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

Reducing Casting Time by %

Status
Not open for further replies.
Level 7
Joined
Jul 20, 2009
Messages
295
Hello,

I have a spell with 10 second cast time.
And I have a Passive Ability at level 0 and a max level of 3.
Is there a way I could reduce the cast time by (Lvl of Passive Ability*15)% via triggers or some other way?
(Other than create 3x numbers of the same ability each with 15% less cast time and replace the spell each time the lvl of Passive ablity increases.)

Thanks.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Detect - A unit begin casting an ability - (The ability which CD is reduced by the passive)
- Start a one shot timer that will expire in 10 - PassiveLevel*1.5.

When the timer expires do the ability effects and order the unit to cast a hidden ability (in a spellbook) with the same base ID and mana cost and cooldown but no effect. This will make the main/real ability go into cooldown.

You also have to detect "A unit stop casting an ability" and the time left in the timer is greater than 0, in which case you stop everything
 
Level 7
Joined
Jul 20, 2009
Messages
295
Detect - A unit begin casting an ability - (The ability which CD is reduced by the passive)
- Start a one shot timer that will expire in 10 - PassiveLevel*1.5.

When the timer expires do the ability effects and order the unit to cast a hidden ability (in a spellbook) with the same base ID and mana cost and cooldown but no effect. This will make the main/real ability go into cooldown.

You also have to detect "A unit stop casting an ability" and the time left in the timer is greater than 0, in which case you stop everything

Nice idea but I'm not sure how the cooldown thingy will work... I'll try it out.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
If you create 2 abilities based on "berserk" (as example) and cast any of them, both will go into cooldown. If you use one with 10s casting time, and another with instant cast, the 2nd one will make the first one go into cooldown.
 
Level 7
Joined
Jul 20, 2009
Messages
295
If you create 2 abilities based on "berserk" (as example) and cast any of them, both will go into cooldown. If you use one with 10s casting time, and another with instant cast, the 2nd one will make the first one go into cooldown.

It bugs for me, I cant seem to be able to do it, the hero keeps recasting and the fake spell keeps appearing and disappearing in a loop.
May you create a demo for me?

Edit: Well, no, not both spells go into cooldown upon casting one of them.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hmm.. making it "Show" the cooldown animation on the icon is a bit harder. You would have to use the Unit Ability Replace with a gray icon.

JASS:
globals
    hashtable TimedAbilHash = InitHashtable()
endglobals

function UnitReplaceAbilityTimerFunc takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit u = LoadUnitHandle(TimedAbilHash, id, 0)
    local integer abilA = LoadInteger(TimedAbilHash, id, 1)
    local integer abilB = LoadInteger(TimedAbilHash, id, 2)

    call UnitRemoveAbility(u, abilB)
    call UnitAddAbility(u, abilA)

    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushChildHashtable(TimedAbilHash, id)
    set u = null
    set t = null
endfunction

function UnitReplaceAbilityTimed takes unit u, integer abilA, integer abilB, real time returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)

    call UnitRemoveAbility(u, abilA)
    call UnitAddAbility(u, abilB)

    call SaveUnitHandle(TimedAbilHash, id, 0, u)
    call SaveInteger(TimedAbilHash, id, 1, abilA)
    call SaveInteger(TimedAbilHash, id, 2, abilB)

    call TimerStart(t, time, false, function UnitReplaceAbilityTimerFunc)

    set t = null
endfunction

Just use
JASS:
call UnitReplaceAbilityTimed(YourUnit, YourAbilToReplace, YourDisabledAbility, TheCooldownTime)
 
Level 7
Joined
Jul 20, 2009
Messages
295
Like the 1 in my signature ?

Nice.
Though, it's totally a different concept than what I'm talking about and it's about cast time, not cooldown. ^^

Hmm.. making it "Show" the cooldown animation on the icon is a bit harder. You would have to use the Unit Ability Replace with a gray icon.

JASS:
globals
    hashtable TimedAbilHash = InitHashtable()
endglobals

function UnitReplaceAbilityTimerFunc takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit u = LoadUnitHandle(TimedAbilHash, id, 0)
    local integer abilA = LoadInteger(TimedAbilHash, id, 1)
    local integer abilB = LoadInteger(TimedAbilHash, id, 2)

    call UnitRemoveAbility(u, abilB)
    call UnitAddAbility(u, abilA)

    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushChildHashtable(TimedAbilHash, id)
    set u = null
    set t = null
endfunction

function UnitReplaceAbilityTimed takes unit u, integer abilA, integer abilB, real time returns nothing
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)

    call UnitRemoveAbility(u, abilA)
    call UnitAddAbility(u, abilB)

    call SaveUnitHandle(TimedAbilHash, id, 0, u)
    call SaveInteger(TimedAbilHash, id, 1, abilA)
    call SaveInteger(TimedAbilHash, id, 2, abilB)

    call TimerStart(t, time, false, function UnitReplaceAbilityTimerFunc)

    set t = null
