]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/sv_monsters.qc
GlobalSound: register player sounds
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / sv_monsters.qc
index 34bd6e5aa4cffb64c6de7793a873143f9c2d89a1..702e8ee39d010bc67d77dff3b4f5118d9485421c 100644 (file)
@@ -1,9 +1,7 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-       #include "../../dpdefs/progsdefs.qh"
-    #include "../../dpdefs/dpextensions.qh"
-    #include "../../warpzonelib/common.qh"
+    #include "../../lib/warpzone/common.qh"
     #include "../constants.qh"
     #include "../teams.qh"
     #include "../util.qh"
@@ -12,8 +10,8 @@
     #include "../weapons/all.qh"
     #include "../../server/autocvars.qh"
     #include "../../server/defs.qh"
-    #include "../deathtypes.qh"
-    #include "../../server/mutators/mutators_include.qh"
+    #include "../deathtypes/all.qh"
+    #include "../../server/mutators/all.qh"
        #include "../../server/steerlib.qh"
        #include "../turrets/sv_turrets.qh"
        #include "../turrets/util.qh"
@@ -22,7 +20,7 @@
     #include "../../server/command/common.qh"
     #include "../../server/command/cmd.qh"
        #include "../triggers/triggers.qh"
-    #include "../../csqcmodellib/sv_model.qh"
+    #include "../../lib/csqcmodel/sv_model.qh"
     #include "../../server/round_handler.qh"
 #endif
 
@@ -38,7 +36,8 @@ void monster_dropitem()
                return;
 
        vector org = self.origin + ((self.mins + self.maxs) * 0.5);
-       entity e = spawn();
+       entity e = new(droppedweapon); // use weapon handling to remove it on touch
+       e.spawnfunc_checked = true;
 
        e.monster_loot = self.monster_loot;
 
@@ -49,14 +48,13 @@ void monster_dropitem()
        {
                setself(e);
                e.noalign = true;
-               e.monster_loot();
+               e.monster_loot(e);
                e.gravity = 1;
                e.movetype = MOVETYPE_TOSS;
                e.reset = SUB_Remove;
                setorigin(e, org);
                e.velocity = randomvec() * 175 + '0 0 325';
                e.item_spawnshieldtime = time + 0.7;
-               e.classname = "droppedweapon"; // use weapon handling to remove it on touch
                SUB_SetFade(e, time + autocvar_g_monsters_drop_time, 1);
                setself(this);
        }
@@ -118,7 +116,7 @@ bool Monster_ValidTarget(entity mon, entity player)
                makevectors (mon.angles);
                dot = normalize (player.origin - mon.origin) * v_forward;
 
-               if(dot <= 0.3) { return false; }
+               if(dot <= autocvar_g_monsters_target_infront_range) { return false; }
        }
 
        return true; // this target is valid!
@@ -348,7 +346,7 @@ void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float
        if(delaytoo)
        if(time < self.msound_delay)
                return; // too early
