Results 1 to 7 of 7

Thread: Ground unit scripted spawn

  1. #1
    Supporting Member
    Join Date
    Dec 2019
    Posts
    213
    Post Thanks / Like
    Total Downloaded
    11.46 MB

    Ground unit scripted spawn

    As there is no Action in the FMB for makign ground units spawn, is it possible to manually add an action to the .mis file then use it in script?

    If so, is there an example somewhere so I can check it?

    Thanks.

    I am Yo-Yo not YoYo (that's someone else)

  2. #2
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    4,946
    Post Thanks / Like
    Total Downloaded
    961.56 MB

    Re: Ground unit scripted spawn

    I use ASpawnGroup action for spawn vehicles too, works OK.

    E.G. t2 ASpawnGroup 0 0_Chief

    Once spawn ships too, but these are not consistent.
    Last edited by 1lokos; Sep-14-2020 at 12:08.

  3. Likes Yo-Yo liked this post
  4. #3
    Supporting Member
    Join Date
    Dec 2019
    Posts
    213
    Post Thanks / Like
    Total Downloaded
    11.46 MB

    Re: Ground unit scripted spawn

    Great many thanks.

    I am Yo-Yo not YoYo (that's someone else)

  5. #4
    ATAG Member ATAG_Ribbs's Avatar
    Join Date
    Jan 2012
    Posts
    1,939
    Post Thanks / Like
    Total Downloaded
    4.11 MB

    Re: Ground unit scripted spawn

    I am having a problem in my mission as to in the scripts tab in the fmb not saving my Trigger/action. I can place them and save them. Close the tab open it back up and they are there. I close the tab again and attemt to test it and nothing happens. Go back in the scripts tab and the text is gone. If i go into the .mis file it is still there, but wont fire in game. No matter what i try ( running it on local server/ or straight out of the FMB set as a single player , it wont save my Trigger/ action in the fmb. The only thing i havent tried was starting a brand new mission, placing the needed objects and creating the Trigger/ actuon to see if it will save it then. Any other ideas?
    Also another question. When you create the trigger/ action, and set the object to be spawned.. lets say a vehicle. That vehicle will be flashing after selected. Are you hitting save at that point or do you unselect the vehicle first then hit save in the scripts tab. Ive tried both ways.
    Cheers
    Ribbs

    INTEL I5 4670 /16 MB DDR3/ MSI Z97 PCMATE MB
    MSI GTX 1060 3 GIG
    WIN 7 64
    MS Sidewinder 2 precision pro Saitek x52 throttle quadrant


    By ATAG_Lewis

  6. #5
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    4,946
    Post Thanks / Like
    Total Downloaded
    961.56 MB

    Re: Ground unit scripted spawn

    Action (ASpawnGroup) you set in FMB only work if you don't have any script code (C#) this mission, if have the action is override and don't fire, require c# script for re-enable.

    Trigger name and action name should be the same, e.g. a1 and a1 (or you need use C# code and set for look for "ActionName" - see // comment in script bellow).

    Using only FMB trigger and action I am able to spawn a vehicle that will fire another trigger that will spawn another vehicle.

    When you set a vehicle to 'trigger' or to 'action" using the set "sight" vehicle name appear in action window (normally Chief#), if are not working, try use Army (red or blue).

    Testing adding this code in "script" tab in FMB - after right click and run "compile" to check for errors.


    Code:
    using System;
    using System.IO;
    using System.Collections;
    using maddox.game;
    using maddox.game.world;
    
    public class Mission : AMission
    {
       public override void OnTrigger(int missionNumber, string shortName, bool active)
       {
            base.OnTrigger(missionNumber, shortName, active);
    
            if ("trigger name".Equals(shortName))
            {
                AiAction Action = GamePlay.gpGetAction(shortName); // if your 'action' has an other Name than your trigger change GamePlay.gpGetAction(shortName) into GamePlay.gpGetAction("ActionName")
    
                if (Action != null)
                    Action.Do();
    			    GamePlay.gpLogServer(null, "xyz", new object[] { }); //Message in Server Info window confirming trigger fired.
    			  {
                GamePlay.gpGetTrigger(shortName).Enable = false; // if trigger is TPassThru disable after fire once to avoid multiple activation
    
                return; // leave method to avoid second call of the Action
            }
    If trigger and action is set OK you see a message in Server info Window (what you put in "xyz"). If all are OK you can remove (optional) the "xyz" line after.

    BTW - An 'trigger' firing don't warrant a 'action' firing, my issue in this topic, my 'action' is off in some part.
    Last edited by 1lokos; Sep-15-2020 at 11:03.

  7. #6
    ATAG Member ATAG_Ribbs's Avatar
    Join Date
    Jan 2012
    Posts
    1,939
    Post Thanks / Like
    Total Downloaded
    4.11 MB

    Re: Ground unit scripted spawn

    Ok thanks.. I should have mentioned I do have 2 different Triggers/ action going already in this mission so setting them isnt too much of a problem. But just for some reason when i set this 3rd trigger/action it wont save. So that is where I'm stumped.
    Cheers
    Ribbs

    INTEL I5 4670 /16 MB DDR3/ MSI Z97 PCMATE MB
    MSI GTX 1060 3 GIG
    WIN 7 64
    MS Sidewinder 2 precision pro Saitek x52 throttle quadrant


    By ATAG_Lewis

  8. #7
    Supporting Member
    Join Date
    Dec 2019
    Posts
    213
    Post Thanks / Like
    Total Downloaded
    11.46 MB

    Re: Ground unit scripted spawn

    Quote Originally Posted by ATAG_Ribbs View Post
    Ok thanks.. I should have mentioned I do have 2 different Triggers/ action going already in this mission so setting them isnt too much of a problem. But just for some reason when i set this 3rd trigger/action it wont save. So that is where I'm stumped.
    I have no idea sorry.

    Check all the actions have different names, and all the triggers have different names. Also maybe just make sure the triggers and actions are not called the same in anyway. (You'd have to make sure to name them properly in the script for getAction do.Action etc.)

    Avoid loading a different mission with a .mis file in the FMB if you were editing another before without closing the FMB and coming back in. I think I've seen previous script show up sometimes.

    I always compile before saving the script, and always save mission too before testing.

    I am Yo-Yo not YoYo (that's someone else)

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
  •