Anonymous

Changes

From Final Fantasy Inside

FF7/Field/Script/Opcodes/C3 OFST

726 bytes added, 13:01, 18 October 2022
no edit summary
* '''const Short''' ''Y'': Y offset amount, relative to current position, or address to find Y offset, if ''B2'' is non-zero.
* '''const Short''' ''Z'': Z offset amount, relative to current position, or address to find Z offset, if ''B3'' is non-zero.
* '''const UShort''' ''S'': Speed Step-count of the offset movement, if type is non-zero, or address to find speed, if ''B4'' is non-zero.
==== Description ====
If B1, B2, B3 or B4 is non-zero, then the value for that particular component is taken from memory using the corresponding bank and address specified, rather than as a literal value. Both retrieved values and literals can be used for different components. If using ''T'', ''X'', ''Y'' or ''S'' as addresses, the lower byte should hold the address whilst the higher byte should be zero.
The amount to offset is specified relative to the current position. If '''T'''ype is specified, the object moves gradually from its current point to the offset position; this can be used to simulate movements such as elevators. Any type outside the range in the table will cause the offset not to occur.  If the object is set to move gradually, then the speed number of offset steps to use to reach the destination can be set; . The current step is incremented by one as the movement progresses. The ratio of the current step to total steps is used to determine the current progress through the movement, so the greater the numberof steps, the slower the object moves to toward its target offset. In the case of linear movement, a simple linear interpolation is used : current position = start position + total distance * current step / total steps. In the case of smooth movement, a cosine function is used to simulate "ease-in" and "ease-out" of the perceived speed : current position = start position + total distance * ((cos(π * current step / total steps + π) + 1) / 2) For the sake of speed, the above calculations are done using look-up tables and fixed-point arithmetic.
Script execution may also be halted until the gradual offset has been completed. For this, see [[FF7/Field/Script/Opcodes/C4 OFSTW|OFSTW]].
10
edits