]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/monsters/sv_monsters.qc
Merge branch 'master' into Mario/vehicles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / monsters / sv_monsters.qc
index d5cd1f3e4c0c38ba184c85076480f15d5e167b59..887ac20ec3be81b4cb4d7c8baf2069dc17212db1 100644 (file)
@@ -1,3 +1,30 @@
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+       #include "../../dpdefs/progsdefs.qh"
+    #include "../../dpdefs/dpextensions.qh"
+    #include "../../warpzonelib/common.qh"
+    #include "../constants.qh"
+    #include "../teams.qh"
+    #include "../util.qh"
+    #include "all.qh"
+    #include "sv_monsters.qh"
+    #include "../weapons/all.qh"
+    #include "../../server/autocvars.qh"
+    #include "../../server/defs.qh"
+    #include "../deathtypes.qh"
+    #include "../../server/mutators/mutators_include.qh"
+    #include "../../server/tturrets/include/turrets_early.qh"
+    #include "../vehicles/sv_vehicles.qh"
+    #include "../../server/campaign.qh"
+    #include "../../server/command/common.qh"
+    #include "../../server/command/cmd.qh"
+       #include "../triggers/triggers.qh"
+    #include "../../csqcmodellib/sv_model.qh"
+    #include "../../server/round_handler.qh"
+    #include "../../server/tturrets/include/turrets.qh"
+#endif
+
 // =========================
 //     SVQC Monster Properties
 // =========================
@@ -13,8 +40,7 @@ void monster_dropitem()
 
        e.monster_loot = self.monster_loot;
 
-       other = e;
-       MUTATOR_CALLHOOK(MonsterDropItem);
+       MUTATOR_CALLHOOK(MonsterDropItem, e);
        e = other;
 
        if(e && e.monster_loot)
@@ -54,7 +80,7 @@ float monster_isvalidtarget (entity targ, entity ent)
        //if(trace_ent != targ)
                //return false;
 
-       if(targ.vehicle_flags & VHF_ISVEHICLE)
+       if(IS_VEHICLE(targ))
        if(!((get_monsterinfo(ent.monsterid)).spawnflags & MON_FLAG_RANGED))
                return false; // melee attacks are useless against vehicles
 
@@ -73,7 +99,7 @@ float monster_isvalidtarget (entity targ, entity ent)
        if(IS_SPEC(targ) || IS_OBSERVER(targ))
                return false; // enemy is a spectator
 
-       if(!(targ.vehicle_flags & VHF_ISVEHICLE))
+       if(!IS_VEHICLE(targ))
        if(targ.deadflag != DEAD_NO || ent.deadflag != DEAD_NO || targ.health <= 0 || ent.health <= 0)
                return false; // enemy/self is dead
 
@@ -83,7 +109,7 @@ float monster_isvalidtarget (entity targ, entity ent)
        if(targ.monster_owner == ent)
                return false; // don't attack our pet
 
-       if(!(targ.vehicle_flags & VHF_ISVEHICLE))
+       if(!IS_VEHICLE(targ))
        if(targ.flags & FL_NOTARGET)
                return false; // enemy can't be targeted
 
@@ -155,7 +181,7 @@ void MonsterTouch ()
                return;
 
        if(self.enemy != other)
-       if(!(other.flags & FL_MONSTER))
+       if(!IS_MONSTER(other))
        if(monster_isvalidtarget(other, self))
                self.enemy = other;
 }
@@ -249,15 +275,15 @@ float LoadMonsterSounds(string f, float first)
                field = GetMonsterSoundSampleField(argv(0));
                if(GetMonsterSoundSampleField_notFound)
                        continue;
-               if(self.field)
-                       strunzone(self.field);
-               self.field = strzone(strcat(argv(1), " ", argv(2)));
+               if (self.(field))
+                       strunzone(self.(field));
+               self.(field) = strzone(strcat(argv(1), " ", argv(2)));
        }
        fclose(fh);
        return 1;
 }
 
