bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Jul 11, 2015 7:40:22 GMT 1
Well, I'm trying to make a script where the AI calls the ground atack planes in some randoms places. Here is the script I made
But the planes allways attacks the "obj0" zone! I tried some variations of this script, but no way, It allways the same, any clue? thanks, BB
|
|
|
Post by Quintaxel on Jul 11, 2015 9:49:09 GMT 1
bb, I made this script that should do what you want. I did not have time yet to test it with calling airplanes but it works for ground units. Let me know if it works.
function stuka1 () local r = RandomInt (6); -- r will be value between 0 and 5 local o = ("obj"); -- script areas on the map are obj0, obj1,..., obj5 local x, y = GetScriptAreaParams (o.. r); Cmd (36, 999, 1, x,y); Suicide(); end;
Your map should have script areas with names obj0, obj1, obj2, obj3, obj4, obj5.
|
|
|
Post by feldgrau on Jul 11, 2015 14:50:39 GMT 1
Hi pilots The aircraft want to know it exactly. With "GetScriptAreaParams" it does not. It must specify the exact coordinates. Cmd(36, 999, 1, GetScriptAreaParams("obj0"));
example ---> Cmd(36, 999, 1, 3230, 3450); mbkg Feldgrau
|
|
|
Post by Quintaxel on Jul 11, 2015 15:05:26 GMT 1
feldgrauWith local x, y = GetScriptAreaParams (o.. r); I do get the exact coordinates as values x and y, no? Do you mean that Cmd(36, 999, 1, x, y); does not work for planes ?
|
|
|
Post by keepitsimple on Jul 11, 2015 22:52:32 GMT 1
Here is nice script by Cadoudal56 in his map Couleuvre
-- Gere l'aviation du coté ennemi
function Aviation() local t1=GetNUnitsInArea(1, "pont4"); local t2=GetNUnitsInArea(1, "town2"); local t3=GetNUnitsInArea(1, "town1"); local t4=GetNUnitsInArea(1, "pont3"); local tel=GetIGlobalVar("TelBomber", 0); SetIGlobalVar("A_avia", RandomInt(11)); if (GetIGlobalVar("A_avia", 0) <= 2) then Cmd(21, 10000, 1, 14500, 6000); elseif (GetIGlobalVar("A_avia", 0) ==3) then Cmd(21, 10000, 1, 2085, 7397); elseif (GetIGlobalVar("A_avia", 0) <=5) then Cmd(21, 10000, 1, 9941, 4889); elseif (GetIGlobalVar("A_avia", 0) == 6) then SetIGlobalVar("TelBomber", tel+1); if tel<3 then Cmd(19, 10000, 1, 14500, 2000); elseif t4==0 then Cmd(19, 10000, 1, 14285, 10081); elseif t3 ==0 then Cmd(19, 10000, 1, 8870+tel*25, 7866+tel*150); elseif tel==3 and t2<=1 then Cmd(19, 10000, 1, 9869, 5805); elseif tel==4 and t2<=1 then Cmd(19, 10000, 1, 8870, 7866); elseif tel==3 then Cmd(19, 10000, 1, 2107, 8131); elseif t2==0 then Cmd(19, 10000, 1, 9869, 5805); else Cmd(19,10000,1,14780,912); end; elseif (GetIGlobalVar("A_avia", 0) == 7) then if t2>0 then Cmd(20, 10000, 1, 9625, 6005); elseif t1>0 then Cmd(20, 10000, 1, 14372, 6881); elseif t3>0 then Cmd(20, 10000, 1, 10460, 10881); elseif t4>0 then Cmd(20, 10000, 1, 14285, 10081); else Cmd(20, 10000, 1, 11707, 14535); end; elseif (GetIGlobalVar("A_avia", 0) == 8) then if t1>0 then Cmd(22, 999, 1, 14285, 6881); elseif t2>0 then Cmd(22, 999, 1, 9625, 6181); elseif t3>0 then Cmd(22, 999, 1, 10460, 10068); elseif t4>0 then Cmd(22, 999, 1, 14215, 10001); else Cmd(22, 999, 1, 11215, 14501); end; else Cmd(36, 10000, 1, 14500, 2000); end; end;
Notice: There is no suicide command used.
The script run every 10 seconds.
RunScript("Aviation", 10000);
However, the sky is not filled with planes as the AI RELAX TIME is set on 300.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Jul 13, 2015 18:37:28 GMT 1
thanks guys, I'll try Feldgrau version, it fit well in my script. keepitsimple, the SetIGlobalVar script is a total mistery to me...
|
|
|
Post by keepitsimple on Jul 13, 2015 19:44:47 GMT 1
Hi BB,
The SetIGlobalVar command you can give an integer value to variabel that is know through out the script. Hence, global. It is the write statement. It says give the variable name "test" the value I.
SetIGlobalVar("Testl",I)
The read statement, what value has the variable "Test" you need the command GetIGlobalVar("Test",0);
if GetIGlobalVar("Test",0) == I then
In the example: SetIGlobalVar("A_avia", RandomInt(11)); means
Set "A_avia" equal to a random number ranging from 0 to 10.
Alternatively you could have use:
Local a=RandomInt(11);
if a<=2 then Cmd(21, 10000, 1, 14500, 6000); elseif a == 3 then ..
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Jul 14, 2015 4:57:02 GMT 1
hmmm... very interesting, but I cant get well the context to use SetGlobalVar. But I'll start to try.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Jul 25, 2016 16:10:15 GMT 1
Ok, this should be easy to you Quintaxel: I made a map where the player must withdraw all their units in the map to an area called "praia". Player units have different scripts, so I cant call it by a script unit. I tried this if(GetNUnitsInParty(0)==GetNUnitsInArea(0, "praia")) then but it didnt run well, I presume because there are lot of objects and buildings seted as player "1". Any advice?
|
|
|
Post by ariete on Jul 25, 2016 17:14:58 GMT 1
if (GetNUnitsInArea(0, praia) > 10) and if (the other areas where troops could be) < 0) then
quote: I presume because there are lot of objects and buildings seted as player "1".
player 0 you meant anyway Units consider units, not other
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Jul 26, 2016 12:15:30 GMT 1
Buildings and Objects set as player 1 are not being seen as NUnits, so that shouldn't be the problem. The condition if(GetNUnitsInParty(0)==GetNUnitsInArea(0, "praia")) then seems a bit weird to me, but i can't explain why. It seems logical that you want to compare two conditions, but i doubt the game will understand this. You should find a way to check whether player 0 NUnits outside of "praia" ==0.
|
|
|
Post by Quintaxel on Jul 26, 2016 12:25:45 GMT 1
bb. Do I understand it correctly that each unit has a ScriptID ?
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Jul 26, 2016 15:34:47 GMT 1
thanks guys. Yes you're right about the objects and buildings. The problem was the "praia" area wasn't big enough, I tried a different aproach, however, and scripted the areas where the units should whithdraw and use the good and old if (GetNUnitsInArea(0, "areaname") < 1). So, I cant tell you if the script if(GetNUnitsInParty(0)==GetNUnitsInArea(0, "praia")) then runs well.
|
|