From: LegendaryGuard Date: Thu, 30 Jun 2022 23:09:20 +0000 (+0200) Subject: Now spawned vehicles from nades cannot be respawned after being deleted, no more... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=368a6f8e28d008242c49fcb606305df095ab08ca;p=xonotic%2Fxonotic-data.pk3dir.git Now spawned vehicles from nades cannot be respawned after being deleted, no more count limits thanks to the no respawn option, and add correctly cl_tandemnade_type due to several changes when merging master branch --- diff --git a/mutators.cfg b/mutators.cfg index 8949ed8b8b..e4182bbd0b 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -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 diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 091cc46618..7038759f5b 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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", ""); diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index d215e9c8be..e12a73e447 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/nades/nades.qh b/qcsrc/common/mutators/mutator/nades/nades.qh index 53acefc2c8..11b0d6b1ba 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qh +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -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); diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 329e74e735..3fb9f38b09 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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; diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index c293a287d6..141c025e21 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -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); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 5fc5422c63..f057b9f720 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -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);