QuakeC:рандомная загрузка уровней
Написано: вторник, 3 апреля 2012 г. автор st1x51
0
Рандомная загрузка уровней[QuakeC]
Открываем client.qc и видим такую вот картину:
void() NextLevel = { local entity o; if (mapname == "start") { if (!cvar("registered")) { mapname = "e1m1"; } else if (!(serverflags & 1)) { mapname = "e1m1"; serverflags = serverflags | 1; } else if (!(serverflags & 2)) { mapname = "e2m1"; serverflags = serverflags | 2; } else if (!(serverflags & 4)) { mapname = "e3m1"; serverflags = serverflags | 4; } else if (!(serverflags & 8)) { mapname = "e4m1"; serverflags = serverflags - 7; } o = spawn(); o.map = mapname; } else { // find a trigger changelevel o = find(world, classname, "trigger_changelevel"); // go back to start if no trigger_changelevel if (!o) { mapname = "start"; o = spawn(); o.map = mapname; } } nextmap = o.map; gameover = TRUE; if (o.nextthink < time) { o.think = execute_changelevel; o.nextthink = time + 0.1; } };
Копируем NextLevel() функцию и меняем ей имя на NextRandomLevel.
Теперь,замените это:
if (mapname == "start") { if (!cvar("registered")) { mapname = "e1m1"; } else if (!(serverflags & 1)) { mapname = "e1m1"; serverflags = serverflags | 1; } else if (!(serverflags & 2)) { mapname = "e2m1"; serverflags = serverflags | 2; } else if (!(serverflags & 4)) { mapname = "e3m1"; serverflags = serverflags | 4; } else if (!(serverflags & 8)) { mapname = "e4m1"; serverflags = serverflags - 7; } o = spawn(); o.map = mapname; } else { // find a trigger changelevel o = find(world, classname, "trigger_changelevel"); // go back to start if no trigger_changelevel if (!o) { mapname = "start"; o = spawn(); o.map = mapname; } }
На это:
local float whichmap; whichmap = rint (random()*36 + 1); if (whichmap == 1) mapname = "start"; else if (whichmap == 2) mapname = "e1m1"; else if (whichmap == 3) mapname = "e1m2"; else if (whichmap == 4) mapname = "e1m3"; else if (whichmap == 5) mapname = "e1m4"; else if (whichmap == 6) mapname = "e1m5"; else if (whichmap == 7) mapname = "e1m6"; else if (whichmap == 8) mapname = "e1m7"; else if (whichmap == 9) mapname = "e1m8"; else if (whichmap == 10) mapname = "e2m1"; else if (whichmap == 11) mapname = "e2m2"; else if (whichmap == 12) mapname = "e2m3"; else if (whichmap == 13) mapname = "e2m4"; else if (whichmap == 14) mapname = "e2m5"; else if (whichmap == 15) mapname = "e2m6"; else if (whichmap == 16) mapname = "e2m7"; else if (whichmap == 17) mapname = "e3m1"; else if (whichmap == 18) mapname = "e3m2"; else if (whichmap == 19) mapname = "e3m3"; else if (whichmap == 20) mapname = "e3m4"; else if (whichmap == 21) mapname = "e3m5"; else if (whichmap == 22) mapname = "e3m6"; else if (whichmap == 23) mapname = "e3m7"; else if (whichmap == 24) mapname = "e4m1"; else if (whichmap == 25) mapname = "e4m2"; else if (whichmap == 26) mapname = "e4m3"; else if (whichmap == 27) mapname = "e4m4"; else if (whichmap == 28) mapname = "e4m5"; else if (whichmap == 29) mapname = "e4m6"; else if (whichmap == 30) mapname = "e4m7"; else if (whichmap == 31) mapname = "e4m8"; else if (whichmap == 32) mapname = "dm1"; else if (whichmap == 33) mapname = "dm2"; else if (whichmap == 34) mapname = "dm3"; else if (whichmap == 35) mapname = "dm4"; else if (whichmap == 36) mapname = "dm5"; else mapname = "dm6"; o = spawn(); o.map = mapname;
В CheckRules() Функции найдите:
if (deathmatch && fraglimit && self.frags >= fraglimit) { NextLevel (); return; }
Теперь замените NextLevel (); на:
NextRandomLevel ();
Все.Компилим.Теперь наши уровни загружаются рандомно