Skip to content

WIP: Player fields for camera modding

Kays Ishaq requested to merge kays/SRB2:camera-options into next

modcameranoclip, modchasecam, modcamspeed, modcamstill, modcamorbit, modcamrotate, modcamdist, modcamheight

For each, the two most significant bits are occupied by a flag (masked by CF_FLAGMASK) to determine how to apply the modded value:

CF_SET (1<<30): Use this value instead of the cvar

CF_ADD (2<<30): Add this value to the cvar

CF_SCALE (3<<30): Multiply this value by the cvar

(For booleans, there's no difference between the three flags)

The remaining 30 bits (masked by CF_VALUEMASK) are the actual value, shifted to the right by CF_VALUESHIFT (2 bits). Booleans are not shifted. e.g., to scale camera distance by a factor of two, player->modcamdist would be set to CF_SCALE | ((2*FRACUNIT)>>CF_VALUESHIFT). To force the camera to noclip, player->modcameranoclip would be set to CF_SET | 1.

P_SetModCam is a Lua exclusive function to handle the bitwise math:

P_SetModCam(player, "modcameranoclip", CF_SET, true)```

WIP because I'd like to use these to implement a less jank camera scanner effect than the one we have now

Merge request reports