Results 1 to 8 of 8

Thread: TGroupDestroyed issues.

  1. #1
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    TGroupDestroyed issues.

    I am having trouble in use this trigger, work once but no more.

    So I set a simple mission for test, with this script:

    Code:
    //$reference parts/core/Campaign.dll
    //-$debug
    using System;
    using System.IO;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    
    public class Mission : maddox.game.campaign.Mission
    {
           public override void OnBattleStarted()
    	   {
            GamePlay.gpHUDLogCenter("Mission started");
      	   }
    
    public override void OnTrigger(int missionNumber, string shortName, bool active)
    	{	 
    	base.OnTrigger(missionNumber, shortName, active); 
    
              if ("trigger_18".Equals(shortName) && active) 
              { 
                    AiAction action = GamePlay.gpGetAction("trigger_18");
                    if (action != null)
                    {
                         action.Do();
                    }
                    GamePlay.gpHUDLogCenter("Got that Boch!");      
                    GamePlay.gpGetTrigger(shortName).Enable = false;            
              }
    	}
    }
    Code:
    [Trigger]
      trigger_18 TGroupDestroyed BoB_LW_Wekusta_51.01 10
    [Action]
      trigger_18 ASpawnGroup 1 BoB_LW_LG2_I.01
    I though that He-115B was the issue, perhaps because most time when he is shot down over sea became a "ping-pong" ball, but replacing with Do-17 the problem continue, no trigger message, no Bf 109 spawn, just the "Mission started" message.

    I already assure that the other parts of trigger (ASpawAirGroup) is OK, if replace TGroupDestroyed by PassThru or TGroundDestroyed all work.
    Last edited by 1lokos; Nov-17-2020 at 17:03.

  2. #2
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: TGroupDestroyed issues.

    I haven't touched scrpt for a while, but is this where you have to first set the flight you are destroying as the target for the player flight to get the TGroupDestroyed to work?
    I am Yo-Yo not YoYo (that's someone else)

  3. #3
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: TGroupDestroyed issues.

    The (test) mission have only one He 115-B and player flight with two Beaufighters.

    No matter if He 115-B is set as target for the player flight (Attack bombers) or not, nothing related to the trigger happens when He 115-B is shot down (destruction is set in just 5%), no message, no Bf 109 spawn, no console errors report...

    Puzzling is that I are using this script - with others; in a campaign mission, and there work once, but in several (10+) attempts, so I set a simple mission for test and the issue continue. Tested though FMB and as Single Mission, cache cleared.

    I did Steam file validation, some game files are replaced, what is always usual doing this validation, some files are just new copies of the borked speech that I have removed, edited.
    Last edited by 1lokos; Nov-18-2020 at 09:37.

  4. #4
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: TGroupDestroyed issues.

    Sometimes the FMB compile give me this error:



    A file in cache folder can't be write.
    Last edited by 1lokos; Nov-18-2020 at 15:23.

  5. #5
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: TGroupDestroyed issues.

    Simple things, complicate solution...

    Without luck with "TGroupDestroyed "I try load a sub-mission with OnAircraftDamage, work, but every time the enemy plane is hit the sub-mission is loaded again, ending with so many new planes that they colide...

    Many attempts after I find an old scrip that MAY "save the day", using "OnActorDead" (set for an specific plane), just create the "Action" in FMB for spawn the new planes.

    Code:
    using System;
    using System.Collections.Generic;
    using maddox.game;
    using maddox.game.world;
    
    
    public class Mission : AMission
    {
    public override void OnBattleStarted()
    	   {
            GamePlay.gpHUDLogCenter("Mission started");
    		MissionNumberListener = -1;
      	   }
        int planecounter = 0;
    
        
        public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
        {
            base.OnActorDead(missionNumber, shortName, actor, damages);
    
            AiAction MakeNewAircraft = GamePlay.gpGetAction("SpawnNew");
    
            if (actor != null && MakeNewAircraft != null)
            {
                if (actor.Name().Contains("BoB_LW_Wekusta_51.000"))
                {
                    planecounter++;
    
                    if (planecounter >= 1)
                    {
                        MakeNewAircraft.Do();
                        GamePlay.gpHUDLogCenter("New Enemy spawned!");
                    }
                }
            }
        }
     }
    Now let's see if this "mix" with campaign script.

    NOPE.

    The issue now is that for every crew member of He 115-B dead is spawned a new fighter... the thing is if all three die simultaneous three new fighters spawn together and explode.

    There's a way to cancel an "Action" after triggered once?
    Last edited by 1lokos; Nov-19-2020 at 11:36.

  6. #6
    varrattu
    Guest

    Re: TGroupDestroyed issues.

    Hello 1lokos,

    OnActorDestroyed() and OnActorDead() are called every time an AiActor is affected. Give OnAircraftKilled() a try.

    ~V~

    edited: OnAircraftKilled() is true when an AiAircraft is not longer flyable. For example if the pilot get killed or its too heavy damaged.

    PS: Another way could be a <return> or <break> included in your method, i guess.

    Quote Originally Posted by 1lokos View Post
    ... The issue now is that for every crew member of He 115-B dead is spawned a new fighter... the thing is if all three die simultaneous three new fighters spawn together and explode.

    There's a way to cancel an "Action" after triggered once?
    Last edited by varrattu; Nov-19-2020 at 03:31.

  7. #7
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: TGroupDestroyed issues.

    Quote Originally Posted by 1lokos View Post

    There's a way to cancel an "Action" after triggered once?
    You can use a boolean as a flag to show when it has triggered once, and then add an 'and' (represented by && in code I think) to this bit: "if (action != null)". So the code is looking to see if your action is not null AND the flag is false for example.

    Sorry I can't put the actual code here, it is a similar way of doing things as I did in the stuka attack problem if you check the code there I think, also if you look in the code for the bf108 mission for the WIP campaign I sent you it uses a flag to determine the end mission message depending on whether the 108 was destroyed or not I think. Also there is a random process that fires only once when the 108 is damaged, that uses a flag to stop it firing each time the 108 is damaged.

    The logic for it is this:

    Create a boolean (eg actionFired) and set to False

    When your event fires, so aircraft damaged, go to an IF that checks if your action is not null AND that the flag is False, then, set it to True

    Next time the aircraft is damaged, because the flag has changed and your IF is checking for a 'False' value to do the action it won't do it.



    Sorry if that is no help.
    I am Yo-Yo not YoYo (that's someone else)

  8. #8
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: TGroupDestroyed issues.

    Thanks for the help.

    I think this resolve the question. So far no multiple spawns.

    Code:
    bool stopFlag = false;   
    .
    .
    .
      
    public override void OnAircraftDamaged(int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiDamageInitiator initiator, part.NamedDamageTypes damageType)
     {
            if (shortName.Contains("BoB_LW_Wekusta_ObdL.000") && stopFlag == false)
            {
                        AiAction Action1 = GamePlay.gpGetAction("Aspawn");
                        if (Action1 != null)
                            Action1.Do();
                        stopFlag = true;
    					GamePlay.gpHUDLogCenter("Got that Boch!");	
                        return;             
            }
     }
    or

    Code:
    bool stopFlag = false;   
    .
    .
    .
    public override void OnAircraftKilled(int missionNumber, string shortName, AiAircraft aircraft)
    {
          base.OnAircraftKilled(missionNumber, shortName, aircraft);
          if (shortName.Contains("BoB_LW_Wekusta_51.000") && stopFlag == false)
          {     
                AiAction Action1 = GamePlay.gpGetAction("Aspawn");
                if (Action1 != null)
                Action1.Do();
                stopFlag = true;
    			GamePlay.gpHUDLogCenter("Got that Boch!");	
                return;  
          }
    }
    Last edited by 1lokos; Nov-20-2020 at 20:26.

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
  •