Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Creep Revival System Not Work

Discussion in 'Triggers & Scripts' started by Siegfird, Jul 24, 2013.

  1. Siegfird

    Siegfird

    Joined:
    Oct 24, 2012
    Messages:
    26
    Resources:
    0
    Resources:
    0
    Initialization
    • Creep Revival System Initialization
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Unit Group - Pick every unit in (Units in PlayRegion <gen> owned by Neutral Hostile) and do (Actions)
          • Loop - Actions
            • Set Integer = (Integer + 1)
            • Unit - Set the custom value of (Picked unit) to Integer
            • Custom script: set udg_Creep_X[udg_Integer] = GetUnitX(GetEnumUnit())
            • Custom script: set udg_Creep_Y[udg_Integer] = GetUnitX(GetEnumUnit())


    Revive Creep
    • Revive Creep 1 by 1
      • Events
        • Unit - A unit Dies
      • Conditions
        • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
      • Actions
        • Wait 5.00 game-time seconds
        • Set tempPoint[1] = (Center of (Entire map))
        • Set tempPoint[2] = (tempPoint[1] offset by (Creep_X[(Custom value of (Triggering unit))], Creep_Y[(Custom value of (Triggering unit))]))
        • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at tempPoint[2] facing (Random angle) degrees
        • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
        • Custom script: call RemoveLocation(udg_tempPoint[1])
        • Custom script: call RemoveLocation(udg_tempPoint[2])


    Im cannot create unit. Please help
     
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,429
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    It should work in some cases. However, if the unit doesn't have a corpse, then it won't work. After the 5 second wait, "Unit-type of (Triggering unit)" will return 0 for units without corpses. I'm guessing this is where your problem is.

    The fix is to declare the variables before the wait. However, that would make the trigger no longer MUI. You will have to use local variables. Make two global variables, one named "TempCustomValue" and the other named "TempId" of type "Integer". Then use the following trigger:
    • Revive Creep 1 by 1
      • Events
        • Unit - A unit Dies
      • Conditions
        • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
      • Actions
        • Custom script: local integer cv = GetUnitUserData(GetTriggerUnit())
        • Custom script: local integer typeId = GetUnitTypeId(GetTriggerUnit())
        • Wait 5.00 game-time seconds
        • Custom script: set udg_TempCustomValue = cv
        • Custom script: set udg_TempId = typeId
        • Set tempPoint[1] = (Center of (Entire map))
        • Set tempPoint[2] = (tempPoint[1] offset by (Creep_X[TempCustomValue], Creep_Y[TempCustomValue]))
        • Unit - Create 1 TempId for Neutral Hostile at tempPoint[2] facing (Random angle) degrees
        • Unit - Set the custom value of (Last created unit) to TempCustomValue
        • Custom script: call RemoveLocation(udg_tempPoint[1])
        • Custom script: call RemoveLocation(udg_tempPoint[2])


    This will create locals, and then assign the globals to them after the wait (maintaining the MUI aspect). That way, you can use them in your GUI functions. You can also do local variable shadowing if you know how.
     
  3. deathismyfriend

    deathismyfriend

    Joined:
    Oct 24, 2012
    Messages:
    6,526
    Resources:
    14
    Spells:
    12
    Tutorials:
    2
    Resources:
    14
    purge u should just shadow global variables.

    @TO
    u can look at my tutorial things a guier should know about local variables and shadowing global variables. this will show u how to use them.
     
  4. caleman

    caleman

    Joined:
    Jul 21, 2011
    Messages:
    139
    Resources:
    0
    Resources:
    0
    nevermind, im kinda busy
     
  5. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Calling Entire Map leaks. You could store it into a variable at map init.