- Joined
- Jun 8, 2004
- Messages
- 66
I've been trying to create one of two spells with no success - either a "summon allies" skill that brings all allied units (minus a few types that are special) to a unit's location, or a variation of mass teleport that brings allies with you. Has anyone created a spell like this before?
The code can be found below. It has a tendency to work only some of the time - more often it works in smaller games or in games I host solo and throw a few computer players into.
The below code is supposed to bring allies with you when you do a regular mass teleport (I have events declared elsewhere which call the skill).
Basically it seems to always at least do the effects, but it doesn't always move the allied units.
By the way, what's leaking?
The spell_id argument is actually a holdover from a previous version of the map, and isn't used in the function. I'll probably get around to removing it soon.
The code can be found below. It has a tendency to work only some of the time - more often it works in smaller games or in games I host solo and throw a few computer players into.
The below code is supposed to bring allies with you when you do a regular mass teleport (I have events declared elsewhere which call the skill).
Basically it seems to always at least do the effects, but it doesn't always move the allied units.
By the way, what's leaking?
JASS:
function jrp_spell_mass_tele takes unit trigunit, unit targunit, integer spell_id returns nothing
local unit tempunit
local group tempgroup
local location tpoint1
local location tpoint2
local player trigplayer = GetOwningPlayer(trigunit)
local player tempplayer
call TriggerSleepAction( 4 )
set tpoint2 = GetUnitLoc(trigunit)
set tpoint1 = GetUnitLoc(trigunit)
set tempgroup = GetUnitsInRangeOfLocAll(600, tpoint1)
call RemoveLocation( tpoint1 )
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
set tempplayer = GetOwningPlayer(tempunit)
if ( (GetOwningPlayer(tempunit) != trigplayer) and (IsPlayerAlly(trigplayer, tempplayer) == true) and (IsUnitType(tempunit, UNIT_TYPE_STRUCTURE) == false) and (GetUnitTypeId(tempunit) != 'earc') ) then
set tpoint1 = GetUnitLoc(tempunit)
call AddSpecialEffectLocBJ( tpoint1, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call RemoveLocation( tpoint1 )
call SetUnitPositionLoc( tempunit, tpoint2 )
set tpoint1 = GetUnitLoc(tempunit)
call AddSpecialEffectLocBJ( tpoint1, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call RemoveLocation( tpoint1 )
endif
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup( tempgroup )
call RemoveLocation( tpoint2 )
endfunction
The spell_id argument is actually a holdover from a previous version of the map, and isn't used in the function. I'll probably get around to removing it soon.
Last edited: