• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Pilfer (Stealing % Gold)

Status
Not open for further replies.
Level 3
Joined
Mar 15, 2020
Messages
48
The ability is meant to steal 20% of the targeted player's current gold and add it directly to the owner of the casting unit. Something's clearly wrong with my triggers, otherwise it would work and I'd not be asking for help.

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Pilfer (Agamand)
  • Actions
    • Set VariableSet tempTarget = (Triggering Unit)
    • Floating Text - Create floating text that reads (+ + (String((((Owner of (Target unit of ability being cast)) Current gold) x (Integer(0.20)))))) above tempTarget with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
    • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
    • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
    • Player - Set (Owner of (Triggering unit)).Current gold to (((Owner of (Triggering unit)) Current gold) + (((Owner of (Target unit of ability being cast)) Current gold) x (Integer(0.20))))
    • Player - Set (Owner of (Target unit of ability being cast)).Current gold to (((Owner of (Target unit of ability being cast)) Current gold) x (Integer(0.20)))
 
Level 3
Joined
Mar 15, 2020
Messages
48
Gives +0 to the player. Was intended to be the 20% of current gold. Something's off with my logic setup here, but I can't find the problem.
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
Why are you setting a variable "tempTarget" to a value if you're not going to use the variable at all?
While GhostWolf already stated the problem at hand, Integer(0.20) is 0, which anyone could figure this out in a span of 0 seconds, you could simply test it yourself and since you admited something was wrong there. Debugging is an important part for everyone.
the first "Player - Set (Owner of (Triggering unit)).Current gold to" can be simplified with the next action near the "set":
  • Player - Add (((Owner of (Target unit of ability being cast)) Current gold) / 5) to (Owner of (Triggering unit)).Current gold
Your next action is simply wrong. Your setting the targeted player's gold to 1/5 (x 0.2) instead of setting to 4/5 (x 0.8)
You can simply use its inverse.
 
Level 3
Joined
Mar 15, 2020
Messages
48
The variable was a leftover from another trigger I copied over to make the current one, that was an oversight on my part entirely. I've modified my triggers as follows;
  • Actions
    • Player - Add (((Owner of (Target unit of ability being cast)) Current gold) / 5) to (Owner of (Triggering unit)).Current gold
    • Player - Set (Owner of (Target unit of ability being cast)).Current gold to (((Owner of (Target unit of ability being cast)) Current gold) x (80 / 100))
But clearly there's something I'm still not grasping or it'd subtract the proper amount of gold from the afflicted target. Right now it removes all of the targeted player's gold.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,496
This should work:

Edit: On second thought, the If Then Else wasn't necessary:
  • Gold Steal
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set VariableSet TempInteger = (((Owner of (Target unit of ability being cast)) Current gold) / 5)
      • Player - Set (Owner of (Target unit of ability being cast)).Current gold to (((Owner of (Target unit of ability being cast)) Current gold) - TempInteger)
      • Player - Set (Triggering player).Current gold to (((Triggering player) Current gold) + TempInteger)
      • Floating Text - Create floating text that reads (+ + (String(TempInteger))) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
Triggering Player is equal to the Owner of the Casting Unit for this Event.

Edit: Even easier you can just add the gold:
  • Gold Steal
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set VariableSet TempInteger = (((Owner of (Target unit of ability being cast)) Current gold) / 5)
      • Player - Add (TempInteger x -1) to (Owner of (Target unit of ability being cast)).Current gold
      • Player - Add TempInteger to (Triggering player).Current gold
      • Floating Text - Create floating text that reads (+ + (String(TempInteger))) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
 
Last edited:
Level 3
Joined
Mar 15, 2020
Messages
48
You've come to my rescue once again, @Uncle. Thank you so much for simplifying the solution so well! I'd considered using an Integer variable at one point but my dumbass immediately dismissed it for no discernable reason.+1
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
What does Integer(0.20) result in?

Gives +0 to the player.
Do
Not
Use
Reals
On
An
Integer
Action
  • Actions
    • Player - Add (((Owner of (Target unit of ability being cast)) Current gold) / 5) to (Owner of (Triggering unit)).Current gold
    • Player - Add (((Owner of (Target unit of ability being cast)) Current gold) / -5) to (Owner of (Target unit of ability being cast)).Current gold
 
Level 3
Joined
Mar 15, 2020
Messages
48
Indeed, @Wrda, we've moved past that point now.

The final triggers look like this for anyone looking for the answer on a similiar problem in the future:

  • Pilfer
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pilfer (Agamand)
    • Actions
      • Set VariableSet PilferAmount = (((Owner of (Target unit of ability being cast)) Current gold) / 5)
      • Player - Set (Owner of (Target unit of ability being cast)).Current gold to (((Owner of (Target unit of ability being cast)) Current gold) - PilferAmount)
      • Player - Add PilferAmount to (Owner of (Triggering unit)).Current gold
      • Game - Display to (All players) the text: (Player_Colors[(Player number of (Owner of (Triggering unit)))] + ((Name of (Triggering player)) + (|r has pilfered + (Player_Colors[(Player number of Player 5 (Yellow))] + ((String(PilferAmount)) + ((|r gold from + Player_Colors[(Player number of (Owner of
      • Floating Text - Create floating text that reads (+ + (String(PilferAmount))) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
      • Floating Text - Create floating text that reads (- + (String(PilferAmount))) above (Target unit of ability being cast) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
 
Status
Not open for further replies.
Top