|
发表于 2007-5-28 08:43:12
|
显示全部楼层
猜测是镜头函数比较占资源,而以上函数是人越多负荷就会越大
可以试试下面的函数:
CameraLockForPlayer:设置玩家镜头参数
CameraLockStart :开始或改变锁定周期
[codes=jass]
globals
gamecache udg_GC
real udg_Camera_TargetDistance = 0
real udg_Camera_AngleOfAttack = 0
real udg_Camera_Roll = 0
real udg_Camera_Rotation = 0
endglobals
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2Tm takes integer i returns timer
return i
return null
endfunction
function CameraLock_Func takes nothing returns nothing
call CameraSetupSetField(CAMERA_FIELD_TARGET_DISTANCE, udg_Camera_TargetDistance, 0.)
call CameraSetupSetField(CAMERA_FIELD_ANGLE_OF_ATTACK, udg_Camera_AngleOfAttack, 0.)
call CameraSetupSetField(CAMERA_FIELD_ROLL, udg_Camera_Roll, 0.)
call CameraSetupSetField(CAMERA_FIELD_ROTATION, udg_Camera_Rotation, 0.)
endfunction
function CameraLockStart takes real R returns nothing
local integer tm = GetStoredInteger(udg_GC, "CameraLock", "Timer")
if tm == 0 then
set tm = H2I(CreateTimer())
call StoreInteger(udg_GC, "CameraLock", "Timer", H2I(tm))
endif
call TimerStart(I2Tm(tm), R, true, function CameraLock_Func)
endfunction
function CameraLockForPlayer takes player P,camerasetup c returns nothing
if GetLocalPlayer() == P then
set udg_Camera_TargetDistance = CameraSetupGetField(c, CAMERA_FIELD_TARGET_DISTANCE)
set udg_Camera_AngleOfAttack = CameraSetupGetField(c, CAMERA_FIELD_ANGLE_OF_ATTACK)
set udg_Camera_Roll = CameraSetupGetField(c, CAMERA_FIELD_ROLL)
set udg_Camera_Rotation = CameraSetupGetField(c, CAMERA_FIELD_ROTATION)
endif
endfunction
[/codes] |
|