HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Triggering Turn On/Off spells using Immolation

01-08-2009, 04:55 AM#1
Av3n
Ok My current method is really messy and if the hero dies while having the spell turned on they is a high chance that i won't work on.

I just some suggestions on how to code it. Yes I know that "unimmolation" triggers when a unit with that kind of ability dies, which is why I'm also relying on the fact it produces a buff on the user.

I don't care about the arguments, I just care for suggestions or ways to work around Immolation's flaws.

-Av3n

EDIT:
Code

Collapse JASS:
scope Phalanx

globals
    constant integer SW_PH_SPELLID   = 'A042'
    constant integer SW_PH_BUFFID    = 'B008'
    constant integer SW_PH_CONTAINER = 'A04O'
    constant integer SW_PH_RESIST    = 'A04R'
    constant integer SW_PH_DODGE     = 'A04P'
    constant integer SW_PH_DODGEBOOK = 'A04Q'
    constant integer SW_PH_REGBONUS  = 'A04Y'
    constant integer SW_PH_CHECKER   = 'B009'
    constant real    SW_PH_AOE       = 500.
    
    private unit SW
    private group Phalanx = CreateGroup()
    private group Current = CreateGroup()
    private integer Count = 0
    private timer Timer   = CreateTimer()
endglobals

private function RemovePhalanx takes nothing returns nothing
    if GetUnitAbilityLevel(SW,SW_PH_CHECKER) < 1 or not IsUnitInRange(GetEnumUnit(),SW,SW_PH_AOE) or GetUnitAbilityLevel(GetEnumUnit(),SW_PH_BUFFID) < 1 or GetWidgetLife(GetEnumUnit()) < .405 then
        call UnitRemoveAbility(GetEnumUnit(),SW_PH_RESIST)
        call UnitRemoveAbility(GetEnumUnit(),SW_PH_DODGEBOOK)
        call UnitRemoveAbility(GetEnumUnit(),SW_PH_BUFFID)
        call GroupRemoveUnit(Current,GetEnumUnit())
    endif
endfunction

private function AddPhalanx takes nothing returns nothing
    local group temp = CreateGroup()
    local unit t 
    set TempPlayer = GetOwningPlayer(GetEnumUnit())
    call GroupEnumUnitsInRange(temp,GetUnitX(GetEnumUnit()),GetUnitY(GetEnumUnit()),SW_PH_AOE*2.,Condition(function AllyFilter))
    loop
        set t = FirstOfGroup(temp)
        exitwhen t == null
        if IsUnitInRange(t,GetEnumUnit(),SW_PH_AOE) and GetUnitAbilityLevel(t,SW_PH_BUFFID) > 0 and not IsUnitInGroup(t,Current) then
            call UnitAddAbility(t,SW_PH_RESIST)
            call UnitAddAbility(t,SW_PH_DODGEBOOK)
            //if GetUnitAbilityLevel(GetEnumUnit(),SW_PH_REGBONUS) > 0 then
                //call IncUnitAbilityLevel(t,SW_PH_RESIST)
                //call IncUnitAbilityLevel(t,SW_PH_DODGE)
            //endif
            call GroupAddUnit(Current,t)
        endif
        call GroupRemoveUnit(temp,t)
    endloop
    set SW = GetEnumUnit()
    call ForGroup(Current,function RemovePhalanx)
    if GetUnitAbilityLevel(SW,SW_PH_CHECKER) < 1 then
        call UnitRemoveAbility(SW,SW_PH_CONTAINER)
        call UnitRemoveAbility(SW,SW_PH_BUFFID)
        call UnitRemoveAbility(SW,SW_PH_REGBONUS)
        call AddUnitAnimationProperties(GetOrderedUnit(),"Defend",false)
        call GroupRemoveUnit(Phalanx,SW)
        set Count = Count - 1
        if Count == 0 then
            call PauseTimer(Timer)
        endif
    endif
    call DestroyGroup(temp)
    set temp = null
endfunction

private function Loop takes nothing returns nothing
    call ForGroup(Phalanx,function AddPhalanx)
endfunction

private function Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetOrderedUnit(),SW_PH_SPELLID) > 0
endfunction