-       GlobalSound(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+       GlobalSound_string(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
 
        self.msound_delay = time + sound_delay;
 }
@@ -365,9 +363,9 @@ float Monster_Attack_Melee(entity targ, float damg, vector anim, float er, float
        setanim(self, anim, false, true, false);
 
        if(self.animstate_endtime > time && (self.flags & FL_MONSTER))
-               self.attack_finished_single = self.anim_finished = self.animstate_endtime;
+               self.attack_finished_single[0] = self.anim_finished = self.animstate_endtime;
        else
-               self.attack_finished_single = self.anim_finished = time + animtime;
+               self.attack_finished_single[0] = self.anim_finished = time + animtime;
 
        monster_makevectors(targ);
 
@@ -387,7 +385,7 @@ float Monster_Attack_Leap_Check(vector vel)
                return false; // not on the ground
        if(self.health <= 0)
                return false; // called when dead?
-       if(time < self.attack_finished_single)
+       if(time < self.attack_finished_single[0])
                return false; // still attacking
 
        vector old = self.velocity;
@@ -409,9 +407,9 @@ bool Monster_Attack_Leap(vector anm, void() touchfunc, vector vel, float animtim
        setanim(self, anm, false, true, false);
 
        if(self.animstate_endtime > time && (self.flags & FL_MONSTER))
-               self.attack_finished_single = self.anim_finished = self.animstate_endtime;
+               self.attack_finished_single[0] = self.anim_finished = self.animstate_endtime;
        else
-               self.attack_finished_single = self.anim_finished = time + animtime;
+               self.attack_finished_single[0] = self.anim_finished = time + animtime;
 
        if(self.flags & FL_MONSTER)
                self.state = MONSTER_ATTACK_RANGED;
@@ -427,7 +425,7 @@ void Monster_Attack_Check(entity e, entity targ)
 {
        if((e == world || targ == world)
        || (!e.monster_attackfunc)
-       || (time < e.attack_finished_single)
+       || (time < e.attack_finished_single[0])
        ) { return; }
 
        float targ_vlen = vlen(targ.origin - e.origin);
@@ -572,7 +570,6 @@ vector Monster_Move_Target(entity targ)
                        || (self.enemy.takedamage == DAMAGE_NO)
                        || (vlen(self.origin - targ_origin) > self.target_range)
                        || ((trace_fraction < 1) && (trace_ent != self.enemy)))
-                       //|| (time > self.ctf_droptime + autocvar_g_ctf_pass_timelimit)) // TODO: chase timelimit?
                {
                        self.enemy = world;
                        self.pass_distance = 0;
@@ -743,7 +740,7 @@ void Monster_Move(float runspeed, float walkspeed, float stpspeed)
                        Unfreeze(self);
                        self.health = 0;
                        if(self.event_damage)
-                               self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE, self.origin, '0 0 0');
+                               self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE.m_id, self.origin, '0 0 0');
                }
 
                else if ( self.revive_progress <= 0 )
@@ -760,7 +757,7 @@ void Monster_Move(float runspeed, float walkspeed, float stpspeed)
                        {
                                self.last_trace = time + 0.4;
 
-                               Damage (self, world, world, 2, DEATH_DROWN, self.origin, '0 0 0');
+                               Damage (self, world, world, 2, DEATH_DROWN.m_id, self.origin, '0 0 0');
                                self.angles = '90 90 0';
                                if(random() < 0.5)
                                {
@@ -847,7 +844,7 @@ void Monster_Move(float runspeed, float walkspeed, float stpspeed)
                self.touch = Monster_Touch;
        }
 
-       if(self.state && time >= self.attack_finished_single)
+       if(self.state && time >= self.attack_finished_single[0])
                self.state = 0; // attack is over
 
        if(self.state != MONSTER_ATTACK_MELEE) // don't move if set
@@ -913,12 +910,13 @@ void Monster_Move(float runspeed, float walkspeed, float stpspeed)
 
 void Monster_Remove(entity mon)
 {
+       .entity weaponentity = weaponentities[0];
        if(!mon) { return; }
 
        if(!MUTATOR_CALLHOOK(MonsterRemove, mon))
                Send_Effect(EFFECT_ITEM_PICKUP, mon.origin, '0 0 0', 1);
 
-       if(mon.weaponentity) { remove(mon.weaponentity); }
+       if(mon.(weaponentity)) { remove(mon.(weaponentity)); }
        if(mon.iceblock) { remove(mon.iceblock); }
        WaypointSprite_Kill(mon.sprite);
        remove(mon);
@@ -968,7 +966,7 @@ void Monster_Reset()
        self.velocity = '0 0 0';
        self.enemy = world;
        self.goalentity = world;
-       self.attack_finished_single = 0;
+       self.attack_finished_single[0] = 0;
        self.moveto = self.origin;
 }
 
@@ -1030,13 +1028,13 @@ void Monster_Dead(entity attacker, float gibbed)
        self.touch                      = Monster_Touch; // reset incase monster was pouncing
        self.reset                      = func_null;
        self.state                      = 0;
-       self.attack_finished_single = 0;
+       self.attack_finished_single[0] = 0;
        self.effects = 0;
 
        if(!((self.flags & FL_FLY) || (self.flags & FL_SWIM)))
                self.velocity = '0 0 0';
 
-       CSQCModel_UnlinkEntity();
+       CSQCModel_UnlinkEntity(self);
 
        Monster mon = get_monsterinfo(self.monsterid);
        mon.mr_death(mon);
@@ -1047,19 +1045,19 @@ void Monster_Dead(entity attacker, float gibbed)
 
 void Monster_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {SELFPARAM();
-       if((self.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL)
+       if((self.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL.m_id && !ITEM_DAMAGE_NEEDKILL(deathtype))
                return;
 
-       if(self.frozen && deathtype != DEATH_KILL && deathtype != DEATH_NADE_ICE_FREEZE)
+       if(self.frozen && deathtype != DEATH_KILL.m_id && deathtype != DEATH_NADE_ICE_FREEZE.m_id)
                return;
 
-       //if(time < self.pain_finished && deathtype != DEATH_KILL)
+       //if(time < self.pain_finished && deathtype != DEATH_KILL.m_id)
                //return;
 
-       if(time < self.spawnshieldtime && deathtype != DEATH_KILL)
+       if(time < self.spawnshieldtime && deathtype != DEATH_KILL.m_id)
                return;
 
-       if(deathtype == DEATH_FALL && self.draggedby != world)
+       if(deathtype == DEATH_FALL.m_id && self.draggedby != world)
                return;
 
        vector v;
@@ -1087,12 +1085,12 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty
 
        self.dmg_time = time;
 
-       if(sound_allowed(MSG_BROADCAST, attacker) && deathtype != DEATH_DROWN)
+       if(sound_allowed(MSG_BROADCAST, attacker) && deathtype != DEATH_DROWN.m_id)
                spamsound (self, CH_PAIN, SND(BODYIMPACT1), VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
 
        self.velocity += force * self.damageforcescale;
 
-       if(deathtype != DEATH_DROWN && take)
+       if(deathtype != DEATH_DROWN.m_id && take)
        {
                Violence_GibSplash_At(hitloc, force, 2, bound(0, take, 200) / 16, self, attacker);
                if (take > 50)
@@ -1103,7 +1101,7 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty
 
        if(self.health <= 0)
        {
-               if(deathtype == DEATH_KILL)
+               if(deathtype == DEATH_KILL.m_id)
                        self.candrop = false; // killed by mobkill command
 
                // TODO: fix this?
@@ -1112,14 +1110,14 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty
                SUB_UseTargets();
                self.target2 = self.oldtarget2; // reset to original target on death, incase we respawn
 
-               Monster_Dead(attacker, (self.health <= -100 || deathtype == DEATH_KILL));
+               Monster_Dead(attacker, (self.health <= -100 || deathtype == DEATH_KILL.m_id));
 
                WaypointSprite_Kill(self.sprite);
 
                frag_target = self;
                MUTATOR_CALLHOOK(MonsterDies, attacker);
 
-               if(self.health <= -100 || deathtype == DEATH_KILL) // check if we're already gibbed
+               if(self.health <= -100 || deathtype == DEATH_KILL.m_id) // check if we're already gibbed
                {
                        Violence_GibSplash(self, 1, 0.5, attacker);
 
@@ -1178,7 +1176,7 @@ void Monster_Move_2D(float mspeed, float allow_jumpoff)
        movelib_move_simple_gravity(v_forward, mspeed, 1);
 
        if(time > self.pain_finished)
-       if(time > self.attack_finished_single)
+       if(time > self.attack_finished_single[0])
        if(vlen(self.velocity) > 10)
                setanim(self, self.anim_walk, true, false, false);
        else
@@ -1230,7 +1228,7 @@ void Monster_Think()
        if(self.monster_lifetime)
        if(time >= self.monster_lifetime)
        {
-               Damage(self, self, self, self.health + self.max_health, DEATH_KILL, self.origin, self.origin);
+               Damage(self, self, self, self.health + self.max_health, DEATH_KILL.m_id, self.origin, self.origin);
                return;
        }
 
@@ -1378,9 +1376,15 @@ bool Monster_Spawn(int mon_id)
                self.movetype = MOVETYPE_FLY;
        }
 
-       if(mon.spawnflags & MONSTER_SIZE_BROKEN)
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
-               self.scale *= 1.3;
+       {
+               if(mon.spawnflags & MONSTER_SIZE_BROKEN)
+                       self.scale *= 1.3;
+
+               if(mon.spawnflags & MONSTER_SIZE_QUAKE)
+               if(autocvar_g_monsters_quake_resize)
+                       self.scale *= 1.3;
+       }
 
        setsize(self, mon.mins * self.scale, mon.maxs * self.scale);