X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmonsters%2Fspawn.qc;h=f7e2e292fbf669f6fed88a2e5677288c4af04fbc;hb=b003ca9abf1bd24bf5edc3587e3931c39809202e;hp=be5accf5ede2d095a2d40cc398970aa406a49a74;hpb=0f444e0d57db660b27b5a54a263a61bc5da41004;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/monsters/spawn.qc b/qcsrc/common/monsters/spawn.qc index be5accf5e..f7e2e292f 100644 --- a/qcsrc/common/monsters/spawn.qc +++ b/qcsrc/common/monsters/spawn.qc @@ -1,18 +1,22 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "../util.qh" + #include "all.qh" + #include "sv_monsters.qh" + #include "spawn.qh" + #include "../../server/autocvars.qh" + #include "../../server/defs.qh" +#endif entity spawnmonster (string monster, float monster_id, entity spawnedby, entity own, vector orig, float respwn, float invincible, float moveflag) -{ - // ensure spawnfunc database is initialized - //initialize_field_db(); - +{SELFPARAM(); + float i; entity e = spawn(); - float i; e.spawnflags = MONSTERFLAG_SPAWNED; - if(!respwn) - e.spawnflags |= MONSTERFLAG_NORESPAWN; - - if(invincible) - e.spawnflags |= MONSTERFLAG_INVINCIBLE; + if(!respwn) { e.spawnflags |= MONSTERFLAG_NORESPAWN; } + if(invincible) { e.spawnflags |= MONSTERFLAG_INVINCIBLE; } setorigin(e, orig); @@ -20,12 +24,11 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity { RandomSelection_Init(); for(i = MON_FIRST; i <= MON_LAST; ++i) - RandomSelection_Add(world, 0, (get_monsterinfo(i)).netname, 1, 1); + RandomSelection_Add(world, i, string_null, 1, 1); - monster = RandomSelection_chosen_string; + monster_id = RandomSelection_chosen_float; } - - if(monster != "") + else if(monster != "") { float found = 0; entity mon; @@ -34,19 +37,15 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity mon = get_monsterinfo(i); if(mon.netname == monster) { - found = TRUE; + found = true; monster_id = mon.monsterid; // we have the monster, old monster id is no longer required break; } } if(!found) - monster = (get_monsterinfo(MON_FIRST)).netname; + monster_id = ((monster_id > 0) ? monster_id : MON_FIRST); } - if(monster == "") - if(monster_id) - monster = (get_monsterinfo(monster_id)).netname; - e.realowner = spawnedby; if(moveflag) @@ -58,19 +57,13 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity e.team = spawnedby.team; // colors handled in spawn code if(autocvar_g_monsters_owners) - e.monster_owner = own; // using .owner makes the monster non-solid for its master + e.monster_follow = own; // using .owner makes the monster non-solid for its master - e.angles = spawnedby.angles; + e.angles_y = spawnedby.angles_y; } - //monster = strcat("$ spawnfunc_monster_", monster); - - entity oldself = self; - self = e; - monster_initialize(monster_id); - self = oldself; - - //target_spawn_edit_entity(e, monster, world, world, world, world, world); + // Monster_Spawn checks if monster is valid + WITH(entity, self, e, Monster_Spawn(monster_id)); return e; }