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

[Solved] Spell dont work

Status
Not open for further replies.
Level 3
Joined
Jun 17, 2011
Messages
18
hi guys, i have a problem i made a spell which calculates the original ability damage, then adds % bonus damage, then checks if crit or not.
But the spell dont do any damage not even 0,
anybody there who can tell me what i did wrong?

Thanks in advantage:ogre_haosis:

Heres the trigger

Deadly Strike
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Deadly Strike
Actions
Set DeadlyStrikeCaster = (Triggering unit)
Set DeadlyStrikeSingleTarget = (Target unit of ability being cast)
Set DeadlyStrikeTarget = (Position of (Target unit of ability being cast))
Set DeadlyStrikeEnemies = (Units within 500.00 of DeadlyStrikeTarget matching ((((Matching unit) is A Hero) Not equal to True) and ((((Matching unit) is Ethereal) Not equal to True) and ((((Matching unit) is dead) Not equal to True) and (((Matching unit) belongs to an enemy of (Owner
Special Effect - Create a special effect at DeadlyStrikeTarget using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
-------- Calculate Spell Damage Multiplier --------
Set SpellDamageMultiplier = 3
-------- Calculate Spell Damage --------
Set DeadlyStrikeDamage = ((Integer((Real((Strength of DeadlyStrikeCaster (Include bonuses)))))) x SpellDamageMultiplier)
-------- Calculate Spell Damage Bonus --------
Set FinalDmg_SpellBonus = 20
Unit Group - Pick every unit in DeadlyStrikeEnemies and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 1 and 100) Less than or equal to CritChance[(Player number of (Owner of DeadlyStrikeCaster))]
Then - Actions
Set FinalDmg1 = (DeadlyStrikeDamage / 100)
Set FinalDmg2 = (100 + FinalDmg_SpellBonus)
Set FinalDmg3 = (FinalDmg1 x FinalDmg2)
Set FinalDmg4 = (FinalDmg3 x 2)
Unit - Cause DeadlyStrikeCaster to damage (Picked unit), dealing (Real(FinalDmg4)) damage of attack type Normal and damage type Normal
Else - Actions
Set FinalDmg1 = (DeadlyStrikeDamage / 100)
Set FinalDmg2 = (100 + FinalDmg_SpellBonus)
Set FinalDmg3 = (FinalDmg1 x FinalDmg2)
Set DamageConvert = (Real(FinalDmg3))
Unit - Cause DeadlyStrikeCaster to damage (Picked unit), dealing DamageConvert damage of attack type Normal and damage type Normal
 
Last edited:
Level 3
Joined
Jun 17, 2011
Messages
18
alright edited, the spell works correctly when i set the damage for example to 200 but not when i use the calculated damage.
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
How much strength does your hero have?
You are calculation the damage through integers. That means everything behind the decimal point is lost during calculations.

Assuming your hero has 40 strength with bonuses. Final damage1 = strength/100 = 40/100 = 0

A few things I noted when reading your trigger:
Instead of this:
Code:
If (attack crits) then
    Set damage1 = ...
    Set damage2 = ...
    Set damage3 = ...
    Set damage4 = damage3 * 2
    Damage target dealing damage4 damage...
Else
    Set damage1 = ...
    Set damage2 = ...
    Set damage3 = ...
    Damage target dealing damage3 damage...

You can simplify it into this:
Code:
Set damage1 = ...
Set damage2 = ...
Set damage3 = ...
If (attack crits) then
    Set damage4 = damage3 * 2
Else
    Set damage4 = damage3
Damage target dealing damage3 damage...

You can reuse the same variable in calculations.
Instead of
damage1 = ...
damage2 = damage1 /100
damage3 = damage2 + 36
etc.

You can do this:
damage1 = ....
damage1 = damage1 / 100
damage1 = damage1 + 36
etc.

Or better yet - make it a single-line calculation:
damage1 = (....)/100 + 36

Last thing:
The basic damage is same for all damaged units. As such the calculation should happen outside the unit group iteration. Inside unit group iteration you just check for the chance on critical strike and if it should be critical, you deal 2x damage instead.
 
Level 3
Joined
Jun 17, 2011
Messages
18
alright that makes sense.
It works now, thank you for the help, wish you a great day. :)
 
Status
Not open for further replies.
Top