📄 pmove.java
字号:
else if (pm.cmd.upmove > 0) wishvel[2] = 200; else if (pm.cmd.upmove < 0) wishvel[2] = -200; else wishvel[2] = 0; // limit horizontal speed when on a ladder if (wishvel[0] < -25) wishvel[0] = -25; else if (wishvel[0] > 25) wishvel[0] = 25; if (wishvel[1] < -25) wishvel[1] = -25; else if (wishvel[1] > 25) wishvel[1] = 25; } // add water currents if ((pm.watertype & Defines.MASK_CURRENT) != 0) { Math3D.VectorClear(v); if ((pm.watertype & Defines.CONTENTS_CURRENT_0) != 0) v[0] += 1; if ((pm.watertype & Defines.CONTENTS_CURRENT_90) != 0) v[1] += 1; if ((pm.watertype & Defines.CONTENTS_CURRENT_180) != 0) v[0] -= 1; if ((pm.watertype & Defines.CONTENTS_CURRENT_270) != 0) v[1] -= 1; if ((pm.watertype & Defines.CONTENTS_CURRENT_UP) != 0) v[2] += 1; if ((pm.watertype & Defines.CONTENTS_CURRENT_DOWN) != 0) v[2] -= 1; s = pm_waterspeed; if ((pm.waterlevel == 1) && (pm.groundentity != null)) s /= 2; Math3D.VectorMA(wishvel, s, v, wishvel); } // add conveyor belt velocities if (pm.groundentity != null) { Math3D.VectorClear(v); if ((pml.groundcontents & Defines.CONTENTS_CURRENT_0) != 0) v[0] += 1; if ((pml.groundcontents & Defines.CONTENTS_CURRENT_90) != 0) v[1] += 1; if ((pml.groundcontents & Defines.CONTENTS_CURRENT_180) != 0) v[0] -= 1; if ((pml.groundcontents & Defines.CONTENTS_CURRENT_270) != 0) v[1] -= 1; if ((pml.groundcontents & Defines.CONTENTS_CURRENT_UP) != 0) v[2] += 1; if ((pml.groundcontents & Defines.CONTENTS_CURRENT_DOWN) != 0) v[2] -= 1; Math3D.VectorMA(wishvel, 100 /* pm.groundentity.speed */, v, wishvel); } } /** * PM_WaterMove. */ public static void PM_WaterMove() { int i; float[] wishvel = { 0, 0, 0 }; float wishspeed; float[] wishdir = { 0, 0, 0 }; // user intentions for (i = 0; i < 3; i++) wishvel[i] = pml.forward[i] * pm.cmd.forwardmove + pml.right[i] * pm.cmd.sidemove; if (0 == pm.cmd.forwardmove && 0 == pm.cmd.sidemove && 0 == pm.cmd.upmove) wishvel[2] -= 60; // drift towards bottom else wishvel[2] += pm.cmd.upmove; PM_AddCurrents(wishvel); Math3D.VectorCopy(wishvel, wishdir); wishspeed = Math3D.VectorNormalize(wishdir); if (wishspeed > pm_maxspeed) { Math3D.VectorScale(wishvel, pm_maxspeed / wishspeed, wishvel); wishspeed = pm_maxspeed; } wishspeed *= 0.5; PM_Accelerate(wishdir, wishspeed, pm_wateraccelerate); PM_StepSlideMove(); } /** * PM_AirMove. */ public static void PM_AirMove() { float[] wishvel = { 0, 0, 0 }; float fmove, smove; float[] wishdir = { 0, 0, 0 }; float wishspeed; float maxspeed; fmove = pm.cmd.forwardmove; smove = pm.cmd.sidemove; wishvel[0] = pml.forward[0] * fmove + pml.right[0] * smove; wishvel[1] = pml.forward[1] * fmove + pml.right[1] * smove; wishvel[2] = 0; PM_AddCurrents(wishvel); Math3D.VectorCopy(wishvel, wishdir); wishspeed = Math3D.VectorNormalize(wishdir); // clamp to server defined max speed maxspeed = (pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0 ? pm_duckspeed : pm_maxspeed; if (wishspeed > maxspeed) { Math3D.VectorScale(wishvel, maxspeed / wishspeed, wishvel); wishspeed = maxspeed; } if (pml.ladder) { PM_Accelerate(wishdir, wishspeed, pm_accelerate); if (0 == wishvel[2]) { if (pml.velocity[2] > 0) { pml.velocity[2] -= pm.s.gravity * pml.frametime; if (pml.velocity[2] < 0) pml.velocity[2] = 0; } else { pml.velocity[2] += pm.s.gravity * pml.frametime; if (pml.velocity[2] > 0) pml.velocity[2] = 0; } } PM_StepSlideMove(); } else if (pm.groundentity != null) { // walking on ground pml.velocity[2] = 0; //!!! this is before the accel PM_Accelerate(wishdir, wishspeed, pm_accelerate); // PGM -- fix for negative trigger_gravity fields // pml.velocity[2] = 0; if (pm.s.gravity > 0) pml.velocity[2] = 0; else pml.velocity[2] -= pm.s.gravity * pml.frametime; // PGM if (0 == pml.velocity[0] && 0 == pml.velocity[1]) return; PM_StepSlideMove(); } else { // not on ground, so little effect on velocity if (pm_airaccelerate != 0) PM_AirAccelerate(wishdir, wishspeed, pm_accelerate); else PM_Accelerate(wishdir, wishspeed, 1); // add gravity pml.velocity[2] -= pm.s.gravity * pml.frametime; PM_StepSlideMove(); } } /** * PM_CatagorizePosition. */ public static void PM_CatagorizePosition() { float[] point = { 0, 0, 0 }; int cont; trace_t trace; int sample1; int sample2; // if the player hull point one unit down is solid, the player // is on ground // see if standing on something solid point[0] = pml.origin[0]; point[1] = pml.origin[1]; point[2] = pml.origin[2] - 0.25f; if (pml.velocity[2] > 180) //!!ZOID changed from 100 to 180 (ramp // accel) { pm.s.pm_flags &= ~pmove_t.PMF_ON_GROUND; pm.groundentity = null; } else { trace = pm.trace.trace(pml.origin, pm.mins, pm.maxs, point); pml.groundsurface = trace.surface; pml.groundcontents = trace.contents; if (null == trace.ent || (trace.plane.normal[2] < 0.7 && !trace.startsolid)) { pm.groundentity = null; pm.s.pm_flags &= ~pmove_t.PMF_ON_GROUND; } else { pm.groundentity = trace.ent; // hitting solid ground will end a waterjump if ((pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0) { pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT); pm.s.pm_time = 0; } if (0 == (pm.s.pm_flags & pmove_t.PMF_ON_GROUND)) { // just hit the ground pm.s.pm_flags |= pmove_t.PMF_ON_GROUND; // don't do landing time if we were just going down a slope if (pml.velocity[2] < -200) { pm.s.pm_flags |= pmove_t.PMF_TIME_LAND; // don't allow another jump for a little while if (pml.velocity[2] < -400) pm.s.pm_time = 25; else pm.s.pm_time = 18; } } } if (pm.numtouch < Defines.MAXTOUCH && trace.ent != null) { pm.touchents[pm.numtouch] = trace.ent; pm.numtouch++; } } // get waterlevel, accounting for ducking pm.waterlevel = 0; pm.watertype = 0; sample2 = (int) (pm.viewheight - pm.mins[2]); sample1 = sample2 / 2; point[2] = pml.origin[2] + pm.mins[2] + 1; cont = pm.pointcontents.pointcontents(point); if ((cont & Defines.MASK_WATER) != 0) { pm.watertype = cont; pm.waterlevel = 1; point[2] = pml.origin[2] + pm.mins[2] + sample1; cont = pm.pointcontents.pointcontents(point); if ((cont & Defines.MASK_WATER) != 0) { pm.waterlevel = 2; point[2] = pml.origin[2] + pm.mins[2] + sample2; cont = pm.pointcontents.pointcontents(point); if ((cont & Defines.MASK_WATER) != 0) pm.waterlevel = 3; } } } /** * PM_CheckJump. */ public static void PM_CheckJump() { if ((pm.s.pm_flags & pmove_t.PMF_TIME_LAND) != 0) { // hasn't been long enough since landing to jump again return; } if (pm.cmd.upmove < 10) { // not holding jump pm.s.pm_flags &= ~pmove_t.PMF_JUMP_HELD; return; } // must wait for jump to be released if ((pm.s.pm_flags & pmove_t.PMF_JUMP_HELD) != 0) return; if (pm.s.pm_type == Defines.PM_DEAD) return; if (pm.waterlevel >= 2) { // swimming, not jumping pm.groundentity = null; if (pml.velocity[2] <= -300) return; if (pm.watertype == Defines.CONTENTS_WATER) pml.velocity[2] = 100; else if (pm.watertype == Defines.CONTENTS_SLIME) pml.velocity[2] = 80; else pml.velocity[2] = 50; return; } if (pm.groundentity == null) return; // in air, so no effect pm.s.pm_flags |= pmove_t.PMF_JUMP_HELD; pm.groundentity = null; pml.velocity[2] += 270; if (pml.velocity[2] < 270) pml.velocity[2] = 270; } /** * PM_CheckSpecialMovement. */ public static void PM_CheckSpecialMovement() { float[] spot = { 0, 0, 0 }; int cont; float[] flatforward = { 0, 0, 0 }; trace_t trace; if (pm.s.pm_time != 0) return; pml.ladder = false; // check for ladder flatforward[0] = pml.forward[0]; flatforward[1] = pml.forward[1]; flatforward[2] = 0; Math3D.VectorNormalize(flatforward); Math3D.VectorMA(pml.origin, 1, flatforward, spot); trace = pm.trace.trace(pml.origin, pm.mins, pm.maxs, spot); if ((trace.fraction < 1) && (trace.contents & Defines.CONTENTS_LADDER) != 0) pml.ladder = true; // check for water jump if (pm.waterlevel != 2) return; Math3D.VectorMA(pml.origin, 30, flatforward, spot); spot[2] += 4; cont = pm.pointcontents.pointcontents(spot); if (0 == (cont & Defines.CONTENTS_SOLID)) return; spot[2] += 16; cont = pm.pointcontents.pointcontents(spot); if (cont != 0) return; // jump out of water Math3D.VectorScale(flatforward, 50, pml.velocity); pml.velocity[2] = 350; pm.s.pm_flags |= pmove_t.PMF_TIME_WATERJUMP; pm.s.pm_time = -1; // was 255 } /** * PM_FlyMove. */ public static void PM_FlyMove(boolean doclip) { float speed, drop, friction, control, newspeed; float currentspeed, addspeed, accelspeed; int i; float[] wishvel = { 0, 0, 0 }; float fmove, smove; float[] wishdir = { 0, 0, 0 }; float wishspeed;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -