User
Join Date: Feb 2007
Posts: 44
|
The correct way of doing this is to use an other group loop. Like:
local group g = CreateGroup() local unit tmpunit local location l = *some random location* call GroupEnumUnitsInRangeOfLoc(g, l, 500, null) call DestroyLocation(l) set l = null loop set tmpunit = FirstOfGroup(g) call GroupRemoveUnit(g, tmpunit) exitwhen tmpunit == null *Do your functions here* endloop call DestroyGroup(g) set g = null
I dont know if its agains the contests rules if someone edits your code to make it work. If so then dont open this.
Fix
function Trig_Chain_Conditions takes nothing returns boolean return GetSpellAbilityId () == 'A000'endfunction//=========================================================//ver local vars MB_targ, MB_SMax, MB_alltargsfunction forUnit takes unit whichUnit, unit targ, real max, group g returns nothing local player p = GetOwningPlayer (GetTriggerUnit ()) local unit MB_targ = targ local real MB_SMax = max local group MB_alltarg = g if IsUnitType (whichUnit, UNIT_TYPE_STRUCTURE ) == false and IsUnitType (whichUnit, UNIT_TYPE_MECHANICAL ) and IsUnitType (whichUnit, UNIT_TYPE_MAGIC_IMMUNE ) and IsUnitEnemy (whichUnit, p ) and (GetUnitState (whichUnit, UNIT_STATE_LIFE ) > 0 ) and IsUnitInGroup (whichUnit, MB_alltarg ) == false and (GetUnitState (whichUnit, UNIT_STATE_MAX_MANA ) > 0 ) and (GetUnitState (whichUnit, UNIT_STATE_MANA ) >= MB_SMax ) then set MB_targ = whichUnit set MB_SMax = GetUnitState (u, UNIT_STATE_MANA ) endif //call DestroyGroup(MB_alltarg) //set MB_alltarg = null //set u = null //set p = null //set MB_targ = nullendfunction//=========================================================function Trig_Chain_Actions takes nothing returns nothing //variables part local unit MB_targ = GetSpellTargetUnit ()//current target local unit MB_prev = GetTriggerUnit () //previous target, the source where it all came local integer MB_level = GetUnitAbilityLevel (MB_prev, 'A000') local integer MB_targetsnum = (4 + (2 * (MB_level - 1 ))) //maximum number of affected unit local integer MB_cur //current number of targets local group MB_alltarg //Group that will save hit units in the past local unit dummy //casts the spells local group MB_TempGroup //will pick a random unit, that will be the next target local real MB_SMax //chooses the unit with more mana local location l local group tmpgroup = CreateGroup () local unit tmpunit //action part loop exitwhen (MB_cur > MB_targetsnum ) //start call GroupAddUnit (MB_alltarg, MB_targ ) set dummy = CreateUnit (GetOwningPlayer (GetTriggerUnit ()), 'h000', GetUnitX (MB_prev ), GetUnitY (MB_prev ), 0.0 ) call UnitAddAbility (dummy, 'A002') call IssueTargetOrder (dummy, "shadowstrike", MB_targ ) call UnitApplyTimedLife (dummy, 'BTLF', 1.0 ) //set dummy = null //Wait Unit Unit was reached by effect loop exitwhen ((GetUnitAbilityLevel (MB_targ, 'BEsh') > 0 ) or (GetUnitState (MB_targ, UNIT_STATE_LIFE ) <= 0 )) call TriggerSleepAction (0.30 ) endloop //If unit is alive, take mana if (GetUnitState (MB_targ, UNIT_STATE_LIFE ) <= 0 ) == false then call CreateUnit (GetOwningPlayer (GetTriggerUnit ()), 'h000', GetUnitX (MB_targ ), GetUnitY (MB_targ ), 0.0 ) call UnitApplyTimedLife (dummy, 'BTLF', 1.0 ) call UnitAddAbility (dummy, 'A001') call SetUnitAbilityLevel (dummy, 'A001', 8 * (MB_level - 1 ) + MB_cur ) call IssueTargetOrder (dummy, "manaburn", MB_targ ) else set MB_cur = MB_targetsnum + 1 endif //Choose New target if (MB_cur < MB_targetsnum ) then set MB_prev = MB_targ set MB_SMax = -1 set l = GetUnitLoc (MB_prev ) call GroupEnumUnitsInRangeOfLoc (tmpgroup, l, 500, null) loop set tmpunit = FirstOfGroup (tmpgroup ) call GroupRemoveUnit (tmpgroup, tmpunit ) exitwhen tmpunit == null call forUnit (tmpunit, MB_targ, MB_SMax, MB_alltarg ) endloop call DestroyGroup (tmpgroup ) set tmpgroup = null call RemoveLocation (l ) set l = null call GroupClear (MB_alltarg ) endif set MB_cur = MB_cur + 1 endloop call DestroyGroup (MB_alltarg ) call DestroyGroup (MB_TempGroup ) set MB_alltarg = null set MB_TempGroup = null set MB_targ = null set MB_prev = null set dummy = nullendfunction//=========================================================function InitTrig_Chain takes nothing returns nothing set gg_trg_Chain = CreateTrigger () call TriggerRegisterAnyUnitEventBJ ( gg_trg_Chain, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition (gg_trg_Chain, Condition (function Trig_Chain_Conditions )) call TriggerAddAction (gg_trg_Chain, function Trig_Chain_Actions )endfunction
|