• Opcode: 0x090
  • Short name: CTURN
  • Long name: Turn to face character

Argument

none

Stack

Entity ID to face

Duration of turn (frames)

CTURN

Description

Make this entity turn to face another entity over a number of frames. The handler pops the duration first (stored at entity+578) and the target entity’s script id second; it resolves that entity and computes the angle from this entity toward it, storing that as the target facing (entity+478) and the current facing as the start angle (entity+476). If it already faces the target it returns 2 immediately; otherwise it marks the turn active (entity+580 = 2), forces the shortest rotational path (wrapping the target by ±256 when the distance exceeds half the 256-unit circle) and returns 1 until the turn finishes.

The entity-id parameter is normally set with PSHAC.

PC handler: SCRIPT_CTURN.

Function addresses

Function Address Description
SCRIPT_CTURN 0x527690 Field script opcode handler (verified IDA function)