Xonotic
campaign.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CAMPAIGN_MAX_ENTRIES   2
 

Functions

int Campaign_GetLevelNum ()
 
string Campaign_GetMessage ()
 
void CampaignLevelWarp (float n)
 
void CampaignPostInit ()
 
void CampaignPostIntermission ()
 
void CampaignPreInit ()
 
void CampaignPreIntermission ()
 

Variables

int autocvar__campaign_index
 
string autocvar__campaign_name
 
bool autocvar__campaign_testrun
 
bool autocvar_g_campaign
 
float autocvar_g_campaign_forceteam
 
int autocvar_g_campaign_skill
 
bool campaign_bots_may_start
 campaign mode: bots shall spawn but wait for the player to spawn before they do anything in other game modes, this is ignored More...
 
bool campaign_forcewin
 

Macro Definition Documentation

◆ CAMPAIGN_MAX_ENTRIES

#define CAMPAIGN_MAX_ENTRIES   2

Definition at line 11 of file campaign.qh.

Function Documentation

◆ Campaign_GetLevelNum()

int Campaign_GetLevelNum ( )

Definition at line 44 of file campaign.qc.

References campaign_level.

Referenced by PrintWelcomeMessage().

45 {
46  return campaign_level + 1;
47 }
float campaign_level
Definition: campaign.qc:17
+ Here is the caller graph for this function:

◆ Campaign_GetMessage()

string Campaign_GetMessage ( )

Definition at line 49 of file campaign.qc.

References campaign_longdesc, campaign_shortdesc, and strcat().

Referenced by PrintWelcomeMessage().

50 {
51  return strcat(campaign_shortdesc[0], "\n^3\n", campaign_longdesc[0]);
52 }
string campaign_shortdesc[CAMPAIGN_MAX_ENTRIES]
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
string campaign_longdesc[CAMPAIGN_MAX_ENTRIES]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CampaignLevelWarp()

void CampaignLevelWarp ( float  n)

Definition at line 266 of file campaign.qc.

References campaign_entries, campaign_level, CampaignFile_Load(), CampaignFile_Unload(), CampaignSetup(), and error().

Referenced by GameCommand_warp().

267 {
268  if(n < 0)
269  n = campaign_level + 1;
271  CampaignFile_Load(n, 1);
272  if(campaign_entries)
273  CampaignSetup(0);
274  else
275  error("Sorry, cheater. You are NOT WELCOME.");
277 }
void CampaignSetup(int n)
int campaign_entries
float campaign_level
Definition: campaign.qc:17
float CampaignFile_Load(float offset, float entries)
void CampaignFile_Unload()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CampaignPostInit()

void CampaignPostInit ( )

Definition at line 105 of file campaign.qc.

References argv(), autocvar__campaign_testrun, campaign_fraglimit, Campaign_Invalid(), campaign_timelimit, cvar_set(), and tokenizebyseparator.

Referenced by spawnfunc().

106 {
107  // now some sanity checks
108  if(Campaign_Invalid())
109  return;
111  {
112  cvar_set("fraglimit", "0");
113  cvar_set("leadlimit", "0");
114  cvar_set("timelimit", "0.01");
115  }
116  else
117  {
118  // "default" uses implicit values, "" or "0" means no limit
120  if(argv(0) != "default") {
121  cvar_set("fraglimit", argv(0));
122  }
123  if(argv(1) != "default") {
124  cvar_set("leadlimit", argv(1));
125  }
126  if(campaign_timelimit[0] != "default") {
127  cvar_set("timelimit", campaign_timelimit[0]);
128  }
129  }
130 }
float Campaign_Invalid()
Definition: campaign.qc:31
string campaign_timelimit[CAMPAIGN_MAX_ENTRIES]
bool autocvar__campaign_testrun
Definition: campaign.qh:3
#define tokenizebyseparator
Definition: dpextensions.qh:21
string campaign_fraglimit[CAMPAIGN_MAX_ENTRIES]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CampaignPostIntermission()

void CampaignPostIntermission ( )

Definition at line 244 of file campaign.qc.

References campaign_entries, campaign_index_var, campaign_name, campaign_won, CampaignFile_Unload(), CampaignSetup(), localcmd, LOG_DEBUG, and strunzone().

Referenced by DoNextMapOverride().

245 {
246  // NOTE: campaign_won is 0 or 1, that is, points to the next level
247 
248  if(campaign_won && campaign_entries < 2)
249  {
250  // last map won!
251  LOG_DEBUG("^2test run: campaign looks GOOD");
252  localcmd("togglemenu 1\n");
254  return;
255  }
256 
261  campaign_name = "";
262 }
string campaign_name
float campaign_won
Definition: campaign.qc:18
string campaign_index_var
Definition: campaign.qc:19
void CampaignSetup(int n)
int campaign_entries
void CampaignFile_Unload()
#define LOG_DEBUG(...)
Definition: log.qh:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CampaignPreInit()

void CampaignPreInit ( )

Definition at line 54 of file campaign.qc.

References _MapInfo_Parse_Settemp(), argv(), autocvar__campaign_index, autocvar__campaign_name, autocvar_g_campaign_skill, autocvar_sv_cheats, campaign_bots, campaign_botskill, campaign_entries, campaign_forcewin, campaign_gametype, campaign_index_var, Campaign_Invalid(), campaign_level, campaign_mutators, campaign_name, CampaignBailout(), CampaignFile_Load(), CampaignFile_Unload(), cvar_set(), cvar_settemp(), ftos(), MAPINFO_SETTEMP_ACL_USER, MapInfo_SwitchGameType(), MapInfo_Type_FromString(), mapname, max(), strcat(), strzone(), and tokenizebyseparator.

Referenced by spawnfunc().

55 {
56  float baseskill;
59  campaign_index_var = strzone(strcat("g_campaign", campaign_name, "_index"));
61 
62  if(campaign_entries < 1)
63  {
64  CampaignBailout("unknown map");
65  return;
66  }
67 
69  {
72  CampaignBailout("JOLLY CHEATS AHAHAHAHAHAHAH))");
73  return;
74  }
75 
76  baseskill = max(0, autocvar_g_campaign_skill + campaign_botskill[0]);
77  campaign_forcewin = false;
78 
79  cvar_set("sv_public", "0");
80  cvar_set("pausable", "1");
81 
82  string cvar_campaignwrapper_list = strcat("; ", campaign_mutators[0], "; ");
83  int argc = tokenizebyseparator(cvar_campaignwrapper_list, "; ");
84  if(argc > 0)
85  {
86  for(int j = 0; j < argc; ++j)
87  {
88  string arg = argv(j);
89  if(arg == "") continue;
91  }
92  }
93 
94  cvar_settemp("g_campaign", "1");
95  cvar_settemp("g_dm", "0");
96  cvar_settemp("skill", ftos(baseskill));
97  cvar_settemp("bot_number", ftos(campaign_bots[0]));
98 
100 
101  if(Campaign_Invalid())
102  return;
103 }
float CampaignBailout(string s)
Definition: campaign.qc:22
float Campaign_Invalid()
Definition: campaign.qc:31
string campaign_name
string campaign_index_var
Definition: campaign.qc:19
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition: util.qc:696
float campaign_botskill[CAMPAIGN_MAX_ENTRIES]
string mapname
Definition: csprogsdefs.qc:26
Gametype MapInfo_Type_FromString(string gtype, bool dowarn)
Definition: mapinfo.qc:589
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
int autocvar_g_campaign_skill
Definition: campaign.qh:8
float campaign_bots[CAMPAIGN_MAX_ENTRIES]
string campaign_mutators[CAMPAIGN_MAX_ENTRIES]
int autocvar_sv_cheats
Definition: cheats.qh:5
int campaign_entries
float campaign_level
Definition: campaign.qc:17
int autocvar__campaign_index
Definition: campaign.qh:4
string campaign_gametype[CAMPAIGN_MAX_ENTRIES]
#define tokenizebyseparator
Definition: dpextensions.qh:21
bool campaign_forcewin
Definition: campaign.qh:29
#define MAPINFO_SETTEMP_ACL_USER
Definition: mapinfo.qh:205
float CampaignFile_Load(float offset, float entries)
void CampaignFile_Unload()
void MapInfo_SwitchGameType(Gametype t)
Definition: mapinfo.qc:1178
void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse)
Definition: mapinfo.qc:627
string autocvar__campaign_name
Definition: campaign.qh:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CampaignPreIntermission()

