• 🏆 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] The Mystery of 1 Extra Damage - A Unit is Attacked

Status
Not open for further replies.
Level 2
Joined
Jan 6, 2013
Messages
11
Hello, I've made a 'battle engine' for my game, which controls the damage of all units in the game (not many so far). Units do not have damage through the object editor, its all done through triggering. Anyways, it works fine in all respects except one: for some reason, whenever a unit attacks a unit for the first time, the attacked unit ALWAYS takes 1 damage. Whenever a unit is at full HP, the first attack always does at least 1 damage (whether hit or miss, as per the battle engine) (if it hits, it does 1 extra damage). This only happens on the first attack against a full HP target; all other attacks deal damage as intended (no 1 extra damage). Heres the relevent part of my trigger (only the swordsman has been triggered completely):

  • -------- 20% MISS chance --------
    • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
    • Floating Text - Create floating text that reads 1 above (Attacked unit) with Z offset 10.00, using font size 8.00, color (0.00%, 100.00%, 0.00%), and 25.00% transparency
    • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
    • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Attacking unit)) Equal to Fishling
            • (Unit-type of (Attacking unit)) Equal to Swordsman
      • Then - Actions
        • -------- miss chance --------
        • Set Random = (Random integer number between 1 and 100)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Random Less than or equal to 20
          • Then - Actions
            • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
            • Floating Text - Create floating text that reads x above (Attacking unit) with Z offset 10.00, using font size 8.00, color (0.00%, 0.00%, 100.00%), and 25.00% transparency
            • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
            • Floating Text - Change (Last created floating text): Disable permanence
            • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
            • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Else - Actions
            • -------- armor deflection --------
            • Set Armor = (Random integer number between 1 and 100)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Armor Less than or equal to (((Level of Armor for (Attacked unit)) x 1) + 0)
              • Then - Actions
                • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                • Floating Text - Create floating text that reads x above (Attacked unit) with Z offset 10.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 25.00% transparency
                • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
                • Floating Text - Change (Last created floating text): Disable permanence
                • Floating Text - Change the lifespan of (Last created floating text) to 0.75 seconds
                • Floating Text - Set the velocity of (Last created floating text) to 95.00 towards 90.00 degrees
              • Else - Actions
                • -------- Unit TYPE --------
                • -------- FISHLING --------
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Unit-type of (Attacking unit)) Equal to Fishling
                  • Then - Actions
                    • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Random real number between 8.00 and 12.00) damage of attack type Chaos and damage type Normal
                  • Else - Actions
                    • -------- SWORDSMAN --------
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Unit-type of (Attacking unit)) Equal to Swordsman
                      • Then - Actions
                        • Set Damage = 20.00
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • (Level of Polearm for (Attacked unit)) Greater than or equal to 1
                          • Then - Actions
                            • Set Damage = (Damage x 1.25)
                          • Else - Actions
                        • -------- evasion --------
                        • Set Evasion = (Random integer number between 1 and 100)
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • Evasion Less than or equal to ((Level of Evasion (mine) for (Attacked unit)) + 0)
                          • Then - Actions
                            • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                            • Floating Text - Create floating text that reads x above (Attacked unit) with Z offset 7.00, using font size 8.00, color (100.00%, 0.00%, 0.00%), and 25.00% transparency
                            • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
                            • Floating Text - Change (Last created floating text): Disable permanence
                            • Floating Text - Change the lifespan of (Last created floating text) to 0.75 seconds
                            • Floating Text - Set the velocity of (Last created floating text) to 125.00 towards 90.00 degrees
                            • Set Parry = (Random integer number between 1 and 100)
                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • Parry Less than or equal to ((Level of Parry for (Attacked unit)) + 0)
                              • Then - Actions
                                • Set PointParry = (Position of (Attacking unit))
                                • Unit - Cause (Attacked unit) to damage (Attacking unit), dealing (Damage x 1.50) damage of attack type Chaos and damage type Normal
                                • Unit - Create 1 Special Effect: Devour for (Owner of (Attacking unit)) at PointParry facing Default building facing degrees
                                • Unit - Add a 1.75 second Generic expiration timer to (Last created unit)
                                • Custom script: call RemoveLocation(udg_PointParry)
                              • Else - Actions
                          • Else - Actions
                            • Set Critical = (Random integer number between 1 and 10)
                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • Critical Less than or equal to 1
                              • Then - Actions
                                • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                                • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Damage x 2.00) damage of attack type Chaos and damage type Normal
                                • Special Effect - Create a special effect attached to the head of (Attacked unit) using Objects\Spawnmodels\Orc\Orcblood\OrcBloodHellScream.mdl
                                • Set SpecialEffect = (Last created special effect)
                                • Special Effect - Destroy SpecialEffect
                              • Else - Actions
                                • Set Execute = (Random integer number between 1 and 20)
                                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • If - Conditions
                                    • Execute Less than or equal to 1
                                  • Then - Actions
                                    • Set Point = (Position of (Attacked unit))
                                    • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                                    • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing 300.00 damage of attack type Chaos and damage type Normal
                                    • Unit - Create 1 Special Effect: Skull and Bones for (Owner of (Attacking unit)) at Point facing Default building facing degrees
                                    • Unit - Add a 1.75 second Generic expiration timer to (Last created unit)
                                    • Custom script: call RemoveLocation(udg_Point)
                                  • Else - Actions
                                    • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing Damage damage of attack type Chaos and damage type Normal
                      • Else - Actions
      • Else - Actions
