2 * OpenBOR - http://www.LavaLit.com
4 ----------------------------------------------------------------------
5 * Licensed under the BSD license, see LICENSE in OpenBOR root for details.
7 * Copyright (c) 2004 - 2011 OpenBOR Team
10 /////////////////////////////////////////////////////////////////////////////
12 // Side-scrolling beat-'em-up //
13 /////////////////////////////////////////////////////////////////////////////
19 /////////////////////////////////////////////////////////////////////////////
40 #include "openborscript.h"
48 /////////////////////////////////////////////////////////////////////////////
50 // FIXME wow. this needs to be fixed. does rename every occurence of those variables/functions.
54 #define pause borPause
55 #define shutdown(ec, fmt, args...) borShutdown(__FUNCTION__, ec, fmt, ## args)
57 #define COMPATIBLEVERSION 0x00030000
58 #define CV_SAVED_GAME 0x00021276
59 #define CV_HIGH_SCORE 0x00020048
60 #define GAME_SPEED 200
62 #define COUNTER_SPEED (GAME_SPEED*2)
65 #define MAX_WEAPONS 10
66 #define MAX_COLOUR_MAPS 30
67 #define MAX_NAME_LEN 40
68 #define LEVEL_MAX_SPAWNS 600
69 #define LEVEL_MAX_PANELS 100
70 #define LEVEL_MAX_HOLES 40
71 #define LEVEL_MAX_WALLS 40
72 #define LEVEL_MAX_BGLAYERS 100
73 #define LEVEL_MAX_FGLAYERS 10
74 #define LEVEL_MAX_TEXTOBJS 50
75 #define LEVEL_MAX_FILESTREAMS 50
76 #define LEVEL_MAX_PALETTES 40 // altered palettes
77 #define MAX_LEVELS 100
78 #define MAX_DIFFICULTIES 10
79 #define MAX_SPECIALS 8 // Added for customizable freespecials
80 #define MAX_SPECIAL_INPUTS 27 // max freespecial input steps, MAX_SPECIAL_INPUTS-1 is reserved, MAX_SPECIAL_INPUTS-2 is animation index, MAX_SPECIAL_INPUTS-3 is reserved. OX -4 , -5 , -6 , -7 , -8 , -9 , -10 also for cancels
81 #define MAX_ATCHAIN 12 // Maximum attack chain length
82 #define MAX_IDLES 1 // Idle animations.
83 #define MAX_WALKS 1 // Walk animations.
84 #define MAX_BACKWALKS 1 // Backwalk animations.
85 #define MAX_UPS 1 // Walk up animations.
86 #define MAX_DOWNS 1 // Walk down animations.
87 #define MAX_ATTACKS 4 // Total number of attacks players have
88 #define MAX_FOLLOWS 4 // For followup animations
90 #define MAX_ARG_LEN 512
91 #define MAX_PAL_SIZE 1024
92 #define MAX_CACHED_BACKGROUNDS 9
94 #define FLAG_ESC 0x00000001
95 #define FLAG_START 0x00000002
96 #define FLAG_MOVELEFT 0x00000004
97 #define FLAG_MOVERIGHT 0x00000008
98 #define FLAG_MOVEUP 0x00000010
99 #define FLAG_MOVEDOWN 0x00000020
100 #define FLAG_ATTACK 0x00000040
101 #define FLAG_JUMP 0x00000080
102 #define FLAG_SPECIAL 0x00000100
103 #define FLAG_SCREENSHOT 0x00000200
104 #define FLAG_ATTACK2 0x00000400
105 #define FLAG_ATTACK3 0x00000800
106 #define FLAG_ATTACK4 0x00001000
107 #define FLAG_ANYBUTTON (FLAG_START|FLAG_SPECIAL|FLAG_ATTACK|FLAG_ATTACK2|FLAG_ATTACK3|FLAG_ATTACK4|FLAG_JUMP)
108 #define FLAG_FORWARD 0
109 #define FLAG_BACKWARD 1
111 #define SDID_MOVEUP 0
112 #define SDID_MOVEDOWN 1
113 #define SDID_MOVELEFT 2
114 #define SDID_MOVERIGHT 3
115 #define SDID_ATTACK 4
116 #define SDID_ATTACK2 5
117 #define SDID_ATTACK3 6
118 #define SDID_ATTACK4 7
120 #define SDID_SPECIAL 9
121 #define SDID_START 10
122 #define SDID_SCREENSHOT 11
125 #define TYPE_PLAYER 1
128 #define TYPE_OBSTACLE 8
129 #define TYPE_STEAMER 16
130 #define TYPE_SHOT 32 // 7-1-2005 type to use for player projectiles
131 #define TYPE_TRAP 64 // 7-1-2005 lets face it enemies are going to just let you storm in without setting a trap or two!
132 #define TYPE_TEXTBOX 128 // New textbox type for displaying messages
133 #define TYPE_ENDLEVEL 256 // New endlevel type that ends the level when touched
134 #define TYPE_NPC 512 // A character can be an ally or enemy.
135 #define TYPE_PANEL 1024 // Fake panel, scroll with screen using model speed
137 #define SUBTYPE_NONE 0
138 #define SUBTYPE_BIKER 1
139 #define SUBTYPE_NOTGRAB 2 //7-1-2005 new subtype for those ungrabbable enemies
140 #define SUBTYPE_ARROW 3 //7-1-2005 subtype for an "enemy" that flies across the screen and dies
141 #define SUBTYPE_TOUCH 4 // ltb 1-18-05 new Item subtype for a more platformer feel.
142 #define SUBTYPE_WEAPON 5
143 #define SUBTYPE_NOSKIP 6 // Text type that can't be skipped
144 #define SUBTYPE_FLYDIE 7 // Now obstacles can be hit and fly like on Simpsons/TMNT
145 #define SUBTYPE_BOTH 8 // Used with TYPE_ENDLEVEL to force both players to reach the point before ending level
146 #define SUBTYPE_PROJECTILE 9 // New weapon projectile type that can be picked up by players/enemies
147 #define SUBTYPE_FOLLOW 10 // Used by NPC character, if set, they will try to follow players
148 #define SUBTYPE_CHASE 11 // Used by enemy always chasing you
150 //------------reserved for A.I. types-------------------------
151 // A.I. move1, affect movement path
152 #define AIMOVE1_NORMAL 0 // Current default style
153 #define AIMOVE1_CHASE 0x00000001 // alway move towards target, and can run to them if target is farway
154 #define AIMOVE1_CHASEZ 0x00000002 // only try to get close in z direction
155 #define AIMOVE1_CHASEX 0x00000004 // only try to get colse in x direction
156 #define AIMOVE1_AVOID 0x00000008 // try to avoid target
157 #define AIMOVE1_AVOIDZ 0x00000010 // only try to avoid target in z direction
158 #define AIMOVE1_AVOIDX 0x00000020 // only try to avoid target in x direction
159 #define AIMOVE1_WANDER 0x00000040 // ignore the target's position completely, wander everywhere, long idle time
160 #define AIMOVE1_BIKER 0x00000080 // move like a biker
161 #define AIMOVE1_ARROW 0x00000100 // fly like an arrow
162 #define AIMOVE1_STAR 0x00000200 // fly like a star, subject to ground
163 #define AIMOVE1_BOMB 0x00000400 // fly like a bomb, subject to ground/wall etc
164 #define AIMOVE1_NOMOVE 0x00000800 // don't move at all
165 #define AIMOVE1_BOOMRANG 0x00001000 // boomrang
166 #define MASK_AIMOVE1 0x0000FFFF
168 // A.I move2, affect terrain reflect
169 #define AIMOVE2_NORMAL 0 // Current default style
170 #define AIMOVE2_IGNOREHOLES 0x00010000 // don't avoid holes
171 #define MASK_AIMOVE2 0xFFFF0000
173 // A.I. attack1, affect attacking style
174 #define AIATTACK1_NORMAL 0 // Current default style
175 #define AIATTACK1_LONG 0x00000001 // Long range first
176 #define AIATTACK1_MELEE 0x00000002 // Melee attack first
177 #define AIATTACK1_NOATTACK 0x00000004 // dont attack at all
178 #define MASK_AIATTACK1 0x0000FFFF
180 // A.I. attack2, affect Defending style
181 #define AIATTACK2_NORMAL 0 // Current default style, don't dodge at all
182 #define AIATTACK2_DODGE 0x00010000 // Use dodge animation to avoid attack
183 #define AIATTACK2_DODGEMOVE 0x00020000 // Try to move in z direction if a jump attack is about to hit him
184 // and try to step back if a melee attack is about to hit him
185 #define MASK_AIATTACK2 0xFFFF0000
192 } s_player_min_max_z_bgheight
;
194 extern s_player_min_max_z_bgheight player_min_max_z_bgheight
;
195 #define PLAYER_MIN_Z (player_min_max_z_bgheight.player_min_z)
196 #define PLAYER_MAX_Z (player_min_max_z_bgheight.player_max_z)
197 #define BGHEIGHT (player_min_max_z_bgheight.bgheight)
199 // Note: the minimum Z coordinate of the player is important
200 // for several other drawing operations.
201 // movement restirctions are here!
202 //int PLAYER_MIN_Z = 160; // 2-10-05 adjustable walking area
203 //int PLAYER_MAX_Z = 232; // 2-10-05 adjustable walking area
204 //int BGHEIGHT = 160; // 2-10-05 adjustable BGHeight
205 //int MAX_WALL_HEIGHT = 1000; // max wall height that an entity can be spawned on
206 #define FRONTPANEL_Z (PLAYER_MAX_Z+50)
207 #define HUD_Z (FRONTPANEL_Z+10000)
208 #define HOLE_Z (PLAYER_MIN_Z-46)
209 #define NEONPANEL_Z (PLAYER_MIN_Z-47)
210 #define SHADOW_Z (PLAYER_MIN_Z-48)
211 #define SCREENPANEL_Z (PLAYER_MIN_Z-49)
212 #define PANEL_Z (PLAYER_MIN_Z-50)
213 #define MIRROR_Z (PLAYER_MIN_Z-5)
214 #define PIT_DEPTH -250
215 #define P2_STATS_DIST 180
216 #define CONTACT_DIST_H 30 // Distance to make contact
217 #define CONTACT_DIST_V 12
218 #define GRAB_DIST 36 // Grabbing ents will be placed this far apart.
219 #define GRAB_STALL (GAME_SPEED * 8 / 10)
230 ATK_STEAL
, // Steal opponents life
241 #define STA_ATKS 6 // default special attack types: blast burn shock freeze steal
242 #define MAX_DOTS 10 // Max active dot effects.
244 #define SCROLL_RIGHT 2
245 #define SCROLL_DOWN 4
246 #define SCROLL_LEFT 8
248 #define SCROLL_BACK 1
249 #define SCROLL_BOTH (SCROLL_BACK|SCROLL_RIGHT)
250 #define SCROLL_RIGHTLEFT SCROLL_BOTH
251 #define SCROLL_LEFTRIGHT (SCROLL_LEFT|SCROLL_BACK)
252 #define SCROLL_INWARD 32
253 #define SCROLL_OUTWARD 64
254 #define SCROLL_OUTIN (SCROLL_OUTWARD|SCROLL_BACK)
255 #define SCROLL_INOUT (SCROLL_INWARD|SCROLL_BACK)
256 #define SCROLL_UPWARD 128
257 #define SCROLL_DOWNWARD 256
266 ANI_ATTACK1
= ANI_ATTACK
,
269 ANI_ATTACK4
, // Very important
271 ANI_BLOCK
, // New block animation
273 ANI_JUMPATTACK1
= ANI_JUMPATTACK
,
279 ANI_GRABATTACK1
= ANI_GRABATTACK
,
283 ANI_SPECIAL1
= ANI_SPECIAL
,
284 ANI_SPECIAL2
, // Animation played for when pressing forward special
285 ANI_SPECIAL3
, // special3 is an alias for jumpspecial
286 ANI_JUMPSPECIAL
= ANI_SPECIAL3
,
288 ANI_FREESPECIAL1
= ANI_FREESPECIAL
,
291 ANI_FREESPECIAL4
, // More freespecials added
292 ANI_FREESPECIAL5
, // More freespecials added
293 ANI_FREESPECIAL6
, // More freespecials added
294 ANI_FREESPECIAL7
, // More freespecials added
295 ANI_FREESPECIAL8
, // More freespecials added
296 ANI_SPAWN
, // 26-12-2004 new animation added here ani_spawn
297 ANI_PICK
, // 7-1-2005 used when players select their character at the select screen
298 ANI_UP
, // Mar 2, 2005 - Animation for when going up
299 ANI_DOWN
, // Mar 2, 2005 - Animation for when going down
300 ANI_SHOCK
, // Animation played when knocked down by shock attack
301 ANI_BURN
, // Animation played when knocked down by burn attack
302 ANI_SHOCKPAIN
, // Animation played when not knocked down by shock attack
303 ANI_BURNPAIN
, // Animation played when not knocked down by shock attack
304 ANI_GRABBED
, // Animation played when grabbed
305 ANI_RUN
, // Animation played when a player is running
306 ANI_RUNATTACK
, // Animation played when a player is running and presses attack
307 ANI_RUNJUMPATTACK
, // Animation played when a player is running and jumps and presses attack
308 ANI_ATTACKUP
, // u u animation
309 ANI_ATTACKDOWN
, // d d animation
310 ANI_ATTACKFORWARD
, // f f animation
311 ANI_ATTACKBACKWARD
, // Used for attacking backwards
312 ANI_DODGE
, // Used for up up / down down SOR3 dodge moves for players
313 ANI_ATTACKBOTH
, // Used for when a player holds down attack and presses jump
314 ANI_GRABFORWARD
, // New grab attack for when a player holds down forward/attack
315 ANI_GRABFORWARD2
, // New second grab attack for when a player holds down forward/attack
316 ANI_JUMPFORWARD
, // Attack when a player is moving and jumps
317 ANI_GRABDOWN
, // Attack when a player has grabbed an opponent and presses down/attack
318 ANI_GRABDOWN2
, // Attack when a player has grabbed an opponent and presses down/attack
319 ANI_GRABUP
, // Attack when a player has grabbed an opponent and presses up/attack
320 ANI_GRABUP2
, // Attack when a player has grabbed an opponent and presses up/attack
321 ANI_SELECT
, // Animation that is displayed at the select screen
322 ANI_DUCK
, // Animation that is played when pressing down in "platform" type levels
323 ANI_FAINT
, // Faint animations for players/enemys by tails
324 ANI_CANT
, // Can't animation for players(animation when mp is less than mpcost) by tails.
325 ANI_THROWATTACK
, // Added for subtype projectile
326 ANI_CHARGEATTACK
, // Plays when player releases attack1 after holding >= chargetime.
327 ANI_VAULT
, // Now you can flip over people like in SOR.
331 ANI_PAIN
, //the pain anims must be in a sequence as they're used to calculate offsets in lcmHandleCommandAnim()
332 ANI_PAIN1
= ANI_PAIN
,
343 ANI_FALL1
= ANI_FALL
,
353 ANI_DIE
, // 29-12-2004 new animation added here ani_die
368 ANI_FOLLOW1
= ANI_FOLLOW
,
372 ANI_TURN
, // turn back/flip
373 ANI_RESPAWN
, //now spawn works for players
380 ANI_GRABBACKWARD1
= ANI_GRABBACKWARD
,
392 ANI_SLIDE
, //Down + Jump animation.
393 ANI_RUNSLIDE
, //Down + Jump while running.
396 ANI_RISE1
= ANI_RISE
,
408 ANI_BLOCKPAIN
, //If entity has this, it will play in place of "pain" when its blockpain is 1 and incoming attack is blocked.
409 ANI_BLOCKPAIN1
= ANI_BLOCKPAIN
,
423 ANI_RISEATTACK
, // Attack used for enemies when players are crowding around after knocking them down
424 ANI_RISEATTACK1
= ANI_RISEATTACK
,
443 // perhaps outdated, now use separted flags for entity
444 #define SUBJECT_TO_WALL 1
445 #define SUBJECT_TO_HOLE 2
446 #define SUBJECT_TO_OBSTACLE 4
447 #define SUBJECT_TO_BORDER 8
448 #define SUBJECT_TO_SCREEN 16
449 #define SUBJECT_TO_MINZ 32
450 #define SUBJECT_TO_MAXZ 48
452 //macros for drawing menu text, fits different font size
455 #define _strmidx(f,s, ...) ((videomodes.hRes-font_string_width((f), s, __VA_ARGS__))/2)
457 #define _strmidx(f,s, args...) ((videomodes.hRes-font_string_width((f), s, ##args))/2)
459 #define _colx(f,c) ((int)(videomodes.hRes/2+(c)*(font_monowidths[(f)]+1)))
460 #define _liney(f,l) ((int)(videomodes.vRes/2+(l)*(font_heights[(f)]+1)))
462 #define _menutextm(f, l, shift, s, ...) font_printf(_strmidx(f,s, __VA_ARGS__)+(int)((shift)*(font_monowidths[(f)]+1)), _liney(f,l), (f), 0, s, __VA_ARGS__)
463 #define _menutext(f, c, l, s, ...) font_printf(_colx(f,c), _liney(f,l), (f), 0, s, __VA_ARGS__)
465 #define _menutextm(f, l, shift, s, args...) font_printf(_strmidx(f,s, ##args)+(int)((shift)*(font_monowidths[(f)]+1)), _liney(f,l), (f), 0, s, ##args)
466 #define _menutext(f, c, l, s, args...) font_printf(_colx(f,c), _liney(f,l), (f), 0, s, ##args)
474 #define ICO_WEAPON 4*/
477 #define MODEL_NO_COPY 0x00000001 //dont copy anything from original model
478 #define MODEL_NO_WEAPON_COPY 0x00000002 //dont copy weapon list from original model
480 #define lut_mul ((level && current_palette)?(level->blendings[current_palette-1][BLEND_MULTIPLY]):(blendings[BLEND_MULTIPLY]))
481 #define lut_screen ((level && current_palette)?(level->blendings[current_palette-1][BLEND_SCREEN]):(blendings[BLEND_SCREEN]))
482 #define lut_overlay ((level && current_palette)?(level->blendings[current_palette-1][BLEND_OVERLAY]):(blendings[BLEND_OVERLAY]))
483 #define lut_hl ((level && current_palette)?(level->blendings[current_palette-1][BLEND_HARDLIGHT]):(blendings[BLEND_HARDLIGHT]))
484 #define lut_dodge ((level && current_palette)?(level->blendings[current_palette-1][BLEND_DODGE]):(blendings[BLEND_DODGE]))
485 #define lut_half ((level && current_palette)?(level->blendings[current_palette-1][BLEND_HALF]):(blendings[BLEND_HALF]))
486 #define lut ((level && current_palette)?(level->blendings[current_palette-1]):(blendings))
488 #define ABS(x) ((x)>0?(x):(-(x)))
490 #define set_attacking(e) e->attacking = 1;\
493 #define set_jumping(e) e->jumping = 1;\
496 #define set_charging(e) e->charging = 1;\
499 #define set_getting(e) e->getting = 1;\
502 #define set_blocking(e) e->blocking = 1;\
505 #define set_turning(e) e->turning = 1;\
508 #define is_frozen(e) ((textbox && e->modeldata.type != TYPE_TEXTBOX) || \
509 (smartbomber && e != smartbomber && e->modeldata.type != TYPE_TEXTBOX) ||(self->frozen&&self->freezetime > borTime))
511 #define expand_time(e) if(e->stalltime>0) e->stalltime++;\
512 if(e->releasetime>0)e->releasetime++;\
513 if(e->nextanim>0)e->nextanim++;\
514 if(e->nextthink>0)e->nextthink++;\
515 if(e->magictime>0)e->magictime++;\
516 if(e->guardtime>0)e->guardtime++;\
517 if(e->toss_time>0)e->toss_time++;\
518 if(e->freezetime>0 && (textbox || smartbomber))e->freezetime++;\
519 if(e->mpchargetime>0)e->mpchargetime++;\
520 if(e->invinctime>0) e->invinctime++;\
521 if(e->sealtime>0) e->sealtime++;
522 /* if(e->dot_time>0) e->dot_time++;\
523 if(e->dot_cnt>0) e->dot_cnt++;
526 #define freezeall (smartbomber || textbox)
528 #define is_projectile(e) (e->modeldata.type == TYPE_SHOT || e->model->subtype == SUBTYPE_ARROW || e->owner)
530 #define check_range(self, target, animnum) \
533 target->x > self->x+self->modeldata.animation[animnum]->range[0] &&\
534 target->x < self->x+self->modeldata.animation[animnum]->range[1]\
536 target->x < self->x-self->modeldata.animation[animnum]->range[0] &&\
537 target->x > self->x-self->modeldata.animation[animnum]->range[1])\
538 && target->z - self->z > self->modeldata.animation[animnum]->range[2] \
539 && target->z - self->z < self->modeldata.animation[animnum]->range[3] \
540 && (target->a - self->a) > self->modeldata.animation[animnum]->range[4] \
541 && (target->a - self->a) < self->modeldata.animation[animnum]->range[5] \
542 && (target->base - self->base) > self->modeldata.animation[animnum]->range[6] \
543 && (target->base - self->base) < self->modeldata.animation[animnum]->range[7] \
546 #define check_range_both(self, target, animnum) \
548 ((target->x > self->x+self->modeldata.animation[animnum]->range[0] &&\
549 target->x < self->x+self->modeldata.animation[animnum]->range[1])\
551 (target->x < self->x-self->modeldata.animation[animnum]->range[0] &&\
552 target->x > self->x-self->modeldata.animation[animnum]->range[1]))\
553 && target->z - self->z > self->modeldata.animation[animnum]->range[2] \
554 && target->z - self->z < self->modeldata.animation[animnum]->range[3] \
555 && (target->a - self->a) > self->modeldata.animation[animnum]->range[4] \
556 && (target->a - self->a) < self->modeldata.animation[animnum]->range[5] \
557 && (target->base - self->base) > self->modeldata.animation[animnum]->range[6] \
558 && (target->base - self->base) < self->modeldata.animation[animnum]->range[7] \
562 #define tobounce(e) (e->animation->bounce && diff(0, e->tossv) > 2 && \
563 !((autoland == 1 && e->damage_on_landing == -1) ||e->damage_on_landing == -2))
565 #define getpal ((current_palette&&level)?(level->palettes[current_palette-1]):pal)
567 #define canbegrabbed(self, other) \
568 (other->animation->vulnerable[other->animpos] && \
569 (!self->animation->move || self->animation->move[self->animpos] == 0) && \
570 (!self->animation->movez || self->animation->movez[self->animpos] == 0 ) && \
571 !(other->nograb || other->invincible || other->link || \
572 other->model->animal || inair(other) || \
573 (self->modeldata.type == TYPE_PLAYER && other->modeldata.type == TYPE_PLAYER && savedata.mode)))
575 #define cangrab(self, other) \
576 ((other->model->antigrab - self->model->grabforce + \
577 (other->model->paingrab?(other->model->paingrab-other->inpain):0)<=0) &&\
578 canbegrabbed(self, other) && \
580 diff(other->a, self->a) <= 0.1)
582 #define unfrozen(e) \
583 ent_set_colourmap(e, e->map);\
587 #define validanim(e, a) ((e)->modeldata.animation[a]&&(e)->modeldata.animation[a]->numframes)
589 //#define MAX_MOVES 16
590 //#define MAX_MOVE_STEPS 16
592 #define MENU_PACK_FILENAME "Menu.xxx"
597 unsigned int compatibleversion
;
600 char usesound
; // Use SB
601 unsigned short soundrate
; // SB freq
602 short soundvol
; // SB volume
603 char usemusic
; // Play music
604 short musicvol
; // Music volume
605 short effectvol
; // Sound fx volume
606 char soundbits
; // SB bits
608 char mode
; // Mode now saves
610 int keys
[MAX_PLAYERS
][12];
613 char screen
[7][2]; // Screen Filtering/Scaling Effects
616 char debuginfo
; // FPS, Memory, etc...
617 char fullscreen
; // Window or Full Screen Mode
618 char stretch
; // Stretch (1) or preserve aspect ratio (0) in fullscreen mode
619 char usegl
; // 1 if OpenGL is preferred over SDL software blitting
620 float glscale
; // Scale factor for OpenGL
621 char glfilter
; // Simple or bilinear scaling
625 unsigned int compatibleversion
:32;
626 char dName
[MAX_NAME_LEN
+ 1]; // Difficulty Name
627 unsigned short level
:16; // Level Number
628 unsigned short stage
:16; // Stage
629 unsigned char pLives
[MAX_PLAYERS
]; // Player Lives Left
630 unsigned char pCredits
[MAX_PLAYERS
]; // Player Credits Left
631 unsigned int pScores
[MAX_PLAYERS
]; // Player Scores
632 unsigned char credits
:8; // Number Of Credits
633 unsigned short times_completed
:16;
634 unsigned short which_set
:16;
635 //-------------------new strict save features-----------------------
636 char flag
:8; // 0 useless slot 1 only load level number 2 load player info and level
637 char pName
[MAX_PLAYERS
][MAX_NAME_LEN
+ 1]; // player names
638 int pSpawnhealth
[MAX_PLAYERS
]; // hit points left
639 int pSpawnmp
[MAX_PLAYERS
]; // magic points left
640 char pWeapnum
[MAX_PLAYERS
]; // weapon
641 char pColourmap
[MAX_PLAYERS
]; // colour map
646 unsigned int compatibleversion
:32;
647 unsigned int highsc
[10];
648 char hscoren
[10][MAX_NAME_LEN
+ 1];
653 float dropv
[3]; // fly height/x/z if the target is knoced down
654 float grab_distance
; // suck target near by
656 int staydown
[3]; // [0] = Add to rise delay. [1] = Add to rise attack delay.
661 int dot_index
; //Dot index.
662 int dot_time
; //Dot time to expire.
663 int dot_force
; //Dot amount per tick.
664 int dot_rate
; //Dot tick delay.
665 int hitsound
; // Sound effect to be played when attack hits opponent
666 int hitflash
; // Custom flash for each animation, model id
667 int blockflash
; // Custom bflash for each animation, model id
668 int blocksound
; // Custom sound for when an attack is blocked
671 short attack_coords
[5]; // stick on the only one victim
672 short jugglecost
; // cost for juggling a falling ent
673 short guardcost
; // cost for blocking an attack
674 short pause_add
; // Flag to determine if an attack adds a pause before updating the animation
676 signed char counterattack
;
678 signed char no_flash
; // Flag to determine if an attack spawns a flash or not
679 signed char no_block
; // Flag to determine if an attack is blockable (default 0 - blockable)
681 signed char force_direction
; // 0 dont care, 1 same direction as attacker, -1 opposite drection as attacker, 2 right, -2 left
685 signed char forcemap
;
687 signed char otg
; // Over The Ground. Gives ground projectiles the ability to hit lying ents.
688 signed char attack_drop
; // now be a knock-down factor, how many this attack will knock victim down
689 signed char attack_type
;
690 signed char damage_on_landing
; // same as throw damage type
697 int loop
[3]; // Animation loop (0 = loop on/off, 1 = Loop to frame, 2 = Loop end frame).
698 short height
:16; // entity's height during animation
699 short tossframe
:16; // Used to determine which frame will toss a bomb/grenade
702 short throwa
:16; // Used for setting the "a" at which weapons are spawned
703 // various entity model id, knife/star/bomb etc
706 int custbomb
; // Used for new projectile bomb
708 int subentity
; // Store the sub-entity's name for further use
709 char fastattack
:8; // Flag to determine if the opponent uses their pain time
710 short energycost
[3]; // 1-10-05 to adjust the amount of energy used for specials. 05072010: Made array with mponly. 0 = Energycost, 1 = MPonly, 2 = Disable flag (see check_energy function).
711 float chargetime
; // charge time for an animation
713 float jumpv
; // moveflag // So movement forward can be specified for jumpframes
714 float jumpx
; // override move forward value
715 float jumpz
; // override move z value
716 int jumpd
; // Index of dust entity to spawn on liftoff of jumpframe.
717 float bounce
; // -tossv/bounce = new tossv
718 float dive
[2]; // new dive kick by tails
719 int *soundtoplay
; // each frame can have a sound
720 int *sprite
; // sprite[set][framenumber]
725 short *seta
; // Now characters can have a custom "a" value
727 short (*bbox_coords
)[5];
729 unsigned char *idle
; // Allow free move
730 short (*shadow_coords
)[2]; // x, z offset of shadow
731 s_drawmethod
**drawmethods
;
734 float (*platform
)[8]; // Now entities can have others land on them
735 int range
[8]; // Use for attacks; xmin, xmax, zmin, zmax, amin, amax, basemin, basemax
736 short flipframe
:16; // Turns entities around on the desired frame
737 short followanim
:16; // use which FOLLOW anim?
738 char followcond
:8; // conditions under which to use a followup
739 short counterframe
[4]; // 0,1; Counter frame, 2 counter cond, 3 counterdam
740 char cancel
:8; // Cancel anims with freespecial
741 short *weaponframe
; // Specify with a frame when to switch to a weapon model
742 short quakeframe
[4]; // Specify with a frame, repeat, quake (4 is highest)
743 float *spawnframe
; // Spawn the subentity as its default type. {frame} {x} {z} {a} {relative?}
744 float *summonframe
; // Summon the subentity as an ally, only one though {frame} {x} {z} {a} {relative?}
745 short unsummonframe
:16; // Un-summon the entity
746 short landframe
[2]; // 0 frame switch to when land, 1 dust to spawn.
747 short dropframe
:16; // if tossv < 0, this frame will be set
748 short animhits
:16; // Does the attack need to hit before cancel is allowed?
762 struct animlist
*next
;
764 typedef struct animlist s_anim_list
;
765 extern s_anim_list
*anim_list
;
778 int (*colourtable
)[11]; //0 default backfill 1-10 foreground colours
789 char direction
:1; //0) left to right or botom to top 1) reversed
791 barorient orientation
:1;
797 LSTYPE_BACKGROUND
= 2,
801 loadingScreenType set
;
802 /*set determines how loading screen would be.
803 - 0 = no loading screen.
804 - 1 = background and status bar.
805 - 2 = background only.
806 - 3 = status bar only.
808 char tf
; //determines used font number for "LOADING" text (last element in command, moved here because of alignment)
814 short bx
; //determines x and y coordinates of loading bar top left's location respectively
816 short bsize
; // length of bar in pixels
817 short tx
; //determines x and y coordinates of "LOADING" text location respectively.
819 short refreshMs
; // modder defined number of milliseconds in which the screen is updated while loading
823 Script
*animation_script
; //system generated script
824 Script
*update_script
; //execute when update_ents
825 Script
*think_script
; //execute when entity thinks.
826 Script
*takedamage_script
; //execute when taking damage.
827 Script
*ondeath_script
; //execute when killed in game.
828 Script
*onkill_script
; //execute when removed from play.
829 Script
*onpain_script
; //Execute when put in pain animation.
830 Script
*onfall_script
; //execute when falling.
831 Script
*onblocks_script
; //execute when blocked by screen.
832 Script
*onblockw_script
; //execute when blocked by wall.
833 Script
*onblocko_script
; //execute when blocked by obstacle.
834 Script
*onblockz_script
; //execute when blocked by Z.
835 Script
*onblocka_script
; //execute when "hit head".
836 Script
*onmovex_script
; //execute when moving along X axis.
837 Script
*onmovez_script
; //execute when moving along Z axis.
838 Script
*onmovea_script
; //execute when moving along A axis.
839 Script
*didhit_script
; //execute when attack hits another.
840 Script
*onspawn_script
; //execute when spawned.
841 Script
*key_script
; //execute when entity's player presses a key
842 Script
*didblock_script
; //execute when blocking attack.
843 Script
*ondoattack_script
; //execute when attack passes do_attack checks.
848 Script level_script
; //execute when level start
849 Script endlevel_script
; //execute when level finished
850 Script update_script
; //execute when ingame update
851 Script updated_script
; //execute when ingame update finished
852 Script key_script_all
; //keyscript for all players
853 Script timetick_script
; //time tick script.
855 Script score_script
[4]; //execute when add score, 4 players
856 Script key_script
[4]; //key listeners, lol
857 Script join_script
[4]; //player join scripts
858 Script respawn_script
[4]; //player respawn scripts
859 Script pdie_script
[4]; //player death scripts
862 extern s_game_scripts game_scripts
;
874 MF_DEF_KNOCKDOWN
= 256,
875 MF_DEF_BLOCKPOWER
= 512,
876 MF_DEF_BLOCKTRESHOLD
= 1024,
877 MF_DEF_BLOCKRATIO
= 2048,
878 MF_DEF_BLOCKTYPE
= 4096,
879 MF_OFF_FACTORS
= 8192,
881 MF_SMARTBOMB
= 32768,
884 #define MF_ALL 0x1FFFF
887 int (*special
)[MAX_SPECIAL_INPUTS
]; // Stores freespecials
888 int (*weapon
)[MAX_WEAPONS
]; // weapon model list
890 unsigned char *palette
; // original palette for 32/16bit mode
891 unsigned char *colourmap
[MAX_COLOUR_MAPS
];
893 char *path
; // Path, so scripts can dynamically get files, sprites, sounds, etc.
894 char *branch
; //level branch name
895 float *defense_factors
; //basic defense factors: damage = damage*(1-def)
896 float *defense_pain
; //Pain factor (like nopain) for defense type.
897 float *defense_knockdown
; //Knockdowncount (like knockdowncount) for attack type.
898 float *defense_blockpower
; //If > unblockable, this attack type is blocked.
899 float *defense_blockthreshold
; //Strongest attack from this attack type that can be blocked.
900 float *defense_blockratio
; //% of damage still taken from this attack type when blocked.
901 float *defense_blocktype
; //0 = HP, 1=MP, 2=both taken when this attack type is blocked.
902 float *offense_factors
; //basic offense factors: damage = damage*(1+def)
907 int mp
; // mp's variable for mpbar by tails
908 int makeinv
; // Option to spawn player invincible >0 blink <0 noblink
909 int riseinv
; // how many seconds will the character become invincible after rise >0 blink, <0 noblink
910 int multiple
; // So you can control how many points are given for hitting opponents
912 int iconpain
; // 20-1-2005 New icons
913 int iconget
; // 20-1-2005 New icons
914 int icondie
; // 20-1-2005 New icons
915 int iconw
; // icon for the weapon like in beat of fighting by tails
916 int iconmp
[3]; // icon for the mpbar 3 levels
917 int parrow
[MAX_PLAYERS
][3]; // Image to be displayed when player spawns invincible
918 int setlayer
; // Used for forcing enities to be displayed behind
922 // these are model id of various stuff
924 int rider
; // 7-1-2005 now every "biker" can have a new driver!
925 int knife
; // 7-1-2005 now every enemy can have their own "knife" projectile
926 int pshotno
; // 7-1-2005 now every enemy can have their own "knife" projectile
927 int star
; // 7-1-2005 now every enemy can have their own "ninja star" projectiles
928 int bomb
; // New projectile type for exploding bombs/grenades/dynamite
929 int flash
; // Now each entity can have their own flash
930 int bflash
; // Flash that plays when an attack is blocked
931 int dust
[3]; // Dust spawn (0 = Fall land, 1 = Jumpland, 2 = Jumpstart.)
932 int grabforce
; // grab factor, antigrab - grabforce <= 0 means can grab
933 int sight
[6]; // Sight ranges, xmin, xmax, zmin, zmax, amin, amax
934 int jugglepoints
[2]; // juggle points. [0] = current [1] = max total
935 int guardpoints
[2]; // guard points. [0] = current [1] = max total
937 unsigned int aiattack
; // attack/defend style
938 unsigned int aimove
; // move style
939 unsigned int offscreenkill
; // for biker, arrow, etc
942 float stats
[20]; // Parameters that do nothing on their own.
943 float scroll
; // Autoscroll like panel entity.
946 float grabdistance
; // 30-12-2004 grabdistance varirable adder per character
947 float jumpspeed
; // normal jump foward speed, default to max(1, speed)
948 float jumpheight
; // 28-12-2004 Jump height variable added per character
950 float runspeed
; // The speed the character runs at
951 float runjumpheight
; // The height the character jumps when running
952 float runjumpdist
; // The distance the character jumps when running
953 float throwheight
; // The height at which an opponent can now be adjusted
954 float throwdist
; // The distance an opponent can now be adjusted
955 float lifespan
; // lifespan count down
956 float knockdowncount
; // the knock down count for this entity
957 float antigravity
; //antigravity : gravity * (1- antigravity)
959 short mpstableval
; // MP Stable target.
960 short aggression
; // For enemy A.I.
961 short risetime
[2]; // 0 = Rise delay, 1 = Riseattack delay.
963 short counter
; // counter of weapons by tails
965 short thold
; // The entities threshold for block
966 short blockodds
; // Odds that an enemy will block an attack (1 : blockodds)
967 short throwframewait
; // The frame victim is thrown during ANIM_THROW, added by kbandressen 10/20/06
968 short specials_loaded
; // Stores how many specials have been loaded
969 short valid_special
; // Used for setting when a valid special has been found
970 short height
; // Used to set height of player in pixels
971 short turndelay
; // turn delay
972 short stealth
[2]; // 0 = Entity's invisibility to AI. 1 = AI ability to see through stealth.
974 //---------------new A.I. switches-----------
975 short hostile
; // specify hostile types
976 short candamage
; // specify types that can be damaged by this entity
977 short projectilehit
; // specify types that can be hit by this entity if it is thrown
979 short throwdamage
; // 1-14-05 adjust throw damage
987 unsigned char shootnum
; // counter of shots by tails
988 unsigned char reload
; // reload max shots by tails
991 char weaploss
[2]; // Determines possibility of losing weapon.
992 char ownweapons
; // is the weapon list own or share with others
993 char reactive
; // Used for setting the "a" at which weapons are spawned
994 char typeshot
; // see if weapon is a gun or knife by tails
995 char animal
; // see is the weapon is a animal by tails
996 char nolife
; // Feb 25, 2005 - Variable flag to show life 0 = no, else yes
997 char dofreeze
; // Flag to freeze all enemies/players while special is executed
998 char noquake
; // Flag to make the screen shake when entity lands 1 = no, else yes
999 char ground
; // Flag to determine if enemy projectiles only hit the enemy when hitting the ground
1000 char bounce
; // Flag to determine if bounce/quake is to be used.
1002 char fmap
; // Corresponds to which remap to use for when a character is frozen
1003 char komap
[2]; // Remap to use when KO'd
1004 char hmap1
; //Bottom range of remaps unavailable at select screen.
1005 char hmap2
; //Top range of remaps unavailable at select screen.
1006 char alpha
; // New alpha variable to determine if the entity uses alpha transparency
1007 char toflip
; // Flag to determine if flashes flip or not
1009 char gfxshadow
; // use current frame to create a shadow
1010 char aironly
; // Used to determine if shadows will be shown when jumping only
1011 char nomove
; // Flag for static enemies
1012 char noflip
; // Flag to determine if static enemies flip or stay facing the same direction
1013 char nodrop
; // Flag to determine if enemies can be knocked down
1014 char nodieblink
; // Flag to determine if blinking while playing die animation
1015 char holdblock
; // Continue the block animation as long as the player holds the button down
1016 char nopassiveblock
; // Don't auto block randomly
1017 char blockback
; // Able to block attacks from behind
1018 char noatflash
; // Flag to determine if attacking characters attack spawns a flash
1019 char runupdown
; // Flag to determine if a player will continue to run while pressing up or down
1020 char runhold
; // Flag to determine if a player will continue to run if holding down forward when landing
1021 char remove
; // Flag to remove a projectile on contact or not
1022 char jumpmovex
; // low byte: 0 default 1 flip in air, 2 move in air, 3 flip and move
1023 char jumpmovez
; // 2nd byte: 0 default 1 zjump with flip(not implemented yet) 2 z jump move in air, 3 1+2
1024 char grabfinish
; // wait for grab animation to finish before do other actoins
1025 char antigrab
; // anti-grab factor
1026 char facing
; // 0 no effect, 1 alway right, 2 always left, 3, affected by level dir
1027 char grabback
; // Flag to determine if entities grab images display behind opponenets
1029 char paingrab
; // Can only be grabbed when in pain
1030 char maps_loaded
; // Used for player colourmap selecting
1031 char unload
; // Unload model after level completed?
1032 char falldie
; // Play die animation?
1033 char globalmap
; // use global palette for its colour map in 24bit mode
1035 char summonkill
; // kill it's summoned entity when died; 0. dont kill 1. kill summoned only 2. kill all spawned entity
1038 char atchain
[MAX_ATCHAIN
];
1041 char escapehits
; // Escape spammers!
1042 char chargerate
; // For the charge animation
1043 char guardrate
; // Rate for guardpoints recover.
1044 char mprate
; // For time-based mp recovery.
1045 char mpdroprate
; // Time based MP loss.
1046 char mpstable
; // MP stable type.
1047 char riseattacktype
;
1048 char mpswitch
; // switch between reduce or gain mp for mpstabletype 4
1049 char model_flag
; //used to judge some copy method when setting new model to an entity
1051 char subject_to_wall
;
1052 char subject_to_platform
;
1053 char subject_to_obstacle
;
1054 char subject_to_hole
;
1055 char subject_to_gravity
;
1056 char subject_to_screen
;
1057 char subject_to_minz
;
1058 char subject_to_maxz
;
1059 char no_adjust_base
; // dont change base to 0 automatically
1060 char instantitemdeath
; // no delay before item suicides
1063 ModelFreetype freetypes
;
1065 s_barstatus hpbarstatus
;
1066 s_edelay edelay
; // Entity level delay adjustment.
1076 extern s_modelcache
*model_cache
;
1079 typedef struct entity
{
1080 struct entity
*link
; // Used to link 2 entities together.
1081 struct entity
*owner
; // Added for "hitenemy" flag so projectile recognizes its owner
1082 struct entity
*grabbing
; // Added for "platform level" layering
1083 struct entity
*weapent
;
1084 struct entity
*parent
; //Its spawner
1085 struct entity
*subentity
; //store the sub entity
1086 struct entity
*opponent
;
1087 struct entity
*lasthit
;
1088 struct entity
*hithead
; // when a player jumps and hits head on the bottom of a platform
1089 struct entity
*bound
; // ignore trymove method, follow this entity
1090 struct entity
*landed_on_platform
;
1091 struct entity
*dot_owner
[MAX_DOTS
]; //Dot owner.
1094 void (*takeaction
) ();
1095 int (*takedamage
) (struct entity
*, s_attack
*);
1096 int (*trymove
) (float, float);
1098 unsigned char *colourmap
;
1100 ScriptVariant
*entvars
;
1102 s_model
*defaultmodel
; // this is the default model
1103 s_model
*model
; // current model
1108 float *defense_factors
; //defense factors: damage = damage*(1-def)
1109 float *defense_pain
; //Pain factor (like nopain) for defense type.
1110 float *defense_knockdown
; //Knockdowncount (like knockdowncount) for attack type.
1111 float *defense_blockpower
; //If > unblockable, this attack type is blocked.
1112 float *defense_blockthreshold
; //Strongest attack from this attack type that can be blocked.
1113 float *defense_blockratio
; //% of damage still taken from this attack type when blocked.
1114 float *defense_blocktype
; //0 = HP, 1=MP, 2=both taken when this attack type is blocked.
1115 float *offense_factors
; //offense factors: damage = damage*(1+def)
1119 float a
; // Altitude
1122 float base
; // Default altitude
1123 float altbase
; // Altitude affected by movea
1124 float tossv
; // Effect of gravity
1128 float stats
[20]; // Parameters that do nothing on their own.
1129 float lifespancountdown
; // life span count down
1130 float antigravity
; // gravity*(1-antigravity)
1131 float knockdowncount
;
1133 int health
; // current hp
1134 int mp
; // current mp
1136 int oldmp
; //mp's variable for mp for players by tails
1137 int sortid
; // id for sprite queue sort
1138 int itemhealth
; // Now items spawned can have their properties changed
1139 int dot
[MAX_DOTS
]; //Dot mode.
1140 int dot_atk
[MAX_DOTS
]; //Dot attack type.
1141 int dot_force
[MAX_DOTS
]; //Dot amount.
1142 int dot_rate
[MAX_DOTS
]; //Dot delay per tick.
1143 int dot_cnt
[MAX_DOTS
]; //Dot time of next tick.
1145 // ---------------------- action times -------------------------------
1146 unsigned int lastmove
;
1147 unsigned int lastdir
;
1148 unsigned int timestamp
;
1149 unsigned int releasetime
;
1150 unsigned int toss_time
; // Used by gravity code
1151 unsigned int stalltime
;
1152 unsigned int combotime
; // For multiple-hit combo
1153 unsigned int movetime
; // For special move
1154 unsigned int freezetime
; // Used to store at what point the a frozen entity becomes unfrozen
1155 unsigned int maptime
; // used by forcemap
1156 unsigned int sealtime
; // used by seal (stops special moves).
1157 unsigned int dot_time
[MAX_DOTS
]; //Dot time to expire.
1158 unsigned int magictime
;
1159 unsigned int guardtime
;
1160 unsigned int nextanim
;
1161 unsigned int nextthink
;
1162 unsigned int pain_time
;
1163 unsigned int mpchargetime
; // For the CHARGE animation
1164 unsigned int sleeptime
; // For the SLEEP animation
1165 unsigned int rushtime
; // rush combo timer
1166 unsigned int knockdowntime
; // count knock down hit
1167 unsigned int invinctime
; // Used to set time for invincibility to expire
1168 unsigned int turntime
;
1169 unsigned int staydown
[3]; // [0] = Extra time before next rise. [1] = Extra time before next rise attack. [3] = Stalltime placeholder for riseattack.
1171 s_drawmethod drawmethod
;
1173 s_model modeldata
; // model data copyied here
1175 short itemplayer_count
;
1177 short item
; // item model id
1181 short lastanimpos
; // Used by AI
1182 short animnum
; // animation id
1185 short hit_by_attack_id
;
1186 //struct entity *thrower;
1187 short bindoffset
[4]; // x, z, a, dir; int is ok
1188 short bindanim
; // keep the bound entities same animation id
1190 unsigned short rush
[2]; // rush combo and max combo
1192 char escapecount
; // For escapehits
1194 char damage_on_landing
;
1195 char damagetype
; // used for set death animation or pain animation
1196 char map
; // Stores the colourmap for restoring purposes
1199 char spawntype
; // Type of spawn. 1 = Level spawn. 0 for all else (subject to change).
1200 char exists
; // flag to determine if it is a valid entity.
1201 char reactive
; // Used for setting the "a" at which weapons are spawned
1205 char dying
; // Coresponds with which remap is to be used for the dying flash
1206 char per1
; // Used to store at what health value the entity begins to flash
1207 char per2
; // Used to store at what health value the entity flashes more rapidly
1208 char direction
; // 0=left 1=right
1209 char nograb
; // Some enemies cannot be grabbed (bikes) - now used with cantgrab as well
1211 char name
[MAX_NAME_LEN
+ 1]; // this is display name
1213 char itemmap
; // Now items spawned can have their properties changed
1214 char itemtrans
; // alpha effect of item
1215 char itemalias
[MAX_NAME_LEN
+ 1]; // Now items spawned can have their properties changed
1216 unsigned char combostep
[MAX_SPECIAL_INPUTS
]; // merge into an array to clear up some code
1220 //------------------------- a lot of flags ---------------------------
1221 //TODO check if these can be set to 1 bit.
1223 char seal
; //1 = No specials.
1225 char jumping
; // Stuff useful for AI
1234 char running
; // Flag to determine if a player is running
1235 char grabwalking
; // a flag for grabwalk check
1236 char inpain
; // playing pain animation
1237 char frozen
; // Flag to determine if an entity is frozen
1239 char invincible
; // Flag used to determine if player is currently invincible
1240 char autokill
; // Kill on end animation
1241 char remove_on_attack
;
1242 char cantfire
; // Flag to determine if another shot can be fired that costs energy
1243 char tocost
; // Flag to determine if special costs life if doesn't hit an enemy
1244 char noaicontrol
; // pause A.I. control
1246 char toexplode
; // Needed to determine if the projectile is a type that will explode (bombs, dynamite, etc)
1247 char animating
; // Set by animation code
1248 char arrowon
; // Flag to display parrow/parrow2 or not
1257 char name
[MAX_NAME_LEN
+ 1];
1259 unsigned int score
:32;
1260 unsigned char lives
:8;
1261 unsigned char credits
:8;
1276 s_sprite
*sprite_normal
;
1277 s_sprite
*sprite_neon
;
1278 s_sprite
*sprite_screen
;
1282 char *sprite_normal
;
1284 char *sprite_screen
;
1285 } s_panel_filenames
;
1287 typedef struct s_spawn_script_cache_node
{
1289 Script
*cached_spawn_script
;
1290 struct s_spawn_script_cache_node
*next
;
1291 } s_spawn_script_cache_node
;
1293 typedef struct s_spawn_script_list_node
{
1294 Script
*spawn_script
;
1295 struct s_spawn_script_list_node
*next
;
1296 } s_spawn_script_list_node
;
1302 char nojoin
:8; // dont allow new hero to join
1303 char spawnplayer_count
:8; // spawn this entity according to the amount of players
1304 char palette
:8; //change system palette to ...
1307 short scrollminz
:16; // new scroll limit
1308 short scrollmaxz
:16;
1309 short blockade
:16; //limit how far you can go back
1310 short light
[2]; // x, z light direction, for gfx shadow
1311 char shadowcolor
:8; // -1 no shadow
1316 char *name
; // must be a name in the model list, so just reference
1317 int index
; // model id
1318 int itemindex
; // item model id
1319 int weaponindex
; // the spawned entity with an weapon item, this is the id of the item model
1320 char alpha
:8; // Used for alpha effects
1326 char dying
:8; // Used for the dying flash animation
1327 char per1
:8; // Used to store at what health value the entity begins to flash
1328 char per2
:8; // Used to store at what health value the entity flashes more rapidly
1329 char nolife
:8; // So nolife can be overriden for all characters
1330 char itemplayer_count
:8; // spawn the item according to the amount of players
1333 char alias
[MAX_NAME_LEN
+ 1];
1334 char *item
; // must be a name in the model list, so just reference
1335 char itemalias
[MAX_NAME_LEN
+ 1];
1337 int health
[MAX_PLAYERS
];
1338 int mp
; // mp's variable for mpbar by tails
1339 unsigned int score
:32; // So score can be overridden for enemies/obstacles
1340 int multiple
; // So score can be overridden for enemies/obstacles
1345 unsigned char credit
:8;
1346 short aggression
:16; // For enemy A.I.
1347 char spawntype
; // Pass 1 when a level spawn.
1348 char *weapon
; // spawn with a weapon, since it should be in the model list, so the model must be loaded, just reference its name
1349 s_model
*weaponmodel
;
1350 s_spawn_script_list_node
*spawn_script_list_head
;
1360 char *branchname
; // Use a name so we can find this level in branches
1362 le_type type
; // see le_type
1363 int z_coords
[3]; // Used for setting custom "z"
1364 int gonext
; // 0. dont complete this level and display score,
1365 // 1. complete level and display score,
1366 // 2. complete game, show hall of fame
1437 int t
; //Time to expire.
1460 // attention, s_wall must have all the members of s_hole in the same order
1461 // as it is used in checkwall_or_hole()
1476 s_spawn_entry spawnpoints
[LEVEL_MAX_SPAWNS
];
1478 int order
[LEVEL_MAX_PANELS
];
1479 s_bglayer bglayers
[LEVEL_MAX_BGLAYERS
];
1480 s_fglayer fglayers
[LEVEL_MAX_FGLAYERS
];
1481 s_textobj textobjs
[LEVEL_MAX_TEXTOBJS
];
1484 s_filestream filestreams
[LEVEL_MAX_FILESTREAMS
];
1489 int numwalls
; // Stores number of walls loaded
1490 s_hole holes
[LEVEL_MAX_HOLES
];
1491 int holesfound
[LEVEL_MAX_HOLES
];
1492 s_wall walls
[LEVEL_MAX_WALLS
]; // Now you can have walls for different walkable areas
1493 int wallsfound
[LEVEL_MAX_WALLS
];
1499 float bgspeed
; // Used to make autoscrolling backgrounds
1500 int bgdir
; // Used to set which direction the backgrounds scroll for autoscrolling backgrounds
1503 char bossmusic
[256];
1504 unsigned int bossmusic_offset
;
1506 unsigned char palettes
[LEVEL_MAX_PALETTES
][1024]; //dynamic palettes
1507 unsigned char *blendings
[LEVEL_MAX_PALETTES
][MAX_BLENDINGS
]; //blending tables
1508 int settime
; // Set time limit per level
1509 int notime
; // Used to specify if the time is displayed 1 = no, else yes
1510 int noreset
; // If set, clock will not reset when players spawn/die
1511 int type
; // Used to specify which level type (1 = bonus, else regular)
1512 int nospecial
; // Used to specify if you can use your special during bonus levels
1513 int nohurt
; // Used to specify if you can hurt the other player during bonus levels
1514 int noslow
; // Flag so the level doesn't slow down after a boss is defeated
1515 int nohit
; // Not able to grab / hit other player on a per level basis
1516 int spawn
[MAX_PLAYERS
][4]; // Used to determine the spawn position of players
1517 int setweap
; // Levels can now specified which weapon will be used by default
1518 int facing
; // Force the players to face to ... 0 no effects, 1 right, 2 left, 3 affected by level dir
1519 //--------------------gravity system-------------------------
1523 //---------------------scripts-------------------------------
1524 Script update_script
;
1525 Script updated_script
;
1527 Script level_script
;
1528 Script endlevel_script
;
1529 s_spawn_script_cache_node
*spawn_script_cache_head
;
1539 typedef struct ArgList
{
1559 #define s_colors_itemcount 12
1562 int r
; int g
; int b
;
1580 extern s_colors colors
;
1599 extern s_samples samples
;
1600 #define s_samples_itemcount 14
1617 } s_samples_strings
;
1619 extern List
*scriptConstantsCommandList
;
1623 } s_script_args_tuple
;
1626 s_script_args_tuple ent
;
1627 s_script_args_tuple attacker
;
1628 s_script_args_tuple drop
;
1629 s_script_args_tuple type
;
1630 s_script_args_tuple noblock
;
1631 s_script_args_tuple guardcost
;
1632 s_script_args_tuple jugglecost
;
1633 s_script_args_tuple pauseadd
;
1634 s_script_args_tuple which
;
1635 s_script_args_tuple atkid
;
1636 s_script_args_tuple blocked
;
1637 s_script_args_tuple animnum
;
1638 s_script_args_tuple frame
;
1639 s_script_args_tuple player
;
1640 s_script_args_tuple attacktype
;
1641 s_script_args_tuple reset
;
1642 s_script_args_tuple plane
;
1643 s_script_args_tuple height
;
1644 s_script_args_tuple obstacle
;
1645 s_script_args_tuple time
;
1646 s_script_args_tuple gotime
;
1647 s_script_args_tuple damage
;
1648 s_script_args_tuple damagetaker
;
1649 s_script_args_tuple other
;
1677 } s_script_args_names
;
1678 #define s_script_args_membercount (sizeof(s_script_args_names) / sizeof(char*))
1696 int buffer_pakfile(char *filename
, char **pbuffer
, size_t * psize
);
1697 int getsyspropertybyindex(ScriptVariant
* var
, int index
);
1698 int changesyspropertybyindex(int index
, ScriptVariant
* value
);
1699 int load_script(Script
* script
, char *path
);
1700 void init_scripts();
1701 void load_scripts();
1702 void execute_animation_script(entity
* ent
);
1703 void execute_takedamage_script(entity
* ent
, entity
* other
, int force
, int drop
, int type
, int noblock
, int guardcost
,
1704 int jugglecost
, int pauseadd
);
1705 void execute_ondeath_script(entity
* ent
, entity
* other
, int force
, int drop
, int type
, int noblock
, int guardcost
,
1706 int jugglecost
, int pauseadd
);
1707 void execute_onkill_script(entity
* ent
);
1708 void execute_onpain_script(entity
* ent
, int iType
, int iReset
);
1709 void execute_onfall_script(entity
* ent
, entity
* other
, int force
, int drop
, int type
, int noblock
, int guardcost
,
1710 int jugglecost
, int pauseadd
);
1711 void execute_onblocks_script(entity
* ent
);
1712 void execute_onblockw_script(entity
* ent
, int plane
, float height
);
1713 void execute_onblocko_script(entity
* ent
, entity
* other
);
1714 void execute_onblockz_script(entity
* ent
);
1715 void execute_onblocka_script(entity
* ent
, entity
* other
);
1716 void execute_onmovex_script(entity
* ent
);
1717 void execute_onmovez_script(entity
* ent
);
1718 void execute_onmovea_script(entity
* ent
);
1719 void execute_didblock_script(entity
* ent
, entity
* other
, int force
, int drop
, int type
, int noblock
, int guardcost
,
1720 int jugglecost
, int pauseadd
);
1721 void execute_ondoattack_script(entity
* ent
, entity
* other
, int force
, int drop
, int type
, int noblock
, int guardcost
,
1722 int jugglecost
, int pauseadd
, int iWhich
, int iAtkID
);
1723 void execute_updateentity_script(entity
* ent
);
1724 void execute_think_script(entity
* ent
);
1725 void execute_didhit_script(entity
* ent
, entity
* other
, int force
, int drop
, int type
, int noblock
, int guardcost
,
1726 int jugglecost
, int pauseadd
, int blocked
);
1727 void execute_onspawn_script(entity
* ent
);
1728 void clearsettings(void);
1729 void savesettings(void);
1730 void saveasdefault(void);
1731 void loadsettings(void);
1732 void loadfromdefault(void);
1733 void clearSavedGame(void);
1734 void clearHighScore(void);
1735 void saveGameFile(void);
1736 int loadGameFile(void);
1737 void saveHighScoreFile(void);
1738 void loadHighScoreFile(void);
1739 int music(char *filename
, int loop
, long offset
);
1741 void check_music_opened(void);
1743 char *findarg(char *command
, int which
);
1744 float diff(float a
, float b
);
1745 int inair(entity
* e
);
1746 float randf(float max
);
1747 int _makecolour(int r
, int g
, int b
);
1748 int load_colourmap(s_model
* model
, char *image1
, char *image2
);
1749 int load_palette(unsigned char *pal
, char *filename
);
1750 void standard_palette();
1751 void change_system_palette(int palindex
);
1752 void unload_background();
1753 void lifebar_colors();
1754 void load_background(char *filename
, int createtables
);
1755 void unload_texture();
1756 void load_texture(char *filename
);
1758 s_sprite
*loadpanel2(char *filename
);
1759 int loadpanel(s_panel_filenames
*);
1760 int loadfrontpanel(char *filename
);
1761 void resourceCleanUp(void);
1763 s_sprite
*loadsprite2(char *filename
, int *width
, int *height
);
1764 int loadsprite(char *filename
, int ofsx
, int ofsy
, int bmpformat
);
1765 void load_special_sprites();
1766 int load_special_sounds();
1767 s_model
*find_model(char *name
);
1768 s_model
*nextplayermodel(s_model
* current
);
1769 s_model
*prevplayermodel(s_model
* current
);
1770 void free_anim(s_anim
* anim
);
1772 s_anim
*alloc_anim();
1773 int addframe(s_anim
* a
, int spriteindex
, int framecount
, short delay
, unsigned char idle
,
1774 short *bbox
, s_attack
* attack
, short move
, short movez
,
1775 short movea
, short seta
, float *platform
, int frameshadow
,
1776 short *shadow_coords
, int soundtoplay
, s_drawmethod
* drawmethod
);
1777 void cache_model(char *name
, char *path
, int flag
);
1778 void remove_from_cache(char *name
);
1779 void free_modelcache();
1780 int get_cached_model_index(char *name
);
1781 char *get_cached_model_path(char *name
);
1782 s_model
*load_cached_model(char *name
, char *owner
, char unload
);
1783 int is_set(s_model
* model
, int m
);
1784 int load_script_setting();
1786 void unload_levelorder();
1787 void add_level(char *filename
, int diff
);
1788 void add_scene(char *filename
, int diff
);
1789 void load_levelorder();
1790 void unload_level();
1791 void load_level(char *filename
);
1792 void drawlifebar(int x
, int y
, int h
, int maxh
);
1793 void drawmpbar(int x
, int y
, int m
, int maxm
);
1794 void update_loading(s_loadingbar
* s
, int value
, int max
);
1795 void spawnplayer(int);
1796 void drop_all_enemies();
1797 void kill_all_enemies();
1798 void ent_set_colourmap(entity
* ent
, unsigned int which
);
1799 void predrawstatus();
1801 void addscore(int playerindex
, int add
);
1802 void free_ent(entity
* e
);
1805 entity
*smartspawn(s_spawn_entry
* p
);
1806 int adjust_grabposition(entity
* ent
, entity
* other
, float dist
, int grabin
);
1807 int player_trymove(float xdir
, float zdir
);
1808 void toss(entity
* ent
, float lift
);
1809 void player_think(void);
1810 void subtract_shot(void);
1811 void set_model_ex(entity
* ent
, char *modelname
, int index
, s_model
* newmodel
, int flag
);
1812 void dropweapon(int flag
);
1813 void biker_drive(void);
1814 void trap_think(void);
1815 void steamer_think(void);
1816 void text_think(void);
1817 void anything_walk(void);
1818 void adjust_walk_animation(entity
* other
);
1819 void kill(entity
*);
1820 int player_takedamage(entity
* other
, s_attack
* attack
);
1821 int biker_takedamage(entity
* other
, s_attack
* attack
);
1822 int obstacle_takedamage(entity
* other
, s_attack
* attack
);
1823 void ent_set_anim(entity
*, int, int);
1825 void player_blink(void);
1826 void common_prejump();
1828 void tryjump(float, float, float, int);
1829 void dojump(float, float, float, int);
1830 void biker_drive(void);
1831 void ent_default_init(entity
* e
);
1832 void ent_spawn_ent(entity
* ent
);
1833 void ent_summon_ent(entity
* ent
);
1834 void ent_set_anim(entity
* ent
, int aninum
, int resetable
);
1835 void ent_set_colourmap(entity
* ent
, unsigned int which
);
1836 void ent_set_model(entity
* ent
, char *modelname
);
1837 entity
*spawn(float x
, float z
, float a
, int direction
, char *name
, int index
, s_model
* model
);
1838 void ent_unlink(entity
* e
);
1839 void ents_link(entity
* e1
, entity
* e2
);
1840 void kill(entity
* victim
);
1842 int checkhit(entity
* attacker
, entity
* target
, int counter
);
1843 int checkhole(float x
, float z
);
1844 int testplatform(entity
*, float, float);
1845 int testhole(int, float, float);
1846 int testwall(int, float, float);
1847 int checkwalls(float x
, float z
, float a1
, float a2
);
1848 int checkholes(float, float);
1849 int checkwall_below(float x
, float z
, float a
);
1850 int checkwall(float x
, float z
);
1851 entity
*check_platform_below(float x
, float z
, float a
);
1852 entity
*check_platform(float x
, float z
);
1853 void do_attack(entity
* e
);
1855 entity
*find_ent_here(entity
* exclude
, float x
, float z
, int types
);
1856 void display_ents();
1857 void toss(entity
* ent
, float lift
);
1858 entity
*findent(int types
);
1859 int count_ents(int types
);
1860 entity
*find_ent_here(entity
* exclude
, float x
, float z
, int types
);
1861 int set_idle(entity
* ent
);
1862 int set_death(entity
* iDie
, int type
, int reset
);
1863 int set_fall(entity
* iFall
, int type
, int reset
, entity
* other
, int force
, int drop
, int noblock
, int guardcost
,
1864 int jugglecost
, int pauseadd
);
1865 int set_rise(entity
* iRise
, int type
, int reset
);
1866 int set_riseattack(entity
* iRiseattack
, int type
, int reset
);
1867 int set_blockpain(entity
* iBlkpain
, int type
, int reset
);
1868 int set_pain(entity
* iPain
, int type
, int reset
);
1869 void set_weapon(entity
* ent
, int wpnum
, int anim_flag
);
1870 entity
*melee_find_target();
1871 entity
*long_find_target();
1872 entity
*normal_find_target(int anim
);
1873 entity
*normal_find_item();
1878 void dograbattack(int);
1879 int check_special();
1880 void normal_prepare();
1882 void common_spawn(void);
1883 void common_drop(void);
1884 void common_jumpattack();
1890 void common_vault();
1893 void common_grab(void);
1894 void common_grabattack();
1895 void common_grabbed();
1896 void common_block(void);
1897 int arrow_takedamage(entity
* other
, s_attack
* attack
);
1898 int common_takedamage(entity
* other
, s_attack
* attack
);
1899 int normal_attack();
1900 void common_throw(void);
1901 void common_throw_wait(void);
1902 void common_prethrow(void);
1904 int common_trymove(float xdir
, float zdir
);
1905 void normal_runoff();
1906 void common_stuck_underneath();
1907 void common_attack_proc();
1908 void normal_attack_finish();
1909 entity
*common_find_target();
1910 int common_attack(void);
1911 int common_try_jump(void);
1912 int common_try_pick(entity
* other
);
1913 int common_try_chase(entity
* target
);
1914 int common_try_follow();
1915 int common_try_avoid(entity
* target
);
1916 int common_try_wandercompletely();
1917 int common_try_wander(entity
* target
);
1918 void common_pickupitem(entity
* other
);
1919 int common_walk_anim(entity
* ent
);
1920 int common_idle_anim(entity
* ent
);
1921 int common_up_anim(entity
* ent
);
1922 int common_down_anim(entity
* ent
);
1923 int common_backwalk_anim(entity
* ent
);
1924 int bomb_move(void);
1925 int arrow_move(void);
1926 int normal_move(void);
1927 int avoid_move(void);
1928 int chase_move(void);
1929 int wander_move(void);
1930 int common_move(void);
1931 void common_think(void);
1933 void prethrow(void);
1935 int player_trymove(float xdir
, float zdir
);
1936 int check_energy(int which
, int ani
);
1937 void player_preinput();
1938 int player_check_special();
1939 void runanimal(void);
1940 void player_blink(void);
1941 int check_combo(int m
);
1942 int check_costmove(int s
, int fs
);
1943 void didfind_item(entity
* other
);
1944 void player_think(void);
1945 void subtract_shot();
1946 void dropweapon(int flag
);
1947 void drop_all_enemies();
1948 void kill_all_enemies();
1949 void smart_bomb(entity
* e
, s_attack
* attack
);
1950 void anything_walk(void);
1951 entity
*knife_spawn(char *name
, int index
, float x
, float z
, float a
, int direction
, int type
, int map
);
1952 entity
*bomb_spawn(char *name
, int index
, float x
, float z
, float a
, int direction
, int map
);
1953 void bomb_explode(void);
1954 int star_spawn(float x
, float z
, float a
, int direction
);
1955 void steam_think(void);
1956 void trap_think(void);
1957 void steam_spawn(float x
, float z
, float a
);
1958 void steamer_think(void);
1959 void text_think(void);
1960 entity
*homing_find_target(int type
);
1961 void biker_drive(void);
1962 void bike_crash(void);
1963 void obstacle_fall(void);
1964 void obstacle_fly(void);
1965 entity
*smartspawn(s_spawn_entry
* props
);
1966 void spawnplayer(int index
);
1968 void update_scroller();
1969 void draw_scrolled_bg();
1970 void update(int ingame
, int usevwait
);
1971 void fade_out(int type
, int speed
);
1972 void apply_controls();
1973 void display_credits(void);
1974 void borShutdown(const char *caller
, int status
, char *msg
, ...);
1975 void guistartup(void);
1977 int playgif(char *filename
, int x
, int y
, int noskip
);
1978 void playscene(char *filename
);
1980 void hallfame(int addtoscore
);
1981 void showcomplete(int num
);
1982 int playlevel(char *filename
);
1983 int selectplayer(int *players
, char *filename
);
1984 void playgame(int *players
, unsigned which_set
, int useSavedGame
);
1985 int choose_difficulty();
1986 int load_saved_game();
1987 void term_videomodes();
1988 int init_videomodes(void);
1989 void safe_set(int *arr
, int index
, int newkey
, int oldkey
);
1990 void keyboard_setup(int player
);
1991 void input_options();
1992 void inputrefresh();
1993 void soundvol_options();
1994 void config_options();
1995 void cheatoptions();
1996 void system_options();
1997 void video_options();
1999 void soundcard_options();
2000 void openborMain(int argc
, char **argv
);
2001 int getValidInt(char *text
, char *file
, char *cmd
);
2002 float getValidFloat(char *text
, char *file
, char *cmd
);
2003 int set_color_correction(int gm
, int br
);
2005 extern s_videomodes videomodes
;
2006 extern unsigned int videoMode
;
2007 extern int current_palette
;
2008 extern unsigned char pal
[MAX_PAL_SIZE
];
2010 extern s_savelevel savelevel
[MAX_DIFFICULTIES
];
2011 extern s_savescore savescore
;
2012 extern s_savedata savedata
;
2014 extern int quit_game
;
2015 extern u32 bothkeys
;
2016 extern u32 bothnewkeys
;
2017 extern u32 interval
;
2018 extern s_playercontrols
*playercontrolpointers
[];
2020 extern int livescheat
;
2021 extern int creditscheat
;
2022 extern int healthcheat
;
2023 extern int keyscriptrate
;
2024 extern int versusdamage
;
2025 extern int ctrlmaxplayers
[MAX_DIFFICULTIES
];
2026 extern int maxplayers
[MAX_DIFFICULTIES
];
2027 extern int current_set
;
2028 extern int pause
; //FIXME rename to borPause and remove pause macro
2029 extern int forcecheatsoff
;
2030 extern unsigned int ifcomplete
[MAX_DIFFICULTIES
];
2031 extern unsigned int num_difficulties
;
2033 extern int saveslot
;
2034 extern char set_names
[MAX_DIFFICULTIES
][MAX_NAME_LEN
+ 1];
2035 extern s_player player
[4];
2037 extern int shadowsprites
[6];
2038 extern int gosprite
;
2039 extern int golsprite
;
2040 extern char *custBkgrds
;
2041 extern char *custLevels
;
2042 extern char *custModels
;