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

📄 gamefunc.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                AngleMove_Final.think(ent);                return true;            }            frames = (float) (Math.floor(traveltime / Defines.FRAMETIME));            // scale the destdelta vector by the time spent traveling to get            // velocity            Math3D.VectorScale(destdelta, 1.0f / traveltime, ent.avelocity);            // set nextthink to trigger a think when dest is reached            ent.nextthink = GameBase.level.time + frames * Defines.FRAMETIME;            ent.think = AngleMove_Final;            return true;        }    };    static EntThinkAdapter Think_AccelMove = new EntThinkAdapter() {        public String getID() { return "thinc_accelmove";}        public boolean think(edict_t ent) {            ent.moveinfo.remaining_distance -= ent.moveinfo.current_speed;            if (ent.moveinfo.current_speed == 0) // starting or blocked                plat_CalcAcceleratedMove(ent.moveinfo);            plat_Accelerate(ent.moveinfo);            // will the entire move complete on next frame?            if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) {                Move_Final.think(ent);                return true;            }            Math3D.VectorScale(ent.moveinfo.dir,                    ent.moveinfo.current_speed * 10, ent.velocity);            ent.nextthink = GameBase.level.time + Defines.FRAMETIME;            ent.think = Think_AccelMove;            return true;        }    };    static EntThinkAdapter plat_hit_top = new EntThinkAdapter() {        public String getID() { return "plat_hit_top";}        public boolean think(edict_t ent) {            if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {                if (ent.moveinfo.sound_end != 0)                    GameBase.gi.sound(ent, Defines.CHAN_NO_PHS_ADD                            + Defines.CHAN_VOICE, ent.moveinfo.sound_end, 1,                            Defines.ATTN_STATIC, 0);                ent.s.sound = 0;            }            ent.moveinfo.state = STATE_TOP;            ent.think = plat_go_down;            ent.nextthink = GameBase.level.time + 3;            return true;        }    };    static EntThinkAdapter plat_hit_bottom = new EntThinkAdapter() {        public String getID() { return "plat_hit_bottom";}        public boolean think(edict_t ent) {            if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {                if (ent.moveinfo.sound_end != 0)                    GameBase.gi.sound(ent, Defines.CHAN_NO_PHS_ADD                            + Defines.CHAN_VOICE, ent.moveinfo.sound_end, 1,                            Defines.ATTN_STATIC, 0);                ent.s.sound = 0;            }            ent.moveinfo.state = STATE_BOTTOM;            return true;        }    };    static EntThinkAdapter plat_go_down = new EntThinkAdapter() {        public String getID() { return "plat_go_down";}        public boolean think(edict_t ent) {            if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {                if (ent.moveinfo.sound_start != 0)                    GameBase.gi.sound(ent, Defines.CHAN_NO_PHS_ADD                            + Defines.CHAN_VOICE, ent.moveinfo.sound_start, 1,                            Defines.ATTN_STATIC, 0);                ent.s.sound = ent.moveinfo.sound_middle;            }            ent.moveinfo.state = STATE_DOWN;            Move_Calc(ent, ent.moveinfo.end_origin, plat_hit_bottom);            return true;        }    };    static EntBlockedAdapter plat_blocked = new EntBlockedAdapter() {        public String getID() { return "plat_blocked";}        public void blocked(edict_t self, edict_t other) {            if (0 == (other.svflags & Defines.SVF_MONSTER)                    && (null == other.client)) {                // give it a chance to go away on it's own terms (like gibs)                GameCombat.T_Damage(other, self, self, Globals.vec3_origin,                        other.s.origin, Globals.vec3_origin, 100000, 1, 0,                        Defines.MOD_CRUSH);                // if it's still there, nuke it                if (other != null)                    GameMisc.BecomeExplosion1(other);                return;            }            GameCombat.T_Damage(other, self, self, Globals.vec3_origin,                    other.s.origin, Globals.vec3_origin, self.dmg, 1, 0,                    Defines.MOD_CRUSH);            if (self.moveinfo.state == STATE_UP)                plat_go_down.think(self);            else if (self.moveinfo.state == STATE_DOWN)                plat_go_up(self);        }    };    static EntUseAdapter Use_Plat = new EntUseAdapter() {        public String getID() { return "use_plat";}        public void use(edict_t ent, edict_t other, edict_t activator) {            if (ent.think != null)                return; // already down            plat_go_down.think(ent);        }    };    static EntTouchAdapter Touch_Plat_Center = new EntTouchAdapter() {        public String getID() { return "touch_plat_center";}        public void touch(edict_t ent, edict_t other, cplane_t plane,                csurface_t surf) {            if (other.client == null)                return;            if (other.health <= 0)                return;            ent = ent.enemy; // now point at the plat, not the trigger            if (ent.moveinfo.state == STATE_BOTTOM)                plat_go_up(ent);            else if (ent.moveinfo.state == STATE_TOP) {                ent.nextthink = GameBase.level.time + 1; // the player is still                                                         // on the plat, so                                                         // delay going down            }        }    };    /**     * QUAKED func_rotating (0 .5 .8) ? START_ON REVERSE X_AXIS Y_AXIS     * TOUCH_PAIN STOP ANIMATED ANIMATED_FAST You need to have an origin brush     * as part of this entity. The center of that brush will be the point around     * which it is rotated. It will rotate around the Z axis by default. You can     * check either the X_AXIS or Y_AXIS box to change that.     *      * "speed" determines how fast it moves; default value is 100. "dmg" damage     * to inflict when blocked (2 default)     *      * REVERSE will cause the it to rotate in the opposite direction. STOP mean     * it will stop moving instead of pushing entities     */    static EntBlockedAdapter rotating_blocked = new EntBlockedAdapter() {        public String getID() { return "rotating_blocked";}        public void blocked(edict_t self, edict_t other) {            GameCombat.T_Damage(other, self, self, Globals.vec3_origin,                    other.s.origin, Globals.vec3_origin, self.dmg, 1, 0,                    Defines.MOD_CRUSH);        }    };    static EntTouchAdapter rotating_touch = new EntTouchAdapter() {        public String getID() { return "rotating_touch";}        public void touch(edict_t self, edict_t other, cplane_t plane,                csurface_t surf) {            if (self.avelocity[0] != 0 || self.avelocity[1] != 0                    || self.avelocity[2] != 0)                GameCombat.T_Damage(other, self, self, Globals.vec3_origin,                        other.s.origin, Globals.vec3_origin, self.dmg, 1, 0,                        Defines.MOD_CRUSH);        }    };    static EntUseAdapter rotating_use = new EntUseAdapter() {        public String getID() { return "rotating_use";}        public void use(edict_t self, edict_t other, edict_t activator) {            if (!Math3D.VectorEquals(self.avelocity, Globals.vec3_origin)) {                self.s.sound = 0;                Math3D.VectorClear(self.avelocity);                self.touch = null;            } else {                self.s.sound = self.moveinfo.sound_middle;                Math3D.VectorScale(self.movedir, self.speed, self.avelocity);                if ((self.spawnflags & 16) != 0)                    self.touch = rotating_touch;            }        }    };    static EntThinkAdapter SP_func_rotating = new EntThinkAdapter() {        public String getID() { return "sp_func_rotating";}        public boolean think(edict_t ent) {            ent.solid = Defines.SOLID_BSP;            if ((ent.spawnflags & 32) != 0)                ent.movetype = Defines.MOVETYPE_STOP;            else                ent.movetype = Defines.MOVETYPE_PUSH;            // set the axis of rotation            Math3D.VectorClear(ent.movedir);            if ((ent.spawnflags & 4) != 0)                ent.movedir[2] = 1.0f;            else if ((ent.spawnflags & 8) != 0)                ent.movedir[0] = 1.0f;            else                // Z_AXIS                ent.movedir[1] = 1.0f;            // check for reverse rotation            if ((ent.spawnflags & 2) != 0)                Math3D.VectorNegate(ent.movedir, ent.movedir);            if (0 == ent.speed)                ent.speed = 100;            if (0 == ent.dmg)                ent.dmg = 2;            //		ent.moveinfo.sound_middle = "doors/hydro1.wav";            ent.use = rotating_use;            if (ent.dmg != 0)                ent.blocked = rotating_blocked;            if ((ent.spawnflags & 1) != 0)                ent.use.use(ent, null, null);            if ((ent.spawnflags & 64) != 0)                ent.s.effects |= Defines.EF_ANIM_ALL;            if ((ent.spawnflags & 128) != 0)                ent.s.effects |= Defines.EF_ANIM_ALLFAST;            GameBase.gi.setmodel(ent, ent.model);            GameBase.gi.linkentity(ent);            return true;        }    };    /*     * ======================================================================     *      * BUTTONS     *      * ======================================================================     */    /*     * QUAKED func_button (0 .5 .8) ? When a button is touched, it moves some     * distance in the direction of it's angle, triggers all of it's targets,     * waits some time, then returns to it's original position where it can be     * triggered again.     *      * "angle" determines the opening direction "target" all entities with a     * matching targetname will be used "speed" override the default 40 speed     * "wait" override the default 1 second wait (-1 = never return) "lip"     * override the default 4 pixel lip remaining at end of move "health" if     * set, the button must be killed instead of touched "sounds" 1) silent 2)     * steam metal 3) wooden clunk 4) metallic click 5) in-out     */    static EntThinkAdapter button_done = new EntThinkAdapter() {        public String getID() { return "button_done";}        public boolean think(edict_t self) {            self.moveinfo.state = STATE_BOTTOM;            self.s.effects &= ~Defines.EF_ANIM23;            self.s.effects |= Defines.EF_ANIM01;            return true;        }    };    static EntThinkAdapter button_return = new EntThinkAdapter() {        public String getID() { return "button_return";}        public boolean think(edict_t self) {            self.moveinfo.state = STATE_DOWN;            Move_Calc(self, self.moveinfo.start_origin, button_done);            self.s.frame = 0;            if (self.health != 0)                self.takedamage = Defines.DAMAGE_YES;            return true;        }    };    static EntThinkAdapter button_wait = new EntThinkAdapter() {        public String getID() { return "button_wait";}        public boolean think(edict_t self) {            self.moveinfo.state = STATE_TOP;            self.s.effects &= ~Defines.EF_ANIM01;            self.s.effects |= Defines.EF_ANIM23;            GameUtil.G_UseTargets(self, self.activator);            self.s.frame = 1;            if (self.moveinfo.wait >= 0) {                self.nextthink = GameBase.level.time + self.moveinfo.wait;                self.think = button_return;            }            return true;        }    };    static EntThinkAdapter button_fire = new EntThinkAdapter() {        public String getID() { return "button_fire";}        public boolean think(edict_t self) {            if (self.moveinfo.state == STATE_UP                    || self.moveinfo.state == STATE_TOP)                return true;            self.moveinfo.state = STATE_UP;            if (self.moveinfo.sound_start != 0                    && 0 == (self.flags & Defines.FL_TEAMSLAVE))                GameBase.gi.sound(self, Defines.CHAN_NO_PHS_ADD                        + Defines.CHAN_VOICE, self.moveinfo.sound_start, 1,                        Defines.ATTN_STATIC, 0);            Move_Calc(self, self.moveinfo.end_origin, button_wait);            return true;        }    };    static EntUseAdapter button_use = new EntUseAdapter() {        public String getID() { return "button_use";}        public void use(edict_t self, edict_t other, edict_t activator) {            self.activator = activator;            button_fire.think(self);            return;        }    };    static EntTouchAdapter button_touch = new EntTouchAdapter() {        public String getID() { return "button_touch";}        public void touch(edict_t self, edict_t other, cplane_t plane,                csurface_t surf) {            if (null == other.client)                return;            if (other.health <= 0)                return;            self.activator = other;            button_fire.think(self);

⌨️ 快捷键说明

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