Heres the entire trigger:

  • Battle Engine
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • -------- 20% MISS chance --------
      • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
      • Floating Text - Create floating text that reads 1 above (Attacked unit) with Z offset 10.00, using font size 8.00, color (0.00%, 100.00%, 0.00%), and 25.00% transparency
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
      • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Attacking unit)) Equal to Fishling
              • (Unit-type of (Attacking unit)) Equal to Swordsman
        • Then - Actions
          • -------- miss chance --------
          • Set Random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Random Less than or equal to 20
            • Then - Actions
              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
              • Floating Text - Create floating text that reads x above (Attacking unit) with Z offset 10.00, using font size 8.00, color (0.00%, 0.00%, 100.00%), and 25.00% transparency
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
            • Else - Actions
              • -------- armor deflection --------
              • Set Armor = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Armor Less than or equal to (((Level of Armor for (Attacked unit)) x 1) + 0)
                • Then - Actions
                  • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                  • Floating Text - Create floating text that reads x above (Attacked unit) with Z offset 10.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 25.00% transparency
                  • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.75 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to 95.00 towards 90.00 degrees
                • Else - Actions
                  • -------- Unit TYPE --------
                  • -------- FISHLING --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Attacking unit)) Equal to Fishling
                    • Then - Actions
                      • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Random real number between 8.00 and 12.00) damage of attack type Chaos and damage type Normal
                    • Else - Actions
                      • -------- SWORDSMAN --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Attacking unit)) Equal to Swordsman
                        • Then - Actions
                          • Set Damage = 20.00
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Level of Polearm for (Attacked unit)) Greater than or equal to 1
                            • Then - Actions
                              • Set Damage = (Damage x 1.25)
                            • Else - Actions
                          • -------- evasion --------
                          • Set Evasion = (Random integer number between 1 and 100)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Evasion Less than or equal to ((Level of Evasion (mine) for (Attacked unit)) + 0)
                            • Then - Actions
                              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                              • Floating Text - Create floating text that reads x above (Attacked unit) with Z offset 7.00, using font size 8.00, color (100.00%, 0.00%, 0.00%), and 25.00% transparency
                              • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
                              • Floating Text - Change (Last created floating text): Disable permanence
                              • Floating Text - Change the lifespan of (Last created floating text) to 0.75 seconds
                              • Floating Text - Set the velocity of (Last created floating text) to 125.00 towards 90.00 degrees
                              • Set Parry = (Random integer number between 1 and 100)
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Parry Less than or equal to ((Level of Parry for (Attacked unit)) + 0)
                                • Then - Actions
                                  • Set PointParry = (Position of (Attacking unit))
                                  • Unit - Cause (Attacked unit) to damage (Attacking unit), dealing (Damage x 1.50) damage of attack type Chaos and damage type Normal
                                  • Unit - Create 1 Special Effect: Devour for (Owner of (Attacking unit)) at PointParry facing Default building facing degrees
                                  • Unit - Add a 1.75 second Generic expiration timer to (Last created unit)
                                  • Custom script: call RemoveLocation(udg_PointParry)
                                • Else - Actions
                            • Else - Actions
                              • Set Critical = (Random integer number between 1 and 10)
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Critical Less than or equal to 1
                                • Then - Actions
                                  • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                                  • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Damage x 2.00) damage of attack type Chaos and damage type Normal
                                  • Special Effect - Create a special effect attached to the head of (Attacked unit) using Objects\Spawnmodels\Orc\Orcblood\OrcBloodHellScream.mdl
                                  • Set SpecialEffect = (Last created special effect)
                                  • Special Effect - Destroy SpecialEffect
                                • Else - Actions
                                  • Set Execute = (Random integer number between 1 and 20)
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • Execute Less than or equal to 1
                                    • Then - Actions
                                      • Set Point = (Position of (Attacked unit))
                                      • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
                                      • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing 300.00 damage of attack type Chaos and damage type Normal
                                      • Unit - Create 1 Special Effect: Skull and Bones for (Owner of (Attacking unit)) at Point facing Default building facing degrees
                                      • Unit - Add a 1.75 second Generic expiration timer to (Last created unit)
                                      • Custom script: call RemoveLocation(udg_Point)
                                    • Else - Actions
                                      • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing Damage damage of attack type Chaos and damage type Normal
                        • Else - Actions
        • Else - Actions
      • -------- 40% MISS chance --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Attacking unit)) Equal to Spearman
        • Then - Actions
          • -------- miss chance --------
          • Set Random = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Random Less than or equal to 40
            • Then - Actions
              • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
              • Floating Text - Create floating text that reads x above (Attacking unit) with Z offset 10.00, using font size 8.00, color (0.00%, 0.00%, 100.00%), and 25.00% transparency
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
            • Else - Actions
              • -------- armor deflection --------
              • Set Armor = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Armor Less than or equal to (((Level of Armor for (Attacked unit)) x 1) + 0)
                • Then - Actions
                  • Floating Text - Create floating text that reads x above (Attacked unit) with Z offset 10.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 25.00% transparency
                  • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.75 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to 95.00 towards 90.00 degrees
                • Else - Actions
                  • -------- Unit TYPE --------
                  • -------- SPEARMEN --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Attacking unit)) Equal to Spearman
                    • Then - Actions
                      • Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Random real number between 5.00 and 10.00) damage of attack type Chaos and damage type Normal
                    • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Percentage life of (Attacked unit)) Equal to 100.00
              • (Percentage life of (Attacked unit)) Equal to 99.00
        • Then - Actions
          • Game - Display to (All players) the text: poo
          • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
          • Set Point = (Position of (Attacked unit))
          • Unit - Create 1 DummyHeal for (Owner of (Attacked unit)) at Point facing Default building facing degrees
          • Unit - Add a 0.25 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Human Priest - Heal (Attacked unit)
          • Custom script: call RemoveLocation(udg_Point)
        • Else - Actions
Thanks for reading, and any help is appreciated!
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
attacked unit event fires earlier than the unit takes real damage, it fires when unit starts the attack animation, so you will try to heal unit which has full life and after that the unit takes the damage
I recommend using Damage Detection System, Bribe has good one in spells section
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
It sounds like you could actually mitigate the damage by changing your unit's attack damage from "1 - 1" to "0 - 0" - you can do this by changing its base attack damage to -1, then change it's number of dice and sides per dice each to 1.

If you're already doing that and somehow units are taking 1 damage extra, a DDS will be necessary.
 
Status
Not open for further replies.
Top