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

📄 gamespawn.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            // styles 32-62 are assigned by the light program for switchable            // lights            // 63 testing            GameBase.gi.configstring(Defines.CS_LIGHTS + 63, "a");            return true;        }    };    /**      * ED_NewString.     */    static String ED_NewString(String string) {        int l = string.length();        StringBuffer newb = new StringBuffer(l);        for (int i = 0; i < l; i++) {            char c = string.charAt(i);            if (c == '\\' && i < l - 1) {                c = string.charAt(++i);                if (c == 'n')                    newb.append('\n');                else                    newb.append('\\');            } else                newb.append(c);        }        return newb.toString();    }    /**     * ED_ParseField     *      * Takes a key/value pair and sets the binary values in an edict.     */    static void ED_ParseField(String key, String value, edict_t ent) {        if (key.equals("nextmap"))            Com.Println("nextmap: " + value);        if (!GameBase.st.set(key, value))            if (!ent.setField(key, value))                GameBase.gi.dprintf("??? The key [" + key                        + "] is not a field\n");    }    /**     * ED_ParseEdict     *      * Parses an edict out of the given string, returning the new position ed     * should be a properly initialized empty edict.     */    static void ED_ParseEdict(Com.ParseHelp ph, edict_t ent) {        boolean init;        String keyname;        String com_token;        init = false;        GameBase.st = new spawn_temp_t();        while (true) {            // parse key            com_token = Com.Parse(ph);            if (com_token.equals("}"))                break;            if (ph.isEof())                GameBase.gi.error("ED_ParseEntity: EOF without closing brace");            keyname = com_token;            // parse value            com_token = Com.Parse(ph);            if (ph.isEof())                GameBase.gi.error("ED_ParseEntity: EOF without closing brace");            if (com_token.equals("}"))                GameBase.gi.error("ED_ParseEntity: closing brace without data");            init = true;            // keynames with a leading underscore are used for utility comments,            // and are immediately discarded by quake            if (keyname.charAt(0) == '_')                continue;            ED_ParseField(keyname.toLowerCase(), com_token, ent);        }        if (!init) {            GameUtil.G_ClearEdict(ent);        }        return;    }    /**     * G_FindTeams     *      * Chain together all entities with a matching team field.     *      * All but the first will have the FL_TEAMSLAVE flag set. All but the last     * will have the teamchain field set to the next one.     */    static void G_FindTeams() {        edict_t e, e2, chain;        int i, j;        int c, c2;        c = 0;        c2 = 0;        for (i = 1; i < GameBase.num_edicts; i++) {            e = GameBase.g_edicts[i];            if (!e.inuse)                continue;            if (e.team == null)                continue;            if ((e.flags & Defines.FL_TEAMSLAVE) != 0)                continue;            chain = e;            e.teammaster = e;            c++;            c2++;                        for (j = i + 1; j < GameBase.num_edicts; j++) {                e2 = GameBase.g_edicts[j];                if (!e2.inuse)                    continue;                if (null == e2.team)                    continue;                if ((e2.flags & Defines.FL_TEAMSLAVE) != 0)                    continue;                if (0 == Lib.strcmp(e.team, e2.team)) {                    c2++;                    chain.teamchain = e2;                    e2.teammaster = e;                    chain = e2;                    e2.flags |= Defines.FL_TEAMSLAVE;                }            }        }    }    /**     * SpawnEntities     *      * Creates a server's entity / program execution context by parsing textual     * entity definitions out of an ent file.     */    public static void SpawnEntities(String mapname, String entities,            String spawnpoint) {                Com.dprintln("SpawnEntities(), mapname=" + mapname);        edict_t ent;        int inhibit;        String com_token;        int i;        float skill_level;        //skill.value =2.0f;        skill_level = (float) Math.floor(GameBase.skill.value);        if (skill_level < 0)            skill_level = 0;        if (skill_level > 3)            skill_level = 3;        if (GameBase.skill.value != skill_level)            GameBase.gi.cvar_forceset("skill", "" + skill_level);        PlayerClient.SaveClientData();        GameBase.level = new level_locals_t();        for (int n = 0; n < GameBase.game.maxentities; n++) {            GameBase.g_edicts[n] = new edict_t(n);        }                GameBase.level.mapname = mapname;        GameBase.game.spawnpoint = spawnpoint;        // set client fields on player ents        for (i = 0; i < GameBase.game.maxclients; i++)            GameBase.g_edicts[i + 1].client = GameBase.game.clients[i];        ent = null;        inhibit = 0;         Com.ParseHelp ph = new Com.ParseHelp(entities);        while (true) { // parse the opening brace            com_token = Com.Parse(ph);            if (ph.isEof())                break;            if (!com_token.startsWith("{"))                GameBase.gi.error("ED_LoadFromFile: found " + com_token                        + " when expecting {");            if (ent == null)                ent = GameBase.g_edicts[0];            else                ent = GameUtil.G_Spawn();            ED_ParseEdict(ph, ent);            Com.DPrintf("spawning ent[" + ent.index + "], classname=" +                     ent.classname + ", flags= " + Integer.toHexString(ent.spawnflags));                        // yet another map hack            if (0 == Lib.Q_stricmp(GameBase.level.mapname, "command")                    && 0 == Lib.Q_stricmp(ent.classname, "trigger_once")                    && 0 == Lib.Q_stricmp(ent.model, "*27"))                ent.spawnflags &= ~Defines.SPAWNFLAG_NOT_HARD;            // remove things (except the world) from different skill levels or            // deathmatch            if (ent != GameBase.g_edicts[0]) {                if (GameBase.deathmatch.value != 0) {                    if ((ent.spawnflags & Defines.SPAWNFLAG_NOT_DEATHMATCH) != 0) {                                                Com.DPrintf("->inhibited.\n");                        GameUtil.G_FreeEdict(ent);                        inhibit++;                        continue;                    }                } else {                    if (/*                         * ((coop.value) && (ent.spawnflags &                         * SPAWNFLAG_NOT_COOP)) ||                         */                    ((GameBase.skill.value == 0) && (ent.spawnflags & Defines.SPAWNFLAG_NOT_EASY) != 0)                            || ((GameBase.skill.value == 1) && (ent.spawnflags & Defines.SPAWNFLAG_NOT_MEDIUM) != 0)                            || (((GameBase.skill.value == 2) || (GameBase.skill.value == 3)) && (ent.spawnflags & Defines.SPAWNFLAG_NOT_HARD) != 0)) {                                                Com.DPrintf("->inhibited.\n");                        GameUtil.G_FreeEdict(ent);                        inhibit++;                                                continue;                    }                }                ent.spawnflags &= ~(Defines.SPAWNFLAG_NOT_EASY                        | Defines.SPAWNFLAG_NOT_MEDIUM                        | Defines.SPAWNFLAG_NOT_HARD                        | Defines.SPAWNFLAG_NOT_COOP | Defines.SPAWNFLAG_NOT_DEATHMATCH);            }            ED_CallSpawn(ent);            Com.DPrintf("\n");        }        Com.DPrintf("player skill level:" + GameBase.skill.value + "\n");        Com.DPrintf(inhibit + " entities inhibited.\n");        i = 1;        G_FindTeams();        PlayerTrail.Init();    }    static String single_statusbar = "yb	-24 " //	   health            + "xv	0 " + "hnum " + "xv	50 " + "pic 0 " //	   ammo            + "if 2 " + "	xv	100 " + "	anum " + "	xv	150 " + "	pic 2 "            + "endif " //	   armor            + "if 4 " + "	xv	200 " + "	rnum " + "	xv	250 " + "	pic 4 "            + "endif " //	   selected item            + "if 6 " + "	xv	296 " + "	pic 6 " + "endif " + "yb	-50 " //	   picked            // up            // item            + "if 7 " + "	xv	0 " + "	pic 7 " + "	xv	26 " + "	yb	-42 "            + "	stat_string 8 " + "	yb	-50 " + "endif "            //	   timer            + "if 9 " + "	xv	262 " + "	num	2	10 " + "	xv	296 " + "	pic	9 "            + "endif "            //		help / weapon icon            + "if 11 " + "	xv	148 " + "	pic	11 " + "endif ";    static String dm_statusbar = "yb	-24 " //	   health            + "xv	0 " + "hnum " + "xv	50 " + "pic 0 " //	   ammo            + "if 2 " + "	xv	100 " + "	anum " + "	xv	150 " + "	pic 2 "            + "endif " //	   armor            + "if 4 " + "	xv	200 " + "	rnum " + "	xv	250 " + "	pic 4 "            + "endif " //	   selected item            + "if 6 " + "	xv	296 " + "	pic 6 " + "endif " + "yb	-50 " //	   picked            // up            // item            + "if 7 " + "	xv	0 " + "	pic 7 " + "	xv	26 " + "	yb	-42 "            + "	stat_string 8 " + "	yb	-50 " + "endif "            //	   timer            + "if 9 " + "	xv	246 " + "	num	2	10 " + "	xv	296 " + "	pic	9 "            + "endif "            //		help / weapon icon            + "if 11 " + "	xv	148 " + "	pic	11 " + "endif " //		frags            + "xr	-50 " + "yt 2 " + "num 3 14 " //	   spectator            + "if 17 " + "xv 0 " + "yb -58 " + "string2 \"SPECTATOR MODE\" "            + "endif " //	   chase camera            + "if 16 " + "xv 0 " + "yb -68 " + "string \"Chasing\" " + "xv 64 "            + "stat_string 16 " + "endif ";    static spawn_t spawns[] = {            new spawn_t("item_health", SP_item_health),

⌨️ 快捷键说明

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