PDA

View Full Version : Rearm, Refuel, Repair and De-Spawning Script



Nitrous
Feb-10-2014, 16:51
Hi Guys,

I'm not great with typing on forums so excuse my emotionless post.

Is there any of you C# wiz-kids out there who are willing to share parts of scripts that I can use.

I'm am after;

Rearm Refuel and Repair

and

De-spawning aircraft, only when the human player leaves the aircraft and creates another aircraft.

Apologies again I don't type on forums much, my thing is talking, not typing:)

If I have not given enough detail I apologise. Please ask for more.

~S~

♣_Spiritus_♣
Feb-11-2014, 00:13
I may be wrong but rearming/refueling isn't available yet. I know it will be back in the game whenever 4.02 comes out. As far as the other one, I have no idea, sorry.

No601_Swallow
Feb-11-2014, 02:07
This is the despawning script that we're using at the moment:


private bool isAiControlledPlane(AiAircraft aircraft)
{
if (aircraft == null)
{
return false;
}


Player[] players = GamePlay.gpRemotePlayers();
foreach (Player p in players)
{
if (p != null && (p.Place() is AiAircraft) && (p.Place() as AiAircraft) == aircraft)
{
return false;
}
}
return true;
}

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{ damageAiControlledPlane(actor); }
);
}

private void damageAiControlledPlane(AiActor actor)
{
if (actor == null || !(actor is AiAircraft))
{
return;
}


AiAircraft aircraft = (actor as AiAircraft);


if (!isAiControlledPlane(aircraft))
{
return;
}


if (aircraft == null)
{
return;
}


aircraft.hitNamed(part.NamedDamageTypes.ControlsEl evatorDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsAi leronsDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsRu dderDisabled);
aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFa ilure);
aircraft.hitNamed(part.NamedDamageTypes.Eng0TotalF ailure);
aircraft.hitNamed(part.NamedDamageTypes.Eng1TotalF ailure);


Timeout(5, () =>
{ destroyPlane(aircraft); }
);
}

private void destroyPlane(AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.Destroy();
}
}

It's a pared down version of the despawn-everything script that I think everyone uses from the Banana Forum. I have no idea why or how it works, but it's fine for us in our "coop" ops missions. It removes the aeroplane after the player leaves, though, not when a player creates a new aeroplane.

Nitrous
Feb-11-2014, 14:36
I may be wrong but rearming/refueling isn't available yet. I know it will be back in the game whenever 4.02 comes out. As far as the other one, I have no idea, sorry.

Thanks for the info mortem.


This is the despawning script that we're using at the moment:


private bool isAiControlledPlane(AiAircraft aircraft)
{
if (aircraft == null)
{
return false;
}


Player[] players = GamePlay.gpRemotePlayers();
foreach (Player p in players)
{
if (p != null && (p.Place() is AiAircraft) && (p.Place() as AiAircraft) == aircraft)
{
return false;
}
}
return true;
}

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{ damageAiControlledPlane(actor); }
);
}

private void damageAiControlledPlane(AiActor actor)
{
if (actor == null || !(actor is AiAircraft))
{
return;
}


AiAircraft aircraft = (actor as AiAircraft);


if (!isAiControlledPlane(aircraft))
{
return;
}


if (aircraft == null)
{
return;
}


aircraft.hitNamed(part.NamedDamageTypes.ControlsEl evatorDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsAi leronsDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsRu dderDisabled);
aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFa ilure);
aircraft.hitNamed(part.NamedDamageTypes.Eng0TotalF ailure);
aircraft.hitNamed(part.NamedDamageTypes.Eng1TotalF ailure);


Timeout(5, () =>
{ destroyPlane(aircraft); }
);
}

private void destroyPlane(AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.Destroy();
}
}

It's a pared down version of the despawn-everything script that I think everyone uses from the Banana Forum. I have no idea why or how it works, but it's fine for us in our "coop" ops missions. It removes the aeroplane after the player leaves, though, not when a player creates a new aeroplane.

Thanks Swallow much appreciated.

fruitbat
Feb-11-2014, 18:49
I too would love to know how the rrr works on the ATAG server and implement it on our dangerdogz training server, but understand if unwilling to share.