-.float skin_for_monstersound;
+.int skin_for_monstersound;
 void UpdateMonsterSounds()
 {
        entity mon = get_monsterinfo(self.monsterid);
@@ -279,7 +305,7 @@ void MonsterSound(.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(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
 
        self.msound_delay = time + sound_delay;
 }
@@ -295,7 +321,7 @@ void monster_makevectors(entity e)
        makevectors(self.v_angle);
 }
 
-float monster_melee(entity targ, float damg, float anim, float er, float anim_finished, float deathtype, float dostop)
+float monster_melee(entity targ, float damg, float anim, float er, float anim_finished, int deathtype, float dostop)
 {
        if (self.health <= 0)
                return false; // attacking while dead?!
@@ -335,7 +361,7 @@ void Monster_CheckMinibossFlag ()
                self.health += autocvar_g_monsters_miniboss_healthboost;
                self.effects |= EF_RED;
                if(!self.weapon)
-                       self.weapon = WEP_VORTEX;
+                       self.weapon = WEP_VORTEX.m_id;
        }
 }
 
@@ -343,7 +369,7 @@ float Monster_CanRespawn(entity ent)
 {
        other = ent;
        if(ent.deadflag == DEAD_DEAD) // don't call when monster isn't dead
-       if(MUTATOR_CALLHOOK(MonsterRespawn))
+       if(MUTATOR_CALLHOOK(MonsterRespawn, ent))
                return true; // enabled by a mutator
 
        if(ent.spawnflags & MONSTERFLAG_NORESPAWN)
@@ -355,7 +381,6 @@ float Monster_CanRespawn(entity ent)
        return true;
 }
 
