Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2012, 12:10 PM
frantic69 frantic69 is offline
Approved Member
 
Join Date: Mar 2010
Posts: 17
Default GamePlay.gpGetAction Question

Hello All,

First of all, thank you for this great forum and all the information we can find. As it is my first post, I take the occasion to say hello to all the COD fan.

My question is regarding this script :

AiAction action = GamePlay.gpGetAction("XXXXXXX");
if (action != null)
{
action.Do();
}

My goal is to constantly test the flight level of an aircraft (I have the flight level thanks to a OnTickGame function and it works fine).

As I don't know the name of the aircraft (the XXXX in the script above), I use the following script :

AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));

It works fine for a OnTrigger() function but it doesn't for a OnTickGame function because missionNumber and shortName do not exist in the OnTickGame context.

So, either I use the exact name XXXXX used by COD mission but I can't find it in the mission file (I tried many name indicated in this file but nothing seems to work) or I use the script above with missionNumber and shortName but it doesn't work in the OnTickGame function.

Have you any Idea of How I can manage this ?

I must say the I search a long time on internet and I tried many thing but nothing works. I am not a specialist of C# and script and I problably make a mistake but I can't see where.

So the full script is something like this :

using System;
using maddox.game;
using maddox.game.world;

public class Mission : maddox.game.AMission
{
double I_Altitude;

public override void OnTickGame()
{

base.OnTickGame();

if (Time.tickCounter() % 30 == 1)
{

AiAircraft curPlane = GamePlay.gpPlayer().Place() as AiAircraft;

if (curPlane != null)
{

I_Altitude = curPlane.getParameter(part.ParameterTypes.I_Altitu de, -1);

double dtime = Time.current();

GamePlay.gpHUDLogCenter(" ALT: " + I_Altitude.ToString("0.00"));

if (I_Altitude > 400)
{
GamePlay.gpHUDLogCenter("above 400");
AiAction action = GamePlay.gpGetAction(maddox.game.ActorName.Full(mi ssionNumber, shortName));
if (action != null)
{
action.Do();
}
}

}


}

}

}


Last point, I would like to thank all the people that post script on internet. As mentioned, I am not a great script maker and I try to understand and reuse existing code. The code above is a made of different script that I found on internet. Thanks to all the guy that made them.

Frantic
Reply With Quote
  #2  
Old 08-09-2012, 01:04 PM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default

You want exact plane names??

extract the names from the below lists.

Dictionary<string, int> LWAvailableAirplanes = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.Bf-109E-3",60},
{"bob:Aircraft.Bf-109E-3B",24},
{"bob:Aircraft.Bf-109E-1",40},
{"bob:Aircraft.Bf-109E-4",10},
{"bob:Aircraft.Bf-109E-4B",24},
{"bob:Aircraft.Bf-110C-4",24},
{"bob:Aircraft.Bf-110C-7",24},
{"bob:Aircraft.Ju-87B-2",60},
{"bob:Aircraft.Ju-88A-1",10},
{"bob:Aircraft.He-111H-2",60},
{"bob:Aircraft.He-111P-2",20},
};
Dictionary<string, int> RAFAvailableAirplanes = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.SpitfireMkIa",30},
{"bob:Aircraft.SpitfireMkI",60},
{"bob:Aircraft.HurricaneMkI",50},
{"bob:Aircraft.HurricaneMkI_dH5-20",50},
{"bob:Aircraft.BlenheimMkIV",40},
{"bob:Aircraft.SpitfireMkIIa",10},
{"bob:Aircraft.SpitfireMkIa_oct",10},
{"bob:Aircraft.HurricaneMkI_100oct",10},
};
__________________
__________________
Win7, 64bit Ultra
Asus P8P67Pro MB
Intel i7-2600K
Coursair 16GB (4x 4GB), DDR3-1600MHz
Gainward Nvidia 580GTX 3GB DDR5
850-Watt Modular Power Supply
WIN7 and COD on Gskill SSD 240GB
40" Panasonic LCD
TrackIR5 +
Thrustmaster Warthog stick, throttle & pedals
Reply With Quote
  #3  
Old 08-09-2012, 01:29 PM
frantic69 frantic69 is offline
Approved Member
 
Join Date: Mar 2010
Posts: 17
Default

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
Reply With Quote
  #4  
Old 08-09-2012, 02:32 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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 02:41 PM.
Reply With Quote
  #5  
Old 08-09-2012, 03:06 PM
frantic69 frantic69 is offline
Approved Member
 
Join Date: Mar 2010
Posts: 17
Default

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.
Reply With Quote
  #6  
Old 08-09-2012, 03:43 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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();
    }
}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:23 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.