]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
Unhardcode a few more 0 slot cases
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / nexball / nexball.qc
index a3d68a2eb0cf51818c6511de79acb17f0806eb55..29bdd265fc5f2a6dc59629b41c1250c3d8e5d6de 100644 (file)
@@ -1,6 +1,5 @@
 #include "nexball.qh"
 
-#ifdef IMPLEMENTATION
 #ifdef CSQC
 int autocvar_cl_eventchase_nexball = 1;
 
@@ -191,12 +190,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)
@@ -459,7 +458,7 @@ spawnfunc(nexball_team)
 
 void nb_spawnteam(string teamname, float teamcolor)
 {
-       LOG_TRACE("^2spawned team ", teamname, "\n");
+       LOG_TRACE("^2spawned team ", teamname);
        entity e = new(nexball_team);
        e.netname = teamname;
        e.cnt = teamcolor;
@@ -836,6 +835,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);
 }
@@ -899,19 +899,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;
@@ -1000,8 +1000,8 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink)
                                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);
+                               player.(weaponentity).m_switchweapon = player.m_switchweapon;
+                               W_SwitchWeapon(player, player.(weaponentity).m_switchweapon, weaponentity);
 
                                player.(weaponentity).weapons = '0 0 0';
                        }
@@ -1025,8 +1025,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);
@@ -1053,15 +1056,17 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPhysics)
 MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon)
 {
        entity player = M_ARGV(0, entity);
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 
-       return PS(player).m_weapon == WEP_NEXBALL;
+       return player.(weaponentity).m_weapon == WEP_NEXBALL;
 }
 
 MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon)
 {
        entity player = M_ARGV(0, entity);
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 
-       return PS(player).m_weapon == WEP_MORTAR; // TODO: what is this for?
+       return player.(weaponentity).m_weapon == WEP_MORTAR; // TODO: what is this for?
 }
 
 MUTATOR_HOOKFUNCTION(nb, FilterItem)
@@ -1086,7 +1091,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;
@@ -1157,4 +1162,3 @@ REGISTER_MUTATOR(nb, g_nexball)
 }
 
 #endif
-#endif