Stealth Ability

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 = 'A009'
    private constant real MAX_RANGE = 450.
    private constant integer BUFF_RAW = 'B007'
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
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
The code looks fine to me. I just learned JASS basics a few weeks ago
How many units were there in 450 range?
If there is 1 enemy unit, and you were able to 'Prowl', well that's because you used '>' 1, instead of '>=', so if there's 1 enemy unit, you still can 'Prowl'

But if there were more than 1 enemy, I don't know..

EDIT:
Shoot >< then I give up JASS is hard..
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
> But if there were more than 1 enemy, I don't know..
Yep, there were 6 ogres and I was still able to Prowl...
 

0zaru

Learning vJASS ;)
Reaction score
60
>IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit())) == true and GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) >= 0.405

replace all GetEnumUnit() with GetFilterUnit(). Also sometimes that boolexpr from the function GroupEnumUnitsInRange doesn't work. Try anyway.
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Ohhhh silly me. Mixed picked with matching >.> Thanks a lot
<3 and +
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top