![]() |
|
|
|
#1
|
|||
|
|||
|
Hello Hc_wolf,
Thank for your help. In fact, in the GamePlay.gpGetAction() we must put the shortname of the unit. As far as I understand, the name can be entered directly thanks to the quote. Here is an example of what can be found on some script on internet : action = GamePlay.gpGetAction("a9"); AiAction action = GamePlay.gpGetAction("0_Chief"); I read that we can find the shortname in the mission file. I found some information and tried them but nothing seems to work. It is for that reason that I tried the AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName)); method but it doesn't work in the ontickgame function. Frantic |
|
#2
|
|||
|
|||
|
Not of the unit, of an Action definded in your mission. The only available action at the moment is the spawn of an AiGroup (AiAirGroup or AiGroundGroup). You define them at the second tab (by Scripts) in the FMB.
![]() In this case the name of the action is MyAction. So you can get access to it via GamePlay.gpGetAction("MyAction"); In the mis file you will find it in the Action Section [Action] MyAction ASpawnGroup 1 BoB_LW_LG2_I.01 Last edited by FG28_Kodiak; 08-09-2012 at 03:41 PM. |
|
#3
|
|||
|
|||
|
hello Kodiak,
Thank you. I saw that there is only few possibilities in the standard action. My goal was to spawn some aircraft when the player altitude goes over 400 ft. I am able to have the altitude of the player. The variable is I_Altitude. I can easily show this altitude on the screen thanks to the GamePlay.gpHUDLogCenter(" ALT: " + I_Altitude.ToString("0.00")); line. All this altitude stuff are done in the ontickgame function. So, tell me if I am wrong but I tried to spawn the enemy aircraft thanks to following script : if (I_Altitude > 400) { GamePlay.gpHUDLogCenter("above 400"); AiAction action = GamePlay.gpGetAction(maddox.game.ActorName.Full(mi ssionNumber, shortName)); if (action != null) { action.Do(); } Could you confirm that we can spawn an aircraft thank to the line above ? If yes, how can I manage to use it in the ontickgame function ? Basically, I don't want to spawn an aircraft after a given time or when someone enter a specific area. I just want to spawn an aircraft when the player altitude is over 400 ft. Sorry for my dumb question. |
|
#4
|
|||
|
|||
|
There are different ways to spawn a new aircraft. Via action is the simplest
To do so, create a new mission, place the Airgroup on the map, enable only script spawn in the Object Options (if you don't do that your Airgroup spawns at beginning of the mission and than again if you call it via action.Do()). Create an action for it in the script -> action tab, give a simple name for example SpawnEnemyPlane, select the airgroup to spawn. Then save and save the mission. Add a flag to the cs file, to avoid multiple spawning of the airgroup Code:
bool Spawned = false; Then in your OnTickGame Code:
if (I_Altitude > 400 && !Spawned)
{
Spawned = true;
GamePlay.gpHUDLogCenter("above 400");
AiAction action = GamePlay.gpGetAction("SpawnEnemyPlane"));
if (action != null)
{
action.Do();
}
}
|
|
#5
|
|||
|
|||
|
Thank you so much Kodiak. That works fine. Before posting I wanted to search and find by myself. I think this is the only way to progress but I was not good enough.
I think it should looks so easy for you but thank you again because was very helpful. thanks to your script I understood manything and I understand now my mistakes. The most important was this part : gpGetAction("SpawnEnemyPlane") I was wrong when I was thinking that the name to put inside the cotes have to be the name found in the mission file. It was simply the name of the trigger you created in the script action box. Thank you, you are a code king. I will probably have some another new questions in the futur and I am happy to think that there is, here on this forum, some very skilled guys like you. Thanks, Frantic |
![]() |
|
|