1 #ifdef REGISTER_MONSTER
4 /* function */ m_zombie,
5 /* spawnflags */ MON_FLAG_MELEE,
6 /* mins,maxs */ '-18 -18 -25', '18 18 47',
7 /* model */ "zombie.dpm",
8 /* netname */ "zombie",
9 /* fullname */ _("Zombie")
14 float autocvar_g_monster_zombie_health;
15 float autocvar_g_monster_zombie_attack_melee_damage;
16 float autocvar_g_monster_zombie_attack_melee_delay;
17 float autocvar_g_monster_zombie_attack_leap_damage;
18 float autocvar_g_monster_zombie_attack_leap_force;
19 float autocvar_g_monster_zombie_attack_leap_speed;
20 float autocvar_g_monster_zombie_attack_leap_delay;
21 float autocvar_g_monster_zombie_speed_stop;
22 float autocvar_g_monster_zombie_speed_run;
23 float autocvar_g_monster_zombie_speed_walk;
25 const float zombie_anim_attackleap = 0;
26 const float zombie_anim_attackrun1 = 1;
27 const float zombie_anim_attackrun2 = 2;
28 const float zombie_anim_attackrun3 = 3;
29 const float zombie_anim_attackstanding1 = 4;
30 const float zombie_anim_attackstanding2 = 5;
31 const float zombie_anim_attackstanding3 = 6;
32 const float zombie_anim_blockend = 7;
33 const float zombie_anim_blockstart = 8;
34 const float zombie_anim_deathback1 = 9;
35 const float zombie_anim_deathback2 = 10;
36 const float zombie_anim_deathback3 = 11;
37 const float zombie_anim_deathfront1 = 12;
38 const float zombie_anim_deathfront2 = 13;
39 const float zombie_anim_deathfront3 = 14;
40 const float zombie_anim_deathleft1 = 15;
41 const float zombie_anim_deathleft2 = 16;
42 const float zombie_anim_deathright1 = 17;
43 const float zombie_anim_deathright2 = 18;
44 const float zombie_anim_idle = 19;
45 const float zombie_anim_painback1 = 20;
46 const float zombie_anim_painback2 = 21;
47 const float zombie_anim_painfront1 = 22;
48 const float zombie_anim_painfront2 = 23;
49 const float zombie_anim_runbackwards = 24;
50 const float zombie_anim_runbackwardsleft = 25;
51 const float zombie_anim_runbackwardsright = 26;
52 const float zombie_anim_runforward = 27;
53 const float zombie_anim_runforwardleft = 28;
54 const float zombie_anim_runforwardright = 29;
55 const float zombie_anim_spawn = 30;
57 void zombie_attack_leap_touch()
66 angles_face = vectoangles(self.moveto - self.origin);
67 angles_face = normalize(angles_face) * (autocvar_g_monster_zombie_attack_leap_force);
68 Damage(other, self, self, (autocvar_g_monster_zombie_attack_leap_damage) * Monster_SkillModifier(), DEATH_MONSTER_ZOMBIE_JUMP, other.origin, angles_face);
69 self.touch = MonsterTouch; // instantly turn it off to stop damage spam
72 if (trace_dphitcontents)
73 self.touch = MonsterTouch;
76 void zombie_blockend()
81 self.frame = zombie_anim_blockend;
83 self.m_armor_blockpercent = autocvar_g_monsters_armor_blockpercent;
88 self.frame = zombie_anim_blockstart;
89 self.armorvalue = 100;
90 self.m_armor_blockpercent = 0.9;
91 self.state = MONSTER_STATE_ATTACK_MELEE; // freeze monster
92 self.attack_finished_single = time + 2.1;
94 defer(2, zombie_blockend);
99 float zombie_attack(float attack_type)
103 case MONSTER_ATTACK_MELEE:
105 float rand = random(), chosen_anim;
108 chosen_anim = zombie_anim_attackstanding1;
110 chosen_anim = zombie_anim_attackstanding2;
112 chosen_anim = zombie_anim_attackstanding3;
114 if(random() < 0.3 && self.health < 75 && self.enemy.health > 10)
115 return zombie_block();
117 return monster_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);
119 case MONSTER_ATTACK_RANGED:
121 makevectors(self.angles);
122 return monster_leap(zombie_anim_attackleap, zombie_attack_leap_touch, v_forward * (autocvar_g_monster_zombie_attack_leap_speed) + '0 0 200', (autocvar_g_monster_zombie_attack_leap_delay));
129 void spawnfunc_monster_zombie()
131 self.classname = "monster_zombie";
133 self.monster_spawnfunc = spawnfunc_monster_zombie;
135 self.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
137 if(Monster_CheckAppearFlags(self))
140 if(!monster_initialize(MON_ZOMBIE, FALSE)) { remove(self); return; }
143 float m_zombie(float req)
149 monster_move((autocvar_g_monster_zombie_speed_run), (autocvar_g_monster_zombie_speed_walk), (autocvar_g_monster_zombie_speed_stop), zombie_anim_runforward, zombie_anim_runforward, zombie_anim_idle);
155 self.m_armor_blockpercent = autocvar_g_monsters_armor_blockpercent;
156 self.frame = ((random() > 0.5) ? zombie_anim_deathback1 : zombie_anim_deathfront1);
161 if(!self.health) self.health = (autocvar_g_monster_zombie_health);
163 if(self.spawnflags & MONSTERFLAG_NORESPAWN)
164 self.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
166 self.monster_loot = spawnfunc_item_health_medium;
167 self.monster_attackfunc = zombie_attack;
168 self.frame = zombie_anim_spawn;
169 self.spawn_time = time + 2.1;
170 self.spawnshieldtime = self.spawn_time;
171 self.respawntime = 0.2;
177 precache_model ("models/monsters/zombie.dpm");
187 float m_zombie(float req)
193 precache_model ("models/monsters/zombie.dpm");
202 #endif // REGISTER_MONSTER