- Joined
- Jun 24, 2009
- Messages
- 1,409
Is there any JASS command to find the casted mass teleport's target building? If I use the target point of ability being cast the pont is targeted point and not the nearest building.
You don't need custom script for the target
I tried a trigger like this and it worked fine:
Untitled Trigger 002
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Mass Teleport
Actions
Set unit = (Target unit of ability being cast)
Game - Display to Player Group - Player 1 (Red) the text: (String((Unit-type of unit)))
well, that one works for me:
Teleport
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Mass Teleport
Actions
Set TeleCaster = (Triggering unit)
Set TelePoint1 = (Target point of ability being cast)
Set TeleGroup = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to True))
Set TeleDist2 = 1000000000.00
Unit Group - Pick every unit in TeleGroup and do (Actions)
Loop - Actions
Set TelePoint2 = (Position of (Picked unit))
Set TeleDist1 = (Distance between TelePoint1 and TelePoint2)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TeleDist1 Less than TeleDist2
Then - Actions
Set TeleDist2 = (Distance between TelePoint1 and TelePoint2)
Set TeleUnit = (Picked unit)
Else - Actions
Custom script: call RemoveLocation (udg_TelePoint2)
Set TelePoint3 = (Position of TeleUnit)
Unit - Create 1 Dummy for (Owner of TeleCaster) at TelePoint3 facing Default building facing degrees
Unit - Add a 2.60 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation (udg_TelePoint1)
Custom script: call RemoveLocation (udg_TelePoint3)
It only works if you target the building itself. If you target the spell on the ground it does nothing.
Hmm.. how can you know this?
"the max range that there can be is Sqrt(480^2+480^2) * 128 = 86889."
And max range of what? :O
Still doesn't sound right to me. Should be a way to exclude that part.
I'll figure something out, give me a day or two.
I already lowered that one.
globals
real TempX=0.0
real TempY=0.0
real TempDist=0.0
unit TempUnit=null
endglobals
function enumGroup takes nothing returns nothing
local unit u=GetEnumUnit()
local real x=GetUnitX(u)-TempX
local real y=GetUnitY(u)-TempY
local real distance=SquareRoot(x*x+y*y)
if TempDist>distance then
set TempDist=distance
set TempUnit=u
endif
set u=null
endfunction
function GetNearestUnitInGroupFromXY takes real x, real y, group g returns unit
local unit u=FirstOfGroup(g)
set TempX=x
set TempY=y
set x=GetUnitX(u)-x
set y=GetUnitY(u)-y
set TempDist=SquareRoot(x*x+y*y)
call GroupRemoveUnit(g,u)
set TempUnit=u
call ForGroup(g,function enumGroup)
set u=null
return TempUnit
endfunction
Also, FirstOfGroup and ForGroup are not functionally similar so there's no point in comparing them.
Eh?, what are we talking about?group.