• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] UNITA in range of UNITB question!

Status
Not open for further replies.
This was graveyarded a while back but it can solve your problem.
http://www.hiveworkshop.com/forums/graveyard-418/vjass-getsourceunit-157624/

It isn't the most efficient solution (it is actually pretty whacky), but it works. You can also just use waterknight's method, you just need to save the unit in a hashtable under the trigger id. Then in the actions you can load the unit under the handle id of GetTriggeringTrigger()

EDIT: Untested and made in textedit so I don't know if it even compiles. However, it should work.

Instead of the normal event, just use TriggerRegisterUnitInRangeEx(trigger, source, range, filter)

Then in the actions, use GetTriggerSourceUnit()

However, you can only register one TriggerRegisterUnitInRangeEx() per trigger. Good luck.

JASS:
library TriggerSourceUnit
	globals
		private hashtable hash = InitHashtable()
	endglobals

	function GetTriggerSourceUnit takes nothing returns unit
		return LoadUnitHandle(hash, 0, GetHandleId(GetTriggeringTrigger()))
	endfunction

	function TriggerRegisterUnitInRangeEx takes trigger t, unit source, real range, boolexpr filter returns boolean
		call SaveUnitHandle(hash, 0, GetHandleId(t), source)
		return TriggerRegisterUnitInRange(t, source, range, filter)
	endfunction
endlibrary
 
Last edited:
Status
Not open for further replies.
Top