• 🏆 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 Based - Critical Chance and Critical Damage Issues

Status
Not open for further replies.
Level 2
Joined
May 1, 2016
Messages
7
Lets start off by saying this is my first time using forums for help on this matter, and i normally can figure it but, but i'm having issues with detecting the damage to be able to calculate the int variable to deal bonus damage for critical damage and show the bonus damage, is there any way to be able to do this function all it one trigger based?

I get the The Text to pop up, but nothing has any value to it

so I'm guess you need to add to attacked_unit =attacked unit
Attacked unit takes damage, how do you that damage value

the main idea was to have, every 5 points of agility you gain 1% critical chance, and every point into intelligence player gains 20% critical damage

and using skills/melee attacks, this would proc

is there something i'm missing?


  • Crit Chance
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is A Hero) Equal to True
    • Actions
      • Set Attacked_Unit = (Attacked unit)
      • Set HeroIntValue = (Intelligence of (Attacking unit) (Include bonuses))
      • Set CritcalChance = (((Agility of (Attacking unit) (Include bonuses)) / 5) + 5)
      • Set CritcalDamage = ((HeroIntValue x (Integer(2.00))) + (Integer(100.00)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Attacked unit) is A structure) Equal to False
              • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
        • Then - Actions
          • Trigger - Add to (This trigger) the event (Unit - Attacked_Unit Takes damage)
          • Set HeroDamageSource = (Damage taken)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between CritcalChance and 80) Greater than or equal to 75
            • Then - Actions
              • Set CritHit = ((Integer(HeroDamageSource)) x CritcalDamage)
              • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Real(CritHit)) damage of attack type Hero and damage type Normal
              • Floating Text - Create floating text that reads (Critical Damage + ((String(HeroDamageSource)) + !)) at (Position of (Attacking unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.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 the lifespan of (Last created floating text) to 1.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Wait 1.00 seconds
              • Floating Text - Destroy (Last created floating text)
            • Else - Actions
        • Else - Actions
          • Do nothing
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
The problem in your trigger is incorrect event. The "unit is attacked" event fires when a unit STARTS an attack - in case of archers this event fires when they prepare to shoot from their bow, for footman it happens when they start swinging their sword. Basically this event fires before any damage is dealt, hence why you get no value in text.

The correct way to get when unit is actually damage is the "Unit - (specific) unit takes damage".
I see that in your trigger you actually do add the attacked unit to the event "unit takes damage", however in your case that will not work either. The reason is that you add that event to this same trigger, however the condition for that trigger is "((Attacking unit) is A Hero) Equal to True". In the "unit takes damage" event there is no attacking unit, only damage source, so the condition always returns false and the trigger never fires when unit actually takes damage.

I strongly advise using damage detection system (DDS). A DDS system does what you did (adds all units to a trigger via the "Trigger -add event" action), but it also recycles handles, re-creates the trigger, etc. so it prevents bugs which may pretty much occur in your version.
You can download DDS here on hive and import it into your map. Then it's a matter of using a correct event (described by the DDS) and calculating the crit chance, etc.
 
Status
Not open for further replies.
Top