]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_hagar.qc
Limit maximum length of vote commands to 160 by default
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_hagar.qc
index 76d2f9414aef874b2a883460bd22c64d3d0867d9..0be6ea527e4e20f125eed0586c54b094e092b8db 100644 (file)
@@ -1,12 +1,22 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", _("Hagar"))
+REGISTER_WEAPON(
+/* WEP_##id  */ HAGAR,
+/* function  */ w_hagar,
+/* ammotype  */ IT_ROCKETS,
+/* impulse   */ 8,
+/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
+/* rating    */ BOT_PICKUP_RATING_MID,
+/* model     */ "hagar",
+/* shortname */ "hagar",
+/* fullname  */ _("Hagar")
+);
 #else
 #ifdef SVQC
 // NO bounce protection, as bounces are limited!
 
 void W_Hagar_Explode (void)
 {
-       self.event_damage = SUB_Null;
+       self.event_damage = func_null;
        RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_primary_damage, autocvar_g_balance_hagar_primary_edgedamage, autocvar_g_balance_hagar_primary_radius, world, autocvar_g_balance_hagar_primary_force, self.projectiledeathtype, other);
 
        remove (self);
@@ -14,7 +24,7 @@ void W_Hagar_Explode (void)
 
 void W_Hagar_Explode2 (void)
 {
-       self.event_damage = SUB_Null;
+       self.event_damage = func_null;
        RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_secondary_damage, autocvar_g_balance_hagar_secondary_edgedamage, autocvar_g_balance_hagar_secondary_radius, world, autocvar_g_balance_hagar_secondary_force, self.projectiledeathtype, other);
 
        remove (self);
@@ -25,10 +35,15 @@ void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deat
        if (self.health <= 0)
                return;
                
-       float is_linkexplode = ((inflictor.realowner == self.realowner) 
-               && ((inflictor.projectiledeathtype & HITTYPE_SECONDARY) && (self.projectiledeathtype & HITTYPE_SECONDARY))
-               && autocvar_g_balance_hagar_secondary_load_linkexplode);
-               
+       float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
+               && (inflictor.projectiledeathtype & HITTYPE_SECONDARY) 
+               && (self.projectiledeathtype & HITTYPE_SECONDARY));
+       
+       if(is_linkexplode)
+               is_linkexplode = (is_linkexplode && autocvar_g_balance_hagar_secondary_load_linkexplode);
+       else
+               is_linkexplode = -1; // not secondary load, so continue as normal without exception.
+
        if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
                return; // g_projectiles_damage says to halt
 
@@ -62,7 +77,7 @@ void W_Hagar_Touch2 (void)
 
 void W_Hagar_Attack (void)
 {
-       local entity missile;
+       entity missile;
 
        W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
 
@@ -96,6 +111,7 @@ void W_Hagar_Attack (void)
 
        missile.angles = vectoangles (missile.velocity);
        missile.flags = FL_PROJECTILE;
+       missile.missile_flags = MIF_SPLASH; 
 
        CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
 
@@ -104,7 +120,7 @@ void W_Hagar_Attack (void)
 
 void W_Hagar_Attack2 (void)
 {
-       local entity missile;
+       entity missile;
 
        W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
 
@@ -139,6 +155,7 @@ void W_Hagar_Attack2 (void)
 
        missile.angles = vectoangles (missile.velocity);
        missile.flags = FL_PROJECTILE;
+       missile.missile_flags = MIF_SPLASH; 
 
        CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
 
@@ -150,9 +167,9 @@ void W_Hagar_Attack2_Load_Release (void)
 {
        // time to release the rockets we've loaded
 
-       local entity missile;
-       local float counter, shots, spread_pershot;
-       local vector s;
+       entity missile;
+       float counter, shots, spread_pershot;
+       vector s;
        vector forward, right, up;
 
        if(!self.hagar_load)
@@ -169,7 +186,7 @@ void W_Hagar_Attack2_Load_Release (void)
 
        shots = self.hagar_load;
        missile = world;
-       while (counter < shots)
+       for(counter = 0; counter < shots; ++counter)
        {
                missile = spawn ();
                missile.owner = missile.realowner = self;
@@ -192,6 +209,7 @@ void W_Hagar_Attack2_Load_Release (void)
                setorigin (missile, w_shotorg);
                setsize(missile, '0 0 0', '0 0 0');
                missile.movetype = MOVETYPE_FLY;
+               missile.missile_flags = MIF_SPLASH; 
                
                // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
                spread_pershot = ((shots - 1) / (autocvar_g_balance_hagar_secondary_load_max - 1)); 
@@ -218,8 +236,6 @@ void W_Hagar_Attack2_Load_Release (void)
                CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
 
                other = missile; MUTATOR_CALLHOOK(EditProjectile);
-
-               counter = counter + 1;
        }
 
        weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_load_animtime, w_ready);
@@ -230,8 +246,11 @@ void W_Hagar_Attack2_Load_Release (void)
 void W_Hagar_Attack2_Load (void)
 {
        // loadable hagar secondary attack, must always run each frame
+       
+       if(time < game_starttime)
+               return;
 
-       local float loaded, enough_ammo;
+       float loaded, enough_ammo;
        loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max;
 
        // this is different than WR_CHECKAMMO when it comes to reloading
@@ -344,8 +363,8 @@ float w_hagar(float req)
                }
        else if (req == WR_THINK)
        {
-               local float loadable_secondary;
-               loadable_secondary = autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary;
+               float loadable_secondary;
+               loadable_secondary = (autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary);
 
                if (loadable_secondary)
                        W_Hagar_Attack2_Load(); // must always run each frame
@@ -426,8 +445,19 @@ float w_hagar(float req)
                if not(self.hagar_load) // require releasing loaded rockets first
                        W_Reload(min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo), autocvar_g_balance_hagar_reload_ammo, autocvar_g_balance_hagar_reload_time, "weapons/reload.wav");
        }
+       else if (req == WR_SUICIDEMESSAGE)
+       {
+               return WEAPON_HAGAR_SUICIDE;
+       }
+       else if (req == WR_KILLMESSAGE)
+       {
+               if(w_deathtype & HITTYPE_SECONDARY)
+                       return WEAPON_HAGAR_MURDER_BURST;
+               else
+                       return WEAPON_HAGAR_MURDER_SPRAY;
+       }
        return TRUE;
-};
+}
 #endif
 #ifdef CSQC
 float w_hagar(float req)
@@ -453,15 +483,6 @@ float w_hagar(float req)
                precache_sound("weapons/hagexp2.wav");
                precache_sound("weapons/hagexp3.wav");
        }
-       else if (req == WR_SUICIDEMESSAGE)
-               w_deathtypestring = _("%s played with tiny rockets");
-       else if (req == WR_KILLMESSAGE)
-       {
-               if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
-                       w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
-               else // unchecked: SPLASH, SECONDARY
-                       w_deathtypestring = _("%s was pummeled by %s");
-       }
        return TRUE;
 }
 #endif