• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Why isn't this functions working?

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
So this is a TEXTURE changer trigger that will change a model's skin while in-game. I tested the same functiong using the "Unit enters playable map area" event and it works fine, but in this one it doesn't. What m'I missing ?
  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Linen Clothing
        • Then - Actions
          • Set TempPointTexture = (Position of (Triggering unit))
          • Set TempPointTexture2 = (TempPointTexture offset by 12.00 towards (Facing of (Triggering unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Triggering unit)) is an ally of Player 11 (Dark Green)) Equal to True
            • Then - Actions
              • Destructible - Create a Human v1 at TempPointTexture facing 0.00 with scale 0.01 and variation 0
            • Else - Actions
              • Destructible - Create a Human v2 at TempPointTexture facing 0.00 with scale 0.01 and variation 0
          • Unit - Add Texture Changer to (Triggering unit)
          • Unit - Order (Triggering unit) to Night Elf Mountain Giant - War Club (Last created destructible)
          • Unit - Remove Texture Changer from (Triggering unit)
          • Destructible - Remove (Last created destructible)
          • Custom script: call RemoveLocation(udg_TempPointTexture)
          • Custom script: call RemoveLocation(udg_TempPointTexture2)
          • Custom script: set udg_TempPointTexture = null
          • Custom script: set udg_TempPointTexture2 = null
          • Custom script: set bj_lastCreatedDestructable = null
        • Else - Actions
 
Level 11
Joined
Oct 9, 2015
Messages
721
I tested without the condition too, and no effect. I've put an "Display Game Message for Player" on every part of the function and it showed up on the screen when the event was fired.

EDIT: If the unit haven't moved yet in the match the trigger will work, but somehow if the units moves and then stops, THEN execute the trigger, it won't work o_O
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
In this instance it would probably be best just to store them in a local variable, wait the shortest possible time, and then perform those actions. There's no need to set bj_lastCreatedDestructable to null, and keeping that line in will mess with you here. Nulling a global variable is unnecessary since it will eventually be reassigned to something else anyway, effectively clearing that part of the leak (still need to actually remove the location, though).

  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Custom script: local destructable D
      • -------- that has to be the first line of the trigger, else you get compiler errors --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Linen Clothing
        • Then - Actions
          • Set TempPointTexture = (Position of (Triggering unit))
          • Set TempPointTexture2 = (TempPointTexture offset by 12.00 towards (Facing of (Triggering unit)) degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Triggering unit)) is an ally of Player 11 (Dark Green)) Equal to True
            • Then - Actions
              • Destructible - Create a Human v1 at TempPointTexture facing 0.00 with scale 0.01 and variation 0
            • Else - Actions
              • Destructible - Create a Human v2 at TempPointTexture facing 0.00 with scale 0.01 and variation 0
          • Unit - Add Texture Changer to (Triggering unit)
          • Unit - Order (Triggering unit) to Night Elf Mountain Giant - War Club (Last created destructible)
          • Custom script: call RemoveLocation(udg_TempPointTexture)
          • Custom script: call RemoveLocation(udg_TempPointTexture2)
          • -------- REMOVE THIS --------
          • Custom script: set udg_TempPointTexture = null
          • Custom script: set udg_TempPointTexture2 = null
          • Custom script: set bj_lastCreatedDestructable = null
          • -------- REMOVE THIS --------
          • Custom script: set D = bj_lastCreatedDestructable
          • Wait 0.00 seconds //something like 0.27 is the shortest possible wait, but this will do that
          • Custom script: set bj_lastCreatedDestructable = D
          • Custom script: set D = null
          • Unit - Remove Texture Changer from (Triggering unit)
          • Destructible - Remove (Last created destructible)
        • Else - Actions
 
Level 11
Joined
Oct 9, 2015
Messages
721
Here it goes:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Permanent
    • Actions
      • -------- ----------------------------------------------- --------
      • -------- LINEN CLOTHING --------
      • -------- ----------------------------------------------- --------
      • Set TempPointTexture = (Position of (Triggering unit))
      • Set TempPointTexture2 = (TempPointTexture offset by 12.00 towards (Facing of (Triggering unit)) degrees)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) is an ally of Player 11 (Dark Green)) Equal to True
        • Then - Actions
          • Destructible - Create a Human v1 at TempPointTexture2 facing 0.00 with scale 0.01 and variation 0
        • Else - Actions
          • Destructible - Create a Human v2 at TempPointTexture2 facing 0.00 with scale 0.01 and variation 0
      • Unit - Add Texture Changer to Unit_Animation[(Player number of (Owner of (Triggering unit)))]
      • Unit - Order Unit_Animation[(Player number of (Owner of (Triggering unit)))] to Night Elf Mountain Giant - War Club (Last created destructible)
      • Unit - Remove Texture Changer from Unit_Animation[(Player number of (Owner of (Triggering unit)))]
      • Destructible - Remove (Last created destructible)
      • Custom script: call RemoveLocation(udg_TempPointTexture)
      • Custom script: call RemoveLocation(udg_TempPointTexture2)
      • Custom script: set udg_TempPointTexture = null
      • Custom script: set udg_TempPointTexture2 = null
      • Custom script: set bj_lastCreatedDestructable = null
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Where is Unit_Animation[] being set and what is it actually? I assumed it was the unit picking up the item, and in that case I don't really see why you're sometimes using Triggering Unit and sometimes using that variable. My intuition is that the variable isn't being set before the first cast.

Like before, does it work fine if you disable (Ctrl+F) the Remove Texture Changer... and Remove (Last created destructible) lines?
 
Level 11
Joined
Oct 9, 2015
Messages
721
the triggering unit is the unit picking up the item, unit_animation is the unit that will have it's texture changed, they're both at the same place all the time. I use the triggering unit for stats etc and the unit_aniamtion to perform animations (attack, walk etc). it is set at the beggining of the match.
 
Level 11
Joined
Oct 9, 2015
Messages
721
Removing the functions cited above doesn't changed anything, however I realized that it was happening because the trigger that runs that function maybe isn't recognizing unit_animation, as it is set praticaly at the same time that the trigger is run. let me explain: the game starts when I choose a dialog button, that's when the unit_animation is set and that's where the item is given to the triggering unit. adding a wait 0.50 seconds in the trigger makes it work, but I would need a better solution than using "wait" functions
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
No, I mean put the wait in the dialog button trigger. This way it will only happen the very first time for each player.
  • Events
    • Dialog button is clicked
  • Conditions
  • Actions
    • -------- ... --------
    • Set Unit_Animation[...] etc.
    • Wait 0.50 seconds.
    • Item - Create 1 Item etc.
  • Events
    • Unit - A unit acquires an item
  • Conditions
  • Actions
    • -------- Blah blah --------
 
Status
Not open for further replies.
Top