/*
RADTODEG=57.29582
DEGTORAD=0.01745
该功能用于将极坐标换算为平面坐标
输入格式为x,y,d,r
x=圆心x
y=圆心y
d=角度
r=距离
输出得到的新坐标x,y
特别注意不可和任何其它文本匹配触发混用如najitest(为了方便省去了关键字检测
*/
globals
string sxyc
endglobals
function XYcalculatorA takes nothing returns nothing
local real array r
local integer a=1
local integer b=0
local integer c=0
set r[1]=0
set r[2]=0
set r[3]=0
set r[4]=0
set sxyc=null
loop
set sxyc=SubString(GetEventPlayerChatString(),b,b+1)
if sxyc=="," then
set r[a]=S2R(SubString(GetEventPlayerChatString(),c,b))
set a=a+1
set c=b+1
if a>=4 then
set r[4]=S2R(SubString(GetEventPlayerChatString(),c,StringLength(GetEventPlayerChatString())))
exitwhen true
endif
endif
set b=b+1
if b>=StringLength(GetEventPlayerChatString()) then
set r[a]=S2R(SubString(GetEventPlayerChatString(),c,StringLength(GetEventPlayerChatString())))
exitwhen true
endif
endloop
set r[5]=r[1]+Cos(0.01745*r[3])*r[4]
set r[6]=r[2]+Sin(0.01745*r[3])*r[4]
call DisplayTextToPlayer(GetTriggerPlayer(),0,0,"|cffFF0000输入|r"+R2S(r[1])+","+R2S(r[2])+","+R2S(r[3])+","+R2S(r[4])+"|cffFFFF00输出|r"+R2S(r[5])+","+R2S(r[6]))
endfunction
function XYcalculatorT takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,GetTriggerPlayer(),"",false)
call TriggerAddCondition(t,Condition(function XYcalculatorA))
set t=null
endfunction
示例:
