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

📄 m_parasite.java

📁 JAKE2用JAVA写的queck2的3D游戏开发引擎
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                return; // no pain anims in nightmare            if (Lib.random() < 0.5)                GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_pain1, 1,                        Defines.ATTN_NORM, 0);            else                GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_pain2, 1,                        Defines.ATTN_NORM, 0);            self.monsterinfo.currentmove = parasite_move_pain1;        }    };    static EntThinkAdapter parasite_drain_attack = new EntThinkAdapter() {    	public String getID(){ return "parasite_drain_attack"; }        public boolean think(edict_t self) {            float[] offset = { 0, 0, 0 }, start = { 0, 0, 0 }, f = { 0, 0, 0 }, r = {                    0, 0, 0 }, end = { 0, 0, 0 }, dir = { 0, 0, 0 };            trace_t tr;            int damage;            Math3D.AngleVectors(self.s.angles, f, r, null);            Math3D.VectorSet(offset, 24, 0, 6);            Math3D.G_ProjectSource(self.s.origin, offset, f, r, start);            Math3D.VectorCopy(self.enemy.s.origin, end);            if (!parasite_drain_attack_ok(start, end)) {                end[2] = self.enemy.s.origin[2] + self.enemy.maxs[2] - 8;                if (!parasite_drain_attack_ok(start, end)) {                    end[2] = self.enemy.s.origin[2] + self.enemy.mins[2] + 8;                    if (!parasite_drain_attack_ok(start, end))                        return true;                }            }            Math3D.VectorCopy(self.enemy.s.origin, end);            tr = GameBase.gi.trace(start, null, null, end, self,                    Defines.MASK_SHOT);            if (tr.ent != self.enemy)                return true;            if (self.s.frame == FRAME_drain03) {                damage = 5;                GameBase.gi.sound(self.enemy, Defines.CHAN_AUTO, sound_impact,                        1, Defines.ATTN_NORM, 0);            } else {                if (self.s.frame == FRAME_drain04)                    GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_suck, 1,                            Defines.ATTN_NORM, 0);                damage = 2;            }            GameBase.gi.WriteByte(Defines.svc_temp_entity);            GameBase.gi.WriteByte(Defines.TE_PARASITE_ATTACK);            //gi.WriteShort(self - g_edicts);            GameBase.gi.WriteShort(self.index);            GameBase.gi.WritePosition(start);            GameBase.gi.WritePosition(end);            GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);            Math3D.VectorSubtract(start, end, dir);            GameCombat.T_Damage(self.enemy, self, self, dir, self.enemy.s.origin,                    Globals.vec3_origin, damage, 0,                    Defines.DAMAGE_NO_KNOCKBACK, Defines.MOD_UNKNOWN);            return true;        }    };    static mframe_t parasite_frames_drain[] = new mframe_t[] {            new mframe_t(GameAI.ai_charge, 0, parasite_launch),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, 15, parasite_drain_attack),            // Target hits)            new mframe_t(GameAI.ai_charge, 0, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, 0, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, 0, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, 0, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, -2, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, -2, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, -3, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, -2, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, 0, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, -1, parasite_drain_attack), // drain)            new mframe_t(GameAI.ai_charge, 0, parasite_reel_in), // let go)            new mframe_t(GameAI.ai_charge, -2, null),            new mframe_t(GameAI.ai_charge, -2, null),            new mframe_t(GameAI.ai_charge, -3, null),            new mframe_t(GameAI.ai_charge, 0, null) };    static mmove_t parasite_move_drain = new mmove_t(FRAME_drain01,            FRAME_drain18, parasite_frames_drain, parasite_start_run);    static mframe_t parasite_frames_break[] = new mframe_t[] {            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, -3, null),            new mframe_t(GameAI.ai_charge, 1, null),            new mframe_t(GameAI.ai_charge, 2, null),            new mframe_t(GameAI.ai_charge, -3, null),            new mframe_t(GameAI.ai_charge, 1, null),            new mframe_t(GameAI.ai_charge, 1, null),            new mframe_t(GameAI.ai_charge, 3, null),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, -18, null),            new mframe_t(GameAI.ai_charge, 3, null),            new mframe_t(GameAI.ai_charge, 9, null),            new mframe_t(GameAI.ai_charge, 6, null),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, -18, null),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, 8, null),            new mframe_t(GameAI.ai_charge, 9, null),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, -18, null),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, 0, null),            new mframe_t(GameAI.ai_charge, 0, null),            /* airborne */            new mframe_t(GameAI.ai_charge, 0, null), /* slides */            new mframe_t(GameAI.ai_charge, 0, null), /* slides */            new mframe_t(GameAI.ai_charge, 0, null), /* slides */            new mframe_t(GameAI.ai_charge, 0, null), /* slides */            new mframe_t(GameAI.ai_charge, 4, null),            new mframe_t(GameAI.ai_charge, 11, null),            new mframe_t(GameAI.ai_charge, -2, null),            new mframe_t(GameAI.ai_charge, -5, null),            new mframe_t(GameAI.ai_charge, 1, null) };    static mmove_t parasite_move_break = new mmove_t(FRAME_break01,            FRAME_break32, parasite_frames_break, parasite_start_run);    /*     * === Break Stuff Ends ===     */    static EntThinkAdapter parasite_attack = new EntThinkAdapter() {    	public String getID(){ return "parasite_attack"; }        public boolean think(edict_t self) {            //	if (random() <= 0.2)            //		self.monsterinfo.currentmove = &parasite_move_break;            //	else            self.monsterinfo.currentmove = parasite_move_drain;            return true;        }    };    /*     * === Death Stuff Starts ===     */    static EntThinkAdapter parasite_dead = new EntThinkAdapter() {    	public String getID(){ return "parasite_dead"; }        public boolean think(edict_t self) {            Math3D.VectorSet(self.mins, -16, -16, -24);            Math3D.VectorSet(self.maxs, 16, 16, -8);            self.movetype = Defines.MOVETYPE_TOSS;            self.svflags |= Defines.SVF_DEADMONSTER;            self.nextthink = 0;            GameBase.gi.linkentity(self);            return true;        }    };    static mframe_t parasite_frames_death[] = new mframe_t[] {            new mframe_t(GameAI.ai_move, 0, null),            new mframe_t(GameAI.ai_move, 0, null),            new mframe_t(GameAI.ai_move, 0, null),            new mframe_t(GameAI.ai_move, 0, null),            new mframe_t(GameAI.ai_move, 0, null),            new mframe_t(GameAI.ai_move, 0, null),            new mframe_t(GameAI.ai_move, 0, null) };    static mmove_t parasite_move_death = new mmove_t(FRAME_death101,            FRAME_death107, parasite_frames_death, parasite_dead);    static EntDieAdapter parasite_die = new EntDieAdapter() {    	public String getID(){ return "parasite_die"; }        public void die(edict_t self, edict_t inflictor, edict_t attacker,                int damage, float[] point) {            int n;            // check for gib            if (self.health <= self.gib_health) {                GameBase.gi                        .sound(self, Defines.CHAN_VOICE, GameBase.gi                                .soundindex("misc/udeath.wav"), 1,                                Defines.ATTN_NORM, 0);                for (n = 0; n < 2; n++)                    GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",                            damage, Defines.GIB_ORGANIC);                for (n = 0; n < 4; n++)                    GameMisc.ThrowGib(self,                            "models/objects/gibs/sm_meat/tris.md2", damage,                            Defines.GIB_ORGANIC);                GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",                        damage, Defines.GIB_ORGANIC);                self.deadflag = Defines.DEAD_DEAD;                return;            }            if (self.deadflag == Defines.DEAD_DEAD)                return;            // regular death            GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_die, 1,                    Defines.ATTN_NORM, 0);            self.deadflag = Defines.DEAD_DEAD;            self.takedamage = Defines.DAMAGE_YES;            self.monsterinfo.currentmove = parasite_move_death;        }    };    /*     * === End Death Stuff ===     */    /*     * QUAKED monster_parasite (1 .5 0) (-16 -16 -24) (16 16 32) Ambush     * Trigger_Spawn Sight     */    public static EntThinkAdapter SP_monster_parasite = new EntThinkAdapter() {    	public String getID(){ return "SP_monster_parasite"; }        public boolean think(edict_t self) {            if (GameBase.deathmatch.value != 0) {                GameUtil.G_FreeEdict(self);                return true;            }            sound_pain1 = GameBase.gi.soundindex("parasite/parpain1.wav");            sound_pain2 = GameBase.gi.soundindex("parasite/parpain2.wav");            sound_die = GameBase.gi.soundindex("parasite/pardeth1.wav");            sound_launch = GameBase.gi.soundindex("parasite/paratck1.wav");            sound_impact = GameBase.gi.soundindex("parasite/paratck2.wav");            sound_suck = GameBase.gi.soundindex("parasite/paratck3.wav");            sound_reelin = GameBase.gi.soundindex("parasite/paratck4.wav");            sound_sight = GameBase.gi.soundindex("parasite/parsght1.wav");            sound_tap = GameBase.gi.soundindex("parasite/paridle1.wav");            sound_scratch = GameBase.gi.soundindex("parasite/paridle2.wav");            sound_search = GameBase.gi.soundindex("parasite/parsrch1.wav");            self.s.modelindex = GameBase.gi                    .modelindex("models/monsters/parasite/tris.md2");            Math3D.VectorSet(self.mins, -16, -16, -24);            Math3D.VectorSet(self.maxs, 16, 16, 24);            self.movetype = Defines.MOVETYPE_STEP;            self.solid = Defines.SOLID_BBOX;            self.health = 175;            self.gib_health = -50;            self.mass = 250;            self.pain = parasite_pain;            self.die = parasite_die;            self.monsterinfo.stand = parasite_stand;            self.monsterinfo.walk = parasite_start_walk;            self.monsterinfo.run = parasite_start_run;            self.monsterinfo.attack = parasite_attack;            self.monsterinfo.sight = parasite_sight;            self.monsterinfo.idle = parasite_idle;            GameBase.gi.linkentity(self);            self.monsterinfo.currentmove = parasite_move_stand;            self.monsterinfo.scale = MODEL_SCALE;            GameAI.walkmonster_start.think(self);            return true;        }    };    static boolean parasite_drain_attack_ok(float[] start, float[] end) {        float[] dir = { 0, 0, 0 }, angles = { 0, 0, 0 };        // check for max distance        Math3D.VectorSubtract(start, end, dir);        if (Math3D.VectorLength(dir) > 256)            return false;        // check for min/max pitch        Math3D.vectoangles(dir, angles);        if (angles[0] < -180)            angles[0] += 360;        if (Math.abs(angles[0]) > 30)            return false;        return true;    }}

⌨️ 快捷键说明

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