]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Now spawned vehicles from nades cannot be respawned after being deleted, no more...
authorLegendaryGuard <rootuser999@gmail.com>
Thu, 30 Jun 2022 23:09:20 +0000 (01:09 +0200)
committerLegendaryGuard <rootuser999@gmail.com>
Thu, 30 Jun 2022 23:09:20 +0000 (01:09 +0200)
mutators.cfg
qcsrc/client/main.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/nades.qh
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qh
qcsrc/server/client.qh

index 8949ed8b8ba3eb987a5cb89f5cc6f2d88e0e00d8..e4182bbd0baef0ec6b094e640c9e230d9a82212c 100644 (file)
@@ -207,6 +207,7 @@ set g_nades_nade_type 1 "Type of the off-hand grenade. 1:normal 2:napalm 3:ice 4
 seta cl_nade_timer 1 "show a visual timer for nades, 1 = only circle, 2 = circle with text"
 seta cl_nade_type 3
 seta cl_pokenade_type "zombie"
+seta cl_tandemnade_type 0
 
 // ------------
 //  Nade bonus
index 091cc466183efecd96bda5291383c2aab720acda..7038759f5b7d2df7733c5082126c1ddaf64626b2 100644 (file)
@@ -80,6 +80,7 @@ void CSQC_Init()
 
        registercvar("cl_nade_type", "3");
        registercvar("cl_pokenade_type", "zombie");
+       registercvar("cl_tandemnade_type", "0");
 
        registercvar("cl_jumpspeedcap_min", "");
        registercvar("cl_jumpspeedcap_max", "");
index d215e9c8bec003b5a6cd66a14bb3268391516e65..e12a73e4478b98a522eda56da4ffa899add8e2b3 100644 (file)
@@ -998,28 +998,24 @@ void nade_emerald_boom(entity this)
                        if(!autocvar_g_vehicles) 
                                return;
 
-                       if (vehspawncount < autocvar_g_nades_emerald_vehiclespawnlimit)
-                       {
-                               e = spawnvehicle(
-                                       e, 
-                                       "random", //this.tandemnade_type, 
-                                       VEH_Null, 
-                                       this.realowner, 
-                                       this.realowner, 
-                                       this.origin, 
-                                       false, 
-                                       false,
-                                       true
-                               );
-
-                               if(!e)
-                                       return; // vehicle failed to be spawned
-                               
-                               vehspawncount++;
-                               return;
-                       }
+                       // looks like a bad practice
+                       time = 0.7;
+
+                       e = spawnvehicle(
+                               e, 
+                               "random", 
+                               VEH_Null, 
+                               this.realowner, 
+                               this.realowner, 
+                               this.origin, 
+                               true, 
+                               false, 
+                               true
+                       );
+
+                       if(!e)
+                               return; // vehicle failed to be spawned
                        
-                       PrintToChatAll("^1Someone tried to spawn more vehicles than the maximum allowed! Sorry, cannot be spawned, spawn limit has been reached!");
                        return;
                }
                case 2:
@@ -1027,30 +1023,23 @@ void nade_emerald_boom(entity this)
                        if(!autocvar_g_turrets) 
                                return;
 
-                       if (turspawncount < autocvar_g_nades_emerald_turretspawnlimit)
-                       {
-                               e = spawnturret(
-                                       e, 
-                                       "random", //this.tandemnade_type, 
-                                       TUR_Null, 
-                                       this.realowner, 
-                                       this.realowner, 
-                                       this.origin, 
-                                       false,
-                                       false, 
-                                       false, 
-                                       1,
-                                       true
-                               );
-
-                               if(!e)
-                                       return; // turret failed to be spawned
-                               
-                               turspawncount++;
-                               return;
-                       }
+                       e = spawnturret(
+                               e, 
+                               "random", //this.tandemnade_type, 
+                               TUR_Null, 
+                               this.realowner, 
+                               this.realowner, 
+                               this.origin, 
+                               false,
+                               false, 
+                               false, 
+                               1,
+                               true
+                       );
+
+                       if(!e)
+                               return; // turret failed to be spawned
                        
-                       PrintToChatAll("^1Someone tried to spawn more vehicles than the maximum allowed! Sorry, cannot be spawned, spawn limit has been reached!");
                        return;
                }
                default:
@@ -1091,6 +1080,7 @@ void nade_emerald_boom(entity this)
                        setsize(fountain, '-16 -16 -16', '16 16 16');
                        CSQCProjectile(fountain, true, PROJECTILE_NADE_EMERALD_BURN, true);
                        nade_emerald_dropping(fountain.origin);
+                       return;
                }
        }
 }
@@ -1200,8 +1190,7 @@ void dark_damage(entity this, float radius, float damage)
 
 void nade_dark_fountain_think(entity this)
 {
-       if(round_handler_IsActive())
-       if(!round_handler_IsRoundStarted())
+       if(round_handler_IsActive() && !round_handler_IsRoundStarted())
        {
                delete(this);
                return;
index 53acefc2c89a4e36fc0dd2a1c7370eef428967b2..11b0d6b1ba1f49413c97db0ea80b9c3ccb057f52 100644 (file)
@@ -74,8 +74,6 @@ float autocvar_g_nades_emerald_ball_count = 3;
 float autocvar_g_nades_emerald_fountain_lifetime = 1; //if much time, fountain will remain
 bool autocvar_g_nades_emerald_powerupjetpack_randomdrop = 0;
 int autocvar_g_nades_emerald_dropitemselect = 0; //admin/user selects which item wants to drop in-game, if not will be random
-int autocvar_g_nades_emerald_vehiclespawnlimit = 6; //LegendGuard adds new nade cvar of vehicle spawn count limit for the server 26-06-2021
-int autocvar_g_nades_emerald_turretspawnlimit = 4; // 26-06-2021
 float autocvar_g_nades_ammo_time = 5; //LegendGuard adds new nade cvars 13-02-2021
 float autocvar_g_nades_ammo_rate = 30;
 float autocvar_g_nades_ammo_friend = 1;
@@ -168,7 +166,7 @@ REPLICATE_INIT(int, cvar_cl_tandemnade_type); //LegendGuard adds new cl variable
 .float nade_refire;
 .float nade_special_time;
 .string pokenade_type;
-.float tandemnade_type; //LegendGuard adds new cvar nade .variable 01-07-2021
+.int tandemnade_type; //LegendGuard adds new cvar nade .variable 01-07-2021
 .entity nade_damage_target;
 .float cvar_cl_nade_type;
 .string cvar_cl_pokenade_type;
@@ -177,8 +175,6 @@ REPLICATE_INIT(int, cvar_cl_tandemnade_type); //LegendGuard adds new cl variable
 .float nade_show_particles;
 .float nade_veil_prevalpha;
 .float nade_dark_prevalpha; //LegendGuard adds new nade .variable 08-02-2021
-int vehspawncount; //LegendGuard adds new .variable 22-06-2021
-int turspawncount; // 26-06-2021
 
 bool orb_send(entity this, entity to, int sf);
 
index 329e74e735fc32c44708ac72df48aa399be4cd90..3fb9f38b09bc85824e84044c550e9098e6e0dadc 100644 (file)
@@ -421,7 +421,7 @@ void vehicles_reset_colors(entity this, entity player)
        this.alpha       = 1;
        this.avelocity = '0 0 0';
        this.velocity  = '0 0 0';
-       if (this.optionalsetup)
+       if (this.optional_setup)
                this.effects = EF_DIMLIGHT;
        else 
                this.effects = eff;
@@ -519,6 +519,11 @@ void vehicles_setreturn(entity veh)
 
        if(IS_DEAD(veh))
        {
+               if (veh.cannot_respawn) 
+               {
+                       delete(veh);
+                       return;
+               }
                ret.cnt          = time + veh.respawntime;
                ret.nextthink   = min(time + veh.respawntime, time + veh.respawntime - 5);
        }
@@ -1292,16 +1297,23 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
        if(MUTATOR_CALLHOOK(VehicleInit, this))
                return false;
 
+       if(this.no_respawn_option)
+               this.cannot_respawn = true;
+
        return true;
 }
 
-entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, bool optional)
+entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool no_respwn, bool removeifinvalid, bool optional)
 {
        e.spawnflags = VHF_MULTISLOT;
-       e.optionalsetup = optional;
-       
-       // TODO: Make a respawn option, the following line isn't functional
-       if(!respwn) { e.spawnflags |= VHF_ISVEHICLE; }
+
+       // if this spawnflag isn't, it won't be spawned
+       e.spawnflags |= VHF_ISVEHICLE;
+
+       e.optional_setup = optional;
+       e.no_respawn_option = no_respwn;
+       e.cannot_respawn = false;
+
        setorigin(e, orig);
        bool allow_any = boolean(vehicle == "anyrandom");
 
@@ -1336,7 +1348,7 @@ entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, en
                                return NULL; // no good
                        }
                        // select a random valid vehicle type if no valid vehicle was provided
