Help with damage based on intelligence

Level 9
Joined
Jun 10, 2013
Messages
473
Hey i'm trying to make a spell that damages unit with in 200 Aoe of the target point of ability being cast based on the level of intelligence my hero has multiplies by the level of the ability being cast but my trigger for some reason isn't working :

  • Arcane Blast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Blast
    • Actions
      • Set TempUnit2 = (Triggering unit)
      • Set TempUnit = (Picked unit)
      • Set TempPoint = (Target point of ability being cast)
      • Set TempInteger = (Intelligence of TempUnit2 (Include bonuses))
      • Set ability_level = (Level of Arcane Blast for TempUnit2)
      • Set tempGroup1 = (Units within 200.00 of TempPoint)
      • Unit Group - Pick every unit in tempGroup1 and do (Actions)
        • Loop - Actions
          • Unit - Set life of TempUnit to ((Life of TempUnit) - ((Real(TempInteger)) x (Real(ability_level))))
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_tempGroup1)
any help would be greatly appreciated :)
 
Last edited:
Level 4
Joined
Jul 26, 2016
Messages
88
Hey i'm trying to make a spell that damages unit with in 200 Aoe of the target point of ability being cast based on the level of intelligence my hero has multiplies by the level of the ability being cast but my trigger for some reason isn't working :

  • Arcane Blast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Blast
    • Actions
      • Set TempUnit2 = (Triggering unit)
      • Set TempUnit = (Picked unit)
      • Set TempPoint = (Target point of ability being cast)
      • Set TempInteger = (Intelligence of TempUnit2 (Include bonuses))
      • Set ability_level = (Level of Arcane Blast for TempUnit2)
      • Set tempGroup1 = (Units within 200.00 of TempPoint)
      • Unit Group - Pick every unit in tempGroup1 and do (Actions)
        • Loop - Actions
          • Unit - Set life of TempUnit to ((Life of TempUnit) - ((Real(TempInteger)) x (Real(ability_level))))
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: call DestroyGroup (udg_tempGroup1)
any help would be greatly appreciated :)


Picked unit only refers to units picked within a (pick every unit...) statement. Put your variable assignment for picked unit inside the unit group action
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I guess you dont fully understand how variables and functions work.

The things like Triggering Unit, Casting Unit, Picked Unit, Target Point Of Ability Being Cast, etc, etc, etc are functions.
These functions return some object from the game.
It is similar to asking someone "Who triggered this trigger?" - "It was Bob."
The thing is that functions (only in WC3) are pretty heavy on the CPU... in theory, it takes the computer quite some time to find out who triggered the trigger.
To avoid asking many times, you store it in a variable.

A variable (just like the global variables, presets, etc) is like a box that contains a pointer to the object from the game.
For example, a pointer that is pointing to Bob.
(variables hold values instead of pointers for primitive variable types (string, integer, real, boolean, code(?)))

What you do at the start of this trigger (Set TempUnit = (Picked unit)), is ask the game who the currently picked unit is.
And you put a pointer to that unit in the TempUnit variable.
The problem is that you were not in a unit group, so the Picked Unit function returns null (aka nothing).
The pointer to null is not going to change until you set TempUnit to something else.
So you substract life from null... not the picked units.

I guess you can understand where to put things now.

(And indeed, you should use "Unit - Damage Target" to have a killing unit if the unit dies and apply resistances to the value.)
 
As a tip, don't use so many variables. That is, unless you plan on reusing them later. In this scenario you can probably not use any variables at all and use directly, Picked unit, Triggering unit, etc. Using too many variables will slow down your map. I was making a map once and a script was running too slow. I removed the variables and replaced them and it went perfectly fine after.

Picked unit returns null if there was no picked unit at the time.
 
Top