-float monster_initialize(float mon_id);
 void monster_respawn()
 {
        // is this function really needed?
@@ -477,7 +502,7 @@ vector monster_pickmovetarget(entity targ)
                vector targ_origin = ((self.enemy.absmin + self.enemy.absmax) * 0.5);
                targ_origin = WarpZone_RefSys_TransformOrigin(self.enemy, self, targ_origin); // origin of target as seen by the monster (us)
                WarpZone_TraceLine(self.origin, targ_origin, MOVE_NOMONSTERS, self);
-               
+
                if((self.enemy == world)
                        || (self.enemy.deadflag != DEAD_NO || self.enemy.health < 1)
                        || (self.enemy.frozen)
@@ -491,19 +516,19 @@ vector monster_pickmovetarget(entity targ)
                        self.enemy = world;
                        self.pass_distance = 0;
                }
-               
+
                if(self.enemy)
                {
                        /*WarpZone_TrailParticles(world, particleeffectnum("red_pass"), self.origin, targ_origin);
                        print("Trace origin: ", vtos(targ_origin), "\n");
                        print("Target origin: ", vtos(self.enemy.origin), "\n");
                        print("My origin: ", vtos(self.origin), "\n"); */
-                       
+
                        self.monster_movestate = MONSTER_MOVE_ENEMY;
                        self.last_trace = time + 1.2;
                        return targ_origin;
                }
-       
+
                /*makevectors(self.angles);
                self.monster_movestate = MONSTER_MOVE_ENEMY;
                self.last_trace = time + 1.2;
@@ -551,7 +576,7 @@ vector monster_pickmovetarget(entity targ)
 
                                if(((self.flags & FL_FLY) && (self.spawnflags & MONSTERFLAG_FLY_VERTICAL)) || (self.flags & FL_SWIM))
                                {
-                                       pos_z = random() * 200;
+                                       pos.z = random() * 200;
                                        if(random() >= 0.5)
                                                pos.z *= -1;
                                }
@@ -566,7 +591,7 @@ void monster_CalculateVelocity(entity mon, vector to, vector from, float turnrat
 {
        float current_distance = vlen((('1 0 0' * to.x) + ('0 1 0' * to.y)) - (('1 0 0' * from.x) + ('0 1 0' * from.y))); // for the sake of this check, exclude Z axis
        float initial_height = 0; //min(50, (targ_distance * tanh(20)));
-       float current_height = (initial_height * min(1, (current_distance / self.pass_distance)));
+       float current_height = (initial_height * min(1, self.pass_distance ? (current_distance / self.pass_distance) : 0));
        //print("current_height = ", ftos(current_height), ", initial_height = ", ftos(initial_height), ".\n");
 
        vector targpos;
@@ -690,11 +715,13 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
 
        targ = self.goalentity;
 
-       monster_target = targ;
-       monster_speed_run = runspeed;
-       monster_speed_walk = walkspeed;
-
-       if(MUTATOR_CALLHOOK(MonsterMove) || gameover || self.draggedby != world || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < self.spawn_time)
+       if (MUTATOR_CALLHOOK(MonsterMove, runspeed, walkspeed, targ)
+               || gameover
+               || self.draggedby != world
+               || (round_handler_IsActive() && !round_handler_IsRoundStarted())
+               || time < game_starttime
+               || (autocvar_g_campaign && !campaign_bots_may_start)
+               || time < self.spawn_time)
        {
                runspeed = walkspeed = 0;
                if(time >= self.spawn_time)
@@ -703,7 +730,6 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                return;
        }
 
-       targ = monster_target;
        runspeed = bound(0, monster_speed_run * Monster_SkillModifier(), runspeed * 2); // limit maxspeed to prevent craziness
        walkspeed = bound(0, monster_speed_walk * Monster_SkillModifier(), walkspeed * 2); // limit maxspeed to prevent craziness
 
@@ -728,7 +754,7 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                                WarpZone_RefSys_Copy(self.enemy, self);
                                WarpZone_RefSys_AddInverse(self.enemy, self); // wz1^-1 ... wzn^-1 receiver
                                self.moveto = WarpZone_RefSys_TransformOrigin(self.enemy, self, (0.5 * (self.enemy.absmin + self.enemy.absmax)));
-                               
+
                                self.pass_distance = vlen((('1 0 0' * self.enemy.origin.x) + ('0 1 0' * self.enemy.origin.y)) - (('1 0 0' *  self.origin.x) + ('0 1 0' *  self.origin.y)));
                                MonsterSound(monstersound_sight, 0, false, CH_VOICE);
                        }
@@ -768,7 +794,7 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
        {
                if((self.flags & FL_ONGROUND) || ((self.flags & FL_FLY) || (self.flags & FL_SWIM)))
                        monster_CalculateVelocity(self, self.moveto, self.origin, true, ((self.enemy) ? runspeed : walkspeed));
-               
+
                /*&if(self.flags & FL_FLY || self.flags & FL_SWIM)
                        movelib_move_simple(v_forward, ((self.enemy) ? runspeed : walkspeed), 0.6);
                else
@@ -795,9 +821,9 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                if (vlen(self.velocity) <= 30)
                        self.frame = manim_idle;
        }
-       
+
        self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95);
-       
+
        vector real_angle = vectoangles(self.steerto) - self.angles;
        float turny = 25;
        if(self.state == MONSTER_STATE_ATTACK_MELEE)
@@ -816,7 +842,7 @@ void monster_remove(entity mon)
        if(!mon)
                return; // nothing to remove
 
-       pointparticles(particleeffectnum("item_pickup"), mon.origin, '0 0 0', 1);
+       Send_Effect("item_pickup", mon.origin, '0 0 0', 1);
 
        if(mon.weaponentity)
                remove(mon.weaponentity);
@@ -885,7 +911,7 @@ void monsters_reset()
        self.moveto = self.origin;
 }
 
-void monsters_corpse_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void monsters_corpse_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        self.health -= damage;
 
@@ -954,7 +980,7 @@ void monster_die(entity attacker, float gibbed)
        MON_ACTION(self.monsterid, MR_DEATH);
 }
 
-void monsters_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void monsters_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        if(self.frozen && deathtype != DEATH_KILL && deathtype != DEATH_NADE_ICE_FREEZE)
                return;
@@ -1013,9 +1039,8 @@ void monsters_damage (entity inflictor, entity attacker, float damage, float dea
 
                WaypointSprite_Kill(self.sprite);
 
-               frag_attacker = attacker;
                frag_target = self;
-               MUTATOR_CALLHOOK(MonsterDies);
+               MUTATOR_CALLHOOK(MonsterDies, attacker);
 
                if(self.health <= -100 || deathtype == DEATH_KILL) // check if we're already gibbed
                {
@@ -1053,11 +1078,11 @@ void monster_setupcolors(entity mon)
 void monster_changeteam(entity ent, float newteam)
 {
        if(!teamplay) { return; }
-       
+
        ent.team = newteam;
        ent.monster_attack = true; // new team, activate attacking
        monster_setupcolors(ent);
-       
+
        if(ent.sprite)
        {
                WaypointSprite_UpdateTeamRadar(ent.sprite, RADARICON_DANGER, ((newteam) ? Team_ColorRGB(newteam) : '1 0 0'));
@@ -1216,7 +1241,7 @@ float monster_initialize(float mon_id)
        if(mon.spawnflags & MONSTER_SIZE_BROKEN)
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
                self.scale *= 1.3;
-               
+
        setsize(self, mon.mins * self.scale, mon.maxs * self.scale);
 
        if(!self.ticrate)