Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   strange behaviour of some function ( classes?) (http://forum.fulqrumpublishing.com/showthread.php?t=32332)

pupo162 05-24-2012 10:48 AM

strange behaviour of some function ( classes?)
 
Im havign a mission with my current mission wich is a little bit of a pain, since i think its not a code problem. ( i will psot the code later)

but the

-ifplayercrashlanded
-ifplayerlanded
-playerisairbourne

function / classes, give faulty resoults.

some times i land, and the the trigger is not launched, others i crash land, and same happens (even with a basic "hello world" ),

To overcome this i created a refly menu option who uses "player is airbourne function), yet some times im safe and sound on the ground and this still doesnt work :S

this is kind of ruining my scripting efforts. Is this an ingame recurrent issue?

FG28_Kodiak 05-24-2012 12:25 PM

-ifplayercrashlanded
depends on Location, if you crashed near or at a Airfield, its not triggered you get a regular landing.

-ifplayerlanded
Works normal for me in Single and Player hosted server, Problems sometimes on dedicated.

-playerisairbourne
works normal for me.

Let me see your code, please

pupo162 05-24-2012 04:00 PM

code will be available here in a coupel of hours...

sorry admins, i posted this in the wrong place, can you move this to the FMB forum? thats were it was supposed to be in :S

Blackdog_kt 05-24-2012 10:23 PM

Roger, will move to FMB forum ;)

pupo162 05-25-2012 06:28 AM

Thnaks blackdog!

Quote:


public override void OnOrderMissionMenuSelected(Player player, int ID, int menuItemIndex)
{
base.OnOrderMissionMenuSelected(player, ID, menuItemIndex);

if (player != null)
{
if (menuItemIndex == 1)
{
GamePlay.gpHUDLogCenter(new Player[] { player }, "Red - {0} blue - {1}", new object[] { redscore, bluescore });
setMainMenu(player);

}
if (menuItemIndex == 2)
{
GamePlay.gpHUDLogCenter(new Player[] { player }, "Ainda nao funciona");
setMainMenu(player);
}
if (menuItemIndex == 3)
{

if (player.Place() != null && player.Place() is AiAircraft)
{
AiAircraft aircraft = player.Place() as AiAircraft;

if (!aircraft.IsAirborne())
{

int value = 0;

if (player != null)

switch (player.Army())
{
case 1:
if (rafa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
rafa[(aircraft as AiAircraft).InternalTypeName()] = value + 1;
GamePlay.gpHUDLogCenter(new Player[] { player }, "You will refly in 5 seconds!");
Timeout(5, () => { destroyPlane(aircraft); });
}

break;

case 2:
if (lwa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
lwa[(aircraft as AiAircraft).InternalTypeName()] = value + 1;
GamePlay.gpHUDLogCenter(new Player[] { player }, "You will refly in 5 seconds!");
Timeout(5, () => { destroyPlane(aircraft); });
}
break;
}
else
GamePlay.gpHUDLogCenter(new Player[] { player }, "Refly is not possible if Airbourne!");
}
}
setMainMenu(player);

}

}
}

this function works perfectly for newly spawn planes, but if take a short circuit and land, or crash, it no longer works, im sitted in my plane and i get the ""Refly is not possible if Airbourne!""

crashlanded was working ok last night, but was giving issues the other one,

Quote:

base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);

Player player = null;

for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null)
{
// TODO: Account for more than one player in an aircraft
player = aircraft.Player(i);
break;
}
}

int value = 0;


if (aircraft.Player(0) != null)

if (player != null)


switch (player.Army())
{
case 1:
if (rafa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
bluescore = bluescore + rafv[(aircraft as AiAircraft).InternalTypeName()];
GamePlay.gpHUDLogCenter(new Player[] { player }, "You crashed!, {0} : LOST!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) });
Timeout(20, () =>
{ destroyPlane(aircraft); });
}

break;

case 2:
if (lwa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
redscore = redscore + lwv[(aircraft as AiAircraft).InternalTypeName()];
GamePlay.gpHUDLogCenter(new Player[] { player }, "You crashed!, {0} : LOST!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) });
Timeout(20, () =>
{ destroyPlane(aircraft); });
}
break;
}
same thing for onplayerlanded, works 90% of the time, its the 10% who get me mad :(

Quote:

public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);

Player player = null;

for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null)
{
// TODO: Account for more than one player in an aircraft
player = aircraft.Player(i);
break;
}
}

int value = 0;


if (aircraft.Player(0) != null)

if (player != null)


switch (player.Army())
{
case 1:
if (rafa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
rafa[(aircraft as AiAircraft).InternalTypeName()] = value + 1;
GamePlay.gpHUDLogCenter(new Player[] { player }, "Welcome Home, {0} : saved!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) });
Timeout(20, () =>
{ destroyPlane(aircraft); });
}

break;

case 2:
if (lwa.TryGetValue((aircraft as AiAircraft).InternalTypeName(), out value))
{
lwa[(aircraft as AiAircraft).InternalTypeName()] = value + 1;
GamePlay.gpHUDLogCenter(new Player[] { player }, "Welcome Home, {0} : saved!", new object[] { SplitName((aircraft as AiAircraft).InternalTypeName()) });
Timeout(20, () =>
{ destroyPlane(aircraft); });

}
break;

}
}

FG28_Kodiak 05-25-2012 06:54 AM

For IsAirborne you can make your own

Simply check:
(actor as AiAircraft).getParameter(part.ParameterTypes.Z_Alt itudeAGL, -1)
(actor as AiAircraft).getParameter(part.ParameterTypes.Z_Vel ocityTAS, -1)

First is Height over Ground, Second is True Airspeed in m/sec.

So if for exampe
Code:

(actor as AiAircraft).getParameter(part.ParameterTypes.Z_AltitudeAGL, -1) <= 1.0
and
Code:

(actor as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1) <= 1.0
you can get shure the plane is on the ground, but you should test the Values.

For checking if plane is Damaged you can use
Code:

(actor as AiAircraft).getParameter(part.ParameterTypes.M_Health, -1)
== 1 if not damaged < 1 if damaged

pupo162 05-25-2012 09:32 AM

soudns amazing. so i can actually get in flight parameters fo the planes? that could be usefull for a lot of stuff!

i will work furthter on this tomorrow, no time today... :(

is the 1.0 in meters and killometers? on the check speed and altitude?


also does
Quote:

(actor as AiAircraft).getParameter(part.ParameterTypes.M_Hea lth, -1)
can be used for static planes? im havign this "issue" where i strafe enemey parked (Ground object) planes, and they are left burning, yet they dont count as destroyed. if i could use this, maybe i could give the points to the team according to the damage done to straffed planes?

thanks Kodiak,

FG28_Kodiak 05-25-2012 09:43 AM

meters, all return values are metric


All times are GMT. The time now is 01:13 PM.

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