Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1
#ifndef _SCRIPT_API_MACROS_H_
2
#define _SCRIPT_API_MACROS_H_
3
4
#include "
evt.h
"
5
#include "stdlib/stdarg.h"
6
7
#ifdef _LANGUAGE_C_PLUS_PLUS
8
extern
"C"
{
9
#endif
10
11
/****** EXPRESSIONS ***************************************************************************************************/
12
20
23
24
#define EVT_LOCAL_VAR_CUTOFF -20000000
25
#define EVT_LOCAL_VAR_OFFSET 30000000
26
#define EVT_MAP_VAR_CUTOFF -40000000
27
#define EVT_MAP_VAR_OFFSET 50000000
28
#define EVT_LOCAL_FLAG_CUTOFF -60000000
29
#define EVT_LOCAL_FLAG_OFFSET 70000000
30
#define EVT_MAP_FLAG_CUTOFF -80000000
31
#define EVT_MAP_FLAG_OFFSET 90000000
32
#define EVT_AREA_FLAG_CUTOFF -100000000
33
#define EVT_AREA_FLAG_OFFSET 110000000
34
#define EVT_GAME_FLAG_CUTOFF -120000000
35
#define EVT_GAME_FLAG_OFFSET 130000000
36
#define EVT_AREA_BYTE_CUTOFF -140000000
37
#define EVT_AREA_BYTE_OFFSET 150000000
38
#define EVT_GAME_BYTE_CUTOFF -160000000
39
#define EVT_GAME_BYTE_OFFSET 170000000
40
#define EVT_ARRAY_VAR_CUTOFF -180000000
41
#define EVT_ARRAY_VAR_OFFSET 190000000
42
#define EVT_ARRAY_FLAG_CUTOFF -200000000
43
#define EVT_ARRAY_FLAG_OFFSET 210000000
44
#define EVT_FIXED_CUTOFF -220000000
45
#define EVT_FIXED_OFFSET 230000000
46
#define EVT_IGNORE_ARG -250000000
// used by a couple functions to selectively ignore args
47
#define EVT_LIMIT -270000000
// TODO better name
48
49
// This fixes an issue with fixed point numbers not being correct. Potentially a truncation vs round difference.
50
#define FLOAT_ROUND(x) ((x) >=0 ? (f64)((x) + 0.9) : (f64)(x))
51
#define Float(DOUBLE) ((Bytecode)FLOAT_ROUND(((DOUBLE) * 1024.0f)) - EVT_FIXED_OFFSET)
52
54
#define EVT_FIXED_TO_FLOAT(x) ({f32 var = (x) + EVT_FIXED_OFFSET; var /= 1024.0f; var;})
55
57
#define FLOAT_TO_FIXED(x) (((x) * 1024.0f) + -EVT_FIXED_OFFSET)
58
60
#define Ref(sym) ((Bytecode) &(sym))
61
67
#define LocalVar(INDEX) ((INDEX) - EVT_LOCAL_VAR_OFFSET)
68
73
#define MapVar(INDEX) ((INDEX) - EVT_MAP_VAR_OFFSET)
74
80
#define LocalFlag(INDEX) ((INDEX) - EVT_LOCAL_FLAG_OFFSET)
81
86
#define MapFlag(INDEX) ((INDEX) - EVT_MAP_FLAG_OFFSET)
87
94
#define AreaFlag(INDEX) ((INDEX) - EVT_AREA_FLAG_OFFSET)
95
101
#define GameFlag(INDEX) ((INDEX) - EVT_GAME_FLAG_OFFSET)
102
110
#define AreaByte(INDEX) ((INDEX) - EVT_AREA_BYTE_OFFSET)
111
115
#define GameByte(INDEX) ((INDEX) - EVT_GAME_BYTE_OFFSET)
116
122
#define ArrayVar(INDEX) ((INDEX) - EVT_ARRAY_VAR_OFFSET)
123
128
#define ArrayFlag(INDEX) ((INDEX) - EVT_ARRAY_FLAG_OFFSET)
129
132
#define EVT_ENTITY_ID_BIT 0x4000
133
#define EVT_ENTITY_INDEX(entityIndex) ((entityIndex) + EVT_ENTITY_ID_BIT)
134
135
// inverse macros for obtaining the index of a variable from its encoded form
136
#define EVT_INDEX_OF_LOCAL_VAR(v) ((v) + EVT_LOCAL_VAR_OFFSET)
137
#define EVT_INDEX_OF_LOCAL_FLAG(v) ((v) + EVT_LOCAL_FLAG_OFFSET)
138
#define EVT_INDEX_OF_MAP_VAR(v) ((v) + EVT_MAP_VAR_OFFSET)
139
#define EVT_INDEX_OF_MAP_FLAG(v) ((v) + EVT_MAP_FLAG_OFFSET)
140
#define EVT_INDEX_OF_AREA_FLAG(v) ((v) + EVT_AREA_FLAG_OFFSET)
141
#define EVT_INDEX_OF_AREA_BYTE(v) ((v) + EVT_AREA_BYTE_OFFSET)
142
#define EVT_INDEX_OF_GAME_FLAG(v) ((v) + EVT_GAME_FLAG_OFFSET)
143
#define EVT_INDEX_OF_GAME_BYTE(v) ((v) + EVT_GAME_BYTE_OFFSET)
144
#define EVT_INDEX_OF_ARRAY_FLAG(v) ((v) + EVT_ARRAY_FLAG_OFFSET)
145
#define EVT_INDEX_OF_ARRAY_VAR(v) ((v) + EVT_ARRAY_VAR_OFFSET)
146
147
// shorthand names for LocalVar
148
#define LVar0 LocalVar(0)
149
#define LVar1 LocalVar(1)
150
#define LVar2 LocalVar(2)
151
#define LVar3 LocalVar(3)
152
#define LVar4 LocalVar(4)
153
#define LVar5 LocalVar(5)
154
#define LVar6 LocalVar(6)
155
#define LVar7 LocalVar(7)
156
#define LVar8 LocalVar(8)
157
#define LVar9 LocalVar(9)
158
#define LVarA LocalVar(10)
159
#define LVarB LocalVar(11)
160
#define LVarC LocalVar(12)
161
#define LVarD LocalVar(13)
162
#define LVarE LocalVar(14)
163
#define LVarF LocalVar(15)
164
165
// shorthand names for common LocalFlags
166
// these actually run all the way up to LocalFlag(96), but nothing past 15 is ever used
167
#define LFlag0 LocalFlag(0)
168
#define LFlag1 LocalFlag(1)
169
#define LFlag2 LocalFlag(2)
170
#define LFlag3 LocalFlag(3)
171
#define LFlag4 LocalFlag(4)
172
#define LFlag5 LocalFlag(5)
173
#define LFlag6 LocalFlag(6)
174
#define LFlag7 LocalFlag(7)
175
#define LFlag8 LocalFlag(8)
176
#define LFlag9 LocalFlag(9)
177
#define LFlagA LocalFlag(10)
178
#define LFlagB LocalFlag(11)
179
#define LFlagC LocalFlag(12)
180
#define LFlagD LocalFlag(13)
181
#define LFlagE LocalFlag(14)
182
#define LFlagF LocalFlag(15)
183
184
/****** INSTRUCTIONS **************************************************************************************************/
185
198
206
207
#define EVT_CMD(opcode, argv...) \
208
opcode, \
209
(sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \
210
##argv
211
213
#define End EVT_CMD(EVT_OP_END),
214
217
#define Return EVT_CMD(EVT_OP_RETURN),
218
222
#define Jump(EVT_SOURCE) EVT_CMD(EVT_OP_JUMP, (Bytecode) EVT_SOURCE),
223
227
#define Label(LABEL_ID) EVT_CMD(EVT_OP_LABEL, LABEL_ID),
228
232
#define Goto(LABEL_ID) EVT_CMD(EVT_OP_GOTO, LABEL_ID),
233
245
#define Loop(TIMES) EVT_CMD(EVT_OP_LOOP, TIMES),
246
248
#define EndLoop EVT_CMD(EVT_OP_END_LOOP),
249
251
#define BreakLoop EVT_CMD(EVT_OP_BREAK_LOOP),
252
254
#define Wait(NUM_FRAMES) EVT_CMD(EVT_OP_WAIT_FRAMES, NUM_FRAMES),
255
256
258
#define WaitSecs(NUM_SECONDS) EVT_CMD(EVT_OP_WAIT_SECS, NUM_SECONDS),
259
269
#define IfEq(LVAR, RVAR) EVT_CMD(EVT_OP_IF_EQ, LVAR, RVAR),
270
272
#define IfNe(LVAR, RVAR) EVT_CMD(EVT_OP_IF_NE, LVAR, RVAR),
273
275
#define IfLt(LVAR, RVAR) EVT_CMD(EVT_OP_IF_LT, LVAR, RVAR),
276
278
#define IfGt(LVAR, RVAR) EVT_CMD(EVT_OP_IF_GT, LVAR, RVAR),
279
281
#define IfLe(LVAR, RVAR) EVT_CMD(EVT_OP_IF_LE, LVAR, RVAR),
282
284
#define IfGe(LVAR, RVAR) EVT_CMD(EVT_OP_IF_GE, LVAR, RVAR),
285
288
#define IfFlag(LVAR, RVAR) EVT_CMD(EVT_OP_IF_FLAG, LVAR, RVAR),
289
292
#define IfNotFlag(LVAR, RVAR) EVT_CMD(EVT_OP_IF_NOT_FLAG, LVAR, RVAR),
293
295
#define Else EVT_CMD(EVT_OP_ELSE),
296
298
#define EndIf EVT_CMD(EVT_OP_END_IF),
299
311
#define Switch(LVAR) EVT_CMD(EVT_OP_SWITCH, LVAR),
312
316
#define SwitchConst(LCONST) EVT_CMD(EVT_OP_SWITCH_CONST, LCONST),
317
319
#define CaseEq(RVAR) EVT_CMD(EVT_OP_CASE_EQ, RVAR),
320
322
#define CaseNe(RVAR) EVT_CMD(EVT_OP_CASE_NE, RVAR),
323
325
#define CaseLt(RVAR) EVT_CMD(EVT_OP_CASE_LT, RVAR),
326
328
#define CaseGt(RVAR) EVT_CMD(EVT_OP_CASE_GT, RVAR),
329
331
#define CaseLe(RVAR) EVT_CMD(EVT_OP_CASE_LE, RVAR),
332
334
#define CaseGe(RVAR) EVT_CMD(EVT_OP_CASE_GE, RVAR),
335
337
#define CaseDefault EVT_CMD(EVT_OP_CASE_DEFAULT),
338
341
#define CaseOrEq(RVAR) EVT_CMD(EVT_OP_CASE_OR_EQ, RVAR),
342
345
#define CaseAndEq(RVAR) EVT_CMD(EVT_OP_CASE_AND_EQ, RVAR),
346
349
#define CaseFlag(RVAR) EVT_CMD(EVT_OP_CASE_FLAG, RVAR),
350
352
#define EndCaseGroup EVT_CMD(EVT_OP_END_CASE_GROUP),
353
356
#define CaseRange(MIN, MAX) EVT_CMD(EVT_OP_CASE_RANGE, MIN, MAX),
357
359
#define BreakSwitch EVT_CMD(EVT_OP_BREAK_SWITCH),
360
362
#define EndSwitch EVT_CMD(EVT_OP_END_SWITCH),
363
365
#define Set(VAR, INT_VALUE) EVT_CMD(EVT_OP_SET, VAR, (Bytecode) INT_VALUE),
366
370
#define SetConst(VAR, CONST) EVT_CMD(EVT_OP_SET_CONST, VAR, (Bytecode) CONST),
371
373
#define SetF(VAR, FLOAT_VALUE) EVT_CMD(EVT_OP_SETF, VAR, FLOAT_VALUE),
374
375
// Basic arithmetic operations.
376
#define Add(VAR, INT_VALUE) EVT_CMD(EVT_OP_ADD, VAR, INT_VALUE),
377
#define Sub(VAR, INT_VALUE) EVT_CMD(EVT_OP_SUB, VAR, INT_VALUE),
378
#define Mul(VAR, INT_VALUE) EVT_CMD(EVT_OP_MUL, VAR, INT_VALUE),
379
#define Div(VAR, INT_VALUE) EVT_CMD(EVT_OP_DIV, VAR, INT_VALUE),
380
#define Mod(VAR, INT_VALUE) EVT_CMD(EVT_OP_MOD, VAR, INT_VALUE),
381
382
// Basic floating-point arithmetic operations.
383
#define AddF(VAR, FLOAT_VALUE) EVT_CMD(EVT_OP_ADDF, VAR, FLOAT_VALUE),
384
#define SubF(VAR, FLOAT_VALUE) EVT_CMD(EVT_OP_SUBF, VAR, FLOAT_VALUE),
385
#define MulF(VAR, FLOAT_VALUE) EVT_CMD(EVT_OP_MULF, VAR, FLOAT_VALUE),
386
#define DivF(VAR, FLOAT_VALUE) EVT_CMD(EVT_OP_DIVF, VAR, FLOAT_VALUE),
387
389
#define UseBuf(INT_PTR) EVT_CMD(EVT_OP_USE_BUF, (Bytecode) INT_PTR),
390
392
#define BufRead1(VAR) EVT_CMD(EVT_OP_BUF_READ1, VAR),
393
395
#define BufRead2(VAR1, VAR2) EVT_CMD(EVT_OP_BUF_READ2, VAR1, VAR2),
396
398
#define BufRead3(VAR1, VAR2, VAR3) EVT_CMD(EVT_OP_BUF_READ3, VAR1, VAR2, VAR3),
399
401
#define BufRead4(VAR1, VAR2, VAR3, VAR4) EVT_CMD(EVT_OP_BUF_READ4, VAR1, VAR2, VAR3, VAR4),
402
404
#define BufPeek(OFFSET, VAR) EVT_CMD(EVT_OP_BUF_PEEK, OFFSET, VAR),
405
407
#define UseFBuf(FLOAT_PTR) EVT_CMD(EVT_OP_USE_FBUF, (Bytecode) FLOAT_PTR),
408
410
#define FBufRead1(VAR) EVT_CMD(EVT_OP_FBUF_READ1, VAR),
411
413
#define FBufRead2(VAR1, VAR2) EVT_CMD(EVT_OP_FBUF_READ2, VAR1, VAR2),
414
416
#define FBufRead3(VAR1, VAR2, VAR3) EVT_CMD(EVT_OP_FBUF_READ3, VAR1, VAR2, VAR3),
417
419
#define FBufRead4(VAR1, VAR2, VAR3, VAR4) EVT_CMD(EVT_OP_FBUF_READ4, VAR1, VAR2, VAR3, VAR4),
420
422
#define FBufPeek(OFFSET, VAR) EVT_CMD(EVT_OP_FBUF_PEEK, OFFSET, VAR),
423
425
#define UseArray(INT_PTR) EVT_CMD(EVT_OP_USE_ARRAY, (Bytecode) INT_PTR),
426
429
#define UseFlagArray(PACKED_FLAGS_PTR) EVT_CMD(EVT_OP_USE_FLAG_ARRAY, (Bytecode) PACKED_FLAGS_PTR),
430
433
#define MallocArray(SIZE, OUT_PTR_VAR) EVT_CMD(EVT_OP_MALLOC_ARRAY, SIZE, OUT_PTR_VAR),
434
436
#define BitwiseAnd(VAR, VALUE) EVT_CMD(EVT_OP_BITWISE_AND, VAR, VALUE),
437
439
#define BitwiseAndConst(VAR, CONST) EVT_CMD(EVT_OP_BITWISE_AND_CONST, VAR, CONST),
440
442
#define BitwiseOr(VAR, VALUE) EVT_CMD(EVT_OP_BITWISE_OR, VAR, VALUE),
443
445
#define BitwiseOrConst(VAR, CONST) EVT_CMD(EVT_OP_BITWISE_OR_CONST, VAR, CONST),
446
455
#define Exec(EVT_SOURCE) EVT_CMD(EVT_OP_EXEC, (Bytecode) EVT_SOURCE),
456
460
#define ExecGetTID(EVT_SOURCE, OUTVAR) EVT_CMD(EVT_OP_EXEC_GET_TID, (Bytecode) EVT_SOURCE, OUTVAR),
461
475
#define ExecWait(EVT_SOURCE) EVT_CMD(EVT_OP_EXEC_WAIT, (Bytecode) EVT_SOURCE),
476
499
#define BindTrigger(EVT_SOURCE, TRIGGER, COLLIDER_ID, UNK_A3, TRIGGER_PTR_OUTVAR) \
500
EVT_CMD(EVT_OP_BIND_TRIGGER, (Bytecode) EVT_SOURCE, TRIGGER, (Bytecode) COLLIDER_ID, UNK_A3, TRIGGER_PTR_OUTVAR),
501
503
#define BindPadlock(EVT_SOURCE, TRIGGER, COLLIDER_ID, ITEM_LIST, UNK_A3, TRIGGER_PTR_OUTVAR) \
504
EVT_CMD(EVT_OP_BIND_PADLOCK, (Bytecode) EVT_SOURCE, TRIGGER, COLLIDER_ID, (Bytecode) ITEM_LIST, UNK_A3, TRIGGER_PTR_OUTVAR),
505
507
#define Unbind EVT_CMD(EVT_OP_UNBIND),
508
510
#define KillThread(TID) EVT_CMD(EVT_OP_KILL_THREAD, TID),
511
513
#define SetPriority(PRIORITY) EVT_CMD(EVT_OP_SET_PRIORITY, PRIORITY),
514
516
#define SetTimescale(TIMESCALE) EVT_CMD(EVT_OP_SET_TIMESCALE, TIMESCALE),
517
519
#define SetGroup(GROUP) EVT_CMD(EVT_OP_SET_GROUP, GROUP),
520
522
#define SuspendGroup(GROUP) EVT_CMD(EVT_OP_SUSPEND_GROUP, GROUP),
523
525
#define ResumeGroup(GROUP) EVT_CMD(EVT_OP_RESUME_GROUP, GROUP),
526
528
#define SuspendOthers(GROUP) EVT_CMD(EVT_OP_SUSPEND_OTHERS, GROUP),
529
531
#define ResumeOthers(GROUP) EVT_CMD(EVT_OP_RESUME_OTHERS, GROUP),
532
534
#define SuspendThread(TID) EVT_CMD(EVT_OP_SUSPEND_THREAD, TID),
535
537
#define ResumeThread(TID) EVT_CMD(EVT_OP_RESUME_THREAD, TID),
538
540
#define IsThreadRunning(TID, OUTVAR) EVT_CMD(EVT_OP_IS_THREAD_RUNNING, TID, OUTVAR),
541
544
#define Thread EVT_CMD(EVT_OP_THREAD),
545
547
#define EndThread EVT_CMD(EVT_OP_END_THREAD),
548
560
#define ChildThread EVT_CMD(EVT_OP_CHILD_THREAD),
561
563
#define EndChildThread EVT_CMD(EVT_OP_END_CHILD_THREAD),
564
576
#define Call(FUNC, ARGS...) EVT_CMD(EVT_OP_CALL, (Bytecode) FUNC, ##ARGS),
577
579
#define EVT_DEBUG_LOG(STRING) EVT_CMD(EVT_OP_DEBUG_LOG, STRING),
580
582
#define DebugPrintVar(VAR) EVT_CMD(EVT_OP_DEBUG_PRINT_VAR, VAR),
583
584
/****** VECTOR OPERATIONS *********************************************************************************************/
585
586
// expand vector components
587
#define EVT_AS_VEC2(baseVar) (baseVar), (baseVar + 1)
588
#define EVT_AS_VEC3(baseVar) (baseVar), (baseVar + 1), (baseVar + 2)
589
590
// extract components from vector
591
#define EVT_VEC_X(baseVar) (baseVar)
592
#define EVT_VEC_Y(baseVar) (baseVar + 1)
593
#define EVT_VEC_Z(baseVar) (baseVar + 2)
594
595
#define EVT_VEC2_OP(OPERATION, MUT_BASE, x, y) \
596
OPERATION(MUT_BASE + 0, x) \
597
OPERATION(MUT_BASE + 1, y)
598
599
#define EVT_VEC3_OP(OPERATION, MUT_BASE, x, y, z) \
600
OPERATION(MUT_BASE + 0, x) \
601
OPERATION(MUT_BASE + 1, y) \
602
OPERATION(MUT_BASE + 2, z)
603
604
#define EVT_VEC2_VOP(OPERATION, MUT_BASE, AMT_BASE) \
605
OPERATION(MUT_BASE + 0, AMT_BASE + 0) \
606
OPERATION(MUT_BASE + 1, AMT_BASE + 1)
607
608
#define EVT_VEC3_VOP(OPERATION, MUT_BASE, AMT_BASE) \
609
OPERATION(MUT_BASE + 0, AMT_BASE + 0) \
610
OPERATION(MUT_BASE + 1, AMT_BASE + 1) \
611
OPERATION(MUT_BASE + 2, AMT_BASE + 2)
612
613
#define EVT_VEC2I_SET(baseVar, x, y) EVT_VEC2_OP(Set, baseVar, x, y)
614
#define EVT_VEC2F_SET(baseVar, x, y) EVT_VEC2_OP(SetF, baseVar, x, y)
615
#define EVT_VEC3I_SET(baseVar, x, y, z) EVT_VEC3_OP(Set, baseVar, x, y, z)
616
#define EVT_VEC3F_SET(baseVar, x, y, z) EVT_VEC3_OP(SetF, baseVar, x, y, z)
617
618
#define EVT_VEC2I_VSET(baseVar, baseSrc) EVT_VEC2_VOP(Set, baseVar, baseSrc)
619
#define EVT_VEC2F_VSET(baseVar, baseSrc) EVT_VEC2_VOP(SetF, baseVar, baseSrc)
620
#define EVT_VEC3I_VSET(baseVar, baseSrc) EVT_VEC3_VOP(Set, baseVar, baseSrc)
621
#define EVT_VEC3F_VSET(baseVar, baseSrc) EVT_VEC3_VOP(SetF, baseVar, baseSrc)
622
623
#define EVT_VEC2I_ADD(baseVar, x, y) EVT_VEC2_OP(Add, baseVar, x, y)
624
#define EVT_VEC2F_ADD(baseVar, x, y) EVT_VEC2_OP(AddF, baseVar, x, y)
625
#define EVT_VEC3I_ADD(baseVar, x, y, z) EVT_VEC3_OP(Add, baseVar, x, y, z)
626
#define EVT_VEC3F_ADD(baseVar, x, y, z) EVT_VEC3_OP(AddF, baseVar, x, y, z)
627
628
#define EVT_VEC2I_VADD(baseVar, baseAmt) EVT_VEC2_VOP(Add, baseVar, baseAmt)
629
#define EVT_VEC2F_VADD(baseVar, baseAmt) EVT_VEC2_VOP(AddF, baseVar, baseAmt)
630
#define EVT_VEC3I_VADD(baseVar, baseAmt) EVT_VEC3_VOP(Add, baseVar, baseAmt)
631
#define EVT_VEC3F_VADD(baseVar, baseAmt) EVT_VEC3_VOP(AddF, baseVar, baseAmt)
632
633
#define EVT_VEC2I_SUB(baseVar, x, y) EVT_VEC2_OP(Sub, baseVar, x, y)
634
#define EVT_VEC2F_SUB(baseVar, x, y) EVT_VEC2_OP(SubF, baseVar, x, y)
635
#define EVT_VEC3I_SUB(baseVar, x, y, z) EVT_VEC3_OP(Sub, baseVar, x, y, z)
636
#define EVT_VEC3F_SUB(baseVar, x, y, z) EVT_VEC3_OP(SubF, baseVar, x, y, z)
637
638
#define EVT_VEC2I_VSUB(baseVar, baseAmt) EVT_VEC2_VOP(Sub, baseVar, baseAmt)
639
#define EVT_VEC2F_VSUB(baseVar, baseAmt) EVT_VEC2_VOP(SubF, baseVar, baseAmt)
640
#define EVT_VEC3I_VSUB(baseVar, baseAmt) EVT_VEC3_VOP(Sub, baseVar, baseAmt)
641
#define EVT_VEC3F_VSUB(baseVar, baseAmt) EVT_VEC3_VOP(SubF, baseVar, baseAmt)
642
643
/****** COMMON SCRIPTS ************************************************************************************************/
644
645
#define IfTrue(b) IfNe(b, 0)
646
#define IfFalse(b) IfEq(b, 0)
647
648
#define EVT_EXIT_WALK(walkDistance, exitIdx, map, entryIdx) \
649
{ \
650
SetGroup(EVT_GROUP_EXIT_MAP) \
651
Call(DisablePlayerInput, TRUE) \
652
Call(UseExitHeading, walkDistance, exitIdx) \
653
Exec(ExitWalk) \
654
Call(GotoMap, Ref(map), entryIdx) \
655
Wait(100) \
656
Return \
657
End \
658
}
659
660
// alternate version of EVT_EXIT_WALK used on Pleasant Path which does not join EVT_GROUP_EXIT_MAP
661
#define EVT_EXIT_WALK_NOK(walkDistance, exitIdx, map, entryIdx) \
662
{ \
663
Call(UseExitHeading, walkDistance, exitIdx) \
664
Exec(ExitWalk) \
665
Call(GotoMap, Ref(map), entryIdx) \
666
Wait(100) \
667
Return \
668
End \
669
}
670
671
#define EVT_EXIT_SINGLE_DOOR(exitIdx, map, entryIdx, colliderID, modelID, swingDir) \
672
{ \
673
SetGroup(EVT_GROUP_EXIT_MAP) \
674
Call(DisablePlayerInput, TRUE) \
675
Set(LVar0, exitIdx) \
676
Set(LVar1, colliderID) \
677
Set(LVar2, modelID) \
678
Set(LVar3, swingDir) \
679
Exec(ExitSingleDoor) \
680
Wait(17) \
681
Call(GotoMap, Ref(map), entryIdx) \
682
Wait(100) \
683
Return \
684
End \
685
}
686
687
#define EVT_EXIT_SINGLE_DOOR_SET_SOUNDS(exitIdx, map, entryIdx, colliderID, modelID, swingDir, sounds) \
688
{ \
689
SetGroup(EVT_GROUP_EXIT_MAP) \
690
Call(DisablePlayerInput, TRUE) \
691
Call(UseDoorSounds, sounds) \
692
Set(LVar0, exitIdx) \
693
Set(LVar1, colliderID) \
694
Set(LVar2, modelID) \
695
Set(LVar3, swingDir) \
696
Exec(ExitSingleDoor) \
697
Wait(17) \
698
Call(GotoMap, Ref(map), entryIdx) \
699
Wait(100) \
700
Return \
701
End \
702
}
703
704
#define EVT_EXIT_SPLIT_SINGLE_DOOR(exitIdx, map, entryIdx, colliderID, topModelID, bottomModelID, swingDir) \
705
{ \
706
SetGroup(EVT_GROUP_EXIT_MAP) \
707
Call(DisablePlayerInput, TRUE) \
708
Set(LVar0, exitIdx) \
709
Set(LVar1, colliderID) \
710
Set(LVar2, topModelID) \
711
Set(LVar4, bottomModelID) \
712
Set(LVar3, swingDir) \
713
Exec(ExitSplitSingleDoor) \
714
Wait(17) \
715
Call(GotoMap, Ref(map), entryIdx) \
716
Wait(100) \
717
Return \
718
End \
719
}
720
721
#define EVT_EXIT_DOUBLE_DOOR(exitIdx, map, entryIdx, colliderID, leftDoorModelID, rightDoorModelID) \
722
{ \
723
SetGroup(EVT_GROUP_EXIT_MAP) \
724
Call(DisablePlayerInput, TRUE) \
725
Set(LVar0, exitIdx) \
726
Set(LVar1, colliderID) \
727
Set(LVar2, leftDoorModelID) \
728
Set(LVar3, rightDoorModelID) \
729
Exec(ExitDoubleDoor) \
730
Wait(17) \
731
Call(GotoMap, Ref(map), entryIdx) \
732
Wait(100) \
733
Return \
734
End \
735
}
736
737
#define EVT_EXIT_DOUBLE_DOOR_SET_SOUNDS(exitIdx, map, entryIdx, colliderID, leftDoorModelID, rightDoorModelID, sounds) \
738
{ \
739
SetGroup(EVT_GROUP_EXIT_MAP) \
740
Call(DisablePlayerInput, TRUE) \
741
Call(UseDoorSounds, sounds) \
742
Set(LVar0, exitIdx) \
743
Set(LVar1, colliderID) \
744
Set(LVar2, leftDoorModelID) \
745
Set(LVar3, rightDoorModelID) \
746
Exec(ExitDoubleDoor) \
747
Wait(17) \
748
Call(GotoMap, Ref(map), entryIdx) \
749
Wait(100) \
750
Return \
751
End \
752
}
753
758
#define EVT_SETUP_CAMERA_DEFAULT(r, g, b) \
759
Call(SetCamPerspective, CAM_DEFAULT, CAM_UPDATE_FROM_ZONE, 25, 16, 4096) \
760
Call(SetCamBGColor, CAM_DEFAULT, r, g, b) \
761
Call(SetCamEnabled, CAM_DEFAULT, TRUE)
762
767
#define EVT_SETUP_CAMERA_NO_LEAD(r, g, b) \
768
Call(SetCamPerspective, CAM_DEFAULT, CAM_UPDATE_FROM_ZONE, 25, 16, 4096) \
769
Call(SetCamBGColor, CAM_DEFAULT, r, g, b) \
770
Call(SetCamLeadPlayer, CAM_DEFAULT, FALSE) \
771
Call(SetCamEnabled, CAM_DEFAULT, TRUE)
772
774
#define EVT_SETUP_CAMERA_MIM() \
775
Call(SetCamPerspective, CAM_DEFAULT, CAM_UPDATE_FROM_ZONE, 25, 16, 650) \
776
Call(SetCamBGColor, CAM_DEFAULT, 0, 0, 0) \
777
Call(SetCamLeadPlayer, CAM_DEFAULT, FALSE) \
778
Call(SetCamEnabled, CAM_DEFAULT, TRUE)
779
780
// allow macros with variable number of arguments
781
// see https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
782
// solution provided by R1tschY and edited by Gabriel Staples
783
#define __NARG__(args...) \
784
__NARG_I_(args,__RSEQ_N())
785
#define __NARG_I_(args...) \
786
__ARG_N(args)
787
#define __ARG_N( \
788
_1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
789
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
790
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
791
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
792
_41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
793
_51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
794
_61,_62,_63,N,...) N
795
#define __RSEQ_N() \
796
63,62,61,60, \
797
59,58,57,56,55,54,53,52,51,50, \
798
49,48,47,46,45,44,43,42,41,40, \
799
39,38,37,36,35,34,33,32,31,30, \
800
29,28,27,26,25,24,23,22,21,20, \
801
19,18,17,16,15,14,13,12,11,10, \
802
9,8,7,6,5,4,3,2,1,0
803
#define _VFUNC_(name, n) name##n
804
#define _VFUNC(name, n) _VFUNC_(name, n)
805
#define VFUNC(func, args...) _VFUNC(func, __NARG__(args)) (args)
806
807
#define PlayEffect(args...) VFUNC(PlayEffect, args)
808
#define PlayEffect1(effect) \
809
Call(PlayEffect_impl, effect, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
810
#define PlayEffect2(effect, subtype) \
811
Call(PlayEffect_impl, effect, subtype, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
812
#define PlayEffect3(effect, subtype, a) \
813
Call(PlayEffect_impl, effect, subtype, a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
814
#define PlayEffect4(effect, subtype, a, b) \
815
Call(PlayEffect_impl, effect, subtype, a, b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
816
#define PlayEffect5(effect, subtype, a, b, c) \
817
Call(PlayEffect_impl, effect, subtype, a, b, c, 0, 0, 0, 0, 0, 0, 0, 0, 0)
818
#define PlayEffect6(effect, subtype, a, b, c, d) \
819
Call(PlayEffect_impl, effect, subtype, a, b, c, d, 0, 0, 0, 0, 0, 0, 0, 0)
820
#define PlayEffect7(effect, subtype, a, b, c, d, e) \
821
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, 0, 0, 0, 0, 0, 0, 0)
822
#define PlayEffect8(effect, subtype, a, b, c, d, e, f) \
823
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, 0, 0, 0, 0, 0, 0)
824
#define PlayEffect9(effect, subtype, a, b, c, d, e, f, g) \
825
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, g, 0, 0, 0, 0, 0)
826
#define PlayEffect10(effect, subtype, a, b, c, d, e, f, g, h) \
827
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, g, h, 0, 0, 0, 0)
828
#define PlayEffect11(effect, subtype, a, b, c, d, e, f, g, h, i) \
829
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, g, h, i, 0, 0, 0)
830
#define PlayEffect12(effect, subtype, a, b, c, d, e, f, g, h, i, j) \
831
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, g, h, i, j, 0, 0)
832
#define PlayEffect13(effect, subtype, a, b, c, d, e, f, g, h, i, j, k) \
833
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, g, h, i, j, k, 0)
834
#define PlayEffect14(effect, subtype, a, b, c, d, e, f, g, h, i, j, k, l) \
835
Call(PlayEffect_impl, effect, subtype, a, b, c, d, e, f, g, h, i, j, k, l)
836
837
#ifdef _LANGUAGE_C_PLUS_PLUS
838
}
839
#endif
840
841
#endif
evt.h
include
script_api
macros.h
Generated by
1.10.0