]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_onslaught.qc
Merge branch 'master' into terencehill/hud_cleanups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_onslaught.qc
index 9b356404dca9948803c46081013acd7a7540a5fa..8b2e223c041fe0756db6072621e04e73dccb162a 100644 (file)
@@ -1,25 +1,16 @@
-#include "../_all.qh"
 
 #include "gamemode.qh"
 #include "../controlpoint.qh"
 #include "../generator.qh"
 
-vector randompos(vector m1, vector m2)
-{
-       vector v;
-       m2 = m2 - m1;
-       v_x = m2_x * random() + m1_x;
-       v_y = m2_y * random() + m1_y;
-       v_z = m2_z * random() + m1_z;
-       return  v;
-}
+void FixSize(entity e);
 
 // =======================
 // CaptureShield Functions
 // =======================
 
 bool ons_CaptureShield_Customize()
-{
+{SELFPARAM();
        entity e = WaypointSprite_getviewentity(other);
 
        if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, e.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return false; }
@@ -29,7 +20,7 @@ bool ons_CaptureShield_Customize()
 }
 
 void ons_CaptureShield_Touch()
-{
+{SELFPARAM();
        if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
        if(!IS_PLAYER(other)) { return; }
        if(SAME_TEAM(other, self)) { return; }
@@ -37,11 +28,11 @@ void ons_CaptureShield_Touch()
        vector mymid = (self.absmin + self.absmax) * 0.5;
        vector othermid = (other.absmin + other.absmax) * 0.5;
 
-       Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * ons_captureshield_force);
+       Damage(other, self, self, 0, DEATH_HURTTRIGGER.m_id, mymid, normalize(othermid - mymid) * ons_captureshield_force);
 
        if(IS_REAL_CLIENT(other))
        {
-               play2(other, "onslaught/damageblockedbyshield.wav");
+               play2(other, SND(ONS_DAMAGEBLOCKEDBYSHIELD));
 
                if(self.enemy.classname == "onslaught_generator")
                        Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_ONS_GENERATOR_SHIELDED);
@@ -51,7 +42,7 @@ void ons_CaptureShield_Touch()
 }
 
 void ons_CaptureShield_Reset()
-{
+{SELFPARAM();
        self.colormap = self.enemy.colormap;
        self.team = self.enemy.team;
 }
@@ -76,7 +67,7 @@ void ons_CaptureShield_Spawn(entity generator, bool is_generator)
 
        precache_model(shield.model);
        setorigin(shield, generator.origin);
-       setmodel(shield, shield.model);
+       _setmodel(shield, shield.model);
        setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs);
 }
 
@@ -89,12 +80,12 @@ void ons_debug(string input)
 {
        switch(autocvar_g_onslaught_debug)
        {
-               case 1: dprint(input); break;
-               case 2: print(input); break;
+               case 1: LOG_TRACE(input); break;
+               case 2: LOG_INFO(input); break;
        }
 }
 
-void setmodel_fixsize(entity e, string m)
+void setmodel_fixsize(entity e, Model m)
 {
        setmodel(e, m);
        FixSize(e);
@@ -238,7 +229,7 @@ void onslaught_updatelinks()
 // Main Link Functions
 // ===================
 
-bool ons_Link_Send(entity to, int sendflags)
+bool ons_Link_Send(entity this, entity to, int sendflags)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
        WriteByte(MSG_ENTITY, sendflags);
@@ -262,7 +253,7 @@ bool ons_Link_Send(entity to, int sendflags)
 }
 
 void ons_Link_CheckUpdate()
