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

[Spell] Spell shared cooldown

Status
Not open for further replies.
Level 4
Joined
Feb 9, 2010
Messages
48
Greetings,

I need to create a unit which will have three abilities: Fire, Storm and Earth. All of those abilities will be a triggered ones, but I need them to share cooldown.

i.e. Fire spell is cast, the unit can't cast Fire/Storm/Earth as they all go on cooldown if one of the spells is cast.

For clarification:
- I can't use spellbook, I want the player to have access to spells w/o opening the spellbook
- I can't use mana as limiter for spells, which replace cooldown
- Unit with those spells would be a regular unit. Regular caster unit that can be produced in hundreds etc, so not a special unit. With that said, the map I'm working on is a huge one, so heavy-triggered or laggy triggers aren't solution

Also I'm not familiar with JASS, so I won't understand anything from the JASS code you throw at me.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
I haven't tried this explicitly but it seems like it might work.

You could potentially catch when the unit casts S/E/F.

When this happens, you remove the S/E/F and add toggled dummy abilities (defend, immolation, etc) for all 3 spells. Force the unit to then toggle each of the dummy S/E/F, putting them all on cooldown.

You then have a loop keeping track of unit's whose spells are on cooldown, when the counter for that particular unit is up. You know the cooldown is about to end, you can remove the dummy S/E/F and add back the real ones.

(You could use usually channel based skills as dummy abilities when you want the dummy ability to hold the cooldown for a real ability, but I think trying to have a unit cast 3 spells might fail if they a long backswing/cast point. They are potentially ordered to stop/stunned. I think in this case the built in toggled abilities might be able to solve this as I think they ignore the units casting delay.)
 
Level 4
Joined
Feb 9, 2010
Messages
48
After some tests, I've tried another approach:
I gave the unit three channel spells, each with diffrent 'Base Order ID'. I've also set the 'Art - Animation - Cast Backswing&Point' to 0 for the unit.

When Earth spell is cast, the trigger checks if the custom value of the unit is 0.

If it is, then:
The trigger sets custom value of unit to 1 and makes the unit cast Fire/Storm spell, then set custom value of unit to 0. After that, the trigger executes the regular stuff for Earth Spell.

So far this seems to be working perfectly, but I have a question - Does setting the animation cast backswing/point to 0 cause any problems? I've never messed with it before, so I don't know if it can cause any unwanted problems. Also does casting 2 additional spells in 1 spell trigger causes any other problems?
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
No problems with 0 cast points and things, just usually a balance concern.

If you show what you've done, we can give more targeted feedback, but ordering a unit to cast abilities should not be a problem.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Also does casting 2 additional spells in 1 spell trigger causes any other problems?
As long as you don't create an infinite loop of cast > trigger runs > order cast > trigger runs then it should be okay.

The only complication I see is that if the spells have a mana cost the unit will lose mana equal to the total cost of all 3 spells combined when any one of them is cast. If the unit doesn't have enough mana to cast all 3 then some won't go on cooldown. There are two cases which you will have to choose between on the spell cast. Let C be the total cost of all spells minus the one that was actually cast, M be the unit's current mana, and T be its total mana:
  • If T-M >= C, then add C mana to the unit before it casts the other 2 spells
  • If T-M < C, then add C mana to the unit after it casts the other 2 spells. Note this can still fail if M < C, but as long as the units mana pool is sufficiently large you'll likely never run into that problem.
If you don't check this and just add C to the unit every time before casting, when its at max mana (for example) it can't gain any more so it will lose the full cost of all 3 spells on-cast.
 
Level 4
Joined
Feb 9, 2010
Messages
48
No problems with 0 cast points and things, just usually a balance concern.

If you show what you've done, we can give more targeted feedback, but ordering a unit to cast abilities should not be a problem.

The map is in uploaded files. What do you mean by balance concern?

As long as you don't create an infinite loop of cast > trigger runs > order cast > trigger runs then it should be okay.

The only complication I see is that if the spells have a mana cost the unit will lose mana equal to the total cost of all 3 spells combined when any one of them is cast. If the unit doesn't have enough mana to cast all 3 then some won't go on cooldown. There are two cases which you will have to choose between on the spell cast. Let C be the total cost of all spells minus the one that was actually cast, M be the unit's current mana, and T be its total mana:
  • If T-M >= C, then add C mana to the unit before it casts the other 2 spells
  • If T-M < C, then add C mana to the unit after it casts the other 2 spells. Note this can still fail if M < C, but as long as the units mana pool is sufficiently large you'll likely never run into that problem.
If you don't check this and just add C to the unit every time before casting, when its at max mana (for example) it can't gain any more so it will lose the full cost of all 3 spells on-cast.

Hmm, I think I haven't done an infinite loop. As for mana, before each 'Additional' spell cast, I add 25 mana (Mana cost of each E/F/S spell) to the unit. I think that solves the problem of mana.
 

Attachments

  • earthfirestorm.w3x
    239.4 KB · Views: 52
Level 13
Joined
Mar 24, 2013
Messages
1,105
Your current way of giving mana, will work so long as they are not full mana/almost full mana. For example -> 200 mana on the shaman -> Cast Earth -> tries to add 25 mana, it cant, casts storm -25 mana for the cast, add 25 back to compensate, casts fire - 25 mana for the cast, add 25 back to compensate. Shaman will now have 150 mana, because the first mana refund failed.

What I mean by balance concerns is, there are reasons units have longer/shorter cast times. It might not be important in this case, that's for you to decide. In regular wc3 melee, casters usually have rather long cast delays because many of their spells are very powerful when used effectively. The backswing is a built in extra "cooldown" that can be cancelled if the person micros, but it rewards skill.
 
Status
Not open for further replies.
Top