X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fgamemode_onslaught.qc;h=8b2e223c041fe0756db6072621e04e73dccb162a;hb=21307f327df5609b82d90496c1c6156d636d1c8d;hp=12035f413b1c45cf4b73efb9c74ff72dd3d9c878;hpb=c67e77ba36fb8dd44b39722e41943b6671b549ff;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 12035f413..8b2e223c0 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -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; } @@ -73,10 +64,10 @@ void ons_CaptureShield_Spawn(entity generator, bool is_generator) shield.avelocity = '7 0 11'; shield.scale = 1; shield.model = ((is_generator) ? "models/onslaught/generator_shield.md3" : "models/onslaught/controlpoint_shield.md3"); - + 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,13 +253,13 @@ 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; - + if(self.goalentity.islinked || self.goalentity.iscaptured) { cc1 = (self.goalentity.team - 1) * 0x01; } if(self.enemy.islinked || self.enemy.iscaptured) { cc2 = (self.enemy.team - 1) * 0x10; } - + cc = cc1 + cc2; if(cc != self.clientcolors) @@ -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,22 +376,22 @@ 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, "weapons/grenade_impact.wav", 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); PlayerScore_Add(attacker, SP_SCORE, 10); - + self.owner.goalentity = world; self.owner.islinked = false; self.owner.iscaptured = false; @@ -414,26 +403,24 @@ 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); } - + self.SendFlags |= CPSF_STATUS; } 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; @@ -524,7 +509,7 @@ void ons_ControlPoint_Icon_BuildThink() return; self.health = self.health + self.count; - + self.SendFlags |= CPSF_STATUS; if (self.health >= self.max_health) @@ -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; - pointparticles(particleeffectnum(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); @@ -549,34 +534,35 @@ void ons_ControlPoint_Icon_BuildThink() PlayerScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, 1); PlayerTeamScore_AddScore(self.owner.ons_toucher, 10); } - + self.owner.ons_toucher = world; 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) - pointparticles(particleeffectnum("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(); - + setsize(e, CPICON_MIN, CPICON_MAX); setorigin(e, cp.origin + CPICON_OFFSET); - + e.classname = "onslaught_controlpoint_icon"; e.owner = cp; e.max_health = autocvar_g_onslaught_cp_health; @@ -588,14 +574,14 @@ void ons_ControlPoint_Icon_Spawn(entity cp, entity player) e.team = player.team; 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; - pointparticles(particleeffectnum(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,20 +651,20 @@ void ons_ControlPoint_UpdateSprite(entity e) } void ons_ControlPoint_Touch() -{ +{SELFPARAM(); entity toucher = other; int attackable; - - if((toucher.vehicle_flags & VHF_ISVEHICLE) && toucher.owner) + + if(IS_VEHICLE(toucher) && toucher.owner) if(autocvar_g_onslaught_allow_vehicle_touch) toucher = toucher.owner; else return; - + if(!IS_PLAYER(toucher)) { return; } if(toucher.frozen) { return; } if(toucher.deadflag != DEAD_NO) { return; } - + if ( SAME_TEAM(self,toucher) ) if ( self.iscaptured ) { @@ -688,7 +673,7 @@ void ons_ControlPoint_Touch() else Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_ONS_TELEPORT); } - + attackable = ons_ControlPoint_Attackable(self, toucher.team); if(attackable != 2 && attackable != 4) return; @@ -696,20 +681,20 @@ void ons_ControlPoint_Touch() // so start building the captured point icon (which only captures this // point if it successfully builds without being destroyed first) ons_ControlPoint_Icon_Spawn(self, toucher); - + self.ons_toucher = toucher; onslaught_updatelinks(); } 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,28 +717,28 @@ 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 ons_worldcplist = cp; - + cp.netname = "Control point"; cp.team = 0; cp.solid = SOLID_BBOX; @@ -766,31 +751,12 @@ void ons_ControlPoint_Setup(entity cp) cp.iscaptured = false; cp.islinked = false; cp.isshielded = true; - + 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("weapons/grenade_impact.wav"); - 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,15 +767,15 @@ 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, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); + sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); } else { // particles on every hit - pointparticles(particleeffectnum("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; @@ -970,21 +936,21 @@ void ons_GeneratorReset() self.event_damage = ons_GeneratorDamage; self.think = ons_GeneratorThink; self.nextthink = time + GEN_THINKRATE; - + Net_LinkEntity(self, false, 0, generator_send); - + self.SendFlags = GSF_SETUP; // just incase self.SendFlags |= GSF_STATUS; WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health); WaypointSprite_UpdateHealth(self.sprite, self.health); WaypointSprite_UpdateRule(self.sprite,self.team,SPRITERULE_TEAMPLAY); - + onslaught_updatelinks(); } void ons_DelayedGeneratorSetup() -{ +{SELFPARAM(); // bot waypoints waypoint_spawnforitem_force(self, self.origin); self.nearestwaypointtimeout = 0; // activate waypointing again @@ -992,15 +958,15 @@ void ons_DelayedGeneratorSetup() // captureshield setup ons_CaptureShield_Spawn(self, true); - + onslaught_updatelinks(); - + Net_LinkEntity(self, false, 0, generator_send); } void onslaught_generator_touch() -{ +{SELFPARAM(); if ( IS_PLAYER(other) ) if ( SAME_TEAM(self,other) ) if ( self.iscaptured ) @@ -1010,15 +976,15 @@ 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 ons_worldgeneratorlist = gen; - + gen.netname = sprintf("%s generator", Team_ColoredFullName(teamnumber)); gen.classname = "onslaught_generator"; gen.solid = SOLID_BBOX; @@ -1035,37 +1001,23 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o gen.islinked = true; 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("weapons/grenade_impact.wav"); - precache_sound("weapons/rocket_impact.wav"); - 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); setorigin(gen, (gen.origin + CPGEN_SPAWN_OFFSET)); 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); - + InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION); } @@ -1119,7 +1071,7 @@ int Onslaught_GetWinnerTeam() bool Onslaught_CheckWinner() { entity e; - + if ((autocvar_timelimit && time > game_starttime + autocvar_timelimit * 60) || (round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)) { ons_stalemate = true; @@ -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,8 +1103,8 @@ 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; tmp_entity.ons_overtime_damagedelay = time + 1; @@ -1161,7 +1113,7 @@ bool Onslaught_CheckWinner() else { wpforenemy_announced = false; ons_stalemate = false; } Onslaught_count_generators(); - + if(ONS_OWNED_GENERATORS_OK()) return 0; @@ -1178,13 +1130,13 @@ bool Onslaught_CheckWinner() Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED); Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED); } - + 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); - + FOR_EACH_PLAYER(e) { e.ons_roundlost = true; @@ -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) @@ -1580,7 +1532,7 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist) closest_target = tmp_entity; tmp_entity = tmp_entity.chain; } - + return closest_target; } @@ -1590,18 +1542,18 @@ 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; - + tmp_entity = findchain(classname, "onslaught_controlpoint"); while(tmp_entity) { delta = tmp_entity.origin - pos; delta_z = 0; distance = vlen(delta); - + if(SAME_TEAM(tmp_entity, self)) if(tmp_entity.iscaptured) if(max_dist <= 0 || distance <= max_dist) @@ -1610,7 +1562,7 @@ entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist) closest_target = tmp_entity; smallest_distance = distance; } - + tmp_entity = tmp_entity.chain; } tmp_entity = findchain(classname, "onslaught_generator"); @@ -1619,7 +1571,7 @@ entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist) delta = tmp_entity.origin - pos; delta_z = 0; distance = vlen(delta); - + if(SAME_TEAM(tmp_entity, self)) if(max_dist <= 0 || distance <= max_dist) if(closest_target == world || distance <= smallest_distance ) @@ -1627,17 +1579,17 @@ entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist) closest_target = tmp_entity; smallest_distance = distance; } - + tmp_entity = tmp_entity.chain; } - + return closest_target; } /** * 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; @@ -1667,7 +1619,7 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe { if ( !tele_target ) return false; - + int i; vector loc; float theta; @@ -1678,9 +1630,9 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe loc_x = cos(theta); loc_z = 0; loc *= random() * range; - + loc += tele_target.origin + '0 0 128'; - + tracebox(loc, PL_MIN, PL_MAX, loc, MOVE_NORMAL, player); if(trace_fraction == 1.0 && !trace_startsolid) { @@ -1689,8 +1641,8 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe { if ( tele_effects ) { - pointparticles(particleeffectnum("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,12 +1651,12 @@ 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 ) - pointparticles(particleeffectnum("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; } } } - + return false; } @@ -1713,30 +1665,31 @@ 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; return false; } - + entity l; for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext) { @@ -1756,14 +1709,14 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) self.ons_spawn_by = world; return false; } - + if(autocvar_g_onslaught_spawn_at_controlpoints) if(random() <= autocvar_g_onslaught_spawn_at_controlpoints_chance) { float random_target = autocvar_g_onslaught_spawn_at_controlpoints_random; entity tmp_entity, closest_target = world; vector spawn_loc = self.ons_deathloc; - + // new joining player or round reset, don't bother checking if(spawn_loc == '0 0 0') { return false; } @@ -1777,9 +1730,9 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) else if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world) closest_target = tmp_entity; } - + if(random_target) { closest_target = RandomSelection_chosen_ent; } - + if(closest_target) { float i; @@ -1802,17 +1755,17 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) } } } - + if(autocvar_g_onslaught_spawn_at_generator) if(random() <= autocvar_g_onslaught_spawn_at_generator_chance) { float random_target = autocvar_g_onslaught_spawn_at_generator_random; entity tmp_entity, closest_target = world; vector spawn_loc = self.ons_deathloc; - + // new joining player or round reset, don't bother checking if(spawn_loc == '0 0 0') { return false; } - + if(random_target) { RandomSelection_Init(); } for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext) @@ -1826,9 +1779,9 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn) closest_target = tmp_entity; } } - + if(random_target) { closest_target = RandomSelection_chosen_ent; } - + if(closest_target) { float i; @@ -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) @@ -1867,16 +1820,16 @@ MUTATOR_HOOKFUNCTION(ons_PlayerDies) { l.sprite.SendFlags |= 16; } - + if ( autocvar_g_onslaught_spawn_choose ) if ( ons_Count_SelfControlPoints() > 1 ) stuffcmd(self, "qc_cmd_cl hud clickradar\n"); - + return false; } MUTATOR_HOOKFUNCTION(ons_MonsterThink) -{ +{SELFPARAM(); entity e = find(world, targetname, self.target); if (e != world) self.team = e.team; @@ -1885,28 +1838,28 @@ MUTATOR_HOOKFUNCTION(ons_MonsterThink) } void ons_MonsterSpawn_Delayed() -{ +{SELFPARAM(); entity e, own = self.owner; - + if(!own) { remove(self); return; } - + if(own.targetname) { e = find(world, target, own.targetname); if(e != world) { own.team = e.team; - + activator = e; own.use(); } } - + remove(self); } 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; } @@ -1927,7 +1880,7 @@ void ons_TurretSpawn_Delayed() { own.team = e.team; own.active = ACTIVE_NOT; - + activator = e; own.use(); } @@ -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; @@ -1989,28 +1942,28 @@ MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand) pos_y = stof(argv(2)); if(cmd_argc > 3) pos_z = stof(argv(3)); - + if ( IS_PLAYER(self) ) { if ( !self.frozen ) { entity source_point = ons_Nearest_ControlPoint(self.origin, autocvar_g_onslaught_teleport_radius); - + if ( !source_point && self.health > 0 ) { sprint(self, "\nYou need to be next to a control point\n"); return 1; } - - + + entity closest_target = ons_Nearest_ControlPoint_2D(pos, autocvar_g_onslaught_click_radius); - + if ( closest_target == world ) { sprint(self, "\nNo control point found\n"); return 1; } - + if ( self.health <= 0 ) { self.ons_spawn_by = closest_target; @@ -2023,26 +1976,26 @@ MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand) sprint(self, "\nTeleporting to the same point\n"); return 1; } - + if ( !ons_Teleport(self,closest_target,autocvar_g_onslaught_teleport_radius,true) ) sprint(self, "\nUnable to teleport there\n"); } - + return 1; } - + sprint(self, "\nNo teleportation for you\n"); } - + return 1; } return 0; } MUTATOR_HOOKFUNCTION(ons_PlayerUseKey) -{ +{SELFPARAM(); if(MUTATOR_RETURNVALUE || gameover) { return false; } - + if((time > self.teleport_antispam) && (self.deadflag == DEAD_NO) && !self.vehicle) { entity source_point = ons_Nearest_ControlPoint(self.origin, autocvar_g_onslaught_teleport_radius); @@ -2052,7 +2005,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerUseKey) return true; } } - + return false; } @@ -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,10 +2053,10 @@ 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; } - + ons_ControlPoint_Setup(self); } @@ -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"); } @@ -2138,18 +2091,13 @@ void ons_ScoreRules() void ons_DelayedInit() // Do this check with a delay so we can wait for teams to be set up { ons_ScoreRules(); - + round_handler_Spawn(Onslaught_CheckPlayers, Onslaught_CheckWinner, Onslaught_RoundStart); round_handler_Init(5, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit); } 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; }