Skip to content

Commit

Permalink
Make EVT macros easier to read and write (#1154)
Browse files Browse the repository at this point in the history
* fix rename.py

* update doxygen EVT_CALL->Call

* support passing files to rename.py

* remove EVT macro prefix and make them PascalCase

* rename PlayEffect function to PlayEffect_impl so it doesn't conflict with macro

* dead_PlayEffect_impl
  • Loading branch information
bates64 authored Jan 21, 2024
1 parent f1edb83 commit 9574bae
Show file tree
Hide file tree
Showing 2,350 changed files with 260,008 additions and 259,894 deletions.
4 changes: 2 additions & 2 deletions docs/doxytheme/theme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Make @evtapi prototype use EVT_CALL and params
// Make @evtapi prototype use Call and params
for (const item of document.querySelectorAll(".memitem:has(.evtapi)")) {
// <a id="..." /> appears 2 children before item
const id = item.previousElementSibling.previousElementSibling.id
Expand All @@ -12,7 +12,7 @@ for (const item of document.querySelectorAll(".memitem:has(.evtapi)")) {
params.push(param.textContent.trim())
}

const proto = `EVT_CALL(${params.join(", ")})`
const proto = `Call(${params.join(", ")})`
tbody.innerHTML = `<tr>${proto}</tr>`

// Find its link
Expand Down
2 changes: 1 addition & 1 deletion include/dead.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
#define SetMusicTrack dead_SetMusicTrack
#define FadeInMusic dead_FadeInMusic
#define RandInt dead_RandInt
#define PlayEffect dead_PlayEffect
#define PlayEffect_impl dead_PlayEffect_impl
#define DisablePlayerInput dead_DisablePlayerInput
#define ModifyColliderFlags dead_ModifyColliderFlags
#define PlayerMoveTo dead_PlayerMoveTo
Expand Down
5 changes: 3 additions & 2 deletions include/script_api/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,8 @@ API_CALLABLE(ShowSleepBubble);
API_CALLABLE(SetSleepBubbleTimeLeft);

/// @evtapi
API_CALLABLE(PlayEffect);
/// @see PlayEffect
API_CALLABLE(PlayEffect_impl);

/// @}

Expand Down Expand Up @@ -1325,7 +1326,7 @@ API_CALLABLE(AssignPanelFlag);
/// @evtapi
API_CALLABLE(AssignCrateFlag);

/// Removes a trigger previously bound with \ref EVT_BIND_TRIGGER.
/// Removes a trigger previously bound with \ref BindTrigger.
/// @evtapi
/// @param triggerPtr
API_CALLABLE(DeleteTrigger);
Expand Down
554 changes: 277 additions & 277 deletions include/script_api/macros.h

Large diffs are not rendered by default.

138 changes: 69 additions & 69 deletions src/38F00.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,84 @@ API_CALLABLE(func_8005DD54);
API_CALLABLE(func_8005DDF0);

EvtScript EVS_800936C0 = {
EVT_CALL(func_8005DB00)
EVT_RETURN
EVT_END
Call(func_8005DB00)
Return
End
};

EvtScript EVS_NpcHitRecoil = {
EVT_CALL(SetNpcAnimation, NPC_SELF, LVar0)
EVT_CALL(GetNpcPos, NPC_SELF, LVar0, LVar3, LVar2)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 1)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 4)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 16)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 8)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 20)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 8)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 12)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 6)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_SET(LVar1, LVar3)
EVT_ADD(LVar1, 0)
EVT_CALL(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
EVT_WAIT(1)
EVT_RETURN
EVT_END
Call(SetNpcAnimation, NPC_SELF, LVar0)
Call(GetNpcPos, NPC_SELF, LVar0, LVar3, LVar2)
Set(LVar1, LVar3)
Add(LVar1, 1)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 4)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 16)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 8)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 20)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 8)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 12)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 6)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Set(LVar1, LVar3)
Add(LVar1, 0)
Call(SetNpcPos, NPC_SELF, LVar0, LVar1, LVar2)
Wait(1)
Return
End
};

