HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Triggering Several Spells w/1 Trigger

12-16-2004, 02:16 PM#1
Ryude
Hi, I want to put all of my spell triggers into one trigger. So I did this and for some reason it gives me an error (Invalid Type for Specified Operator):

Code:
//======================
//   Functions
//======================

function Ability_Effects_Actions takes nothing returns boolean
//== Locals ============
  local unit u=GetTriggerUnit()
  local unit t=GetSpellTargetUnit()
  local unit p
  local group g=CreateGroup()
  local location l=GetSpellTargetLoc()
  local real d
  local real hu=GetUnitStateSwap(UNIT_STATE_LIFE,u)
  local real ht=GetUnitStateSwap(UNIT_STATE_LIFE,t)
  local integer a=GetSpellAbilityId()
  local integer i=GetUnitAbilityLevel(u,a)

//== Actions ===========

//== Devour Magic ======
    if a=='A02T' then
        set d=(75.00*I2R(i))
        call SetUnitLifeBJ(u,(hu+d))
    endif

//== Energy Surge ======
    if a=='A03J' then
        set d=(30.00*I2R(i))
        call SetUnitLifeBJ(u,(hu+d))
    endif

//== Ethereal Rejuvenation
    if a=='A025' then
        set d=(25.00*I2R(i))
        call SetUnitLifeBJ(t,(ht-d))
    endif

//== Eat Treant ========
    if a=='A04H' then
        set d=(ht*(0.40*I2R(i)))
        call KillUnit(t)
        call SetUnitLifeBJ(u,(hu+d))
    endif

//== Touch of Death ====
    if a=='A015' then
        call UnitDamageTargetBJ(u,t,((I2R(i)*5.00)+ 15.00),ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL)
    endif

//== Magic Curse =======
    if UnitHasBuffBJ(u,'B01N') then
        call GroupEnumUnitsOfType(g,UnitId2String('O000'),null)
        loop
            set p=FirstOfGroup(g)
            exitwhen p==null
            set d=(I2R(GetUnitAbilityLevel(p,'A01X'))*50.00)
            if GetOwningPlayer(p)!=Player(PLAYER_NEUTRAL_PASSIVE) then
                call UnitDamageTargetBJ(p,u,d,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL)
            endif
            call GroupRemoveUnit(g,p)
        endloop
        call AddSpecialEffectTargetUnitBJ("overhead",u,"Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl")
        call DestroyEffectBJ(GetLastCreatedEffectBJ())
    endif

//== Siphon Strength ===
    if a=='A00V' then
        call GroupEnumUnitsInRangeOfLoc(g,t,300,null)
        loop
            set p=FirstOfGroup(g)
            exitwhen p==null
            set d=(GetUnitStateSwap(UNIT_STATE_MAX_LIFE,p)*0.33)
            if GetUnitAbilityLevel(p,'Aloc')==0 and IsUnitAliveBJ(p) and IsUnitEnemy(p,GetOwningPlayer(u)) and not(IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)) then
                call UnitDamageTargetBJ(u,p,d,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL)
            endif
            call GroupRemoveUnit(g,p)
        endloop
    endif

//== Rift ==============
    if a=='A00M' then
        call SetUnitPositionLoc(u,l)
    endif

//== LVL Death =========
    if a=='A03G' then
        if GetHeroLevel(t)==3 or GetHeroLevel(t)==6 or GetHeroLevel(t)==9 then
            call AddSpecialEffectTargetUnitBJ("overhead",t,"Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl")
            call DestroyEffectBJ(GetLastCreatedEffectBJ())
            call AddSpecialEffectTargetUnitBJ("overhead",t,"Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl")
            call DestroyEffectBJ(GetLastCreatedEffectBJ())
            call UnitDamageTargetBJ(u,t,75.00,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL)
        endif
    endif

//== Magnetic Force ====
    if a=='A00B' then
        call SetUnitAnimation(u,"Spell Slam")
        call GroupEnumUnitsInRangeOfLoc(g,u,700,null)
        loop
            set p=FirstOfGroup(g)
            exitwhen p==null
            if GetOwningPlayer(p)!=Player(PLAYER_NEUTRAL_PASSIVE) and not(IsUnitType(p,UNIT_TYPE_FLYING)) and not(IsUnitType(p,UNIT_TYPE_STRUCTURE)) then
                call SetUnitPositionLoc(p,GetUnitLoc(u))
            endif
            call GroupRemoveUnit(g,p)
        endloop
    endif

//== Cleanup ===========
    call DestroyGroup(g)
    call RemoveLocation(l)
    set u=null
    set t=null
    set p=null
    set l=null
    set g=null
endfunction

//======================
//   Events
//======================

function InitTrig_Ability_Effects takes nothing returns nothing
    set gg_trg_Ability_Effects=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Ability_Effects,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(gg_trg_Ability_Effects,function Ability_Effects_Actions)
endfunction
12-17-2004, 01:06 PM#2
AIAndy
GroupEnumUnitsInRangeOfLoc takes a location as second parameter, not a unit.
I suggest to use PJass ( http://amai.wc3campaigns.com/pjass.zip ) when the built-in syntax checker does not give enough information.
12-17-2004, 03:30 PM#3
Ryude
That's okay, I figured out how to do it =D I had the action returning a boolean (wrong type for specified operator).

Thanks anyhow.
01-08-2005, 12:08 AM#4
ProFeT
You could use a switch instead of if-endif - if-endif ...

Quote:
//== Devour Magic ======
if a=='A02T' then
set d=(75.00*I2R(i))
call SetUnitLifeBJ(u,(hu+d))
endif

//== Energy Surge ======
if a=='A03J' then
set d=(30.00*I2R(i))
call SetUnitLifeBJ(u,(hu+d))
endif

//== Ethereal Rejuvenation
if a=='A025' then
set d=(25.00*I2R(i))
call SetUnitLifeBJ(t,(ht-d))
endif

use :

Code:
//== Devour Magic ======
    if a=='A02T' then
        set d=(75.00*I2R(i))
        call SetUnitLifeBJ(u,(hu+d))

//== Energy Surge ======
    elseif a=='A03J' then
        set d=(30.00*I2R(i))
        call SetUnitLifeBJ(u,(hu+d))

//== Ethereal Rejuvenation
    elseif a=='A025' then
        set d=(25.00*I2R(i))
        call SetUnitLifeBJ(t,(ht-d))

...

    endif
01-08-2005, 05:59 AM#5
Ryude
If I use that then the spells won't work right.

1 of the spells I use requires that 2 of those occur at the same time.
01-08-2005, 10:47 AM#6
ProFeT
try :

if a=1

elseif a=2

elseif a=3

...

endif


if a=3 AND "2nd cond" then ....