1 /**
2  * @file
3  * @brief Header for geoscape event related stuff.
4  */
5 
6 /*
7 Copyright (C) 2002-2013 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 #define MAX_EVENTMAILS 64
29 #define MAX_CAMPAIGNEVENTS 128
30 
31 /**
32  * @brief available mails for a tech - mail and mail_pre in script files
33  * @sa techMail_t
34  * @note Parsed via CL_ParseEventMails
35  * @note You can add a mail to the message system and mail client
36  * by using e.g. the mission triggers with the script command 'addeventmail \<id\>'
37  */
38 typedef struct eventMail_s {
39 	char* id;			/**< script id */
40 	char* from;			/**< sender (_mail_from_paul_navarre, _mail_from_dr_connor) */
41 	char* to;			/**< recipient (_mail_to_base_commander) */
42 	char* cc;			/**< copy recipient (_mail_to_base_commander) */
43 	char* subject;		/**< mail subject line - if mail and mail_pre are available
44 						 * this will be filled with Proposal: (mail_pre) and Re: (mail)
45 						 * automatically */
46 	char* date;			/**< date string, if empty use the date of research */
47 	char* body;			/**< the body of the event mail */
48 	char* icon;			/**< icon in the mailclient */
49 	char* model;		/**< model name of the sender */
50 	bool read;			/**< already read the mail? */
51 	bool sent;			/**< already sent, don't send twice */
52 	bool skipMessage;	/**< don't add the mail to the message stack (won't be saved) */
53 } eventMail_t;
54 
55 void CL_EventAddMail_f(void);
56 void CL_ParseEventMails(const char* name, const char** text);
57 eventMail_t* CL_GetEventMail(const char* id);
58 void CP_FreeDynamicEventMail(void);
59 void CL_EventAddMail(const char* eventMailId);
60 
61 /**
62  * @brief Defines campaign events when story related technologies should be researched
63  */
64 typedef struct campaignEvent_s {
65 	char* tech;			/**< technology id that should be researched if the overall interest is reached */
66 	int interest;		/**< the interest value (see @c ccs.oberallInterest) */
67 } campaignEvent_t;
68 
69 typedef struct campaignEvents_s {
70 	campaignEvent_t campaignEvents[MAX_CAMPAIGNEVENTS];	/**< holds all campaign events */
71 	int numCampaignEvents;	/**< how many events (script-id: events) parsed */
72 	char* id;				/**< script id */
73 } campaignEvents_t;
74 
75 /**
76  * @brief events that are triggered by the campaign
77  */
78 typedef enum {
79 	NEW_DAY,
80 	UFO_DETECTION,
81 	CAPTURED_ALIENS_DIED,
82 	CAPTURED_ALIENS,
83 	ALIENBASE_DISCOVERED
84 } campaignTriggerEventType_t;
85 
86 typedef struct {
87 	campaignTriggerEventType_t type;
88 	char* id;				/**< the script id */
89 	char* require;			/**< the binary expression to evaluate for this event */
90 	char* reactivate;		/**< the binary expression to reactivate this event */
91 	char* command;			/**< the command to execute if the @c require field evaluated to @c true */
92 	bool once;				/**< if this is @c true, the event will only be triggered once */
93 	bool active;			/**< if this event is inactive, and has a @c reactivate binary expression, it can get reactivated */
94 } campaignTriggerEvent_t;
95 
96 #define MAX_CAMPAIGN_TRIGGER_EVENTS 32
97 
98 void CP_CheckCampaignEvents(struct campaign_s* campaign);
99 void CL_ParseCampaignEvents(const char* name, const char** text);
100 void CP_ParseEventTrigger(const char* name, const char** text);
101 bool CP_TriggerEventLoadXML(xmlNode_t* p);
102 bool CP_TriggerEventSaveXML(xmlNode_t* p);
103 void CP_TriggerEvent(campaignTriggerEventType_t type, const void* userdata = nullptr);
104 const campaignEvents_t* CP_GetEventsByID(const char* name);
105