endfunction

Just use
JASS:
call UnitReplaceAbilityTimed(YourUnit, YourAbilToReplace, YourDisabledAbility, TheCooldownTime)

I 100% doubt that removing/adding abilities will work since the Spell is in a SpellBook.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Who would have though? ¬¬

Then instead of ability add/remove use ability enable/disable. The downside of this is that all the player units are affected.
 
Level 7
Joined
Jul 20, 2009
Messages
295

I don't understand where 'reducing cast time' comes in? If you could explain more please.

Who would have though? ¬¬

Then instead of ability add/remove use ability enable/disable. The downside of this is that all the player units are affected.

Each player will only have 1 unit (hero) to control.
The problem is that, there are lots of spells within the spellbook, each spell is going to be affected by that 'Passive Ability' which reduces their cast time.

Adding/Removing/Enabling/Disabling abilities into that spellbook won't work, it will create a mess out of it.

I thought maybe there is someway in Jass/vJass where you can reduce cast time where GUI triggers wouldn't be able to.

The only Idea atm I got is that making the spell Instant and trigger the Cast Time but the only problem with that is, what if the player decides to cancel the spell while being cast, the spell will still undergo cooldown (which could be between 1 second up to 60 seconds). Then, in wc3 you cannot reset the cooldown of a single spell (which is stupid) instead, it resets every single spell...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Disable/Enable is your way to go. If you add both, enabled and disabled abilities to the unit, and disable all the "disabled abilities" by default, then you can just disable the used ability, and enable the "disabled ability" with a local timer. When timer expires, disable the "disabled ability" and enable the original ability again.

There is no mess in it, as there would be with adding/removing.

There is no way to access cooldown through triggers.
 
Level 7
Joined
Jul 20, 2009
Messages
295
Disable/Enable is your way to go. If you add both, enabled and disabled abilities to the unit, and disable all the "disabled abilities" by default, then you can just disable the used ability, and enable the "disabled ability" with a local timer. When timer expires, disable the "disabled ability" and enable the original ability again.

There is no mess in it, as there would be with adding/removing.

There is no way to access cooldown through triggers.

Alright, in spellbook, you are only able to have 11 abilities/spells.
If you disable one, it's position will be blank and empty and no other spell will take over it's position.
E.g.
[Abi1Tru] [Abi1Fake] [Abi2Tru] [Abi2Fake]
[Abi3Tru] [Abi3Fake] [Abi4Tru] [Abi4Fake]
[Abi5Tru] [Abi5Fake] [Abi6Tru] [Cancel]

If you disable Abi1Fake it'll appear like this.
[Abi1Tru] [Blank] [Abi2Tru] [Abi2Fake]
[Abi3Tru] [Abi3Fake] [Abi4Tru] [Abi4Fake]
[Abi5Tru] [Abi5Fake] [Abi6Tru] [Cancel]

In other words, there will be blank spaces between the abilities which looks weird... and I can only add 5 abilities (Tru) per SpellBook... where in some cases in my map the hero has 11 abilities (Tru) in 1 spellbook.

Also, you are able to Reset the Cooldown of ALL abilities via triggers BUT is there a way to Reset the Cooldown of ONLY one ability? If so, I could go with my idea of making all abilities instant and trigger the Cast TIme.

Edit: Removing/Adding the ability resets cooldown BUT since it's in a spellbook, if I remove/add it will be removed from spellbook and put into the hero.
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
You can make all abilities instant and use a timer check to know if the abil is in cooldown or not. The downside is the player doesn't know if he can cast the ability untill he casts it and a Game Message says he can't cast it yet.

You can use a floating text or special effect (or both) to let the user know he can already cast an ability.
 
Level 7
Joined
Jul 20, 2009
Messages
295
You can make all abilities instant and use a timer check to know if the abil is in cooldown or not. The downside is the player doesn't know if he can cast the ability untill he casts it and a Game Message says he can't cast it yet.

You can use a floating text or special effect (or both) to let the user know he can already cast an ability.

I don't like the idea =/, this is because, I got about 180+ abilities to make and so, I got to make a timer specific to each ability to keep track whether a player can or cannot cast this ability.
Thanks though.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok... you can do this

1- Create an Empty Spellbook.
2- Create 1 spellbook for each enabled/disabled ability (make enabled/disabled abiltiies match on their x/y position).
3- Make all of them have the same base ID.
4- Disable all the spellbooks (except the empty one).

