[Spell] I don't want bloodbath ability to work on buildings.

Level 15
Joined
Jul 19, 2007
Messages
825
How can I make so this JASS-ability Bloodbath not working on buildings? It's normally just meant to be working on organic units.
JASS:
//TESH.scrollpos=11
//TESH.alwaysfold=0
scope Bloodbath initializer Init

globals
    private constant integer AbilId = 'A0I9'
    private constant integer BSId = 'N01N'
endglobals

private function Actions takes nothing returns nothing
    local unit u = GetKillingUnit()
    local real eff
    
    if IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)==true then
        set eff=(GetUnitAbilityLevel(u,AbilId)*0.1)*GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE)
    else
        set eff=(0.05+GetUnitAbilityLevel(u,AbilId)*0.05)*GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE)
    endif
    call SetWidgetLife(u,GetUnitState(u,UNIT_STATE_LIFE)+eff)
    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HeroBloodElfBlood.mdl",u,"head"))
    
    set u = null
endfunction
private function CheckRange takes nothing returns nothing
    local unit targ = GetTriggerUnit()
    local unit u
    local group g = NewGroup()
    
    call GroupEnumUnitsInRange(g,GetUnitX(targ),GetUnitY(targ),200.,B_TRUE)
    loop
        set u = FirstOfGroup(g)
        exitwhen u==null
        call GroupRemoveUnit(g,u)
        if GetUnitTypeId(u)==BSId then
            call SetWidgetLife(u,GetUnitState(u,UNIT_STATE_LIFE)+(0.05+GetUnitAbilityLevel(u,AbilId)*0.05)*GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE))
            call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HeroBloodElfBlood.mdl",u,"head"))
        endif
    endloop
    
    call ReleaseGroup(g)
    set targ = null
endfunction

private function Conds takes nothing returns boolean
    if GetUnitAbilityLevel(GetKillingUnit(),AbilId)>0 then
        call Actions()
    elseif IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)==true then
        call CheckRange()
    endif
    
    return false
endfunction
private function Init takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t,Condition(function Conds))
endfunction

endscope
 
Level 44
Joined
Feb 27, 2007
Messages
5,474
Add another check to the conditions for buildings:
JASS:
private function Conds takes nothing returns boolean
    if GetUnitAbilityLevel(GetKillingUnit(),AbilId)>0 and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) then
        call Actions()
    elseif IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)==true then
        call CheckRange()
    endif
    
    return false
endfunction
 
Level 15
Joined
Jul 19, 2007
Messages
825
Add another check to the conditions for buildings:
JASS:
private function Conds takes nothing returns boolean
    if GetUnitAbilityLevel(GetKillingUnit(),AbilId)>0 and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) then
        call Actions()
    elseif IsUnitType(GetDyingUnit(),UNIT_TYPE_HERO)==true then
        call CheckRange()
    endif
   
    return false
endfunction
It works, thank you!
 
Top