📄 m_infantry.pas
字号:
AngleVectors(self.s.angles, fwrd, right, nil);
G_ProjectSource(self.s.origin, monster_flash_offset[flash_number], fwrd, right, start);
VectorSubtract(self.s.angles, aimangles[flash_number-MZ2_INFANTRY_MACHINEGUN_2], vec);
AngleVectors(vec, fwrd, nil, nil);
end;
monster_fire_bullet(self, start, fwrd, 3, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flash_number);
end;
procedure infantry_sight(self, other : edict_t);
begin
gi.sound(self, CHAN_BODY, sound_sight, 1, ATTN_NORM, 0);
end;
procedure infantry_dead(self : edict_t);
begin
VectorSet(self.mins, -16, -16, -24);
VectorSet(self.maxs, 16, 16, -8);
self.movetype := MOVETYPE_TOSS;
self.svflags :=(self.svflags or SVF_DEADMONSTER);
gi.linkentitiy(self);
M_FlyCheck(self);
end;
const
infantry_frames_death1 : Array[0..19] of mframe_t =
((aifunc:ai_move; dist:-4; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:-1; thinkfunc:nil),
(aifunc:ai_move; dist:-4; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:-1; thinkfunc:nil),
(aifunc:ai_move; dist:3; thinkfunc:nil),
(aifunc:ai_move; dist:1; thinkfunc:nil),
(aifunc:ai_move; dist:1; thinkfunc:nil),
(aifunc:ai_move; dist:-2; thinkfunc:nil),
(aifunc:ai_move; dist:2; thinkfunc:nil),
(aifunc:ai_move; dist:2; thinkfunc:nil),
(aifunc:ai_move; dist:9; thinkfunc:nil),
(aifunc:ai_move; dist:9; thinkfunc:nil),
(aifunc:ai_move; dist:5; thinkfunc:nil),
(aifunc:ai_move; dist:-3; thinkfunc:nil),
(aifunc:ai_move; dist:-3; thinkfunc:nil));
infantry_move_death1 : mmove_t =
(firstframe:FRAME_death101; lastframe:FRAME_death120; frame:infantry_frames_death1; endfunc:infantry_dead);
// Off with his head
const
infantry_frames_death2 : Array[0..24] of mframe_t =
((aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:1; thinkfunc:nil),
(aifunc:ai_move; dist:5; thinkfunc:nil),
(aifunc:ai_move; dist:-1; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:1; thinkfunc:nil),
(aifunc:ai_move; dist:1; thinkfunc:nil),
(aifunc:ai_move; dist:4; thinkfunc:nil),
(aifunc:ai_move; dist:3; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:-2; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-2; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-3; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-1; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-2; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:0; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:2; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:2; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:3; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-10; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-7; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-8; thinkfunc:InfantryMachineGun),
(aifunc:ai_move; dist:-6; thinkfunc:nil),
(aifunc:ai_move; dist:4; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil));
infantry_move_death2 : mmove_t =
(firstframe:FRAME_death201; lastframe:FRAME_death225; frame:infantry_frames_death2; endfunc:infantry_dead);
const
infantry_frames_death3 : Array[0..8] of mframe_t =
((aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:-6; thinkfunc:nil),
(aifunc:ai_move; dist:-11; thinkfunc:nil),
(aifunc:ai_move; dist:-3; thinkfunc:nil),
(aifunc:ai_move; dist:-11; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil),
(aifunc:ai_move; dist:0; thinkfunc:nil));
infantry_move_death3 : mmove_t =
(firstframe:FRAME_death301; lastframe:FRAME_death309; frame:infantry_frames_death3; endfunc:infantry_dead);
procedure infantry_die(self, inflictor, attacker : edict_t; damage : Integer; point : vec3_t);
var
n : Integer;
begin
// check for gib
if self.health <= self.gib_health then
begin
gi.sound(self, CHAN_VOICE, gi.soundindex('misc/udeath.wav'), 1, ATTN_NORM, 0);
for n := 0 to 1 do
ThrowGib(self, 'models/objects/gibs/bone/tris.md2', damage, GIB_ORGANIC);
for n := 0 to 3 do
ThrowGib(self, 'models/objects/gibs/sm_meat/tris.md2', damage, GIB_ORGANIC);
ThrowHead(self, 'models/objects/gibs/head2/tris.md2', damage, GIB_ORGANIC);
self.deadflag := DEAD_DEAD;
exit;
end;
if (self.deadflag = DEAD_DEAD) then
exit;
// regular death
self.deadflag := DEAD_DEAD;
self.takedamage := DAMAGE_YES;
n := random(3);
if n = 0 then
begin
self.monsterinfo.currentmove := infantry_move_death1;
gi.sound(self, CHAN_VOICE, sound_die2, 1, ATTN_NORM, 0);
end
else
if n =1 then
begin
self.monsterinfo.currentmove := infantry_move_death2;
gi.sound(self, CHAN_VOICE, sound_die1, 1, ATTN_NORM, 0);
end
else
begin
self.monsterinfo.currentmove := infantry_move_death3;
gi.sound(self, CHAN_VOICE, sound_die2, 1, ATTN_NORM, 0);
end;
end;
procedure infantry_duck_down(self : edict_t);
begin
if (self.monsterinfo.aiflags and AI_DUCKED) = 1 then
exit;
self.monsterinfo.aiflags:= (self.monsterinfo.aiflags or AI_DUCKED);
self.maxs[2] := self.maxs[2] - 32;
self.takedamage := DAMAGE_YES;
self.monsterinfo.pausetime := level.time + 1;
gi.linkentity(self);
end;
procedure infantry_duck_hold(self : edict_t);
begin
if level.time >= self.monsterinfo.pausetime then
self.monsterinfo.aiflags := (self.monsterinfo.aiflags and AI_HOLD_FRAME)
else
self.monsterinfo.aiflags := (self.monsterinfo.aiflags or AI_HOLD_FRAME);
end;
procedure infantry_duck_up(self : edict_t);
begin
self.monsterinfo.aiflags := (self.monsterinfo.aiflags and AI_DUCKED);
self.maxs[2] := self.maxs[2] + 32;
self.takedamage := DAMAGE_AIM;
gi.linkentity(self);
end;
const
infantry_frames_duck : Array[0..4] of mframe_t =
((aifunc:ai_move; dist:-2; thinkfunc:infantry_duck_down),
(aifunc:ai_move; dist:-5; thinkfunc:infantry_duck_hold),
(aifunc:ai_move; dist:3; thinkfunc:nil),
(aifunc:ai_move; dist:4; thinkfunc:infantry_duck_up),
(aifunc:ai_move; dist:0; thinkfunc:nil));
infantry_move_duck : mmove_t =
(firstframe:FRAME_duck01; lastframe:FRAME_duck05; frame:infantry_frames_duck; endfunc:infantry_run);
procedure infantry_dodge(self, attacker : edict_t; eta : single);
begin
if random() > 0.25 then
exit;
if not(self.enemy) then
self.enemy := attacker;
self.monsterinfo.currentmove := infantry_move_duck;
end;
procedure infantry_cock_gun(self : edict_t);
var
n : integer;
begin
gi.sound(self, CHAN_WEAPON, sound_weapon_cock, 1, ATTN_NORM, 0);
n := random(15) + 3 + 7; // (rand() & 15) + 3 + 7;
self.monsterinfo.pausetime := level.time + n * FRAMETIME;
end;
procedure infantry_fire(self : edict_t);
begin
InfantryMachineGun(self);
if level.time >= self.monsterinfo.pausetime then
self.monsterinfo.aiflags := (self.monsterinfo.aiflags and AI_HOLD_FRAME)
else
self.monsterinfo.aiflags := (self.monsterinfo.aiflags or AI_HOLD_FRAME);
end;
const
infantry_frames_attack1 : Array[0..14] of mframe_t =
((aifunc:ai_charge; dist:4; thinkfunc:nil),
(aifunc:ai_charge; dist:-1; thinkfunc:nil),
(aifunc:ai_charge; dist:-1; thinkfunc:nil),
(aifunc:ai_charge; dist:0; thinkfunc:infantry_cock_gun),
(aifunc:ai_charge; dist:-1; thinkfunc:nil)
(aifunc:ai_charge; dist:1; thinkfunc:nil)
(aifunc:ai_charge; dist:1; thinkfunc:nil)
(aifunc:ai_charge; dist:2; thinkfunc:nil)
(aifunc:ai_charge; dist:-2; thinkfunc:nil)
(aifunc:ai_charge; dist:-3; thinkfunc:nil)
(aifunc:ai_charge; dist:1; thinkfunc:infantry_fire)
(aifunc:ai_charge; dist:5; thinkfunc:nil)
(aifunc:ai_charge; dist:-1; thinkfunc:nil)
(aifunc:ai_charge; dist:-2; thinkfunc:nil)
(aifunc:ai_charge; dist:-3; thinkfunc:nil));
infantry_move_attack1 : mmove_t =
(firstframe:FRAME_attak101; lastframe:FRAME_attak115; frame:infantry_frames_attack1; endfunc:infantry_run);
procedure infantry_swing(self : edict_t);
begin
gi.sound(self, CHAN_WEAPON, sound_punch_swing, 1, ATTN_NORM, 0);
end;
procedure infantry_smack(self : edict_t);
var
aim : vec3_t;
begin
VectorSet(aim, MELEE_DISTANCE, 0, 0);
if fire_hit(self, aim, (5 + rand(5)), 50) then
gi.sound(self, CHAN_WEAPON, sound_punch_hit, 1, ATTN_NORM, 0);
end;
const
infantry_frames_attack2 : Array[0..7] of mframe_t =
((aifunc:ai_charge; dist:3; thinkfunc:nil),
(aifunc:ai_charge; dist:6; thinkfunc:nil),
(aifunc:ai_charge; dist:0; thinkfunc:infantry_swing),
(aifunc:ai_charge; dist:8; thinkfunc:nil),
(aifunc:ai_charge; dist:5; thinkfunc:nil),
(aifunc:ai_charge; dist:8; thinkfunc:infantry_smack),
(aifunc:ai_charge; dist:6; thinkfunc:nil),
(aifunc:ai_charge; dist:3; thinkfunc:nil));
infantry_move_attack2 : mmove_t =
(firstframe:FRAME_attak201; lastframe:FRAME_attak208; frame:infantry_frames_attack2; endfunc:infantry_run);
procedure infantry_attack(self : edict_t);
begin
if range(self, self.enemy) = RANGE_MELEE then
self.monsterinfo.currentmove := infantry_move_attack2;
else
self.monsterinfo.currentmove := infantry_move_attack1;
end;
{QUAKED monster_infantry (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight}
procedure SP_monster_infantry(self : edict_t);
begin
if deathmatch.value <> nil then
begin
G_FreeEdict(self);
exit;
end;
sound_pain1 := gi.soundindex('infantry/infpain1.wav');
sound_pain2 := gi.soundindex('infantry/infpain2.wav');
sound_die1 := gi.soundindex('infantry/infdeth1.wav');
sound_die2 := gi.soundindex('infantry/infdeth2.wav');
sound_gunshot := gi.soundindex('infantry/infatck1.wav');
sound_weapon_cock := gi.soundindex('infantry/infatck3.wav');
sound_punch_swing := gi.soundindex('infantry/infatck2.wav');
sound_punch_hit := gi.soundindex('infantry/melee2.wav');
sound_sight := gi.soundindex('infantry/infsght1.wav');
sound_search := gi.soundindex('infantry/infsrch1.wav');
sound_idle := gi.soundindex('infantry/infidle1.wav');
self.movetype := MOVETYPE_STEP;
self.solid := SOLID_BBOX;
self.s.modelindex := gi.modelindex('models/monsters/infantry/tris.md2');
VectorSet(self.mins, -16, -16, -24);
VectorSet(self.maxs, 16, 16, 32);
self.health := 100;
self.gib_health := -40;
self.mass := 200;
self.pain := infantry_pain;
self.die := Infantry_die;
self.monsterinfo.stand := infantry_stand;
self.monsterinfo.walk := infantry_walk;
self.monsterinfo.run := infantry_run;
self.monsterinfo.dodge := infantry_dodge;
self.monsterinfo.attack := infantry_attack;
self.monsterinfo.melee := nil;
self.monsterinfo.sight := infantry_sight;
self.monsterinfo.idle := infantry_fidget;
gi.linkentity(self);
self.monsterinfo.currentmove := infantry_move_stand;
self.monsterinfo.scale := MODEL_SCALE;
walkmonster_start(self);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -