1 //----------------------------------------------------------------------------
2 //  Radius Trigger Main definitions
3 //----------------------------------------------------------------------------
4 //
5 //  Copyright (c) 1999-2009  The EDGE Team.
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; either version 2
10 //  of the License, or (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //----------------------------------------------------------------------------
18 
19 #ifndef __RAD_MAIN_H__
20 #define __RAD_MAIN_H__
21 
22 #include "ddf/main.h"
23 
24 #include "r_defs.h"
25 #include "hu_stuff.h"
26 
27 #include "epi/math_crc.h"
28 
29 struct rts_state_s;
30 struct rad_script_s;
31 struct rad_trigger_s;
32 
33 typedef struct s_tip_s
34 {
35 	// tip text or graphic.  Two of these must be NULL.
36 	const char *tip_text;
37 	char *tip_ldf;
38 	char *tip_graphic;
39 
40 	// display time, in ticks
41 	int display_time;
42 
43 	// play the TINK sound ?
44 	bool playsound;
45 
46 	// graphic scaling (1.0 is normal, higher is bigger).
47 	float gfx_scale;
48 }
49 s_tip_t;
50 
51 
52 typedef struct s_tip_prop_s
53 {
54 	// new slot number, or < 0 for no change.
55 	int slot_num;
56 
57 	// tip position (as a percentage, 0-255), < 0 for no change
58 	percent_t x_pos, y_pos;
59 
60 	// left justify.  Can be 1, 0, or < 0 for no change.
61 	int left_just;
62 
63 	// tip color, or NULL for no change
64 	const char *color_name;
65 
66 	// translucency value (normally 1.0), or < 0 for no change
67 	percent_t translucency;
68 
69 	// time (in tics) to reach target.
70 	int time;
71 }
72 s_tip_prop_t;
73 
74 
75 typedef struct s_show_menu_s
76 {
77 	bool use_ldf;
78 
79 	char *title;
80 	char *options[9];
81 }
82 s_show_menu_t;
83 
84 typedef struct s_menu_style_s
85 {
86 	char *style;
87 }
88 s_menu_style_t;
89 
90 typedef struct s_jump_on_s
91 {
92 	// int vartype;  /* only MENU currently supported */
93 
94 	char *labels[9];
95 }
96 s_jump_on_t;
97 
98 // SpawnThing Function
99 typedef struct s_thing_s
100 {
101 	// spawn coordinates.  z can be ONFLOORZ or ONCEILINGZ.
102 	float x;
103 	float y;
104 	float z;
105 
106 	angle_t angle;
107 	float slope;
108 	int tag;
109 
110 	when_appear_e appear;
111 
112 	// -AJA- 1999/09/11: since the RSCRIPT lump can be loaded before
113 	//       DDF* lumps, we can't store a pointer to a mobjtype_c here
114 	//       (and the mobjtypes can move about with later additions).
115 
116 	// thing's DDF name, or if NULL, then thing's mapnumber.
117 	char *thing_name;
118 	int thing_type;
119 
120 	bool ambush;
121 	bool spawn_effect;
122 }
123 s_thing_t;
124 
125 
126 // Radius Damage Player Trigger
127 typedef struct
128 {
129 	float damage_amount;
130 }
131 s_damagep_t;
132 
133 
134 // Radius Heal Player Trigger
135 typedef struct
136 {
137 	float limit;
138 	float heal_amount;
139 }
140 s_healp_t;
141 
142 
143 // Radius GiveArmour Player Trigger
144 typedef struct
145 {
146 	armour_type_e type;
147 	float limit;
148 	float armour_amount;
149 }
150 s_armour_t;
151 
152 
153 // Radius Give/Lose Benefit
154 typedef struct
155 {
156 	benefit_t *benefit;
157 	bool lose_it;  // or use_it :)
158 }
159 s_benefit_t;
160 
161 
162 // Radius Damage Monster Trigger
163 typedef struct s_damage_monsters_s
164 {
165 	// type of monster to damage: DDF name, or if NULL, then the
166 	// monster's mapnumber, or if -1 then ANY monster can be damaged.
167 	char *thing_name;
168 	int thing_type;
169 	int thing_tag;
170 
171 	// how much damage to do
172 	float damage_amount;
173 }
174 s_damage_monsters_t;
175 
176 
177 // Set Skill
178 typedef struct
179 {
180 	skill_t skill;
181 	bool respawn;
182 	bool fastmonsters;
183 }
184 s_skill_t;
185 
186 
187 // Go to map
188 typedef struct
189 {
190 	char *map_name;
191 
192 	bool skip_all;
193 	bool is_hub;
194 
195 	int tag;
196 }
197 s_gotomap_t;
198 
199 
200 // Play Sound function
201 typedef enum
202 {
203 	PSOUND_Normal = 0,
204 	PSOUND_BossMan
205 }
206 s_sound_kind_e;
207 
208 typedef struct s_sound_s
209 {
210 	int kind;
211 
212 	// sound location.  z can be ONFLOORZ.
213 	float x, y, z;
214 
215 	struct sfx_s *sfx;
216 }
217 s_sound_t;
218 
219 
220 // Change Music function
221 typedef struct s_music_s
222 {
223 	// playlist entry number
224 	int playnum;
225 
226 	// whether to loop or not
227 	bool looping;
228 }
229 s_music_t;
230 
231 
232 //Sector Vertical movement
233 typedef struct s_movesector_s
234 {
235 	// tag to apply to.  When tag == 0, use the exact sector number
236 	// (deprecated, but kept for backwards compat).
237 	int tag;
238 	int secnum;
239 
240 	// Ceiling or Floor
241 	bool is_ceiling;
242 
243 	// when true, add the value to current height.  Otherwise set it.
244 	bool relative;
245 
246 	float value;
247 }
248 s_movesector_t;
249 
250 
251 //Sector Light change
252 typedef struct s_lightsector_s
253 {
254 	// tag to apply to.  When tag == 0, use the exact sector number
255 	// (deprecated, but kept for backwards compat).
256 	int tag;
257 	int secnum;
258 
259 	// when true, add the value to current light.  Otherwise set it.
260 	bool relative;
261 
262 	float value;
263 }
264 s_lightsector_t;
265 
266 
267 // Enable/Disable
268 typedef struct s_enabler_s
269 {
270 	// script to enable/disable.  If script_name is NULL, then `tag' is
271 	// the tag number to enable/disable.
272 	char *script_name;
273 	int tag;
274 
275 	// true to disable, false to enable
276 	bool new_disabled;
277 }
278 s_enabler_t;
279 
280 
281 // ActivateLine
282 typedef struct s_lineactivator_s
283 {
284 	// line type
285 	int typenum;
286 
287 	// sector tag
288 	int tag;
289 }
290 s_lineactivator_t;
291 
292 
293 // UnblockLines
294 typedef struct s_lineunblocker_s
295 {
296 	// line tag
297 	int tag;
298 }
299 s_lineunblocker_t;
300 
301 
302 // Jump
303 typedef struct s_jump_s
304 {
305 	// label name
306 	char *label;
307 
308 	// state to jump to.  Initially NULL, it is looked up when needed
309 	// (since the label may be a future reference, we can't rely on
310 	// looking it up at parse time).
311 	struct rts_state_s *cache_state;
312 
313 	// chance that the jump is taken.
314 	percent_t random_chance;
315 }
316 s_jump_t;
317 
318 
319 // Exit
320 typedef struct s_exit_s
321 {
322 	// exit time, in tics
323 	int exittime;
324 
325 	bool is_secret;
326 }
327 s_exit_t;
328 
329 
330 // Texture changing on lines/sectors
331 typedef enum
332 {
333 	// right side of the line
334 	CHTEX_RightUpper  = 0,
335 	CHTEX_RightMiddle = 1,
336 	CHTEX_RightLower  = 2,
337 
338 	// left side of the line
339 	CHTEX_LeftUpper  = 3,
340 	CHTEX_LeftMiddle = 4,
341 	CHTEX_LeftLower  = 5,
342 
343 	// the sky texture
344 	CHTEX_Sky = 6,
345 
346 	// sector floor or ceiling
347 	CHTEX_Floor   = 7,
348 	CHTEX_Ceiling = 8,
349 }
350 changetex_type_e;
351 
352 typedef struct s_changetex_s
353 {
354 	// what to change
355 	changetex_type_e what;
356 
357 	// texture/flat name
358 	char texname[10];
359 
360 	// tags used to find lines/sectors to change.  The `tag' value must
361 	// match sector.tag for sector changers and line.tag for line
362 	// changers.  The `subtag' value, if not 0, acts as a restriction:
363 	// for sector changers, a line in the sector must match subtag, and
364 	// for line changers, the sector on the given side must match the
365 	// subtag.  Both are ignored for sky changers.
366 	int tag, subtag;
367 }
368 s_changetex_t;
369 
370 
371 // Thing Event
372 typedef struct s_thing_event_s
373 {
374 	// DDF type name of thing to cause the event.  If NULL, then the
375 	// thing map number is used instead.
376 	const char *thing_name;
377 	int thing_type;
378 	int thing_tag;
379 
380 	// label to jump to
381 	const char *label;
382 	int offset;
383 }
384 s_thing_event_t;
385 
386 
387 // A single RTS action, not unlike the ones for DDF things.
388 //
389 typedef struct rts_state_s
390 {
391 	// link in list of states
392 	struct rts_state_s *next;
393 	struct rts_state_s *prev;
394 
395 	// duration in tics
396 	int tics;
397 
398 	// routine to be performed
399 	void (*action)(struct rad_trigger_s *trig, void *param);
400 
401 	// parameter for routine, or NULL
402 	void *param;
403 
404 	// state's label, or NULL
405 	char *label;
406 }
407 rts_state_t;
408 
409 
410 // Destination path name
411 typedef struct rts_path_s
412 {
413 	// next in list, or NULL
414 	struct rts_path_s *next;
415 
416 	const char *name;
417 
418 	// cached pointer to script
419 	struct rad_script_s *cached_scr;
420 }
421 rts_path_t;
422 
423 
424 // ONDEATH info
425 typedef struct s_ondeath_s
426 {
427 	// next in link (order is unimportant)
428 	struct s_ondeath_s *next;
429 
430 	// thing's DDF name, or if NULL, then thing's mapnumber.
431 	char *thing_name;
432 	int thing_type;
433 
434 	// threshhold: number of things still alive before the trigger can
435 	// activate.  Defaults to zero (i.e. all of them must be dead).
436 	int threshhold;
437 
438 	// mobjdef pointer, computed the first time this ONDEATH condition
439 	// is tested.
440 	const mobjtype_c *cached_info;
441 }
442 s_ondeath_t;
443 
444 
445 // ONHEIGHT info
446 typedef struct s_onheight_s
447 {
448 	// next in link (order is unimportant)
449 	struct s_onheight_s *next;
450 
451 	// Ceiling/Floor
452 	bool is_ceil;
453 
454 	// height range, trigger won't activate until sector's floor is
455 	// within this range (inclusive).
456 	float z1, z2;
457 
458 	// sector number, < 0 means use the trigger's location
459 	int sec_num;
460 
461 	// sector pointer, computed the first time this ONHEIGHT condition
462 	// is tested.
463 	sector_t *cached_sector;
464 }
465 s_onheight_t;
466 
467 
468 // WAIT_UNTIL_DEAD info
469 typedef struct s_wait_until_dead_s
470 {
471 	// tag number to give the monsters which we'll wait on
472 	int tag;
473 
474 	// the DDF names of the monsters to wait for
475 	const char *mon_names[10];
476 }
477 s_wait_until_dead_t;
478 
479 
480 // Trigger Definition (Made up of actions)
481 // Start_Map & Radius_Trigger Declaration
482 
483 typedef struct rad_script_s
484 {
485 	// link in list
486 	struct rad_script_s *next;
487 	struct rad_script_s *prev;
488 
489 	// Which map
490 	char *mapid;
491 
492 	// When appears
493 	when_appear_e appear;
494 
495 	int min_players;
496 	int max_players;
497 
498 	// Map Coordinates
499 	float x, y, z;
500 
501 	// Trigger size
502 	float rad_x, rad_y, rad_z;
503 
504 	// Script name (or NULL)
505 	char *script_name;
506 
507 	// Script tag (or 0 for none)
508 	int tag;
509 
510 	// ABSOLUTE mode: minimum players needed to trigger, -1 for ALL
511 	int absolute_req_players;
512 
513 	// Initially disabled ?
514 	bool tagged_disabled;
515 
516 	// Check for use.
517 	bool tagged_use;
518 
519 	// Continues working ?
520 	bool tagged_independent;
521 
522 	// Requires no player intervention ?
523 	bool tagged_immediate;
524 
525 	// Tagged_Repeat info (normal if repeat_count < 0)
526 	int repeat_count;
527 	int repeat_delay;
528 
529 	// Optional conditions...
530 	s_ondeath_t *boss_trig;
531 	s_onheight_t *height_trig;
532 	condition_check_t *cond_trig;
533 
534 	// Path info
535 	rts_path_t *next_in_path;
536 	int next_path_total;
537 
538 	const char *path_event_label;
539 	int path_event_offset;
540 
541 	// Set of states
542 	rts_state_t *first_state;
543 	rts_state_t *last_state;
544 
545 	// CRC of the important parts of this RTS script.
546 	epi::crc32_c crc;
547 }
548 rad_script_t;
549 
550 
551 #define REPEAT_FOREVER  0
552 
553 // Dynamic Trigger info.
554 // Goes away when trigger is finished.
555 typedef struct rad_trigger_s
556 {
557 	// link in list
558 	struct rad_trigger_s *next;
559 	struct rad_trigger_s *prev;
560 
561 	// link for triggers with the same tag
562 	struct rad_trigger_s *tag_next;
563 	struct rad_trigger_s *tag_prev;
564 
565 	// parent info of trigger
566 	rad_script_t *info;
567 
568 	// is it disabled ?
569 	bool disabled;
570 
571 	// has it been activated yet?
572 	bool activated;
573 
574 	// players who activated it (bit field)
575 	int acti_players;
576 
577 	// repeat info
578 	int repeats_left;
579 	int repeat_delay;
580 
581 	// current state info
582 	rts_state_t *state;
583 	int wait_tics;
584 
585 	// current tip slot (each tip slot works independently).
586 	int tip_slot;
587 
588 	// menu style name, or NULL if not set
589 	const char *menu_style_name;
590 
591 	// result of last SHOW_MENU (1 to 9, or 0 when cancelled)
592 	int menu_result;
593 
594     // Sound handle
595 	position_c sfx_origin;
596 
597 	// used for WAIT_UNTIL_DEAD, normally zero
598 	int wud_tag;
599 	int wud_count;
600 
601 	// prevent repeating scripts from clogging the console
602 	const char *last_con_message;
603 }
604 rad_trigger_t;
605 
606 
607 //
608 // Tip Displayer info
609 //
610 #define MAXTIPSLOT    45
611 
612 #define TIP_LINE_MAX  10
613 
614 typedef struct drawtip_s
615 {
616 	// current properties
617 	s_tip_prop_t p;
618 
619 	// display time.  When < 0, this slot is not in use (and all of the
620 	// fields below this one are unused).
621 	int delay;
622 
623 	// do we need to recompute some stuff (e.g. colmap) ?
624 	bool dirty;
625 
626 	// tip text DOH!
627 	const char *tip_text;
628 	const image_c *tip_graphic;
629 
630 	// play a sound ?
631 	bool playsound;
632 
633 	// scaling info (so far only for Tip_Graphic)
634 	float scale;
635 
636 	// current colour
637 	rgbcol_t color;
638 
639 	// fading fields
640 	int fade_time;
641 	float fade_target;
642 }
643 drawtip_t;
644 
645 extern drawtip_t tip_slots[MAXTIPSLOT];
646 
647 #endif /*__RAD_MAIN_H__*/
648 
649 //--- editor settings ---
650 // vi:ts=4:sw=4:noexpandtab
651