]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a system for monster sounds & some sounds for zombie
authorMario <mario.mario@y7mail.com>
Mon, 4 Mar 2013 08:28:53 +0000 (19:28 +1100)
committerMario <mario.mario@y7mail.com>
Mon, 4 Mar 2013 08:28:53 +0000 (19:28 +1100)
qcsrc/server/monsters/lib/defs.qh
qcsrc/server/monsters/lib/monsters.qc
qcsrc/server/monsters/monster/shalrath.qc
qcsrc/server/monsters/monster/soldier.qc
qcsrc/server/monsters/monster/zombie.qc
sound/monsters/zombie_death.ogg [new file with mode: 0644]
sound/monsters/zombie_idle.ogg [new file with mode: 0644]
sound/monsters/zombie_sight.ogg [new file with mode: 0644]

index a795bab7df62e68b493c6b6b82329d0c1b5d311f..78852632bd51b36a10a59db7281010e6f6b71092 100644 (file)
@@ -23,6 +23,15 @@ const float MONSTERFLAG_APPEAR = 256; // delay spawn until triggered
 const float MONSTERFLAG_GIANT = 512; // experimental giant monsters feature
 const float MONSTERFLAG_SPAWNED = 1024; // flag for spawned monsters
 
+.float msound_delay; // restricts some monster sounds
+.string msound_idle;
+.string msound_death;
+.string msound_attack_melee;
+.string msound_attack_ranged;
+.string msound_spawn;
+.string msound_sight;
+.string msound_pain;
+
 .void() monster_spawnfunc;
 .void() monster_die;
 .void() monster_delayedattack;
index a5651c25e32bc635aedaacd8d0c32d3d8ecfa440..957017c119409f100c6560a3c9244054cbe2a8c3 100644 (file)
@@ -162,6 +162,29 @@ void MonsterTouch ()
                self.enemy = other;
 }
 
+void monster_sound(string msound, float sound_delay, float delaytoo)
+{
+       if(delaytoo && time < self.msound_delay)
+               return; // too early
+               
+       if(msound == "")
+               return; // sound doesn't exist
+
+       sound(self, CH_PAIN_SINGLE, msound, VOL_BASE, ATTN_NORM);
+
+       self.msound_delay = time + sound_delay;
+}
+
+void monster_precachesounds()
+{
+       precache_sound(self.msound_idle);
+       precache_sound(self.msound_death);
+       precache_sound(self.msound_attack_melee);
+       precache_sound(self.msound_attack_ranged);
+       precache_sound(self.msound_sight);
+       precache_sound(self.msound_pain);
+}
+
 void monster_melee (entity targ, float damg, float er, float deathtype)
 {
        float bigdmg = 0, rdmg = damg * random();
@@ -334,20 +357,26 @@ float GenericCheckAttack ()
        if(self.attack_melee)
        if(enemy_range() <= 100 * self.scale)
        {
+               monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
                self.attack_melee(); // don't wait for nextthink - too slow
                return TRUE;
        }
        
        // monster doesn't have a ranged attack function, so stop here
-       if(!self.attack_ranged)
+       if not(self.attack_ranged)
                return FALSE;
 
        // see if any entities are in the way of the shot
-       if (!findtrajectorywithleading(self.origin, '0 0 0', '0 0 0', self.enemy, 800, 0, 2.5, 0, self))
+       if not(findtrajectorywithleading(self.origin, '0 0 0', '0 0 0', self.enemy, 800, 0, 2.5, 0, self))
                return FALSE;
 
-       self.attack_ranged(); // don't wait for nextthink - too slow
-       return TRUE;
+       if(self.attack_ranged())
+       {
+               monster_sound(self.msound_attack_ranged, 0, FALSE); // no delay for attack sounds
+               return TRUE;
+       }
+
+       return FALSE;
 }
 
 void monster_use ()
@@ -505,7 +534,11 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                self.enemy = world;
                
        if not(self.enemy)