private function Actions takes nothing returns nothing
    if GetIssuedOrderId() == 852177 then
        call UnitAddAbility(GetOrderedUnit(),SW_PH_CONTAINER)
        //if UnitHasItemOfTypeBJ(GetOrderedUnit(),'flag') or UnitHasItemOfTypeBJ(GetOrderedUnit(),'sfog') or (UnitHasItemOfTypeBJ(GetOrderedUnit(),'reg6')and UnitHasItemOfTypeBJ(GetOrderedUnit(),'hbth')and UnitHasItemOfTypeBJ(GetOrderedUnit(),'grsl')) then 
            //call UnitAddAbility(GetOrderedUnit(),SW_PH_REGBONUS)
        //endif
        call GroupAddUnit(Phalanx,GetOrderedUnit())
        call AddUnitAnimationProperties(GetOrderedUnit(),"Defend",true)
        set Count = Count + 1
        if Count == 1 then
            call TimerStart(Timer,1.,true,function Loop)
        endif
    elseif GetIssuedOrderId() == 852178 then
        call UnitRemoveAbility(GetOrderedUnit(),SW_PH_CONTAINER)
        call UnitRemoveAbility(GetOrderedUnit(),SW_PH_BUFFID)
        call UnitRemoveAbility(GetOrderedUnit(),SW_PH_REGBONUS)
        call GroupRemoveUnit(Phalanx,GetOrderedUnit())
        set SW = GetOrderedUnit()
        call ForGroup(Current,function RemovePhalanx)
        call AddUnitAnimationProperties(GetOrderedUnit(),"Defend",false)
        set Count = Count - 1
        if Count == 0 then
            call PauseTimer(Timer)
        endif
    endif
endfunction

function InitTrig_Phalanx takes nothing returns nothing
    set gg_trg_Phalanx = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Phalanx, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( gg_trg_Phalanx, Condition( function Conditions ) )
    call TriggerAddAction( gg_trg_Phalanx, function Actions )
    call XE_PreloadAbility(SW_PH_CONTAINER)
    call XE_PreloadAbility(SW_PH_RESIST)
    call XE_PreloadAbility(SW_PH_DODGE)
    call XE_PreloadAbility(SW_PH_DODGEBOOK)
    call XE_PreloadAbility(SW_PH_REGBONUS)
    call DisableAbility(SW_PH_CONTAINER)
    call DisableAbility(SW_PH_DODGEBOOK)
endfunction

endscope

01-08-2009, 05:15 AM#2
Pyrogasm
Quote:
Originally Posted by Av3n
they is a high chance that i won't work on.
What?

What is the method you use? Post up your code.
01-08-2009, 05:54 AM#3
DioD
before doing anything check for buff this will fix any problems.
01-08-2009, 08:11 AM#4
Av3n
It is pretty old and I tried fixing it up but i failed very bad.
Which is why I posted up the thread.

The code is in the hidden tags. This was back when I started working with on/off abilities as well so expect a lot of noob-ness

-Av3n
01-08-2009, 09:00 AM#5
Fulla
Best way I found as Diod mentioned:
- Detect 'on' order to activate.
- Run a timer, periodically checking for buff, to determine when its off.
01-08-2009, 09:04 AM#6
BestZero
just a little off-topic.

There's
Code:
[hiddenjass] YOUR SCRIPT HERE [/hiddenjass]
which is more easier to look rather than warping jass tag with hidden tag.
01-08-2009, 01:16 PM#7
emjlr3
does dieing not trigger "immolationoff"?
01-08-2009, 09:17 PM#8
Av3n
Thanks guys

@emjlr: that is what I stated in the beginning of the thread.

-Av3n
01-08-2009, 11:35 PM#9
moyack
A periodic timer checking the presence of immolation buff is the best and safest way to detect unimmolation.
01-09-2009, 05:40 AM#10
BestZero
Dying does trigger "unimmolation". Check out this

Expand JASS:

Either Demon Hunter turns off manually or dies while having Immolation turned on. Message always says "Immolation is de-activated". I assume you have done something wrong with your code, add debug message to check out or maybe try to assign variables instead of using it directly.
01-09-2009, 05:54 AM#11
Av3n
How come I got the feeling you have mis-read the first post...

-Av3n