-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arbitrary trainer scripts + on frame/trigger softlock prevention #5033
Arbitrary trainer scripts + on frame/trigger softlock prevention #5033
Conversation
There's obviously a comparison to be drawn between point 3 and ghoulslash's The small difference is that this PR puts the check to see if the script should run inside the script (via A consequence of punning the flag is iiuc that flags 1-3 are treated as trainer types, meaning that I personally prefer the design in this branch—if a user has a script that doesn't start with |
2c04041
to
1eb51c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a bit of this is out of my league, but some preliminary thoughts before other people review this
EDIT: special flags are no longer supported due to the issue mentioned at the bottom of this message. Oh, to quickly justify why I think that special vars, special flags, and string buffers do not count as player-visible but everything else does:
I think you could argue that special flags shouldn't be counted as non-visible, e.g. |
Temporarily marked as draft to give myself time to think about Deokishisu's comments on Discord. |
Script_RunImmediatelyUntilEffect runs a script until either a specified effect may occur or it reaches an end. All existing script commands now call Script_RequestEffects which allow us to analyze them. Any downstream script commands will be statically known not to call Script_RequestEffects and treated as if they have all effects. Specials and natives are also able to opt-in to Script_RequestEffects. Using these, we're able to execute scripts until they either exit with no effect, or would possibly have an effect. This allows us to: 1. Not run on frame map scripts or triggers if they would have no effect. 2. Immediately run triggers if they only affect flags/vars. This removes the lag frames when biking into the Cycling Road, for example. 3. Support arbitrary control flow in trainer scripts. The trainer does not see the player if the script has no effect, and the trainer will use whichever trainerbattle command is branched to. 4. Support arbitrary scripts in trainer scripts. cant_see and cant_see_if_* commands have been introduced so that scripts are able to do something when the player interacts with the trainer even if that trainer wouldn't see them.
6f8c414
to
8a7553a
Compare
I've changed how analysis works to account for these—in addition to This allows the player to move through the Cycling Road gate without losing any momentum on their bike. |
The reason why there's a version number (
|
On load / on transition / on resume / on return to field / on dive warp softlock prevention.
ty Egg! I'll squash this so I can get a proper commit message written :) |
RunScriptImmediatelyUntilEffect
runs a script until it either exits withend
/return
, or would have an effect. The possible effects are:SCREFF_SAVE
an effect on the save (so a write to anything ingSaveBlock1
/gSaveBlock2
/gSaveBlock3
/gPokemonStorage
/etc).SCREFF_HARDWARE
an effect on the hardware registers (e.g. playing a sound, displaying graphics, waiting for a button input, etc).SCREFF_TRAINERBATTLE
literally just thetrainerbattle
command.Opcodes have been manually tagged with whether they call
Script_RequestEffects
to warn about the effects they would have if executed. Natives and specials can be tagged too (and a few have been).Using these, we're able to:
Migrate on load/on transition/on resume/on return to field/on dive warp scripts onto the global script context if they would block (approximated via(Currently broken—reverted by Revert #5033 change to MapHeaderRunScriptType #5975)SCREFF_HARDWARE
).trainerbattle
command is branched to.cant_see
andcant_see_if_*
commands have been introduced so that scripts are able to do something when the player interacts with the trainer even if that trainer wouldn't see them.Things to note in the release changelog:
No script which was correctly written before this PR should have changed behavior after it (if you find an instance, it's either an incorrect script or a bug in this PR).
Script commands, targets of
callnative
, and specials need to be tagged withrequests_effects=1
and callScript_RequestEffects
before performing those effects to be supported byRunScriptImmediatelyUntilEffect
/Script_HasNoEffect
/trainer sight.If your code has no effects, it must call
Script_RequestEffects(SCREFF_V1);
to make that explicit.