PDA

View Full Version : [scripted Mission] Emergency Landing


FG28_Kodiak
04-26-2011, 01:43 PM
I've created this little simple mission to play around with the damage types of CoD.

It triggered a damage if you are close to one of the islands, try to land on one of the Airfield.

I use 9 different types of damages (random), you can expand it or change the damage types by your own. Simply editing the EmergencyLanding.cs script.

Emergency Landing Script:

// Script that triggered an accidental damage to the player plane
// Autor: FG28_Kodiak

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

public class Mission : maddox.game.AMission
{

AiAircraft PlayerPlane;



public override void OnTrigger(int missionNumber, string shortName, bool active)
{
if (("trigger01".Equals(shortName) || "trigger02".Equals(shortName)) && active)
{
DoDamage();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}


private void DoDamage()
{
PlayerPlane = (AiAircraft)GamePlay.gpPlayer().Place();

Random RandomIncident = new Random();

switch (RandomIncident.Next(1,9))
{
case 1:
PlayerPlane.hitNamed(part.NamedDamageTypes.Control sElevatorDisabled);
GamePlay.gpHUDLogCenter("Elevator Disabled");
break;
case 2:
PlayerPlane.hitNamed(part.NamedDamageTypes.Control sAileronsDisabled);
GamePlay.gpHUDLogCenter("Ailerons Disabled");
break;
case 3:
PlayerPlane.hitNamed(part.NamedDamageTypes.Control sRudderDisabled);
GamePlay.gpHUDLogCenter("Rudder Disabled");
break;
case 4:
PlayerPlane.hitNamed(part.NamedDamageTypes.Eng0Pro pBlade0Broken);
GamePlay.gpHUDLogCenter("PropBlade Broken");
break;
case 5:
PlayerPlane.hitNamed(part.NamedDamageTypes.Eng0Tot alFailure);
GamePlay.gpHUDLogCenter("Engine Failure");
break;
case 6:
PlayerPlane.hitNamed(part.NamedDamageTypes.Eng0Oil SecondariesFire);
GamePlay.gpHUDLogCenter("Oil is on fire");
break;
case 7:
PlayerPlane.hitNamed(part.NamedDamageTypes.Hydraul icsPumpFailure);
GamePlay.gpHUDLogCenter("Hydraulics Pump failure");
break;
case 8:
PlayerPlane.hitNamed(part.NamedDamageTypes.Underca rriageDownLockFailureL);
GamePlay.gpHUDLogCenter("UndercarriageDownLock Left failure");
break;
case 9:
PlayerPlane.hitNamed(part.NamedDamageTypes.Eng0Plu g00Failure);
PlayerPlane.hitNamed(part.NamedDamageTypes.Eng0Plu g01Failure);
PlayerPlane.hitNamed(part.NamedDamageTypes.Eng0Plu g05Failure);
GamePlay.gpHUDLogCenter("Engine Plug 0,1,5 failure");
break;
}

}

public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
GamePlay.gpHUDLogCenter("Excellent!");
}

public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
GamePlay.gpHUDLogCenter("Congratulation You are alive ;-)");
}


}





CoD possible Damage Types are:

part.NamedDamageTypes.AirbrakeDriveFailure
part.NamedDamageTypes.AirbrakeHosePerforated
part.NamedDamageTypes.AirbrakePistonFailure
part.NamedDamageTypes.ChunkLargeDamage
part.NamedDamageTypes.ChunkSmallDamage
part.NamedDamageTypes.CockpitDamageFlag00 ... part.NamedDamageTypes.CockpitDamageFlag14
part.NamedDamageTypes.ControlsAileronsDisabled
part.NamedDamageTypes.ControlsElevatorDisabled
part.NamedDamageTypes.ControlsGenericKickdown
part.NamedDamageTypes.ControlsRudderDisabled
part.NamedDamageTypes.ElecBatteryFailure
part.NamedDamageTypes.ElecGeneratorFailure
part.NamedDamageTypes.ElecIlluminationFailure
part.NamedDamageTypes.ElecMasterCompassFailure
part.NamedDamageTypes.ElecPrimaryFailure
part.NamedDamageTypes.ElecPriNavigationFailure
part.NamedDamageTypes.ElecSecNavigationFailure
part.NamedDamageTypes.ElecSecondaryFailure
part.NamedDamageTypes.ElecTransceiverFailure
part.NamedDamageTypes.ElecWeaponryFailure

