-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathopenbor.h
2043 lines (1884 loc) · 69.3 KB
/
openbor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* OpenBOR - http://www.LavaLit.com
* -
----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in OpenBOR root for details.
*
* Copyright (c) 2004 - 2011 OpenBOR Team
*/
/////////////////////////////////////////////////////////////////////////////
// Beats of Rage //
// Side-scrolling beat-'em-up //
/////////////////////////////////////////////////////////////////////////////
#ifndef OPENBOR_H
#define OPENBOR_H
/////////////////////////////////////////////////////////////////////////////
#include "types.h"
#include "video.h"
#include "vga.h"
#include "screen.h"
#include "loadimg.h"
#include "bitmap.h"
#include "sprite.h"
#include "spriteq.h"
#include "font.h"
#include "timer.h"
#include "rand32.h"
#include "sblaster.h"
#include "soundmix.h"
#include "control.h"
#include "draw.h"
#include "packfile.h"
#include "palette.h"
#include "anigif.h"
#include "texture.h"
#include "openborscript.h"
#include "globals.h"
#include "version.h"
#ifdef SDL
#include "gfx.h"
#endif
/////////////////////////////////////////////////////////////////////////////
// FIXME wow. this needs to be fixed. does rename every occurence of those variables/functions.
#define exit borExit
#define kill borKill
#define pause borPause
#define shutdown(ec, fmt, args...) borShutdown(__FUNCTION__, ec, fmt, ## args)
#define COMPATIBLEVERSION 0x00030000
#define CV_SAVED_GAME 0x00021276
#define CV_HIGH_SCORE 0x00020048
#define GAME_SPEED 200
#define THINK_SPEED 2
#define COUNTER_SPEED (GAME_SPEED*2)
#define MAX_ENTS 150
#define MAX_PANELS 52
#define MAX_WEAPONS 10
#define MAX_COLOUR_MAPS 30
#define MAX_NAME_LEN 40
#define LEVEL_MAX_SPAWNS 600
#define LEVEL_MAX_PANELS 100
#define LEVEL_MAX_HOLES 40
#define LEVEL_MAX_WALLS 40
#define LEVEL_MAX_BGLAYERS 100
#define LEVEL_MAX_FGLAYERS 10
#define LEVEL_MAX_TEXTOBJS 50
#define LEVEL_MAX_FILESTREAMS 50
#define LEVEL_MAX_PALETTES 40 // altered palettes
#define MAX_LEVELS 100
#define MAX_DIFFICULTIES 10
#define MAX_SPECIALS 8 // Added for customizable freespecials
#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
#define MAX_ATCHAIN 12 // Maximum attack chain length
#define MAX_IDLES 1 // Idle animations.
#define MAX_WALKS 1 // Walk animations.
#define MAX_BACKWALKS 1 // Backwalk animations.
#define MAX_UPS 1 // Walk up animations.
#define MAX_DOWNS 1 // Walk down animations.
#define MAX_ATTACKS 4 // Total number of attacks players have
#define MAX_FOLLOWS 4 // For followup animations
#define MAX_PLAYERS 4
#define MAX_ARG_LEN 512
#define MAX_PAL_SIZE 1024
#define MAX_CACHED_BACKGROUNDS 9
#define FLAG_ESC 0x00000001
#define FLAG_START 0x00000002
#define FLAG_MOVELEFT 0x00000004
#define FLAG_MOVERIGHT 0x00000008
#define FLAG_MOVEUP 0x00000010
#define FLAG_MOVEDOWN 0x00000020
#define FLAG_ATTACK 0x00000040
#define FLAG_JUMP 0x00000080
#define FLAG_SPECIAL 0x00000100
#define FLAG_SCREENSHOT 0x00000200
#define FLAG_ATTACK2 0x00000400
#define FLAG_ATTACK3 0x00000800
#define FLAG_ATTACK4 0x00001000
#define FLAG_ANYBUTTON (FLAG_START|FLAG_SPECIAL|FLAG_ATTACK|FLAG_ATTACK2|FLAG_ATTACK3|FLAG_ATTACK4|FLAG_JUMP)
#define FLAG_FORWARD 0
#define FLAG_BACKWARD 1
#define SDID_MOVEUP 0
#define SDID_MOVEDOWN 1
#define SDID_MOVELEFT 2
#define SDID_MOVERIGHT 3
#define SDID_ATTACK 4
#define SDID_ATTACK2 5
#define SDID_ATTACK3 6
#define SDID_ATTACK4 7
#define SDID_JUMP 8
#define SDID_SPECIAL 9
#define SDID_START 10
#define SDID_SCREENSHOT 11
#define TYPE_NONE 0
#define TYPE_PLAYER 1
#define TYPE_ENEMY 2
#define TYPE_ITEM 4
#define TYPE_OBSTACLE 8
#define TYPE_STEAMER 16
#define TYPE_SHOT 32 // 7-1-2005 type to use for player projectiles
#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!
#define TYPE_TEXTBOX 128 // New textbox type for displaying messages
#define TYPE_ENDLEVEL 256 // New endlevel type that ends the level when touched
#define TYPE_NPC 512 // A character can be an ally or enemy.
#define TYPE_PANEL 1024 // Fake panel, scroll with screen using model speed
#define SUBTYPE_NONE 0
#define SUBTYPE_BIKER 1
#define SUBTYPE_NOTGRAB 2 //7-1-2005 new subtype for those ungrabbable enemies
#define SUBTYPE_ARROW 3 //7-1-2005 subtype for an "enemy" that flies across the screen and dies
#define SUBTYPE_TOUCH 4 // ltb 1-18-05 new Item subtype for a more platformer feel.
#define SUBTYPE_WEAPON 5
#define SUBTYPE_NOSKIP 6 // Text type that can't be skipped
#define SUBTYPE_FLYDIE 7 // Now obstacles can be hit and fly like on Simpsons/TMNT
#define SUBTYPE_BOTH 8 // Used with TYPE_ENDLEVEL to force both players to reach the point before ending level
#define SUBTYPE_PROJECTILE 9 // New weapon projectile type that can be picked up by players/enemies
#define SUBTYPE_FOLLOW 10 // Used by NPC character, if set, they will try to follow players
#define SUBTYPE_CHASE 11 // Used by enemy always chasing you
//------------reserved for A.I. types-------------------------
// A.I. move1, affect movement path
#define AIMOVE1_NORMAL 0 // Current default style
#define AIMOVE1_CHASE 0x00000001 // alway move towards target, and can run to them if target is farway
#define AIMOVE1_CHASEZ 0x00000002 // only try to get close in z direction
#define AIMOVE1_CHASEX 0x00000004 // only try to get colse in x direction
#define AIMOVE1_AVOID 0x00000008 // try to avoid target
#define AIMOVE1_AVOIDZ 0x00000010 // only try to avoid target in z direction
#define AIMOVE1_AVOIDX 0x00000020 // only try to avoid target in x direction
#define AIMOVE1_WANDER 0x00000040 // ignore the target's position completely, wander everywhere, long idle time
#define AIMOVE1_BIKER 0x00000080 // move like a biker
#define AIMOVE1_ARROW 0x00000100 // fly like an arrow
#define AIMOVE1_STAR 0x00000200 // fly like a star, subject to ground
#define AIMOVE1_BOMB 0x00000400 // fly like a bomb, subject to ground/wall etc
#define AIMOVE1_NOMOVE 0x00000800 // don't move at all
#define AIMOVE1_BOOMRANG 0x00001000 // boomrang
#define MASK_AIMOVE1 0x0000FFFF
// A.I move2, affect terrain reflect
#define AIMOVE2_NORMAL 0 // Current default style
#define AIMOVE2_IGNOREHOLES 0x00010000 // don't avoid holes
#define MASK_AIMOVE2 0xFFFF0000
// A.I. attack1, affect attacking style
#define AIATTACK1_NORMAL 0 // Current default style
#define AIATTACK1_LONG 0x00000001 // Long range first
#define AIATTACK1_MELEE 0x00000002 // Melee attack first
#define AIATTACK1_NOATTACK 0x00000004 // dont attack at all
#define MASK_AIATTACK1 0x0000FFFF
// A.I. attack2, affect Defending style
#define AIATTACK2_NORMAL 0 // Current default style, don't dodge at all
#define AIATTACK2_DODGE 0x00010000 // Use dodge animation to avoid attack
#define AIATTACK2_DODGEMOVE 0x00020000 // Try to move in z direction if a jump attack is about to hit him
// and try to step back if a melee attack is about to hit him
#define MASK_AIATTACK2 0xFFFF0000
typedef struct {
short player_min_z;
short player_max_z;
short bgheight;
} s_player_min_max_z_bgheight;
extern s_player_min_max_z_bgheight player_min_max_z_bgheight;
#define PLAYER_MIN_Z (player_min_max_z_bgheight.player_min_z)
#define PLAYER_MAX_Z (player_min_max_z_bgheight.player_max_z)
#define BGHEIGHT (player_min_max_z_bgheight.bgheight)
// Note: the minimum Z coordinate of the player is important
// for several other drawing operations.
// movement restirctions are here!
//int PLAYER_MIN_Z = 160; // 2-10-05 adjustable walking area
//int PLAYER_MAX_Z = 232; // 2-10-05 adjustable walking area
//int BGHEIGHT = 160; // 2-10-05 adjustable BGHeight
//int MAX_WALL_HEIGHT = 1000; // max wall height that an entity can be spawned on
#define FRONTPANEL_Z (PLAYER_MAX_Z+50)
#define HUD_Z (FRONTPANEL_Z+10000)
#define HOLE_Z (PLAYER_MIN_Z-46)
#define NEONPANEL_Z (PLAYER_MIN_Z-47)
#define SHADOW_Z (PLAYER_MIN_Z-48)
#define SCREENPANEL_Z (PLAYER_MIN_Z-49)
#define PANEL_Z (PLAYER_MIN_Z-50)
#define MIRROR_Z (PLAYER_MIN_Z-5)
#define PIT_DEPTH -250
#define P2_STATS_DIST 180
#define CONTACT_DIST_H 30 // Distance to make contact
#define CONTACT_DIST_V 12
#define GRAB_DIST 36 // Grabbing ents will be placed this far apart.
#define GRAB_STALL (GAME_SPEED * 8 / 10)
typedef enum {
ATK_NORMAL = 0,
ATK_NORMAL2,
ATK_NORMAL3,
ATK_NORMAL4,
ATK_BLAST,
ATK_BURN,
ATK_FREEZE,
ATK_SHOCK,
ATK_STEAL, // Steal opponents life
ATK_NORMAL5,
ATK_NORMAL6,
ATK_NORMAL7,
ATK_NORMAL8,
ATK_NORMAL9,
ATK_NORMAL10,
ATK_ITEM,
MAX_ATKS
} attack_types;
#define STA_ATKS 6 // default special attack types: blast burn shock freeze steal
#define MAX_DOTS 10 // Max active dot effects.
#define SCROLL_RIGHT 2
#define SCROLL_DOWN 4
#define SCROLL_LEFT 8
#define SCROLL_UP 16
#define SCROLL_BACK 1
#define SCROLL_BOTH (SCROLL_BACK|SCROLL_RIGHT)
#define SCROLL_RIGHTLEFT SCROLL_BOTH
#define SCROLL_LEFTRIGHT (SCROLL_LEFT|SCROLL_BACK)
#define SCROLL_INWARD 32
#define SCROLL_OUTWARD 64
#define SCROLL_OUTIN (SCROLL_OUTWARD|SCROLL_BACK)
#define SCROLL_INOUT (SCROLL_INWARD|SCROLL_BACK)
#define SCROLL_UPWARD 128
#define SCROLL_DOWNWARD 256
// blah, blah,
typedef enum {
ANI_IDLE = 0,
ANI_WALK,
ANI_JUMP,
ANI_LAND,
ANI_ATTACK,
ANI_ATTACK1 = ANI_ATTACK,
ANI_ATTACK2,
ANI_ATTACK3,
ANI_ATTACK4, // Very important
ANI_UPPER,
ANI_BLOCK, // New block animation
ANI_JUMPATTACK,
ANI_JUMPATTACK1 = ANI_JUMPATTACK,
ANI_JUMPATTACK2,
ANI_JUMPATTACK3,
ANI_GET,
ANI_GRAB,
ANI_GRABATTACK,
ANI_GRABATTACK1 = ANI_GRABATTACK,
ANI_GRABATTACK2,
ANI_THROW,
ANI_SPECIAL,
ANI_SPECIAL1 = ANI_SPECIAL,
ANI_SPECIAL2, // Animation played for when pressing forward special
ANI_SPECIAL3, // special3 is an alias for jumpspecial
ANI_JUMPSPECIAL = ANI_SPECIAL3,
ANI_FREESPECIAL,
ANI_FREESPECIAL1 = ANI_FREESPECIAL,
ANI_FREESPECIAL2,
ANI_FREESPECIAL3,
ANI_FREESPECIAL4, // More freespecials added
ANI_FREESPECIAL5, // More freespecials added
ANI_FREESPECIAL6, // More freespecials added
ANI_FREESPECIAL7, // More freespecials added
ANI_FREESPECIAL8, // More freespecials added
ANI_SPAWN, // 26-12-2004 new animation added here ani_spawn
ANI_PICK, // 7-1-2005 used when players select their character at the select screen
ANI_UP, // Mar 2, 2005 - Animation for when going up
ANI_DOWN, // Mar 2, 2005 - Animation for when going down
ANI_SHOCK, // Animation played when knocked down by shock attack
ANI_BURN, // Animation played when knocked down by burn attack
ANI_SHOCKPAIN, // Animation played when not knocked down by shock attack
ANI_BURNPAIN, // Animation played when not knocked down by shock attack
ANI_GRABBED, // Animation played when grabbed
ANI_RUN, // Animation played when a player is running
ANI_RUNATTACK, // Animation played when a player is running and presses attack
ANI_RUNJUMPATTACK, // Animation played when a player is running and jumps and presses attack
ANI_ATTACKUP, // u u animation
ANI_ATTACKDOWN, // d d animation
ANI_ATTACKFORWARD, // f f animation
ANI_ATTACKBACKWARD, // Used for attacking backwards
ANI_DODGE, // Used for up up / down down SOR3 dodge moves for players
ANI_ATTACKBOTH, // Used for when a player holds down attack and presses jump
ANI_GRABFORWARD, // New grab attack for when a player holds down forward/attack
ANI_GRABFORWARD2, // New second grab attack for when a player holds down forward/attack
ANI_JUMPFORWARD, // Attack when a player is moving and jumps
ANI_GRABDOWN, // Attack when a player has grabbed an opponent and presses down/attack
ANI_GRABDOWN2, // Attack when a player has grabbed an opponent and presses down/attack
ANI_GRABUP, // Attack when a player has grabbed an opponent and presses up/attack
ANI_GRABUP2, // Attack when a player has grabbed an opponent and presses up/attack
ANI_SELECT, // Animation that is displayed at the select screen
ANI_DUCK, // Animation that is played when pressing down in "platform" type levels
ANI_FAINT, // Faint animations for players/enemys by tails
ANI_CANT, // Can't animation for players(animation when mp is less than mpcost) by tails.
ANI_THROWATTACK, // Added for subtype projectile
ANI_CHARGEATTACK, // Plays when player releases attack1 after holding >= chargetime.
ANI_VAULT, // Now you can flip over people like in SOR.
ANI_JUMPCANT,
ANI_BURNDIE,
ANI_SHOCKDIE,
ANI_PAIN, //the pain anims must be in a sequence as they're used to calculate offsets in lcmHandleCommandAnim()
ANI_PAIN1 = ANI_PAIN,
ANI_PAIN2,
ANI_PAIN3,
ANI_PAIN4,
ANI_PAIN5,
ANI_PAIN6,
ANI_PAIN7,
ANI_PAIN8,
ANI_PAIN9,
ANI_PAIN10,
ANI_FALL,
ANI_FALL1 = ANI_FALL,
ANI_FALL2,
ANI_FALL3,
ANI_FALL4,
ANI_FALL5,
ANI_FALL6,
ANI_FALL7,
ANI_FALL8,
ANI_FALL9,
ANI_FALL10,
ANI_DIE, // 29-12-2004 new animation added here ani_die
ANI_DIE1 = ANI_DIE,
ANI_DIE2,
ANI_DIE3,
ANI_DIE4,
ANI_DIE5,
ANI_DIE6,
ANI_DIE7,
ANI_DIE8,
ANI_DIE9,
ANI_DIE10,
ANI_CHARGE,
ANI_BACKWALK,
ANI_SLEEP,
ANI_FOLLOW,
ANI_FOLLOW1 = ANI_FOLLOW,
ANI_FOLLOW2,
ANI_FOLLOW3,
ANI_FOLLOW4,
ANI_TURN, // turn back/flip
ANI_RESPAWN, //now spawn works for players
ANI_FORWARDJUMP,
ANI_RUNJUMP,
ANI_JUMPLAND,
ANI_JUMPDELAY,
ANI_HITWALL,
ANI_GRABBACKWARD,
ANI_GRABBACKWARD1 = ANI_GRABBACKWARD,
ANI_GRABBACKWARD2,
ANI_GRABWALK,
ANI_GRABBEDWALK,
ANI_GRABWALKUP,
ANI_GRABBEDWALKUP,
ANI_GRABWALKDOWN,
ANI_GRABBEDWALKDOWN,
ANI_GRABTURN,
ANI_GRABBEDTURN,
ANI_GRABBACKWALK,
ANI_GRABBEDBACKWALK,
ANI_SLIDE, //Down + Jump animation.
ANI_RUNSLIDE, //Down + Jump while running.
ANI_DUCKATTACK,
ANI_RISE,
ANI_RISE1 = ANI_RISE,
ANI_RISE2,
ANI_RISE3,
ANI_RISE4,
ANI_RISE5,
ANI_RISE6,
ANI_RISE7,
ANI_RISE8,
ANI_RISE9,
ANI_RISE10,
ANI_RISEB,
ANI_RISES,
ANI_BLOCKPAIN, //If entity has this, it will play in place of "pain" when its blockpain is 1 and incoming attack is blocked.
ANI_BLOCKPAIN1 = ANI_BLOCKPAIN,
ANI_BLOCKPAIN2,
ANI_BLOCKPAIN3,
ANI_BLOCKPAIN4,
ANI_BLOCKPAIN5,
ANI_BLOCKPAIN6,
ANI_BLOCKPAIN7,
ANI_BLOCKPAIN8,
ANI_BLOCKPAIN9,
ANI_BLOCKPAIN10,
ANI_BLOCKPAINB,
ANI_BLOCKPAINS,
ANI_CHIPDEATH,
ANI_GUARDBREAK,
ANI_RISEATTACK, // Attack used for enemies when players are crowding around after knocking them down
ANI_RISEATTACK1 = ANI_RISEATTACK,
ANI_RISEATTACK2,
ANI_RISEATTACK3,
ANI_RISEATTACK4,
ANI_RISEATTACK5,
ANI_RISEATTACK6,
ANI_RISEATTACK7,
ANI_RISEATTACK8,
ANI_RISEATTACK9,
ANI_RISEATTACK10,
ANI_RISEATTACKB,
ANI_RISEATTACKS,
ANI_WALKOFF,
MAX_ANIS
} ani_types;
#define ARG_FLOAT 0
#define ARG_STRING 1
#define ARG_INT 2
// perhaps outdated, now use separted flags for entity
#define SUBJECT_TO_WALL 1
#define SUBJECT_TO_HOLE 2
#define SUBJECT_TO_OBSTACLE 4
#define SUBJECT_TO_BORDER 8
#define SUBJECT_TO_SCREEN 16
#define SUBJECT_TO_MINZ 32
#define SUBJECT_TO_MAXZ 48
//macros for drawing menu text, fits different font size
#ifdef _MSC_VER
#define _strmidx(f,s, ...) ((videomodes.hRes-font_string_width((f), s, __VA_ARGS__))/2)
#else
#define _strmidx(f,s, args...) ((videomodes.hRes-font_string_width((f), s, ##args))/2)
#endif
#define _colx(f,c) ((int)(videomodes.hRes/2+(c)*(font_monowidths[(f)]+1)))
#define _liney(f,l) ((int)(videomodes.vRes/2+(l)*(font_heights[(f)]+1)))
#ifdef _MSC_VER
#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__)
#define _menutext(f, c, l, s, ...) font_printf(_colx(f,c), _liney(f,l), (f), 0, s, __VA_ARGS__)
#else
#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)
#define _menutext(f, c, l, s, args...) font_printf(_colx(f,c), _liney(f,l), (f), 0, s, ##args)
#endif
/*
#define ICO_NORMAL 0
#define ICO_PAIN 1
#define ICO_DIE 2
#define ICO_GET 3
#define ICO_WEAPON 4*/
// model flags
#define MODEL_NO_COPY 0x00000001 //dont copy anything from original model
#define MODEL_NO_WEAPON_COPY 0x00000002 //dont copy weapon list from original model
#define lut_mul ((level && current_palette)?(level->blendings[current_palette-1][BLEND_MULTIPLY]):(blendings[BLEND_MULTIPLY]))
#define lut_screen ((level && current_palette)?(level->blendings[current_palette-1][BLEND_SCREEN]):(blendings[BLEND_SCREEN]))
#define lut_overlay ((level && current_palette)?(level->blendings[current_palette-1][BLEND_OVERLAY]):(blendings[BLEND_OVERLAY]))
#define lut_hl ((level && current_palette)?(level->blendings[current_palette-1][BLEND_HARDLIGHT]):(blendings[BLEND_HARDLIGHT]))
#define lut_dodge ((level && current_palette)?(level->blendings[current_palette-1][BLEND_DODGE]):(blendings[BLEND_DODGE]))
#define lut_half ((level && current_palette)?(level->blendings[current_palette-1][BLEND_HALF]):(blendings[BLEND_HALF]))
#define lut ((level && current_palette)?(level->blendings[current_palette-1]):(blendings))
#define ABS(x) ((x)>0?(x):(-(x)))
#define set_attacking(e) e->attacking = 1;\
e->idling = 0;
#define set_jumping(e) e->jumping = 1;\
e->idling = 0;
#define set_charging(e) e->charging = 1;\
e->idling = 0;
#define set_getting(e) e->getting = 1;\
e->idling = 0;
#define set_blocking(e) e->blocking = 1;\
e->idling = 0;
#define set_turning(e) e->turning = 1;\
e->idling = 0;
#define is_frozen(e) ((textbox && e->modeldata.type != TYPE_TEXTBOX) || \
(smartbomber && e != smartbomber && e->modeldata.type != TYPE_TEXTBOX) ||(self->frozen&&self->freezetime > borTime))
#define expand_time(e) if(e->stalltime>0) e->stalltime++;\
if(e->releasetime>0)e->releasetime++;\
if(e->nextanim>0)e->nextanim++;\
if(e->nextthink>0)e->nextthink++;\
if(e->magictime>0)e->magictime++;\
if(e->guardtime>0)e->guardtime++;\
if(e->toss_time>0)e->toss_time++;\
if(e->freezetime>0 && (textbox || smartbomber))e->freezetime++;\
if(e->mpchargetime>0)e->mpchargetime++;\
if(e->invinctime>0) e->invinctime++;\
if(e->sealtime>0) e->sealtime++;
/* if(e->dot_time>0) e->dot_time++;\
if(e->dot_cnt>0) e->dot_cnt++;
*/
#define freezeall (smartbomber || textbox)
#define is_projectile(e) (e->modeldata.type == TYPE_SHOT || e->model->subtype == SUBTYPE_ARROW || e->owner)
#define check_range(self, target, animnum) \
( target && \
(self->direction ? \
target->x > self->x+self->modeldata.animation[animnum]->range[0] &&\
target->x < self->x+self->modeldata.animation[animnum]->range[1]\
:\
target->x < self->x-self->modeldata.animation[animnum]->range[0] &&\
target->x > self->x-self->modeldata.animation[animnum]->range[1])\
&& target->z - self->z > self->modeldata.animation[animnum]->range[2] \
&& target->z - self->z < self->modeldata.animation[animnum]->range[3] \
&& (target->a - self->a) > self->modeldata.animation[animnum]->range[4] \
&& (target->a - self->a) < self->modeldata.animation[animnum]->range[5] \
&& (target->base - self->base) > self->modeldata.animation[animnum]->range[6] \
&& (target->base - self->base) < self->modeldata.animation[animnum]->range[7] \
)\
#define check_range_both(self, target, animnum) \
( target && \
((target->x > self->x+self->modeldata.animation[animnum]->range[0] &&\
target->x < self->x+self->modeldata.animation[animnum]->range[1])\
||\
(target->x < self->x-self->modeldata.animation[animnum]->range[0] &&\
target->x > self->x-self->modeldata.animation[animnum]->range[1]))\
&& target->z - self->z > self->modeldata.animation[animnum]->range[2] \
&& target->z - self->z < self->modeldata.animation[animnum]->range[3] \
&& (target->a - self->a) > self->modeldata.animation[animnum]->range[4] \
&& (target->a - self->a) < self->modeldata.animation[animnum]->range[5] \
&& (target->base - self->base) > self->modeldata.animation[animnum]->range[6] \
&& (target->base - self->base) < self->modeldata.animation[animnum]->range[7] \
)\
#define tobounce(e) (e->animation->bounce && diff(0, e->tossv) > 2 && \
!((autoland == 1 && e->damage_on_landing == -1) ||e->damage_on_landing == -2))
#define getpal ((current_palette&&level)?(level->palettes[current_palette-1]):pal)
#define canbegrabbed(self, other) \
(other->animation->vulnerable[other->animpos] && \
(!self->animation->move || self->animation->move[self->animpos] == 0) && \
(!self->animation->movez || self->animation->movez[self->animpos] == 0 ) && \
!(other->nograb || other->invincible || other->link || \
other->model->animal || inair(other) || \
(self->modeldata.type == TYPE_PLAYER && other->modeldata.type == TYPE_PLAYER && savedata.mode)))
#define cangrab(self, other) \
((other->model->antigrab - self->model->grabforce + \
(other->model->paingrab?(other->model->paingrab-other->inpain):0)<=0) &&\
canbegrabbed(self, other) && \
!inair(self) && \
diff(other->a, self->a) <= 0.1)
#define unfrozen(e) \
ent_set_colourmap(e, e->map);\
e->frozen = 0;\
e->freezetime = 0;
#define validanim(e, a) ((e)->modeldata.animation[a]&&(e)->modeldata.animation[a]->numframes)
//#define MAX_MOVES 16
//#define MAX_MOVE_STEPS 16
#define MENU_PACK_FILENAME "Menu.xxx"
#pragma pack (4)
typedef struct {
unsigned int compatibleversion;
short gamma;
short brightness;
char usesound; // Use SB
unsigned short soundrate; // SB freq
short soundvol; // SB volume
char usemusic; // Play music
short musicvol; // Music volume
short effectvol; // Sound fx volume
char soundbits; // SB bits
char usejoy;
char mode; // Mode now saves
char windowpos;
int keys[MAX_PLAYERS][12];
char showtitles;
char videoNTSC;
char screen[7][2]; // Screen Filtering/Scaling Effects
char logo;
char uselog;
char debuginfo; // FPS, Memory, etc...
char fullscreen; // Window or Full Screen Mode
char stretch; // Stretch (1) or preserve aspect ratio (0) in fullscreen mode
char usegl; // 1 if OpenGL is preferred over SDL software blitting
float glscale; // Scale factor for OpenGL
char glfilter; // Simple or bilinear scaling
} s_savedata;
typedef struct {
unsigned int compatibleversion:32;
char dName[MAX_NAME_LEN + 1]; // Difficulty Name
unsigned short level:16; // Level Number
unsigned short stage:16; // Stage
unsigned char pLives[MAX_PLAYERS]; // Player Lives Left
unsigned char pCredits[MAX_PLAYERS]; // Player Credits Left
unsigned int pScores[MAX_PLAYERS]; // Player Scores
unsigned char credits:8; // Number Of Credits
unsigned short times_completed:16;
unsigned short which_set:16;
//-------------------new strict save features-----------------------
char flag:8; // 0 useless slot 1 only load level number 2 load player info and level
char pName[MAX_PLAYERS][MAX_NAME_LEN + 1]; // player names
int pSpawnhealth[MAX_PLAYERS]; // hit points left
int pSpawnmp[MAX_PLAYERS]; // magic points left
char pWeapnum[MAX_PLAYERS]; // weapon
char pColourmap[MAX_PLAYERS]; // colour map
} s_savelevel;
typedef struct {
unsigned int compatibleversion:32;
unsigned int highsc[10];
char hscoren[10][MAX_NAME_LEN + 1];
} s_savescore;
typedef struct {
float dropv[3]; // fly height/x/z if the target is knoced down
float grab_distance; // suck target near by
int staydown[3]; // [0] = Add to rise delay. [1] = Add to rise attack delay.
int freezetime;
int maptime;
int sealtime;
int dot; //Dot mode.
int dot_index; //Dot index.
int dot_time; //Dot time to expire.
int dot_force; //Dot amount per tick.
int dot_rate; //Dot tick delay.
int hitsound; // Sound effect to be played when attack hits opponent
int hitflash; // Custom flash for each animation, model id
int blockflash; // Custom bflash for each animation, model id
int blocksound; // Custom sound for when an attack is blocked
short attack_force;
short attack_coords[5]; // stick on the only one victim
short jugglecost; // cost for juggling a falling ent
short guardcost; // cost for blocking an attack
short pause_add; // Flag to determine if an attack adds a pause before updating the animation
signed char counterattack;
signed char no_pain;
signed char no_flash; // Flag to determine if an attack spawns a flash or not
signed char no_block; // Flag to determine if an attack is blockable (default 0 - blockable)
signed char grab;
signed char force_direction; // 0 dont care, 1 same direction as attacker, -1 opposite drection as attacker, 2 right, -2 left
signed char blast;
signed char freeze;
signed char steal;
signed char forcemap;
signed char seal;
signed char otg; // Over The Ground. Gives ground projectiles the ability to hit lying ents.
signed char attack_drop; // now be a knock-down factor, how many this attack will knock victim down
signed char attack_type;
signed char damage_on_landing; // same as throw damage type
} s_attack;
typedef struct {
int model_index;
short numframes:16;
int loop[3]; // Animation loop (0 = loop on/off, 1 = Loop to frame, 2 = Loop end frame).
short height:16; // entity's height during animation
short tossframe:16; // Used to determine which frame will toss a bomb/grenade
short shootframe:16;
short throwframe:16;
short throwa:16; // Used for setting the "a" at which weapons are spawned
// various entity model id, knife/star/bomb etc
int custknife;
int custstar;
int custbomb; // Used for new projectile bomb
int custpshotno;
int subentity; // Store the sub-entity's name for further use
char fastattack:8; // Flag to determine if the opponent uses their pain time
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).
float chargetime; // charge time for an animation
short jumpframe:16;
float jumpv; // moveflag // So movement forward can be specified for jumpframes
float jumpx; // override move forward value
float jumpz; // override move z value
int jumpd; // Index of dust entity to spawn on liftoff of jumpframe.
float bounce; // -tossv/bounce = new tossv
float dive[2]; // new dive kick by tails
int *soundtoplay; // each frame can have a sound
int *sprite; // sprite[set][framenumber]
short *delay;
short *move;
short *movez;
short *movea;
short *seta; // Now characters can have a custom "a" value
short *vulnerable;
short (*bbox_coords)[5];
int *shadow;
unsigned char *idle; // Allow free move
short (*shadow_coords)[2]; // x, z offset of shadow
s_drawmethod **drawmethods;
char attackone:8;
s_attack **attacks;
float (*platform)[8]; // Now entities can have others land on them
int range[8]; // Use for attacks; xmin, xmax, zmin, zmax, amin, amax, basemin, basemax
short flipframe:16; // Turns entities around on the desired frame
short followanim:16; // use which FOLLOW anim?
char followcond:8; // conditions under which to use a followup
short counterframe[4]; // 0,1; Counter frame, 2 counter cond, 3 counterdam
char cancel:8; // Cancel anims with freespecial
short *weaponframe; // Specify with a frame when to switch to a weapon model
short quakeframe[4]; // Specify with a frame, repeat, quake (4 is highest)
float *spawnframe; // Spawn the subentity as its default type. {frame} {x} {z} {a} {relative?}
float *summonframe; // Summon the subentity as an ally, only one though {frame} {x} {z} {a} {relative?}
short unsummonframe:16; // Un-summon the entity
short landframe[2]; // 0 frame switch to when land, 1 dust to spawn.
short dropframe:16; // if tossv < 0, this frame will be set
short animhits:16; // Does the attack need to hit before cancel is allowed?
} s_anim;
typedef struct {
int mode;
float factor;
int cap_min;
int cap_max;
int range_min;
int range_max;
} s_edelay;
struct animlist {
s_anim *anim;
struct animlist *next;
};
typedef struct animlist s_anim_list;
extern s_anim_list *anim_list;
typedef enum {
horizontalbar = 0,
verticalbar = 1,
} barorient;
typedef enum {
valuebar = 0,
percentagebar = 1,
} bartype;
typedef struct {
int (*colourtable)[11]; //0 default backfill 1-10 foreground colours
int barlayer;
int backlayer;
int borderlayer;
int shadowlayer;
short offsetx;
short offsety;
short sizex;
short sizey;
char noborder:1;
char direction:1; //0) left to right or botom to top 1) reversed
bartype type:1;
barorient orientation:1;
} s_barstatus;
typedef enum {
LSTYPE_NONE = 0,
LSTYPE_BAR = 1,
LSTYPE_BACKGROUND = 2,
} loadingScreenType;
typedef struct {
loadingScreenType set;
/*set determines how loading screen would be.
- 0 = no loading screen.
- 1 = background and status bar.
- 2 = background only.
- 3 = status bar only.
*/
char tf; //determines used font number for "LOADING" text (last element in command, moved here because of alignment)
/*
- 0 = font.gif
- 1 = font2.gif
- 2 = font3.gif
- 3 = font4.gif */
short bx; //determines x and y coordinates of loading bar top left's location respectively
short by;
short bsize; // length of bar in pixels
short tx; //determines x and y coordinates of "LOADING" text location respectively.
short ty;
short refreshMs; // modder defined number of milliseconds in which the screen is updated while loading
} s_loadingbar;
typedef struct {
Script *animation_script; //system generated script
Script *update_script; //execute when update_ents
Script *think_script; //execute when entity thinks.
Script *takedamage_script; //execute when taking damage.
Script *ondeath_script; //execute when killed in game.
Script *onkill_script; //execute when removed from play.
Script *onpain_script; //Execute when put in pain animation.
Script *onfall_script; //execute when falling.
Script *onblocks_script; //execute when blocked by screen.
Script *onblockw_script; //execute when blocked by wall.
Script *onblocko_script; //execute when blocked by obstacle.
Script *onblockz_script; //execute when blocked by Z.
Script *onblocka_script; //execute when "hit head".
Script *onmovex_script; //execute when moving along X axis.
Script *onmovez_script; //execute when moving along Z axis.
Script *onmovea_script; //execute when moving along A axis.
Script *didhit_script; //execute when attack hits another.
Script *onspawn_script; //execute when spawned.
Script *key_script; //execute when entity's player presses a key
Script *didblock_script; //execute when blocking attack.
Script *ondoattack_script; //execute when attack passes do_attack checks.
} s_scripts;
typedef struct {
//global script
Script level_script; //execute when level start
Script endlevel_script; //execute when level finished
Script update_script; //execute when ingame update
Script updated_script; //execute when ingame update finished
Script key_script_all; //keyscript for all players
Script timetick_script; //time tick script.
//player script
Script score_script[4]; //execute when add score, 4 players
Script key_script[4]; //key listeners, lol
Script join_script[4]; //player join scripts
Script respawn_script[4]; //player respawn scripts
Script pdie_script[4]; //player death scripts
} s_game_scripts;
extern s_game_scripts game_scripts;
typedef enum {
MF_NONE = 0,
MF_ANIMLIST = 1,
MF_COLOURMAP = 2,
MF_PALETTE = 4,
MF_WEAPONS = 8,
MF_BRANCH = 16,
MF_ANIMATION = 32,
MF_DEF_FACTORS = 64,
MF_DEF_PAIN = 128,
MF_DEF_KNOCKDOWN = 256,
MF_DEF_BLOCKPOWER = 512,
MF_DEF_BLOCKTRESHOLD = 1024,
MF_DEF_BLOCKRATIO = 2048,
MF_DEF_BLOCKTYPE = 4096,
MF_OFF_FACTORS = 8192,
MF_SPECIAL = 16384,
MF_SMARTBOMB = 32768,
MF_SCRIPTS = 65536,
} ModelFreetype;
#define MF_ALL 0x1FFFF
typedef struct {
int (*special)[MAX_SPECIAL_INPUTS]; // Stores freespecials
int (*weapon)[MAX_WEAPONS]; // weapon model list
unsigned char *palette; // original palette for 32/16bit mode
unsigned char *colourmap[MAX_COLOUR_MAPS];
char *name;
char *path; // Path, so scripts can dynamically get files, sprites, sounds, etc.
char *branch; //level branch name
float *defense_factors; //basic defense factors: damage = damage*(1-def)
float *defense_pain; //Pain factor (like nopain) for defense type.
float *defense_knockdown; //Knockdowncount (like knockdowncount) for attack type.
float *defense_blockpower; //If > unblockable, this attack type is blocked.
float *defense_blockthreshold; //Strongest attack from this attack type that can be blocked.
float *defense_blockratio; //% of damage still taken from this attack type when blocked.
float *defense_blocktype; //0 = HP, 1=MP, 2=both taken when this attack type is blocked.
float *offense_factors; //basic offense factors: damage = damage*(1+def)
s_attack *smartbomb;
s_anim **animation;
int health;
int mp; // mp's variable for mpbar by tails
int makeinv; // Option to spawn player invincible >0 blink <0 noblink
int riseinv; // how many seconds will the character become invincible after rise >0 blink, <0 noblink
int multiple; // So you can control how many points are given for hitting opponents
int icon;
int iconpain; // 20-1-2005 New icons
int iconget; // 20-1-2005 New icons
int icondie; // 20-1-2005 New icons
int iconw; // icon for the weapon like in beat of fighting by tails
int iconmp[3]; // icon for the mpbar 3 levels
int parrow[MAX_PLAYERS][3]; // Image to be displayed when player spawns invincible
int setlayer; // Used for forcing enities to be displayed behind
int diesound;
int index;
// these are model id of various stuff
int project;
int rider; // 7-1-2005 now every "biker" can have a new driver!
int knife; // 7-1-2005 now every enemy can have their own "knife" projectile
int pshotno; // 7-1-2005 now every enemy can have their own "knife" projectile
int star; // 7-1-2005 now every enemy can have their own "ninja star" projectiles
int bomb; // New projectile type for exploding bombs/grenades/dynamite
int flash; // Now each entity can have their own flash
int bflash; // Flash that plays when an attack is blocked
int dust[3]; // Dust spawn (0 = Fall land, 1 = Jumpland, 2 = Jumpstart.)
int grabforce; // grab factor, antigrab - grabforce <= 0 means can grab
int sight[6]; // Sight ranges, xmin, xmax, zmin, zmax, amin, amax
int jugglepoints[2]; // juggle points. [0] = current [1] = max total
int guardpoints[2]; // guard points. [0] = current [1] = max total
unsigned int aiattack; // attack/defend style
unsigned int aimove; // move style
unsigned int offscreenkill; // for biker, arrow, etc
unsigned int score;
float stats[20]; // Parameters that do nothing on their own.
float scroll; // Autoscroll like panel entity.
float speed;
float grabdistance; // 30-12-2004 grabdistance varirable adder per character
float jumpspeed; // normal jump foward speed, default to max(1, speed)
float jumpheight; // 28-12-2004 Jump height variable added per character
float grabwalkspeed;
float runspeed; // The speed the character runs at
float runjumpheight; // The height the character jumps when running
float runjumpdist; // The distance the character jumps when running
float throwheight; // The height at which an opponent can now be adjusted
float throwdist; // The distance an opponent can now be adjusted
float lifespan; // lifespan count down
float knockdowncount; // the knock down count for this entity
float antigravity; //antigravity : gravity * (1- antigravity)
short mpstableval; // MP Stable target.
short aggression; // For enemy A.I.
short risetime[2]; // 0 = Rise delay, 1 = Riseattack delay.
short sleepwait;
short counter; // counter of weapons by tails
short type;
short thold; // The entities threshold for block
short blockodds; // Odds that an enemy will block an attack (1 : blockodds)
short throwframewait; // The frame victim is thrown during ANIM_THROW, added by kbandressen 10/20/06
short specials_loaded; // Stores how many specials have been loaded
short valid_special; // Used for setting when a valid special has been found
short height; // Used to set height of player in pixels
short turndelay; // turn delay
short stealth[2]; // 0 = Entity's invisibility to AI. 1 = AI ability to see through stealth.
//---------------new A.I. switches-----------
short hostile; // specify hostile types
short candamage; // specify types that can be damaged by this entity
short projectilehit; // specify types that can be hit by this entity if it is thrown
short throwdamage; // 1-14-05 adjust throw damage
short hpx;
short hpy;
short iconx;
short icony;
short namex;
short namey;
unsigned char shootnum; // counter of shots by tails
unsigned char reload; // reload max shots by tails
char weapnum;
char secret;
char weaploss[2]; // Determines possibility of losing weapon.
char ownweapons; // is the weapon list own or share with others
char reactive; // Used for setting the "a" at which weapons are spawned
char typeshot; // see if weapon is a gun or knife by tails
char animal; // see is the weapon is a animal by tails
char nolife; // Feb 25, 2005 - Variable flag to show life 0 = no, else yes
char dofreeze; // Flag to freeze all enemies/players while special is executed
char noquake; // Flag to make the screen shake when entity lands 1 = no, else yes
char ground; // Flag to determine if enemy projectiles only hit the enemy when hitting the ground
char bounce; // Flag to determine if bounce/quake is to be used.