• 🏆 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!

Bleeding effect

Status
Not open for further replies.
Level 2
Joined
Nov 8, 2013
Messages
18
Hi everyone,

I've comeback to War3 Modding recently, and I am struggling here with this effect:

1) Trigger activated;
2) Effect lives within a "Loop - Actions" structure;
3) Loop is iterating sucessfully, but effect only happens once (first iteraction).

5b9edac2319a6d956b7d2d2b68cf220a.jpg


I tested and I get the "in loop" messages correctly, however the HP removal only occurs once :vw_wtf:

Hopefully someone can drop a hint or two?
Thank you!
 
Level 2
Joined
Nov 8, 2013
Messages
18
Sorry, maybe some Mod can move it to the correct place?

Changing to "Casting Unit" did not fix it, same behaviour occured.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I would say the issue is that you use Integer A instead of your own variable, and thus the loop might not be stable because of the wait, but you did say you are getting the messages, so it's weird (unless you tested with multiple units, in which case this is probably indeed the issue).

Either way, never use globals if you are planning to use waits.
Suppose you have one unit start this effect, and then 5 seconds later another unit starts it.
The A global integer will be overwritten by each trigger invocation ("instance") running, and each one will mess up the other.

This is relevant to all globals, which there are many of in WC3.

Triggering unit actually happens to not be a global, so it's fine in this case (can't remember if casting unit is or not, there's probably a list of what's global and what not somewhere on the Hive).

What you should do, then, is use a local variable for your loop counter, which doesn't exist in GUI, so Jass it is! (via the Custom script action in GUI).

Suppose you define an integer variable in GUI called "MyCounter".
In your trigger, right at the beginning, you can add the custom script
  • Custom script: local integer udg_MyCounter
(udg means user defined global, that's how you reference the variables you create in the GUI variable editor when using Jass)
Now in your loop simply replace Integer A with your MyCounter variable.
This will "trick" WC3 into using your local variable instead of the global GUI one.
Local variables essentially create a new copy on every invocation of your trigger, and therefore it doesn't matter how many of these loops you run in parallel, they won't bother each other.

As a side note, please attach triggers directly using [trigger][/trigger], instead of attaching offsite images.
 
Level 3
Joined
May 12, 2016
Messages
51
Hmm...For a start...add this before the loop,

  • Set bleeding_unit = (Triggering Unit)
then tweak the damage Action to...

  • Unit - Cause bleeding_unit to damage bleeding_unit, dealing ((Max Life of bleeding_unit) * (0.05)) damage of attack type Magic and damage type Magic
That should fix your problem with the damage.
 
Level 2
Joined
Nov 8, 2013
Messages
18
Hello everyone,

Thanks for all your suggestions, unfortunately the "bug" persists.

I've tried both suggestions (custom script set counter variable + bleeding_unit variable), in both what happened was the unit got a "clone" of himself, right on top of it that was taking the damage and died with the effect, this "clone" was not selectable, could only watch it manifest it's pain while on top of the other unit, looked like some crazy freddy kruguer sh*t :goblin_jawdrop:
P.S - First iteraction still occurred correctly and damage the desired unit for 5% Max HP and "loop" messages were displayed.


This is where I am at:
  • Wrecker One Swipe Tauren
    • Events
      • Unit - A unit owned by Player 1 (Red) Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to One Swipe Tauren
    • Actions
      • Custom script: local integer udg_counter
      • Set bleeding_unit = (Triggering unit)
      • Game - Display to (All players) the text: ability used
      • For each (Integer A) from 1 to 30, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: in loop
          • Unit - Cause bleeding_unit to damage bleeding_unit, dealing ((Max life of bleeding_unit) x 0.05) damage of attack type Magic and damage type Magic
          • Wait 1.00 seconds
      • For each (Integer counter) from 1 to 30, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: in loop
          • Unit - Cause (Triggering unit) to damage (Triggering unit), dealing ((Max life of (Triggering unit)) x 0.05) damage of attack type Magic and damage type Magic
          • Set counter = (counter + 1)
          • Wait 1.00 seconds
(Naturally, I tested 1 Loop at the time, disabling the other.)

I am thinking at this point this has got to be a unit selecting issue, it seems after the first iteration of the loop, the unit memory references goes kaput?
 
Level 2
Joined
Nov 8, 2013
Messages
18
Remove that loop for integer A and do not increase the counter. Test it once more.

Didn't work, same behaviour.

  • For each (Integer counter) from 1 to 30, do (Actions)
    • Loop - Actions
      • Game - Display to (All players) the text: (counter value: + (String(counter)))
      • Unit - Set life of (Triggering unit) to ((Max life of (Triggering unit)) - ((Max life of (Triggering unit)) x 0.05))
      • Wait 1.00 seconds
Also tried a different HP removal function... same effect, kills the "cloned" unit.
P.S - The counter message works flawless, outputing: 1,2,3,4,5,6....



EDIT: Hah, just solved the issue!

After using this different function, I noticed the problem was within the function itself, basically I was saying
"Make that Unit get: His Max Life - (His Max Life * 0.05)" which always returns the same value, what I really have to say is
"Make that Unit get: His Current Life - (His Max Life * 0.05)"

So, here is the correct function:

  • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - ((Max life of (Triggering unit)) x 0.05))
Still having the cloned unit issue, though, so this clone shows up and dies within 3 iteractions of the loop.
 
Status
Not open for further replies.
Top