| 07-05-2009, 01:54 PM | #1 |
Is there any event that can detect when unit attacks with a cold arrow or flaming arrow? I need the exact moment when unit casts the arrow spell. The EVENT_PLAYER_UNIT_SPELL_EFFECT only detects when you manually cast the arrow, not when it is on autocast |
| 07-05-2009, 02:00 PM | #2 |
Trigger the autocast =/ it's really lame but it's the best you'll do. |
| 07-05-2009, 02:05 PM | #3 |
There's a "MultipleColdArrow" spell that somehow detects when an autocast is fired. http://www.wc3c.net/showthread.php?t=100292 The code is pretty outdated imo and doesn't use vJass but it should help you though. I think it uses the EVENT_UNIT_TARGET_IN_RANGE thingy or something like that. |
| 07-05-2009, 02:06 PM | #4 |
Whenever the unit get ordered to active the autocast set a bool to true(false if he orders to disable it) and then use attack event and if the bool is true and the unit has more mana then the autocast cost then he is autocasting. Its lame but meh...its a solution. |
| 07-05-2009, 02:12 PM | #5 | |
Quote:
I did that, but it does not work. Attack event sometimes fires before and sometimes after the arrow effect uses mana. It is really lame. I'll check that cold arrow spell... |
| 07-05-2009, 04:45 PM | #6 | |
Quote:
JASS:scope Feedback initializer Init //! runtextmacro PUI_PROPERTY("public", "boolean", "On", "false") //! runtextmacro PUI_PROPERTY("public", "integer", "Counter", "0") globals private constant integer AID_SPELL = AID_feedback private constant integer OID_ON = OID_flamingarrows private constant integer OID_OFF = OID_unflamingarrows endglobals //=========================================================================== // How much mana it takes to cast feedback //=========================================================================== private function ManaCost takes integer level returns real return 50. endfunction //=========================================================================== // How much mana is burned with feedback attack //=========================================================================== private function ManaFeed takes integer level returns real return 50. * level endfunction //=========================================================================== private function ActionsOn takes nothing returns nothing set On[GetTriggerUnit()] = true endfunction //=========================================================================== private function ActionsOff takes nothing returns nothing set On[GetTriggerUnit()] = false endfunction //=========================================================================== private function ActionsSpell takes nothing returns nothing local unit hero = GetTriggerUnit() set Counter[hero] = Counter[hero] + 1 call BJDebugMsg("ActionsSpell: "+I2S(Counter[hero])) set hero = null endfunction //=========================================================================== private function ActionsAttack takes nothing returns nothing local unit hero = GetAttacker() local real mana = GetUnitState(hero, UNIT_STATE_MANA) if mana >= ManaCost(GetUnitAbilityLevel(hero, AID_SPELL)) then set Counter[hero] = Counter[hero] + 1 endif call BJDebugMsg("ActionsAttack: "+I2S(Counter[hero])) set hero = null endfunction //=========================================================================== private function ActionsOrb takes nothing returns nothing local unit hero = GetEventDamageSource() local unit target = GetTriggerUnit() local real manafeed = ManaFeed(GetUnitAbilityLevel(hero, AID_SPELL)) local real mana = GetUnitState(target, UNIT_STATE_MANA) set Counter[hero] = Counter[hero] - 1 if mana < manafeed then call SetUnitState(target, UNIT_STATE_MANA, 0.0) call TextTag_ManaBurn(target, R2I(mana)) else call SetUnitState(target, UNIT_STATE_MANA, mana-manafeed) call TextTag_ManaBurn(target, R2I(manafeed)) endif set hero = null set target = null endfunction //=========================================================================== private function ConditionsOn takes nothing returns boolean return GetIssuedOrderId() == OID_ON endfunction //=========================================================================== private function ConditionsOff takes nothing returns boolean return GetIssuedOrderId() == OID_OFF endfunction //=========================================================================== private function ConditionsSpell takes nothing returns boolean return GetSpellAbilityId() == AID_SPELL endfunction //=========================================================================== private function ConditionsAttack takes nothing returns boolean if GetAttacker() != null then return On[GetAttacker()] == true endif return false endfunction //=========================================================================== private function ConditionsOrb takes nothing returns boolean return Counter[GetEventDamageSource()]>0 endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ISSUED_ORDER ) call TriggerAddCondition( trig, Condition( function ConditionsOn ) ) call TriggerAddAction( trig, function ActionsOn ) set trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ISSUED_ORDER ) call TriggerAddCondition( trig, Condition( function ConditionsOff ) ) call TriggerAddAction( trig, function ActionsOff ) set trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( trig, Condition( function ConditionsSpell ) ) call TriggerAddAction( trig, function ActionsSpell ) set trig = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ATTACKED ) call TriggerAddCondition( trig, Condition( function ConditionsAttack ) ) call TriggerAddAction( trig, function ActionsAttack ) set trig = CreateTrigger() call TriggerAddCondition(trig, Condition(function ConditionsOrb)) call TriggerAddAction(trig, function ActionsOrb) call ORBEngine_RegisterOrbAttack(trig, AID_SPELL, SCOPE_PREFIX) endfunction endscope Does not work, it has about 30% chance to fail when unit has below needed mana, than when mana regenerates, auto attack spell fires before ATTACKED event. Has anyone ever made any autocast on-attack spell that worked? |
| 07-05-2009, 05:27 PM | #7 |
Another thing you can do is when he attacks and the boolean is true, to order the unit to cast the spell manually which means you should dish the mana check too. When he gets bellow the needed mana for the autocast, order the unit to disable the autocast or else he will be tryin to cast it everytime he attacks and by having no mana the unit will just do nothing. |
| 07-05-2009, 05:39 PM | #8 |
I was hoping someone already had this problem and solved it. Dusk? |
| 07-05-2009, 05:53 PM | #9 | |
Quote:
I think it would just silently fail... IssueTargetOrder should return false for that. |
| 07-05-2009, 06:25 PM | #10 |
I solved it. The trick is to use cold arrows and than detect and remove a buff. Should have used that from the start, but I was hoping to avoid using orb effects... |
| 07-05-2009, 09:35 PM | #11 |
this is the kind of thing you should request in the RtC thread. |
| 09-22-2009, 07:20 AM | #12 | |
Quote:
Sorry if it is against the rules to necro bump this thread, I'm only read the rule about bumping your own thread and only if it's more than 48 or more hours old. Any new info on if it's possible to detect Searing Arrow autocast? I'm trying to make add an effect to the default Searing Arrows, the reason why I want and need to use Searing Arrows is to make it work with Barrage. I am trying to add a 25% chance that there will be AoE damage effect to Searing Arrows and also make it stack with Barrage(so each multi shot explodes). Since Searing Arrows seem to be the only auto cast ability that stacks with Barrage, I am forced to use it. Of course there are some other alternatives but I really want to attach the effect to Searing Arrows instead of making it a passive ability or something. So does anyone know if it's possible to detect Searing Arrow autocast attacks? |
| 09-22-2009, 11:36 AM | #13 |
You sure it doesn't work with Freezing/Poison/Black/Incinerate Arrows as well? Otherwise it's kinda tricky.. |
| 09-22-2009, 11:39 AM | #14 |
Dunno. You can detect activation of autocast right? So add a condition for when you attack and got enough mana for the attack. |
| 09-22-2009, 01:11 PM | #15 |
That can fail because there is a gap between when a unit attacks and when the projectile is created and they could regen enough mana in that duration. |
