• 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.

[Trigger] Gold stealing skill

Status
Not open for further replies.
Level 3
Joined
Nov 12, 2011
Messages
46
This is my attempt making a skill that steal gold and damaging the targeted enemy. but i cant tell if it is leaking, or if it will work. Can anyone give me an opinion

  • Mugging
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mugging[Q]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Mugging[Q] for (Triggering unit)) Equal to 1
        • Then - Actions
          • Set Gold_Stolen = (5 + (Intelligence of (Triggering unit) (Exclude bonuses)))
          • Player - Add Gold_Stolen to (Owner of (Triggering unit)) Current gold
          • Player - Add (-1 x Gold_Stolen) to (Owner of (Target unit of ability being cast)) Current gold
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Mugging[Q] for (Triggering unit)) Equal to 2
            • Then - Actions
              • Set Gold_Stolen = (10 + (Intelligence of (Triggering unit) (Exclude bonuses)))
              • Player - Add Gold_Stolen to (Owner of (Triggering unit)) Current gold
              • Player - Add (-1 x Gold_Stolen) to (Owner of (Target unit of ability being cast)) Current gold
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Mugging[Q] for (Triggering unit)) Equal to 3
                • Then - Actions
                  • Set Gold_Stolen = (20 + (Intelligence of (Triggering unit) (Exclude bonuses)))
                  • Player - Add Gold_Stolen to (Owner of (Triggering unit)) Current gold
                  • Player - Add (-1 x Gold_Stolen) to (Owner of (Target unit of ability being cast)) Current gold
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Mugging[Q] for (Triggering unit)) Equal to 4
                    • Then - Actions
                      • Set Gold_Stolen = (40 + (Intelligence of (Triggering unit) (Exclude bonuses)))
                      • Player - Add Gold_Stolen to (Owner of (Triggering unit)) Current gold
                      • Player - Add (-1 x Gold_Stolen) to (Owner of (Target unit of ability being cast)) Current gold
                    • Else - Actions
tested and it is stuck using the level one gold steal :( and i cant tell if it is steal gold from the other player at all.
i would like some help fixing this code.
 
Last edited:
You ought to use a formula for the amount of gold stolen i.e.
  • Set Gold_Stolen = ((Level of Mugging[Q] for (Triggering unit)) + (Intelligence of (Triggering unit) (Exclude bonuses)))
Also, I'd suggest making sure the enemy -has- that much gold (can't mug gold they don't have) i.e. checking the change in gold of a player, and adding the change the the mugging player's gold, rather than adding the value and then deducting it from the player

other than that, should work, imo and no it's not leaking, though could do with as bit of caching values (triggering unit) namingly
 
Level 3
Joined
Nov 12, 2011
Messages
46
can you explain a bit more about the caching values. its been so long since i did anything on warcraft. been meesing with java, c, and c++
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
It doesn't leak, but it's very bad coded.

Instead of using If/Then/Else for each level, make the level a part of the formula to calculate the values, so, if the level increases, the formula result will increase aswell. That's what Tank-Commander said.

The "Logic" in your numbers is 5 - 10 - 20 - 40, so, it doubles every time, but levels are 1, 2, 3, 4. How to make 1=5, 2=10, 3=20, 4=40? I don't know, but you could make it as LevelOfAbilityx10 and scale it from 10, 20, 30, 40.

Once you have the amount of gold to be stolen, you make an ITE (if then else) and if the value you're going to steal is greater than the target player gold, you make the amount of gold to be stolen equal to the gold the other player has, else, do nothing.

Additionally, on the whole trigger you use several times "Triggering Unit" and "Owner of Triggering Unit" and "Owner of Target Unit of Ability Being Cast".
So, before any action do
  • Set tempUnit1 = (Triggering Unit)
  • set tempPlayer1 = (Triggering Player) // This stands as Owner of Triggering Unit automatically.
  • set tempUnit2 = Target unit of Ability Being Cast
  • set tempPlayer2 = Owner of tempUnit2
  • ... the rest of your actions
Then, replace all the other Triggering Units, and Triggering Player, and Owner of Target Unit of Ability Being Cast with these variables values. It improves the efficiency since you look for these values just once, then you tell the trigger where they're stored (in the variable) else, the system would have to look around several times for the same units and players in the same trigger.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
The "Logic" in your numbers is 5 - 10 - 20 - 40, so, it doubles every time, but levels are 1, 2, 3, 4. How to make 1=5, 2=10, 3=20, 4=40? I don't know

First we check if it is an arithemtic sequence. It means that a constant value is added when getting the next value. For example, 2-4-6-8 is an arithmetic sequence since (n+1)-n = 8-6 = 2 and 4-2 = 2. Number two is added each time.

5-10-20-40 is not an arithmetic sequence since 40-20=20 but 10-5 = 5.

Then we can test if it is a geometric sequence. It means there is a certain ratio between the numbers. This we do with division (n+1)/n.

40/20 = 2, 20/10 = 2, 10/5 = 2

Looks like a geometric sequence to me alright. 2 is the ratio between the numbers. Now we must discover the whole equation.

The first number in the sequence is 5, so we use that as the base. Then there is 2 as the ratio, we muliply with that.

Now we have 5*2. That alone doesn't get us anywhere.

We must produce different numbers for each natural number (1,2,3,4...). The letter n must be added to the equation to represent each number.

When we divide each number from the original sequence with the base, 5, we get 1-2-4-8. We can see the geometric shape here. And that sequence follows the pattern produced by 2n, when n starts from 0.

We add then n to be the power of the 2, to achieve the increasing growth of the values. Now we have 5*2n. But that still doesn't give us what we want, since we start from 1 and not 0. There is no 0th number in the original sequence. We must offset our equation by -1. And therefore the final equation is

5*2n-1
 
Last edited:
The "Logic" in your numbers is 5 - 10 - 20 - 40, so, it doubles every time, but levels are 1, 2, 3, 4. How to make 1=5, 2=10, 3=20, 4=40? I don't know, but you could make it as LevelOfAbilityx10 and scale it from 10, 20, 30, 40.

Here is a little tip since few people know about this tool :)
http://world-editor-tutorials.thehelper.net/formula.php

Acehart developed a means of assisting with that problem. While it may not necessarily find the exact formula, it can come pretty close. It is obviously not as clean nor as accurate as Maker's, but it is pretty fun to play with.
 
Status
Not open for further replies.
Top