2 // _campaign_index: index of CURRENT map
3 // g_campaign_index: index of current LAST map (saved)
4 // g_campaign_skill: bot skill offset
9 void(string s) CampaignBailout =
11 cvar_set("g_campaign", "0");
12 bprint(strcat("campaign initialization failed: ", s, "\n"));
13 //error(strcat("campaign initialization failed: ", s, "\n"));
17 void() CampaignPreInit =
21 campaign_level = cvar("_campaign_index");
22 CampaignFile_Load(campaign_level, 2);
23 if(campaign_entries < 1)
24 return CampaignBailout("unknown map");
25 cvar_set("bot_number", ftos(campaign_bots[0]));
27 baseskill = cvar("g_campaign_skill");
28 baseskill = baseskill + campaign_botskill[0];
31 cvar_set("skill", ftos(baseskill));
33 cvar_set("sv_public", "0");
34 cvar_set("pausable", "1");
36 title = campaign_shortdesc[0];
37 title = strzone(strcat("Level ", ftos(campaign_level + 1), ": ", title));
38 campaign_message = strzone(strcat("\n\n\n\n\n\n\n\n\n\n^1\n", title, "\n^3\n", Campaign_wordwrap(campaign_longdesc[0], 50), "\n\n^1press jump to enter the game"));
43 void() CampaignPostInit =
45 // now some sanity checks
46 string thismapname, wantedmapname;
47 thismapname = GetMapname();
48 wantedmapname = campaign_gametype[0];
49 wantedmapname = strcat(wantedmapname, "_", campaign_mapname[0]);
50 if(wantedmapname != thismapname)
51 return CampaignBailout(strcat("wrong map: ", wantedmapname, " != ", thismapname));
52 cvar_set("fraglimit", ftos(campaign_fraglimit[0]));
53 cvar_set("timelimit", "0");
56 void() CampaignPreIntermission =
64 head = findchain(classname, "player");
67 if(clienttype(head) == CLIENTTYPE_REAL)
77 if(won == 1 && lost == 0)
80 bprint("The current level has been WON.\n");
86 bprint("The current level has been LOST.\n");
92 if(campaign_level == cvar("g_campaign_index"))
95 localcmd("set g_campaign_index ");
96 localcmd(ftos(campaign_level + 1));
99 if(campaign_entries < 2)
101 localcmd("set g_campaign_index 0\n");
102 localcmd("set g_campaign_won 1\n");
107 void() CampaignPostIntermission =
109 // NOTE: campaign_won is 0 or 1, that is, points to the next level
111 if(campaign_won && campaign_entries < 2)
114 localcmd("togglemenu\n");
115 CampaignFile_Unload();
119 CampaignSetup(campaign_won);
120 CampaignFile_Unload();
121 strunzone(campaign_message);
126 void(float n) CampaignLevelWarp =
128 if(!cvar("sv_cheats"))
130 CampaignFile_Unload();
131 CampaignFile_Load(n, 1);
135 error("Sorry, cheater. You are NOT WELCOME.");
136 CampaignFile_Unload();