Post by keepitsimple on Dec 4, 2014 1:36:05 GMT 1
EDIT:
To make the following work: you need to add MOBILE REINFORMENT. This you do in the mapeditor. Go to AI Settings, select Side 1 and the number 2100 etc. On the map you next go to a unit with this number left click on the unit. A circle will appear below the unit. Move this circle to the position you want to defend (go in the middle small circle and you can move it around it has a light green middle). You will also notice is easy to increase the size of the circle. In mapeditor you will see that under AI Settings now a position is given. You can add more.
If click ones more on the unit ones you get again a circle. This circle is however fixed in that you can't change it size. When you go to middle it has dark green middle. This is PLACEHOLDER want it does is unclear to me (havn't found any connection between this point and the behavior of vehicles).
END Edit
Many of you will know that if you give A supply trucks of AI the script number 2100, 2200 or 2300 then it will resupply ammo and/or humans anywhere on the map. Similarly, this works for engineering trucks. They move and start to repair any damaged unit of AI.
The only problem with this automatic resupply is that AI-trucks will also try to take any unmanned guns from the player. Hence, you get AI-trucks moving straight to your position if a gun is unmanned. I always though this looks strange.
This problem can however easily be solved with the command AddIronMan.
Give all guns of the player a scripted number (tanks or other units are not effected) and then add in the script the line AddIronMan({number});
Now the AI-trucks won't try to take the player's unmanned guns (with this scripted number).
You can give the command AddIronMan(-1); this means all units without a number (=-1) are now not resupplied or repaired by the AI-trucks.
Below is a script I made to use automatic resupply for AI more effectively.
I start off with the command AddIronMan(-1).
function Start()
AddIronMan(-1);
SetIGlobalVar("Versterk2200", 0);
Suicide();
end;
Next I don't want the AI-trucks to close to the front to resupply the AI if the player is near. Hence I have all unit of the AI in the first line numbered 200 and in the second line 201. In front of the first line is an area "Area200" and similarly in front of the second line is area "Area201". As soon as the player enters such an area, the resupply/repair is stopped the first and next the seconded. If somehow all trucks with number 2100 are destroyed by the player then a new group of trucks appears on the map to take over the task.
function RevealObjective0()
ObjectiveChanged(0, 0);
RunScript( "ARM200", 4000);
RunScript( "ARM201", 4000);
RunScript( "Trucks2200", 6000);
Suicide();
end;
-- if the player enters the area defened by units with scripted 200 then AI-trucks no longer resupplying--
function ARM200()
local voor =GetNUnitsInArea(0, "Area200");
if voor>1 then
AddIronMan(200);
Suicide();
end;
end;
-- if the player enters the area defened by units with scripted 200 then AI-trucks no longer resupplying--
function ARM201()
local voor =GetNUnitsInArea(0, "Area201");
if voor>1 then
AddIronMan(201);
Suicide();
end;
end;
function Trucks2200()
local num=GetNUnitsInScriptGroup(2100, 1);
local versterk= GetIGlobalVar("Versterk2200", 0);
if num<1 and versterk==0 then
LandReinforcement(2200);
SetIGlobalVar("Versterk2200", 1);
Suicide();
end;
end;
To make the following work: you need to add MOBILE REINFORMENT. This you do in the mapeditor. Go to AI Settings, select Side 1 and the number 2100 etc. On the map you next go to a unit with this number left click on the unit. A circle will appear below the unit. Move this circle to the position you want to defend (go in the middle small circle and you can move it around it has a light green middle). You will also notice is easy to increase the size of the circle. In mapeditor you will see that under AI Settings now a position is given. You can add more.
If click ones more on the unit ones you get again a circle. This circle is however fixed in that you can't change it size. When you go to middle it has dark green middle. This is PLACEHOLDER want it does is unclear to me (havn't found any connection between this point and the behavior of vehicles).
END Edit
The only problem with this automatic resupply is that AI-trucks will also try to take any unmanned guns from the player. Hence, you get AI-trucks moving straight to your position if a gun is unmanned. I always though this looks strange.
This problem can however easily be solved with the command AddIronMan.
Give all guns of the player a scripted number (tanks or other units are not effected) and then add in the script the line AddIronMan({number});
Now the AI-trucks won't try to take the player's unmanned guns (with this scripted number).
You can give the command AddIronMan(-1); this means all units without a number (=-1) are now not resupplied or repaired by the AI-trucks.
Below is a script I made to use automatic resupply for AI more effectively.
I start off with the command AddIronMan(-1).
function Start()
AddIronMan(-1);
SetIGlobalVar("Versterk2200", 0);
Suicide();
end;
Next I don't want the AI-trucks to close to the front to resupply the AI if the player is near. Hence I have all unit of the AI in the first line numbered 200 and in the second line 201. In front of the first line is an area "Area200" and similarly in front of the second line is area "Area201". As soon as the player enters such an area, the resupply/repair is stopped the first and next the seconded. If somehow all trucks with number 2100 are destroyed by the player then a new group of trucks appears on the map to take over the task.
function RevealObjective0()
ObjectiveChanged(0, 0);
RunScript( "ARM200", 4000);
RunScript( "ARM201", 4000);
RunScript( "Trucks2200", 6000);
Suicide();
end;
-- if the player enters the area defened by units with scripted 200 then AI-trucks no longer resupplying--
function ARM200()
local voor =GetNUnitsInArea(0, "Area200");
if voor>1 then
AddIronMan(200);
Suicide();
end;
end;
-- if the player enters the area defened by units with scripted 200 then AI-trucks no longer resupplying--
function ARM201()
local voor =GetNUnitsInArea(0, "Area201");
if voor>1 then
AddIronMan(201);
Suicide();
end;
end;
function Trucks2200()
local num=GetNUnitsInScriptGroup(2100, 1);
local versterk= GetIGlobalVar("Versterk2200", 0);
if num<1 and versterk==0 then
LandReinforcement(2200);
SetIGlobalVar("Versterk2200", 1);
Suicide();
end;
end;