Defend ability

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
In the Object Editor? Not possible. Unless you trigger it or use some sort of metamorphosis to convert the unit whenever she cast that ability.
Mhh thanks for the fast response. Do you have a suggestion for a trigger, that could solve this? Was looking around, but sadly can't find any kind of trigger that influences cooldown.
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
Events :
A unit is issued an order with no target
Conditions :
Issued order Equal to Order(defend)
Actions :
Set mana of Triggering unit to (Mana of Triggering unit - "Insert the value here")

As for the cooldown you may use a countdown timer, like when the unit cast the ability start a countdown timer as a one shot... and when the timer expire disable the ability.
 
Level 7
Joined
May 30, 2018
Messages
290
Events :
A unit is issued an order with no target
Conditions :
Issued order Equal to Order(defend)
Actions :
Set mana of Triggering unit to (Mana of Triggering unit - "Insert the value here")

As for the cooldown you may use a countdown timer, like when the unit cast the ability start a countdown timer as a one shot... and when the timer expire disable the ability.

thanks for the advice. appreciated.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
How exactly do you want the cooldown to work?

1) Toggle Defend On -> Go on Cooldown and disable the ability entirely (can't toggle it off/on until the cooldown expires)
2) Toggle Defend On -> Go on Cooldown but allow you to still toggle Defend off (in this case the cooldown can be running in the background OR the cooldown can start once you toggle Defend off)
 
Level 7
Joined
May 30, 2018
Messages
290
How exactly do you want the cooldown to work?

1) Toggle Defend On -> Go on Cooldown and disable the ability entirely (can't toggle it off/on until the cooldown expires)
2) Toggle Defend On -> Go on Cooldown but allow you to still toggle Defend off (in this case the cooldown can be running in the background OR the cooldown can start once you toggle Defend off)

I'd prefer 2), but 1) would be okay too, if it is simpler to create.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
If you have multiple units with this ability then it won't be simple to create, unfortunately. Not that it would be hard to do, in fact I could probably whip it up in 30 minutes or so.

Have you learned how to use a Unit Indexer yet? I saw that you said that you were new to coding and that's why you're looking for simple solutions. A Unit Indexer and indexing in general is probably the best thing you can possibly learn how to use when starting out. It's really not all that complicated either. You can probably get by without fully understanding how it works, and simply understand how to use it.

I could create an example of the spell if you'd like.

EDIT: Doom_Sheep's method is actually a lot simpler than what I had in mind. Maybe try that, I think that would work pretty great. And if you don't understand how, I can show you how to do his idea.
 
Last edited:
Level 7
Joined
May 30, 2018
Messages
290
If you have multiple units with this ability then it won't be simple to create, unfortunately. Not that it would be hard to do, in fact I could probably whip it up in 30 minutes or so.

Have you learned how to use a Unit Indexer yet? I saw that you said that you were new to coding and that's why you're looking for simple solutions. A Unit Indexer and indexing in general is probably the best thing you can possibly learn how to use when starting out. It's really not all that complicated either. You can probably get by without fully understanding how it works, and simply understand how to use it.

I could whip up an example of the spell if you'd like.
Luckily I need this spell only for one unit, so that's that.
And yeah sure, if you would like to do that I would greatly appreciate it. Iam always interested in improving and learning something new :)! Thanks man.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'm not sure if edits show up in your notifications (I feel bad if they do, I edit a lot LOL) but I uploaded the latest working version of the spell. Defend Cooldown 3 SHOULD be 100% working.

If you have any questions, please let me know. Sorry if it ended up being a bit complicated, I tried to keep it as simple as possible but with like most things in Warcraft 3 there ended up being a ton of weird issues that I never expected.
 
Last edited:
Level 7
Joined
May 30, 2018
Messages
290
I'm not sure if edits show up in your notifications (I feel bad if they do, I edit a lot LOL) but I uploaded the latest working version of the spell. Defend Cooldown 3 SHOULD be 100% working.

If you have any questions, please let me know. Sorry if it ended up being a bit complicated, I tried to keep it as simple as possible but with like most things in Warcraft 3 there ended up being a ton of weird issues that I never expected.
Hey Uncle, I just came home and will have a look at your map. Thanks a lot!
 
Level 4
Joined
Jan 18, 2019
Messages
71
Like everyone else mentioned, you will need to trigger this in order to occur (mana and cool down reduction).

Is this an ability that will be used by the A.I.? Or is it a spell that user will use?

If it is the A.I., the computer will not cast defend if it has been given extra levels or certain modifications. I just recently got done incorporating an A.I. Defend that gives a bonus if the unit makes a kill while defending. A way in which I got around the movement-stop business, was to reissue an order-move command to the unit after the ability has been casted. I know that this isn't your issue, but it may be something you'll need to address.

Defend could also be setup so that when it is detected in the event's trigger, that it checks the unit's mana. You'd need to convert their ability level to an integer representing the required mana for the ability, and if the unit has less, have the trigger not fire. If it does fire, then trigger the unit's mana to take a reduction. As for the cooldown, you would probably need to make a wait system that count's down the time from the moment the unit's defend is detected, and until it reaches the time you've allocated. You can use a "real" variable as your time to wait. Simply think of how much time you want each ability to reduce the cooldown and set the "real" variable, with math, to represent it.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Got it working great, no movement interruptions or anything. Deleted my old post.

You have two abilities based off of Berserk. Defend (On) and Defend (Off).

When you cast Defend On the ability is removed and replaced with Defend Off. Then I add Elune's Grace and Slow Aura to the caster to imitate the effects of Defend. Finally, I turn on a timer that lasts 5 second (the cooldown of Defend).

When you cast Defend Off I set the cooldown of it to be equal to the amount of time left in the timer. So if 5 seconds has passed since you casted Defend On then the cooldown of Defend Off will be set to 0.
Finally, I detect if the cooldown is 0 and if it is then I remove Defend Off and add back Defend On.
Otherwise, if the cooldown is > 0, I wait until Defend Off is done cooling down and remove it once that's complete, adding back Defend On so the cycle can be repeated all over again.


Attached the map below.
 

Attachments

  • Defend Cooldown 4.w3x
    25.7 KB · Views: 46
Last edited:
Status
Not open for further replies.
Top