added some constants to common.lua so you can tweak the player physics

This commit is contained in:
Ben Russell (300178622) 2013-06-20 11:39:17 +12:00
parent 052088604f
commit 162fcea1ce
2 changed files with 29 additions and 16 deletions

View File

@ -60,6 +60,19 @@ MODE_AUTOCLIMB = true
MODE_AIRJUMP = false MODE_AIRJUMP = false
MODE_SOFTCROUCH = true MODE_SOFTCROUCH = true
MODE_JUMP_SPEED = 7.0
MODE_GRAVITY = 9.81
MODE_PSPEED_NORMAL = 7.0
MODE_PSPEED_FLYMODE = 20.0
MODE_PSPEED_CHANGE = 5.0
MODE_PSPEED_AIRSLOW = 0.3
MODE_PSPEED_AIRSLOW_CHANGE = 0.3
MODE_PSPEED_WATER = 0.6
MODE_PSPEED_CROUCH = 0.5
MODE_PSPEED_SNEAK = 0.5
MODE_PSPEED_SPADE = 1.25
MODE_NADE_SPEED = 30.0 MODE_NADE_SPEED = 30.0
MODE_NADE_STEP = 0.1 MODE_NADE_STEP = 0.1
MODE_NADE_FUSE = 3.0 MODE_NADE_FUSE = 3.0

View File

@ -962,7 +962,7 @@ function new_player(settings)
this.crouching = true this.crouching = true
end end
if this.ev_jump and this.alive and (MODE_CHEAT_FLY or this.grounded) then if this.ev_jump and this.alive and (MODE_CHEAT_FLY or this.grounded) then
this.vy = -7 this.vy = -MODE_JUMP_SPEED
this.ev_jump = false this.ev_jump = false
if client then if client then
client.wav_play_global(wav_jump_up, this.x, this.y, this.z) client.wav_play_global(wav_jump_up, this.x, this.y, this.z)
@ -985,14 +985,14 @@ function new_player(settings)
-- apply tool speedup -- apply tool speedup
if this.mode == PLM_NORMAL and (this.tool == TOOL_SPADE or this.tool == TOOL_BLOCK) then if this.mode == PLM_NORMAL and (this.tool == TOOL_SPADE or this.tool == TOOL_BLOCK) then
mvx = mvx * 1.25 mvx = mvx * MODE_PSPEED_SPADE
mvz = mvz * 1.25 mvz = mvz * MODE_PSPEED_SPADE
end end
-- apply base slowdown -- apply base slowdown
local mvspd = 7.0 local mvspd = MODE_PSPEED_NORMAL
local mvchange = 5.0 local mvchange = MODE_PSPEED_CHANGE
if this.mode ~= PLM_NORMAL then mvspd = 20.0 end if this.mode ~= PLM_NORMAL then mvspd = MODE_PSPEED_FLYMODE end
mvx = mvx * mvspd mvx = mvx * mvspd
mvy = mvy * mvspd mvy = mvy * mvspd
mvz = mvz * mvspd mvz = mvz * mvspd
@ -1000,21 +1000,21 @@ function new_player(settings)
-- apply extra slowdowns -- apply extra slowdowns
if this.mode == PLM_NORMAL then if this.mode == PLM_NORMAL then
if not this.grounded then if not this.grounded then
mvx = mvx * 0.3 mvx = mvx * MODE_PSPEED_AIRSLOW
mvz = mvz * 0.3 mvz = mvz * MODE_PSPEED_AIRSLOW
mvchange = mvchange * 0.3 mvchange = mvchange * MODE_PSPEED_AIRSLOW_CHANGE
end end
if inwater then if inwater then
mvx = mvx * 0.6 mvx = mvx * MODE_PSPEED_WATER
mvz = mvz * 0.6 mvz = mvz * MODE_PSPEED_WATER
end end
if this.crouching then if this.crouching then
mvx = mvx * 0.5 mvx = mvx * MODE_PSPEED_CROUCH
mvz = mvz * 0.5 mvz = mvz * MODE_PSPEED_CROUCH
end end
if this.zooming or this.ev_sneak then if this.zooming or this.ev_sneak then
mvx = mvx * 0.5 mvx = mvx * MODE_PSPEED_SNEAK
mvz = mvz * 0.5 mvz = mvz * MODE_PSPEED_SNEAK
end end
end end
@ -1024,7 +1024,7 @@ function new_player(settings)
this.vx = this.vx + (mvx - this.vx)*(1.0-math.exp(-sec_delta*mvchange)) this.vx = this.vx + (mvx - this.vx)*(1.0-math.exp(-sec_delta*mvchange))
this.vz = this.vz + (mvz - this.vz)*(1.0-math.exp(-sec_delta*mvchange)) this.vz = this.vz + (mvz - this.vz)*(1.0-math.exp(-sec_delta*mvchange))
if this.mode == PLM_NORMAL then if this.mode == PLM_NORMAL then
this.vy = this.vy + 2*9.81*sec_delta this.vy = this.vy + 2*MODE_GRAVITY*sec_delta
else else
this.vy = this.vy + (mvy - this.vy)*(1.0-math.exp(-sec_delta*mvchange)) this.vy = this.vy + (mvy - this.vy)*(1.0-math.exp(-sec_delta*mvchange))
end end