-
Could someone create a script that sets an engine on fire after a certain time?
I am sure this can be done but do not know how to do it.
I would like to create a simple mission but then add a script that sets an engine on fire for a chosen aircraft?
Would anyone script gurus be able to share one please and how to change it to a different aircraft if required? Thanks, Mysticpuma
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Somewhat like this?
:salute: ~V~
Addendum 06.11.2019:
Unfortunately the code doesn't work with all <NamedDamageTypes>.
Means the following code doesn't work with Eng0CylinderHeadFire etc.
Sorry ~V~
Code:
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission {
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) {
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft aircraft = player.Place() as AiAircraft;
GamePlay.gpLogServer(null, aircraft.ToString(), new object [] { });
if (aircraft.Player(0) != null) {
player = aircraft.Player(0);
GamePlay.gpLogServer(null, player.ToString(), new object [] { });
/// Remove the player from the aircraft for a few ms.
/// A workaround to do damage to player aircraft.
player.PlaceLeave(0);
Timeout(0.1, () => {
aircraft.hitNamed(part.NamedDamageTypes.Eng0CylinderHeadFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng0FuelSecondariesFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng0OilSecondariesFire);
player.PlaceEnter(aircraft, 0);
});
}
}
}
-
Re: Could someone create a script that sets an engine on fire after a certain time?
I have no idea!
Okay, so I copy that text onto a notepad then save it as?
Then.... where does it go....... then how do I make it affect an aircraft?
Honestly, you are dealing with a code/script novice, what you have written is akin to a musician reading music (which I can't do either :))
Basically I want to be able to fly a 109 but have it chase a Wellington. I would like the Wellingtons starboard engine to catch fire approx 1 minute into the mission.
I can set the mission up.... I just need to know how this script can make the Wellingtons right engine catch fire a minute into the mission?
Thanks so much for your help so far :)
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Copy the code and save it as CS file: example.cs
Rename the .cs file to the same name as your mission .mis file and put it into the same directory.
:salute: ~V~
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Is there also a script, to be used only online, to set instantly afire every Red aircraft getting too close to my Bf 110 tail? :)
-
1 Attachment(s)
Re: Could someone create a script that sets an engine on fire after a certain time?
Quote:
Originally Posted by
varrattu
Somewhat like this?
:salute: ~V~
Code:
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission {
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) {
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft aircraft = player.Place() as AiAircraft;
GamePlay.gpLogServer(null, aircraft.ToString(), new object [] { });
if (aircraft.Player(0) != null) {
player = aircraft.Player(0);
GamePlay.gpLogServer(null, player.ToString(), new object [] { });
/// Remove the player from the aircraft for a few ms.
/// A workaround to do damage to player aircraft.
player.PlaceLeave(0);
Timeout(0.1, () => {
aircraft.hitNamed(part.NamedDamageTypes.Eng0CylinderHeadFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng0FuelSecondariesFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng0OilSecondariesFire);
player.PlaceEnter(aircraft, 0);
});
}
}
}
Thanks again varrattu, I have attached the very simple mission, taken out my aircraft. Simply put, is it possible to set the right engine of the Wellington on fire after 30 to 60 seconds?
Cheers, MP
Attachment 41570
-
Re: Could someone create a script that sets an engine on fire after a certain time?
I think you can adjust the timeout. Or you could add a trigger in the FMB so when the plane flies into the radius you set, it would fire that script.
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Unfortunately the workaround doesn't work with all <NamedDamageTypes>.
Means the code I provided with post #2 doesn't work with Eng0CylinderHeadFire etc....
Sorry. I will come with a new try asap.
:salute: ~V~
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Next try. But I promise, it works :thumbsup:
Have fun:)
:salute: ~V~
Code:
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission
{
/// choose aircraft to be damaged
string targetAiAircraft = "Wellington";
/// choose delay for damage
int delayInSeconds = 10;
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
if (player.Place() != null)
{
Point3d playerPos3d = player.Place().Pos();
DamageTargetAiAircraft(playerPos3d, delayInSeconds, targetAiAircraft);
}
}
public void DamageTargetAiAircraft(Point3d playerPos3d, int timeInSeconds, string targetType)
{
foreach (int army in GamePlay.gpArmies())
{
if (GamePlay.gpAirGroups(army) != null)
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (group.GetItems() != null)
foreach (AiActor actor in group.GetItems())
{
if ((actor as AiAircraft) != null
&& (actor as AiAircraft).InternalTypeName().Contains(targetType))
{
Timeout(timeInSeconds, () => {
AiAircraft aircraft = actor as AiAircraft;
aircraft.hitNamed(part.NamedDamageTypes.Eng1CylinderHeadFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng1FuelSecondariesFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng1OilSecondariesFire);
});
}
}
}
}
}
}
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Quote:
Originally Posted by
SKG 210_Mölders
Is there also a script, to be used only online, to set instantly afire every Red aircraft getting too close to my Bf 110 tail? :)
YES. But need to pay the host :devilish:
:salute:~V~
-
1 Attachment(s)
Re: Could someone create a script that sets an engine on fire after a certain time?
Great script, varratu! :)
If you want, here's your mission with the script working, Neil. You'll spawn as a Bf-109 E-3 so you just right click to select planes, select the Wellington and wait for it to burn (30sec). :D
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Thank you for your contribution, danperin.
I didn't delete a few snippets (pieces) of code, which are from another version (distance based).
So if you want,
delete line 22:
Point3d playerPos3d = player.Place().Pos();
then you need to change line 31:
public void DamageTargetAiAircraft(Point3d playerPos3d, int timeInSeconds, string targetType)
in line 31:
public void DamageTargetAiAircraft(int timeInSeconds, string targetType)
:salute:~V~
Quote:
Originally Posted by
danperin
Great script, varratu! :)
If you want, here's your mission with the script working, Neil. You'll spawn as a Bf-109 E-3 so you just right click to select planes, select the Wellington and wait for it to burn (30sec). :D
-
Re: Could someone create a script that sets an engine on fire after a certain time?
AND OF COURSE ...
then you also need to change line 24:
DamageTargetAiAircraft(playerPos3d, delayInSeconds, targetAiAircraft);
to line 24:
DamageTargetAiAircraft(delayInSeconds, targetAiAircraft);
:salute:~V~
Quote:
Originally Posted by
varrattu
Thank you for your contribution, danperin.
I didn't delete a few snippets (pieces) of code, which are from another version (distance based).
So if you want,
delete line 22:
Point3d playerPos3d = player.Place().Pos();
then you need to change line 31:
public void DamageTargetAiAircraft(Point3d playerPos3d, int timeInSeconds, string targetType)
in line 31:
public void DamageTargetAiAircraft(int timeInSeconds, string targetType)
:salute:~V~
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Quote:
Originally Posted by
varrattu
Next try. But I promise, it works :thumbsup:
Have fun:)
:salute: ~V~
Code:
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission
{
/// choose aircraft to be damaged
string targetAiAircraft = "Wellington";
/// choose delay for damage
int delayInSeconds = 10;
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
if (player.Place() != null)
{
Point3d playerPos3d = player.Place().Pos();
DamageTargetAiAircraft(playerPos3d, delayInSeconds, targetAiAircraft);
}
}
public void DamageTargetAiAircraft(Point3d playerPos3d, int timeInSeconds, string targetType)
{
foreach (int army in GamePlay.gpArmies())
{
if (GamePlay.gpAirGroups(army) != null)
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (group.GetItems() != null)
foreach (AiActor actor in group.GetItems())
{
if ((actor as AiAircraft) != null
&& (actor as AiAircraft).InternalTypeName().Contains(targetType))
{
Timeout(timeInSeconds, () => {
AiAircraft aircraft = actor as AiAircraft;
aircraft.hitNamed(part.NamedDamageTypes.Eng1CylinderHeadFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng1FuelSecondariesFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng1OilSecondariesFire);
});
}
}
}
}
}
}
Thank you very much for your time and effort. The detail and ability of CloD to create some amazing scenarios is exceptional. Best wishes, Mysticpuma
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Quote:
Originally Posted by
varrattu
AND OF COURSE ...
then you also need to change line 24:
DamageTargetAiAircraft(playerPos3d, delayInSeconds, targetAiAircraft);
to line 24:
DamageTargetAiAircraft(delayInSeconds, targetAiAircraft);
:salute:~V~
:recon:
-
1 Attachment(s)
Re: Could someone create a script that sets an engine on fire after a certain time?
Here's the version with varrattu’s changes :thumbsup:
:-)
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Just a note, for multiplayer environments you may want to add this:
Code:
public override void Init(ABattle battle, int missionNumber)
{
base.Init(battle, missionNumber);
MissionNumberListener = -1;
}
this way the script will listen to all missions in a battle.
Quote:
Originally Posted by
varrattu
Somewhat like this?
:salute: ~V~
Addendum 06.11.2019:
Unfortunately the code doesn't work with all <NamedDamageTypes>.
Means the following code doesn't work with Eng0CylinderHeadFire etc.
Sorry ~V~
Code:
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission {
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) {
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft aircraft = player.Place() as AiAircraft;
GamePlay.gpLogServer(null, aircraft.ToString(), new object [] { });
if (aircraft.Player(0) != null) {
player = aircraft.Player(0);
GamePlay.gpLogServer(null, player.ToString(), new object [] { });
/// Remove the player from the aircraft for a few ms.
/// A workaround to do damage to player aircraft.
player.PlaceLeave(0);
Timeout(0.1, () => {
aircraft.hitNamed(part.NamedDamageTypes.Eng0CylinderHeadFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng0FuelSecondariesFire);
aircraft.hitNamed(part.NamedDamageTypes.Eng0OilSecondariesFire);
player.PlaceEnter(aircraft, 0);
});
}
}
}
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Just curious about a thing ( maybe ) related to scripts...Is it possible to create, using a script, a sort of very basic " Aircraft Black Box " to record, into a log file for example, aircraft data like speed, data, altitude, etc during a LAN session for example?
I'm meaning something really " naked and raw " that could provides/extract only the data indicated above.
Especially for aircraft tests and training sessions should be extremely usefull, IMHO, having something like this.
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Klick here and find out
:salute: ~V~
Quote:
Originally Posted by
SKG 210_Mölders
Just curious about a thing ( maybe ) related to scripts...Is it possible to create, using a script, a sort of very basic " Aircraft Black Box " to record, into a log file for example, aircraft data like speed, data, altitude, etc during a LAN session for example?
I'm meaning something really " naked and raw " that could provides/extract only the data indicated above.
Especially for aircraft tests and training sessions should be extremely usefull, IMHO, having something like this.
-
Re: Could someone create a script that sets an engine on fire after a certain time?
Thank you very much mate! To add it to the mission same process as described above correct?