-{
+{SELFPARAM();
        // TODO check if the two sides have moved (currently they won't move anyway)
        float cc = 0, cc1 = 0, cc2 = 0;
 
@@ -281,7 +272,7 @@ void ons_Link_CheckUpdate()
 }
 
 void ons_DelayedLinkSetup()
-{
+{SELFPARAM();
        self.goalentity = find(world, targetname, self.target);
        self.enemy = find(world, targetname, self.target2);
        if(!self.goalentity) { objerror("can not find target\n"); }
@@ -354,9 +345,7 @@ int ons_ControlPoint_Attackable(entity cp, int teamnumber)
 }
 
 void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
-       entity oself;
-
+{SELFPARAM();
        if(damage <= 0) { return; }
 
        if (self.owner.isshielded)
@@ -365,7 +354,7 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
                if (time > self.pain_finished)
                        if (IS_PLAYER(attacker))
                        {
-                               play2(attacker, "onslaught/damageblockedbyshield.wav");
+                               play2(attacker, SND(ONS_DAMAGEBLOCKEDBYSHIELD));
                                self.pain_finished = time + 1;
                                attacker.typehitsound += 1; // play both sounds (shield is way too quiet)
                        }
@@ -376,7 +365,7 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
        if(IS_PLAYER(attacker))
        if(time - ons_notification_time[self.team] > 10)
        {
-               play2team(self.team, "onslaught/controlpoint_underattack.wav");
+               play2team(self.team, SND(ONS_CONTROLPOINT_UNDERATTACK));
                ons_notification_time[self.team] = time;
        }
 
@@ -387,17 +376,17 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
                WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / ONS_CP_THINKRATE));
        self.pain_finished = time + 1;
        // particles on every hit
-       pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
+       pointparticles(particleeffectnum(EFFECT_SPARKS), hitloc, force*-1, 1);
        //sound on every hit
        if (random() < 0.5)
-               sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_ONS_HIT1, VOL_BASE+0.3, ATTEN_NORM);
        else
-               sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE+0.3, ATTEN_NORM);
 
        if (self.health < 0)
        {
-               sound(self, CH_TRIGGER, W_Sound("grenade_impact"), VOL_BASE, ATTEN_NORM);
-               pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
+               sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
+               pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
                Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_CPDESTROYED_), self.owner.message, attacker.netname);
 
                PlayerScore_Add(attacker, SP_ONS_TAKES, 1);
@@ -414,15 +403,14 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               oself = self;
-               self = self.owner;
+               setself(self.owner);
                activator = self;
                SUB_UseTargets ();
-               self = oself;
+               setself(this);
 
                self.owner.waslinked = self.owner.islinked;
                if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
-                       setmodel_fixsize(self.owner, "models/onslaught/controlpoint_pad.md3");
+                       setmodel_fixsize(self.owner, MDL_ONS_CP_PAD1);
                //setsize(self, '-32 -32 0', '32 32 8');
 
                remove(self);
@@ -432,8 +420,7 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
 }
 
 void ons_ControlPoint_Icon_Think()
