1 /*
2  *
3  *   Copyright (c) 1994, 2002, 2003  Johannes Prix
4  *   Copyright (c) 1994, 2002, 2003  Reinhard Prix
5  *
6  *
7  *  This file is part of Freedroid
8  *
9  *  Freedroid is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  Freedroid 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.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with Freedroid; see the file COPYING. If not, write to the
21  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  *  MA  02111-1307  USA
23  *
24  */
25 
26 /*----------------------------------------------------------------------
27  *
28  * Desc: all the define-constants and macros
29  *
30  *----------------------------------------------------------------------*/
31 
32 #ifndef _defs_h
33 #define _defs_h
34 
35 #define MAX_THEMES  100
36 
37 #define JOY_MAX_VAL 32767     // maximal amplitude of joystick axis values
38 
39 #define RESET 0x01
40 #define UPDATE 0x02
41 #define INIT_ONLY 0x04
42 
43 #define DROID_ROTATION_TIME 3.0
44 #define NUM_DECAL_PICS    2
45 
46 #define UserCenter_x (User_Rect.x + User_Rect.w/2)
47 #define UserCenter_y (User_Rect.y + User_Rect.h/2)
48 
49 #define ScaleRect(rect,scale) do {\
50 (rect).x *= scale; (rect).y *= scale; (rect).w *= scale; (rect).h *= scale; } while(0)
51 
52 #define ScalePoint(point,scale) do {\
53 (point).x *= scale; (point).y *= scale; } while(0)
54 
55 #define Set_Rect(rect, xx, yy, ww, hh) do {\
56 (rect).x = (xx); (rect).y = (yy); (rect).w = (ww); (rect).h = (hh); } while(0)
57 
58 #define Copy_Rect(src, dst) do {\
59 (dst).x = (src).x; (dst).y = (src).y; (dst).w = (src).w; (dst).h = (src).h; } while(0)
60 
61 #define FreeIfUsed(pt) do { if ((pt)) SDL_FreeSurface((pt)); } while(0)
62 
63 #define EnterPressed() KeyIsPressed(SDLK_RETURN)
64 
65 #define ShiftPressed() ModIsPressed(KMOD_SHIFT)
66 #define AltPressed() ModIsPressed(KMOD_ALT)
67 #define CtrlPressed() ModIsPressed(KMOD_CTRL)
68 
69 #define UpPressed() (KeyIsPressed(SDLK_UP)||KeyIsPressed('w'))
70 #define DownPressed() (KeyIsPressed(SDLK_DOWN)||KeyIsPressed('s'))
71 #define LeftPressed() (KeyIsPressed(SDLK_LEFT)||KeyIsPressed('a'))
72 #define RightPressed() (KeyIsPressed(SDLK_RIGHT)||KeyIsPressed('d'))
73 
74 #define EscapePressed() KeyIsPressed(SDLK_ESCAPE)
75 #define SpacePressed() KeyIsPressed(SDLK_SPACE)
76 #define FirePressed() (SpacePressed()||MouseLeftPressed())
77 
78 #define EscapePressedR() KeyIsPressedR (SDLK_ESCAPE)
79 #define SpacePressedR() KeyIsPressedR (SDLK_SPACE)
80 #define FirePressedR() (SpacePressedR()||MouseLeftPressedR())
81 
82 #define UpPressedR() (KeyIsPressedR(SDLK_UP)||KeyIsPressedR('w'))
83 #define DownPressedR() (KeyIsPressedR(SDLK_DOWN)||KeyIsPressedR('s'))
84 #define LeftPressedR() (KeyIsPressedR(SDLK_LEFT)||KeyIsPressedR('a'))
85 #define RightPressedR() (KeyIsPressedR(SDLK_RIGHT)||KeyIsPressedR('d'))
86 
87 #define Wait4Fire() do {while(1) {if(FirePressedR()||EscapePressedR()) break; else SDL_Delay(50);}; } while(0)
88 
89 #define COLLISION_STEPSIZE   0.1
90 
91 /* ************************************************************
92  * Highscore related defines
93  *************************************************************/
94 #define HS_BACKGROUND_FILE     "transfer.jpg"
95 #define HS_EMPTY_ENTRY  "--- empty ---"
96 #define MAX_NAME_LEN 	15     /* max len of highscore name entry */
97 #define MAX_HIGHSCORES  10     /* only keep Top10 */
98 #define DATE_LEN	10     /* reserved for the date-string */
99 //***************************************************************
100 
101 // find_file(): use current-theme subdir in search or not
102 enum _themed {
103   NO_THEME= 0,
104   USE_THEME
105 };
106 // find_file(): how important is the file in question:
107 enum _criticality {
108   IGNORE = 0,    // ignore if not found and return NULL
109   WARNONLY,      // warn if not found and return NULL
110   CRITICAL       // Error-message and Terminate
111 };
112 
113 // The flags for DisplayBanner are:
114 enum
115   { BANNER_FORCE_UPDATE=1 , BANNER_DONT_TOUCH_TEXT=2 , BANNER_NO_SDL_UPDATE=4 };
116 
117 // The flags for AssembleCombatWindow are:
118 enum
119 { ONLY_SHOW_MAP = 0x01 , DO_SCREEN_UPDATE = 0x02 , SHOW_FULL_MAP = 0x04};
120 
121 // symbolic Alert-names
122 enum _alertnames {
123   AL_GREEN = 0,
124   AL_YELLOW,
125   AL_AMBER,
126   AL_RED,
127   AL_LAST
128 };
129 
130 
131 
132 // **********************************************************************
133 // Constants for Paths and names of Data-files
134 // the root "FD_DATADIR" should be defined in the Makefile as $(pkgdatadir)
135 // if not, we set it here:
136 #ifndef FD_DATADIR
137 #ifdef __MACOSX__
138 #define FD_DATADIR "FreeDroid.app/Contents/Resources"  // our local fallback
139 #else
140 #define FD_DATADIR "."   // our local fallback
141 #endif
142 
143 #endif
144 
145 #define GRAPHICS_DIR		"graphics/"
146 #define SOUND_DIR		"sound/"
147 #define MAP_DIR			"map/"
148 
149 #define MAP_BLOCK_FILE          "map_blocks.png"
150 #define DROID_BLOCK_FILE	"droids.png"
151 #define BULLET_BLOCK_FILE 	"bullet.png"
152 #define BLAST_BLOCK_FILE 	"blast.png"
153 #define DIGIT_BLOCK_FILE        "digits.png"
154 
155 
156 #define BANNER_BLOCK_FILE       "banner.png"
157 #define TITLE_PIC_FILE          "title.jpg"
158 #define CONSOLE_PIC_FILE        "console_fg.png"
159 #define CONSOLE_BG_PIC1_FILE    "console_bg1.jpg"
160 #define CONSOLE_BG_PIC2_FILE    "console_bg2.jpg"
161 #define TAKEOVER_BG_PIC_FILE    "takeover_bg.jpg"
162 #define CREDITS_PIC_FILE        "credits.jpg"
163 
164 #define SHIP_ON_PIC_FILE        "ship_on.png"
165 #define SHIP_OFF_PIC_FILE       "ship_off.png"
166 
167 #define STANDARD_MISSION        "Paradroid.mission"
168 #define NEW_MISSION             "CleanPrivateGoodsStorageCellar.mission"
169 
170 #define PARA_FONT_FILE 		"parafont.png"
171 
172 #define FPS_FONT_FILE 		"font05.png"
173 #define ICON_FILE		"paraicon.bmp"
174 
175 
176 // **********************************************************************
177 
178 #define DIGITNUMBER 10
179 
180 #define TEXT_STRETCH 1.2
181 #define LEFT_TEXT_LEN 10
182 #define RIGHT_TEXT_LEN 6
183 
184 
185 #define BULLET_BULLET_COLLISION_DIST (10.0/64.0)
186 #define BULLET_COLL_DIST2     0.0244140625
187 // **********************************************************************
188 //
189 //
190 
191 // The following is the definition of the sound file names used in freedroid
192 // DO NOT EVER CHANGE THE ORDER OF APPEARENCE IN THIS LIST PLEASE!!!!!
193 // The order of appearance here should match the order of appearance
194 // in the SoundSampleFilenames definition located in sound.c!
195 enum _sounds
196 {
197   ERRORSOUND = 0,
198   BLASTSOUND,
199   COLLISIONSOUND,
200   GOT_INTO_BLAST_SOUND,
201   MOVE_ELEVATOR_SOUND,
202   REFRESH_SOUND,
203   LEAVE_ELEVATOR_SOUND,
204   ENTER_ELEVATOR_SOUND,
205   THOU_ART_DEFEATED_SOUND,
206   GOT_HIT_SOUND,
207   TAKEOVER_SET_CAPSULE_SOUND,
208   MENU_ITEM_SELECTED_SOUND,
209   MOVE_MENU_POSITION_SOUND,
210   TAKEOVER_GAME_WON_SOUND,
211   TAKEOVER_GAME_DEADLOCK_SOUND,
212   TAKEOVER_GAME_LOST_SOUND,
213   FIRE_BULLET_PULSE_SOUND,
214   FIRE_BULLET_SINGLE_PULSE_SOUND,
215   FIRE_BULLET_MILITARY_SOUND,
216   FIRE_BULLET_FLASH_SOUND,
217   FIRE_BULLET_EXTERMINATOR_SOUND,
218   FIRE_BULLET_LASER_RIFLE_SOUND,
219   CRY_SOUND,
220   TRANSFER_SOUND,
221   COUNTDOWN_SOUND,
222   ENDCOUNTDOWN_SOUND,
223   INFLUEXPLOSION_SOUND,
224   WHITE_NOISE,
225   ALERT_SOUND,
226   ALL_SOUNDS   // marks the last entry always!
227 };
228 
229 
230 // choose background music by level-color:
231 // if filename_raw==BYCOLOR then chose bg_music[color]
232 #define BYCOLOR "BYCOLOR"
233 
234 // The sounds when the influencers energy is low or when he is in transfer mode
235 // occur periodically.  These constants specify which intervals are to be used
236 // for these periodic happenings...
237 #define CRY_SOUND_INTERVAL 2
238 #define TRANSFER_SOUND_INTERVAL 1.1
239 
240 
241 // **********************************************************************
242 
243 #define TRUE (1==1)
244 #define FALSE (1==0)
245 
246 #define ERR 	-1
247 #define OK		0
248 
249 /* Ship-Elevator Picture */
250 
251 #define DIRECTIONS 		8
252 
253 #define ALLSHIPS 		4
254 #define ENEMYPHASES 		8
255 #define DROID_PHASES            ENEMYPHASES
256 
257 #define WAIT_LEVELEMPTY		1.0  /* warte bevor Graufaerben (in seconds)*/
258 #define WAIT_AFTER_KILLED	2000 // time (in ms) to wait and still display pictures after the destruction of
259 #define SHOW_WAIT           3500   // std amount of time to show something
260                                    // the players droid.  This is now measured in seconds and can be a float
261 #define WAIT_SHIPEMPTY		20
262 #define WAIT_TRANSFERMODE	0.3   /* this is a "float" indicating the number of seconds the influence
263 					 stand still with space pressed, before switching into transfermode
264 					 This variable describes the amount in SECONDS */
265 #define WAIT_COLLISION		1 // after a little collision with influ, enemys hold position for a while
266                                   // this variable describes the amount of time in SECONDS
267 #define ENEMYMAXWAIT 2.0		  // after each robot has reached its current destination waypoint is waits a
268                                   // while.  This variable describes the amount of time in SECONDS.  However,
269                                   // the final wait time is a random number within [0,ENEMYMAXWAIT].
270 #define FLASH_DURATION           0.1   // in seconds
271 
272 /* direction definitions (fireing bullets and testing blockedness of positions) */
273 enum _directions
274 {
275   OBEN = 0,
276   RECHTSOBEN,
277   RECHTS,
278   RECHTSUNTEN,
279   UNTEN,
280   LINKSUNTEN,
281   LINKS,
282   LINKSOBEN,
283   CENTER,
284   LIGHT				/* special: checking passability for light, not for a checkpos */
285 };
286 
287 
288 /* Maximal number of ... */
289 
290 #define NUM_MAP_BLOCKS		51  // total number of map-blocks
291 #define NUM_COLORS              7   // how many different level colorings?/different tilesets?
292 
293 // #define ALLBULLETTYPES		4	/* number of bullet-types */
294 #define ALLBLASTTYPES		2	/* number of different exposions */
295 
296 #define MAXBULLETS		100	/* maximum possible Bullets in the air */
297 #define MAXBLASTS		100	/* max. possible Blasts visible */
298 #define AGGRESSIONMAX  		100
299 #define ROBOT_MAX_WAIT_BETWEEN_SHOTS 5  // how long shoud each droid wait at most until
300                                         // is considers fireing again?
301 
302 /* Map-related defines:
303 	WARNING leave them here, they are required in struct.h
304 */
305 #define MAX_WP_CONNECTIONS 	12
306 #define MAXMAPLINES 		50
307 #define MAX_ENEMYS_ON_SHIP	300
308 #define MAX_CHAT_KEYWORDS_PER_DROID 30
309 #define MAX_INFLU_POSITION_HISTORY 100
310 
311 #define MAX_LIFTS	 	50  	/* actually the entries to the lifts */
312 #define MAX_LEVELS		29   	/* don't change this easily */
313 				     	/* corresponds to a reserved palette range ! */
314 #define MAX_LIFT_ROWS		15   	/* the different lift "rows" */
315 					/* don't change this easily */
316 					/* corresponds to a reserved palette range !*/
317 #define MAX_LEVEL_RECTS         20   // how many rects compose a level
318 #define MAX_EVENT_TRIGGERS      20   // how many event triggers at most to allow
319 #define MAX_TRIGGERED_ACTIONS   20   // how many triggerable actions to allow at most
320 
321 
322 #define MAXWAYPOINTS 		100
323 #define MAX_DOORS_ON_LEVEL 	60
324 #define MAX_REFRESHES_ON_LEVEL	40
325 #define MAX_ALERTS_ON_LEVEL	40
326 #define MAX_TELEPORTERS_ON_LEVEL	10
327 
328 #define MAX_PHASES_IN_A_BULLET 12
329 #define MAX_STEPS_IN_GIVEN_COURSE 1000
330 
331 #define BREMSDREHUNG 3		/* warte 3*, bevor Influencer weitergedreht wird */
332 
333 /* Wegstossgeschw. von Tueren u.ae. */
334 // NORMALISATION #define PUSHSPEED 2
335 #define PUSHSPEED 2
336 
337 /* Schusstypen */
338 enum _bullets
339 {
340   PULSE=0,
341   SINGLE_PULSE,
342   MILITARY,
343   FLASH,
344   EXTERMINATOR,
345   LASER_RIFLE
346 };
347 
348 
349 /* Explosionstypen */
350 enum _explosions
351 {
352   BULLETBLAST=0,
353   DRUIDBLAST,
354   REJECTBLAST
355 };
356 
357 #define BLINKENERGY 25
358 
359 /* Druidtypen */
360 enum _druids
361 {
362   DRUID001 = 0,			/* You will know why are the numbers there, when you */
363   DRUID123 = 1,			/* enter the crew of a level !! */
364   DRUID139 = 2,
365   DRUID247 = 3,
366   DRUID249 = 4,
367   DRUID296 = 5,
368   DRUID302 = 6,
369   DRUID329 = 7,
370   DRUID420 = 8,
371   DRUID476 = 9,
372   DRUID493 = 10,
373   DRUID516 = 11,
374   DRUID571 = 12,
375   DRUID598 = 13,
376   DRUID614 = 14,
377   DRUID615 = 15,
378   DRUID629 = 16,
379   DRUID711 = 17,
380   DRUID742 = 18,
381   DRUID751 = 19,
382   DRUID821 = 20,
383   DRUID834 = 21,
384   DRUID883 = 22,
385   DRUID999 = 23,
386   NUM_DROIDS
387 };
388 
389 /* Status- Werte der Druids */
390 enum _status
391 {
392   MOBILE,
393   TRANSFERMODE,
394   WEAPON,
395   CAPTURED,
396   COMPLETE,
397   REJECTED,
398   CONSOLE,
399   DEBRIEFING,
400   TERMINATED,
401   PAUSE,
402   CHEESE,
403   ELEVATOR,
404   BRIEFING,
405   MENU,
406   VICTORY,
407   ACTIVATE,
408   OUT
409 };
410 
411 #define DECKCOMPLETEBONUS 500
412 
413 /* Konstanten die die Kartenwerte anschaulich machen */
414 enum
415 {
416   FLOOR = 0,
417   ECK_LU = 1,   T_U,          ECK_RU,       T_L,          KREUZ,       T_R,    ECK_LO,  T_O,    ECK_RO,
418   H_WALL =10,   V_WALL,       INVISIBLE,      BLOCK1,       BLOCK2,      BLOCK3, BLOCK4,  BLOCK5,
419   H_ZUTUERE=18, H_HALBTUERE1, H_HALBTUERE2, H_HALBTUERE3, H_GANZTUERE,
420   KONSOLE_L=23, KONSOLE_R,    KONSOLE_O,    KONSOLE_U,
421   V_ZUTUERE=27, V_HALBTUERE1, V_HALBTUERE2, V_HALBTUERE3, V_GANZTUERE,
422   LIFT = 32,    VOID = 33,
423   REFRESH1=34,  REFRESH2,     REFRESH3,    REFRESH4,
424   ALERT_GREEN=38, ALERT_YELLOW, ALERT_AMBER, ALERT_RED,
425   UNUSED2 = 42,   FINE_GRID,
426   NUM_MAP_TILES
427 };
428 
429 
430 #endif
431