void CampaignPreIntermission ( )

Definition at line 172 of file campaign.qc.

References autocvar__campaign_testrun, bprint(), campaign_entries, campaign_forcewin, campaign_index_var, campaign_level, campaign_name, campaign_won, CampaignSaveCvar(), cheatcount_total, checkrules_equality, cvar(), FOREACH_CLIENT, IS_PLAYER, IS_REAL_CLIENT, strcat(), and time.

Referenced by NextLevel().

173 {
174  int won = 0;
175  int lost = 0;
176  string savevar;
177 
179  if(it.winning)
180  won += 1;
181  else
182  lost += 1;
183  });
184 
186  {
187  campaign_won = 1;
188  bprint("Campaign test run, advancing level.\n");
189  }
190  else if(campaign_forcewin)
191  {
192  campaign_won = 1;
193  bprint("The current level has been WON.\n");
194  }
195  else if(won == 1 && lost == 0 && checkrules_equality == 0)
196  {
197  if(autocvar_timelimit != 0 && autocvar_fraglimit != 0 && time > autocvar_timelimit * 60) // checks if the timelimit has expired.
198  {
199  campaign_won = 0;
200  bprint("Time's up! The current level has been LOST.\n");
201  // sound!
202  }
203  else
204  {
205  campaign_won = 1;
206  bprint("The current level has been WON.\n");
207  // sound!
208  }
209  }
210  else if(autocvar_timelimit != 0 && time > autocvar_timelimit * 60)
211  {
212  campaign_won = 0;
213  bprint("Time's up! The current level has been LOST.\n");
214  // sound!
215  }
216  else
217  {
218  campaign_won = 0;
219  bprint("The current level has been LOST.\n");
220  // sound!
221  }
222 
224  {
226  {
227  if(campaign_entries < 2)
228  {
229  // I have won
230  savevar = strcat("g_campaign", campaign_name, "_won");
231  CampaignSaveCvar(savevar, 1);
232  // advance level (for menu to show it right)
234  }
235  else
236  {
237  // advance level
239  }
240  }
241  }
242 }
string campaign_name
float campaign_won
Definition: campaign.qc:18
string campaign_index_var
Definition: campaign.qc:19
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
bool autocvar__campaign_testrun
Definition: campaign.qh:3
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float cheatcount_total
Definition: cheats.qh:10
int campaign_entries
float campaign_level
Definition: campaign.qc:17
void CampaignSaveCvar(string cvarname, float value)
Definition: campaign.qc:132
bool campaign_forcewin
Definition: campaign.qh:29
float checkrules_equality
Definition: world.qh:31
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar__campaign_index

int autocvar__campaign_index

Definition at line 4 of file campaign.qh.

Referenced by CampaignPreInit().

◆ autocvar__campaign_name

string autocvar__campaign_name

Definition at line 5 of file campaign.qh.

Referenced by CampaignPreInit().

◆ autocvar__campaign_testrun

bool autocvar__campaign_testrun

◆ autocvar_g_campaign

◆ autocvar_g_campaign_forceteam

float autocvar_g_campaign_forceteam

Definition at line 7 of file campaign.qh.

Referenced by Player_DetermineForcedTeam(), and TeamBalance_GetTeamCounts().

◆ autocvar_g_campaign_skill

int autocvar_g_campaign_skill

Definition at line 8 of file campaign.qh.

Referenced by CampaignPreInit().

◆ campaign_bots_may_start

bool campaign_bots_may_start

campaign mode: bots shall spawn but wait for the player to spawn before they do anything in other game modes, this is ignored

Definition at line 27 of file campaign.qh.

Referenced by bot_think(), Join(), Monster_Move(), Monster_Move_2D(), MUTATOR_HOOKFUNCTION(), PlayerPreThink(), round_handler_Think(), and WinningCondition_LMS().

◆ campaign_forcewin

bool campaign_forcewin

Definition at line 29 of file campaign.qh.

Referenced by CampaignPreInit(), and CampaignPreIntermission().