4 REGISTER_MONSTER_SIMPLE(
6 /* spawnflags */ MON_FLAG_MELEE,
7 /* mins,maxs */ '-18 -18 -25', '18 18 47',
8 /* model */ "zombie.dpm",
9 /* netname */ "zombie",
10 /* fullname */ _("Zombie")
13 this.monster_func = M_Zombie;
14 this.monster_func(MR_PRECACHE);
19 float autocvar_g_monster_zombie_health;
20 float autocvar_g_monster_zombie_damageforcescale = 0.55;
21 float autocvar_g_monster_zombie_attack_melee_damage;
22 float autocvar_g_monster_zombie_attack_melee_delay;
23 float autocvar_g_monster_zombie_attack_leap_damage;
24 float autocvar_g_monster_zombie_attack_leap_force;
25 float autocvar_g_monster_zombie_attack_leap_speed;
26 float autocvar_g_monster_zombie_attack_leap_delay;
27 float autocvar_g_monster_zombie_speed_stop;
28 float autocvar_g_monster_zombie_speed_run;
29 float autocvar_g_monster_zombie_speed_walk;
32 const float zombie_anim_attackleap = 0;
33 const float zombie_anim_attackrun1 = 1;
34 const float zombie_anim_attackrun2 = 2;
35 const float zombie_anim_attackrun3 = 3;
36 const float zombie_anim_attackstanding1 = 4;
37 const float zombie_anim_attackstanding2 = 5;
38 const float zombie_anim_attackstanding3 = 6;
39 const float zombie_anim_blockend = 7;
40 const float zombie_anim_blockstart = 8;
41 const float zombie_anim_deathback1 = 9;
42 const float zombie_anim_deathback2 = 10;
43 const float zombie_anim_deathback3 = 11;
44 const float zombie_anim_deathfront1 = 12;
45 const float zombie_anim_deathfront2 = 13;
46 const float zombie_anim_deathfront3 = 14;
47 const float zombie_anim_deathleft1 = 15;
48 const float zombie_anim_deathleft2 = 16;
49 const float zombie_anim_deathright1 = 17;
50 const float zombie_anim_deathright2 = 18;
51 const float zombie_anim_idle = 19;
52 const float zombie_anim_painback1 = 20;
53 const float zombie_anim_painback2 = 21;
54 const float zombie_anim_painfront1 = 22;
55 const float zombie_anim_painfront2 = 23;
56 const float zombie_anim_runbackwards = 24;
57 const float zombie_anim_runbackwardsleft = 25;
58 const float zombie_anim_runbackwardsright = 26;
59 const float zombie_anim_runforward = 27;
60 const float zombie_anim_runforwardleft = 28;
61 const float zombie_anim_runforwardright = 29;
62 const float zombie_anim_spawn = 30;
65 void M_Zombie_Attack_Leap_Touch()
74 angles_face = vectoangles(self.moveto - self.origin);
75 angles_face = normalize(angles_face) * (autocvar_g_monster_zombie_attack_leap_force);
76 Damage(other, self, self, (autocvar_g_monster_zombie_attack_leap_damage) * MONSTER_SKILLMOD(self), DEATH_MONSTER_ZOMBIE_JUMP, other.origin, angles_face);
77 self.touch = Monster_Touch; // instantly turn it off to stop damage spam
81 if (trace_dphitcontents)
84 self.touch = Monster_Touch;
88 void M_Zombie_Defend_Block_End()
93 setanim(self, self.anim_blockend, false, true, true);
94 self.armorvalue = autocvar_g_monsters_armor_blockpercent;
97 float M_Zombie_Defend_Block()
99 self.armorvalue = 0.9;
100 self.state = MONSTER_ATTACK_MELEE; // freeze monster
101 self.attack_finished_single = time + 2.1;
102 self.anim_finished = self.attack_finished_single;
103 setanim(self, self.anim_blockstart, false, true, true);
105 Monster_Delay(1, 0, 2, M_Zombie_Defend_Block_End);
110 float M_Zombie_Attack(float attack_type)
114 case MONSTER_ATTACK_MELEE:
116 if(random() < 0.3 && self.health < 75 && self.enemy.health > 10)
117 return M_Zombie_Defend_Block();
119 float rand = random();
123 chosen_anim = self.anim_melee1;
125 chosen_anim = self.anim_melee2;
127 chosen_anim = self.anim_melee3;
129 return Monster_Attack_Melee(self.enemy, (autocvar_g_monster_zombie_attack_melee_damage), chosen_anim, self.attack_range, (autocvar_g_monster_zombie_attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE, true);
131 case MONSTER_ATTACK_RANGED:
133 makevectors(self.angles);
134 return Monster_Attack_Leap(self.anim_shoot, M_Zombie_Attack_Leap_Touch, v_forward * (autocvar_g_monster_zombie_attack_leap_speed) + '0 0 200', (autocvar_g_monster_zombie_attack_leap_delay));
141 void spawnfunc_monster_zombie() { Monster_Spawn(MON_ZOMBIE.monsterid); }
144 bool M_Zombie(int req)
151 if(time >= self.spawn_time)
152 self.damageforcescale = autocvar_g_monster_zombie_damageforcescale;
157 self.pain_finished = time + 0.34;
158 setanim(self, ((random() > 0.5) ? self.anim_pain1 : self.anim_pain2), true, true, false);
163 self.armorvalue = autocvar_g_monsters_armor_blockpercent;
165 setanim(self, ((random() > 0.5) ? self.anim_die1 : self.anim_die2), false, true, true);
172 vector none = '0 0 0';
173 self.anim_die1 = animfixfps(self, '9 1 0.5', none); // 2 seconds
174 self.anim_die2 = animfixfps(self, '12 1 0.5', none); // 2 seconds
175 self.anim_spawn = animfixfps(self, '30 1 3', none);
176 self.anim_walk = animfixfps(self, '27 1 1', none);
177 self.anim_idle = animfixfps(self, '19 1 1', none);
178 self.anim_pain1 = animfixfps(self, '20 1 2', none); // 0.5 seconds
179 self.anim_pain2 = animfixfps(self, '22 1 2', none); // 0.5 seconds
180 self.anim_melee1 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
181 self.anim_melee2 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
182 self.anim_melee3 = animfixfps(self, '4 1 5', none); // analyze models and set framerate
183 self.anim_shoot = animfixfps(self, '0 1 5', none); // analyze models and set framerate
184 self.anim_run = animfixfps(self, '27 1 1', none);
185 self.anim_blockstart = animfixfps(self, '8 1 1', none);
186 self.anim_blockend = animfixfps(self, '7 1 1', none);
194 if(!self.health) self.health = (autocvar_g_monster_zombie_health);
195 if(!self.speed) { self.speed = (autocvar_g_monster_zombie_speed_walk); }
196 if(!self.speed2) { self.speed2 = (autocvar_g_monster_zombie_speed_run); }
197 if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_zombie_speed_stop); }
199 if(self.spawnflags & MONSTERFLAG_NORESPAWN)
200 self.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
202 self.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
204 self.monster_loot = spawnfunc_item_health_medium;
205 self.monster_attackfunc = M_Zombie_Attack;
206 self.spawnshieldtime = self.spawn_time;
207 self.respawntime = 0.2;
208 self.damageforcescale = 0.0001; // no push while spawning
210 setanim(self, self.anim_spawn, false, true, true);
211 self.spawn_time = self.animstate_endtime;
217 precache_model("models/monsters/zombie.dpm");