• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] Function "Set Unit: Weapon..." Not Working

Level 18
Joined
Mar 16, 2008
Messages
721
It's supposed to temporarly set weapon damage to 5000, then back to 'regular' however it seems to just keep increasing it by an interval of 5000. I'm puzzled.

This seems to work:
  • Unit - Set Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: 5000
This seems to just keep adding 5000.
  • Unit - Set Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: Warden_base_damage
I'm clearly over looking something but very puzzled what it is...

  • warden near corrupt
    • Events
    • Conditions
      • (Triggering unit) Equal to Warden (NPC) 0054 <gen>
      • warden_neutral Equal to False
    • Actions
      • Set VariableSet warden_neutral = True
      • Unit - Change ownership of Warden (NPC) 0054 <gen> to Neutral Passive and Retain color
      • Set VariableSet Warden_var = (Triggering unit)
      • Set VariableSet Warden_base_damage = (Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b') at Index:1)
      • Unit - Set Warden (NPC) 0054 <gen> movement speed to 400.00
      • Countdown Timer - Pause warden_cor_atk_timer
      • Countdown Timer - Start warden_cor_atk_timer as a One-shot timer that will expire in 10.00 seconds
      • Unit - Set Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: 5000
      • Custom script: set udg_Warden_Target = GetClosestUnitInGroup(GetUnitX(udg_Warden_var), GetUnitY(udg_Warden_var), udg_corrupted_player_buildings)
      • Unit - Order Warden (NPC) 0054 <gen> to Attack Warden_Target
  • corrupt building dies
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
      • Unit - A unit owned by Player 2 (Blue) Dies
      • Unit - A unit owned by Player 3 (Teal) Dies
      • Unit - A unit owned by Player 4 (Purple) Dies
      • Unit - A unit owned by Player 13 (Maroon) Dies
      • Unit - A unit owned by Player 14 (Navy) Dies
      • Unit - A unit owned by Player 15 (Turquoise) Dies
      • Unit - A unit owned by Player 16 (Violet) Dies
    • Conditions
      • (Level of Corrupted Class (hidden) for (Dying unit)) Equal to 1
    • Actions
      • Unit Group - Remove (Dying unit) from corrupted_player_buildings.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Killing unit) Equal to Warden (NPC) 0054 <gen>
        • Then - Actions
          • Sound - Play maive_corrupt_atk_sound[(Random integer number between 0 and 2)]
          • Countdown Timer - Pause warden_cor_atk_timer
          • Unit - Set Warden (NPC) 0054 <gen> movement speed to (Default movement speed of Warden (NPC) 0054 <gen>)
          • Unit - Set Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: Warden_base_damage
          • Hero - Set Warden (NPC) 0054 <gen> Hero-level to ((Hero level of (Killing unit)) + 1), Show level-up graphics
          • Unit - Change ownership of Warden (NPC) 0054 <gen> to Player 5 (Yellow) and Retain color
          • Set VariableSet warden_neutral = False
        • Else - Actions
  • waden corrupt timer
    • Events
      • Time - warden_cor_atk_timer expires
    • Conditions
      • (Warden (NPC) 0054 <gen> is in (Units owned by Player 5 (Yellow).).) Equal to False
    • Actions
      • Countdown Timer - Pause warden_cor_atk_timer
      • Unit - Set Warden (NPC) 0054 <gen> movement speed to (Default movement speed of Warden (NPC) 0054 <gen>)
      • Unit - Set Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: Warden_base_damage
      • Unit - Change ownership of Warden (NPC) 0054 <gen> to Player 5 (Yellow) and Retain color
      • Set VariableSet warden_neutral = False

EDIT: I debugged and confirmed ugh_Warden_base_damage is being set correctly, the integer variable is being set correctly, but for some reason it's not setting the units damage back to that variable for some reason. ???
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
Index: 1 should refer to the second weapon since these functions are indexed starting at 0.

Also, I remember this specific field being bugged but I forget the exact details.

The solution sounds like you just need to treat it like addition and subtract 5000 when you're done.
  • Unit - Set Unit: Warden (NPC) 0054 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: -5000
 
Last edited:
Level 20
Joined
Feb 27, 2019
Messages
593
I dont remember having any issues with that function but it appears its a bit unintuitive. Even if I kinda see how it works I still dont feel confident trying to explain it so Ill show it instead. Both of these seem to work though.
  • Unit - Set Unit: Warden 0000 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: ((Unit: Warden 0000 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b') at Index:1) + 5000)
  • Unit - Set Unit: Warden 0000 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: ((Unit: Warden 0000 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b') at Index:1) - 5000)
  • Unit - Set Unit: Warden 0000 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: (5000 + (Agility of Warden 0000 <gen> (Exclude bonuses)))
  • Unit - Set Unit: Warden 0000 <gen>'s Weapon Integer Field: Attack Damage Base ('ua1b')at Index:1 to Value: (-5000 + (Agility of Warden 0000 <gen> (Exclude bonuses)))
I realized why I was so confused. Ive mostly used other functions that are more straight forward. I think I would use the very first function in your case though, because it automatically accounts for any gained base damage during the duration of the trigger.
  • Set VariableSet Warden_base_damage = (Base Damage of Warden 0000 <gen> for weapon index 0)
  • Unit - Set Base Damage of Warden 0000 <gen> to 5000 for weapon index: 0
  • Unit - Set Base Damage of Warden 0000 <gen> to Warden_base_damage for weapon index: 0
 
Level 18
Joined
Mar 16, 2008
Messages
721
Thanks I'm sure this will solve the problem.

Would anyone want to propose an alternative way to make the warden 1-shot these buildings? The RP is she will attack any "corrupted" buildings that she "sees."
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
I heard that trigger unavoidably leaks, or maybe that's a rumor. or maybe i could just have the first trigger turn on that trigger.
Patch 1.31 added a generic Takes Damage event. Bribe's Damage Engine uses it as well. No leaks. You're probably looking at info from like 2015 when people were using the Specific Unit event since that was the only thing available for damage detection.

Also, you could disable the triggers when they're not needed, that would help with performance.
 
Level 18
Joined
Mar 16, 2008
Messages
721
Just doing +x then -x results in the heroes damage being zero. ugh so we need to factor in the agility too i guess, like Duck mentioned above.

EDIT: and for some reason weapon index 0 isn't on this unit? hmm

EDIT 2: including the bonus seems to get the damage back to where it was before. luckily this hero won't be swapping out items.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
Just doing +x then -x results in the heroes damage being zero. ugh so we need to factor in the agility too i guess, like Duck mentioned above.

EDIT: and for some reason weapon index 0 isn't on this unit? hmm

EDIT 2: including the bonus seems to get the damage back to where it was before. luckily this hero won't be swapping out items.
All of those functions SHOULD be indexed starting at 0, so Weapon 1 should be Index 0 and Weapon 2 should be Index 1. That doesn't mean that it's guaranteed to be true. Reforged is a buggy mess.

Anyway, I think you're overcomplicating it, you can simply add/remove a +Attack Damage ability to the unit:
  • Unit - Add 9999999 Damage to Warden
  • Unit - Remove 9999999 Damage from Warden
This is what Claws of Attack and other items like it use.
 
Level 18
Joined
Mar 16, 2008
Messages
721
Ahh I like this. Sometimes I just search through GUI functions and jump on the first one I see. I knew you could imagine a better way.

EDIT: and i've decided to go with 750 damage for more dramatic effect. the one-shot is a bit anti climactic and perhaps the player would just be confused what's going on lol.

EDIT 2: I'm going to enable/disable ability instead. worried adding the ability will cause a stutter.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,580
Ahh I like this. Sometimes I just search through GUI functions and jump on the first one I see. I knew you could imagine a better way.

EDIT: and i've decided to go with 750 damage for more dramatic effect. the one-shot is a bit anti climactic and perhaps the player would just be confused what's going on lol.

EDIT 2: I'm going to enable/disable ability instead. worried adding the ability will cause a stutter.
Adding abilities only causes a stutter the very first time you do it. This has to do with how it's loaded from memory. To fix this you can "preload" your abilities at the start of the game by adding them to some Dummy unit and then removing it once you're done. This will get all of the stuttering over with before anything important happens. This also applies to loading models which is tied to Units/Special Effects and can be handled in a very similar manner.
 
Top