+       {
                self.enemy = FindTarget(self);
+               if(self.enemy)
+                       monster_sound(self.msound_sight, 0, FALSE);
+       }
                
        if(time >= self.last_trace)
        {
@@ -515,6 +548,9 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                        self.last_trace = time + 0.5;
                self.moveto = monster_pickmovetarget(targ);
        }
+
+       if not(self.enemy)
+               monster_sound(self.msound_idle, 5, TRUE);
        
        vector angles_face = vectoangles(self.moveto - self.origin);
        vector owner_face = vectoangles(self.monster_owner.origin - self.origin);
@@ -639,6 +675,8 @@ void monster_hook_death()
        if(self.sprite)
         WaypointSprite_Kill(self.sprite);
                
+       monster_sound(self.msound_death, 0, FALSE);
+               
        if(!(self.spawnflags & MONSTERFLAG_SPAWNED) && !self.monster_respawned)
                monsters_killed += 1;
                
@@ -658,6 +696,8 @@ void monster_hook_spawn()
 
        self.max_health = self.health;
        self.pain_finished = self.nextthink;
+
+       monster_precachesounds();
        
        if(teamplay && self.team)
        {
@@ -678,6 +718,8 @@ void monster_hook_spawn()
                WaypointSprite_UpdateHealth(self.sprite, self.health);
        }
        
+       monster_sound(self.msound_spawn, 0, FALSE);
+
        MUTATOR_CALLHOOK(MonsterSpawn);
 }
 
index 13d5282b016e15df59e6a2cad378305e15215748..d43a0cf9dcc18e941edec9e771b3841e4aec0e17 100644 (file)
@@ -165,6 +165,7 @@ float ShalrathCheckAttack ()
        {       // melee attack
                if (self.attack_melee)
                {
+                       monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
                        self.attack_melee();
                        return TRUE;
                }
index 8e7870ca15c4bfc7d666c6f928171c73fdc3cf57..7c90d595faf12cb6f9e644f2af2f334c02f029d1 100644 (file)
@@ -128,6 +128,7 @@ float SoldierCheckAttack ()
                
        if(self.currentammo <= 0 && enemy_range() <= 120)
        {
+               monster_sound(self.msound_attack_melee, 0, FALSE); // no delay for attack sounds
                self.attack_melee();
                return TRUE;
        }
index 566d36f73b8770a8b0cab13fce603c00229adcf6..4c4ee297c49e21061ace14a13f7ab0d6da3d0f53 100644 (file)
@@ -170,6 +170,14 @@ void zombie_spawn()
        self.attack_ranged              = zombie_attack_ranged;
        self.skin                               = rint(random() * 4);
        
+       // some sounds
+       if(self.msound_idle == "") self.msound_idle = "monsters/zombie_idle.wav";
+       if(self.msound_death == "") self.msound_death = "monsters/zombie_death.wav";
+       if(self.msound_pain == "") self.msound_pain = "monsters/zombie_pain.wav";
+       if(self.msound_attack_melee == "") self.msound_attack_melee = "monsters/zombie_melee.wav";
+       if(self.msound_attack_ranged == "") self.msound_attack_ranged = "monsters/zombie_attack.wav";
+       if(self.msound_sight == "") self.msound_sight = "monsters/zombie_sight.wav";
+       
        monster_hook_spawn(); // for post-spawn mods
 }
 
diff --git a/sound/monsters/zombie_death.ogg b/sound/monsters/zombie_death.ogg
new file mode 100644 (file)
index 0000000..7af422e
Binary files /dev/null and b/sound/monsters/zombie_death.ogg differ
diff --git a/sound/monsters/zombie_idle.ogg b/sound/monsters/zombie_idle.ogg
new file mode 100644 (file)
index 0000000..3dac288
Binary files /dev/null and b/sound/monsters/zombie_idle.ogg differ
diff --git a/sound/monsters/zombie_sight.ogg b/sound/monsters/zombie_sight.ogg
new file mode 100644 (file)
index 0000000..c033a9e
Binary files /dev/null and b/sound/monsters/zombie_sight.ogg differ