| 09-21-2009, 04:15 PM | #1 |
how to check if an units ability is on cooldown (do only need a boolean value)? btw how to change a units color/size for only one player (like illusions)? |
| 09-22-2009, 03:36 AM | #2 |
tried this in WE. you can detect cd by trying to issue the order of the ability *WHEN ALL OTHER FACTORS PERMITTING THE CASTING OF THE ABILITY BESIDES COOLDOWN ARE OK*: JASS:scope Test2 initializer Run globals private unit u endglobals private function aaa takes nothing returns nothing call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA)) if IssueImmediateOrder(u, "fanofknives") then call BJDebugMsg("Fan of knives ordering") else call BJDebugMsg("Fan of knives not ordering") endif endfunction private function Run takes nothing returns nothing set u = CreateUnit(Player(0), 'Hpal',0,0,0) call UnitAddAbility(u, 'AEfk') call SetUnitAbilityLevel(u, 'AEfk', 3) call TimerStart(CreateTimer(), 0.50, true, function aaa) endfunction endscope edit: so, assuming the condition above (all caps): for immediate abilities just issue the order (IssueImmediateOrder); for point abilities maybe just order the unit to cast the spell at a point some distance in front of it (min cast range (if there is any)<distnace<cast range); for unit/item/destructable target abilities maybe make an invisible dummy (that can be targeted by the ability) in front of the caster and order the latter to cast the spell on the former. also note there are special spells with special requirements to be casted - these requirements must be satisfied (see all caps above). eg Raise/Animate Dead requires that there are nearby corpses; etc. then refer to the boolean from issuing the order (Issue-Immediate/Point/Target-Order takes stuff returns boolean). then make the caster stop casting the spell after you get the boolean. maybe use the LastOrder by either anitarf/rising_dusk (i always mix up those two) library somewhere in this site. ==================================================================================================== to change unit color stuff for a player you can use GetLocalPlayer(): JASS:if GetLocalPlayer() == playerIWantToChangeColorFor then call SetUnitVertexColor(etc) //change color call SetUnitScale ??? // size endif |
| 09-22-2009, 05:14 PM | #3 | |
Quote:
but you dont give the player you want to change to the change color/sizte function, so why does he know which player to affect? |
| 09-22-2009, 07:12 PM | #4 |
They don't, but the functions are only called for the player you want anyway. |
| 09-22-2009, 07:26 PM | #5 |
its always better to read AND use your brain thx storyyeller, i've overread GetLocalPlayer()/didn't get what it is |
| 09-23-2009, 03:44 AM | #6 |
read moar and divine brilliance will clarify your soul with knowlege of GetLocalPlayer() usage!!! GetLocalPlayer() is local player, no more no less, if local player 1 its machine of player 1 |
| 09-24-2009, 07:52 AM | #7 |
wonder if u can use the issueorder functions for this. they return boolean, if the order you are given is doable for the unit or not. so maybe if u order the unit to cast f.e. flamestrike on its position and the function returns false, the abilit still has cooldown. just a short idea :) |
| 09-24-2009, 08:50 AM | #8 |
The problem I see is that you'd need some sort of a database to know what are the valid targets for each ability so you can issue the order properly, if you have to do that you might as well store the ability cooldowns to that database instead and then simply use a timer whenever an ability is cast that waits until that ability's cooldown finishes. |
| 09-24-2009, 11:21 AM | #9 | |
Quote:
why not issue all possible orders and check if one of these is true? Under the condition that Qillraven is right |
| 09-24-2009, 01:16 PM | #10 | |
Quote:
|
| 09-24-2009, 01:58 PM | #11 |
A better solution is to just run a timer when the unit casts your desired spell. If the timer is running, then it is on cooldown, otherwise it is not. You will need to hardcode in the duration of the cooldown to the timer, however, but this is still the cleanest solution. Anyways, Anitarf is right, don't use the order method. It sucks and there are so many ways it can falter it's not even funny. Furthermore, even if you get the order right, then you have to go to the trouble of canceling it. Even worse, what if you have two spells on your hero and you get the wrong one right? Now you have a false positive, unless you've associated orderids to raw codes and well, that is way too much hardcoding for anyone to do. |
| 09-24-2009, 03:42 PM | #12 | ||
Quote:
Quote:
|
