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

How to make Critical Strikes work on spells and items

Level 7
Joined
Jun 4, 2006
Messages
127
INTRODUCTION

Ever thought of the idea "Hey, I want to make a Passive ability where both my attacks and spell damages are doubled, or tripled!" but then you are unable to do it?

Well then I have good news for you! I, denmax, have made this tutorial for you to make a passive ability where your attacks, spell damages, and even spell damages from items are multiplied to your wanting! This tutorial only shows a One Level Critical Strike, which only triples the damages the unit does.



THE ESSENTIALS

First things is first. You should have a Damage Detection Trigger. You may ask "What's a Damage Detection Trigger?" Well a Damage Detection Trigger is a trigger where it's actions will try to add the "Takes damage" event to a specific trigger, which would be our Critical Strike ability.

Let's name this trigger: DDT
  • DDT
    • Events
      • Map initialization
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BooleanVar[1] Equal to False
        • Then - Actions
          • Set BooleanVar[1] = True
          • Set UnitGroupVar = (Units in (Playable map area))
          • Unit Group - Pick every unit in UnitGroupVar and do (Actions)
            • Loop - Actions
              • Trigger - Add to Critical Strike <gen> the event (Unit - (Picked unit) Takes damage)
          • Custom script: call DestroyGroup(udg_UnitGroupVar)
        • Else - Actions
          • Trigger - Add to Critical Strike <gen> the event (Unit - (Triggering unit) Takes damage)
Variables:
> UnitGroupVar = a unit group variable
> BooleanVar = a boolean variable


This trigger plainly tries to pick all preplaced units in the map. After so, it sets a boolean "True" so it doesn't have to pick all the same unit again and again, but then picks the units that enter the Playable Map Area. A simple saying would be, it allows all units in the map to have a possibility from the Critical Strike ability unless placed with a new condition.



THE TRIGGER

Now we are on with the trigger itself. Let's start out by creating some variables.

>IntegerVar = a integer variable

We first have to set the conditions of the trigger. Remember that the DDT adds the event to this trigger which we will be calling Critical Strike..
The condition should check if the "Damage source" has Critical Strike. We also have to make sure that the Damage taken is greater than 0 to avoid multiplying 0 damage (which usually happens for some unknown reason)
  • Critical Strike
    • Events
    • Conditions
      • (Level of Critical Strike for (Damage source)) Greater than 0
      • (Damage taken) Greater than 0.00
If you would want the spell to "not work" on magic immune enemies then simply place in the conditions this command

  • ((Damage source) is Magic immune) not Equal to True

After applying this commands, we shall continue with the actions...
To start, we must make sure that the Critical Strike is done by chances. Let's say our chance is 15.00%.
  • Critical Strike
    • Events
    • Conditions
      • (Level of Critical Strike for (Damage source)) Greater than 0
      • (Damage taken) Greater than 0.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer between 1 and 100) Less than or Equal to 15
        • Then - Actions
        • Else - Actions
If you want to change the chances, you may change the value "15" under the If conditions to anything between 1 to 100.


The next step would be to do the damage. First we must Turn off the trigger. Do not worry, this will not malfunction the trigger one bit since we will be turning it on after all actions are done.

We must set the Integer Variable to the desired damage. I want the damage to be multiplied by 3.00.
  • Critical Strike
    • Events
    • Conditions
      • (Level of Critical Strike for (Damage source)) Greater than 0
      • (Damage taken) Greater than 0.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer between 1 and 100) Less than or Equal to 15
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set IntegerVar = (Real((Damage taken) x 2.00))
          • Unit - Cause (Damage source) to damage (Triggering unit), dealing IntegerVar damage of attack type Hero and damage type Normal
        • Else - Actions
If you want to change the critical multiplication, change the field in IntegerVar where there is 2.00 to any number. Remember that the damage is done first then is multiplied. So quite frankly, it multiplied the damage taken by 2, which is already taken by the target so it then takes 3 times the damage.
In logic: Damage taken by target (from the normal attack) + Damage that has been multiplied = Total damage



