]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/monsters/monster/tarbaby.qc
Move some more precaching to the client
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / monsters / monster / tarbaby.qc
index 25903b3ef73f7768373555c76a074343719314de..b438de4b5bef1831ee0465f09acf10c0f92f9a7e 100644 (file)
@@ -1,7 +1,14 @@
+#ifndef MENUQC
 // size
 const vector TARBABY_MIN = '-16 -16 -24';
 const vector TARBABY_MAX = '16 16 16';
 
+// model
+string TARBABY_MODEL = "models/monsters/tarbaby.mdl";
+
+#endif
+
+#ifdef SVQC
 // cvars
 float autocvar_g_monster_tarbaby;
 float autocvar_g_monster_tarbaby_health;
@@ -9,31 +16,29 @@ float autocvar_g_monster_tarbaby_speed_walk;
 float autocvar_g_monster_tarbaby_speed_run;
 
 // animations
-#define tarbaby_anim_walk              0
-#define tarbaby_anim_run               1
-#define tarbaby_anim_jump              2
-#define tarbaby_anim_fly               3
-#define tarbaby_anim_explode   4
+const float tarbaby_anim_walk          = 0;
+const float tarbaby_anim_run           = 1;
+const float tarbaby_anim_jump          = 2;
+const float tarbaby_anim_fly           = 3;
+const float tarbaby_anim_explode       = 4;
 
 void tarbaby_think ()
 {
        self.think = tarbaby_think;
-       self.nextthink = time + 0.1;
+       self.nextthink = time + self.ticrate;
        
        monster_move(autocvar_g_monster_tarbaby_speed_run, autocvar_g_monster_tarbaby_speed_walk, 20, tarbaby_anim_run, tarbaby_anim_walk, tarbaby_anim_walk);
 }
 
 void Tar_JumpTouch ()
 {
-       // dunno why this would be called when dead, but to be safe
-       if (self.health <= 0)
-               return;
-               
-       if (other.takedamage)
-       if (vlen(self.velocity) > 200)
+       if(self.health > 0)
+       if(other.health > 0)
+       if(other.takedamage)
+       if(vlen(self.velocity) > 200)
        {
                // make the monster die
-               self.event_damage(self, self, self.health + self.max_health, DEATH_TOUCHEXPLODE, self.origin, '0 0 0');
+               self.event_damage(self, self, self.health + self.max_health + 200, DEATH_MONSTER_TARBABY, self.origin, '0 0 0');
                        
                return;
        }
@@ -53,10 +58,7 @@ void tarbaby_jump ()
 {
        if not(self.flags & FL_ONGROUND)
                return;
-       self.frame = tarbaby_anim_jump;
-       // dunno why this would be called when dead, but to be safe
-       if (self.health <= 0)
-               return;
+       monsters_setframe(tarbaby_anim_jump);
        self.movetype = MOVETYPE_BOUNCE;
        self.touch = Tar_JumpTouch;
        makevectors (self.angles);
@@ -78,7 +80,7 @@ float tbaby_jump ()
 void tarbaby_blowup ()
 {
        float bigboom = 250 * (self.scale * 0.7);
-       RadiusDamage(self, self, 250 * monster_skill, 15, bigboom * (monster_skill * 0.7), world, 250, DEATH_MONSTER_TARBABY_BLOWUP, world);
+       RadiusDamage(self, self, 250 * monster_skill, 15, bigboom * (monster_skill * 0.7), world, 250, DEATH_MONSTER_TARBABY, world);
        pointparticles(particleeffectnum(((self.scale > 3) ? "explosion_big" : "explosion_medium")), self.origin, '0 0 0', 1);
        sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
        
@@ -91,18 +93,24 @@ void tarbaby_explode()
 {
        tarbaby_blowup();
        
+       self.think = Monster_Fade;
+       self.nextthink = time + 0.1;
+       
        monster_hook_death(); // calling this next frame should be ok...
 }
 
 void tarbaby_die ()
 {
-       self.solid                      = SOLID_NOT;
-       self.takedamage         = DAMAGE_NO;
+       self.think                      = tarbaby_explode;
+       self.nextthink          = time + 0.1;
        self.event_damage   = func_null;
        self.movetype           = MOVETYPE_NONE;
        self.enemy                      = world;
-       self.think                      = tarbaby_explode;
-       self.nextthink          = time + 0.1;
+       self.health                     = 0;
+       
+       WaypointSprite_Kill(self.sprite);
+       
+       self.SendFlags          |= MSF_MOVE | MSF_STATUS;
 }
 
 void tarbaby_spawn ()
@@ -117,35 +125,26 @@ void tarbaby_spawn ()
        self.attack_melee               = tarbaby_jump;
        self.nextthink                  = time + random() * 0.5 + 0.1;
        self.think                              = tarbaby_think;
-       self.sprite_height              = 20 * self.scale;
-       self.frame                              = tarbaby_anim_walk;
+       self.sprite_height              = 20;
+       
+       monsters_setframe(tarbaby_anim_walk);
        
        monster_hook_spawn(); // for post-spawn mods
 }
 
 void spawnfunc_monster_tarbaby ()
 {      
-       if not(autocvar_g_monster_tarbaby)
-       {
-               remove(self);
-               return;
-       }
+       if not(autocvar_g_monster_tarbaby) { remove(self); return; }
        
        self.monster_spawnfunc = spawnfunc_monster_tarbaby;
        
-       if(self.spawnflags & MONSTERFLAG_APPEAR)
-       {
-               self.think = func_null;
-               self.nextthink = -1;
-               self.use = Monster_Appear;
+       if(Monster_CheckAppearFlags(self))
                return;
-       }
        
        self.scale = 1.3;
        
        if not (monster_initialize(
-                        "Spawn",
-                        "models/monsters/tarbaby.mdl",
+                        "Spawn", MONSTER_TARBABY,
                         TARBABY_MIN, TARBABY_MAX,
                         FALSE,
                         tarbaby_die, tarbaby_spawn))
@@ -153,9 +152,9 @@ void spawnfunc_monster_tarbaby ()
                remove(self);
                return;
        }
-       
-       precache_sound ("weapons/rocket_impact.wav");
 }
 
 // compatibility with old spawns
 void spawnfunc_monster_spawn () { spawnfunc_monster_tarbaby(); }
+
+#endif // SVQC