// Engine Damages Engine0 - Engine7
part.NamedDamageTypes.Eng0CarbControlsFailure
part.NamedDamageTypes.Eng0CarbFailure
part.NamedDamageTypes.Eng0CompressorFailure
part.NamedDamageTypes.Eng0CompressorGovernorFailur e
part.NamedDamageTypes.Eng0CompressorSeizure
part.NamedDamageTypes.Eng0CylinderHeadExtinguished
part.NamedDamageTypes.Eng0CylinderHeadFire
part.NamedDamageTypes.Eng0ExhaustHeadFailure
part.NamedDamageTypes.Eng0FuelLinePerforated
part.NamedDamageTypes.Eng0FuelPumpFailure
part.NamedDamageTypes.Eng0FuelSecondariesFire
part.NamedDamageTypes.Eng0GovernorFailure
part.NamedDamageTypes.Eng0GovernorSeizure
part.NamedDamageTypes.Eng0IntakeBurnt
part.NamedDamageTypes.Eng0IntercoolerBurnt
part.NamedDamageTypes.Eng0Magneto0Failure
part.NamedDamageTypes.Eng0Magneto1Failure
part.NamedDamageTypes.Eng0OilGasketLeak
part.NamedDamageTypes.Eng0OilLineBroken
part.NamedDamageTypes.Eng0OilPumpFailure
part.NamedDamageTypes.Eng0OilRadiatorPerforated
part.NamedDamageTypes.Eng0OilSecondariesExtinguish ed
part.NamedDamageTypes.Eng0OilSecondariesFire
part.NamedDamageTypes.Eng0OilTankPerforated
part.NamedDamageTypes.Eng0Plug00Failure - part.NamedDamageTypes.Eng0Plug17Failure
part.NamedDamageTypes.Eng0PropBlade1Broken - part.NamedDamageTypes.Eng0PropBlade4Broken
part.NamedDamageTypes.Eng0PropControlBroken
part.NamedDamageTypes.Eng0ThrottleControlBroken
part.NamedDamageTypes.Eng0TotalFailure
part.NamedDamageTypes.Eng0TotalSeizure
part.NamedDamageTypes.Eng0TretiaryControlBroken
part.NamedDamageTypes.Eng0WaterJacketBroken
part.NamedDamageTypes.Eng0WaterLineBroken
part.NamedDamageTypes.Eng0WaterPumpFailure
part.NamedDamageTypes.Eng0WaterRadiatorPerforated
part.NamedDamageTypes.Eng0WaterTankPerforated

part.NamedDamageTypes.EngineLargeDamage
part.NamedDamageTypes.EngineSmallDamage
part.NamedDamageTypes.FuelPumpFailure

// Tanks 0 - 7
part.NamedDamageTypes.FuelTank0Exploded
part.NamedDamageTypes.FuelTank0Fire
part.NamedDamageTypes.FuelTank0HosePerforated
part.NamedDamageTypes.FuelTank0LargeLeak
part.NamedDamageTypes.FuelTank0PumpFailure
part.NamedDamageTypes.FuelTank0SmallLeak
part.NamedDamageTypes.FuelTank0TinyLeak

part.NamedDamageTypes.HydraulicsEmergencyFailure
part.NamedDamageTypes.HydraulicsPistonOpened
part.NamedDamageTypes.HydraulicsPrimaryHosePerfora ted
part.NamedDamageTypes.HydraulicsPumpFailure
part.NamedDamageTypes.HydraulicsTankPerforated
part.NamedDamageTypes.LandingFlapsDriveFailure
part.NamedDamageTypes.LandingFlapsHosePerforated
part.NamedDamageTypes.LandingFlapsKinematicFailure 1
part.NamedDamageTypes.LandingFlapsKinematicFailure 2
part.NamedDamageTypes.LandingFlapsPistonFailure1
part.NamedDamageTypes.LandingFlapsPistonFailure2
part.NamedDamageTypes.LifeKeeperPartLargeDamage
part.NamedDamageTypes.LifeKeeperPartSmallDamage