Now we need the Floating Text. The Floating text is the numbers that appear above a unit when it does a normal Critical Strike. The one in Evasion and obtaining gold is also called a Floating Text
The string value should be right. We need to convert the arithmetic of (Damage taken + (IntegerVar)). Let's also make sure that the Floating text is red. So 100% red and no other percentage for the other colors. We'll also disable its Permanent Status so it can fade and be destroyed (by lifespan). We'll also allow the Floating Text to move up while fading, like most floating text do.
  • Critical Strike
    • Events
    • Conditions
      • (Level of Critical Strike for (Damage source)) Greater than 0
      • (Damage taken) Greater than 0.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer between 1 and 100) Less than or Equal to 15
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set IntegerVar = (Real((Damage taken) x 2.00))
          • Unit - Cause (Damage source) to damage (Triggering unit), dealing IntegerVar damage of attack type Hero and damage type Normal
          • Floating Text - Create floating text that reads (String(((Damage Taken) + IntegerVar)) + !) 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 - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 0.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 90.00 towards 90.00 degrees
          • Trigger - Turn on (This trigger)
        • Else - Actions
IntegerVar, as you may know, is an integer variable. You must set it to a conversion to a real to have damage taken multiplied by 3.00

You may ask "Why do we have to go through an integer variable if we can just make a real variable instead?" Well, you may know that reals record the decimals within numbers in WCIII. If so, then when we show those numbers to the Floating Text, the decimals will be shown making it look very ugly. Integers, however, remove the decimals of a number thus making it look like the true Critical Strike floating texts.

Remember that the floating text of this type of Critical Strike is a multiplication of the true damage taken, not a multiplication of the ordinary damage of the Hero.


THINGS TO CONSIDER

There are some things you have to put your attention on.

• In AoE (both spells and siege attack) and Waves multiplication of damages is by target, not by spell.
• I can't seem to make it multiply only spells or attacks. It has to multiply every damage dealt by a unit with the custom "Critical Strike".
• Floating Text appears above the Hero. If it makes multiple criticals in one time then multiple floating texts also appear above it.
• This ability is MUI
• You are able to rename the variables. If you are prepared to rename the unit group variable please be sure to edit the Custom script as well (udg_<your variable name>). Custom scripts are CASE SENSITIVE.
• Please do not remove the "Turn off" and "Turn on" triggers from the Critical Strike trigger. This keeps the trigger from infinite loops.
• You are able to recolor the Floating Texts or even change the string value. It may not be the damage but also something humorous or anything of your wanting.
• There are no problems in renaming your triggers as well
• Unauthorized duplication and copying of this tutorial is supported. I don't care about credit. The only thing I care about is the idea that I have helped people.
 
Last edited:
Level 10
Joined
Aug 19, 2008
Messages
491
This tutorial isn't very user friendly :sad:
I read the "The Essentials" part and I got lost in it, mostly because of your wierd variable names, and no explenation at all (except what the triggers will do).

Let's take this line as an example:
Now we are on with the trigger itself. Let's start out by creating some variables.
My first thought was "ok... why?"
And then you jump right into the trigger and I ask myself "why do we need variables?"
Ok I know that every good trigger needs variables, but the speed of this tutorial is too high! Why are you hasting? Chill down...

You should consider that not everyone who read these tutorials are pro-GUI'ers,
there are guys like me who wanna understand what we're doing and not just do it right away.


I gotta admit that I like your layout though. Clear headlines, colored parts and a personal attitude.
If you think about what I've said this can become a great tutorial.
 
Last edited:
Does it matter if it leaks?
If someone wanna know what leaks, he/she should read that thread Ralle made on "Things that leak" and he/she can fix that him/herself.
Adding that to a tutorial on topics like this will only unneccessarily expand it.

You should still deleak this, because otherwise people will just copy this and end up having a leaky map.

So yeah. Deleak this.
 
Level 24
Joined
Feb 28, 2007
Messages
3,479
Seems promising at first glance. The formatting and the content seems good enough for approval, also seems detailed and easy for the reader to follow which are other good things. But yeah, needs deleaking or otherwise has no chance of approval, since tutorials are not made to teach people wrong.
 
Top