If you add the disabled spellbook to the unit, the abilities inside will be transfered to the empty spellbook. Opposite will happen if you remove the spellbook. So, basically you'll handle the ability enable/disable by adding/removing the spellbooks that holds the abilities.

However, this will not display the icon cooldown animation

You can also add all the spellbooks to the unit by default, but make them empty at lvl 1, have the enabled ability on level 2, and the disabled ability on lvl 3. So you don't add/remove but just increase/reduce level. The good thing with this is it halves the amount of required spellbooks.
 
Level 7
Joined
Jul 20, 2009
Messages
295
I didn't understand the first part, may you explain more please.
As for the second part:
"You can also add all the spellbooks to the unit by default, but make them empty at lvl 1, have the enabled ability on level 2, and the disabled ability on lvl 3. So you don't add/remove but just increase/reduce level. The good thing with this is it halves the amount of required spellbooks. "

You did not take into consideration the other abilities (a spellbook may or may not contain more than one ability to be used)
E.g. I got 5 enabled abilities in a spellbook on lvl x.
If I use 1 of them, what lvl should I change my spellbook to in order to include the diabled ability of this casted ability + keep the rest (4 abilities) as enabled abilities?
This will complicate things ^^
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Lets say you have SPa and SPb (SpellBook A, and SpellBook B) and SPc. They all have the same BaseId (A Data field that allows you to difference one spellbook from another).

SPa is empty and enabled
SPb has Entangling Roots on x0 y0 and is disabled.
SPc has WarStomp on x0 and y1 and is disabled

If you add SPb and SPc to the unit the Spellbook icon won't display (because it's disabled) but the abilities inside SPb and SPc will be shown in SPa on their respective positions. If you remove SPb or SPc the abilities within the spellbooks will also be removed from SPa.

I know you have your system and your way to handle stuff, but you can't force warcraft to do what you want the way you want. You'll have to make changes to the way you're working and coding and doing stuff in order to achieve different results.

You did not take into consideration the other abilities (a spellbook may or may not contain more than one ability to be used)
How would I know? Did you say it somewhere? You have a problem i'm discovering part by part while i'm trying to give solutions.

E.g. I got 5 enabled abilities in a spellbook on lvl x.
You don't if you follow my suggestions. You would have 1 empty enabled spellbook on lvl 1, and a bunch of disabled spellbooks on lvl 1 (if the ability isn't gained yet), on lvl 2 (if the ability is active) or level 3 (if it's on cooldown, therefore, disabled).

If I use 1 of them, what lvl should I change my spellbook to in order to include the diabled ability of this casted ability + keep the rest (4 abilities) as enabled abilities?
You can save the Spellbook each ability is holded in within a Hashtable. When the ability is cast, you load the spellbook and increase it's level (to remove the ability and add the disableda bility). Then start a timer to reduce the spellbook level again when cooldown is reached.
 
Level 7
Joined
Jul 20, 2009
Messages
295
Lets say you have SPa and SPb (SpellBook A, and SpellBook B) and SPc. They all have the same BaseId (A Data field that allows you to difference one spellbook from another).

SPa is empty and enabled
SPb has Entangling Roots on x0 y0 and is disabled.
SPc has WarStomp on x0 and y1 and is disabled

If you add SPb and SPc to the unit the Spellbook icon won't display (because it's disabled) but the abilities inside SPb and SPc will be shown in SPa on their respective positions. If you remove SPb or SPc the abilities within the spellbooks will also be removed from SPa.

Hmm, I'll try this one out and let you know how it goes.

How would I know? Did you say it somewhere? You have a problem i'm discovering part by part while i'm trying to give solutions.

Don't get me wrong, I'm not trying to attack your ideas but letting you know whether this idea suits me or not with reason of course. I'm trying to find the most simple and easy way possible with your help and the others.
Each player will only have 1 unit (hero) to control.
The problem is that, there are lots of spells within the spellbook, each spell is going to be affected by that 'Passive Ability' which reduces their cast time.
But it's my fault for giving out the information in parts rather than in one go, this is for the sake of simplicity. I'm reveal the information whenever I find that it is needed.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Another way is just making your abilities have 3 levels each and then change level of ability whenever you level up the passive.

Why would that help? Because each ability level can have a separate cooldown.

Also, ability levels do not add loading time - text does, so be sure to NOT fill in the text of other levels unless the ability originally had multiple levels(like hero abilities)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
there are lots of spells within the spellbook
In this case It doens't matter how many abilities you have, since you're adding the abilities with triggers and disabled spellbooks and not via Object Editor.
 
Level 7
Joined
Jul 20, 2009
Messages
295
Another way is just making your abilities have 3 levels each and then change level of ability whenever you level up the passive.

Why would that help? Because each ability level can have a separate cooldown.

Also, ability levels do not add loading time - text does, so be sure to NOT fill in the text of other levels unless the ability originally had multiple levels(like hero abilities)