EvtScript D_800939A4 = {
EVT_RETURN
EVT_END
Return
End
};

EvtScript D_800939B4 = {
EVT_CALL(GetSelfVar, 0, LVar0)
EVT_IF_EQ(LVar0, 0)
EVT_CALL(SetSelfVar, 0, 1)
EVT_CALL(BindNpcAI, NPC_SELF, EVT_PTR(D_800939A4))
EVT_CALL(SetNpcFlagBits, NPC_SELF, NPC_FLAG_GRAVITY | NPC_FLAG_IGNORE_CAMERA_FOR_YAW, TRUE)
EVT_CALL(SetNpcFlagBits, NPC_SELF, NPC_FLAG_FLYING | NPC_FLAG_JUMPING, FALSE)
EVT_CALL(SetNpcAnimation, NPC_SELF, LVar2)
EVT_SET(LVar0, 0)
EVT_LOOP(30)
EVT_CALL(SetNpcRotation, NPC_SELF, 0, LVar0, 0)
EVT_CALL(func_8005DD54)
EVT_CALL(SetNpcImgFXParams, NPC_SELF, IMGFX_SET_COLOR, LVar2, LVar2, LVar2, 0)
EVT_ADD(LVar0, 30)
EVT_WAIT(1)
EVT_END_LOOP
EVT_CALL(SetNpcRotation, NPC_SELF, 0, 0, 0)
EVT_CALL(SetNpcImgFXParams, NPC_SELF, IMGFX_SET_COLOR, 255, 255, 255, 0)
EVT_CALL(SetNpcFlagBits, NPC_SELF, NPC_FLAG_IGNORE_CAMERA_FOR_YAW, FALSE)
EVT_CALL(SetSelfVar, 0, 0)
EVT_CALL(func_8005DDF0)
EVT_CALL(BindNpcAI, NPC_SELF, LVar1)
EVT_END_IF
EVT_RETURN
EVT_END
Call(GetSelfVar, 0, LVar0)
IfEq(LVar0, 0)
Call(SetSelfVar, 0, 1)
Call(BindNpcAI, NPC_SELF, Ref(D_800939A4))
Call(SetNpcFlagBits, NPC_SELF, NPC_FLAG_GRAVITY | NPC_FLAG_IGNORE_CAMERA_FOR_YAW, TRUE)
Call(SetNpcFlagBits, NPC_SELF, NPC_FLAG_FLYING | NPC_FLAG_JUMPING, FALSE)
Call(SetNpcAnimation, NPC_SELF, LVar2)
Set(LVar0, 0)
Loop(30)
Call(SetNpcRotation, NPC_SELF, 0, LVar0, 0)
Call(func_8005DD54)
Call(SetNpcImgFXParams, NPC_SELF, IMGFX_SET_COLOR, LVar2, LVar2, LVar2, 0)
Add(LVar0, 30)
Wait(1)
EndLoop
Call(SetNpcRotation, NPC_SELF, 0, 0, 0)
Call(SetNpcImgFXParams, NPC_SELF, IMGFX_SET_COLOR, 255, 255, 255, 0)
Call(SetNpcFlagBits, NPC_SELF, NPC_FLAG_IGNORE_CAMERA_FOR_YAW, FALSE)
Call(SetSelfVar, 0, 0)
Call(func_8005DDF0)
Call(BindNpcAI, NPC_SELF, LVar1)
EndIf
Return
End
};

