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

[General] Question about setting variables

Status
Not open for further replies.
Level 2
Joined
Jan 2, 2013
Messages
16
It's possible to set a variable like this at the begining of the map:
  • Set SpellDamage[0] = ((Intelligence of DamageEventSource (Include bonuses)) + 6)
and when I use the variable SpellDamage to get automatically the Intelligence of the damage source?

Or do I need to set the formula everytime the spell is casted?
 
Level 2
Joined
Jan 2, 2013
Messages
16
I just tried and it doesn't work :(
I created a game message to tell the result of the formula and it's always coming 6 and that because in the formula is Int of the SourceDamage + 6

What I was trying to ask was if I can do something like this:
Formula = A * X
A - a number, let's say 7
X - a function that takes a number from somewhere (that can change anytime, agi/int/str etc...)

The formula being set at the Map Initiation, and to be used to determinate the damage (changing in function of the stats in the moment the spell is casted) a spell must do
 
Level 2
Joined
Jan 2, 2013
Messages
16
I have made an spell that after casting a spell, for the next 5 sec, the unit is dealing X damage around the unit is auto-attacking. I am using Damage Engine v2.2.1.0 to detect the damage hit.
So I guess the message is after.
Here is the first trigger:
  • BF
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Burning Fists
    • Actions
      • Trigger - Turn on BF Dmg <gen>
      • Wait (Real(SpellDuration[((Level of (Ability being cast) for (Triggering unit)) - 1)])) game-time seconds
      • Trigger - Turn off BF Dmg <gen>
And the second:

  • BF Dmg
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has buff Burning Fists ) Equal to True
      • DamageEventType Not equal to DamageTypeSpell
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 160.00 of (Position of DamageEventTarget) matching (((Matching unit) belongs to an ally of (Owner of DamageEventTarget)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set DamageEventType = DamageTypeSpell
          • Unit - Cause DamageEventSource to damage (Picked unit), dealing (Real(SpellDamage[((Level of Burning Fists for DamageEventSource) - 1)])) damage of attack type Spells and damage type Fire
      • Game - Display to (All players) the text: (String(SpellDamage[0]))
 
"Unit - Cause DamageEventSource to damage (Picked unit), dealing (Real(SpellDamage[((Level of Burning Fists for DamageEventSource) - 1)])) damage of attack type Spells and damage type Fire"

Instead of the bolded text use the SpellDamage[0]

The "Set SpellDamage[0]" should be done in the map initialization.

Also. That wait you have. While I'm pretty sure that's not the problem here, it could very well become a problem later on.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
I don't think it will work if you set SpellDamage[0] at map initialization.
The SpellDamage[0]'s calculation is ((Intelligence of DamageEventSource (Include bonuses)) + 6)
As SpellDamage[0] is (most likely) a real variable (thus it's not handle) and the function Intelligence of unit returns value, not pointer to handle, it will not get actualized. The whole thing will actually look like as "((Intelligence of No Unit(Include bonuses)) + 6)", since at map initialization there is no unit to which the DamageEventSource points to, thus the function "Intelligence of unit" returns number 0 (default value). So your calculation at map ini will be 0+6, which correctly saves number 6 into SpellDamage[0].

You actually want to calculate the amount of damage when the damage event fires (thus DamageEventSource variable points at correct unit and you can get its stats)
 
Level 2
Joined
Jan 2, 2013
Messages
16
It's still not working... I tried to do even this from the Map Initiation:
C=A+B
A=5

and when unit hits something set B = int of unit and send the game message with the result and it's 5 (not 11 from 5+6 int)

@edit: @Nichilus: So that means I need to do the settings for the spell everytime the unit attacks?
 
No, it won't. It will save SpellDamage as using the current intelligence of the unit in question. You have to set the variable every time you want to damage the unit using it. Variables are not dynamic; they just store the data that you input into them.

But the DamageEventSource is set every time the spell is cast. Only the formula will stay static.
I'll have to test it myself I guess.
 
Level 2
Joined
Jan 2, 2013
Messages
16
Oh, and i forgot to ask...
Why I will be having problems with the Wait later? I did a search on the forum and all I found is that they are not very accurate. If I set it to 5 sec the real value will be something between 4.75-5.25, that's all that I have found....
Few milliseconds more or less of a "buff" won't affect so much the gameplay right?
And if I don't use Wait, what should I use? Make an other trigger that is checking periodic if the unit has the buff from the dummy spell, if the buff is on let the damage trigger on and when is gone turn it off? Won't it consume to many resources if I do this for every spell?
 
Oh, and i forgot to ask...
Why I will be having problems with the Wait later? I did a search on the forum and all I found is that they are not very accurate. If I set it to 5 sec the real value will be something between 4.75-5.25, that's all that I have found....
Few milliseconds more or less of a "buff" won't affect so much the gameplay right?
And if I don't use Wait, what should I use? Make an other trigger that is checking periodic if the unit has the buff from the dummy spell, if the buff is on let the damage trigger on and when is gone turn it off? Won't it consume to many resources if I do this for every spell?

Yeah the wait in inaccurate. That's one thing. The bigger problem is it can desync players because all players have different latency. I don't know the exact details or the "correct" explanation. Just stay away from them ;)

A periodic trigger is far better. You should only have the trigger running if a buff is in effect however.
Usually you run the periodic trigger by seconds. Set an integer index and either a unit group or unit index.
The integer index counts the seconds, and when an integer reaches 0 you either deindex the corresponding unit, or throw the unit in question out of the unit group.

When the unit index, or unit group, is 0 or empty you turn off the periodic trigger. Only to turn it on again when a new buff is applied.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Solu, what you think cannot work as it wouldn't even make sense, nor save any time. It would just limit you.

The whole WCIII script works by using assignment statements and pointer logic.

What you think it would do doesn't make sense, because you actually wouldn't save any value into the real variable, you would have to save the whole command into it (what function to call, who does the function call, arithmetic, etc.). It wouldn't save you anything, because still the same functions would be called no matter what.

Another thing is more of a logic behind it. Let's say you play the game and have your hero with level 1 and 27 Intelligence. You know how much intelligence he has, but if that hero levels up by X levels (you don't know how many levels) and gains some items with Intelligence stats (you don't know which and how many), then do you still know how much Intelligence your hero has? You won't know -> you'll have to look at his stats.
This is the same for the game. The game *doesn't look* at your heroes stats when it doesn't need it as that would be unnecessary process - you have to tell the game that you want to know that hero's stats.
 
Status
Not open for further replies.
Top