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

[Trigger] Trigger-based Critical Strike

Status
Not open for further replies.
Level 6
Joined
Sep 17, 2004
Messages
277
Here I am, again with more questions!
  • Fury StanceCrit
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Trigger - Add to (This trigger) the event (Unit - (Attacked unit) Takes damage)
      • Set CritChance = (Random integer number between 1 and 10)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CritChance Equal to 5
        • Then - Actions
          • Set TheristaDamage = (2.00 x (Damage taken))
          • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing TheristaDamage damage of attack type Hero and damage type Normal
          • Floating Text - Create floating text that reads ((String(TheristaDamage, 0, 2)) + !) above (Attacking unit) 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 2.00 seconds
        • Else - Actions
Okay, I have a few questions:

1) How do I make it so it's a 15% chance to critical strike via random numbers? [Answered!]
2) How do I show how much damage she deals with a critical strike instead of "0.000!"?
3) Is there a way to get rid of all the decimals?

Thank you!

P.S. Yes, I've tried the spellbook trick, but it shifts the abilities around if she has all the buttons full. And I don't like that, so I'm doing a trigger-based crit strike.
 
Last edited:
Level 9
Joined
Apr 25, 2009
Messages
468
Hmm, kinda hard to say now since I dont have WC3 on this computer...

Well, you should find an option that says "Convert Real to Integer" in the list of options when you want to do an action... Ahh man this is hard to explain without showing...
I'll return later when I can show better :p
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
  • Events
    • Unit - A unit Is attacked
This causes the trigger to be started when the unit begins attacking, so damage taken is 0. Make 2 triggers, one:
  • Events
    • Unit - A unit Is attacked
  • Conditions
    • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
    • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
  • Actions
    • Trigger - Add to (Damage) the event (Unit - (Attacked unit) Takes damage)
  • Events
  • Conditions
    • (Unit-type of (Damage Source)) Equal to Therista (Fury Stance)
  • Actions
    • Set CritChance = (Random integer number between 1 and 10)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CritChance Equal to 5
      • Then - Actions
        • Set TheristaDamage = (2.00 x (Damage taken))
        • Unit - Cause (Damage Source) to damage (Triggering unit), dealing TheristaDamage damage of attack type Hero and damage type Normal
        • Floating Text - Create floating text that reads ((String(TheristaDamage, 0, 2)) + !) above (Damage Source) 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 2.00 seconds
    • Else - Actions
 
Level 6
Joined
Sep 17, 2004
Messages
277
Thanks, Reaper. That kinda worked, except I started getting double the number of the crit damage on some instances. :S The first hit was a 130, the second was a 264? That doesn't make sense on a 2x critical strike.

I tried making a wait command, and then a Set Therista Damage = 0.00 and that seems to work some of the time, but it fails to work most of the time. I'll show you some screens.

Straight 130 damage
Straight 264 damage (look at her normal damage range in her status screen. That makes no sense.)
WTF Flag is happening here?

Here's the triggers:
  • FuryStanceCrit1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Trigger - Add to Fury StanceCrit2 <gen> the event (Unit - (Attacked unit) Takes damage)
  • Fury StanceCrit2
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Therista (Fury Stance)
    • Actions
      • Set CritChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CritChance Less than or equal to 15
        • Then - Actions
          • Set TheristaDamage = (2.00 x (Damage taken))
          • Unit - Cause (Damage source) to damage (Triggering unit), dealing TheristaDamage damage of attack type Hero and damage type Normal
          • Floating Text - Create floating text that reads ((String(TheristaDamage, 0, 0)) + !) above (Damage source) 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 2.00 seconds
          • Wait 0.15 game-time seconds
          • Set TheristaDamage = 0.00
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
Also, the damage shown by the text is the damage she deals. So sometimes, she deals over 1000 damage because of the errors in here. X_X

Still not sure what's wrong. Thanks for all the help so far, though! :)
 
Level 9
Joined
Apr 25, 2009
Messages
468
Remove the Wait...
What is it with people and the action Wait?
It's like the worst action you can use... Add an timer and make a new trigger with the event Timer Expires...
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
BULLSHIT, you cannot detect the damage taken if you use attacked... damage taken is the only way to manipulate damage, haniBon, stop spreading shit....

Well, remove the wait, and I see no error here, I will take a closer look... so I can reduce the unqualified answers in this thread maybe (spots hanibon)...

Here is the custom critical strike: http://www.hiveworkshop.com/forums/pastebin.php?id=tamcbi
 
Last edited:
Level 6
Joined
Sep 17, 2004
Messages
277
Red scores, that's nice, but it uses an ability. I'm trying to do it without an ability listed (and without spellbook). It's a good setup though. Let me see if I can work with it.

I did and here it is (second trigger):

  • FuryStanceCrit2
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Therista (Fury Stance)
    • Actions
      • Set CritChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CritChance Less than or equal to 15
        • Then - Actions
          • Set TheristaDamage = (Damage taken)
          • Unit - Cause (Damage source) to damage (Triggering unit), dealing TheristaDamage damage of attack type Hero and damage type Normal
          • Floating Text - Create floating text that reads ((String((Integer((2.00 x TheristaDamage))))) + !) above (Damage source) 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 2.00 seconds
        • Else - Actions
It works very well in the game, but is there any clean up I need to do? And is this acceptable?
 
Level 6
Joined
Sep 17, 2004
Messages
277
Thanks! What about this first trigger? Does it need any variables?
  • FuryStanceCrit1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Trigger - Add to FuryStanceCrit2 <gen> the event (Unit - (Attacked unit) Takes damage)
Do'h: I'm still getting memory crashes, did I clean up the variables properly?

  • FuryStanceCrit2
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Therista (Fury Stance)
    • Actions
      • Set DamageSourceCrit = (Damage source)
      • Set AttackedUnit = (Triggering unit)
      • Set CritChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CritChance Less than or equal to 15
        • Then - Actions
          • Set TheristaDamage = (Damage taken)
          • Unit - Cause DamageSourceCrit to damage AttackedUnit, dealing TheristaDamage damage of attack type Hero and damage type Normal
          • Floating Text - Create floating text that reads ((String((Integer((2.00 x TheristaDamage))))) + !) above DamageSourceCrit 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 2.00 seconds
          • Set AttackedUnit = No unit
          • Set DamageSourceCrit = No unit
        • Else - Actions
Also, how do I make it so abilities like Whirlwind or Thunder Clap do not receive the crit bonus?
 

Attachments

  • 2009-05-24 13.47.00 Crash.txt
    10.4 KB · Views: 117
Last edited:
Level 21
Joined
Aug 9, 2006
Messages
2,384
Hm, let me think.

I think thats really hard... well, you need maybe a third trigger, which always triggers if you attack, then it sets boolean true, and in the FuryStanceCrit2 conditions you check for that boolean, if it is true, do the critical, well, and, in the FuryStanceCrit2 you set instantly the boolean to false, that prevents it from starting without any attack (bladestorm).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I'd figure it's pretty obvious that whenever you attack a unit it registers him again and thus runs yet another time.

It is better to register all the units on the map (even better if you don't register units that don't need to be registered) and be done with it.
 
Level 6
Joined
Sep 17, 2004
Messages
277
Hm, let me think.

I think thats really hard... well, you need maybe a third trigger, which always triggers if you attack, then it sets boolean true, and in the FuryStanceCrit2 conditions you check for that boolean, if it is true, do the critical, well, and, in the FuryStanceCrit2 you set instantly the boolean to false, that prevents it from starting without any attack (bladestorm).

Oookay... I'll see what I can do, though I'm not sure how to start.

Have any ideas on how to avoid the memory crash/leak?

I'd figure it's pretty obvious that whenever you attack a unit it registers him again and thus runs yet another time.

It is better to register all the units on the map (even better if you don't register units that don't need to be registered) and be done with it.

Huh? o_O
 
Level 9
Joined
Apr 25, 2009
Messages
468
Dude, when you use "Add to event..." command, you must destroy the trigger when you are done, or it will leak.
 
Level 6
Joined
Sep 17, 2004
Messages
277
Dude, when you use "Add to event..." command, you must destroy the trigger when you are done, or it will leak.

Do you mean under "FuryStanceCrit1" that I place "Destroy (this trigger)" or in FuryStanceCrit2?

It's not quite so obvious to me. :p

I can't find a "Destroy Trigger" option under actions.
 
Level 4
Joined
Mar 14, 2009
Messages
98
Your trigger would do less damage than you expect and the number would be different from what you expect.

Armor will be applied again to the bonus damage from the critical strike leading you to deal less damage than expected. Also, the total damage taken by the target would not be equal to the total damage it took nor twice the hero's attack damage.

Say the target has 50% damage reduction from armor and Therista has 100 attack damage. The attack would lead to 50 damage, then the trigger causes Therista to damage the target for another 50 points of damage which is reduced by armor again. That leads you to a total of 75 damage dealt. The number that comes out would be 100. A normal critical strike would make Therista deal 100 damage(after armor reduction) and would show 200 damage in the floating text.

To deal the same damage as the event registers, you have to make it attack type chaos, damage type universal I believe. But that's just me being really obsessed with details.

Also, your first trigger leaks events, lots of them. A simple solution would be to check if the attacked unit is in a unit group. If it's not, add the attacked unit to the unit group then add the event to the trigger. That way, a unit is added only once to the trigger.
 
Level 6
Joined
Sep 17, 2004
Messages
277
Okay... I'm just confused now. X_x; How would I set this up? Does this mean I create another trigger? Because the Attacked Unit is already in a variable. I'm not sure how to set this up. :S

  • FuryStanceCrit1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) is in AttackedUnitGroup) Equal to True
        • Then - Actions
          • Trigger - Add to FuryStanceCrit2 <gen> the event (Unit - (Attacked unit) Takes damage)
        • Else - Actions
          • Unit Group - Add (Attacked unit) to AttackedUnitGroup
          • Trigger - Add to FuryStanceCrit2 <gen> the event (Unit - (Attacked unit) Takes damage)
Does this work? What do I have to add to the second trigger?
 
Last edited:
Level 6
Joined
Sep 17, 2004
Messages
277
I would, but the problem is that it uses an existing ability to make the custom critical work! I need to be based on the fact that Therista is in Fury Stance. She has no space for extra abilities as I said before. It also needs to be a specific unit. Yours applies globally. :S And I'm not sure how to change it to make it fit my needs.

I'm grateful you made it though.
 
Level 6
Joined
Sep 17, 2004
Messages
277
Ugh....

Ugh... I've found another bug. While it seems that the leak has been stopped (I don't know if it has been), I've been noticing that Therista insta-kills some monsters with her critical strike. I realized that it was just damage stacking, a double crit in one chance.

Anyway to fix this? Or should I just give up on the custom critical all together (it's getting to be annoyingly complex)?
 
Level 6
Joined
Sep 17, 2004
Messages
277
Okay, Anitarf from WC3Campaigns gave me a hand and here are the current triggers now:

  • FuryStanceCrit1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
      • ((Attacked unit) is A structure) Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) is in AttackedUnitGroup) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit Group - Add (Attacked unit) to AttackedUnitGroup
          • Trigger - Add to FuryStanceCrit2 <gen> the event (Unit - (Attacked unit) Takes damage)
  • FuryStanceCrit2
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Therista (Fury Stance)
    • Actions
      • Set CritChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CritChance Less than or equal to 15
        • Then - Actions
          • Set AttackedUnit = (Triggering unit)
          • Set DamageSourceCrit = (Damage source)
          • Set TheristaDamage = (Damage taken)
          • Unit - Cause DamageSourceCrit to damage AttackedUnit, dealing TheristaDamage damage of attack type Hero and damage type Normal
          • Floating Text - Create floating text that reads ((String((Integer((2.00 x TheristaDamage))))) + !) above DamageSourceCrit 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 2.00 seconds
          • Set AttackedUnit = No unit
          • Set DamageSourceCrit = No unit
        • Else - Actions
He says this will no longer leak because of the change I made in the first trigger. So far, that seems to be true. If there are any leaks, please tell me. If not, then YAY! :)

Second, I was trying to make it so Therista would not crit using Whirlwind or Thunder Clap.

Rain.mon told me to add an "attacked unit" event and then identify the attacker as Therista in Fury Stance to the second trigger, so I did:

  • ThunderClapWhirlwind1
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Whirlwind
          • (Ability being cast) Equal to Thunder Clap (Therista)
    • Actions
      • Trigger - Turn off FuryStanceCrit1 <gen>
  • ThunderClapWhirlwind2
    • Events
      • Unit - A unit Is attacked
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Whirlwind
          • (Ability being cast) Equal to Thunder Clap (Therista)
    • Actions
      • Trigger - Turn on FuryStanceCrit1 <gen>
So far, this has worked in stopping crits on those abilities. Nevermind, it didn't stop the crit on abilities. Anything I should add or anything that leaks in this?

Thank you in advance.
 
Last edited:
Level 6
Joined
Sep 17, 2004
Messages
277
Yes, it does exist. I copied the trigger from my trigger editor word for word. I used the "Copy as Text" option.

Um... Damagetype... I don't really know.

Thank you SO MUCH for answering though. I was waiting a LONG time for someone to help me.
 
Level 7
Joined
Mar 8, 2009
Messages
360
Ugh... I've found another bug. While it seems that the leak has been stopped (I don't know if it has been), I've been noticing that Therista insta-kills some monsters with her critical strike. I realized that it was just damage stacking, a double crit in one chance.

Anyway to fix this? Or should I just give up on the custom critical all together (it's getting to be annoyingly complex)?

To fix this you need a dummy unit to deal the critical damage to the unit , because now it will hit twice when you damage the target.

JASS:
 Unit - Cause DamageSourceCrit to damage AttackedUnit, dealing TheristaDamage damage of attack type Hero and damage type Normal
this is also registered by your event i think which makes the trigger run again

I'm not 100% sure of all i said, i'm not very experienced in map making.
 
Level 4
Joined
May 16, 2009
Messages
61
Try making it so it is
  • Events
  • Unit - A unit Is attacked
  • Conditions
  • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
  • Actions
  • Trigger - Turn on FuryStanceCrit1 <gen>
 
Level 6
Joined
Sep 17, 2004
Messages
277
Okay... I should have said this earlier, but I removed one of the "ThunderClapWhirlwind" triggers and made it turn off FuryStanceCrit2. That seemed to work for awhile, but then, it seemed to not work. *sigh* Also, I basically did the same thing you suggested, just with the trigger "turn on FuryStanceCrit2" in FuryStanceCrit1. :S And it didn't work, unfortunately.

Here's what I have now (one trigger instead of two "ThunderClapWhirlwind"s):

  • ThunderClapWhirlwind
    • Events
      • Unit - A unit Begins casting an ability
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Therista (Fury Stance)
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Whirlwind
          • (Ability being cast) Equal to Thunder Clap (Therista)
    • Actions
      • Trigger - Turn off FuryStanceCrit2 <gen>
Still need help. Bump. (I hope this is not too early, nor too late. >_<)
 
Level 4
Joined
Mar 14, 2009
Messages
98
If you aren't already using custom values in your map, you could always set Therista's custom value to 1 whenever she attacks, then have a condition on the second trigger that makes it so that it only works if her custom value is 1 and an action in the second trigger that changes her custom value to 0. Also, you'll need another trigger so that whenever she casts a spell, it changes her custom value to 0. This should fix both the damage stacking problem and the spell critical problem.

Edit: It just hit me, if there's only one Therista in the map, you won't even need to use her custom value. You can just use some boolean variable instead.
 
Status
Not open for further replies.
Top