cr4xzZz
Also known as azwraith_ftL.
- Reaction score
- 51
Well, it's kind a stupid situation... I can't imagine that this simple trigger can give me problems.... OK, so this spell is based on WW. On cast if there is an enemy in 450 range the Hero cannot Prowl. The problem is that the Hero prowls even if there are enemies in 450 range. I can't find why it's doing this
JASS:
scope Prowl
globals
private constant integer ABILITY_RAW = 039;A009039;
private constant real MAX_RANGE = 450.
private constant integer BUFF_RAW = 039;B007039;
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABILITY_RAW
endfunction
private function Check takes nothing returns boolean
return IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == true and GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) >= 0.405
endfunction
private function Actions takes nothing returns nothing
local unit cast = GetTriggerUnit()
local group gr = CreateGroup()
local real cX = GetUnitX(cast)
local real cY = GetUnitY(cast)
local string text = "You cannot Prowl in front of enemies"
call TriggerSleepAction(0.1) // transparency .. + the buff can't be removed instantly on cast
call GroupEnumUnitsInRange(gr, cX, cY, MAX_RANGE, Condition(function Check))
if CountUnitsInGroup(gr) > 1 then
call UnitRemoveAbility(cast, BUFF_RAW)
call SimError_Call(GetOwningPlayer(cast), text)
endif
call DestroyGroup(gr)
set cast = null
set text = null
set gr = null
endfunction
function InitTrig_Prowl takes nothing returns nothing
local trigger prw = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(prw, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(prw, Condition(function Conditions))
call TriggerAddAction(prw, function Actions)
endfunction
endscope