]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add lifetime for spawned vehicles and turrets, their spawn functionality is completed!
authorLegendaryGuard <rootuser999@gmail.com>
Thu, 7 Jul 2022 21:22:47 +0000 (23:22 +0200)
committerLegendaryGuard <rootuser999@gmail.com>
Thu, 7 Jul 2022 21:22:47 +0000 (23:22 +0200)
mutators.cfg
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/nades/nades.qh
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/sv_turrets.qh
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qh

index 07875a64768a0322683bbcb094ddcb72b8ede21b..00556800740747e35c4cbf0cb850cab9a3504b32 100644 (file)
@@ -271,6 +271,8 @@ set g_nades_heal_foe   -2 "Multiplier of health given to enemies"
 
 // Tandem (7)
 set g_nades_pokenade_monster_lifetime 150 "How long pokenade monster will survive"
+set g_nades_pokenade_turret_lifetime 150 "How long pokenade turret will take to be in the world"
+set g_nades_pokenade_vehicle_lifetime 150 "How long pokenade vehicle will take to be in the world"
 set g_nades_pokenade_type "zombie" "Monster, item, vehicle and turret to spawn"
 set g_nades_tandemnade_type 0 "Tandem nade selection; 0: monster, 1: item, 2: vehicle, 3: turret"
 set g_nades_tandem_ball_spread 0.5 "Maximum force which the ball will have on explosion"
index 56fae5e121d8e1c4ae88449f99970b23b98df595..ea64deb605587d5200246feaeaaaf253a1bb2e46 100644 (file)
@@ -992,7 +992,9 @@ void nade_tandem_boom(entity this)
 
                        if(!e)
                                return; // vehicle failed to be spawned
-                       
+
+                       if(autocvar_g_nades_pokenade_vehicle_lifetime > 0)
+                               e.vehicle_lifetime = time + autocvar_g_nades_pokenade_vehicle_lifetime;
                        return;
                }
                case 3:
@@ -1017,6 +1019,8 @@ void nade_tandem_boom(entity this)
                        if(!e)
                                return; // turret failed to be spawned
                        
+                       if(autocvar_g_nades_pokenade_turret_lifetime > 0)
+                               e.turret_lifetime = time + autocvar_g_nades_pokenade_turret_lifetime;
                        return;
                }
                default:
index c3cf84afc994dd93c53f53e1a26c3e651a3548ff..7b195205835176aded36d436ee7557e1cda44dd8 100644 (file)
@@ -82,6 +82,8 @@ float autocvar_g_nades_dark_radius;
 string autocvar_g_nades_pokenade_type;
 int autocvar_g_nades_tandemnade_type; //LegendGuard adds new nade cvar for emerald nade options 01-07-2021
 float autocvar_g_nades_pokenade_monster_lifetime;
+float autocvar_g_nades_pokenade_turret_lifetime;
+float autocvar_g_nades_pokenade_vehicle_lifetime;
 #endif
 
 // use slots 70-100
index 8177f1734f619adec9ec0da3dbbf326588537d24..6b6c89e10650067aaebad39da2dd164f7c787100 100644 (file)
@@ -1030,6 +1030,15 @@ void turret_fire(entity this)
 
 void turret_think(entity this)
 {
+       if(this.tur_spawned && this.turret_lifetime != 0)
+       if(time >= this.turret_lifetime)
+       {
+               tmp_vehcount--;
+
+               turret_die(this);
+               return;
+       }
+
        this.nextthink = time + this.ticrate;
 
        MUTATOR_CALLHOOK(TurretThink, this);
@@ -1128,7 +1137,7 @@ void turret_think(entity this)
                // Check if we have a vailid enemy, and try to find one if we dont.
 
                // Don't attack against owner
-               if (turret_select_target(this) == this.realowner) return;
+               if(turret_select_target(this) == this.realowner) return;
 
                // g_turrets_targetscan_maxdelay forces a target re-scan at least this often
                float do_target_scan = 0;
@@ -1152,7 +1161,7 @@ void turret_think(entity this)
                {
                        this.enemy = turret_select_target(this);
                        // Don't attack against owner
-                       if (this.enemy == this.realowner) return;
+                       if(this.enemy == this.realowner) return;
                        this.target_select_time = time;
                }
 
index 83d971f43c0231e90f3800f1b2a089e8595c8a37..497c3b8c526a7d5aed8f339a0c636c1d58c6bbb4 100644 (file)
@@ -39,6 +39,7 @@ TR_PROPS_COMMON(X, , )
 .float tur_dist_aimpos; // distance to aim location
 .float tur_dist_impact_to_aimpos; // distance impact<->aim
 .bool tur_spawned; // spawned turret using spawnturret
+.float turret_lifetime; // turret disappears instantly after this delay, set from spawn
 .float volly_counter; // decrement counter from .shot_volly to 0
 .float target_select_time; // last time turret had a valid target
 .float target_validate_time; // throttle re-validation of current target
index 399eac132b04d8461331d3022093679799faa107..752391030e41d2008b48d29fbcf757c23626d0a6 100644 (file)
@@ -978,6 +978,7 @@ void vehicles_enter(entity pl, entity veh)
        if(veh.owner)
                return; // got here and didn't enter the gunner, return
 
+
        if(!teamplay)
        if(!veh.realowner)
        if(veh.realowner != pl && autocvar_g_vehicles_steal)
@@ -1110,6 +1111,22 @@ void vehicles_enter(entity pl, entity veh)
 
 void vehicles_think(entity this)
 {
+       if(this.summoned && this.vehicle_lifetime != 0)
+       if(time >= this.vehicle_lifetime)
+       {
+               Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 100', '0 0 0', 1);
+
+               tmp_vehcount--;
+
+               // to avoid weird entity assignments to other stuff like projectiles
+               delete(this.vehicle_shieldent);
+               delete(this.vehicle_hudmodel);
+               delete(this.tur_head);
+               delete(this.vehicle);
+               delete(this);
+               return;
+       }
+
        this.nextthink = time + autocvar_g_vehicles_thinkrate;
 
        if(this.owner)
index 708244d5d5b9b2e0302ba38d05792b6717d994e3..b59550fa7dc2d1bb8bb18a87811a99e2f1b2a573 100644 (file)
@@ -88,6 +88,7 @@ const int MAX_AXH = 4;
 .bool  no_respawn_option;
 .bool  cannot_respawn;
 .bool  summoned;
+.float vehicle_lifetime; // vehicle disappears instantly after this delay, set from spawn
 
 // vehicle functions
 .void(int _spawnflag) vehicle_spawn;  /// Vehicles custom fucntion to be efecuted when vehicle (re)spawns