-#ifndef ZOMBIE_H
-#define ZOMBIE_H
-
-#ifndef MENUQC
-MODEL(MON_ZOMBIE, M_Model("zombie.dpm"));
-#endif
-
-CLASS(Zombie, Monster)
- ATTRIB(Zombie, spawnflags, int, MON_FLAG_MELEE | MON_FLAG_RIDE);
- ATTRIB(Zombie, mins, vector, '-18 -18 -25');
- ATTRIB(Zombie, maxs, vector, '18 18 47');
-#ifndef MENUQC
- ATTRIB(Zombie, m_model, Model, MDL_MON_ZOMBIE);
-#endif
- ATTRIB(Zombie, netname, string, "zombie");
- ATTRIB(Zombie, monster_name, string, _("Zombie"));
-ENDCLASS(Zombie)
-
-REGISTER_MONSTER(ZOMBIE, NEW(Zombie)) {
-#ifndef MENUQC
- this.mr_precache(this);
-#endif
-}
-
-#endif
-
-#ifdef IMPLEMENTATION
+#include "zombie.qh"
#ifdef SVQC
float autocvar_g_monster_zombie_health;
float autocvar_g_monster_zombie_speed_run;
float autocvar_g_monster_zombie_speed_walk;
-/*
-const float zombie_anim_attackleap = 0;
-const float zombie_anim_attackrun1 = 1;
-const float zombie_anim_attackrun2 = 2;
-const float zombie_anim_attackrun3 = 3;
-const float zombie_anim_attackstanding1 = 4;
-const float zombie_anim_attackstanding2 = 5;
-const float zombie_anim_attackstanding3 = 6;
-const float zombie_anim_blockend = 7;
-const float zombie_anim_blockstart = 8;
-const float zombie_anim_deathback1 = 9;
-const float zombie_anim_deathback2 = 10;
-const float zombie_anim_deathback3 = 11;
-const float zombie_anim_deathfront1 = 12;
-const float zombie_anim_deathfront2 = 13;
-const float zombie_anim_deathfront3 = 14;
-const float zombie_anim_deathleft1 = 15;
-const float zombie_anim_deathleft2 = 16;
-const float zombie_anim_deathright1 = 17;
-const float zombie_anim_deathright2 = 18;
-const float zombie_anim_idle = 19;
-const float zombie_anim_painback1 = 20;
-const float zombie_anim_painback2 = 21;
-const float zombie_anim_painfront1 = 22;
-const float zombie_anim_painfront2 = 23;
-const float zombie_anim_runbackwards = 24;
-const float zombie_anim_runbackwardsleft = 25;
-const float zombie_anim_runbackwardsright = 26;
-const float zombie_anim_runforward = 27;
-const float zombie_anim_runforwardleft = 28;
-const float zombie_anim_runforwardright = 29;
-const float zombie_anim_spawn = 30;
-*/
-
.vector moveto;
void M_Zombie_Attack_Leap_Touch(entity this, entity toucher)
{
- if (this.health <= 0)
+ if (GetResource(this, RES_HEALTH) <= 0)
return;
vector angles_face;
{
angles_face = vectoangles(this.moveto - this.origin);
angles_face = normalize(angles_face) * (autocvar_g_monster_zombie_attack_leap_force);
- Damage(toucher, this, this, (autocvar_g_monster_zombie_attack_leap_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_ZOMBIE_JUMP.m_id, toucher.origin, angles_face);
+ Damage(toucher, this, this, (autocvar_g_monster_zombie_attack_leap_damage) * MONSTER_SKILLMOD(this), DEATH_MONSTER_ZOMBIE_JUMP.m_id, DMG_NOWEP, toucher.origin, angles_face);
settouch(this, Monster_Touch); // instantly turn it off to stop damage spam
this.state = 0;
}
void M_Zombie_Defend_Block_End(entity this)
{
- if(this.health <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
setanim(this, this.anim_blockend, false, true, true);
- this.armorvalue = autocvar_g_monsters_armor_blockpercent;
+ SetResourceExplicit(this, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
}
bool M_Zombie_Defend_Block(entity this)
{
- this.armorvalue = 0.9;
+ SetResourceExplicit(this, RES_ARMOR, 0.9);
this.state = MONSTER_ATTACK_MELEE; // freeze monster
this.attack_finished_single[0] = time + 2.1;
this.anim_finished = this.attack_finished_single[0];
return true;
}
-bool M_Zombie_Attack(int attack_type, entity actor, entity targ)
+bool M_Zombie_Attack(int attack_type, entity actor, entity targ, .entity weaponentity)
{
switch(attack_type)
{
case MONSTER_ATTACK_MELEE:
{
- if(random() < 0.3 && actor.health < 75 && actor.enemy.health > 10)
+ if(random() < 0.3 && GetResource(actor, RES_HEALTH) < 75 && GetResource(actor.enemy, RES_HEALTH) > 10)
return M_Zombie_Defend_Block(actor);
float anim_chance = random();
return false;
}
-spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); }
+spawnfunc(monster_zombie) { Monster_Spawn(this, true, MON_ZOMBIE); }
#endif // SVQC
#ifdef SVQC
{
TC(Zombie, this);
actor.pain_finished = time + 0.34;
- setanim(actor, ((random() > 0.5) ? actor.anim_pain1 : actor.anim_pain2), true, true, false);
+ if(time >= actor.spawn_time)
+ setanim(actor, ((random() > 0.5) ? actor.anim_pain1 : actor.anim_pain2), true, true, false);
return damage_take;
}
METHOD(Zombie, mr_death, bool(Zombie this, entity actor))
{
TC(Zombie, this);
- actor.armorvalue = autocvar_g_monsters_armor_blockpercent;
+ SetResourceExplicit(actor, RES_ARMOR, autocvar_g_monsters_armor_blockpercent);
setanim(actor, ((random() > 0.5) ? actor.anim_die1 : actor.anim_die2), false, true, true);
return true;
}
#endif
-#ifndef MENUQC
+#ifdef GAMEQC
METHOD(Zombie, mr_anim, bool(Zombie this, entity actor))
{
TC(Zombie, this);
METHOD(Zombie, mr_setup, bool(Zombie this, entity actor))
{
TC(Zombie, this);
- if(!actor.health) actor.health = (autocvar_g_monster_zombie_health);
+ if(!GetResource(actor, RES_HEALTH)) SetResourceExplicit(actor, RES_HEALTH, autocvar_g_monster_zombie_health);
if(!actor.speed) { actor.speed = (autocvar_g_monster_zombie_speed_walk); }
if(!actor.speed2) { actor.speed2 = (autocvar_g_monster_zombie_speed_run); }
if(!actor.stopspeed) { actor.stopspeed = (autocvar_g_monster_zombie_speed_stop); }
if(actor.spawnflags & MONSTERFLAG_NORESPAWN)
actor.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn
+ actor.spawnflags &= ~MONSTERFLAG_APPEAR; // once it's appeared, it will respawn quickly, we don't want it to appear
+
actor.spawnflags |= MONSTER_RESPAWN_DEATHPOINT;
- actor.monster_loot = spawnfunc_item_health_medium;
+ actor.monster_loot = ITEM_HealthMedium;
actor.monster_attackfunc = M_Zombie_Attack;
- actor.spawnshieldtime = actor.spawn_time;
+ StatusEffects_apply(STATUSEFFECT_SpawnShield, actor, actor.spawn_time, 0);
actor.respawntime = 0.2;
actor.damageforcescale = 0.0001; // no push while spawning
return true;
}
-
-METHOD(Zombie, mr_precache, bool(Zombie this))
-{
- TC(Zombie, this);
- return true;
-}
-#endif
-
#endif