|
Post by keepitsimple on Apr 17, 2012 22:27:52 GMT 1
Getting more one types of ground-attack plane in single player map?
In the map-editor you increase number of players with one with diplomacy.
Player 3 is now the neutral party. Player 2 is now also for the player.
In Map Unit Creation Property (plane selection) player 2 is available. You can now add a second attack-plane;fighter;scout;bomber;lander; as well as second para group.
There is one drawback. The player can't control it. Only by script the second planes can be called. Here is example how airborne-troops can made available to the player
function Drop() SetIGlobalVar("ParadropSquad.ScriptID", 999);{gives id-number 999 to para's} Cmd(22,2,2,GetScriptAreaParams("Dropzone"));{=22 drop para, 2 = air-transport, 2 = party, in map area 'dropzone'} RunScript( "HaveLanded", 24000); Suicide(); end; function HaveLanded() local para=GetNScriptUnitsInArea(999,"Dropzone"); if (para>=100) then {"100" = number of para's drop; every para counts for one}} ChangePlayer(999,0); {para are available to player} Suicide(); end; end;
Instead of the player you can of course also increase the planes types for the AI. In diplomacy made player 2 for party 1. If you first DisableAviation(1, -1); you can with script sent in planes (in the beginning you know where the player is) from player 2. Later on you can EnableAviation and are sure that AI still has planes left.
Want to check if player i (0=player;1 =AI; 2 =depends on you) still has a plane type?
GetNUnitsOfType("avia_attack",i) GetNUnitsOfType("avia_bomber",i) GetNUnitsOfType("avia_lander",i) GetNUnitsOfType("avia_fighter",i) GetNUnitsOfType("avia_scout",i)
|
|
|
Post by Major Pain on Apr 18, 2012 1:56:40 GMT 1
Bravo.... well played sir...
Thank you for bringing this subject back to the forefront!
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 18, 2012 14:11:33 GMT 1
Yeah, well played, that's a great idea.
|
|
|
Post by keepitsimple on May 10, 2012 23:16:38 GMT 1
|
|
|
Post by keepitsimple on May 14, 2012 21:43:28 GMT 1
Some good and some bad news
The bad news: GetNUnitsOfType("avia_bombers",2) Gives the number of planes player 2 has original, not how many player 2 still has left.
The good news: some script to send bombers and attack planes for player 2 over and over again till none are left.
function Bomber() local AviaState = GetAviationState(2); DisplayTrace("Bomber1"); -- For testing: you must make sure the planes have return home before -- sent on the next mission. With this text you can test if -- time set before the next function start is long enough -- Don't forget to take it away in the final game ;D -- player 2 last planes were: no plane (-1) or attack plane (4) if ((AviaState ==-1) or (AviaState ==4)) then Cmd(19,4,2,GetScriptAreaParams("BorderPost")); RunScript( "AttackPlane",120000,1); Suicide(); end; -- player 2 last planes were bombers --> no more attack planes if AviaState == 3 then Cmd(19,4,2,GetScriptAreaParams("BorderPost")); RunScript( "Bomber2",120000,1); Suicide(); end; end;
function AttackPlane() local AviaState = GetAviationState(2); DisplayTrace("AttackPlane"); -- for testing see above -- player 2 last planes were bombers if AviaState == 3 then Cmd(36,3,2,GetScriptAreaParams("BorderPost")); RunScript( "Bomber",240000,1); Suicide(); end; -- player 2 last planes were attack planes --> no more bombers if AviaState == 4 then Cmd(36,3,2,GetScriptAreaParams("BorderPost")); RunScript( "Attackplane2",240000,1); Suicide(); end; end;
function Bomber2() RunScript( "Bomber",1200,1); Suicide(); end;
function Attackplane2() RunScript( "Attackplane",1200,1); Suicide(); end;
Of course randomizing the target would make it even more interesting
|
|
|
Post by keepitsimple on Jun 30, 2012 22:02:27 GMT 1
CLOSE AIR SUPPORT Want to give the player control over planes from player 2 or higher? This is how you can do it. To give control over scout, fighter or ground-attack planes you introduce a radio officer(car). The officer has a number (here 280) and if it gets close to the enemy (<=distance) then plane(s) (here ground-attack) are send to coordination's of the officer(car). Only if office(car) is close to the enemy, the planes are send in. As long as this is not the case, the test if officer is now close enough is fastly repeated. function CloseAirSupport1() local distance = 1200; local X1,Y1 = GetObjCoord(280); local num1 = GetNUnitsInCircle(1, X1 ,Y1, 2*distance); local alive1 = GetNUnitsInScriptGroup(280, 0); if (num1>= 1) and (alive1==1) then Cmd(36,4,2,X1,Y1); RunScript( "CloseAirSupport12", 240000,1); Suicide(); end; if (num1 ==0) and (alive1==1) then Cmd(36,4,2,X1,Y1); RunScript( "CloseAirSupport12", 1000,1); Suicide(); end; end; CloseAirSupport12 is copy of CloseAirSupport1 (calling in 1 where the first calls in 12) To use bombers is more difficult. If you copy above, your bombers go to bomb your officer(car). It can be done as I show in this map. With just ground-attack planes and bombers you are expected to win. A test of your close air support skills ;D The map is for RT or BHRT www.mediafire.com/?34qc4gs4rd4rcas
|
|
Ocelo
General
Map Artist/Eastern Front enthusiast
Posts: 1,400
|
Post by Ocelo on Jul 4, 2012 0:36:12 GMT 1
I have a somewhat simpler question (2 actually):
1. How can I disable the player's bomber aviation at startup, and then enable it later in the mission?
2. What would be a specific function to call enemy ground attack aircraft to point XX, YY on the map? (if I could copy+paste, would be great).
Thanks!
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,356
|
Post by bb on Jul 4, 2012 3:27:16 GMT 1
Hi ocelo, 1. DisableAviation(0, 3); after: EnableAviation( 0,3 );
2. Here is my secret: first make a script area in the map, lets call it "deploy2". Now just put it in your script: Cmd(36, 999, 1, GetScriptAreaParams("deploy2"));
No need of x, y, this script runs well with all comands. Check my scripts, I never use X, y just the GetScriptAreaParams.
I learnt this with Stalingrad scripts.
|
|
|
Post by keepitsimple on Jul 4, 2012 15:42:50 GMT 1
For player 0: BB rightly points out that with: DisableAviation(0, 3); later EnableAviation( 0,3 )
For player 2 or higher: You have to work with script to get them. So you control in the script the time they come.
I show here that by using an unit as "marker" you can make planes from player 2 (or higher) controllable by the player. He can determine were they go (not the script). I my case there is the limit that your marker has to be close to the enemy. Hence, close air support.
As BB said: you have the player to take an area. If he has done this it bombed or attack by the enemy. With GetScriptAreaParams("deploy2") the very easy. Otherwise, you have the get X and Y coordinates from the map. Instead of GetScriptAreaParams("deploy2")
I also use GetObjCoord(iScriptID). This command send the enemy plane to a specific unit or building. Give a bridge a number and then send in the bombers to destroy it. ;D
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,356
|
Post by bb on Jul 4, 2012 23:25:09 GMT 1
I also use GetObjCoord(iScriptID). This command send the enemy plane to a specific unit or building. Give a bridge a number and then send in the bombers to destroy it. ;D Hey! Nice tip! How do you write this script? Cmd(36, 999, 1, GetObjCoord(iScriptID))?
|
|
|
Post by keepitsimple on Jul 5, 2012 0:15:02 GMT 1
Yes But be careful, if you use this command to get a bomber, the bomber will bomb your "marker". With ground-attack this doesn't happen. The ground-attack plane will fly to your "marker" and will look for enemy units close by to attack.
|
|
|
Post by keepitsimple on Sept 1, 2015 9:16:32 GMT 1
The problem with AI-bomber for player 2 is that you need to send it to specific coordinates. I made the following script to make this slightly more intelligent. In this example the AI-bomber are send every 12 minutes to the location of one the players heavy guns if this gun was firing within the last two minutes.
RunScript("Fired1",30000,1); RunScript("JU88",720000);
-- test if a heavy gun was fired less then two minutes ago --
-- if a gun has fired then this test is repeat after two minutes, the trigger to send bomber is set and the coordinates are set -- -- if no guns have fired the test is repeat every 30 seconds -- -- if none of guns are left this command stops running --
function Fired1() local leeft1=GetNUnitsInScriptGroup(2111,0); local leeft2=GetNUnitsInScriptGroup(2112,0); local leeft3=GetNUnitsInScriptGroup(2113,0); local stat1 = GetUnitState(2111); local stat2 = GetUnitState(2112); local stat3 = GetUnitState(2113); local x1,y1 =GetObjCoord(2111); local x2,y2 =GetObjCoord(2112); local x3,y3 =GetObjCoord(2113); if ((leeft1==1) and ((stat1==16) or (stat1==34))) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x1); SetIGlobalVar( "CoordinatesBomberY", y1); RunScript("Fired2",120000,1); elseif ((leeft2==1) and ((stat2==16) or (stat2==34))) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x2); SetIGlobalVar( "CoordinatesBomberY", y2); RunScript("Fired2",120000,1); elseif ((leeft3==1) and ((stat3==16) or (stat3==34))) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x3); SetIGlobalVar( "CoordinatesBomberY", y3); RunScript("Fired2",120000,1); elseif leeft1+leeft2+leeft3>0 then SetIGlobalVar( "SendBomber", 0); RunScript("Fired2",30000,1); else SetIGlobalVar( "SendBomber", 2); Suicide(); end; end;
function Fired2() local leeft1=GetNUnitsInScriptGroup(2111,0); local leeft2=GetNUnitsInScriptGroup(2112,0); local leeft3=GetNUnitsInScriptGroup(2113,0); local stat1 = GetUnitState(2111); local stat2 = GetUnitState(2112); local stat3 = GetUnitState(2113); local x1,y1 =GetObjCoord(2111); local x2,y2 =GetObjCoord(2112); local x3,y3 =GetObjCoord(2113); if leeft1==1 and ((stat1==16) or (stat1==34)) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x1); SetIGlobalVar( "CoordinatesBomberY", y1); RunScript("Fired1",120000,1); elseif leeft2==1 and ((stat2==16) or (stat2==34)) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x2); SetIGlobalVar( "CoordinatesBomberY", y2); RunScript("Fired1",120000,1); if leeft3==1 and ((stat3==16) or (stat3==34)) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x3); SetIGlobalVar( "CoordinatesBomberY", y3); RunScript("Fired1",120000,1); elseif leeft1+leeft2+leeft3>=1 then SetIGlobalVar( "SendBomber", 0); RunScript("Fired1",30000,1); else SetIGlobalVar( "SendBomber", 2); Suicide(); end; end;
-- If the bomber trigger is set then the bomber are send -- -- if no of the heavy guns are left SendBomber==2 then this command stops running--
function JU88() local bomb= GetIGlobalVar( "SendBomber", 0); local x= GetIGlobalVar( "CoordinatesBomberX", 0); local y= GetIGlobalVar( "CoordinatesBomberY", 0); if bomb==1 then Cmd(19,3,2,x,y); elseif bomb==2 then Suicide(); end; end;
|
|
|
Post by keepitsimple on Sept 1, 2015 13:08:05 GMT 1
I made a little improvement on the previous script. More general usable. To make this work the new function Fired must me put below the function Init as shown here.
RunScript("RunFired",30000); RunScript("JU88",720000);
-- in this example guns are number 101, 201 and 2113 --
function RunFired() Fired(101,201,2113); end;
-- if a gun was fired less then two minutes ago bomber are send --
function JU88() local bomb= GetIGlobalVar( "SendBomber", 0); local x= GetIGlobalVar( "CoordinatesBomberX", 0); local y= GetIGlobalVar( "CoordinatesBomberY", 0); if bomb==1 then Cmd(19,3,2,x,y); elseif bomb==2 then Suicide(); end; end;
--------------------------------------------------------- --------------- INIT ------------------ ---------------------------------------------------------
function Init() RunScript("Start", 10); RunScript("DebugView", 1000); RunScript( "RevealObjective0", 4000); RunScript( "Objective0", 26000); RunScript("ToDefeat", 4000); end;
--------------------------------------------------------- --------------- New command: Fired ------------------ ---------------------------------------------------------
-- Input parameter are iScriptId1, iScriptId2, iScriptID3 -- -- If a gun fires then trigger is set and bombers are give the coordinates -- -- If all gun stop firing then trigger remain active until the command has run 4 times-- -- If still no gun is firing then trigger is taken off --
-- If all guns are destroyed then the command stops --
function Fired(iScriptID1, iScriptID2, iScriptID3) local leeft1=GetNUnitsInScriptGroup(iScriptID1,0); local leeft2=GetNUnitsInScriptGroup(iScriptID2,0); local leeft3=GetNUnitsInScriptGroup(iScriptID3,0); local stat1 =GetUnitState(iScriptID1); local stat2 =GetUnitState(iScriptID2); local stat3 =GetUnitState(iScriptID3); local x1,y1 =GetObjCoord(iScriptID1); local x2,y2 =GetObjCoord(iScriptID2); local x3,y3 =GetObjCoord(iScriptID3); local tel =GetIGlobalVar( "TelBomber", 0); if ((leeft1==1) and ((stat1==16) or (stat1==34))) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x1); SetIGlobalVar( "CoordinatesBomberY", y1); SetIGlobalVar( "TelBomber", 1); -- DisplayTrace("Fired 1"); elseif ((leeft2==1) and ((stat2==16) or (stat2==34))) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x2); SetIGlobalVar( "CoordinatesBomberY", y2); SetIGlobalVar( "TelBomber", 1); --DisplayTrace("Fired 2"); elseif ((leeft3==1) and ((stat3==16) or (stat3==34))) then SetIGlobalVar( "SendBomber", 1); SetIGlobalVar( "CoordinatesBomberX", x3); SetIGlobalVar( "CoordinatesBomberY", y3); SetIGlobalVar( "TelBomber", 1); --DisplayTrace("Fired 3"); elseif ((leeft1+leeft2+leeft3>=1) and (tel>0) and (tel< 5)) then SetIGlobalVar( "TelBomber", tel+1); --DisplayTrace("Not Fired : %g",tel+1); elseif ((leeft1+leeft2+leeft3>=1) and (tel==5)) then SetIGlobalVar( "TelBomber", 0); SetIGlobalVar( "SendBomber", 0); --DisplayTrace("No Bombers"); elseif (leeft1+leeft2+leeft3 ==0) then SetIGlobalVar( "SendBomber", 2); Suicide(); end; end;
|
|
|
Post by ariete on Sept 3, 2015 12:54:57 GMT 1
thank you keep it simple for the great tutorial. you're a master, thank you again and always.
|
|
|
Post by keepitsimple on Sept 4, 2015 10:34:28 GMT 1
Testing the latest version shown that sending bombers to coordinates of the players gun means the destruction of the gun if player doesn't destroy the bombers.
This might no be very popular so I though it might be good to add some random disperse on the coordinates. If that could be linked to setting (playing easy or hard) that would be nice. More disperse for easy and little disperse for hard.
Hence my question:
Can you link to general setting of the player gameplay (EASY, NORMAL, HARD)?
|
|