-{
-       entity oself;
+{SELFPARAM();
        self.nextthink = time + ONS_CP_THINKRATE;
 
        if(autocvar_g_onslaught_cp_proxydecap)
@@ -488,11 +475,10 @@ void ons_ControlPoint_Icon_Think()
                if(!self.owner.islinked)
                        self.owner.team = 0;
 
-               oself = self;
-               self = self.owner;
+               setself(self.owner);
                activator = self;
                SUB_UseTargets ();
-               self = oself;
+               setself(this);
 
                self.owner.team = t;
 
@@ -502,18 +488,17 @@ void ons_ControlPoint_Icon_Think()
        // damaged fx
        if(random() < 0.6 - self.health / self.max_health)
        {
-               Send_Effect("electricity_sparks", self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
+               Send_Effect(EFFECT_ELECTRIC_SPARKS, self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
 
                if(random() > 0.8)
-                       sound(self, CH_PAIN, "onslaught/ons_spark1.wav", VOL_BASE, ATTEN_NORM);
+                       sound(self, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
                else if (random() > 0.5)
-                       sound(self, CH_PAIN, "onslaught/ons_spark2.wav", VOL_BASE, ATTEN_NORM);
+                       sound(self, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
        }
 }
 
 void ons_ControlPoint_Icon_BuildThink()
-{
-       entity oself;
+{SELFPARAM();
        int a;
 
        self.nextthink = time + ONS_CP_THINKRATE;
@@ -532,11 +517,11 @@ void ons_ControlPoint_Icon_BuildThink()
                self.health = self.max_health;
                self.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
                self.think = ons_ControlPoint_Icon_Think;
-               sound(self, CH_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
                self.owner.iscaptured = true;
                self.solid = SOLID_BBOX;
 
-               Send_Effect(sprintf("%s_cap", Static_Team_ColorName_Lower(self.owner.team)), self.owner.origin, '0 0 0', 1);
+               Send_Effect(EFFECT_CAP(self.owner.team), self.owner.origin, '0 0 0', 1);
 
                WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
                WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
@@ -555,21 +540,22 @@ void ons_ControlPoint_Icon_BuildThink()
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               oself = self;
-               self = self.owner;
+               setself(self.owner);
                activator = self;
                SUB_UseTargets ();
-               self = oself;
+               setself(this);
 
                self.SendFlags |= CPSF_SETUP;
        }
-       if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
-               setmodel_fixsize(self.owner, "models/onslaught/controlpoint_pad2.md3");
+       if(self.owner.model != MDL_ONS_CP_PAD2.model_str())
+               setmodel_fixsize(self.owner, MDL_ONS_CP_PAD2);
 
        if(random() < 0.9 - self.health / self.max_health)
-               Send_Effect("rage", self.origin + 10 * randomvec(), '0 0 -1', 1);
+               Send_Effect(EFFECT_RAGE, self.origin + 10 * randomvec(), '0 0 -1', 1);
 }
 
+void onslaught_controlpoint_icon_link(entity e, void() spawnproc);
+
 void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
 {
        entity e = spawn();
@@ -589,13 +575,13 @@ void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
        e.colormap = 1024 + (e.team - 1) * 17;
        e.count = (e.max_health - e.health) * ONS_CP_THINKRATE / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
 
-       sound(e, CH_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTEN_NORM);
+       sound(e, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILD, VOL_BASE, ATTEN_NORM);
 
        cp.goalentity = e;
        cp.team = e.team;
        cp.colormap = e.colormap;
 
-       Send_Effect(sprintf("%sflag_touch", Static_Team_ColorName_Lower(player.team)), e.origin, '0 0 0', 1);
+       Send_Effect(EFFECT_FLAG_TOUCH(player.team), e.origin, '0 0 0', 1);
 
        WaypointSprite_UpdateBuildFinished(cp.sprite, time + (e.max_health - e.health) / (e.count / ONS_CP_THINKRATE));
        WaypointSprite_UpdateRule(cp.sprite,cp.team,SPRITERULE_TEAMPLAY);
@@ -604,26 +590,25 @@ void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
        onslaught_controlpoint_icon_link(e, ons_ControlPoint_Icon_BuildThink);
 }
 
-string ons_ControlPoint_Waypoint(entity e)
+entity ons_ControlPoint_Waypoint(entity e)
 {
        if(e.team)
        {
                int a = ons_ControlPoint_Attackable(e, e.team);
 
-               if(a == -2) { return "ons-cp-dfnd"; } // defend now
-               if(a == -1 || a == 1 || a == 2) { return "ons-cp"; } // touch
-               if(a == 3 || a == 4) { return "ons-cp-atck"; } // attack
+               if(a == -2) { return WP_OnsCPDefend; } // defend now
+               if(a == -1 || a == 1 || a == 2) { return WP_OnsCP; } // touch
+               if(a == 3 || a == 4) { return WP_OnsCPAttack; } // attack
        }
        else
-               return "ons-cp";
+               return WP_OnsCP;
 
-       return "";
+       return WP_Null;
 }
 
 void ons_ControlPoint_UpdateSprite(entity e)
 {
-       string s1;
-       s1 = ons_ControlPoint_Waypoint(e);
+       entity s1 = ons_ControlPoint_Waypoint(e);
        WaypointSprite_UpdateSprites(e.sprite, s1, s1, s1);
 
        bool sh;
@@ -666,7 +651,7 @@ void ons_ControlPoint_UpdateSprite(entity e)
 }
 
 void ons_ControlPoint_Touch()
-{
+{SELFPARAM();
        entity toucher = other;
        int attackable;
 
@@ -703,13 +688,13 @@ void ons_ControlPoint_Touch()
 }
 
 void ons_ControlPoint_Think()
-{
+{SELFPARAM();
        self.nextthink = time + ONS_CP_THINKRATE;
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void ons_ControlPoint_Reset()
-{
+{SELFPARAM();
        if(self.goalentity)
                remove(self.goalentity);
 
@@ -722,7 +707,7 @@ void ons_ControlPoint_Reset()
        self.think = ons_ControlPoint_Think;
        self.ons_toucher = world;
        self.nextthink = time + ONS_CP_THINKRATE;
-       setmodel_fixsize(self, "models/onslaught/controlpoint_pad.md3");
+       setmodel_fixsize(self, MDL_ONS_CP_PAD1);
 
        WaypointSprite_UpdateMaxHealth(self.sprite, 0);
        WaypointSprite_UpdateRule(self.sprite,self.team,SPRITERULE_TEAMPLAY);
@@ -732,23 +717,23 @@ void ons_ControlPoint_Reset()
        activator = self;
        SUB_UseTargets(); // to reset the structures, playerspawns etc.
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void ons_DelayedControlPoint_Setup(void)
-{
+{SELFPARAM();
        onslaught_updatelinks();
 
        // captureshield setup
        ons_CaptureShield_Spawn(self, false);
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 }
 
 void ons_ControlPoint_Setup(entity cp)
-{
+{SELFPARAM();
        // declarations
-       self = cp; // for later usage with droptofloor()
+       setself(cp); // for later usage with droptofloor()
 
        // main setup
        cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
@@ -769,27 +754,8 @@ void ons_ControlPoint_Setup(entity cp)
 
        if(cp.message == "") { cp.message = "a"; }
 
-       // precache - TODO: clean up!
-       precache_model("models/onslaught/controlpoint_pad.md3");
-       precache_model("models/onslaught/controlpoint_pad2.md3");
-       precache_model("models/onslaught/controlpoint_shield.md3");
-       precache_model("models/onslaught/controlpoint_icon.md3");
-       precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
-       precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
-       precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
-       precache_model("models/onslaught/controlpoint_icon_gib1.md3");
-       precache_model("models/onslaught/controlpoint_icon_gib2.md3");
-       precache_model("models/onslaught/controlpoint_icon_gib4.md3");
-       precache_sound("onslaught/controlpoint_build.wav");
-       precache_sound("onslaught/controlpoint_built.wav");
-       precache_sound(W_Sound("grenade_impact"));
-       precache_sound("onslaught/damageblockedbyshield.wav");
-       precache_sound("onslaught/controlpoint_underattack.wav");
-       precache_sound("onslaught/ons_spark1.wav");
-       precache_sound("onslaught/ons_spark2.wav");
-
        // appearence
-       setmodel_fixsize(cp, "models/onslaught/controlpoint_pad.md3");
+       setmodel_fixsize(cp, MDL_ONS_CP_PAD1);
 
        // control point placement
        if((cp.spawnflags & 1) || cp.noalign) // don't drop to floor, just stay at fixed location
@@ -801,13 +767,13 @@ void ons_ControlPoint_Setup(entity cp)
        {
                setorigin(cp, cp.origin + '0 0 20');
                cp.noalign = false;
-               self = cp;
+               setself(cp);
                droptofloor();
                cp.movetype = MOVETYPE_TOSS;
        }
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(string_null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE, '0 0 0');
+       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
        WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
 
        InitializeEntity(cp, ons_DelayedControlPoint_Setup, INITPRIO_SETLOCATION);
@@ -818,16 +784,16 @@ void ons_ControlPoint_Setup(entity cp)
 // Main Generator Functions
 // =========================
 
-string ons_Generator_Waypoint(entity e)
+entity ons_Generator_Waypoint(entity e)
 {
-       if(e.isshielded)
-               return "ons-gen-shielded";
-       return "ons-gen";
+       if (e.isshielded)
+               return WP_OnsGenShielded;
+       return WP_OnsGen;
 }
 
 void ons_Generator_UpdateSprite(entity e)
 {
-       string s1 = ons_Generator_Waypoint(e);
+       entity s1 = ons_Generator_Waypoint(e);
        WaypointSprite_UpdateSprites(e.sprite, s1, s1, s1);
 
        if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
@@ -853,7 +819,7 @@ void ons_Generator_UpdateSprite(entity e)
 }
 
 void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(damage <= 0) { return; }
        if(warmup_stage || gameover) { return; }
        if(!round_handler_IsRoundStarted()) { return; }
@@ -866,7 +832,7 @@ void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int de
                        if (time > self.pain_finished)
                                if (IS_PLAYER(attacker))
                                {
-                                       play2(attacker, "onslaught/damageblockedbyshield.wav");
+                                       play2(attacker, SND(ONS_DAMAGEBLOCKEDBYSHIELD));
                                        attacker.typehitsound += 1;
                                        self.pain_finished = time + 1;
                                }
@@ -877,7 +843,7 @@ void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int de
                        self.pain_finished = time + 10;
                        entity head;
                        FOR_EACH_REALPLAYER(head) if(SAME_TEAM(head, self)) { Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK); }
-                       play2team(self.team, "onslaught/generator_underattack.wav");
+                       play2team(self.team, SND(ONS_GENERATOR_UNDERATTACK));
                }
        }
        self.health = self.health - damage;
@@ -918,25 +884,25 @@ void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int de
        // Throw some flaming gibs on damage, more damage = more chance for gib
        if(random() < damage/220)
        {
-               sound(self, CH_TRIGGER, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+               sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        }
        else
        {
                // particles on every hit
-               Send_Effect("sparks", hitloc, force * -1, 1);
+               Send_Effect(EFFECT_SPARKS, hitloc, force * -1, 1);
 
                //sound on every hit
                if (random() < 0.5)
-                       sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTEN_NORM);
+                       sound(self, CH_TRIGGER, SND_ONS_HIT1, VOL_BASE, ATTEN_NORM);
                else
-                       sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);
+                       sound(self, CH_TRIGGER, SND_ONS_HIT2, VOL_BASE, ATTEN_NORM);
        }
 
        self.SendFlags |= GSF_STATUS;
 }
 
 void ons_GeneratorThink()
-{
+{SELFPARAM();
        entity e;
        self.nextthink = time + GEN_THINKRATE;
        if (!gameover)
@@ -949,7 +915,7 @@ void ons_GeneratorThink()
                                if(SAME_TEAM(e, self))
                                {
                                        Send_Notification(NOTIF_ONE, e, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
-                    soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTEN_NONE);    // FIXME: unique sound?
+                    soundto(MSG_ONE, e, CHAN_AUTO, SND(KH_ALARM), VOL_BASE, ATTEN_NONE);    // FIXME: unique sound?
                 }
                                else
                                        Send_Notification(NOTIF_ONE, e, MSG_CENTER, APP_TEAM_NUM_4(self.team, CENTER_ONS_NOTSHIELDED_));
@@ -959,7 +925,7 @@ void ons_GeneratorThink()
 }
 
 void ons_GeneratorReset()
-{
+{SELFPARAM();
        self.team = self.team_saved;
        self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
        self.takedamage = DAMAGE_AIM;
@@ -984,7 +950,7 @@ void ons_GeneratorReset()
 }
 
 void ons_DelayedGeneratorSetup()
-{
+{SELFPARAM();
        // bot waypoints
        waypoint_spawnforitem_force(self, self.origin);
        self.nearestwaypointtimeout = 0; // activate waypointing again
@@ -1000,7 +966,7 @@ void ons_DelayedGeneratorSetup()
 
 
 void onslaught_generator_touch()
-{
+{SELFPARAM();
        if ( IS_PLAYER(other) )
        if ( SAME_TEAM(self,other) )
        if ( self.iscaptured )
@@ -1010,10 +976,10 @@ void onslaught_generator_touch()
 }
 
 void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
-{
+{SELFPARAM();
        // declarations
        int teamnumber = gen.team;
-       self = gen; // for later usage with droptofloor()
+       setself(gen); // for later usage with droptofloor()
 
        // main setup
        gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
@@ -1036,20 +1002,6 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.isshielded = true;
        gen.touch = onslaught_generator_touch;
 
-       // precache - TODO: clean up!
-       precache_model("models/onslaught/generator_shield.md3");
-       precache_model("models/onslaught/gen_gib1.md3");
-       precache_model("models/onslaught/gen_gib2.md3");
-       precache_model("models/onslaught/gen_gib3.md3");
-       precache_sound("onslaught/generator_decay.wav");
-       precache_sound(W_Sound("grenade_impact"));
-       precache_sound(W_Sound("rocket_impact"));
-       precache_sound("onslaught/generator_underattack.wav");
-       precache_sound("onslaught/shockwave.wav");
-       precache_sound("onslaught/ons_hit1.wav");
-       precache_sound("onslaught/ons_hit2.wav");
-       precache_sound("onslaught/generator_underattack.wav");
-
        // appearence
        // model handled by CSQC
        setsize(gen, GENERATOR_MIN, GENERATOR_MAX);
@@ -1057,11 +1009,11 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.colormap = 1024 + (teamnumber - 1) * 17;
 
        // generator placement
-       self = gen;
+       setself(gen);
        droptofloor();
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(string_null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE, '0 0 0');
+       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
        WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
        WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
        WaypointSprite_UpdateHealth(self.sprite, self.health);
@@ -1127,7 +1079,7 @@ bool Onslaught_CheckWinner()
                if (!wpforenemy_announced)
                {
                        Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT);
-                       sound(world, CH_INFO, "onslaught/generator_decay.wav", VOL_BASE, ATTEN_NONE);
+                       sound(world, CH_INFO, SND_ONS_GENERATOR_DECAY, VOL_BASE, ATTEN_NONE);
 
                        wpforenemy_announced = true;
                }
@@ -1151,7 +1103,7 @@ bool Onslaught_CheckWinner()
                        else
                                d = d * tmp_entity.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
 
-                       Damage(tmp_entity, tmp_entity, tmp_entity, d, DEATH_HURTTRIGGER, tmp_entity.origin, '0 0 0');
+                       Damage(tmp_entity, tmp_entity, tmp_entity, d, DEATH_HURTTRIGGER.m_id, tmp_entity.origin, '0 0 0');
 
                        tmp_entity.sprite.SendFlags |= 16;
 
@@ -1181,7 +1133,7 @@ bool Onslaught_CheckWinner()
 
        ons_stalemate = false;
 
-       play2all(sprintf("ctf/%s_capture.wav", Static_Team_ColorName_Lower(winner_team)));
+       play2all(SND(CTF_CAPTURE(winner_team)));
 
        round_handler_Init(7, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
 
@@ -1221,7 +1173,7 @@ void Onslaught_RoundStart()
 // NOTE: LEGACY CODE, needs to be re-written!
 
 void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        float t, c;
        int i;
@@ -1295,7 +1247,7 @@ void havocbot_role_ons_setrole(entity bot, int role)
 }
 
 int havocbot_ons_teamcount(entity bot, int role)
-{
+{SELFPARAM();
        int c = 0;
        entity head;
 
@@ -1308,7 +1260,7 @@ int havocbot_ons_teamcount(entity bot, int role)
 }
 
 void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
-{
+{SELFPARAM();
        entity cp, cp1, cp2, best, pl, wp;
        float radius, bestvalue;
        int c;
@@ -1426,7 +1378,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 }
 
 bool havocbot_goalrating_ons_generator_attack(float ratingscale)
-{
+{SELFPARAM();
        entity g, wp, bestwp;
        bool found;
        int best;
@@ -1482,7 +1434,7 @@ bool havocbot_goalrating_ons_generator_attack(float ratingscale)
 }
 
 void havocbot_role_ons_offense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                self.havocbot_attack_time = 0;
@@ -1517,17 +1469,17 @@ void havocbot_role_ons_offense()
 }
 
 void havocbot_role_ons_assistant()
-{
+{SELFPARAM();
        havocbot_ons_reset_role(self);
 }
 
 void havocbot_role_ons_defense()
-{
+{SELFPARAM();
        havocbot_ons_reset_role(self);
 }
 
 void havocbot_ons_reset_role(entity bot)
-{
+{SELFPARAM();
        entity head;
        int c = 0;
 
@@ -1559,7 +1511,7 @@ void havocbot_ons_reset_role(entity bot)
  * if max_dist is positive, only control points within this range will be considered
  */
 entity ons_Nearest_ControlPoint(vector pos, float max_dist)
-{
+{SELFPARAM();
        entity tmp_entity, closest_target = world;
        tmp_entity = findchain(classname, "onslaught_controlpoint");
        while(tmp_entity)
@@ -1590,7 +1542,7 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist)
  * This function only check distances on the XY plane, disregarding Z
  */
 entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist)
-{
+{SELFPARAM();
        entity tmp_entity, closest_target = world;
        vector delta;
        float smallest_distance = 0, distance;
@@ -1637,7 +1589,7 @@ entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist)
  * find the number of control points and generators in the same team as self
  */
 int ons_Count_SelfControlPoints()
-{
+{SELFPARAM();
        entity tmp_entity;
        tmp_entity = findchain(classname, "onslaught_controlpoint");
        int n = 0;
@@ -1689,8 +1641,8 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
                        {
                                if ( tele_effects )
                                {
-                                       Send_Effect("teleport", player.origin, '0 0 0', 1);
-                                       sound (player, CH_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTEN_NORM);
+                                       Send_Effect(EFFECT_TELEPORT, player.origin, '0 0 0', 1);
+                                       sound (player, CH_TRIGGER, SND_TELEPORT, VOL_BASE, ATTEN_NORM);
                                }
                                setorigin(player, loc);
                                player.angles = '0 1 0' * ( theta * RAD2DEG + 180 );
@@ -1699,7 +1651,7 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
                                player.teleport_antispam = time + autocvar_g_onslaught_teleport_wait;
 
                                if ( tele_effects )
-                                       Send_Effect("teleport", player.origin + v_forward * 32, '0 0 0', 1);
+                                       Send_Effect(EFFECT_TELEPORT, player.origin + v_forward * 32, '0 0 0', 1);
                                return true;
                        }
                }
@@ -1713,24 +1665,25 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
 // ==============
 
 MUTATOR_HOOKFUNCTION(ons_ResetMap)
-{
-       FOR_EACH_PLAYER(self)
+{SELFPARAM();
+       entity e;
+       FOR_EACH_PLAYER(e)
        {
-               self.ons_roundlost = false;
-               self.ons_deathloc = '0 0 0';
-               PutClientInServer();
+               e.ons_roundlost = false;
+               e.ons_deathloc = '0 0 0';
+               WITH(entity, self, e, PutClientInServer());
        }
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ons_RemovePlayer)
-{
+{SELFPARAM();
        self.ons_deathloc = '0 0 0';
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
-{
+{SELFPARAM();
        if(!round_handler_IsRoundStarted())
        {
                self.player_blocked = true;
@@ -1856,7 +1809,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ons_PlayerDies)
-{
+{SELFPARAM();
        frag_target.ons_deathloc = frag_target.origin;
        entity l;
        for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
@@ -1876,7 +1829,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(ons_MonsterThink)
-{
+{SELFPARAM();
        entity e = find(world, targetname, self.target);
        if (e != world)
                self.team = e.team;
@@ -1885,7 +1838,7 @@ MUTATOR_HOOKFUNCTION(ons_MonsterThink)
 }
 
 void ons_MonsterSpawn_Delayed()
-{
+{SELFPARAM();
        entity e, own = self.owner;
 
        if(!own) { remove(self); return; }
@@ -1906,7 +1859,7 @@ void ons_MonsterSpawn_Delayed()
 }
 
 MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
-{
+{SELFPARAM();
        entity e = spawn();
        e.owner = self;
        InitializeEntity(e, ons_MonsterSpawn_Delayed, INITPRIO_FINDTARGET);
@@ -1915,7 +1868,7 @@ MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
 }
 
 void ons_TurretSpawn_Delayed()
-{
+{SELFPARAM();
        entity e, own = self.owner;
 
        if(!own) { remove(self); return; }
@@ -1937,7 +1890,7 @@ void ons_TurretSpawn_Delayed()
 }
 
 MUTATOR_HOOKFUNCTION(ons_TurretSpawn)
-{
+{SELFPARAM();
        entity e = spawn();
        e.owner = self;
        InitializeEntity(e, ons_TurretSpawn_Delayed, INITPRIO_FINDTARGET);
@@ -1946,7 +1899,7 @@ MUTATOR_HOOKFUNCTION(ons_TurretSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ons_BotRoles)
-{
+{SELFPARAM();
        havocbot_ons_reset_role(self);
        return true;
 }
@@ -1970,13 +1923,13 @@ MUTATOR_HOOKFUNCTION(ons_GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(ons_SpectateCopy)
-{
+{SELFPARAM();
        self.ons_roundlost = other.ons_roundlost; // make spectators see it too
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE) // command was already handled?
                return false;
 
@@ -2040,7 +1993,7 @@ MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand)
 }
 
 MUTATOR_HOOKFUNCTION(ons_PlayerUseKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE || gameover) { return false; }
 
        if((time > self.teleport_antispam) && (self.deadflag == DEAD_NO) && !self.vehicle)
@@ -2075,7 +2028,7 @@ keys:
 "target" - first control point.
 "target2" - second control point.
  */
-void spawnfunc_onslaught_link()
+spawnfunc(onslaught_link)
 {
        if(!g_onslaught) { remove(self); return; }
 
@@ -2100,7 +2053,7 @@ keys:
 "message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
  */
 
-void spawnfunc_onslaught_controlpoint()
+spawnfunc(onslaught_controlpoint)
 {
        if(!g_onslaught) { remove(self); return; }
 
@@ -2116,7 +2069,7 @@ keys:
 "team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
  */
-void spawnfunc_onslaught_generator()
+spawnfunc(onslaught_generator)
 {
        if(!g_onslaught) { remove(self); return; }
        if(!self.team) { objerror("team must be set"); }
@@ -2145,11 +2098,6 @@ void ons_DelayedInit() // Do this check with a delay so we can wait for teams to
 
 void ons_Initialize()
 {
-       precache_sound("ctf/red_capture.wav");
-       precache_sound("ctf/blue_capture.wav");
-       precache_sound("ctf/yellow_capture.wav");
-       precache_sound("ctf/pink_capture.wav");
-
        ons_captureshield_force = autocvar_g_onslaught_shield_force;
 
        addstat(STAT_ROUNDLOST, AS_INT, ons_roundlost);
@@ -2190,7 +2138,7 @@ MUTATOR_DEFINITION(gamemode_onslaught)
 
        MUTATOR_ONREMOVE
        {
-               print("This is a game type and it cannot be removed at runtime.");
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
                return -1;
        }