UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_mission_triggers.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include "../../cl_shared.h"
27#include "../../ui/ui_dataids.h" /* TEXT_STANDARD */
28#include "cp_campaign.h"
29#include "cp_missions.h"
30#include "cp_mission_triggers.h"
31#include "cp_event_callbacks.h"
32
41void CP_ExecuteMissionTrigger (const mission_t* mission, bool won)
42{
43 cgi->Com_DPrintf(DEBUG_CLIENT, "Execute mission triggers\n");
44
45 if (mission == nullptr)
46 return;
47
48 /* we add them only here - and remove them afterwards to prevent cheating */
50
51 if (won) {
52 if (Q_strvalid(mission->onwin)) {
53 cgi->Com_DPrintf(DEBUG_CLIENT, "...won - executing '%s'\n", mission->onwin);
54 cgi->Cmd_ExecuteString("%s", mission->onwin);
55 }
56 if (mission->mapDef && Q_strvalid(mission->mapDef->onwin)) {
57 cgi->Com_DPrintf(DEBUG_CLIENT, "...won - executing '%s'\n", mission->mapDef->onwin);
58 cgi->Cmd_ExecuteString("%s", mission->mapDef->onwin);
59 }
60 } else {
61 if (Q_strvalid(mission->onlose)) {
62 cgi->Com_DPrintf(DEBUG_CLIENT, "...lost - executing '%s'\n", mission->onlose);
63 cgi->Cmd_ExecuteString("%s", mission->onlose);
64 }
65 if (mission->mapDef && Q_strvalid(mission->mapDef->onlose)) {
66 cgi->Com_DPrintf(DEBUG_CLIENT, "...lost - executing '%s'\n", mission->mapDef->onlose);
67 cgi->Cmd_ExecuteString("%s", mission->mapDef->onlose);
68 }
69 }
70
72}
Share stuff between the different cgame implementations.
Header file for single player campaign control.
const cgame_import_t * cgi
void CP_CampaignTriggerFunctions(bool add)
Add/Remove temporary mission trigger functions.
void CP_ExecuteMissionTrigger(const mission_t *mission, bool won)
Executes console commands after a mission.
Campaign mission triggers.
Campaign missions headers.
#define DEBUG_CLIENT
Definition defines.h:59
#define Q_strvalid(string)
Definition shared.h:141
char * onwin
Definition q_shared.h:497
char * onlose
Definition q_shared.h:498
mission definition
Definition cp_missions.h:86
mapDef_t * mapDef
Definition cp_missions.h:89
char onwin[256]
char onlose[256]