]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
Merge branch 'master' into Mario/wepent_experimental
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / nexball / nexball.qc
index 9c6c9f0803941379bb39e765980cd4bc6361b133..2cad55f166da384fd9c254179b028dc5079530a6 100644 (file)
@@ -34,6 +34,7 @@ float autocvar_g_nexball_football_bouncestop;
 bool autocvar_g_nexball_radar_showallplayers;
 bool autocvar_g_nexball_sound_bounce;
 int autocvar_g_nexball_trail_color;
+bool autocvar_g_nexball_playerclip_collisions = true;
 
 float autocvar_g_nexball_safepass_turnrate;
 float autocvar_g_nexball_safepass_maxdist;
@@ -103,9 +104,9 @@ void nexball_setstatus(entity this)
        {
                if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time))
                {
-                       bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
-                       DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_NEXBALL_RETURN_HELD));
                        entity e = this.ballcarried;
+                       DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0');
                        ResetBall(e);
                }
                else
@@ -167,6 +168,7 @@ void GiveBall(entity plyr, entity ball)
                ball.teamtime = time + autocvar_g_nexball_basketball_delay_hold_forteam;
 
        ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it
+       ball.weaponentity_fld = weaponentity;
        ball.team = plyr.team;
        plyr.ballcarried = ball;
        ball.nb_dropper = plyr;
@@ -190,12 +192,12 @@ void GiveBall(entity plyr, entity ball)
        }
 
        plyr.(weaponentity).weapons = plyr.weapons;
-       plyr.(weaponentity).m_switchweapon = PS(plyr).m_weapon;
+       plyr.m_switchweapon = plyr.(weaponentity).m_weapon;
        plyr.weapons = WEPSET(NEXBALL);
        Weapon w = WEP_NEXBALL;
        w.wr_resetplayer(w, plyr);
-       PS(plyr).m_switchweapon = WEP_NEXBALL;
-       W_SwitchWeapon(plyr, WEP_NEXBALL);
+       plyr.(weaponentity).m_switchweapon = WEP_NEXBALL;
+       W_SwitchWeapon(plyr, WEP_NEXBALL, weaponentity);
 }
 
 void DropBall(entity ball, vector org, vector vel)
@@ -218,7 +220,7 @@ void DropBall(entity ball, vector org, vector vel)
        if(ball.owner.metertime)
        {
                ball.owner.metertime = 0;
-               .entity weaponentity = weaponentities[0]; // TODO: find ballstealer
+               .entity weaponentity = ball.weaponentity_fld;
                ball.owner.(weaponentity).state = WS_READY;
        }
 
@@ -255,7 +257,7 @@ void ResetBall(entity this)
        if(this.cnt < 2)        // step 1
        {
                if(time == this.teamtime)
-                       bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n");
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_NEXBALL_RETURN_HELD));
 
                settouch(this, func_null);
                set_movetype(this, MOVETYPE_NOCLIP);
@@ -552,6 +554,12 @@ void SpawnBall(entity this)
 
        set_movetype(this, MOVETYPE_FLY);
 
+       if(autocvar_g_nexball_playerclip_collisions)
+       {
+               this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP;
+               this.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
+       }
+
        if(!autocvar_g_nexball_sound_bounce)
                this.noise = "";
        else if(this.noise == "")
@@ -835,6 +843,7 @@ void W_Nexball_Attack2(entity actor, .entity weaponentity)
        missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
        missile.flags = FL_PROJECTILE;
        IL_PUSH(g_projectiles, missile);
+       IL_PUSH(g_bot_dodge, missile);
 
        CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
 }
@@ -898,19 +907,19 @@ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity we
     }
 }
 
-METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor))
+METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor, .entity weaponentity))
 {
     TC(BallStealer, this);
     //weapon_setup(WEP_PORTO.m_id);
 }
 
-METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor))
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor, .entity weaponentity))
 {
     TC(BallStealer, this);
     return true;
 }
 
-METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor))
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor, .entity weaponentity))
 {
     TC(BallStealer, this);
     return true;
@@ -993,16 +1002,20 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
                }
                else
                {
-                       .entity weaponentity = weaponentities[0]; // TODO
-                       if(player.(weaponentity).weapons)
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                        {
-                               player.weapons = player.(weaponentity).weapons;
-                               Weapon w = WEP_NEXBALL;
-                               w.wr_resetplayer(w, player);
-                               PS(player).m_switchweapon = player.(weaponentity).m_switchweapon;
-                               W_SwitchWeapon(player, PS(player).m_switchweapon);
+                               .entity weaponentity = weaponentities[slot];
+
+                               if(player.(weaponentity).weapons)
+                               {
+                                       player.weapons = player.(weaponentity).weapons;
+                                       Weapon w = WEP_NEXBALL;
+                                       w.wr_resetplayer(w, player);
+                                       player.(weaponentity).m_switchweapon = player.m_switchweapon;
+                                       W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
 
-                               player.(weaponentity).weapons = '0 0 0';
+                                       player.(weaponentity).weapons = '0 0 0';
+                               }
                        }
                }
 
@@ -1024,8 +1037,11 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn)
        entity player = M_ARGV(0, entity);
 
        player.metertime = 0;
-       .entity weaponentity = weaponentities[0];
-       player.(weaponentity).weapons = '0 0 0';
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               player.(weaponentity).weapons = '0 0 0';
+       }
 
        if (nexball_mode & NBM_BASKETBALL)
                player.weapons |= WEPSET(NEXBALL);
@@ -1051,16 +1067,18 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPhysics)
 
 MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
 {
-       entity player = M_ARGV(0, entity);
+       //entity player = M_ARGV(0, entity);
+       entity wepent = M_ARGV(1, entity);
 
-       return PS(player).m_weapon == WEP_NEXBALL;
+       return wepent.m_weapon == WEP_NEXBALL;
 }
 
 MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
 {
-       entity player = M_ARGV(0, entity);
+       //entity player = M_ARGV(0, entity);
+       int wep = M_ARGV(1, int);
 
-       return PS(player).m_weapon == WEP_MORTAR; // TODO: what is this for?
+       return wep == WEP_MORTAR.m_id; // TODO: what is this for?
 }
 
 MUTATOR_HOOKFUNCTION(nb, FilterItem)
@@ -1085,7 +1103,7 @@ MUTATOR_HOOKFUNCTION(nb, ItemTouch)
        return MUT_ITEMTOUCH_CONTINUE;
 }
 
-MUTATOR_HOOKFUNCTION(nb, GetTeamCount)
+MUTATOR_HOOKFUNCTION(nb, CheckAllowedTeams)
 {
        M_ARGV(1, string) = "nexball_team";
        return true;