📄 m_gunner.java
字号:
if (GameBase.skill.value == 3) return; // no pain anims in nightmare if (damage <= 10) self.monsterinfo.currentmove = gunner_move_pain3; else if (damage <= 25) self.monsterinfo.currentmove = gunner_move_pain2; else self.monsterinfo.currentmove = gunner_move_pain1; } }; static EntThinkAdapter gunner_dead = new EntThinkAdapter() { public String getID() { return "gunner_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 gunner_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, -7, null), new mframe_t(GameAI.ai_move, -3, null), new mframe_t(GameAI.ai_move, -5, null), new mframe_t(GameAI.ai_move, 8, null), new mframe_t(GameAI.ai_move, 6, 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 gunner_move_death = new mmove_t(FRAME_death01, FRAME_death11, gunner_frames_death, gunner_dead); static EntDieAdapter gunner_die = new EntDieAdapter() { public String getID() { return "gunner_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_death, 1, Defines.ATTN_NORM, 0); self.deadflag = Defines.DEAD_DEAD; self.takedamage = Defines.DAMAGE_YES; self.monsterinfo.currentmove = gunner_move_death; } }; static EntThinkAdapter gunner_duck_down = new EntThinkAdapter() { public String getID() { return "gunner_duck_down"; } public boolean think(edict_t self) { if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0) return true; self.monsterinfo.aiflags |= Defines.AI_DUCKED; if (GameBase.skill.value >= 2) { if (Lib.random() > 0.5) GunnerGrenade.think(self); } self.maxs[2] -= 32; self.takedamage = Defines.DAMAGE_YES; self.monsterinfo.pausetime = GameBase.level.time + 1; GameBase.gi.linkentity(self); return true; } }; static EntThinkAdapter gunner_duck_hold = new EntThinkAdapter() { public String getID() { return "gunner_duck_hold"; } public boolean think(edict_t self) { if (GameBase.level.time >= self.monsterinfo.pausetime) self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME; else self.monsterinfo.aiflags |= Defines.AI_HOLD_FRAME; return true; } }; static EntThinkAdapter gunner_duck_up = new EntThinkAdapter() { public String getID() { return "gunner_duck_up"; } public boolean think(edict_t self) { self.monsterinfo.aiflags &= ~Defines.AI_DUCKED; self.maxs[2] += 32; self.takedamage = Defines.DAMAGE_AIM; GameBase.gi.linkentity(self); return true; } }; static mframe_t gunner_frames_duck[] = new mframe_t[] { new mframe_t(GameAI.ai_move, 1, gunner_duck_down), new mframe_t(GameAI.ai_move, 1, null), new mframe_t(GameAI.ai_move, 1, gunner_duck_hold), new mframe_t(GameAI.ai_move, 0, null), new mframe_t(GameAI.ai_move, -1, null), new mframe_t(GameAI.ai_move, -1, null), new mframe_t(GameAI.ai_move, 0, gunner_duck_up), new mframe_t(GameAI.ai_move, -1, null) }; static mmove_t gunner_move_duck = new mmove_t(FRAME_duck01, FRAME_duck08, gunner_frames_duck, gunner_run); static EntDodgeAdapter gunner_dodge = new EntDodgeAdapter() { public String getID() { return "gunner_dodge"; } public void dodge(edict_t self, edict_t attacker, float eta) { if (Lib.random() > 0.25) return; if (self.enemy == null) self.enemy = attacker; self.monsterinfo.currentmove = gunner_move_duck; } }; static EntThinkAdapter gunner_opengun = new EntThinkAdapter() { public String getID() { return "gunner_opengun"; } public boolean think(edict_t self) { GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_open, 1, Defines.ATTN_IDLE, 0); return true; } }; static EntThinkAdapter GunnerFire = new EntThinkAdapter() { public String getID() { return "GunnerFire"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] target = { 0, 0, 0 }; float[] aim = { 0, 0, 0 }; int flash_number; flash_number = Defines.MZ2_GUNNER_MACHINEGUN_1 + (self.s.frame - FRAME_attak216); Math3D.AngleVectors(self.s.angles, forward, right, null); Math3D.G_ProjectSource(self.s.origin, M_Flash.monster_flash_offset[flash_number], forward, right, start); // project enemy back a bit and target there Math3D.VectorCopy(self.enemy.s.origin, target); Math3D.VectorMA(target, -0.2f, self.enemy.velocity, target); target[2] += self.enemy.viewheight; Math3D.VectorSubtract(target, start, aim); Math3D.VectorNormalize(aim); Monster.monster_fire_bullet(self, start, aim, 3, 4, Defines.DEFAULT_BULLET_HSPREAD, Defines.DEFAULT_BULLET_VSPREAD, flash_number); return true; } }; static EntThinkAdapter GunnerGrenade = new EntThinkAdapter() { public String getID() { return "GunnerGrenade"; } public boolean think(edict_t self) { float[] start = { 0, 0, 0 }; float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }; float[] aim = { 0, 0, 0 }; int flash_number; if (self.s.frame == FRAME_attak105) flash_number = Defines.MZ2_GUNNER_GRENADE_1; else if (self.s.frame == FRAME_attak108) flash_number = Defines.MZ2_GUNNER_GRENADE_2; else if (self.s.frame == FRAME_attak111) flash_number = Defines.MZ2_GUNNER_GRENADE_3; else // (self.s.frame == FRAME_attak114) flash_number = Defines.MZ2_GUNNER_GRENADE_4; Math3D.AngleVectors(self.s.angles, forward, right, null); Math3D.G_ProjectSource(self.s.origin, M_Flash.monster_flash_offset[flash_number], forward, right, start); //FIXME : do a spread -225 -75 75 225 degrees around forward Math3D.VectorCopy(forward, aim); Monster.monster_fire_grenade(self, start, aim, 50, 600, flash_number); return true; } }; static EntThinkAdapter gunner_attack = new EntThinkAdapter() { public String getID() { return "gunner_attack"; } public boolean think(edict_t self) { if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) { self.monsterinfo.currentmove = gunner_move_attack_chain; } else { if (Lib.random() <= 0.5) self.monsterinfo.currentmove = gunner_move_attack_grenade; else self.monsterinfo.currentmove = gunner_move_attack_chain; } return true; } }; static EntThinkAdapter gunner_fire_chain = new EntThinkAdapter() { public String getID() { return "gunner_fire_chain"; } public boolean think(edict_t self) { self.monsterinfo.currentmove = gunner_move_fire_chain; return true; } }; static mframe_t gunner_frames_attack_chain[] = new mframe_t[] { new mframe_t(GameAI.ai_charge, 0, gunner_opengun), new mframe_t(GameAI.ai_charge, 0, 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), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null) }; static mmove_t gunner_move_attack_chain = new mmove_t(FRAME_attak209, FRAME_attak215, gunner_frames_attack_chain, gunner_fire_chain); static mframe_t gunner_frames_fire_chain[] = new mframe_t[] { new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire), new mframe_t(GameAI.ai_charge, 0, GunnerFire) }; static EntThinkAdapter gunner_refire_chain = new EntThinkAdapter() { public String getID() { return "gunner_refire_chain"; } public boolean think(edict_t self) { if (self.enemy.health > 0) if (GameUtil.visible(self, self.enemy)) if (Lib.random() <= 0.5) { self.monsterinfo.currentmove = gunner_move_fire_chain; return true; } self.monsterinfo.currentmove = gunner_move_endfire_chain; return true; } }; static mmove_t gunner_move_fire_chain = new mmove_t(FRAME_attak216, FRAME_attak223, gunner_frames_fire_chain, gunner_refire_chain); static mframe_t gunner_frames_endfire_chain[] = new mframe_t[] { new mframe_t(GameAI.ai_charge, 0, 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), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null) }; static mmove_t gunner_move_endfire_chain = new mmove_t(FRAME_attak224, FRAME_attak230, gunner_frames_endfire_chain, gunner_run); static mframe_t gunner_frames_attack_grenade[] = new mframe_t[] { new mframe_t(GameAI.ai_charge, 0, 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), new mframe_t(GameAI.ai_charge, 0, GunnerGrenade), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, GunnerGrenade), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, GunnerGrenade), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, GunnerGrenade), new mframe_t(GameAI.ai_charge, 0, 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), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null), new mframe_t(GameAI.ai_charge, 0, null) }; static mmove_t gunner_move_attack_grenade = new mmove_t(FRAME_attak101, FRAME_attak121, gunner_frames_attack_grenade, gunner_run); /* * QUAKED monster_gunner (1 .5 0) (-16 -16 -24) (16 16 32) Ambush * Trigger_Spawn Sight */ public static void SP_monster_gunner(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); return; } sound_death = GameBase.gi.soundindex("gunner/death1.wav"); sound_pain = GameBase.gi.soundindex("gunner/gunpain2.wav"); sound_pain2 = GameBase.gi.soundindex("gunner/gunpain1.wav"); sound_idle = GameBase.gi.soundindex("gunner/gunidle1.wav"); sound_open = GameBase.gi.soundindex("gunner/gunatck1.wav"); sound_search = GameBase.gi.soundindex("gunner/gunsrch1.wav"); sound_sight = GameBase.gi.soundindex("gunner/sight1.wav"); GameBase.gi.soundindex("gunner/gunatck2.wav"); GameBase.gi.soundindex("gunner/gunatck3.wav"); self.movetype = Defines.MOVETYPE_STEP; self.solid = Defines.SOLID_BBOX; self.s.modelindex = GameBase.gi .modelindex("models/monsters/gunner/tris.md2"); Math3D.VectorSet(self.mins, -16, -16, -24); Math3D.VectorSet(self.maxs, 16, 16, 32); self.health = 175; self.gib_health = -70; self.mass = 200; self.pain = gunner_pain; self.die = gunner_die; self.monsterinfo.stand = gunner_stand; self.monsterinfo.walk = gunner_walk; self.monsterinfo.run = gunner_run; self.monsterinfo.dodge = gunner_dodge; self.monsterinfo.attack = gunner_attack; self.monsterinfo.melee = null; self.monsterinfo.sight = gunner_sight; self.monsterinfo.search = gunner_search; GameBase.gi.linkentity(self); self.monsterinfo.currentmove = gunner_move_stand; self.monsterinfo.scale = MODEL_SCALE; GameAI.walkmonster_start.think(self); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -