Results 1 to 20 of 20

Thread: Could someone create a script that sets an engine on fire after a certain time?

  1. #1
    Ace Mysticpuma's Avatar
    Join Date
    Dec 2012
    Location
    Worcestershire, UK
    Posts
    5,132
    Post Thanks / Like
    Blog Entries
    1
    Total Downloaded
    2.38 GB

    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
    "The needs of the Flight Sim Community outweigh the needs of the one or the few"

  2. #2
    varrattu
    Guest

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Somewhat like this?

    ~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);
                });
            }
    
        }
    }
    Last edited by varrattu; Nov-06-2019 at 09:15.

  3. Likes DUI, danperin, Rostic liked this post
  4. #3
    Ace Mysticpuma's Avatar
    Join Date
    Dec 2012
    Location
    Worcestershire, UK
    Posts
    5,132
    Post Thanks / Like
    Blog Entries
    1
    Total Downloaded
    2.38 GB

    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
    "The needs of the Flight Sim Community outweigh the needs of the one or the few"

  5. #4
    varrattu
    Guest

    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.

    ~V~

  6. #5
    Ace Erpr.Gr.210_Mölders's Avatar
    Join Date
    Dec 2015
    Location
    Italy
    Posts
    2,452
    Post Thanks / Like
    Total Downloaded
    1,002.26 MB

    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?
    Last edited by Erpr.Gr.210_Mölders; Nov-06-2019 at 06:20.
    Visit the Robert Mölders Facebook Group ( Left-click on the red link on the left to open the relative page! )
    Visit the Robert Mölders YouTube Channel ( Left-click on the red link on the left to open the relative page! )
    *Important Note: You can also open the Robert Mölders Facebook Group page by clicking directly on my signature image


    My PC specs
    Windows 10 Pro 64 bit ~ Intel Core i7-7700K 4.2GHz 8MB Cache Quad core
    ASUS ROG STRIX Z270H GAMING Motherboard, Socket 1151 ATX, Dual M.2, USB 3.1 Type-C ~ MSI GeForce GTX 1080 TI Gaming X 11G Graphic Card PCIE 3.0, 11 GB, GDDR5X 352 bit, 11.01 GHz, 1569 MHz
    Samsung MZ-V6E250BW SSD 960 EVO, 250 GB, M.2, NVMe ~ Western Digital WD Caviar Blue 2TB 64MB Cache, WD20EZRZ (64MB Cache) ~ Enermax Liqmax II 240 (ELC-LMR240S-BS)
    Corsair CMK16GX4M2B3000C15 Vengeance LPX RAM 16 GB, 2x8 GB, DDR4, 3000 MHz, CL15 ~ EVGA SuperNOVA GQ PSU 750W ~ NZXT CA-N450W-M1 Case for Gaming PC, Black
    LG 49UK6200PLA TV 49" 4K UltraHD, IPS Display, 4096 x 2160, Active HDR, Multitasking ~ LG 27UD68P Monitor 27" 4K UltraHD LED IPS, 3840 x 2160, AMD FreeSync, Multitasking
    Thrustmaster T.16000M FCS Joystick ~ Thrustmaster TWCS Throttle ~ Thrustmaster TFRP Pedals

  7. Likes \Hawk/ liked this post
  8. #6
    Ace Mysticpuma's Avatar
    Join Date
    Dec 2012
    Location
    Worcestershire, UK
    Posts
    5,132
    Post Thanks / Like
    Blog Entries
    1
    Total Downloaded
    2.38 GB

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Quote Originally Posted by varrattu View Post
    Somewhat like this?

    ~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

    Wellington for fire.zip
    "The needs of the Flight Sim Community outweigh the needs of the one or the few"

  9. #7
    Team Fusion ♣_Spiritus_♣'s Avatar
    Join Date
    Dec 2013
    Location
    The Demon-Haunted World: Science as a Candle in the Dark
    Posts
    5,600
    Post Thanks / Like
    Blog Entries
    2
    Total Downloaded
    0

    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.

  10. #8
    varrattu
    Guest

    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.

    ~V~
    Last edited by varrattu; Nov-06-2019 at 09:17.

  11. Likes Mysticpuma liked this post
  12. #9
    varrattu
    Guest

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Next try. But I promise, it works

    Have fun

    ~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);
    
                                    });
                                }
                            }
                    }
            }
        }
    }

  13. Likes danperin, Gingerbread, Rostic liked this post
  14. #10
    varrattu
    Guest

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Quote Originally Posted by SKG 210_Mölders View Post
    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

    ~V~

  15. Likes Erpr.Gr.210_Mölders, danperin liked this post
  16. #11
    Team Fusion danperin's Avatar
    Join Date
    Dec 2012
    Location
    Sao Paulo, Brazil
    Posts
    1,955
    Post Thanks / Like
    Total Downloaded
    806.84 MB

    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).
    Attached Files Attached Files
    Last edited by danperin; Nov-06-2019 at 22:59.

  17. Likes N/A, Gingerbread liked this post
  18. #12
    varrattu
    Guest

    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)

    ~V~

    Quote Originally Posted by danperin View Post
    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).

  19. Likes danperin liked this post
  20. #13
    varrattu
    Guest

    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);

    ~V~

    Quote Originally Posted by varrattu View Post
    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)

    ~V~

  21. Likes danperin liked this post
  22. #14
    Ace Mysticpuma's Avatar
    Join Date
    Dec 2012
    Location
    Worcestershire, UK
    Posts
    5,132
    Post Thanks / Like
    Blog Entries
    1
    Total Downloaded
    2.38 GB

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Quote Originally Posted by varrattu View Post
    Next try. But I promise, it works

    Have fun

    ~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
    "The needs of the Flight Sim Community outweigh the needs of the one or the few"

  23. #15
    Ace Mysticpuma's Avatar
    Join Date
    Dec 2012
    Location
    Worcestershire, UK
    Posts
    5,132
    Post Thanks / Like
    Blog Entries
    1
    Total Downloaded
    2.38 GB

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Quote Originally Posted by varrattu View Post
    AND OF COURSE ...

    then you also need to change line 24:
    DamageTargetAiAircraft(playerPos3d, delayInSeconds, targetAiAircraft);

    to line 24:
    DamageTargetAiAircraft(delayInSeconds, targetAiAircraft);

    ~V~
    "The needs of the Flight Sim Community outweigh the needs of the one or the few"

  24. #16
    Team Fusion danperin's Avatar
    Join Date
    Dec 2012
    Location
    Sao Paulo, Brazil
    Posts
    1,955
    Post Thanks / Like
    Total Downloaded
    806.84 MB

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Here's the version with varrattu’s changes

    Attached Files Attached Files
    Last edited by danperin; Nov-08-2019 at 06:53.

  25. Likes Mysticpuma liked this post
  26. #17
    Team Fusion xoriguer's Avatar
    Join Date
    Mar 2017
    Location
    Elx
    Posts
    377
    Post Thanks / Like
    Total Downloaded
    43.95 MB

    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 View Post
    Somewhat like this?

    ~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);
                });
            }
    
        }
    }

  27. Likes danperin liked this post
  28. #18
    Ace Erpr.Gr.210_Mölders's Avatar
    Join Date
    Dec 2015
    Location
    Italy
    Posts
    2,452
    Post Thanks / Like
    Total Downloaded
    1,002.26 MB

    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.
    Last edited by Erpr.Gr.210_Mölders; Nov-08-2019 at 06:20.
    Visit the Robert Mölders Facebook Group ( Left-click on the red link on the left to open the relative page! )
    Visit the Robert Mölders YouTube Channel ( Left-click on the red link on the left to open the relative page! )
    *Important Note: You can also open the Robert Mölders Facebook Group page by clicking directly on my signature image


    My PC specs
    Windows 10 Pro 64 bit ~ Intel Core i7-7700K 4.2GHz 8MB Cache Quad core
    ASUS ROG STRIX Z270H GAMING Motherboard, Socket 1151 ATX, Dual M.2, USB 3.1 Type-C ~ MSI GeForce GTX 1080 TI Gaming X 11G Graphic Card PCIE 3.0, 11 GB, GDDR5X 352 bit, 11.01 GHz, 1569 MHz
    Samsung MZ-V6E250BW SSD 960 EVO, 250 GB, M.2, NVMe ~ Western Digital WD Caviar Blue 2TB 64MB Cache, WD20EZRZ (64MB Cache) ~ Enermax Liqmax II 240 (ELC-LMR240S-BS)
    Corsair CMK16GX4M2B3000C15 Vengeance LPX RAM 16 GB, 2x8 GB, DDR4, 3000 MHz, CL15 ~ EVGA SuperNOVA GQ PSU 750W ~ NZXT CA-N450W-M1 Case for Gaming PC, Black
    LG 49UK6200PLA TV 49" 4K UltraHD, IPS Display, 4096 x 2160, Active HDR, Multitasking ~ LG 27UD68P Monitor 27" 4K UltraHD LED IPS, 3840 x 2160, AMD FreeSync, Multitasking
    Thrustmaster T.16000M FCS Joystick ~ Thrustmaster TWCS Throttle ~ Thrustmaster TFRP Pedals

  29. #19
    varrattu
    Guest

    Re: Could someone create a script that sets an engine on fire after a certain time?

    Klick here and find out

    ~V~

    Quote Originally Posted by SKG 210_Mölders View Post
    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.

  30. Likes Erpr.Gr.210_Mölders, danperin liked this post
  31. #20
    Ace Erpr.Gr.210_Mölders's Avatar
    Join Date
    Dec 2015
    Location
    Italy
    Posts
    2,452
    Post Thanks / Like
    Total Downloaded
    1,002.26 MB

    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?
    Visit the Robert Mölders Facebook Group ( Left-click on the red link on the left to open the relative page! )
    Visit the Robert Mölders YouTube Channel ( Left-click on the red link on the left to open the relative page! )
    *Important Note: You can also open the Robert Mölders Facebook Group page by clicking directly on my signature image


    My PC specs
    Windows 10 Pro 64 bit ~ Intel Core i7-7700K 4.2GHz 8MB Cache Quad core
    ASUS ROG STRIX Z270H GAMING Motherboard, Socket 1151 ATX, Dual M.2, USB 3.1 Type-C ~ MSI GeForce GTX 1080 TI Gaming X 11G Graphic Card PCIE 3.0, 11 GB, GDDR5X 352 bit, 11.01 GHz, 1569 MHz
    Samsung MZ-V6E250BW SSD 960 EVO, 250 GB, M.2, NVMe ~ Western Digital WD Caviar Blue 2TB 64MB Cache, WD20EZRZ (64MB Cache) ~ Enermax Liqmax II 240 (ELC-LMR240S-BS)
    Corsair CMK16GX4M2B3000C15 Vengeance LPX RAM 16 GB, 2x8 GB, DDR4, 3000 MHz, CL15 ~ EVGA SuperNOVA GQ PSU 750W ~ NZXT CA-N450W-M1 Case for Gaming PC, Black
    LG 49UK6200PLA TV 49" 4K UltraHD, IPS Display, 4096 x 2160, Active HDR, Multitasking ~ LG 27UD68P Monitor 27" 4K UltraHD LED IPS, 3840 x 2160, AMD FreeSync, Multitasking
    Thrustmaster T.16000M FCS Joystick ~ Thrustmaster TWCS Throttle ~ Thrustmaster TFRP Pedals

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •