Юнит перемещается на ~50 по координатам вперёд, не больше..
Где могла быть ошибка:
Код
function AngleBetweenPositions takes real xa, real ya, real xb, real yb returns real
return 180.0 / 3.14159 * Atan2( yb - ya, xb - xa )
endfunction
function DistanceBetweenPositions takes real xa, real ya, real xb, real yb returns real
real dx = xb - xa
real dy = yb - ya
return SquareRoot( dx * dx + dy * dy )
endfunction
function PolarProjectionX takes real x, real dist, real angle returns real
return x + dist * Cos( angle * 3.14159 / 180.0 )
endfunction
function PolarProjectionY takes real y, real dist, real angle returns real
return y + dist * Sin( angle * 3.14159 / 180.0 )
endfunction
Код
scope InitA001 initializer InitA001
globals
private constant trigger Trigger = CreateTrigger( )
private constant timer Timer = CreateTimer( )
private group Group = CreateGroup( )
private int GetAbilityAccount = 8192
private int GetSourceAccount = 0
private unit arr Dummy
private unit arr Source
private real arr SourceX
private real arr SourceY
private real arr TargetX
private real arr TargetY
private real arr Angle
private real arr Distance
private real arr DistanceAccount
private real arr Speed
endglobals
define
private n = [ GetAbilityAccount ]
private ID = [ i ]
enddefine
function A001Activate takes player p returns void
if GetLocalPlayer( ) == p
ForceUIKey( "E" )
end
endfunction
private function Actions takes void returns void
unit u = GetEnumUnit( )
int i = GetUnitUserData( u )
if DistanceAccount ID < Distance ID
SetUnitX( Source ID, PolarProjectionX( SourceX ID, Speed ID, Angle ID ) )
SetUnitY( Source ID, PolarProjectionY( SourceY ID, Speed ID, Angle ID ) )
DistanceAccount ID += Speed ID
else
Source ID = null
GroupRemoveUnit( Group, Dummy ID )
RemoveUnit( Dummy ID )
Dummy ID = null
GetSourceAccount --
if GetSourceAccount == 0
u = null
PauseTimer( Timer )
end
end
endfunction
private function Update takes void returns void
ForGroup( Group, function Actions )
endfunction
private function Registers takes void returns void
if GetSourceAccount == 0
GetAbilityAccount = 8192
ResumeTimer( Timer )
end
GetAbilityAccount --
GetSourceAccount ++
Source n = GetSpellAbilityUnit( )
SourceX n = GetUnitX( Source n )
SourceY n = GetUnitY( Source n )
if GetSpellTargetUnit( ) == null
TargetX n = GetSpellTargetX( )
TargetY n = GetSpellTargetY( )
else
TargetX n = GetUnitX( GetSpellTargetUnit( ) )
TargetY n = GetUnitY( GetSpellTargetUnit( ) )
end
Angle n = AngleBetweenPositions( SourceX n, SourceY n, TargetX n, TargetY n )
Distance n = DistanceBetweenPositions( SourceX n, SourceY n, TargetX n, TargetY n )
DistanceAccount n = 0.0
Speed n = Distance n * 0.03
Dummy n = CreateUnit( GetOwningPlayer( Source n ), 'unit', SourceX n, SourceY n, 0.0 )
SetUnitUserData( Dummy n, GetAbilityAccount )
GroupAddUnit( Group, Dummy n )
endfunction
private function AbiFilter takes void returns bool
return GetSpellAbilityId( ) == 'A001'
endfunction
function InitA001 takes void returns void
int nPl = 0
loop
nPl ++
TriggerRegisterPlayerUnitEvent( Trigger, GetPlayerIndex[ nPl ], ConvertPlayerUnitEvent( 274 ), null )
break nPl >= GetPlayersAccount
endloop
TriggerAddCondition( Trigger, function AbiFilter )
TriggerAddAction( Trigger, function Registers )
TimerStart( Timer, 0.03, true, function Update )
endfunction
endscope
Конечно я писал понимая, но вдруг такая неожиданность... искал ошибку часов полтора, так и не нашёл - тошнит уже
Тискаю клаву... остальных пока некогда!