In my Map:
What I'm trying to do is find a way to change Cast Time + Cooldown of abilities.
Why? As there are equipments, passive abilities that makes my hero abilities cast faster and/or (so not always will be both) reduce cooldown.
Aim: Trying to find whether this is possible in a non-complicated, time wasting way.

Possibility 1:
Cast Time
-Make all abilities Cast Instantly and set Cast Time via triggers.
Why not via ability stats?
(a) As any level other than level 1 is 'bugged' and wc3 will set cast time of ability as to that in Level 1 of the ability.
(b) The cooldown will be interfered.
Problem:
The ability will undergo cooldown EVEN if ability gets interrupted by for example making unit 'stop' or move while casting?

Spartipilo Solution: (From what I understood so far, please correct me if wrong)
Set cooldown to instant, and set cooldown via triggers.
If interrupted, set countdown to 0.
If Casted, set countdown to x
Then unit cannot cast until countdown is 0.
I liked this idea though:
-There will be more than 180 abilities, thus got to set for each one of them (This isn't much of a problem compared to the one below)
-It isn't user friendly as the user will not know when he'll be able to cast.
Solution: Create float text with the countdown number.
Problem: If more than 5 spells are on countdown, where do I put all these float text on screen? :S

Cooldown
-I could set the cooldown of each spell via triggers and use Spartiplio's solution to add/minus to the countdown if equipments/abilities increased/decreased the cooldown of abilities.

Edit:
As for Spartiplio's Solution No.2:
Add/Remove disabled SpellBooks of same Base ID seems quite complicated I'll think about it later as I g2g for now.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Problem: If more than 5 spells are on countdown, where do I put all these float text on screen? :S
You just create an special effect or display a floating text (or both) when the ability is already enabled. You could also display the CD in a local Multiboard. You can also make the disabled ability cast-able and display a floating text with the CD remaining when it's used.
 
Level 7
Joined
Jul 20, 2009
Messages
295
You just create an special effect or display a floating text (or both) when the ability is already enabled. You could also display the CD in a local Multiboard. You can also make the disabled ability cast-able and display a floating text with the CD remaining when it's used.

Special Effect - doesn't sound good as, I got to create for each ability a specific special effect for it and will make the unit look 'godly' (in my opinion) and that's just for cooldown. (I don't think I understood what you meant by this, but im thinking of it as attaching a special effect to a unit until countdown is at 0.)

Multiboard - I did think about it, I'll see if there is a way I could implement one for the cooldown case and see whether it looks good or bad.

Floating text, show CD remaining when ability casted - sounds good, though I'm not sure what do you mean by 'disabled ability'. Do you mean by that while the countdown is running the ability will become a 'disabled ability'? Since upon casting the ability will have no effect.
If so:
What if ability CD is 0 and upon trying to cast, the ability effect occurs unintendedly?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The Special Effect can be something pretty small just to indicate that an ability is cast-able again. No need to make it excesively eyecandy.

Of course you have to make a disabled form of each ability. It's generally gray and passive with no effect, but if you make it cast-able, you can use it to let the user know the remaining cooldown. when he tries to cast it while on CD.

If the ability CD is 0, he will see the icon in colors, not in gray... and if he presses the skills is because he intends to use it, not just to know the CD :p
 
Level 7
Joined
Jul 20, 2009
Messages
295
The Special Effect can be something pretty small just to indicate that an ability is cast-able again. No need to make it excesively eyecandy.

Special Effect - A single hero will have about 40 unique abilities. The reason for why I think this is inappropriate as the Player got to learn the look of each ability's special effect.

Of course you have to make a disabled form of each ability. It's generally gray and passive with no effect, but if you make it cast-able, you can use it to let the user know the remaining cooldown. when he tries to cast it while on CD.

If the ability CD is 0, he will see the icon in colors, not in gray... and if he presses the skills is because he intends to use it, not just to know the CD :p

I'm sorry, I feel lost here, may you point out to me where the gray icons came from? and how to add them to spellbooks e.g. more than one gray icon.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
God.... I never tough this would be so hard :'(

Special Effect - A single hero will have about 40 unique abilities. The reason for why I think this is inappropriate as the Player got to learn the look of each ability's special effect.
The same special effect for every ability once it's active again. It's just to indicate that AN ABILITY is already cast-able again, not which ability. That's what the Floating Text is for.

I'm sorry, I feel lost here, may you point out to me where the gray icons came from? and how to add them to spellbooks e.g. more than one gray icon.
Gray Icon is the Icon of the Disabled Ability. It's the same icon of the active ability, but in gray. Of course you have to make it yourself. I already said how to the ability part with the spellbooks in older posts.
 
Status
Not open for further replies.
Top