HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why doesnt this work? =/

06-18-2004, 08:44 AM#1
Xinlitik
Ok...I'm making a spell that lays a mine. When the mine comes into play, it steals the mana of nearby units for 3 seconds. This is all stored in a variable and when the casting is over, all units are moved towards the mine and then there's an explosion that deals a multiplier * the mana stolen.

Basically, the stupid GroupEnumUnits function doesnt do anything for some weird reason. The mana stolen debug message gives 0 every time. After that, the mine is killed but nothing else happens. Also, the mana siphon is only cast on the first run of the loop, not the other two.

By the way, the damageunit functions and the castability functions are from vexorian's caster system.

Thanks

Code:
function LunarMineFilter takes nothing returns boolean
    return (GetUnitState(GetFilterUnit(),UNIT_STATE_MANA) > 0) and (IsUnitAliveBJ(GetFilterUnit()) == true) and (IsUnitEnemy(GetFilterUnit(),bj_groupEnumOwningPlayer))
endfunction

function MoveLunarUnits takes unit u, location l returns nothing
    local location temp
    local location temp2
    local integer i = 0
    call SetUnitPathing(u,false)
    loop
        exitwhen i > 12
        set temp = GetUnitLoc(u)
        set temp2 = PolarProjectionBJ(temp,10,AngleBetweenPoints(temp,l))
        call SetUnitPositionLoc(u,temp2)
        call RemoveLocation(temp)
        call RemoveLocation(temp2)
        set temp = null
        set temp2 = null
        call PolledWait(.25)
        call DisplayTimedTextToPlayer(Player(0),0,0,3,GetUnitName(u) + "is being pulled!")
        set i = i + 1
    endloop
    call SetUnitPathing(u,true)
endfunction

function LunarMineGroupPull takes nothing returns nothing
    local location moveto = bj_meleeNearestMineToLoc
    call MoveLunarUnits(GetEnumUnit(),moveto)
    call RemoveLocation(moveto)
    set moveto = null
    call DisplayTimedTextToPlayer(Player(0),0,0,3,GetUnitName(GetEnumUnit()) + "had its move function called!")
endfunction


function Trig_Lunar_Mine_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01B'
endfunction

function Trig_Lunar_Mine_Actions takes nothing returns nothing
    local location targetloc = GetSpellTargetLoc()
    local unit caster = GetTriggerUnit()
    local real level = GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit())
    local real int = I2R(GetHeroInt(caster,true))
    local real damage = int * level * .01
    local unit mine = CreateUnitAtLoc(GetOwningPlayer(caster),'o000',targetloc,0)
    local integer i = 0
    local real manastolen = 0
    local group tosteal = CreateGroup()
    local effect fx

    loop
        exitwhen i > 3
        set udg_sourcehack = targetloc
        set udg_delayhack = 1.00
        call CasterCastAbilityAOELoc(GetOwningPlayer(caster),'A01C',"drain",targetloc,450,false,false)
        set udg_delayhack = 0.00
        call RemoveLocation(udg_sourcehack)
        set udg_sourcehack = null
        set bj_groupEnumOwningPlayer=GetOwningPlayer(caster)
        call GroupClear(tosteal)
        call GroupEnumUnitsInRangeOfLoc(tosteal,targetloc,450,Condition(function LunarMineFilter))
        set manastolen = manastolen + (15.00 * CountUnitsInGroup(tosteal))
        call DisplayTimedTextToPlayer(Player(0),0,0,3,R2S(manastolen) + "is what manastolen is equal to!")
        call PolledWait(1)
        set i = i + 1
    endloop
    
    set bj_groupEnumOwningPlayer=GetOwningPlayer(caster)
    call TerrainDeformRipple(GetLocationX(targetloc),GetLocationY(targetloc), 450,64,3,8,50,.25,350,false)
    set fx = AddSpecialEffectLoc("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl",targetloc)
    call GroupClear(tosteal)
    call GroupEnumUnitsInRangeOfLoc(tosteal,targetloc,450,Condition(function LunarMineFilter))
    set bj_meleeNearestMineToLoc = targetloc
    call ForGroup(tosteal,function LunarMineGroupPull)
    call RemoveLocation(bj_meleeNearestMineToLoc)
    set bj_meleeNearestMineToLoc = null
    call PolledWait(3)
    call DestroyEffect(fx)
    set fx = null
    call KillUnit(mine)
    call PolledWait(.01)
    call DamageUnitsInAOELoc(GetOwningPlayer(caster),damage * manastolen,targetloc,450,false)
    call RemoveLocation(targetloc)
    set targetloc = null
    call GroupClear(tosteal)
    call DestroyGroup(tosteal)
    set tosteal = null
    set mine = null
    endfunction
//===========================================================================
function InitTrig_Lunar_Mine takes nothing returns nothing
    set gg_trg_Lunar_Mine = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lunar_Mine, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Lunar_Mine, Condition( function Trig_Lunar_Mine_Conditions ) )
    call TriggerAddAction( gg_trg_Lunar_Mine, function Trig_Lunar_Mine_Actions )
endfunction