📄 cl_tent.java
字号:
float hand_multiplier; frame_t oldframe; player_state_t ps, ops; // PMM if (Globals.hand != null) { if (Globals.hand.value == 2) hand_multiplier = 0; else if (Globals.hand.value == 1) hand_multiplier = -1; else hand_multiplier = 1; } else { hand_multiplier = 1; } // PMM // update beams beam_t[] b = cl_playerbeams; for (int i = 0; i < MAX_BEAMS; i++) { if (b[i].model == null || b[i].endtime < Globals.cl.time) continue; if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam)) { // if coming from the player, update the start position if (b[i].entity == Globals.cl.playernum + 1) // entity 0 is the // world { // set up gun position // code straight out of CL_AddViewWeapon ps = Globals.cl.frame.playerstate; int j = (Globals.cl.frame.serverframe - 1) & Defines.UPDATE_MASK; oldframe = Globals.cl.frames[j]; if (oldframe.serverframe != Globals.cl.frame.serverframe - 1 || !oldframe.valid) oldframe = Globals.cl.frame; // previous frame was // dropped or involid ops = oldframe.playerstate; for (j = 0; j < 3; j++) { b[i].start[j] = Globals.cl.refdef.vieworg[j] + ops.gunoffset[j] + Globals.cl.lerpfrac * (ps.gunoffset[j] - ops.gunoffset[j]); } Math3D.VectorMA(b[i].start, (hand_multiplier * b[i].offset[0]), Globals.cl.v_right, org); Math3D.VectorMA(org, b[i].offset[1], Globals.cl.v_forward, org); Math3D.VectorMA(org, b[i].offset[2], Globals.cl.v_up, org); if ((Globals.hand != null) && (Globals.hand.value == 2)) { Math3D.VectorMA(org, -1, Globals.cl.v_up, org); } // FIXME - take these out when final Math3D.VectorCopy(Globals.cl.v_right, r); Math3D.VectorCopy(Globals.cl.v_forward, f); Math3D.VectorCopy(Globals.cl.v_up, u); } else Math3D.VectorCopy(b[i].start, org); } else { // if coming from the player, update the start position if (b[i].entity == Globals.cl.playernum + 1) // entity 0 is the // world { Math3D.VectorCopy(Globals.cl.refdef.vieworg, b[i].start); b[i].start[2] -= 22; // adjust for view height } Math3D.VectorAdd(b[i].start, b[i].offset, org); } // calculate pitch and yaw Math3D.VectorSubtract(b[i].end, org, dist); // PMM if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam) && (b[i].entity == Globals.cl.playernum + 1)) { len = Math3D.VectorLength(dist); Math3D.VectorScale(f, len, dist); Math3D.VectorMA(dist, (hand_multiplier * b[i].offset[0]), r, dist); Math3D.VectorMA(dist, b[i].offset[1], f, dist); Math3D.VectorMA(dist, b[i].offset[2], u, dist); if ((Globals.hand != null) && (Globals.hand.value == 2)) { Math3D.VectorMA(org, -1, Globals.cl.v_up, org); } } // PMM if (dist[1] == 0 && dist[0] == 0) { yaw = 0; if (dist[2] > 0) pitch = 90; else pitch = 270; } else { // PMM - fixed to correct for pitch of 0 if (dist[0] != 0.0f) yaw = (float) (Math.atan2(dist[1], dist[0]) * 180 / Math.PI); else if (dist[1] > 0) yaw = 90; else yaw = 270; if (yaw < 0) yaw += 360; forward = (float) Math.sqrt(dist[0] * dist[0] + dist[1] * dist[1]); pitch = (float) (Math.atan2(dist[2], forward) * -180.0 / Math.PI); if (pitch < 0) pitch += 360.0; } if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam)) { if (b[i].entity != Globals.cl.playernum + 1) { framenum = 2; // Com_Printf ("Third person\n"); ent.angles[0] = -pitch; ent.angles[1] = yaw + 180.0f; ent.angles[2] = 0; // Com_Printf ("%f %f - %f %f %f\n", -pitch, yaw+180.0, // b[i].offset[0], b[i].offset[1], b[i].offset[2]); Math3D.AngleVectors(ent.angles, f, r, u); // if it's a non-origin offset, it's a player, so use the // hardcoded player offset if (!Math3D.VectorEquals(b[i].offset, Globals.vec3_origin)) { Math3D.VectorMA(org, -(b[i].offset[0]) + 1, r, org); Math3D.VectorMA(org, -(b[i].offset[1]), f, org); Math3D.VectorMA(org, -(b[i].offset[2]) - 10, u, org); } else { // if it's a monster, do the particle effect CL_newfx.MonsterPlasma_Shell(b[i].start); } } else { framenum = 1; } } // if it's the heatbeam, draw the particle effect if ((cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam) && (b[i].entity == Globals.cl.playernum + 1))) { CL_newfx.Heatbeam(org, dist); } // add new entities for the beams d = Math3D.VectorNormalize(dist); //memset (&ent, 0, sizeof(ent)); ent.clear(); if (b[i].model == cl_mod_heatbeam) { model_length = 32.0f; } else if (b[i].model == cl_mod_lightning) { model_length = 35.0f; d -= 20.0; // correction so it doesn't end in middle of tesla } else { model_length = 30.0f; } steps = (float) Math.ceil(d / model_length); len = (d - model_length) / (steps - 1); // PMM - special case for lightning model .. if the real length is // shorter than the model, // flip it around & draw it from the end to the start. This prevents // the model from going // through the tesla mine (instead it goes through the target) if ((b[i].model == cl_mod_lightning) && (d <= model_length)) { // Com_Printf ("special case\n"); Math3D.VectorCopy(b[i].end, ent.origin); // offset to push beam outside of tesla model (negative because // dist is from end to start // for this beam) // for (j=0 ; j<3 ; j++) // ent.origin[j] -= dist[j]*10.0; ent.model = b[i].model; ent.flags = Defines.RF_FULLBRIGHT; ent.angles[0] = pitch; ent.angles[1] = yaw; ent.angles[2] = Lib.rand() % 360; V.AddEntity(ent); return; } while (d > 0) { Math3D.VectorCopy(org, ent.origin); ent.model = b[i].model; if (cl_mod_heatbeam != null && (b[i].model == cl_mod_heatbeam)) { // ent.flags = RF_FULLBRIGHT|RF_TRANSLUCENT; // ent.alpha = 0.3; ent.flags = Defines.RF_FULLBRIGHT; ent.angles[0] = -pitch; ent.angles[1] = yaw + 180.0f; ent.angles[2] = (Globals.cl.time) % 360; // ent.angles[2] = rand()%360; ent.frame = framenum; } else if (b[i].model == cl_mod_lightning) { ent.flags = Defines.RF_FULLBRIGHT; ent.angles[0] = -pitch; ent.angles[1] = yaw + 180.0f; ent.angles[2] = Lib.rand() % 360; } else { ent.angles[0] = pitch; ent.angles[1] = yaw; ent.angles[2] = Lib.rand() % 360; } // Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity); V.AddEntity(ent); for (int j = 0; j < 3; j++) org[j] += dist[j] * len; d -= model_length; } } } /* * ================= CL_AddExplosions ================= */ static void AddExplosions() { entity_t ent; int i; explosion_t[] ex; float frac; int f; //memset (&ent, 0, sizeof(ent)); Pointer! ent = null; ex = cl_explosions; for (i = 0; i < MAX_EXPLOSIONS; i++) { if (ex[i].type == ex_free) continue; frac = (Globals.cl.time - ex[i].start) / 100.0f; f = (int) Math.floor(frac); ent = ex[i].ent; switch (ex[i].type) { case ex_mflash: if (f >= ex[i].frames - 1) ex[i].type = ex_free; break; case ex_misc: if (f >= ex[i].frames - 1) { ex[i].type = ex_free; break; } ent.alpha = 1.0f - frac / (ex[i].frames - 1); break; case ex_flash: if (f >= 1) { ex[i].type = ex_free; break; } ent.alpha = 1.0f; break; case ex_poly: if (f >= ex[i].frames - 1) { ex[i].type = ex_free; break; } ent.alpha = (16.0f - (float) f) / 16.0f; if (f < 10) { ent.skinnum = (f >> 1); if (ent.skinnum < 0) ent.skinnum = 0; } else { ent.flags |= Defines.RF_TRANSLUCENT; if (f < 13) ent.skinnum = 5; else ent.skinnum = 6; } break; case ex_poly2: if (f >= ex[i].frames - 1) { ex[i].type = ex_free; break; } ent.alpha = (5.0f - (float) f) / 5.0f; ent.skinnum = 0; ent.flags |= Defines.RF_TRANSLUCENT; break; } if (ex[i].type == ex_free) continue; if (ex[i].light != 0.0f) { V.AddLight(ent.origin, ex[i].light * ent.alpha, ex[i].lightcolor[0], ex[i].lightcolor[1], ex[i].lightcolor[2]); } Math3D.VectorCopy(ent.origin, ent.oldorigin); if (f < 0) f = 0; ent.frame = ex[i].baseframe + f + 1; ent.oldframe = ex[i].baseframe + f; ent.backlerp = 1.0f - Globals.cl.lerpfrac; V.AddEntity(ent); } } /* * ================= CL_AddLasers ================= */ static void AddLasers() { laser_t[] l; int i; l = cl_lasers; for (i = 0; i < MAX_LASERS; i++) { if (l[i].endtime >= Globals.cl.time) V.AddEntity(l[i].ent); } } /* PMM - CL_Sustains */ static void ProcessSustain() { cl_sustain_t[] s; int i; s = cl_sustains; for (i = 0; i < MAX_SUSTAINS; i++) { if (s[i].id != 0) if ((s[i].endtime >= Globals.cl.time) && (Globals.cl.time >= s[i].nextthink)) { s[i].think.think(s[i]); } else if (s[i].endtime < Globals.cl.time) s[i].id = 0; } } /* * ================= CL_AddTEnts ================= */ static void AddTEnts() { AddBeams(); // PMM - draw plasma beams AddPlayerBeams(); AddExplosions(); AddLasers(); // PMM - set up sustain ProcessSustain(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -