]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move spawn functions to the correct code places
authorLegendaryGuard <rootuser999@gmail.com>
Fri, 24 Jun 2022 00:29:37 +0000 (02:29 +0200)
committerLegendaryGuard <rootuser999@gmail.com>
Fri, 24 Jun 2022 00:29:37 +0000 (02:29 +0200)
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/vehicles/sv_vehicles.qc

index 79afff9aa20dbf591bb779359b130d58e218b0fe..9899b3ea0895367fed3329b2a46ae8c2b45ad820 100644 (file)
@@ -784,151 +784,8 @@ void nade_emerald_randomweapons(entity e, vector org)
 }
 
 //LegendGuard adds vehicle spawn option for emerald nade 20-06-2021
-entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
-{
-       e.spawnflags = VHF_MULTISLOT;
-
-       if(!respwn) { e.spawnflags |= VHF_ISVEHICLE; }
-       setorigin(e, orig);
-       bool allow_any = boolean(vehicle == "anyrandom");
-
-       if(vehicle == "random" || allow_any)
-       {
-               RandomSelection_Init();
-               FOREACH(Vehicles, it != VEH_Null && (allow_any || !(it.spawnflags & VHF_MULTISLOT)),
-               {
-                       RandomSelection_AddEnt(it, 1, 1);
-               });
-
-               veh = RandomSelection_chosen_ent;
-       }
-       else if(vehicle != "")
-       {
-               bool found = false;
-               FOREACH(Vehicles, it != VEH_Null,
-               {
-                       if(it.netname == vehicle)
-                       {
-                               found = true;
-                               veh = it; // we have the vehicle, old vehicle id is no longer required
-                               break;
-                       }
-               });
-
-               if(!found && veh == VEH_Null)
-               {
-                       if(removeifinvalid)
-                       {
-                               delete(e);
-                               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, moveflag);
-               }
-       }
-
-       e.realowner = spawnedby;
-
-       e.effects |= EF_DIMLIGHT;
-
-       // TODO: Create a vehicle .entity moveflag
-       //if(moveflag && e.vehicle_flags == VEH_FLAG_MOVE)
-       //      e.monster_moveflags = moveflag;
-
-       if(IS_PLAYER(spawnedby))
-       {
-               if(teamplay && autocvar_g_monsters_teams)
-                       e.team = spawnedby.team; // colors handled in spawn code
-               
-               e.angles_y = spawnedby.angles_y;
-       }
-
-       // TODO: Remove or not?
-       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.4;
-       
-       vehicle_initialize(e, veh, true);
-
-       return e;
-}
 
 //LegendGuard adds turret spawn option for emerald nade 22-06-2021
-entity spawnturret (entity e, string turret, Turret tur, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
-{
-       e.spawnflags = TSF_SUSPENDED;
-
-       if(!respwn) { e.spawnflags |= TSL_NO_RESPAWN; }
-       // if(invincible) { e.damage_flags |= TFL_DMG_NO; }
-
-       setorigin(e, orig);
-       bool allow_any = boolean(turret == "anyrandom");
-
-       if(turret == "random" || allow_any)
-       {
-               RandomSelection_Init();
-               FOREACH(Turrets, it != TUR_Null && (allow_any || !(it.spawnflags & TSF_SUSPENDED)),
-               {
-                       RandomSelection_AddEnt(it, 1, 1);
-               });
-
-               tur = RandomSelection_chosen_ent;
-       }
-       else if(turret != "")
-       {
-               bool found = false;
-               FOREACH(Turrets, it != TUR_Null,
-               {
-                       if(it.netname == turret)
-                       {
-                               found = true;
-                               tur = it; // we have the turret, old turret id is no longer required
-                               break;
-                       }
-               });
-
-               if(!found && tur == TUR_Null)
-               {
-                       if(removeifinvalid)
-                       {
-                               delete(e);
-                               return NULL; // no good
-                       }
-                       // select a random valid turret type if no valid turret was provided
-                       return spawnturret(e, "random", TUR_Null, spawnedby, own, orig, respwn, removeifinvalid, moveflag);
-               }
-       }
-
-       e.realowner = spawnedby;
-       
-       e.effects |= EF_DIMLIGHT;
-
-       // TODO: Create a turret .entity moveflag
-       //if(moveflag && e.turret_flags == TUR_FLAG_MOVE)
-       //      e.monster_moveflags = moveflag;
-
-       if(IS_PLAYER(spawnedby))
-       {
-               if(teamplay && autocvar_g_monsters_teams)
-                       e.team = spawnedby.team; // colors handled in spawn code
-
-               // TODO: Create a turret .entity moveflag
-               //if(autocvar_g_monsters_owners)
-               //      e.monster_follow = own; // using .owner makes the monster non-solid for its master
-               
-               e.angles_y = spawnedby.angles_y;
-       }
-
-       // TODO: Remove or not?
-       if(!(e.spawnflags & TSF_SUSPENDED)) { delete(e); return NULL; } // remove even if told not to, as we didn't spawn any kind of turret
-       
-       turret_initialize(e, tur);
-
-       return e;
-}
 
 void nade_emerald_randomitem(entity e, vector org)
 {
index 1b5e7cdb84ed9e098cd0f0dfff71931bbbb48ec0..902ddff3c565507171cdabf1dc8c4ff9fd80bf54 100644 (file)
@@ -1415,4 +1415,74 @@ bool turret_initialize(entity this, Turret tur)
 
        return true;
 }
+
+entity spawnturret (entity e, string turret, Turret tur, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
+{
+       e.spawnflags = TSF_SUSPENDED;
+
+       if(!respwn) { e.spawnflags |= TSL_NO_RESPAWN; }
+       // if(invincible) { e.damage_flags |= TFL_DMG_NO; }
+
+       setorigin(e, orig);
+       bool allow_any = boolean(turret == "anyrandom");
+
+       if(turret == "random" || allow_any)
+       {
+               RandomSelection_Init();
+               FOREACH(Turrets, it != TUR_Null && (allow_any || !(it.spawnflags & TSF_SUSPENDED)),
+               {
+                       RandomSelection_AddEnt(it, 1, 1);
+               });
+
+               tur = RandomSelection_chosen_ent;
+       }
+       else if(turret != "")
+       {
+               bool found = false;
+               FOREACH(Turrets, it != TUR_Null,
+               {
+                       if(it.netname == turret)
+                       {
+                               found = true;
+                               tur = it; // we have the turret, old turret id is no longer required
+                               break;
+                       }
+               });
+
+               if(!found && tur == TUR_Null)
+               {
+                       if(removeifinvalid)
+                       {
+                               delete(e);
+                               return NULL; // no good
+                       }
+                       // select a random valid turret type if no valid turret was provided
+                       return spawnturret(e, "random", TUR_Null, spawnedby, own, orig, respwn, removeifinvalid, moveflag);
+               }
+       }
+
+       e.realowner = spawnedby;
+
+       // TODO: Create a turret .entity moveflag
+       //if(moveflag && e.turret_flags == TUR_FLAG_MOVE)
+       //      e.monster_moveflags = moveflag;
+
+       if(IS_PLAYER(spawnedby))
+       {
+               if(teamplay)
+                       e.team = spawnedby.team; // colors handled in spawn code
+
+               // TODO: Create a turret .entity moveflag
+               //if(autocvar_g_monsters_owners)
+               //      e.monster_follow = own; // using .owner makes the monster non-solid for its master
+               
+               e.angles_y = spawnedby.angles_y;
+       }
+       
+       if(!(e.spawnflags & TSF_SUSPENDED)) { delete(e); return NULL; } // remove even if told not to, as we didn't spawn any kind of turret
+       
+       turret_initialize(e, tur);
+
+       return e;
+}
 #endif
index 302b39a0d16d66c12b6c328d992a710cd2d0c373..83fd479bfe24cbfbcf369affe781b9b4cb0b191d 100644 (file)
@@ -1291,3 +1291,68 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
 
        return true;
 }
+
+entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag)
+{
+       e.spawnflags = VHF_MULTISLOT;
+
+       if(!respwn) { e.spawnflags |= VHF_ISVEHICLE; }
+       setorigin(e, orig);
+       bool allow_any = boolean(vehicle == "anyrandom");
+
+       if(vehicle == "random" || allow_any)
+       {
+               RandomSelection_Init();
+               FOREACH(Vehicles, it != VEH_Null && (allow_any || !(it.spawnflags & VHF_MULTISLOT)),
+               {
+                       RandomSelection_AddEnt(it, 1, 1);
+               });
+
+               veh = RandomSelection_chosen_ent;
+       }
+       else if(vehicle != "")
+       {
+               bool found = false;
+               FOREACH(Vehicles, it != VEH_Null,
+               {
+                       if(it.netname == vehicle)
+                       {
+                               found = true;
+                               veh = it; // we have the vehicle, old vehicle id is no longer required
+                               break;
+                       }
+               });
+
+               if(!found && veh == VEH_Null)
+               {
+                       if(removeifinvalid)
+                       {
+                               delete(e);
+                               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, moveflag);
+               }
+       }
+
+       e.realowner = spawnedby;
+
+       if(IS_PLAYER(spawnedby))
+       {
+               if(teamplay)
+                       e.team = spawnedby.team; // colors handled in spawn code
+               
+               e.angles_y = spawnedby.angles_y;
+       }
+       
+       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.6;
+       
+       vehicle_initialize(e, veh, true);
+
+       return e;
+}