// Weapondamages 00 - 11
part.NamedDamageTypes.Machinegun00BeltBroken
part.NamedDamageTypes.Machinegun00Charged
part.NamedDamageTypes.Machinegun00Failure
part.NamedDamageTypes.Machinegun00Jammed
part.NamedDamageTypes.Machinegun00LineDamaged


part.NamedDamageTypes.PartLargeDamage
part.NamedDamageTypes.PartSmallDamage
part.NamedDamageTypes.PneumaticsCompressorFailure
part.NamedDamageTypes.PneumaticsPrimaryContainerPe rforated
part.NamedDamageTypes.PneumaticsPrimaryHosePerfora ted
part.NamedDamageTypes.PneumaticsSecondaryContainer Perforated
part.NamedDamageTypes.PneumaticsSecondaryHosePerfo rated
part.NamedDamageTypes.UndercarriageDownLockFailure C
part.NamedDamageTypes.UndercarriageDownLockFailure L
part.NamedDamageTypes.UndercarriageDownLockFailure R
part.NamedDamageTypes.UndercarriageDriveDamaged
part.NamedDamageTypes.UndercarriageHosePerforated
part.NamedDamageTypes.UndercarriageKinematicFailur eC
part.NamedDamageTypes.UndercarriageKinematicFailur eL
part.NamedDamageTypes.UndercarriageKinematicFailur eR
part.NamedDamageTypes.UndercarriageShockFailureC
part.NamedDamageTypes.UndercarriageShockFailureL
part.NamedDamageTypes.UndercarriageShockFailureR
part.NamedDamageTypes.UndercarriageUpLockFailureC
part.NamedDamageTypes.UndercarriageUpLockFailureL
part.NamedDamageTypes.UndercarriageUpLockFailureR
part.NamedDamageTypes.WeaponLargeDamage
part.NamedDamageTypes.WeaponSmallDamage
part.NamedDamageTypes.WheelBrakesFailureL
part.NamedDamageTypes.WheelBrakesFailureR
part.NamedDamageTypes.WheelBrakesHosePerforated
part.NamedDamageTypes.WheelBrakesTotalFailure

part.NamedDamageTypes.MaxValue
part.NamedDamageTypes.Nil


Enjoy and sorry for my english :/

Attached single mission:

seiseki
04-26-2011, 01:54 PM
Interesting, would be cool to have a series of missions where your plane is handicapped in some way..

I once tried to shoot down 2 bombers with any aileron control.. Sadly they didn't go down, but they were full of holes..
I was suprised how easy it was to fly with just rudder and elevator..

Now flying with only ailerons and rudder, that would be a challenge..

Stiboo
04-26-2011, 07:17 PM
Nice find

can't wait to we get full instructions/lessons for scripts!


.

tityus
04-27-2011, 12:00 AM
Where could I get scripting info, sintaxes and so?

té mais
tityus

FG28_Kodiak
04-27-2011, 07:12 AM
The scripting language is C# (http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29), so you must use the syntax of this programming language.
In directory ...\SteamApps\common\il-2 sturmovik cliffs of dover\parts\core you find several dlls: maddox.dll, gameworld.dll ...
Then you need for example Visual Studio (Express).
Make a c# project then link the gameworld.dll to the project, for example.
After this you can look at the objects, methods and variables with the Object Explorer of Visual Studio (for mission scripting look at the class AMission).
And now try and error ;).
Examples for Mission scripting you will find in the campaign directories (...\SteamApps\common\il-2 sturmovik cliffs of dover\parts\bob\mission\campaign).
Hope in future there will be a detailed documentation by the developer.

Ataros
04-27-2011, 07:40 AM
CoD possible Damage Types are:


Great you have found this out. I need some help with a script to destroy bots in online missions.

There are 2 issues with online currently:

1) when a player exits a plane AI takes control resulting in too many AI flying around at a server. There is a script to destroy AI after player exit http://forum.1cpublishing.eu/showpost.php?p=268215&postcount=16
the problem with this script is that if a player exits while under attack his plane would disappear making the attacker very disappointed. Discussion is here http://forum.1cpublishing.eu/showthread.php?t=21518&page=3

Possible solution: damage an aircraft upon player exit to make it fall down and destroy it later in 10 minutes after it hits the ground.

2) When AI bombers are scripted to reappear on a server as time goes by the server can become very crowded with AI bombers making it unplayable. Mission example http://forum.1cpublishing.eu/showpost.php?p=273758&postcount=24

