From: Mario Date: Sun, 2 Jun 2013 12:03:53 +0000 (+1000) Subject: Allow spawning monsters by ID & remove spawn list X-Git-Tag: xonotic-v0.8.0~241^2^2~207 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b181d67383e003593d38ce631b0afbf9e4f6856f;p=xonotic%2Fxonotic-data.pk3dir.git Allow spawning monsters by ID & remove spawn list --- diff --git a/monsters.cfg b/monsters.cfg index 7423a323e..00c63645c 100644 --- a/monsters.cfg +++ b/monsters.cfg @@ -25,7 +25,6 @@ set g_monsters_skill_normal 4 "Monster normal skill level (used for skill based set g_monsters_skill_hard 5 "Monster hard skill level (used for skill based functions)" set g_monsters_skill_insane 7 "Monster insane skill level (used for skill based functions)" set g_monsters_skill_nightmare 10 "Monster nightmare skill level (used for skill based functions)" -set g_monsters_spawn_list "brute animus shambler bruiser wyvern cerberus slime knight stingray mage zombie spider" "monsters not listed here will spawn as bruisers" // Brute set g_monster_brute 1 "Enable Brutes" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 4457c603a..7236c4e7f 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1254,7 +1254,6 @@ float autocvar_g_monsters_skill_normal; float autocvar_g_monsters_skill_hard; float autocvar_g_monsters_skill_insane; float autocvar_g_monsters_skill_nightmare; -string autocvar_g_monsters_spawn_list; float autocvar_g_touchexplode_radius; float autocvar_g_touchexplode_damage; float autocvar_g_touchexplode_edgedamage; diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 7814abef2..941e6b5e2 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -265,8 +265,14 @@ void ClientCommand_mobspawn(float request, float argc) if(tospawn == "list") { - sprint(self, "Available monsters:\n"); - sprint(self, strcat(autocvar_g_monsters_spawn_list, "\n")); + float i; + string list = "Available monsters:"; + + for(i = MONSTER_FIRST + 1; i < MONSTER_LAST; ++i) + list = strcat(list, " ", monster_id2string(i)); + + sprint(self, strcat(list, "\n")); + return; } @@ -287,7 +293,7 @@ void ClientCommand_mobspawn(float request, float argc) makevectors(self.v_angle); WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 150, MOVE_NORMAL, self); - e = spawnmonster(tospawn, self, self, trace_endpos, FALSE, moveflag); + e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, moveflag); if(mname) e.netname = strzone(mname); sprint(self, strcat("Spawned 1 ", tospawn, "\n")); diff --git a/qcsrc/server/command/cmd.qh b/qcsrc/server/command/cmd.qh index b0118c5cf..45d1f7584 100644 --- a/qcsrc/server/command/cmd.qh +++ b/qcsrc/server/command/cmd.qh @@ -13,7 +13,7 @@ float totalspawned; string MapVote_Suggest(string m); -entity spawnmonster(string monster, entity spawnedby, entity own, vector orig, float respwn, float moveflag); +entity spawnmonster(string monster, float mnster, entity spawnedby, entity own, vector orig, float respwn, float moveflag); // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file void ClientCommand_macro_write_aliases(float fh); diff --git a/qcsrc/server/monsters/lib/monsters_early.qh b/qcsrc/server/monsters/lib/monsters_early.qh index 0bda379d2..717d14c80 100644 --- a/qcsrc/server/monsters/lib/monsters_early.qh +++ b/qcsrc/server/monsters/lib/monsters_early.qh @@ -36,6 +36,46 @@ float MONSTER_MAGE = 12; float MONSTER_SPIDER = 13; float MONSTER_LAST = 14; +// id-string converters (TODO: remove these!) +string monster_id2string(float mnster) +{ + switch(mnster) + { + case MONSTER_ZOMBIE: return "zombie"; + case MONSTER_BRUTE: return "brute"; + case MONSTER_ANIMUS: return "animus"; + case MONSTER_SHAMBLER: return "shambler"; + case MONSTER_BRUISER: return "bruiser"; + case MONSTER_WYVERN: return "wyvern"; + case MONSTER_CERBERUS: return "cerberus"; + case MONSTER_SLIME: return "slime"; + case MONSTER_KNIGHT: return "knight"; + case MONSTER_STINGRAY: return "stingray"; + case MONSTER_MAGE: return "mage"; + case MONSTER_SPIDER: return "spider"; + default: return ""; + } +} +float monster_string2id(string monster) +{ + switch(monster) + { + case "zombie": return MONSTER_ZOMBIE; + case "brute": return MONSTER_BRUTE; + case "animus": return MONSTER_ANIMUS; + case "shambler": return MONSTER_SHAMBLER; + case "bruiser": return MONSTER_BRUISER; + case "wyvern": return MONSTER_WYVERN; + case "cerberus": return MONSTER_CERBERUS; + case "slime": return MONSTER_SLIME; + case "knight": return MONSTER_KNIGHT; + case "stingray": return MONSTER_STINGRAY; + case "mage": return MONSTER_MAGE; + case "spider": return MONSTER_SPIDER; + default: return 0; + } +} + float MSF_UPDATE = 2; float MSF_STATUS = 4; float MSF_SETUP = 8; diff --git a/qcsrc/server/monsters/lib/spawn.qc b/qcsrc/server/monsters/lib/spawn.qc index a756fad11..b985c7f2c 100644 --- a/qcsrc/server/monsters/lib/spawn.qc +++ b/qcsrc/server/monsters/lib/spawn.qc @@ -1,14 +1,4 @@ -float spawnmonster_checkinlist(string monster, string list) -{ - string l = strcat(" ", list, " "); - - if(strstrofs(l, strcat(" ", monster, " "), 0) >= 0) - return TRUE; - - return FALSE; -} - -entity spawnmonster (string monster, entity spawnedby, entity own, vector orig, float respwn, float moveflag) +entity spawnmonster (string monster, float mnster, entity spawnedby, entity own, vector orig, float respwn, float moveflag) { if(!spawncode_first_load) { @@ -25,8 +15,13 @@ entity spawnmonster (string monster, entity spawnedby, entity own, vector orig, setorigin(e, orig); - if not(spawnmonster_checkinlist(monster, autocvar_g_monsters_spawn_list)) + if(monster != "") + if not(monster_string2id(monster)) monster = "bruiser"; + + if(monster == "") + if(mnster) + monster = monster_id2string(mnster); e.realowner = spawnedby; diff --git a/qcsrc/server/mutators/gamemode_towerdefense.qc b/qcsrc/server/mutators/gamemode_towerdefense.qc index f4519da4c..a0a210ed8 100644 --- a/qcsrc/server/mutators/gamemode_towerdefense.qc +++ b/qcsrc/server/mutators/gamemode_towerdefense.qc @@ -187,7 +187,7 @@ entity PickSpawn (float tm) return RandomSelection_chosen_ent; } -void TD_SpawnMonster(float tm, string mnster) +void TD_SpawnMonster(float tm, float monster) { entity e, mon; @@ -199,7 +199,7 @@ void TD_SpawnMonster(float tm, string mnster) return; } - mon = spawnmonster(mnster, e, e, e.origin, FALSE, 2); + mon = spawnmonster("", monster, e, e, e.origin, FALSE, 2); if(e.target2) { if(random() <= 0.5 && e.target) @@ -211,26 +211,6 @@ void TD_SpawnMonster(float tm, string mnster) mon.target2 = e.target; } -string monster_type2string(float mnster) -{ - switch(mnster) - { - case MONSTER_ZOMBIE: return "zombie"; - case MONSTER_BRUTE: return "brute"; - case MONSTER_ANIMUS: return "animus"; - case MONSTER_SHAMBLER: return "shambler"; - case MONSTER_BRUISER: return "bruiser"; - case MONSTER_WYVERN: return "wyvern"; - case MONSTER_CERBERUS: return "cerberus"; - case MONSTER_SLIME: return "slime"; - case MONSTER_KNIGHT: return "knight"; - case MONSTER_STINGRAY: return "stingray"; - case MONSTER_MAGE: return "mage"; - case MONSTER_SPIDER: return "spider"; - default: return ""; - } -} - float RandomMonster() { RandomSelection_Init(); @@ -254,7 +234,7 @@ void SpawnMonsters(float tm) whichmon = RandomMonster(); - TD_SpawnMonster(tm, monster_type2string(whichmon)); + TD_SpawnMonster(tm, whichmon); } entity PickGenerator(float tm)