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

[JASS] Changing Spell-Values during the game?

Status
Not open for further replies.
Level 14
Joined
Dec 12, 2012
Messages
1,007
Hello

I have a question which I wasn't able to solve until now: Is it possible to change the values of a ability/spell during the game?

If I have for example a Skill that gives me +20 Damage, and I want that everytime my Hero gots hit, its Damage increases. So first hit: +25 Damage, second hit +30 Damage and so on...

How could I realize this?

Any help is appreciated :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Unfortunately, something like that can only* be done with a damage detection system and the skill must be triggered.
GDD is still a good GUI-friendly damage detection system (that doesn't require JNGP).
How the skill needs to be triggered depends on what it does exactly.


* I am strongly against using many ability levels, 50 should always be the absolute maximum (I recommend about 20 though).
For that, I don't count "level the ability each time the hero is hit" as a valid option.
 
Last edited:
Level 7
Joined
Nov 15, 2009
Messages
225
Is it a hero or a normal ability?

If it's a hero ability you need other systems, mentioned above.
If you use a normal ability, because you only need 1 level you can do it very easy on your own.

You need 1 trigger and 1 spell.

The trigger is something like that:
Code:
function Trig_DamageLevelUp_Actions takes nothing returns nothing
   local unit u = GetTriggerUnit()
   if (GetUnitAbilityLevelSwapped('SPELL ID', u) > 0) then
      if (GetUnitAbilityLevelSwapped('SPELL ID', u) < SPELL MAX LEVEL) then
         call SetUnitAbilityLevelSwapped('SPELL ID', u, (GetUnitAbilityLevelSwapped('SPELL ID', u) + 1 ))
      else
      endif
   else
   endif
   set u = null
endfunction

function InitTrig_DamageLevelUp takes nothing returns nothing
   local trigger t = CreateTrigger()
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
   call TriggerAddAction(t, function Trig_DamageLevelUp_Actions)
   set t = null
endfunction

You need to replace SPELL ID with the spell id and Spell max level with the max level as integer of course.

And 1 spell.. just take a normal spell which gives your unit damage.
You need a few levels for that spell, first levels amount is the normal damage and anything else is the damage increasion + normal damage.
Example:
Level 1 = 20 damage
Level 2 = 22 damage

Which means if you recieve the spell you deal +20 damage and if your unit takes damage you deal +22 damage.


For beginners its a good option for getting a spell, using copy and pasted systems you don't understand doesn't make you a better map maker anyway.


Hope I could help you..
 
Last edited:
Level 14
Joined
Dec 12, 2012
Messages
1,007
Hello,

thank you both, that is interesting.

But I meant this more generaly, not only for the case that the hero gots hit (the damage-detection is not the problem). I'll give another example, sorry the first wasn't clearly pointing out what I am looking for.

I meant I want to tune a hero-ability during the game, dependend on any condition (the condition is not important).

For example, my Hero has evasion (that has a certain percentage for evading an attack, lets say 20%). Now I want to change this percentage dependend on a given condition (to, lets say 10%). The Skill is a normal Hero-Ability and has 3 Levels.

Is this possible?

Greetings,
lfh
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
no. u can still use damage detection to trigger the evasion -_- but anything in the object editor cant be edited after the values are put in
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Wow thats really bad news :(

Untill now I did it this way (minimal-example):

JASS:
function Trig_myTrig_Actions takes nothing returns nothing



    if udg_myFlag == 1 then

        set udg_myFlag = 0
        call UnitRemoveAbility( myUnit , mySkill)
        
    endif


    if udg_myFlag == 0 then

         set udg_myFlag = 1
         call UnitAddAbility( myUnit , mySkill)

    endif


endfunction

Just every time the given condition is true, a self-made ability should be switched. This works, BUT the hero keeps the animation of the ability, although it was already removed. The hero does not have the effect, but the animation.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Consider upgrading to StarCraft II. Map makers for that game have access to the catalog natives that allow you to change a large variety of fields during gameplay for specific players. For example, you could increase the game of snipe for a specific player.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Consider upgrading to StarCraft II. Map makers for that game have access to the catalog natives that allow you to change a large variety of fields during gameplay for specific players. For example, you could increase the game of snipe for a specific player.

Id reccommend atleast a year of experience before moving to sc2. I've been coding for 3 years but Im still an uber noob at the sc2 editorial
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
uh.. kinda...

whenever you call that trig it will just flip the ability. so if u have x it will remove x and add y, if u have y it will remove y and add X.

id also reccommend setting level of x/y when removing

also, this wnt work for auras
 
Hi again,

yes it does flip the ability, and I fixed the problem with the animation, so it works fine now. I just had to add a PolledWait of half a second, and now the animation is changed correctly.

Thank you all for helping!

Use timer instead because polled wait use it as well together with many other for you useless shit.

call TimerStart(CreateTimer(), 0.5, false, function Run)

and then in Run function finish your spell.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Hi,

thanks for this advice, this works very good for me now.

But according to timers, I have another question. I have two conditions:

Condition 1 true: Variable x should be set to 1 after 30 seconds
Condition 2 true: Variable x should be set to 1 instantly

The problem now is, that if Condition 2 is true, the timer started in Condtion 1 should be killed/stopped. How can I realize this?

There is the PauseTimer function, but how can I get the timer specified in Condition 1 into a variable so that I can give it to function PauseTimer?

And: Is pause timer enough, or will there be Memory-Leak-Problems if this happens very often, because I would have then hundreds of paused timers?

Greetings,
lfh
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Ok,

but doesn't

JASS:
call TimerStart(CreateTimer(), 0.5, false, function Run)

allways create a new timer, which when it is only paused never gets destroyed?

What I would like to know is how can I write a specific timer into a specific variable,
so that I can destry exactly that timer whenever I want.
 
Ok,

but doesn't

JASS:
call TimerStart(CreateTimer(), 0.5, false, function Run)

allways create a new timer, which when it is only paused never gets destroyed?

What I would like to know is how can I write a specific timer into a specific variable,
so that I can destry exactly that timer whenever I want.

Nah just to
call DestroyTimer(GetExpiredTimer())
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
well yeah it will always leak because

call TimerStart(CreateTimer()

but

call TimerStart(variable

will not leak. Kobas's workaround will work for clearing the leak if u use CreateTimer() but you will not be able to stop it mid-timer
 
Status
Not open for further replies.
Top