API_CALLABLE(func_8005DB00) {
Expand Down
80 changes: 40 additions & 40 deletions src/battle/16C8E0.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,49 +51,49 @@ HudScript* bHPDigitHudScripts[] = {
s32 BattleScreenFadeAmt = 255;

EvtScript BtlPutPartnerAway = {
EVT_CALL(DispatchEvent, ACTOR_PARTNER, EVENT_PUT_PARTNER_AWAY)
EVT_CHILD_THREAD
EVT_SETF(LVar0, EVT_FLOAT(1.0))
EVT_LOOP(10)
EVT_CALL(SetActorScale, ACTOR_PARTNER, LVar0, LVar0, EVT_FLOAT(1.0))
EVT_SUBF(LVar0, EVT_FLOAT(0.1))
EVT_WAIT(1)
EVT_END_LOOP
EVT_END_CHILD_THREAD
EVT_CALL(EnablePartnerBlur)
EVT_CALL(PlaySoundAtActor, 0, SOUND_PARTNER_GET_OUT)
EVT_CALL(GetActorPos, 0, LVar0, LVar1, LVar2)
EVT_ADD(LVar1, 25)
EVT_CALL(SetActorJumpGravity, ACTOR_PARTNER, EVT_FLOAT(1.0))
EVT_CALL(SetGoalPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
EVT_CALL(JumpToGoal, ACTOR_PARTNER, 10, 0, 0, 1)
EVT_CALL(DisablePartnerBlur)
EVT_RETURN
EVT_END
Call(DispatchEvent, ACTOR_PARTNER, EVENT_PUT_PARTNER_AWAY)
ChildThread
SetF(LVar0, Float(1.0))
Loop(10)
Call(SetActorScale, ACTOR_PARTNER, LVar0, LVar0, Float(1.0))
SubF(LVar0, Float(0.1))
Wait(1)
EndLoop
EndChildThread
Call(EnablePartnerBlur)
Call(PlaySoundAtActor, 0, SOUND_PARTNER_GET_OUT)
Call(GetActorPos, 0, LVar0, LVar1, LVar2)
Add(LVar1, 25)
Call(SetActorJumpGravity, ACTOR_PARTNER, Float(1.0))
Call(SetGoalPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
Call(JumpToGoal, ACTOR_PARTNER, 10, 0, 0, 1)
Call(DisablePartnerBlur)
Return
End
};

EvtScript BtlBringPartnerOut = {
EVT_CHILD_THREAD
EVT_SETF(LVar0, EVT_FLOAT(0.1))
EVT_LOOP(20)
EVT_CALL(SetActorScale, ACTOR_PARTNER, LVar0, LVar0, EVT_FLOAT(1.0))
EVT_ADDF(LVar0, EVT_FLOAT(0.05))
EVT_WAIT(1)
EVT_END_LOOP
EVT_CALL(SetActorScale, ACTOR_PARTNER, EVT_FLOAT(1.0), EVT_FLOAT(1.0), EVT_FLOAT(1.0))
EVT_END_CHILD_THREAD
EVT_CALL(PlaySoundAtActor, 0, SOUND_PARTNER_PUT_AWAY)
EVT_CALL(GetGoalPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
EVT_CALL(SetActorJumpGravity, ACTOR_PARTNER, EVT_FLOAT(1.0))
EVT_IF_EQ(LVar1, 0)
EVT_CALL(JumpToGoal, ACTOR_PARTNER, 20, 0, 0, 1)
EVT_ELSE
EVT_CALL(JumpToGoal, ACTOR_PARTNER, 20, 0, 0, 1)
EVT_END_IF
EVT_CALL(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
EVT_CALL(ForceHomePos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
EVT_RETURN
EVT_END
ChildThread
SetF(LVar0, Float(0.1))
Loop(20)
Call(SetActorScale, ACTOR_PARTNER, LVar0, LVar0, Float(1.0))
AddF(LVar0, Float(0.05))
Wait(1)
EndLoop
Call(SetActorScale, ACTOR_PARTNER, Float(1.0), Float(1.0), Float(1.0))
EndChildThread
Call(PlaySoundAtActor, 0, SOUND_PARTNER_PUT_AWAY)
Call(GetGoalPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
Call(SetActorJumpGravity, ACTOR_PARTNER, Float(1.0))
IfEq(LVar1, 0)
Call(JumpToGoal, ACTOR_PARTNER, 20, 0, 0, 1)
Else
Call(JumpToGoal, ACTOR_PARTNER, 20, 0, 0, 1)
EndIf
Call(GetActorPos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
Call(ForceHomePos, ACTOR_PARTNER, LVar0, LVar1, LVar2)
Return
End
};

extern HudScript HES_HPBar;
Expand Down
Loading

0 comments on commit 9574bae

Please sign in to comment.