]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_nades.qc
Merge branch 'master' into Mario/nade_fixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_nades.qc
index 88e83a960b02a89093429d6eebc1eed675bde25d..60b2acce56053ea2b1d2ab295b393c99737a0df6 100644 (file)
@@ -129,9 +129,9 @@ void nade_napalm_ball()
        proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
        proj.effects = EF_LOWPRECISION | EF_FLAME;
 
-       kick_x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
-       kick_y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
-       kick_z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
+       kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
+       kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
+       kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
        proj.velocity = kick;
 
        proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
@@ -219,7 +219,7 @@ void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
        else { DropBall(frost_target.ballcarried, frost_target.origin, frost_target.velocity);}
        if(frost_target.flagcarried) { ctf_Handle_Throw(frost_target, world, DROP_THROW); }
        if(frost_target.nade) { toss_nade(frost_target, '0 0 0', time + 0.05); }
-       
+
        kh_Key_DropAll(frost_target, false);
 }
 
@@ -268,9 +268,9 @@ void nade_ice_think()
        float randomw;
        randomw = random()*M_PI*2;
        vector randomp;
-       randomp_x = randomr*cos(randomw);
-       randomp_y = randomr*sin(randomw);
-       randomp_z = 1;
+       randomp.x = randomr*cos(randomw);
+       randomp.y = randomr*sin(randomw);
+       randomp.z = 1;
        pointparticles(particleeffectnum("electro_muzzleflash"), self.origin + randomp, '0 0 0', 1);
 
        if(time >= self.nade_special_time)
@@ -383,9 +383,9 @@ void nade_heal_think()
                remove(self);
                return;
        }
-       
+
        self.nextthink = time;
-       
+
        if(time >= self.nade_special_time)
        {
                self.nade_special_time = time+0.25;
@@ -420,15 +420,15 @@ void nade_heal_touch()
                                        pointparticles(particleeffectnum("healing_fx"), other.origin, '0 0 0', 1);
                                other.health = min(other.health+health_factor, maxhealth);
                        }
-                       other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);  
+                       other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
                }
                else if ( health_factor < 0 )
                {
                        Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL,other.origin,'0 0 0');
                }
-               
+
        }
-       
+
        if ( IS_REAL_CLIENT(other) || (other.vehicle_flags & VHF_ISVEHICLE) )
        {
                entity show_red = (other.vehicle_flags & VHF_ISVEHICLE) ? other.owner : other;
@@ -455,9 +455,9 @@ void nade_heal_boom()
        healer.healer_radius = autocvar_g_nades_nade_radius;
        vector size = '1 1 1' * healer.healer_radius / 2;
        setsize(healer,-size,size);
-       
+
        Net_LinkEntity(healer, true, 0, healer_send);
-       
+
        healer.think = nade_heal_think;
        healer.nextthink = time;
        healer.SendFlags |= 1;
@@ -466,7 +466,7 @@ void nade_heal_boom()
 void nade_monster_boom()
 {
        entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
-       
+
        if(autocvar_g_nades_pokenade_monster_lifetime > 0)
                e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
        e.monster_skill = MONSTER_SKILL_INSANE;
@@ -551,17 +551,17 @@ void nade_boom()
 
 void nade_touch()
 {
-       float is_weapclip = 0;
+       /*float is_weapclip = 0;
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
        if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
        if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
-               is_weapclip = 1;
-       if(ITEM_TOUCH_NEEDKILL() || is_weapclip)
+               is_weapclip = 1;*/
+       if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
        {
                remove(self);
                return;
        }
-       
+
        PROJECTILE_TOUCH;
 
        //setsize(self, '-2 -2 -2', '2 2 2');
@@ -639,7 +639,7 @@ void nade_damage(entity inflictor, entity attacker, float damage, float deathtyp
        }
 
        self.health -= damage;
-       
+
        if ( self.nade_type != NADE_TYPE_HEAL || IS_PLAYER(attacker) )
                self.realowner = attacker;
 
@@ -666,7 +666,13 @@ void toss_nade(entity e, vector _velocity, float _time)
 
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES);
 
-       setorigin(_nade, w_shotorg + (v_right * 25) * -1);
+       vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
+                                 + (v_right * autocvar_g_nades_throw_offset.y)
+                                 + (v_up * autocvar_g_nades_throw_offset.z);
+       if(autocvar_g_nades_throw_offset == '0 0 0')
+               offset = '0 0 0';
+
+       setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
        //setmodel(_nade, "models/weapons/v_ok_grenade.md3");
        //setattachment(_nade, world, "");
        PROJECTILE_MAKETRIGGER(_nade);
@@ -677,7 +683,7 @@ void toss_nade(entity e, vector _velocity, float _time)
        if (trace_startsolid)
                setorigin(_nade, e.origin);
 
-       if(self.v_angle.x >= 70 && self.v_angle.x <= 110)
+       if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && self.BUTTON_CROUCH)
                _nade.velocity = '0 0 100';
        else if(autocvar_g_nades_nade_newton_style == 1)
                _nade.velocity = e.velocity + _velocity;
@@ -767,7 +773,7 @@ float nade_customize()
                        self.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(self.nade_type, false), self.team));
                self.alpha = 1;
        }
-       
+
        return true;
 }
 
@@ -797,7 +803,7 @@ void nade_prime()
                n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
                n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
        }
-       
+
        n.nade_type = bound(1, n.nade_type, NADE_TYPE_LAST);
 
        setmodel(n, "models/weapons/v_ok_grenade.md3");
@@ -912,7 +918,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
 
        if(g_grappling_hook || client_hasweapon(self, WEP_HOOK, false, false) || (weaponsInMap & WEPSET_HOOK))
                key_pressed = self.button16; // if hook is enabled, use an alternate key
-               
+
        if(self.nade)
        {
                self.nade_timer = bound(0, (time - self.nade.lifetime) / autocvar_g_nades_nade_lifetime, 1);
@@ -961,7 +967,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
                                time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
                        else
                                time_score = autocvar_g_nades_bonus_score_time;
-                               
+
                        if(key_count)
                                time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
 
@@ -975,7 +981,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
                                self.nade_type = autocvar_g_nades_bonus_type;
                                self.pokenade_type = autocvar_g_nades_pokenade_monster_type;
                        }
-                               
+
                        self.nade_type = bound(1, self.nade_type, NADE_TYPE_LAST);
 
                        if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
@@ -1050,7 +1056,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerSpawn)
        {
                setorigin(self, self.nade_spawnloc.origin);
                self.nade_spawnloc.cnt -= 1;
-               
+
                if(self.nade_spawnloc.cnt <= 0)
                {
                        remove(self.nade_spawnloc);
@@ -1111,7 +1117,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDamage)
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
                Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
        }
-       
+
        return false;
 }
 
@@ -1172,7 +1178,7 @@ void nades_Initialize()
        addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
        addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
        addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
-       
+
        precache_model("models/ok_nade_counter/ok_nade_counter.md3");
        precache_model("models/weapons/h_ok_grenade.iqm");
        precache_model("models/weapons/v_ok_grenade.md3");