/
acscript.h
115 lines (92 loc) · 3 KB
/
acscript.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/** @file acscript.h Hexen "ACS" scripting system.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1999 Activision
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef LIBHEXEN_PLAY_ACS_H
#define LIBHEXEN_PLAY_ACS_H
#ifndef __JHEXEN__
# error "Using jHexen headers without __JHEXEN__"
#endif
#include "jhexen.h"
#include "p_mobj.h"
#define MAX_ACS_SCRIPT_VARS 10
#define MAX_ACS_MAP_VARS 32
#define MAX_ACS_WORLD_VARS 64
#define ACS_STACK_DEPTH 32
#ifdef __cplusplus
extern "C" {
#endif
/**
* To be called when a new game session begins to initialize ACS scripting.
*/
void P_InitACScript(void);
void P_LoadACScripts(lumpnum_t lump);
/**
* @param map Map number on which the script is being started on.
* @c 0 = Current map. Otherwise 1-based index of the map to start on (deferred).
*/
dd_bool P_StartACScript(int number, uint map, byte *args, mobj_t *activator, Line *line, int side);
dd_bool P_TerminateACScript(int number, uint map);
dd_bool P_SuspendACScript(int number, uint map);
void P_ACScriptTagFinished(int tag);
void P_ACScriptPolyobjFinished(int tag);
/**
* To be called when the current map changes to activate any deferred scripts which
* should now begin/resume.
*/
void P_ACScriptRunDeferredTasks(uint map/*Uri const *map*/);
void P_WriteGlobalACScriptData(void);
void P_ReadGlobalACScriptData(int saveVersion);
void P_WriteMapACScriptData(void);
void P_ReadMapACScriptData(void);
#ifdef __cplusplus
} // extern "C"
#endif
/**
* Action script thinker.
*/
typedef struct acscript_s {
thinker_t thinker;
mobj_t *activator;
Line *line;
int side;
int number;
int infoIndex;
int delayCount;
int stack[ACS_STACK_DEPTH];
int stackPtr;
int vars[MAX_ACS_SCRIPT_VARS];
int const *ip;
} ACScript;
#ifdef __cplusplus
extern "C" {
#endif
void ACScript_Thinker(ACScript *script);
/**
* Serialize the thinker to the currently open save file.
*/
void ACScript_Write(ACScript const *script);
/**
* Deserialize the thinker from the currently open save file.
*/
int ACScript_Read(ACScript *script, int mapVersion);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // LIBHEXEN_PLAY_ACS_H