]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/nades/nades.qc
Merged master.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / nades.qc
index c09e221e469ec96b7e912b3bc0491dd372cc68e7..9447ba3955e9d14355a539e45dc702b81612243a 100644 (file)
@@ -74,7 +74,7 @@ MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
 
        if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
        {
-               loopsound(proj, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
+               loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
                proj.mins = '-16 -16 -16';
                proj.maxs = '16 16 16';
        }
@@ -133,7 +133,7 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan
                DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
 
                if(autocvar_hud_panel_ammo_text)
-                       drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
                if(draw_expanding)
                        drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
@@ -220,7 +220,7 @@ void napalm_damage(entity this, float dist, float damage, float edgedamage, floa
        {
                d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
                d = damage + (edgedamage - damage) * (d / dist);
-               Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE);
+               Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
                //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
                Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
        }
@@ -265,7 +265,7 @@ void nade_napalm_ball(entity this)
        entity proj;
        vector kick;
 
-       spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
+       spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
 
        proj = new(grenade);
        proj.owner = this.owner;
@@ -577,7 +577,7 @@ void nade_entrap_touch(entity this, entity toucher)
                if(!pushdeltatime) return;
 
                // div0: ticrate independent, 1 = identity (not 20)
-               toucher.velocity = toucher.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime);
+               toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
 
        #ifdef SVQC
                UpdateCSQCProjectile(toucher);
@@ -738,7 +738,7 @@ void nade_boom(entity this)
 
        IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
        {
-               RemoveGrapplingHook(it.realowner);
+               RemoveHook(it);
        });
 
        delete(this);
@@ -769,7 +769,6 @@ void nade_touch(entity this, entity toucher)
        if(autocvar_g_nades_pickup)
        if(time >= this.spawnshieldtime)
        if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much
-       if(!STAT(FROZEN, toucher))
        if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
        if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
        {
@@ -787,7 +786,7 @@ void nade_touch(entity this, entity toucher)
        {
                IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
                {
-                       RemoveGrapplingHook(it.realowner);
+                       RemoveHook(it);
                });
                delete(this);
                return;
@@ -799,7 +798,7 @@ void nade_touch(entity this, entity toucher)
        //UpdateCSQCProjectile(this);
        if(this.health == this.max_health)
        {
-               spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM);
+               spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
                return;
        }
 
@@ -893,7 +892,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
        makevectors(e.v_angle);
 
        // NOTE: always throw from first weapon entity?
-       W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
+       W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0);
 
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
 
@@ -1036,6 +1035,8 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        if(Nades_from(n.nade_type) == NADE_TYPE_Null)
                n.nade_type = NADE_TYPE_NORMAL.m_id;
 
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+
        setmodel(n, MDL_PROJECTILE_NADE);
        //setattachment(n, player, "bip01 l hand");
        n.exteriormodeltoclient = player;
@@ -1050,10 +1051,10 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        setthink(n, nade_beep);
        n.nextthink = max(n.wait - 3, time);
        n.projectiledeathtype = DEATH_NADE.m_id;
+       n.weaponentity_fld = weaponentity;
        n.nade_lifetime = ntime;
 
        setmodel(fn, MDL_NADE_VIEW);
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
        setattachment(fn, player.(weaponentity), "");
        fn.realowner = fn.owner = player;
        fn.colormod = Nades_from(n.nade_type).m_color;
@@ -1061,6 +1062,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        fn.glowmod = player.glowmod;
        setthink(fn, SUB_Remove);
        fn.nextthink = n.wait;
+       fn.weaponentity_fld = weaponentity;
 
        player.nade = n;
        player.fake_nade = fn;
@@ -1103,9 +1105,6 @@ bool CanThrowNade(entity this)
        if(this.vehicle)
                return false;
 
-       if(gameover)
-               return false;
-
        if(IS_DEAD(this))
                return false;
 
@@ -1374,19 +1373,19 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
        if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
                toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
 
-       float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
-
        if(IS_PLAYER(frag_attacker))
        {
+               float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
+
                if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
                        nades_RemoveBonus(frag_attacker);
                else if(frag_target.flagcarried)
                        nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
-               else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
+               else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
                {
                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
                                case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
-                       switch(frag_attacker.killcount)
+                       switch(CS(frag_attacker).killcount)
                        {
                                KILL_SPREE_LIST
                                default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
@@ -1400,7 +1399,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
        nades_RemoveBonus(frag_target);
 }
 
-MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
+MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
 {
        entity frag_inflictor = M_ARGV(0, entity);
        entity frag_attacker = M_ARGV(1, entity);