The solution would be to damage AI bombers one by one (with 1-2 min intervals) in 15-25 minutes after their last waypoint. OnTaskCompleted()? Then when they fall down destroy them in 10 minutes.

Ideally damage applied to aircraft should be different (say 10 different types of damage) but deadly enough to make aircraft fall down in 1-3 minutes.

If you can make such a script it would be very useful for community I think. Anyway any advice on how to do it would be appreciated as I am not familiar with C#

You are welcome to join our discussion here if you are interested http://forum.1cpublishing.eu/showthread.php?t=21518&page=4

Longbone
04-27-2011, 07:54 AM
Special Thanks to FG28 Kodiak for his nice Script "Wunderbar" :grin:

I hope it is possible to find a way that points also in the other direction for a repair/refuel script etc.



and for tityus

some information can be found in CoD Multiplayer Online War - FMB scripting

http://forum.1cpublishing.eu/showthread.php?t=21518

and take alook at the

http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=ru&tl=en&u=http%3A%2F%2Fwww.sukhoi.ru%2Fforum%2Fshowthread. php%3Ft%3D68369

link from Ataros. Thanks this is a good source.

also please vote for adonys thread

http://forum.1cpublishing.eu/showthread.php?t=22167

to become a FMB subforum to get a grip in this things

like ARMA2 and not search the whole forum for a little peace of information.

Have a nice Day

Ataros
04-27-2011, 08:10 AM
and take alook at the

http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=ru&tl=en&u=http%3A%2F%2Fwww.sukhoi.ru%2Fforum%2Fshowthread. php%3Ft%3D68369

link from Ataros.

Have a nice Day

The whole new section now http://translate.google.com/translate?hl=en&sl=ru&tl=en&u=http%3A%2F%2Fwww.sukhoi.ru%2Fforum%2Fforumdispla y.php%3Ff%3D234

FG28_Kodiak
04-27-2011, 09:26 AM
Great you have found this out. I need some help with a script to destroy bots in online missions.

There are 2 issues with online currently:

1) when a player exits a plane AI takes control resulting in too many AI flying around at a server. There is a script to destroy AI after player exit http://forum.1cpublishing.eu/showpost.php?p=268215&postcount=16
the problem with this script is that if a player exits while under attack his plane would disappear making the attacker very disappointed. Discussion is here http://forum.1cpublishing.eu/showthread.php?t=21518&page=3

Possible solution: damage an aircraft upon player exit to make it fall down and destroy it later in 10 minutes after it hits the ground.

2) When AI bombers are scripted to reappear on a server as time goes by the server can become very crowded with AI bombers making it unplayable. Mission example http://forum.1cpublishing.eu/showpost.php?p=273758&postcount=24

The solution would be to damage AI bombers one by one (with 1-2 min intervals) in 15-25 minutes after their last waypoint. OnTaskCompleted()? Then when they fall down destroy them in 10 minutes.

Ideally damage applied to aircraft should be different (say 10 different types of damage) but deadly enough to make aircraft fall down in 1-3 minutes.

If you can make such a script it would be very useful for community I think. Anyway any advice on how to do it would be appreciated as I am not familiar with C#

You are welcome to join our discussion here if you are interested http://forum.1cpublishing.eu/showthread.php?t=21518&page=4
The easiest way to get a plane down would be to disable its engine and elevator:
.hitNamed(part.NamedDamageTypes.ControlsElevatorDi sabled);
.hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
//for 2mots
.hitNamed(part.NamedDamageTypes.Eng1TotalFailure);
//then wait 10min
Timeout(600.0, () => {
.Destroy();
});

An Alternative for destroying would be to give the plane a new waypoint (Airport) and Action (landing).

At the moment i ve not the possibility to test the script, i will take a look at it, later.

Mington
09-08-2011, 11:26 PM
I must say we are greatly in your debt Kodiak (and Ataros of course!), especially for the heads-up to Microsoft Visual C# 2010 Express software that you told us about earlier in the thread, all very interesting

Your damage script worked perfectly Kodiak when I inserted it into a training mission - in the main map not the Islands map. I landed and got the Excellent message. Scripting seems robust, good work mate :)

Ming

Allons!
09-09-2011, 08:22 AM
Thx to god i already made it through the A-license at JFS.. :) :)