Trying to include allies with mass teleport

J

JRPereira

Guest
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 tendancy 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.

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.
 

Sooda

Diversity enchants
Reaction score
318
> 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?

Don' t you just want to create dummy unit, give it modified Mass Teleport and create it from where you want to 'summon' allies. Order dummy to cast ability where you want them to transport. Sounds simple.
 
J

JRPereira

Guest
For some reason creating the dummy units and calling them to mass teleport wouldn't bring along heroes, no matter how I did the targets allowed field.

I ended up using this one to get it to work. It could be cleaned up a slight bit by using player locals.

JASS:
function jrp_spell_mass_tele takes unit trigunit, location targloc, integer spell_id returns nothing

	local unit tempunit
	local group tempgroup
	local location tpoint1 = GetUnitLoc(trigunit)
	local location tpoint2
	
	local effect tele01 = jrp_create_effect(tpoint1, "Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl" )
	local effect tele02 = jrp_create_effect(targloc, "Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl" )
	
	call PolledWait( 1.75 )
	
	set tempgroup = GetUnitsInRangeOfLocAll(600, targloc)
	
	loop
	exitwhen(FirstOfGroup(tempgroup) == null)
		set tempunit = FirstOfGroup(tempgroup)

		if ( (GetOwningPlayer(tempunit) != GetOwningPlayer(trigunit)) and (IsPlayerAlly(GetOwningPlayer(trigunit), GetOwningPlayer(tempunit)) == true) and (IsUnitType(tempunit, UNIT_TYPE_STRUCTURE) == false) and (GetUnitTypeId(tempunit) != 'earc') ) then
			set tpoint2 = GetUnitLoc(tempunit)
			call jrp_create_and_destroy_effect( tpoint2, "Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl" )
			call RemoveLocation( tpoint2 )
			
			call SetUnitPositionLoc( tempunit, tpoint1 )

			set tpoint2 = GetUnitLoc(tempunit)
			call jrp_create_and_destroy_effect( tpoint2, "Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl" )
			call RemoveLocation( tpoint2 )
		endif
		
	call GroupRemoveUnit(tempgroup, tempunit)
	endloop
	
	call DestroyGroup( tempgroup )
	call RemoveLocation( tpoint1 )
	call RemoveLocation( targloc )

	call DestroyEffect( tele01 )
	call DestroyEffect( tele02 )
	
endfunction
 

N-a-z-g-u-l

New Member
Reaction score
30
CreateAndDestroyEffect?

dont you want to use DestroyEffect(AddSpecialEffectLoc(....))?

EDIT: you use it to create effects, too... it seems like it does something more... then you can use it of course^^
 
J

JRPereira

Guest
Actually I just did createanddestroyeffect to have something with no other function than its name, and be easy to write out.

The map I'm working on has undergone a lot of changes and a rewrite of almost all of the jass.

I'm not sure if my functions are worth anything to anyone, but I'll get around to posting them once I polish up the map.

Or you could just pop open the map and grab everything there, I'm not going through the trouble of protecting the map.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top