📄 blizzard.j
字号:
function TanBJ takes real degrees returns real
return Tan(degrees*bj_DEGTORAD)
endfunction
function AsinBJ takes real degrees returns real
return Asin(degrees)*bj_RADTODEG
endfunction
function AcosBJ takes real degrees returns real
return Acos(degrees)*bj_RADTODEG
endfunction
function AtanBJ takes real degrees returns real
return Atan(degrees)*bj_RADTODEG
endfunction
function Atan2BJ takes real y,real x returns real
return Atan2(y,x)*bj_RADTODEG
endfunction
function AngleBetweenPoints takes location locA,location locB returns real
return bj_RADTODEG*Atan2(GetLocationY(locB)-GetLocationY(locA),GetLocationX(locB)-GetLocationX(locA))
endfunction
function DistanceBetweenPoints takes location locA,location locB returns real
local real dx=GetLocationX(locB)-GetLocationX(locA)
local real dy=GetLocationY(locB)-GetLocationY(locA)
return SquareRoot(dx*dx+dy*dy)
endfunction
function PolarProjectionBJ takes location source,real dist,real angle returns location
local real x=GetLocationX(source)+dist*Cos(angle*bj_DEGTORAD)
local real y=GetLocationY(source)+dist*Sin(angle*bj_DEGTORAD)
return Location(x,y)
endfunction
function GetRandomDirectionDeg takes nothing returns real
return GetRandomReal(0,360)
endfunction
function GetRandomPercentageBJ takes nothing returns real
return GetRandomReal(0,100)
endfunction
function GetRandomLocInRect takes rect whichRect returns location
return Location(GetRandomReal(GetRectMinX(whichRect),GetRectMaxX(whichRect)),GetRandomReal(GetRectMinY(whichRect),GetRectMaxY(whichRect)))
endfunction
function ModuloInteger takes integer dividend,integer divisor returns integer
local integer modulus=dividend-(dividend/divisor)*divisor
if(modulus<0)then
set modulus=modulus+divisor
endif
return modulus
endfunction
function ModuloReal takes real dividend,real divisor returns real
local real modulus=dividend-I2R(R2I(dividend/divisor))*divisor
if(modulus<0)then
set modulus=modulus+divisor
endif
return modulus
endfunction
function OffsetLocation takes location loc,real dx,real dy returns location
return Location(GetLocationX(loc)+dx,GetLocationY(loc)+dy)
endfunction
function OffsetRectBJ takes rect r,real dx,real dy returns rect
return Rect(GetRectMinX(r)+dx,GetRectMinY(r)+dy,GetRectMaxX(r)+dx,GetRectMaxY(r)+dy)
endfunction
function RectFromCenterSizeBJ takes location center,real width,real height returns rect
local real x=GetLocationX(center)
local real y=GetLocationY(center)
return Rect(x-width*0.5,y-height*0.5,x+width*0.5,y+height*0.5)
endfunction
function RectContainsCoords takes rect r,real x,real y returns boolean
return(GetRectMinX(r)<=x)and(x<=GetRectMaxX(r))and(GetRectMinY(r)<=y)and(y<=GetRectMaxY(r))
endfunction
function RectContainsLoc takes rect r,location loc returns boolean
return RectContainsCoords(r,GetLocationX(loc),GetLocationY(loc))
endfunction
function RectContainsUnit takes rect r,unit whichUnit returns boolean
return RectContainsCoords(r,GetUnitX(whichUnit),GetUnitY(whichUnit))
endfunction
function RectContainsItem takes item whichItem,rect r returns boolean
if(whichItem==null)then
return false
endif
if(IsItemOwned(whichItem))then
return false
endif
return RectContainsCoords(r,GetItemX(whichItem),GetItemY(whichItem))
endfunction
function ConditionalTriggerExecute takes trigger trig returns nothing
if TriggerEvaluate(trig)then
call TriggerExecute(trig)
endif
endfunction
function TriggerExecuteBJ takes trigger trig,boolean checkConditions returns boolean
if checkConditions then
if not(TriggerEvaluate(trig))then
return false
endif
endif
call TriggerExecute(trig)
return true
endfunction
function PostTriggerExecuteBJ takes trigger trig,boolean checkConditions returns boolean
if checkConditions then
if not(TriggerEvaluate(trig))then
return false
endif
endif
call TriggerRegisterTimerEvent(trig,0,false)
return true
endfunction
function QueuedTriggerCheck takes nothing returns nothing
local string s="TrigQueue Check "
local integer i
set i=0
loop
exitwhen i>=bj_queuedExecTotal
set s=s+"q["+I2S(i)+"]="
if(bj_queuedExecTriggers[i]==null)then
set s=s+"null "
else
set s=s+"x "
endif
set i=i+1
endloop
set s=s+"("+I2S(bj_queuedExecTotal)+" total)"
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,600,s)
endfunction
function QueuedTriggerGetIndex takes trigger trig returns integer
local integer index=0
loop
exitwhen index>=bj_queuedExecTotal
if(bj_queuedExecTriggers[index]==trig)then
return index
endif
set index=index+1
endloop
return-1
endfunction
function QueuedTriggerRemoveByIndex takes integer trigIndex returns boolean
local integer index
if(trigIndex>=bj_queuedExecTotal)then
return false
endif
set bj_queuedExecTotal=bj_queuedExecTotal-1
set index=trigIndex
loop
exitwhen index>=bj_queuedExecTotal
set bj_queuedExecTriggers[index]=bj_queuedExecTriggers[index+1]
set bj_queuedExecUseConds[index]=bj_queuedExecUseConds[index+1]
set index=index+1
endloop
return true
endfunction
function QueuedTriggerAttemptExec takes nothing returns boolean
loop
exitwhen bj_queuedExecTotal==0
if TriggerExecuteBJ(bj_queuedExecTriggers[0],bj_queuedExecUseConds[0])then
call TimerStart(bj_queuedExecTimeoutTimer,bj_QUEUED_TRIGGER_TIMEOUT,false,null)
return true
endif
call QueuedTriggerRemoveByIndex(0)
endloop
return false
endfunction
function QueuedTriggerAddBJ takes trigger trig,boolean checkConditions returns boolean
if(bj_queuedExecTotal>=bj_MAX_QUEUED_TRIGGERS)then
return false
endif
set bj_queuedExecTriggers[bj_queuedExecTotal]=trig
set bj_queuedExecUseConds[bj_queuedExecTotal]=checkConditions
set bj_queuedExecTotal=bj_queuedExecTotal+1
if(bj_queuedExecTotal==1)then
call QueuedTriggerAttemptExec()
endif
return true
endfunction
function QueuedTriggerRemoveBJ takes trigger trig returns nothing
local integer index
local integer trigIndex
local boolean trigExecuted
set trigIndex=QueuedTriggerGetIndex(trig)
if(trigIndex==-1)then
return
endif
call QueuedTriggerRemoveByIndex(trigIndex)
if(trigIndex==0)then
call PauseTimer(bj_queuedExecTimeoutTimer)
call QueuedTriggerAttemptExec()
endif
endfunction
function QueuedTriggerDoneBJ takes nothing returns nothing
local integer index
if(bj_queuedExecTotal<=0)then
return
endif
call QueuedTriggerRemoveByIndex(0)
call PauseTimer(bj_queuedExecTimeoutTimer)
call QueuedTriggerAttemptExec()
endfunction
function QueuedTriggerClearBJ takes nothing returns nothing
call PauseTimer(bj_queuedExecTimeoutTimer)
set bj_queuedExecTotal=0
endfunction
function QueuedTriggerClearInactiveBJ takes nothing returns nothing
set bj_queuedExecTotal=IMinBJ(bj_queuedExecTotal,1)
endfunction
function QueuedTriggerCountBJ takes nothing returns integer
return bj_queuedExecTotal
endfunction
function IsTriggerQueueEmptyBJ takes nothing returns boolean
return bj_queuedExecTotal<=0
endfunction
function IsTriggerQueuedBJ takes trigger trig returns boolean
return QueuedTriggerGetIndex(trig)!=-1
endfunction
function GetForLoopIndexA takes nothing returns integer
return bj_forLoopAIndex
endfunction
function SetForLoopIndexA takes integer newIndex returns nothing
set bj_forLoopAIndex=newIndex
endfunction
function GetForLoopIndexB takes nothing returns integer
return bj_forLoopBIndex
endfunction
function SetForLoopIndexB takes integer newIndex returns nothing
set bj_forLoopBIndex=newIndex
endfunction
function PolledWait takes real duration returns nothing
local timer t
local real timeRemaining
if(duration>0)then
set t=CreateTimer()
call TimerStart(t,duration,false,null)
loop
set timeRemaining=TimerGetRemaining(t)
exitwhen timeRemaining<=0
if(timeRemaining>bj_POLLED_WAIT_SKIP_THRESHOLD)then
call TriggerSleepAction(0.1*timeRemaining)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(t)
endif
endfunction
function IntegerTertiaryOp takes boolean flag,integer valueA,integer valueB returns integer
if flag then
return valueA
else
return valueB
endif
endfunction
function DoNothing takes nothing returns nothing
endfunction
function CommentString takes string commentString returns nothing
endfunction
function StringIdentity takes string theString returns string
return GetLocalizedString(theString)
endfunction
function GetBooleanAnd takes boolean valueA,boolean valueB returns boolean
return valueA and valueB
endfunction
function GetBooleanOr takes boolean valueA,boolean valueB returns boolean
return valueA or valueB
endfunction
function PercentToInt takes real percentage,integer max returns integer
local integer result=R2I(percentage*I2R(max)*0.01)
if(result<0)then
set result=0
elseif(result>max)then
set result=max
endif
return result
endfunction
function PercentTo255 takes real percentage returns integer
return PercentToInt(percentage,255)
endfunction
function GetTimeOfDay takes nothing returns real
return GetFloatGameState(GAME_STATE_TIME_OF_DAY)
endfunction
function SetTimeOfDay takes real whatTime returns nothing
call SetFloatGameState(GAME_STATE_TIME_OF_DAY,whatTime)
endfunction
function SetTimeOfDayScalePercentBJ takes real scalePercent returns nothing
call SetTimeOfDayScale(scalePercent*0.01)
endfunction
function GetTimeOfDayScalePercentBJ takes nothing returns real
return GetTimeOfDayScale()*100
endfunction
function PlaySound takes string soundName returns nothing
local sound soundHandle=CreateSound(soundName,false,false,true,12700,12700,"")
call StartSound(soundHandle)
call KillSoundWhenDone(soundHandle)
endfunction
function CompareLocationsBJ takes location A,location B returns boolean
return GetLocationX(A)==GetLocationX(B)and GetLocationY(A)==GetLocationY(B)
endfunction
function CompareRectsBJ takes rect A,rect B returns boolean
return GetRectMinX(A)==GetRectMinX(B)and GetRectMinY(A)==GetRectMinY(B)and GetRectMaxX(A)==GetRectMaxX(B)and GetRectMaxY(A)==GetRectMaxY(B)
endfunction
function GetRectFromCircleBJ takes location center,real radius returns rect
local real centerX=GetLocationX(center)
local real centerY=GetLocationY(center)
return Rect(centerX-radius,centerY-radius,centerX+radius,centerY+radius)
endfunction
function GetCurrentCameraSetup takes nothing returns camerasetup
local camerasetup theCam=CreateCameraSetup()
local real duration=0
call CameraSetupSetField(theCam,CAMERA_FIELD_TARGET_DISTANCE,GetCameraField(CAMERA_FIELD_TARGET_DISTANCE),duration)
call CameraSetupSetField(theCam,CAMERA_FIELD_FARZ,GetCameraField(CAMERA_FIELD_FARZ),duration)
call CameraSetupSetField(theCam,CAMERA_FIELD_ZOFFSET,GetCameraField(CAMERA_FIELD_ZOFFSET),duration)
call CameraSetupSetField(theCam,CAMERA_FIELD_ANGLE_OF_ATTACK,bj_RADTODEG*GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK),duration)
call CameraSetupSetField(theCam,CAMERA_FIELD_FIELD_OF_VIEW,bj_RADTODEG*GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW),duration)
call CameraSetupSetField(theCam,CAMERA_FIELD_ROLL,bj_RADTODEG*GetCameraField(CAMERA_FIELD_ROLL),duration)
call CameraSetupSetField(theCam,CAMERA_FIELD_ROTATION,bj_RADTODEG*GetCameraField(CAMERA_FIELD_ROTATION),duration)
call CameraSetupSetDestPosition(theCam,GetCameraTargetPositionX(),GetCameraTargetPositionY(),duration)
return theCam
endfunction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -