📄 playerhud.java
字号:
/* * Copyright (C) 1997-2001 Id Software, Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. * */// Created on 28.12.2003 by RST.// $Id: PlayerHud.java,v 1.9 2005/11/20 22:18:33 salomo Exp $package jake2.game;import jake2.*;import jake2.client.*;import jake2.qcommon.*;import jake2.render.*;import jake2.server.*;import jake2.util.Lib;import jake2.util.Math3D;import jake2.util.Vargs;public class PlayerHud { /* * ====================================================================== * * INTERMISSION * * ====================================================================== */ public static void MoveClientToIntermission(edict_t ent) { if (GameBase.deathmatch.value != 0 || GameBase.coop.value != 0) ent.client.showscores = true; Math3D.VectorCopy(GameBase.level.intermission_origin, ent.s.origin); ent.client.ps.pmove.origin[0] = (short) (GameBase.level.intermission_origin[0] * 8); ent.client.ps.pmove.origin[1] = (short) (GameBase.level.intermission_origin[1] * 8); ent.client.ps.pmove.origin[2] = (short) (GameBase.level.intermission_origin[2] * 8); Math3D.VectorCopy(GameBase.level.intermission_angle, ent.client.ps.viewangles); ent.client.ps.pmove.pm_type = Defines.PM_FREEZE; ent.client.ps.gunindex = 0; ent.client.ps.blend[3] = 0; ent.client.ps.rdflags &= ~Defines.RDF_UNDERWATER; // clean up powerup info ent.client.quad_framenum = 0; ent.client.invincible_framenum = 0; ent.client.breather_framenum = 0; ent.client.enviro_framenum = 0; ent.client.grenade_blew_up = false; ent.client.grenade_time = 0; ent.viewheight = 0; ent.s.modelindex = 0; ent.s.modelindex2 = 0; ent.s.modelindex3 = 0; ent.s.modelindex = 0; ent.s.effects = 0; ent.s.sound = 0; ent.solid = Defines.SOLID_NOT; // add the layout if (GameBase.deathmatch.value != 0 || GameBase.coop.value != 0) { DeathmatchScoreboardMessage(ent, null); GameBase.gi.unicast(ent, true); } } public static void BeginIntermission(edict_t targ) { int i, n; edict_t ent, client; if (GameBase.level.intermissiontime != 0) return; // already activated GameBase.game.autosaved = false; // respawn any dead clients for (i = 0; i < GameBase.maxclients.value; i++) { client = GameBase.g_edicts[1 + i]; if (!client.inuse) continue; if (client.health <= 0) PlayerClient.respawn(client); } GameBase.level.intermissiontime = GameBase.level.time; GameBase.level.changemap = targ.map; if (GameBase.level.changemap.indexOf('*') > -1) { if (GameBase.coop.value != 0) { for (i = 0; i < GameBase.maxclients.value; i++) { client = GameBase.g_edicts[1 + i]; if (!client.inuse) continue; // strip players of all keys between units for (n = 1; n < GameItemList.itemlist.length; n++) { // null pointer exception fixed. (RST) if (GameItemList.itemlist[n] != null) if ((GameItemList.itemlist[n].flags & Defines.IT_KEY) != 0) client.client.pers.inventory[n] = 0; } } } } else { if (0 == GameBase.deathmatch.value) { GameBase.level.exitintermission = true; // go immediately to the // next level return; } } GameBase.level.exitintermission = false; // find an intermission spot ent = GameBase.G_FindEdict(null, GameBase.findByClass, "info_player_intermission"); if (ent == null) { // the map creator forgot to put in an intermission // point... ent = GameBase.G_FindEdict(null, GameBase.findByClass, "info_player_start"); if (ent == null) ent = GameBase.G_FindEdict(null, GameBase.findByClass, "info_player_deathmatch"); } else { // chose one of four spots i = Lib.rand() & 3; EdictIterator es = null; while (i-- > 0) { es = GameBase.G_Find(es, GameBase.findByClass, "info_player_intermission"); if (es == null) // wrap around the list continue; ent = es.o; } } Math3D.VectorCopy(ent.s.origin, GameBase.level.intermission_origin); Math3D.VectorCopy(ent.s.angles, GameBase.level.intermission_angle); // move all clients to the intermission point for (i = 0; i < GameBase.maxclients.value; i++) { client = GameBase.g_edicts[1 + i]; if (!client.inuse) continue; MoveClientToIntermission(client); } } /* * ================== * DeathmatchScoreboardMessage * ================== */ public static void DeathmatchScoreboardMessage(edict_t ent, edict_t killer) { StringBuffer string = new StringBuffer(1400); int stringlength; int i, j, k; int sorted[] = new int[Defines.MAX_CLIENTS]; int sortedscores[] = new int[Defines.MAX_CLIENTS]; int score, total; int picnum; int x, y; gclient_t cl; edict_t cl_ent; String tag; // sort the clients by score total = 0; for (i = 0; i < GameBase.game.maxclients; i++) { cl_ent = GameBase.g_edicts[1 + i]; if (!cl_ent.inuse || GameBase.game.clients[i].resp.spectator) continue; score = GameBase.game.clients[i].resp.score; for (j = 0; j < total; j++) { if (score > sortedscores[j]) break; } for (k = total; k > j; k--) { sorted[k] = sorted[k - 1]; sortedscores[k] = sortedscores[k - 1]; } sorted[j] = i; sortedscores[j] = score; total++; } // print level name and exit rules // add the clients in sorted order if (total > 12) total = 12; for (i = 0; i < total; i++) { cl = GameBase.game.clients[sorted[i]]; cl_ent = GameBase.g_edicts[1 + sorted[i]]; picnum = GameBase.gi.imageindex("i_fixme"); x = (i >= 6) ? 160 : 0; y = 32 + 32 * (i % 6); // add a dogtag if (cl_ent == ent) tag = "tag1"; else if (cl_ent == killer) tag = "tag2"; else tag = null; if (tag != null) { string.append("xv ").append(x + 32).append(" yv ").append(y) .append(" picn ").append(tag); } // send the layout string .append(" client ") .append(x) .append(" ") .append(y) .append(" ") .append(sorted[i]) .append(" ") .append(cl.resp.score) .append(" ") .append(cl.ping) .append(" ") .append( (GameBase.level.framenum - cl.resp.enterframe) / 600); } GameBase.gi.WriteByte(Defines.svc_layout); GameBase.gi.WriteString(string.toString()); } /* * ================== * DeathmatchScoreboard * * Draw instead of help message. Note that it isn't that hard to overflow * the 1400 byte message limit! * ================== */ public static void DeathmatchScoreboard(edict_t ent) { DeathmatchScoreboardMessage(ent, ent.enemy); GameBase.gi.unicast(ent, true); } /* * ================== * Cmd_Score_f * * Display the scoreboard
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -