Авто-поворот юнитов
Автор: host_pi
-L - автокручение против часовой
-R - автокручение по часовой
-f XXX (-f 45 -f 200 -f 300) - поворот на градус
-R - автокручение по часовой
-f XXX (-f 45 -f 200 -f 300) - поворот на градус
globals
integer PLAYERS=12
integer array GO
integer array N
trigger array tgo4
integer array tgo4_init
hashtable ht=InitHashtable()
string array Direction
real array DirectionStart
unit array u
endglobals
function GOO4_Actions takes nothing returns nothing
local integer i=LoadInteger(ht,GetHandleId(GetTriggeringTrigger()),0)
local real A=0
set N[i]=N[i]+1
if Direction[i]=="R" then
set A=DirectionStart[i]-(N[i]*120)
elseif Direction[i]=="L" then
set A=DirectionStart[i]+(N[i]*120)
endif
call BJDebugMsg(I2S(R2I(GetUnitFacing(u[i])))+" "+I2S(N[i])+" "+GetPlayerName(Player(i-1)))
call SetUnitFacing(u[i],A)
if N[i]==3 then
set N[i]=0
endif
endfunction
function GOO4 takes string s returns nothing
local integer i=GetPlayerId(GetTriggerPlayer())+1
if tgo4_init[i]==0 then
set tgo4_init[i]=1
set tgo4[i]=CreateTrigger()
call SaveInteger(ht,GetHandleId(tgo4[i]),0,i)
call TriggerRegisterTimerEvent(tgo4[i], 0.5,true)
call TriggerAddAction(tgo4[i], function GOO4_Actions)
call DisableTrigger(tgo4[i])
endif
if s=="R" then
call BJDebugMsg("R")
set Direction[i]="R"
elseif s=="L" then
set Direction[i]="L"
call BJDebugMsg("L")
endif
if GO[i]==0 then
set GO[i]=1
set DirectionStart[i] = GetUnitFacing(u[i])
call EnableTrigger(tgo4[i])
else
set GO[i]=0
set N[i]=0
call DisableTrigger(tgo4[i])
call BJDebugMsg("STOP: "+GetPlayerName(Player(i-1)))
endif
endfunction
function Facing takes integer s returns nothing
local integer i=GetPlayerId(GetTriggerPlayer())+1
call SetUnitFacing(u[i],s)
endfunction
function Start takes nothing returns nothing
local string s=StringCase(GetEventPlayerChatString(),false)
if s=="-r" then
call GOO4("R")
elseif s=="-l" then
call GOO4("L")
elseif SubString(s,0,3)=="-f " then
call Facing(S2I(SubString(s,3,StringLength(s))))
endif
endfunction
function Start_init takes nothing returns nothing
local trigger t=CreateTrigger()
local integer i=1
loop
exitwhen i>PLAYERS
call TriggerRegisterPlayerChatEvent(t,Player(i-1),"-",false)
set i=i+1
endloop
call TriggerAddAction(t,function Start)
endfunction
function Facing_Start takes nothing returns nothing
call SetUnitFacing(u[1],270)
call SetUnitFacing(u[2],270)
call SetUnitFacing(u[3],270)
call SetUnitFacing(u[4],270)
call SetUnitFacing(u[5],270)
call SetUnitFacing(u[6],270)
call SetUnitFacing(u[7],270)
call BJDebugMsg("Use -L , -R , -f XXX")
endfunction
function CreateAllUnits takes nothing returns nothing
set u[1] = CreateUnit(Player(0), 'Hblm', -800, -50, 3.977)
set u[2] = CreateUnit(Player(1), 'Hblm', -400, -50, 3.977)
set u[3] = CreateUnit(Player(2), 'Hblm', 0, -50, 3.977)
set u[4] = CreateUnit(Player(3), 'Hblm', -200, -450, 3.977)
set u[5] = CreateUnit(Player(4), 'Hblm', -600, -450, 3.977)
set u[6] = CreateUnit(Player(5), 'Hblm', -200, 350, 3.977)
set u[7] = CreateUnit(Player(6), 'Hblm', -600, 350, 3.977)
call Facing_Start()
endfunction
Карта
Ред. nazarpunk
Ред. ScorpioT1000