PDA

View Full Version : OnAircraftTookOff broken?


theOden
02-24-2014, 07:31 PM
I have these simple overrides but "OnAircraftTookOff" just refuse to trigger.
Back in the old days I built a simple BoB campaign using this among others and unless I'm way too senile by now this used to work?

I slapped in "OnPlaceEnter" for reference and that bugger does work.

Anyone more up-to-date with Dover than me who knows what might be missing?

TF 4.0 is in use btw and no errors in log.txt and the gpLogServer never shows in the log either.




public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

GamePlay.gpLogServer(null, "OnPlaceEnter '{0}' '{1}'", new object[] { actor.Name(), placeIndex });
GamePlay.gpHUDLogCenter("OnPlaceEnter");
}

public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
GamePlay.gpLogServer(null, "OnAircraftTookOff '{0}' '{1}'", new object[] { shortName, aircraft.TypedName() });
GamePlay.gpHUDLogCenter("OnAircraftTookOff");
bool activateBombers = false;
if (GamePlay.gpIsServerSingle())
{ // player CAP
if (aircraft.Player(0) != null)
if (!activateBombers)
activateBombers = true;
} else {
if(aircraft.Player(0) != null)
activateBombers = true;
if (!activateBombers)
foreach (Player p in GamePlay.gpRemotePlayers())
if (aircraft == (AiAircraft)p.Place())
activateBombers = true;
};
activateBombers = true;
if(activateBombers)
{
if (!bWellington)
{
GamePlay.gpHUDLogCenter("Wellington bombers are inbound from the north, escort them to target");
bWellington = true;
AiAction action = GamePlay.gpGetAction("redAirborne");
if (action != null) action.Do();
};
};
}





Edit:
Ok, this function is singleplayer only it seems.
Starting to remember why I dropped this product a few ago..
Pure Quality.

Edit2:
Nope, function runs ok in both SP and MP - unless you delete all SP planes when hosted in MP.
Need to create another solution I guess.

salmo
02-27-2014, 12:46 AM
I can confirm that the OnAircraftTookOff event works in both SP & MP modes. If it's not achieving what you want then it must be your code itself.

theOden
02-27-2014, 04:27 AM
Yes, I've already confirmed SP/MP in my "Edit2".
It's a small loop in OnBattleStarted that removes all singleplayer planes, including "player", that has the extra effect of totally disabling this override (not even GamePlay.gpLogServer shows up if I keep the "clean-up code").

Was hoping to get the mission working in both SP and MP (as I always do in ArmA2) but I can keep all files but .mis as "unified code base" and I guess that is good enough (only removing the player flight before repacking as MP).

Anyway, thank you for your effort - I remember your name as a helpful one from earlier :)