⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmd.java

📁 JAKE2用JAVA写的queck2的3D游戏开发引擎
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        }        it = GameItemList.itemlist[ent.client.pers.selected_item];        if (it.drop == null) {            SV_GAME.PF_cprintfhigh(ent, "Item is not dropable.\n");            return;        }        it.drop.drop(ent, it);    }    /**      * Cmd_Score_f     *      * Display the scoreboard.     *      */    public static void Score_f(edict_t ent) {        ent.client.showinventory = false;        ent.client.showhelp = false;        if (0 == GameBase.deathmatch.value && 0 == GameBase.coop.value)            return;        if (ent.client.showscores) {            ent.client.showscores = false;            return;        }        ent.client.showscores = true;        PlayerHud.DeathmatchScoreboard(ent);    }    /**     * Cmd_Help_f     *      * Display the current help message.      *     */    public static void Help_f(edict_t ent) {        // this is for backwards compatability        if (GameBase.deathmatch.value != 0) {            Score_f(ent);            return;        }        ent.client.showinventory = false;        ent.client.showscores = false;        if (ent.client.showhelp                && (ent.client.pers.game_helpchanged == GameBase.game.helpchanged)) {            ent.client.showhelp = false;            return;        }        ent.client.showhelp = true;        ent.client.pers.helpchanged = 0;        PlayerHud.HelpComputer(ent);    }    /**     * Cmd_Kill_f     */    public static void Kill_f(edict_t ent) {        if ((GameBase.level.time - ent.client.respawn_time) < 5)            return;        ent.flags &= ~Defines.FL_GODMODE;        ent.health = 0;        GameBase.meansOfDeath = Defines.MOD_SUICIDE;        PlayerClient.player_die.die(ent, ent, ent, 100000, Globals.vec3_origin);    }    /**     * Cmd_PutAway_f     */    public static void PutAway_f(edict_t ent) {        ent.client.showscores = false;        ent.client.showhelp = false;        ent.client.showinventory = false;    }    /**     * Cmd_Players_f     */    public static void Players_f(edict_t ent) {        int i;        int count;        String small;        String large;        Integer index[] = new Integer[256];        count = 0;        for (i = 0; i < GameBase.maxclients.value; i++) {            if (GameBase.game.clients[i].pers.connected) {                index[count] = new Integer(i);                count++;            }        }        // sort by frags        Arrays.sort(index, 0, count - 1, Cmd.PlayerSort);        // print information        large = "";        for (i = 0; i < count; i++) {            small = GameBase.game.clients[index[i].intValue()].ps.stats[Defines.STAT_FRAGS]                    + " "                    + GameBase.game.clients[index[i].intValue()].pers.netname                    + "\n";            if (small.length() + large.length() > 1024 - 100) {                // can't print all of them in one packet                large += "...\n";                break;            }            large += small;        }        SV_GAME.PF_cprintfhigh(ent, large + "\n" + count + " players\n");    }    /**     * Cmd_Wave_f     */    public static void Wave_f(edict_t ent) {        int i;        i = Lib.atoi(Cmd.Argv(1));        // can't wave when ducked        if ((ent.client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0)            return;        if (ent.client.anim_priority > Defines.ANIM_WAVE)            return;        ent.client.anim_priority = Defines.ANIM_WAVE;        switch (i) {        case 0:            SV_GAME.PF_cprintfhigh(ent, "flipoff\n");            ent.s.frame = M_Player.FRAME_flip01 - 1;            ent.client.anim_end = M_Player.FRAME_flip12;            break;        case 1:            SV_GAME.PF_cprintfhigh(ent, "salute\n");            ent.s.frame = M_Player.FRAME_salute01 - 1;            ent.client.anim_end = M_Player.FRAME_salute11;            break;        case 2:            SV_GAME.PF_cprintfhigh(ent, "taunt\n");            ent.s.frame = M_Player.FRAME_taunt01 - 1;            ent.client.anim_end = M_Player.FRAME_taunt17;            break;        case 3:            SV_GAME.PF_cprintfhigh(ent, "wave\n");            ent.s.frame = M_Player.FRAME_wave01 - 1;            ent.client.anim_end = M_Player.FRAME_wave11;            break;        case 4:        default:            SV_GAME.PF_cprintfhigh(ent, "point\n");            ent.s.frame = M_Player.FRAME_point01 - 1;            ent.client.anim_end = M_Player.FRAME_point12;            break;        }    }    /**     * Command to print the players own position.     */    public static void ShowPosition_f(edict_t ent) {        SV_GAME.PF_cprintfhigh(ent, "pos=" + Lib.vtofsbeaty(ent.s.origin) + "\n");    }    /**     * Cmd_Say_f     */    public static void Say_f(edict_t ent, boolean team, boolean arg0) {        int i, j;        edict_t other;        String text;        gclient_t cl;        if (Cmd.Argc() < 2 && !arg0)            return;        if (0 == ((int) (GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS)))            team = false;        if (team)            text = "(" + ent.client.pers.netname + "): ";        else            text = "" + ent.client.pers.netname + ": ";        if (arg0) {            text += Cmd.Argv(0);            text += " ";            text += Cmd.Args();        } else {            if (Cmd.Args().startsWith("\""))                text += Cmd.Args().substring(1, Cmd.Args().length() - 1);            else                text += Cmd.Args();        }        // don't let text be too long for malicious reasons        if (text.length() > 150)            //text[150] = 0;            text = text.substring(0, 150);        text += "\n";        if (GameBase.flood_msgs.value != 0) {            cl = ent.client;            if (GameBase.level.time < cl.flood_locktill) {                SV_GAME.PF_cprintfhigh(ent, "You can't talk for "                                        + (int) (cl.flood_locktill - GameBase.level.time)                                        + " more seconds\n");                return;            }            i = (int) (cl.flood_whenhead - GameBase.flood_msgs.value + 1);            if (i < 0)                i = (10) + i;            if (cl.flood_when[i] != 0                    && GameBase.level.time - cl.flood_when[i] < GameBase.flood_persecond.value) {                cl.flood_locktill = GameBase.level.time + GameBase.flood_waitdelay.value;                SV_GAME.PF_cprintf(ent, Defines.PRINT_CHAT,                        "Flood protection:  You can't talk for "                                + (int) GameBase.flood_waitdelay.value                                + " seconds.\n");                return;            }            cl.flood_whenhead = (cl.flood_whenhead + 1) % 10;            cl.flood_when[cl.flood_whenhead] = GameBase.level.time;        }        if (Globals.dedicated.value != 0)            SV_GAME.PF_cprintf(null, Defines.PRINT_CHAT, "" + text + "");        for (j = 1; j <= GameBase.game.maxclients; j++) {            other = GameBase.g_edicts[j];            if (!other.inuse)                continue;            if (other.client == null)                continue;            if (team) {                if (!GameUtil.OnSameTeam(ent, other))                    continue;            }            SV_GAME.PF_cprintf(other, Defines.PRINT_CHAT, "" + text + "");        }    }    /**     * Returns the playerlist. TODO: The list is badly formatted at the moment.     */    public static void PlayerList_f(edict_t ent) {        int i;        String st;        String text;        edict_t e2;        // connect time, ping, score, name        text = "";        for (i = 0; i < GameBase.maxclients.value; i++) {            e2 = GameBase.g_edicts[1 + i];            if (!e2.inuse)                continue;            st = ""                    + (GameBase.level.framenum - e2.client.resp.enterframe)                    / 600                    + ":"                    + ((GameBase.level.framenum - e2.client.resp.enterframe) % 600)                    / 10 + " " + e2.client.ping + " " + e2.client.resp.score                    + " " + e2.client.pers.netname + " "                    + (e2.client.resp.spectator ? " (spectator)" : "") + "\n";            if (text.length() + st.length() > 1024 - 50) {                text += "And more...\n";                SV_GAME.PF_cprintfhigh(ent, "" + text + "");                return;            }            text += st;        }        SV_GAME.PF_cprintfhigh(ent, text);    }    /**     * Adds the current command line as a clc_stringcmd to the client message.     * things like godmode, noclip, etc, are commands directed to the server, so     * when they are typed in at the console, they will need to be forwarded.     */    public static void ForwardToServer() {        String cmd;        cmd = Cmd.Argv(0);        if (Globals.cls.state <= Defines.ca_connected || cmd.charAt(0) == '-'                || cmd.charAt(0) == '+') {            Com.Printf("Unknown command \"" + cmd + "\"\n");            return;        }        MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);        SZ.Print(Globals.cls.netchan.message, cmd);        if (Cmd.Argc() > 1) {            SZ.Print(Globals.cls.netchan.message, " ");            SZ.Print(Globals.cls.netchan.message, Cmd.Args());        }    }    /**     * Cmd_CompleteCommand.     */    public static Vector CompleteCommand(String partial) {        Vector cmds = new Vector();        // check for match        for (cmd_function_t cmd = cmd_functions; cmd != null; cmd = cmd.next)            if (cmd.name.startsWith(partial))                cmds.add(cmd.name);        for (cmdalias_t a = Globals.cmd_alias; a != null; a = a.next)            if (a.name.startsWith(partial))                cmds.add(a.name);        return cmds;    }    /**     * Processes the commands the player enters in the quake console.     */    public static void ClientCommand(edict_t ent) {        String cmd;            if (ent.client == null)            return; // not fully in game yet            cmd = GameBase.gi.argv(0).toLowerCase();            if (cmd.equals("players")) {            Players_f(ent);            return;        }        if (cmd.equals("say")) {            Say_f(ent, false, false);            return;        }        if (cmd.equals("say_team")) {            Say_f(ent, true, false);            return;        }        if (cmd.equals("score")) {            Score_f(ent);            return;        }        if (cmd.equals("help")) {            Help_f(ent);            return;        }            if (GameBase.level.intermissiontime != 0)            return;            if (cmd.equals("use"))            Use_f(ent);        else if (cmd.equals("drop"))            Drop_f(ent);        else if (cmd.equals("give"))            Give_f(ent);        else if (cmd.equals("god"))            God_f(ent);        else if (cmd.equals("notarget"))            Notarget_f(ent);        else if (cmd.equals("noclip"))            Noclip_f(ent);        else if (cmd.equals("inven"))            Inven_f(ent);        else if (cmd.equals("invnext"))            GameItems.SelectNextItem(ent, -1);        else if (cmd.equals("invprev"))            GameItems.SelectPrevItem(ent, -1);        else if (cmd.equals("invnextw"))            GameItems.SelectNextItem(ent, Defines.IT_WEAPON);        else if (cmd.equals("invprevw"))            GameItems.SelectPrevItem(ent, Defines.IT_WEAPON);        else if (cmd.equals("invnextp"))            GameItems.SelectNextItem(ent, Defines.IT_POWERUP);        else if (cmd.equals("invprevp"))            GameItems.SelectPrevItem(ent, Defines.IT_POWERUP);        else if (cmd.equals("invuse"))            InvUse_f(ent);        else if (cmd.equals("invdrop"))            InvDrop_f(ent);        else if (cmd.equals("weapprev"))            WeapPrev_f(ent);        else if (cmd.equals("weapnext"))            WeapNext_f(ent);        else if (cmd.equals("weaplast"))            WeapLast_f(ent);        else if (cmd.equals("kill"))            Kill_f(ent);        else if (cmd.equals("putaway"))            PutAway_f(ent);        else if (cmd.equals("wave"))            Wave_f(ent);        else if (cmd.equals("playerlist"))            PlayerList_f(ent);        else if (cmd.equals("showposition"))            ShowPosition_f(ent);        else            // anything that doesn't match a command will be a chat            Say_f(ent, false, true);    }    public static void ValidateSelectedItem(edict_t ent) {    	        gclient_t cl = ent.client;            if (cl.pers.inventory[cl.pers.selected_item] != 0)            return; // valid            GameItems.SelectNextItem(ent, -1);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -