X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fsv_spawn.qc;h=0a5f350eeb523bb6ef4d35981be8481a86d0178f;hb=885c7f4d3ed9a1c0ded2fab0b289120dfda75ba5;hp=d6989ad31839d52229cc8f612879fd6c83ab8686;hpb=e57fd111a3279a4aa4789e2c72f9c819a56c7be9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/sv_spawn.qc b/qcsrc/common/monsters/sv_spawn.qc index d6989ad31..0a5f350ee 100644 --- a/qcsrc/common/monsters/sv_spawn.qc +++ b/qcsrc/common/monsters/sv_spawn.qc @@ -1,14 +1,17 @@ #include "sv_spawn.qh" + #if defined(CSQC) #elif defined(MENUQC) #elif defined(SVQC) - #include "../util.qh" - #include "all.qh" - #include "sv_monsters.qh" - #include - #include + #include + #include + #include + #include + #include + #include #endif -entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag) + +entity spawnmonster (entity e, string monster, Monster monster_id, entity spawnedby, entity own, vector orig, bool respwn, bool removeifinvalid, int moveflag) { e.spawnflags = MONSTERFLAG_SPAWNED; @@ -21,12 +24,12 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, if(monster == "random" || allow_any) { RandomSelection_Init(); - FOREACH(Monsters, it != MON_Null && (allow_any || (!(it.spawnflags & MONSTER_TYPE_PASSIVE) && !(it.spawnflags & MON_FLAG_HIDDEN))), + FOREACH(Monsters, it != MON_Null && (allow_any || !(it.spawnflags & MON_FLAG_HIDDEN)) && !(it.spawnflags & MONSTER_TYPE_PASSIVE), { RandomSelection_AddEnt(it, 1, 1); }); - monster_id = RandomSelection_chosen_ent.monsterid; + monster_id = RandomSelection_chosen_ent; } else if(monster != "") { @@ -36,12 +39,12 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, if(it.netname == monster) { found = true; - monster_id = it.monsterid; // we have the monster, old monster id is no longer required + monster_id = it; // we have the monster, old monster id is no longer required break; } }); - if(!found && !monster_id) + if(!found && monster_id == MON_Null) { if(removeifinvalid) { @@ -49,7 +52,10 @@ entity spawnmonster (entity e, string monster, int monster_id, entity spawnedby, return NULL; // no good } else - monster_id = MON_FIRST; + { + // select a random valid monster type if no valid monster was provided + return spawnmonster(e, "random", MON_Null, spawnedby, own, orig, respwn, removeifinvalid, moveflag); + } } }