X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fmonster%2Fzombie.qc;h=578cf4c59cf57628d28a7d9e5a4795e74e1f0edd;hb=5eea97bc262bfaf271817ca034439ad551f691d4;hp=ef9aa06cb009df05b57891b7c7c49c129353484a;hpb=3589bb7872babf0ee489a54c85c9213562c1ffe9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/monster/zombie.qc b/qcsrc/common/monsters/monster/zombie.qc index ef9aa06cb..578cf4c59 100644 --- a/qcsrc/common/monsters/monster/zombie.qc +++ b/qcsrc/common/monsters/monster/zombie.qc @@ -2,7 +2,7 @@ #define ZOMBIE_H #ifndef MENUQC -MODEL(MON_ZOMBIE, "models/monsters/zombie.dpm"); +MODEL(MON_ZOMBIE, M_Model("zombie.dpm")); #endif CLASS(Zombie, Monster) @@ -73,8 +73,10 @@ const float zombie_anim_runforwardright = 29; const float zombie_anim_spawn = 30; */ -void M_Zombie_Attack_Leap_Touch() -{SELFPARAM(); +.vector moveto; + +void M_Zombie_Attack_Leap_Touch(entity this) +{ if (self.health <= 0) return; @@ -85,148 +87,152 @@ void M_Zombie_Attack_Leap_Touch() angles_face = vectoangles(self.moveto - self.origin); angles_face = normalize(angles_face) * (autocvar_g_monster_zombie_attack_leap_force); Damage(other, self, self, (autocvar_g_monster_zombie_attack_leap_damage) * MONSTER_SKILLMOD(self), DEATH_MONSTER_ZOMBIE_JUMP.m_id, other.origin, angles_face); - self.touch = Monster_Touch; // instantly turn it off to stop damage spam + settouch(self, Monster_Touch); // instantly turn it off to stop damage spam self.state = 0; } if (trace_dphitcontents) { self.state = 0; - self.touch = Monster_Touch; + settouch(self, Monster_Touch); } } -void M_Zombie_Defend_Block_End() -{SELFPARAM(); - if(self.health <= 0) +void M_Zombie_Defend_Block_End(entity this) +{ + if(this.health <= 0) return; - setanim(self, self.anim_blockend, false, true, true); - self.armorvalue = autocvar_g_monsters_armor_blockpercent; + setanim(this, this.anim_blockend, false, true, true); + this.armorvalue = autocvar_g_monsters_armor_blockpercent; } -float M_Zombie_Defend_Block() -{SELFPARAM(); - self.armorvalue = 0.9; - self.state = MONSTER_ATTACK_MELEE; // freeze monster - self.attack_finished_single = time + 2.1; - self.anim_finished = self.attack_finished_single; - setanim(self, self.anim_blockstart, false, true, true); +bool M_Zombie_Defend_Block(entity this) +{ + this.armorvalue = 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]; + setanim(this, this.anim_blockstart, false, true, true); - Monster_Delay(1, 0, 2, M_Zombie_Defend_Block_End); + Monster_Delay(this, 1, 2, M_Zombie_Defend_Block_End); return true; } -float M_Zombie_Attack(float attack_type, entity targ) -{SELFPARAM(); +bool M_Zombie_Attack(int attack_type, entity actor, entity targ) +{ switch(attack_type) { case MONSTER_ATTACK_MELEE: { - if(random() < 0.3 && self.health < 75 && self.enemy.health > 10) - return M_Zombie_Defend_Block(); + if(random() < 0.3 && actor.health < 75 && actor.enemy.health > 10) + return M_Zombie_Defend_Block(actor); - float rand = random(); + float anim_chance = random(); vector chosen_anim; - if(rand < 0.33) - chosen_anim = self.anim_melee1; - else if(rand < 0.66) - chosen_anim = self.anim_melee2; + if(anim_chance < 0.33) + chosen_anim = actor.anim_melee1; + else if(anim_chance < 0.66) + chosen_anim = actor.anim_melee2; else - chosen_anim = self.anim_melee3; + chosen_anim = actor.anim_melee3; - 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.m_id, true); + return Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_zombie_attack_melee_damage), chosen_anim, actor.attack_range, (autocvar_g_monster_zombie_attack_melee_delay), DEATH_MONSTER_ZOMBIE_MELEE.m_id, true); } case MONSTER_ATTACK_RANGED: { - makevectors(self.angles); - 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)); + makevectors(actor.angles); + return Monster_Attack_Leap(actor, actor.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)); } } return false; } -spawnfunc(monster_zombie) { Monster_Spawn(MON_ZOMBIE.monsterid); } +spawnfunc(monster_zombie) { Monster_Spawn(this, MON_ZOMBIE.monsterid); } #endif // SVQC - #ifdef SVQC - METHOD(Zombie, mr_think, bool(Zombie thismon)) - { - SELFPARAM(); - if(time >= self.spawn_time) - self.damageforcescale = autocvar_g_monster_zombie_damageforcescale; - return true; - } - METHOD(Zombie, mr_pain, bool(Zombie thismon)) - { - SELFPARAM(); - self.pain_finished = time + 0.34; - setanim(self, ((random() > 0.5) ? self.anim_pain1 : self.anim_pain2), true, true, false); - return true; - } - METHOD(Zombie, mr_death, bool(Zombie thismon)) - { - SELFPARAM(); - self.armorvalue = autocvar_g_monsters_armor_blockpercent; +#ifdef SVQC +METHOD(Zombie, mr_think, bool(Zombie this, entity actor)) +{ + TC(Zombie, this); + if(time >= actor.spawn_time) + actor.damageforcescale = autocvar_g_monster_zombie_damageforcescale; + return true; +} - setanim(self, ((random() > 0.5) ? self.anim_die1 : self.anim_die2), false, true, true); - return true; - } - #endif - #ifndef MENUQC - METHOD(Zombie, mr_anim, bool(Zombie thismon)) - { - SELFPARAM(); - vector none = '0 0 0'; - self.anim_die1 = animfixfps(self, '9 1 0.5', none); // 2 seconds - self.anim_die2 = animfixfps(self, '12 1 0.5', none); // 2 seconds - self.anim_spawn = animfixfps(self, '30 1 3', none); - self.anim_walk = animfixfps(self, '27 1 1', none); - self.anim_idle = animfixfps(self, '19 1 1', none); - self.anim_pain1 = animfixfps(self, '20 1 2', none); // 0.5 seconds - self.anim_pain2 = animfixfps(self, '22 1 2', none); // 0.5 seconds - self.anim_melee1 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_melee2 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_melee3 = animfixfps(self, '4 1 5', none); // analyze models and set framerate - self.anim_shoot = animfixfps(self, '0 1 5', none); // analyze models and set framerate - self.anim_run = animfixfps(self, '27 1 1', none); - self.anim_blockstart = animfixfps(self, '8 1 1', none); - self.anim_blockend = animfixfps(self, '7 1 1', none); - - return true; - } - #endif - #ifdef SVQC - METHOD(Zombie, mr_setup, bool(Zombie thismon)) - { - if(!self.health) self.health = (autocvar_g_monster_zombie_health); - if(!self.speed) { self.speed = (autocvar_g_monster_zombie_speed_walk); } - if(!self.speed2) { self.speed2 = (autocvar_g_monster_zombie_speed_run); } - if(!self.stopspeed) { self.stopspeed = (autocvar_g_monster_zombie_speed_stop); } +METHOD(Zombie, mr_pain, float(Zombie this, entity actor, float damage_take, entity attacker, float deathtype)) +{ + TC(Zombie, this); + actor.pain_finished = time + 0.34; + 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; - if(self.spawnflags & MONSTERFLAG_NORESPAWN) - self.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn + setanim(actor, ((random() > 0.5) ? actor.anim_die1 : actor.anim_die2), false, true, true); + return true; +} +#endif +#ifndef MENUQC +METHOD(Zombie, mr_anim, bool(Zombie this, entity actor)) +{ + TC(Zombie, this); + vector none = '0 0 0'; + actor.anim_die1 = animfixfps(actor, '9 1 0.5', none); // 2 seconds + actor.anim_die2 = animfixfps(actor, '12 1 0.5', none); // 2 seconds + actor.anim_spawn = animfixfps(actor, '30 1 3', none); + actor.anim_walk = animfixfps(actor, '27 1 1', none); + actor.anim_idle = animfixfps(actor, '19 1 1', none); + actor.anim_pain1 = animfixfps(actor, '20 1 2', none); // 0.5 seconds + actor.anim_pain2 = animfixfps(actor, '22 1 2', none); // 0.5 seconds + actor.anim_melee1 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_melee2 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_melee3 = animfixfps(actor, '4 1 5', none); // analyze models and set framerate + actor.anim_shoot = animfixfps(actor, '0 1 5', none); // analyze models and set framerate + actor.anim_run = animfixfps(actor, '27 1 1', none); + actor.anim_blockstart = animfixfps(actor, '8 1 1', none); + actor.anim_blockend = animfixfps(actor, '7 1 1', none); + return true; +} +#endif +#ifdef SVQC +METHOD(Zombie, mr_setup, bool(Zombie this, entity actor)) +{ + TC(Zombie, this); + if(!actor.health) actor.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); } - self.spawnflags |= MONSTER_RESPAWN_DEATHPOINT; + if(actor.spawnflags & MONSTERFLAG_NORESPAWN) + actor.spawnflags &= ~MONSTERFLAG_NORESPAWN; // zombies always respawn - self.monster_loot = spawnfunc_item_health_medium; - self.monster_attackfunc = M_Zombie_Attack; - self.spawnshieldtime = self.spawn_time; - self.respawntime = 0.2; - self.damageforcescale = 0.0001; // no push while spawning + actor.spawnflags |= MONSTER_RESPAWN_DEATHPOINT; - setanim(self, self.anim_spawn, false, true, true); - self.spawn_time = self.animstate_endtime; + actor.monster_loot = spawnfunc_item_health_medium; + actor.monster_attackfunc = M_Zombie_Attack; + actor.spawnshieldtime = actor.spawn_time; + actor.respawntime = 0.2; + actor.damageforcescale = 0.0001; // no push while spawning - return true; - } - METHOD(Zombie, mr_precache, bool(Zombie thismon)) - { - return true; - } - #endif + setanim(actor, actor.anim_spawn, false, true, true); + actor.spawn_time = actor.animstate_endtime; + + return true; +} + +METHOD(Zombie, mr_precache, bool(Zombie this)) +{ + TC(Zombie, this); + return true; +} +#endif #endif