-                       return spawnvehicle(e, "random", VEH_Null, spawnedby, own, orig, respwn, removeifinvalid, optional);
+                       return spawnvehicle(e, "random", VEH_Null, spawnedby, own, orig, no_respwn, removeifinvalid, optional);
                }
        }
 
@@ -1352,11 +1364,10 @@ entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, en
        
        if(!(e.spawnflags & VHF_ISVEHICLE)) { delete(e); return NULL; } // remove even if told not to, as we didn't spawn any kind of vehicle
 
-       // e.angles = '0 0 0';
        e.velocity = randomvec() * 150 + '0 0 325';
        e.spawnfunc_checked = true;
-       time = 0.7;
-       
+
+       // spawn!
        vehicle_initialize(e, veh, true);
 
        return e;
index c293a287d64377f7ed2101daea29647d07b252bc..141c025e218771dc8acf6f087672bc429685970a 100644 (file)
@@ -82,7 +82,9 @@ const int MAX_AXH = 4;
 .float  lock_strength;
 .float  lock_time;
 .float  lock_soundtime;
-.bool  optionalsetup;
+.bool  optional_setup;
+.bool  no_respawn_option;
+.bool  cannot_respawn;
 
 // vehicle functions
 .void(int _spawnflag) vehicle_spawn;  /// Vehicles custom fucntion to be efecuted when vehicle (re)spawns
@@ -104,7 +106,7 @@ float vehicles_exit_running;
 
 .float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly
 
-entity spawnvehicle(entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, bool optional);
+entity spawnvehicle(entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool no_respwn, bool removeifinvalid, bool optional);
 void vehicles_exit(entity vehic, int eject);
 bool vehicle_initialize(entity this, Vehicle info, float nodrop);
 bool vehicle_impulse(entity this, int imp);
index 5fc5422c63f7e55e5d4316f1a91fad7f3b0bdce5..f057b9f7206a2a86979970c898ad9da10f150a34 100644 (file)
@@ -206,6 +206,7 @@ CLASS(Client, Object)
     ATTRIB(Client, cvar_cl_buffs_autoreplace, bool, this.cvar_cl_buffs_autoreplace);
     ATTRIB(Client, cvar_cl_nade_type, int, this.cvar_cl_nade_type);
     ATTRIB(Client, cvar_cl_pokenade_type, string, this.cvar_cl_pokenade_type);
+    ATTRIB(Client, cvar_cl_tandemnade_type, int, this.cvar_cl_tandemnade_type);
     ATTRIB(Client, cvar_cl_spawn_near_teammate, bool, this.cvar_cl_spawn_near_teammate);
     ATTRIB(Client, cvar_cl_gunalign, int, this.cvar_cl_gunalign);
     ATTRIB(Client, cvar_cl_handicap, float, this.cvar_cl_handicap);