1 /*
2  * Copyright 2011-2013 Arx Libertatis Team (see the AUTHORS file)
3  *
4  * This file is part of Arx Libertatis.
5  *
6  * Arx Libertatis is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Arx Libertatis is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Arx Libertatis.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 /* Based on:
20 ===========================================================================
21 ARX FATALIS GPL Source Code
22 Copyright (C) 1999-2010 Arkane Studios SA, a ZeniMax Media company.
23 
24 This file is part of the Arx Fatalis GPL Source Code ('Arx Fatalis Source Code').
25 
26 Arx Fatalis Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
27 License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28 
29 Arx Fatalis Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
30 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License along with Arx Fatalis Source Code.  If not, see
33 <http://www.gnu.org/licenses/>.
34 
35 In addition, the Arx Fatalis Source Code is also subject to certain additional terms. You should have received a copy of these
36 additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Arx
37 Fatalis Source Code. If not, please request a copy in writing from Arkane Studios at the address below.
38 
39 If you have questions concerning this license or the applicable additional terms, you may contact in writing Arkane Studios, c/o
40 ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
41 ===========================================================================
42 */
43 // Code: Cyril Meynier
44 //
45 // Copyright (c) 1999-2000 ARKANE Studios SA. All rights reserved
46 
47 #ifndef ARX_SCRIPT_SCRIPT_H
48 #define ARX_SCRIPT_SCRIPT_H
49 
50 #include <stddef.h>
51 #include <string>
52 
53 #include "platform/Flags.h"
54 
55 class PakFile;
56 class Entity;
57 
58 const size_t MAX_SHORTCUT = 80;
59 const size_t MAX_SCRIPTTIMERS = 5;
60 
61 enum ValueType {
62 	TYPE_TEXT = 1,
63 	TYPE_FLOAT = 2,
64 	TYPE_LONG = 3
65 };
66 
67 
68 enum VariableType {
69 	TYPE_UNKNOWN = 0, // does not exist !
70 	TYPE_G_TEXT = 1,
71 	TYPE_L_TEXT = 2,
72 	TYPE_G_LONG = 4,
73 	TYPE_L_LONG = 8,
74 	TYPE_G_FLOAT = 16,
75 	TYPE_L_FLOAT = 32
76 };
77 
78 struct SCRIPT_VAR {
79 	VariableType type;
80 	long ival;
81 	float fval;
82 	char * text;  // for a TEXT type ival equals strlen(text).
83 	char name[64];
84 };
85 
86 struct LABEL_INFO {
87 	char * string;
88 	long idx;
89 };
90 
91 enum DisabledEvent {
92 	DISABLE_HIT             = (1<<0),
93 	DISABLE_CHAT            = (1<<1),
94 	DISABLE_INVENTORY2_OPEN = (1<<2),
95 	DISABLE_HEAR            = (1<<3),
96 	DISABLE_DETECT          = (1<<4),
97 	DISABLE_AGGRESSION      = (1<<5),
98 	DISABLE_MAIN            = (1<<6),
99 	DISABLE_COLLIDE_NPC     = (1<<7),
100 	DISABLE_CURSORMODE      = (1<<8),
101 	DISABLE_EXPLORATIONMODE = (1<<9)
102 };
103 DECLARE_FLAGS(DisabledEvent, DisabledEvents)
104 DECLARE_FLAGS_OPERATORS(DisabledEvents)
105 
106 struct EERIE_SCRIPT {
107 	size_t size;
108 	char * data;
109 	long nblvar;
110 	SCRIPT_VAR * lvar;
111 	unsigned long lastcall;
112 	unsigned long timers[MAX_SCRIPTTIMERS];
113 	DisabledEvents allowevents;
114 	EERIE_SCRIPT * master;
115 	long shortcut[MAX_SHORTCUT];
116 	long nb_labels;
117 	LABEL_INFO * labels;
118 };
119 
120 struct SCR_TIMER {
121 
122 	std::string name;
123 	short exist;
124 	short flags;
125 	long times;
126 	long msecs;
127 	long pos;
128 	long longinfo;
129 	unsigned long tim;
130 	Entity * io;
131 	EERIE_SCRIPT * es;
132 
SCR_TIMERSCR_TIMER133 	inline SCR_TIMER() : name(), exist(0), flags(0), times(0),
134 	                     msecs(0), pos(0), longinfo(0), tim(0), io(NULL), es(NULL) { }
135 
resetSCR_TIMER136 	inline void reset() {
137 		name.clear();
138 		exist = 0;
139 		flags = 0;
140 		times = 0;
141 		msecs = 0;
142 		pos = 0;
143 		longinfo = 0;
144 		tim = 0;
145 		io = NULL;
146 		es = NULL;
147 	}
148 
149 };
150 
151 enum AnimationNumber {
152 
153 	ANIM_NONE = -1,
154 
155 	ANIM_WAIT = 0,
156 	ANIM_WALK = 1,
157 	ANIM_WALK2 = 2,
158 	ANIM_WALK3 = 3,
159 	ANIM_ACTION = 8,
160 	ANIM_ACTION2 = 9,
161 	ANIM_ACTION3 = 10,
162 	ANIM_HIT1 = 11,
163 	ANIM_STRIKE1 = 12,
164 	ANIM_DIE = 13,
165 	ANIM_WAIT2 = 14,
166 	ANIM_RUN = 15,
167 	ANIM_RUN2 = 16,
168 	ANIM_RUN3 = 17,
169 	ANIM_ACTION4 = 18,
170 	ANIM_ACTION5 = 19,
171 	ANIM_ACTION6 = 20,
172 	ANIM_ACTION7 = 21,
173 	ANIM_ACTION8 = 22,
174 	ANIM_ACTION9 = 23,
175 	ANIM_ACTION10 = 24,
176 	ANIM_TALK_NEUTRAL = 30,
177 	ANIM_TALK_HAPPY = 31,
178 	ANIM_TALK_ANGRY = 32,
179 	ANIM_WALK_BACKWARD = 33,
180 
181 	ANIM_BARE_READY = 34,
182 	ANIM_BARE_UNREADY = (ANIM_BARE_READY+1),
183 	ANIM_BARE_WAIT = (ANIM_BARE_READY+2),
184 	ANIM_BARE_STRIKE_LEFT_START = (ANIM_BARE_READY+3),
185 	ANIM_BARE_STRIKE_LEFT_CYCLE = (ANIM_BARE_READY+4),
186 	ANIM_BARE_STRIKE_LEFT = (ANIM_BARE_READY+5),
187 	ANIM_BARE_STRIKE_RIGHT_START = (ANIM_BARE_READY+6),
188 	ANIM_BARE_STRIKE_RIGHT_CYCLE = (ANIM_BARE_READY+7),
189 	ANIM_BARE_STRIKE_RIGHT = (ANIM_BARE_READY+8),
190 	ANIM_BARE_STRIKE_TOP_START = (ANIM_BARE_READY+9),
191 	ANIM_BARE_STRIKE_TOP_CYCLE = (ANIM_BARE_READY+10),
192 	ANIM_BARE_STRIKE_TOP = (ANIM_BARE_READY+11),
193 	ANIM_BARE_STRIKE_BOTTOM_START = (ANIM_BARE_READY+12),
194 	ANIM_BARE_STRIKE_BOTTOM_CYCLE = (ANIM_BARE_READY+13),
195 	ANIM_BARE_STRIKE_BOTTOM = (ANIM_BARE_READY+14),
196 
197 	ANIM_1H_READY_PART_1 = (ANIM_BARE_STRIKE_BOTTOM+1),
198 	ANIM_1H_READY_PART_2 = (ANIM_1H_READY_PART_1+1),
199 	ANIM_1H_UNREADY_PART_1 = (ANIM_1H_READY_PART_1+2),
200 	ANIM_1H_UNREADY_PART_2 = (ANIM_1H_READY_PART_1+3),
201 	ANIM_1H_WAIT = (ANIM_1H_READY_PART_1+4),
202 	ANIM_1H_STRIKE_LEFT_START = (ANIM_1H_READY_PART_1+5),
203 	ANIM_1H_STRIKE_LEFT_CYCLE = (ANIM_1H_READY_PART_1+6),
204 	ANIM_1H_STRIKE_LEFT = (ANIM_1H_READY_PART_1+7),
205 	ANIM_1H_STRIKE_RIGHT_START = (ANIM_1H_READY_PART_1+8),
206 	ANIM_1H_STRIKE_RIGHT_CYCLE = (ANIM_1H_READY_PART_1+9),
207 	ANIM_1H_STRIKE_RIGHT = (ANIM_1H_READY_PART_1+10),
208 	ANIM_1H_STRIKE_TOP_START = (ANIM_1H_READY_PART_1+11),
209 	ANIM_1H_STRIKE_TOP_CYCLE = (ANIM_1H_READY_PART_1+12),
210 	ANIM_1H_STRIKE_TOP = (ANIM_1H_READY_PART_1+13),
211 	ANIM_1H_STRIKE_BOTTOM_START = (ANIM_1H_READY_PART_1+14),
212 	ANIM_1H_STRIKE_BOTTOM_CYCLE = (ANIM_1H_READY_PART_1+15),
213 	ANIM_1H_STRIKE_BOTTOM = (ANIM_1H_READY_PART_1+16),
214 
215 	ANIM_2H_READY_PART_1 = (ANIM_1H_STRIKE_BOTTOM+1), //66
216 	ANIM_2H_READY_PART_2 = (ANIM_2H_READY_PART_1+1),
217 	ANIM_2H_UNREADY_PART_1 = (ANIM_2H_READY_PART_1+2),
218 	ANIM_2H_UNREADY_PART_2 = (ANIM_2H_READY_PART_1+3),
219 	ANIM_2H_WAIT = (ANIM_2H_READY_PART_1+4),
220 	ANIM_2H_STRIKE_LEFT_START = (ANIM_2H_READY_PART_1+5),
221 	ANIM_2H_STRIKE_LEFT_CYCLE = (ANIM_2H_READY_PART_1+6),
222 	ANIM_2H_STRIKE_LEFT = (ANIM_2H_READY_PART_1+7),
223 	ANIM_2H_STRIKE_RIGHT_START = (ANIM_2H_READY_PART_1+8),
224 	ANIM_2H_STRIKE_RIGHT_CYCLE = (ANIM_2H_READY_PART_1+9),
225 	ANIM_2H_STRIKE_RIGHT = (ANIM_2H_READY_PART_1+10),
226 	ANIM_2H_STRIKE_TOP_START = (ANIM_2H_READY_PART_1+11),
227 	ANIM_2H_STRIKE_TOP_CYCLE = (ANIM_2H_READY_PART_1+12),
228 	ANIM_2H_STRIKE_TOP = (ANIM_2H_READY_PART_1+13),
229 	ANIM_2H_STRIKE_BOTTOM_START = (ANIM_2H_READY_PART_1+14),
230 	ANIM_2H_STRIKE_BOTTOM_CYCLE = (ANIM_2H_READY_PART_1+15),
231 	ANIM_2H_STRIKE_BOTTOM = (ANIM_2H_READY_PART_1+16),
232 
233 	ANIM_DAGGER_READY_PART_1 = (ANIM_2H_STRIKE_BOTTOM+1), //82
234 	ANIM_DAGGER_READY_PART_2 = (ANIM_DAGGER_READY_PART_1+1),
235 	ANIM_DAGGER_UNREADY_PART_1 = (ANIM_DAGGER_READY_PART_1+2),
236 	ANIM_DAGGER_UNREADY_PART_2 = (ANIM_DAGGER_READY_PART_1+3),
237 	ANIM_DAGGER_WAIT = (ANIM_DAGGER_READY_PART_1+4),
238 	ANIM_DAGGER_STRIKE_LEFT_START = (ANIM_DAGGER_READY_PART_1+5),
239 	ANIM_DAGGER_STRIKE_LEFT_CYCLE = (ANIM_DAGGER_READY_PART_1+6),
240 	ANIM_DAGGER_STRIKE_LEFT = (ANIM_DAGGER_READY_PART_1+7),
241 	ANIM_DAGGER_STRIKE_RIGHT_START = (ANIM_DAGGER_READY_PART_1+8),
242 	ANIM_DAGGER_STRIKE_RIGHT_CYCLE = (ANIM_DAGGER_READY_PART_1+9),
243 	ANIM_DAGGER_STRIKE_RIGHT = (ANIM_DAGGER_READY_PART_1+10),
244 	ANIM_DAGGER_STRIKE_TOP_START = (ANIM_DAGGER_READY_PART_1+11),
245 	ANIM_DAGGER_STRIKE_TOP_CYCLE = (ANIM_DAGGER_READY_PART_1+12),
246 	ANIM_DAGGER_STRIKE_TOP = (ANIM_DAGGER_READY_PART_1+13),
247 	ANIM_DAGGER_STRIKE_BOTTOM_START = (ANIM_DAGGER_READY_PART_1+14),
248 	ANIM_DAGGER_STRIKE_BOTTOM_CYCLE = (ANIM_DAGGER_READY_PART_1+15),
249 	ANIM_DAGGER_STRIKE_BOTTOM = (ANIM_DAGGER_READY_PART_1+16),
250 
251 	ANIM_MISSILE_READY_PART_1 = (ANIM_DAGGER_STRIKE_BOTTOM+1), //99
252 	ANIM_MISSILE_READY_PART_2 = (ANIM_MISSILE_READY_PART_1+1),
253 	ANIM_MISSILE_UNREADY_PART_1 = (ANIM_MISSILE_READY_PART_1+2),
254 	ANIM_MISSILE_UNREADY_PART_2 = (ANIM_MISSILE_READY_PART_1+3),
255 	ANIM_MISSILE_WAIT = (ANIM_MISSILE_READY_PART_1+4),
256 	ANIM_MISSILE_STRIKE_PART_1 = (ANIM_MISSILE_READY_PART_1+5),
257 	ANIM_MISSILE_STRIKE_PART_2 = (ANIM_MISSILE_READY_PART_1+6),
258 	ANIM_MISSILE_STRIKE_CYCLE = (ANIM_MISSILE_READY_PART_1+7),
259 	ANIM_MISSILE_STRIKE = (ANIM_MISSILE_READY_PART_1+8),
260 
261 	ANIM_SHIELD_START = (ANIM_MISSILE_STRIKE+1), //108
262 	ANIM_SHIELD_CYCLE = (ANIM_SHIELD_START+1),
263 	ANIM_SHIELD_HIT = (ANIM_SHIELD_START+2),
264 	ANIM_SHIELD_END = (ANIM_SHIELD_START+3),
265 
266 	ANIM_CAST_START = (ANIM_SHIELD_END+1), //112
267 	ANIM_CAST_CYCLE = (ANIM_CAST_START+1),
268 	ANIM_CAST = (ANIM_CAST_START+2),
269 	ANIM_CAST_END = (ANIM_CAST_START+3),
270 
271 	ANIM_DEATH_CRITICAL = (ANIM_CAST_END+1),
272 	ANIM_CROUCH = (ANIM_CAST_END+2),
273 	ANIM_CROUCH_WALK = (ANIM_CAST_END+3),
274 	ANIM_CROUCH_WALK_BACKWARD = (ANIM_CAST_END+4),
275 	ANIM_LEAN_RIGHT = (ANIM_CAST_END+5),
276 	ANIM_LEAN_LEFT = (ANIM_CAST_END+6),
277 	ANIM_JUMP = (ANIM_CAST_END+7),
278 	ANIM_HOLD_TORCH = (ANIM_CAST_END+8),
279 	ANIM_WALK_MINISTEP = (ANIM_CAST_END+9),
280 	ANIM_STRAFE_RIGHT = (ANIM_CAST_END+10),
281 	ANIM_STRAFE_LEFT = (ANIM_CAST_END+11),
282 	ANIM_MEDITATION = (ANIM_CAST_END+12),
283 	ANIM_WAIT_SHORT = (ANIM_CAST_END+13),
284 
285 	ANIM_FIGHT_WALK_FORWARD = (ANIM_CAST_END+14),
286 	ANIM_FIGHT_WALK_BACKWARD = (ANIM_CAST_END+15),
287 	ANIM_FIGHT_WALK_MINISTEP = (ANIM_CAST_END+16),
288 	ANIM_FIGHT_STRAFE_RIGHT = (ANIM_CAST_END+17),
289 	ANIM_FIGHT_STRAFE_LEFT = (ANIM_CAST_END+18),
290 	ANIM_FIGHT_WAIT = (ANIM_CAST_END+19),
291 
292 	ANIM_LEVITATE = (ANIM_CAST_END+20),
293 	ANIM_CROUCH_START = (ANIM_CAST_END+21),
294 	ANIM_CROUCH_WAIT = (ANIM_CAST_END+22),
295 	ANIM_CROUCH_END = (ANIM_CAST_END+23),
296 	ANIM_JUMP_ANTICIPATION = (ANIM_CAST_END+24),
297 	ANIM_JUMP_UP = (ANIM_CAST_END+25),
298 	ANIM_JUMP_CYCLE = (ANIM_CAST_END+26),
299 	ANIM_JUMP_END = (ANIM_CAST_END+27),
300 	ANIM_TALK_NEUTRAL_HEAD = (ANIM_CAST_END+28),
301 	ANIM_TALK_ANGRY_HEAD = (ANIM_CAST_END+29),
302 	ANIM_TALK_HAPPY_HEAD = (ANIM_CAST_END+30),
303 	ANIM_STRAFE_RUN_LEFT = (ANIM_CAST_END+31),
304 	ANIM_STRAFE_RUN_RIGHT = (ANIM_CAST_END+32),
305 	ANIM_CROUCH_STRAFE_LEFT = (ANIM_CAST_END+33),
306 	ANIM_CROUCH_STRAFE_RIGHT = (ANIM_CAST_END+34),
307 	ANIM_WALK_SNEAK = (ANIM_CAST_END+35),
308 	ANIM_GRUNT = (ANIM_CAST_END+36),
309 	ANIM_JUMP_END_PART2 = (ANIM_CAST_END+37),
310 	ANIM_HIT_SHORT = (ANIM_CAST_END+38),
311 	ANIM_U_TURN_LEFT = (ANIM_CAST_END+39),
312 	ANIM_U_TURN_RIGHT = (ANIM_CAST_END+40),
313 	ANIM_RUN_BACKWARD = (ANIM_CAST_END+41),
314 	ANIM_U_TURN_LEFT_FIGHT = (ANIM_CAST_END+42),
315 	ANIM_U_TURN_RIGHT_FIGHT = (ANIM_CAST_END+43),
316 
317 };
318 
319 const AnimationNumber ANIM_DEFAULT = ANIM_WAIT;
320 
321 enum ScriptResult {
322 	ACCEPT = 1,
323 	REFUSE = -1,
324 	BIGERROR = -2
325 };
326 
327 enum ScriptMessage {
328 	SM_NULL = 0,
329 	SM_INIT = 1,
330 	SM_INVENTORYIN = 2,
331 	SM_INVENTORYOUT = 3,
332 	SM_INVENTORYUSE = 4,
333 	SM_SCENEUSE = 5,
334 	SM_EQUIPIN = 6,
335 	SM_EQUIPOUT = 7,
336 	SM_MAIN = 8,
337 	SM_RESET = 9,
338 	SM_CHAT = 10,
339 	SM_ACTION = 11,
340 	SM_DEAD = 12,
341 	SM_REACHEDTARGET = 13,
342 	SM_FIGHT = 14,
343 	SM_FLEE = 15,
344 	SM_HIT = 16,
345 	SM_DIE = 17,
346 	SM_LOSTTARGET = 18,
347 	SM_TREATIN = 19,
348 	SM_TREATOUT = 20,
349 	SM_MOVE = 21,
350 	SM_DETECTPLAYER = 22,
351 	SM_UNDETECTPLAYER = 23,
352 	SM_COMBINE = 24,
353 	SM_NPC_FOLLOW = 25,
354 	SM_NPC_FIGHT = 26,
355 	SM_NPC_STAY = 27,
356 	SM_INVENTORY2_OPEN = 28,
357 	SM_INVENTORY2_CLOSE = 29,
358 	SM_CUSTOM = 30,
359 	SM_ENTER_ZONE = 31,
360 	SM_LEAVE_ZONE = 32,
361 	SM_INITEND = 33,
362 	SM_CLICKED = 34,
363 	SM_INSIDEZONE = 35,
364 	SM_CONTROLLEDZONE_INSIDE = 36,
365 	SM_LEAVEZONE = 37,
366 	SM_CONTROLLEDZONE_LEAVE = 38,
367 	SM_ENTERZONE = 39,
368 	SM_CONTROLLEDZONE_ENTER = 40,
369 	SM_LOAD = 41,
370 	SM_SPELLCAST = 42,
371 	SM_RELOAD = 43,
372 	SM_COLLIDE_DOOR = 44,
373 	SM_OUCH = 45,
374 	SM_HEAR = 46,
375 	SM_SUMMONED = 47,
376 	SM_SPELLEND = 48,
377 	SM_SPELLDECISION = 49,
378 	SM_STRIKE = 50,
379 	SM_COLLISION_ERROR = 51,
380 	SM_WAYPOINT = 52,
381 	SM_PATHEND = 53,
382 	SM_CRITICAL = 54,
383 	SM_COLLIDE_NPC = 55,
384 	SM_BACKSTAB = 56,
385 	SM_AGGRESSION = 57,
386 	SM_COLLISION_ERROR_DETAIL = 58,
387 	SM_GAME_READY = 59,
388 	SM_CINE_END = 60,
389 	SM_KEY_PRESSED = 61,
390 	SM_CONTROLS_ON = 62,
391 	SM_CONTROLS_OFF = 63,
392 	SM_PATHFINDER_FAILURE = 64,
393 	SM_PATHFINDER_SUCCESS = 65,
394 	SM_TRAP_DISARMED = 66,
395 	SM_BOOK_OPEN = 67,
396 	SM_BOOK_CLOSE = 68,
397 	SM_IDENTIFY = 69,
398 	SM_BREAK = 70,
399 	SM_STEAL = 71,
400 	SM_COLLIDE_FIELD = 72,
401 	SM_CURSORMODE = 73,
402 	SM_EXPLORATIONMODE = 74,
403 	SM_MAXCMD = 75,
404 	SM_EXECUTELINE = 255,
405 	SM_DUMMY = 256
406 };
407 
408 extern SCRIPT_VAR * svar;
409 extern Entity * EVENT_SENDER;
410 extern SCR_TIMER * scr_timer;
411 extern long NB_GLOBALS;
412 extern long ActiveTimers;
413 extern long FORBID_SCRIPT_IO_CREATION;
414 extern long MAX_TIMER_SCRIPT;
415 
416 void ARX_SCRIPT_Timer_Check();
417 void ARX_SCRIPT_Timer_FirstInit(long number);
418 void ARX_SCRIPT_Timer_ClearAll();
419 void ARX_SCRIPT_Timer_Clear_For_IO(Entity * io);
420 void ARX_SCRIPT_Timer_Clear_By_IO(Entity * io);
421 long ARX_SCRIPT_Timer_GetFree();
422 
423 void ARX_SCRIPT_SetMainEvent(Entity * io, const std::string & newevent);
424 void ARX_SCRIPT_EventStackExecute();
425 void ARX_SCRIPT_EventStackExecuteAll();
426 void ARX_SCRIPT_EventStackInit();
427 void ARX_SCRIPT_EventStackClear(bool check_exist = true);
428 void ARX_SCRIPT_ResetObject(Entity * io, long flags);
429 void ARX_SCRIPT_Reset(Entity * io, long flags);
430 long ARX_SCRIPT_GetSystemIOScript(Entity * io, const std::string & name);
431 void ARX_SCRIPT_ComputeShortcuts(EERIE_SCRIPT & es);
432 void ARX_SCRIPT_AllowInterScriptExec();
433 long ARX_SCRIPT_CountTimers();
434 void ARX_SCRIPT_Timer_ClearByNum(long num);
435 void ARX_SCRIPT_ResetAll(long flags);
436 void ARX_SCRIPT_EventStackClearForIo(Entity * io);
437 Entity * ARX_SCRIPT_Get_IO_Max_Events();
438 Entity * ARX_SCRIPT_Get_IO_Max_Events_Sent();
439 
440 void ManageCasseDArme(Entity * io);
441 void ReleaseScript(EERIE_SCRIPT * es);
442 void ARX_SCRIPT_Init_Event_Stats();
443 ScriptResult SendInitScriptEvent(Entity * io);
444 
445 //used by scriptevent
446 void MakeSSEPARAMS(const char * params);
447 float GetVarValueInterpretedAsFloat(const std::string & temp1, const EERIE_SCRIPT * esss, Entity * io);
448 std::string GetVarValueInterpretedAsText(const std::string & temp1, const EERIE_SCRIPT * esss, Entity * io);
449 
450 //! Generates a random name for an unnamed timer
451 std::string ARX_SCRIPT_Timer_GetDefaultName();
452 
453 // Use to set the value of a script variable
454 SCRIPT_VAR * SETVarValueText(SCRIPT_VAR *& svf, long & nb, const std::string &  name, const std::string & val);
455 SCRIPT_VAR * SETVarValueLong(SCRIPT_VAR *& svf, long & nb, const std::string & name, long val);
456 SCRIPT_VAR * SETVarValueFloat(SCRIPT_VAR *& svf, long & nb, const std::string & name, float val);
457 
458 // Use to get the value of a script variable
459 long GETVarValueLong(SCRIPT_VAR svf[], size_t nb, const std::string & name);
460 float GETVarValueFloat(SCRIPT_VAR svf[], size_t nb, const std::string & name);
461 std::string GETVarValueText(SCRIPT_VAR svf[], size_t nb, const std::string & name);
462 
463 ValueType getSystemVar(const EERIE_SCRIPT * es, Entity * io, const std::string & name, std::string & txtcontent, float * fcontent, long * lcontent);
464 void ARX_SCRIPT_Timer_Clear_All_Locals_For_IO(Entity * io);
465 void ARX_SCRIPT_Timer_Clear_By_Name_And_IO(const std::string & timername, Entity * io);
466 
467 ScriptResult SendIOScriptEvent(Entity * io, ScriptMessage msg, const std::string & params = "", const std::string & eventname = "" );
468 
469 ScriptResult SendMsgToAllIO(ScriptMessage msg, const std::string & params = "");
470 
471 void Stack_SendIOScriptEvent(Entity * io, ScriptMessage msg, const std::string & params = "", const std::string & eventname = "");
472 
473 /*!
474  * Finds the first occurence of str in the script that is followed
475  * by a separator (a character of value less then or equal 32)
476  *
477  * @return The position of str in the script or -1 if str was not found.
478  */
479 long FindScriptPos(const EERIE_SCRIPT * es, const std::string & str);
480 
481 void CloneLocalVars(Entity * ioo, Entity * io);
482 void ARX_SCRIPT_Free_All_Global_Variables();
483 void MakeLocalText(EERIE_SCRIPT * es, std::string & tx);
484 void MakeGlobalText(std::string & tx);
485 
486 void loadScript(EERIE_SCRIPT & script, PakFile * file);
487 
488 #endif // ARX_SCRIPT_SCRIPT_H
489