
For the rest, if you find the rule interesting, I will ask you to provide me with the script to incorporate in the current scenarios, for a future patch.
Code: Select all
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ADD GARRISON
// Ajoute une garnison à la faction
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function TScriptEngine.AddGarrison(Params : TStringList) : integer;
var
AreaUID : TUID;
StrucKind : TUID;
UnitUID : TUID;
Chance : integer;
begin
Result := 0;
if (Params.Count <> 8) then
begin
Inc(Result);
Log(['=> Add Garrison , syntax is: AddGarrison = AreaUID ; StrucKindUID ; UnitDefUID ; ChancePerRPL; PlaceHolder1; PlaceHolder2; PlaceHolder3; PlaceHolder4']);
end;
if (cuFaction = nil) then
begin
Inc(Result);
Log(['=> AddGarrison: No faction selected']);
end;
AreaUID := STI(Params[0]);
StrucKind := STI(Params[1]);
UnitUID := STI(Params[2]);
Chance := STI(Params[3]);
if (AreaUID < 0) or (AreaUID > Areas.Count-1) then
begin
Inc(Result);
Log(['=> Add Garrison , Erroneous AreaUID', AreaUID]);
end;
if (StrucKind < _noUID) or (StrucKind > _stuMax) then
begin
Inc(Result);
Log(['=> Add Garrison , Erroneous StrucKind', StrucKind]);
end;
if (UnitUID < 0) or (UnitUID > ListUnitDefs.Count-1) then
begin
Inc(Result);
Log(['=> Add Garrison , Erroneous UnitUID', UnitUID]);
end;
if (Chance <= 0) then
begin
Inc(Result);
Log(['=> Add Garrison , Erroneous Chance value', Chance]);
end;
if Result > 0 then Exit;
cuFaction.AddGarrisonsInfos(AreaUID, StrucKind, UnitUID, Chance);
Log(['Add Garrison , Added this garrison:', 'AreaUID:', AreaUID, 'StrucKind:', StrucKind, 'UnitDefUID:', UnitUID, 'ChancePerRPL:', Chance]);
end;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CLEAR GARRISONS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function TScriptEngine.ClearGarrisons(Params : TStringList) : integer;
begin
Result := 0;
if (Params.Count > 0) then
begin
Log(['=> [WARNING] Clear Garrisons Garrison , syntax is: ClearGarrisons, no parameter are needed.']);
end;
if (cuFaction = nil) then
begin
Inc(Result);
Log(['=> Clear Garrisons: No faction selected']);
end;
if Result > 0 then Exit;
cuFaction.ClearGarrisonsInfos;
Log(['Clear Garrisons , All Garrisons cleared for faction', cuFaction.UID, cuFaction.Name]);
end;
Pocus wrote:New Commands: AddGarrison & ClearGarrisons
Concept: Auto Garrisoning
Clovis wrote:OK I've put the new data at the end of the variousevents.xls file:
Rafiki wrote:Clovis, is this something you have done/are doing work on? I'd like to take a shot at it, either from scratch or building off the work already done
(I want to become more familiar with how modding/scripting works)
Pocus wrote:You are missing the 4 placeholders data at the end of the command, they are needed.
AddGarrison = $NY;-1;$mdl_CSA_Inf10;10;x;x;x;x
the command must be in the setup or within an event. It does not seem to be the case in your xls excerpt.
The garrison has 10% chance of appearing in your case, for each RPL you have in stock of the type needed by the unit you use (regular I guess). Region which qualify are: has a depot, has a fort, or has a city of level 7+
city level variable is not exported yet. you have to strike the balance between adding garrison in a sufficient number of place and not sucking the rpl pool by adding them everywhere, so it seems ok to me.
Return to “Modding AGE engine games”
Users browsing this forum: No registered users and 8 guests