Last time we looked at match scripts which were the highest level scripts controlling opponents in Punch-Out. The basic function of a match script was to sequence opponent behaviors throughout the fight. Today we’ll dive into behavior scripts which are where those behaviors are actually implemented.

The following video shows an interpretation of what the behavior script for Piston Honda 1 might look like in something like plain English commands.

﻿

Animation Commands

Behavior scripts are in charge of sequencing animations in much the same way that match scripts were in charge of sequencing behaviors. The anim command plays a single specific animation, and the anim_rnd command plays an animation randomly selected from a list of 8 options. In the video above, whenever a random selection is made from a list of options, the chosen option is briefly highlighted in red. When Piston Honda throws his opening 2 jabs, he is using anim for each one. After that, he uses anim_rnd to randomly pick from a set containing 6 hook animations, and 2 empty animations. The result is that his third action will be to throw a hook 75% of time time, and to do nothing 25% of the time.

Animations will be played back synchronously from the point of view of the behavior script since the script interpreter is paused any time the animation system is not in its idle state.

Flow Control Commands

There are a few commands available to modify the execution of the behavior script itself. The pause commands can pause script execution for a specific number of frames, or a number of frames randomly chosen from a list of 2 options.

There are various branch commands available that optionally jump to a different part of the behavior script if certain conditions are met. The branch_rnd command has a specified probability that the branch will be taken each time it is executed. A special case of the probabilistic branch is branch_always which has a 100% chance of branching.

There is a simple looping mechanism built in to the behavior script interpreter that can be used to repeat sections of script a certain number of times. The set_loop_count command sets the current value of the loop counter. Then, each time the branch_while_loop command is executed, it decrements the loop counter by one and branches only if the counter is still above zero.

The final kind of branch checks the contents of memory to decide whether or not to take the branch. Piston Honda uses this branch_mem_test command to check if his most recent punch connected during his special behavior. Any time his punch connects, he branches directly to the next punch. If a punch does not connect, he uses a branch_while_loop command to keep punching only until he accumulates 5 failed punches.

Behavior Commands

There are 2 commands that behavior scripts can use to control the behavior system itself. The begin_behavior_main command is used to end whatever behavior is currently running and begin running the main behavior. This is different from a branch within the behavior script because the section of script that is considered to be the current “main” behavior can be changed during the course of the match by the match script (see the previous post about match scripts.)

The other command related to behavior is enable_behavior_change . Whenever a new behavior begins, it starts off in a locked state where any further requests to change behavior will be blocked. By using the enable_behavior_change command, the script is signaling that it is ready to allow other behaviors to happen. For example, in Piston Honda’s special behavior, the enable_behavior_change command is never executed and so if Mac gets tired during that time, the special behavior will continue to run. Knock down events will bypass this system however so if Mac gets knocked down during Piston Honda’s special, a behavior change will happen no matter what.

Up Next

With match script and behavior script out of the way, the final piece of the opponent script hierarchy puzzle is animation script. These are very low level scripts with a rich command set that run to implement the animations that the behavior scripts have been requesting. If you have any questions or comments, or you want to know when these (very infrequent) blog posts go up, please feel free to contact me on twitter @allan_blomquist

(Prev – This is part 4 of a series)