Cavestory Mod API
Demos

Create & manipulate game demos. More...

enum  PXDEMO_EVENT_TYPE : unsigned char {
  PXDET_INVALID_EVENT = 0 , PXDET_SET_PLAYER_STATE = 1 , PXDET_SET_STAGE = 2 , PXDET_SET_RANDOM_SEED = 3 ,
  PXDET_SET_NPC_STATE = 4 , PXDET_DO_SCREEN_FADE = 5 , PXDET_SET_CAMERA = 6 , PXDET_SET_TIMER = 7 ,
  PXDET_SET_NPC_DATA = 8 , PXDET_SET_MAP_TILE = 9 , PXDET_MAX_EVENTS
}
 GameDemo Event Types. More...
 
enum  PXDEMO_FADE_TYPE : unsigned char { PXDFT_CLEAR_FADE = 0 , PXDFT_FADE_IN = 1 , PXDFT_FADE_OUT = 2 , PXDFT_MAX_FADES }
 Fade effect types. More...
 
enum  PXDEMO_PLAYERSTATE_CHANGE : unsigned int {
  PXDPSC_cond = 0x00000001 , PXDPSC_x = 0x00000002 , PXDPSC_y = 0x00000004 , PXDPSC_xm = 0x00000008 ,
  PXDPSC_ym = 0x00000010 , PXDPSC_life = 0x00000020 , PXDPSC_max_life = 0x00000040 , PXDPSC_input_flags = 0x00000080 ,
  PXDPSC_input_flags_trg = 0x00000100 , PXDPSC_weapon_code = 0x00000200 , PXDPSC_weapon_ammo = 0x00000400 , PXDPSC_weapon_max_ammo = 0x00000800 ,
  PXDPSC_weapon_level = 0x00001000 , PXDPSC_weapon_exp = 0x00002000 , PXDPSC_selectedArms = 0x00004000 , PXDPSC_direct = 0x00008000 ,
  PXDPSC_ani_no = 0x00010000 , PXDPSC_ani_wait = 0x00020000 , PXDPSC_equip = 0x00040000 , PXDPSC_star = 0x00080000 ,
  PXDPSC_shock = 0x00100000 , PXDPSC_netanim = 0x00200000 , PXDPSC_physics_normal = 0x00400000 , PXDPSC_physics_underwater = 0x00800000 ,
  PXDPSC_ignore_water = 0x01000000 , PXDPSC_boost_sw = 0x02000000 , PXDPSC_boost_cnt = 0x04000000 , PXDPSC_flag = 0x08000000 ,
  PXDPSC_updown = 0x10000000 , PXDPSC_counts = 0x20000000 , PXDPSC_act_wait = 0x40000000 , PXDPSC_act_no = 0x80000000 ,
  PXDPSC_ALL_FLAGS = 0xFFFFFFFF , PXDPSC_COUNT = 34 + (8 * 2) , PXDPSC_UNIQUE_COUNT = PXDPSC_COUNT - ((8 * 2) + 1) , PXDPSC_BIGGEST_TYPE = sizeof(MYCHAR_PHYSICS)
}
 Changed playerstate variables between frames. More...
 
CAVESTORY_MOD_API GAME_DEMO_STATEgRecordingDemo
 A pointer to the current recording demo. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Link (GAME_DEMO_STATE *pState)
 Register a demo to the active linkage list. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Unlink (GAME_DEMO_STATE *pState)
 Unregister a demo from the active linkage list. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_FirstLink (GAME_DEMO_STATE **pFirst)
 Get the first in the gamestate link. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Init (GAME_DEMO_STATE *pState)
 Initialize a GAME_DEMO_STATE object without linking it. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Init_Relink (GAME_DEMO_STATE *pState)
 Initialize a GAME_DEMO_STATE object whilst also re-linking it. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Free (GAME_DEMO_STATE *pState)
 Free a GAME_DEMO_STATE object. More...
 
CAVESTORY_MOD_API int CSM_GameDemo_Load (GAME_DEMO_STATE *pState, const char *pFileName)
 Load a game demo. More...
 
CAVESTORY_MOD_API int CSM_GameDemo_Save (GAME_DEMO_STATE *pState, const char *pFileName)
 Save a game demo. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_CombineDemos (GAME_DEMO_STATE *pDst, GAME_DEMO_STATE *pSource, unsigned int iFrameOffset=0xFFFFFFFF)
 Combine game demos. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Optimize (GAME_DEMO_STATE *pState, bool bSaveAndLoad)
 Optimize a game demo. More...
 
CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCTCSM_GameDemo_Players_Add (GAME_DEMO_STATE *pState, const char *pName, SafeClientInterface *pInterface)
 Add a player to the demo state. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Players_Remove (GAME_DEMO_STATE *pState, const char *pName)
 Remove a player from the demo state. More...
 
CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCTCSM_GameDemo_Players_Find (GAME_DEMO_STATE *pState, const char *pName, int *pIndex=NULL)
 Find a player's object by name. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Events_Add (GAME_DEMO_STATE *pState, PXDEMO_EVENT_TYPE iType, unsigned int iFrameNo, unsigned int iInsertNo=0xFFFFFFFF)
 Add an event to the demo. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Events_Remove (GAME_DEMO_STATE *pState, PXDEMO_EVENT_TYPE iType, int iFrameNo, int iStartIndex=0)
 Remove an event from the demo. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Events_Find (GAME_DEMO_STATE *pState, PXDEMO_EVENT_TYPE iType, int iFrameNo, int iStartIndex=0, PXDEMO_FRAME_STRUCT **pFramePtr=NULL, int *pFrameIndex=NULL, int *pEventIndex=NULL)
 Find an event. More...
 
CAVESTORY_MOD_API PXDEMO_FRAME_STRUCTCSM_GameDemo_Frames_Add (GAME_DEMO_STATE *pState, int iFrameNo)
 Add af rame to the demo. More...
 
CAVESTORY_MOD_API bool CSM_GameDemo_Frames_Remove (GAME_DEMO_STATE *pState, int iFrameNo)
 Remove a frame from the demo. More...
 
CAVESTORY_MOD_API PXDEMO_FRAME_STRUCTCSM_GameDemo_Frames_Find (GAME_DEMO_STATE *pState, int iFrameNo, int *pIndex=NULL)
 Find a frame. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_LoadGamestate (GAME_DEMO_STATE *pState)
 Load a demo's gamestate. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_Act (GAME_DEMO_STATE *pState, bool bFreezeFrame=false, bool bDontDraw=false, bool bDrawHUD=true, bool bDrawFade=true)
 Act for a frame. More...
 
CAVESTORY_MOD_API void CSM_GameDemo_StartRecord ()
 Begin recording a demo.
 
CAVESTORY_MOD_API void CSM_GameDemo_StopRecord (GAME_DEMO_STATE *pState)
 Stop recording a demo. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_PlayerState (GAME_DEMO_STATE *pState, const char *pName, SafeClientInterface *pInterface)
 Record a player's state. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_Stage (GAME_DEMO_STATE *pState)
 Record the current stage index. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_RandomSeed (GAME_DEMO_STATE *pState)
 Record the current random seed. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_NpcState (GAME_DEMO_STATE *pState, NPCHAR *pNpc, int iIndex)
 Record the state of an NPC. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_Fade (GAME_DEMO_STATE *pState, PXDEMO_FADE_TYPE iType, Directions iDirect)
 Record a screen fade. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_Camera (GAME_DEMO_STATE *pState)
 Record the game camera's current details. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_Timer (GAME_DEMO_STATE *pState)
 Record the game's timer. More...
 
CAVESTORY_MOD_API PXDEMO_EVENT_STRUCTCSM_GameDemo_Record_MapTileChange (GAME_DEMO_STATE *pState, unsigned short iTileX, unsigned short iTileY, unsigned int iOldTileID, unsigned int iNewTileID, bool bCreateSmoke, bool bOnlyUndo)
 Record a maptile change. More...
 
CAVESTORY_MOD_API int CSM_GameDemo_Record_NewFrame (GAME_DEMO_STATE *pState)
 Increment the simulated frame count. More...
 
#define NULL_DRAW_FUNC(NAME)
 
#define USE_DRAW_FUNC(NAME)   void __DRAW__##NAME(int, int, MYCHAR*, SafeClientInterface*);
 
#define DECLARE_PLAYER_STATE(NAME, CUSTOM_DRAW)
 
#define NULL_DRAW_FUNC_IMPLEMENT(NAME)
 
#define USE_DRAW_FUNC_IMPLEMENT(NAME)
 
#define IMPLEMENT_PLAYER_STATE(NAME, FLAGS, TRANSMIT_FLAGS, CUSTOM_DRAW, OVERRIDE, ANIMATE_TYPE)
 
#define PROCESS_WATER_SPLASHING()
 When the player hits water, create splash particles. More...
 
#define PROCESS_MOVEMENT_TILES()
 If the player is inside of any wind / water current tiles, move them accordingly. More...
 
#define PROCESS_DAMAGE_TILES()
 If the player is touching damaging map tiles, damage them. More...
 
#define LIMIT_VELOCITY(MULT)
 Limit the player's velocity. More...
 
#define LIMIT_VELOCITY_NORMAL()
 Limit the player's velocity. More...
 
#define IMPLEMENT_PLAYER_STATE_ANIM(NAME)   unsigned int PlayerStates::__ANIMATE__##NAME(BOOL bKey, MYCHAR* pMC, SafeClientInterface* pInterface)
 
#define IMPLEMENT_PLAYER_STATE_ACT(NAME)   void PlayerStates::__ACT__##NAME(BOOL bKey, SafeClientInterface* pInterface, MYCHAR* pMC, const MYCHAR_PHYSICS* physics)
 
#define IMPLEMENT_PLAYER_STATE_DRAW(NAME)   void PlayerStates::__DRAW__##NAME(int iFrameX, int iFrameY, MYCHAR* pMC, SafeClientInterface* pInterface)
 
#define GAMEFLAGS   (*pInterface->mGameFlags)
 
#define KEY   (*pInterface->mKey)
 
#define KEYTRG   (*pInterface->mKeyTrg)
 
#define CLIENT   pInterface->mClient
 
#define ARMS_TABLE   pInterface->mArms
 
#define SELECTED_WEAPON   (*pInterface->mSelectedArms)
 

Detailed Description

Create & manipulate game demos.

These functions assist with creating & manipulating demos. An example of loading a GameDemo:

if (CSM_GameDemo_Load(&pDemo, "demos/MyDemo.pxdemo"))
{
// Do stuff here!
}
CAVESTORY_MOD_API int CSM_GameDemo_Load(GAME_DEMO_STATE *pState, const char *pFileName)
Load a game demo.
CAVESTORY_MOD_API void CSM_GameDemo_Init(GAME_DEMO_STATE *pState)
Initialize a GAME_DEMO_STATE object without linking it.
CAVESTORY_MOD_API void CSM_GameDemo_Free(GAME_DEMO_STATE *pState)
Free a GAME_DEMO_STATE object.
Holds a game demo's state.
Definition: GameDemo.h:727

Macro Definition Documentation

◆ DECLARE_PLAYER_STATE

#define DECLARE_PLAYER_STATE (   NAME,
  CUSTOM_DRAW 
)
Value:
void __ACT__##NAME(BOOL, SafeClientInterface*, MYCHAR*, const MYCHAR_PHYSICS*);\
unsigned int __ANIMATE__##NAME(BOOL, MYCHAR*, SafeClientInterface*);\
static int PLAYER_STATE_##NAME;\
CUSTOM_DRAW(NAME)
Physics specifier for MYCHAR.
Definition: CSMAPI_types.h:1359
Player character object.
Definition: CSMAPI_types.h:1470
SafeClientInterface.
Definition: CSMAPI_types.h:1775

◆ IMPLEMENT_PLAYER_STATE

#define IMPLEMENT_PLAYER_STATE (   NAME,
  FLAGS,
  TRANSMIT_FLAGS,
  CUSTOM_DRAW,
  OVERRIDE,
  ANIMATE_TYPE 
)
Value:
"PLAYER_STATE_" #NAME,\
FLAGS,\
TRANSMIT_FLAGS,\
CUSTOM_DRAW##_IMPLEMENT(NAME),\
&PlayerStates::PLAYER_STATE_##NAME,\
OVERRIDE,\
PlayerStateAnimator_OutputType::PSAOT_##ANIMATE_TYPE\
);
CAVESTORY_MOD_API BOOL CSM_RegisterPlayerState(const char *pStateName, unsigned long long int iFlags, unsigned int iTransmitFlags, PlayerState_ActFuncType pActFunc, PlayerState_AnimFuncType pAnimFunc, PlayerState_DrawFuncType pDrawFunc=NULL, int *pPlayerStateIndex=NULL, unsigned int iIndexOverride=0, PlayerStateAnimator_OutputType iOutputType=PlayerStateAnimator_OutputType::PSAOT_PLAYER_FRAME)
Register a player state.

◆ LIMIT_VELOCITY

#define LIMIT_VELOCITY (   MULT)
Value:
if (pMC->ym > (physics->max_move * MULT))\
pMC->ym = (physics->max_move * MULT);\
if (pMC->ym < -(physics->max_move * MULT))\
pMC->ym = -(physics->max_move * MULT);\
if (pMC->xm > (physics->max_move * MULT))\
pMC->xm = (physics->max_move * MULT);\
if (pMC->xm < -(physics->max_move * MULT))\
pMC->xm = -(physics->max_move * MULT);

Limit the player's velocity.

Use a multiplier, too.

Only use this in implemented playerstate ACT functions.

◆ LIMIT_VELOCITY_NORMAL

#define LIMIT_VELOCITY_NORMAL ( )
Value:
if (pMC->ym > physics->max_move)\
pMC->ym = physics->max_move;\
if (pMC->ym < -physics->max_move)\
pMC->ym = -physics->max_move;\
if (pMC->xm > physics->max_move)\
pMC->xm = physics->max_move;\
if (pMC->xm < -physics->max_move)\
pMC->xm = -physics->max_move;

Limit the player's velocity.

Only use this in implemented playerstate ACT functions.

◆ NULL_DRAW_FUNC_IMPLEMENT

#define NULL_DRAW_FUNC_IMPLEMENT (   NAME)
Value:
PlayerStates::__ACT__##NAME,\
PlayerStates::__ANIMATE__##NAME,\
NULL

◆ PROCESS_DAMAGE_TILES

#define PROCESS_DAMAGE_TILES ( )
Value:
{\
if (!CaveNet::Client::IsConnected() || CaveNet::Server::IsHosting())\
pInterface->DamagePlayer(10);\
}
@ gmc_flag_on_damage_tile
Slope.
Definition: CSMAPI_enums.h:506

If the player is touching damaging map tiles, damage them.

Only use this in implemented playerstate ACT functions.

◆ PROCESS_MOVEMENT_TILES

#define PROCESS_MOVEMENT_TILES ( )
Value:
pMC->xm -= 0x88;\
pMC->ym -= 0x80;\
pMC->xm += 0x88;\
pMC->ym += 0x55;
@ gmc_flag_in_current_up
Wind / water current moving up.
Definition: CSMAPI_enums.h:515
@ gmc_flag_in_current_down
Wind / water current moving down.
Definition: CSMAPI_enums.h:521
@ gmc_flag_in_current_right
Wind / water current moving right.
Definition: CSMAPI_enums.h:518
@ gmc_flag_in_current_left
Wind / water current moving left.
Definition: CSMAPI_enums.h:512

If the player is inside of any wind / water current tiles, move them accordingly.

Only use this in implemented playerstate ACT functions.

◆ PROCESS_WATER_SPLASHING

#define PROCESS_WATER_SPLASHING ( )
Value:
if (!pMC->ignore_water && !pMC->sprash && (pMC->flag & GMC_flag::gmc_flag_on_water_tile)){\
int dir = ((pMC->flag & 0x800) ? 2 : 0);\
if ((pMC->flag & 8) == 0 && pMC->ym > 0x200){for (int a = 0; a < 8; a++){int x = pMC->x + (Random(-8, 8) * 0x200);SetNpChar(73, x, pMC->y, pMC->xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - pMC->ym / 2, dir, 0, 0);}PlaySoundObject(56, 1);}\
else{if (pMC->xm > 0x200 || pMC->xm < -0x200){for (int a = 0; a < 8; a++){int x = pMC->x + (Random(-8, 8) * 0x200);SetNpChar(73, x, pMC->y, pMC->xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, 0, 0);}PlaySoundObject(56, 1);}}\
pMC->sprash = 1;}\
if (!(pMC->flag & 0x100))pMC->sprash = 0;
@ gmc_flag_on_water_tile
Slope.
Definition: CSMAPI_enums.h:503
CAVESTORY_MOD_API void SetNpChar(int iNpcId, int iSpawnX, int iSpawnY, int iVelocityX, int iVelocityY, int iDirection, NPCHAR *pNpc, int iStartIndex, NPCHAR **iOutNPC=0, bool bForceSpawn=false)
Spawn an NPC at the coordinates.
CAVESTORY_MOD_API int Random(int iMin, int iMax)
Get a random value.
CAVESTORY_MOD_API void PlaySoundObject(int iSoundIndex, int iPlayMode=SOUND_MODE_STOP_THEN_PLAY, unsigned int iPlayVolume=0x100)
Play a sound by index.

When the player hits water, create splash particles.

Only use this in implemented playerstate ACT functions.

◆ USE_DRAW_FUNC_IMPLEMENT

#define USE_DRAW_FUNC_IMPLEMENT (   NAME)
Value:
PlayerStates::__ACT__##NAME,\
PlayerStates::__ANIMATE__##NAME,\
PlayerStates::__DRAW__##NAME

Enumeration Type Documentation

◆ PXDEMO_EVENT_TYPE

enum PXDEMO_EVENT_TYPE : unsigned char

GameDemo Event Types.

Enumerator
PXDET_INVALID_EVENT 

Invalid.

PXDET_SET_PLAYER_STATE 

Set the state of a player.

PXDET_SET_STAGE 

Transfer to a new stage.

PXDET_SET_RANDOM_SEED 

Set the random seed.

PXDET_SET_NPC_STATE 

Set an NPC.

PXDET_DO_SCREEN_FADE 

Fade in or fade out the screen.

PXDET_SET_CAMERA 

Set the game camera's details.

PXDET_SET_TIMER 

Set the game timer.

PXDET_SET_NPC_DATA 

Set the game timer.

PXDET_SET_MAP_TILE 

Set a map tile.

PXDET_MAX_EVENTS 

How many events there can be.

◆ PXDEMO_FADE_TYPE

enum PXDEMO_FADE_TYPE : unsigned char

Fade effect types.

Enumerator
PXDFT_CLEAR_FADE 

Stop fading.

PXDFT_FADE_IN 

Fade in.

PXDFT_FADE_OUT 

Fade out.

PXDFT_MAX_FADES 

How many fade types there.

◆ PXDEMO_PLAYERSTATE_CHANGE

enum PXDEMO_PLAYERSTATE_CHANGE : unsigned int

Changed playerstate variables between frames.

Lowers the filesize of demos considerably

Enumerator
PXDPSC_cond 

cond

PXDPSC_x 

x

PXDPSC_y 

y

PXDPSC_xm 

xm

PXDPSC_ym 

ym

PXDPSC_life 

life

PXDPSC_max_life 

max_life

PXDPSC_input_flags 

input_flags

PXDPSC_input_flags_trg 

input_flags_trg

PXDPSC_weapon_code 

weapon_code

PXDPSC_weapon_ammo 

weapon_ammo

PXDPSC_weapon_max_ammo 

weapon_max_ammo

PXDPSC_weapon_level 

weapon_level

PXDPSC_weapon_exp 

weapon_exp

PXDPSC_selectedArms 

selectedArms

PXDPSC_direct 

direct

PXDPSC_ani_no 

ani_no

PXDPSC_ani_wait 

ani_wait

PXDPSC_equip 

equip

PXDPSC_star 

star

PXDPSC_shock 

shock

PXDPSC_netanim 

unit

PXDPSC_physics_normal 

physics_normal

PXDPSC_physics_underwater 

physics_underwater

PXDPSC_ignore_water 

ignore_water

PXDPSC_boost_sw 

boost_sw

PXDPSC_boost_cnt 

boost_cnt

PXDPSC_flag 

Flags.

PXDPSC_updown 

Up / down.

PXDPSC_counts 

Count1.

PXDPSC_act_wait 

Count2.

PXDPSC_act_no 

Count2.

PXDPSC_ALL_FLAGS 

All flags combined.

PXDPSC_COUNT 

Number of recordable variables for playerstate.

PXDPSC_UNIQUE_COUNT 

Number of recordable variables (with unique change flags)

PXDPSC_BIGGEST_TYPE 

Biggest variable type.

Function Documentation

◆ CSM_GameDemo_Act()

CAVESTORY_MOD_API void CSM_GameDemo_Act ( GAME_DEMO_STATE pState,
bool  bFreezeFrame = false,
bool  bDontDraw = false,
bool  bDrawHUD = true,
bool  bDrawFade = true 
)

Act for a frame.

Parameters
pStateThe demo to simulate the game with.
bFreezeFrameIf set to true, the frame counter does not advance, and nothing is acted.
bDontDrawDon't draw anything.
bDrawHUDDraw the HUD.
bDrawFadeDraw the screen fade effect. If bDontDraw is set to 'true', then this is ignored.

◆ CSM_GameDemo_CombineDemos()

CAVESTORY_MOD_API bool CSM_GameDemo_CombineDemos ( GAME_DEMO_STATE pDst,
GAME_DEMO_STATE pSource,
unsigned int  iFrameOffset = 0xFFFFFFFF 
)

Combine game demos.

Parameters
pDstThe desired demo destination.
pSourceThe demo to insert.
iFrameOffsetThe frame index at which the demo should be inserted. Set to 0xFFFFFFFF to insert at the end of the demo.
Returns
Returns true on success.

◆ CSM_GameDemo_Events_Add()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Events_Add ( GAME_DEMO_STATE pState,
PXDEMO_EVENT_TYPE  iType,
unsigned int  iFrameNo,
unsigned int  iInsertNo = 0xFFFFFFFF 
)

Add an event to the demo.

Parameters
pStateThe gamedemo state to manipulate.
iTypeThe type of event to allocate.
iFrameNoThe frame number to add the event to.
iInsertNoThe event index to insert this new event at. Pass '0xFFFFFFFF' to push to the back of the event queue.
Returns
Returns a pointer to the newly allocated PXDEMO_EVENT_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Events_Find()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Events_Find ( GAME_DEMO_STATE pState,
PXDEMO_EVENT_TYPE  iType,
int  iFrameNo,
int  iStartIndex = 0,
PXDEMO_FRAME_STRUCT **  pFramePtr = NULL,
int *  pFrameIndex = NULL,
int *  pEventIndex = NULL 
)

Find an event.

Parameters
pStateThe gamedemo state to manipulate.
iTypeThe type of event to remove.
iFrameNoThe frame number the event should belong to.
iStartIndexThe starting index in the frame's event list.
pFramePtrA pointer to the variable that will hold the frame that holds the event. Can be NULL.
pFrameIndexA pointer to an int that will hold the index at which the frame was found at. Can be NULL.
pEventIndexA pointer to an int that will hold the index at which the event was found at. Can be NULL.
Returns
Returns a pointer to the specified event's PXDEMO_EVENT_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Events_Remove()

CAVESTORY_MOD_API bool CSM_GameDemo_Events_Remove ( GAME_DEMO_STATE pState,
PXDEMO_EVENT_TYPE  iType,
int  iFrameNo,
int  iStartIndex = 0 
)

Remove an event from the demo.

Parameters
pStateThe gamedemo state to manipulate.
iTypeThe type of event to remove.
iFrameNoThe frame number to remove the event from.
iStartIndexThe starting index in the frame's event list.
Returns
Returns true on success.

◆ CSM_GameDemo_FirstLink()

CAVESTORY_MOD_API bool CSM_GameDemo_FirstLink ( GAME_DEMO_STATE **  pFirst)

Get the first in the gamestate link.

Parameters
pFirstA pointer to a GAME_DEMO_STATE* variable that should hold the value.
Returns
Returns true if there was an object in the linkage, false otherwise.

◆ CSM_GameDemo_Frames_Add()

CAVESTORY_MOD_API PXDEMO_FRAME_STRUCT* CSM_GameDemo_Frames_Add ( GAME_DEMO_STATE pState,
int  iFrameNo 
)

Add af rame to the demo.

Parameters
pStateThe gamedemo state to manipulate.
iFrameNoThe frame number.
Returns
Returns a pointer to the newly allocated PXDEMO_FRAME_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Frames_Find()

CAVESTORY_MOD_API PXDEMO_FRAME_STRUCT* CSM_GameDemo_Frames_Find ( GAME_DEMO_STATE pState,
int  iFrameNo,
int *  pIndex = NULL 
)

Find a frame.

Parameters
pStateThe gamedemo state to manipulate.
iFrameNoThe frame number to search for.
pIndexA pointer to an int that will hold the index at which the entry was found at. Can be NULL.
Returns
Returns a pointer to the specified frame's PXDEMO_FRAME_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Frames_Remove()

CAVESTORY_MOD_API bool CSM_GameDemo_Frames_Remove ( GAME_DEMO_STATE pState,
int  iFrameNo 
)

Remove a frame from the demo.

Parameters
pStateThe gamedemo state to manipulate.
iFrameNoThe frame number.
Returns
Returns true on success.

◆ CSM_GameDemo_Free()

CAVESTORY_MOD_API void CSM_GameDemo_Free ( GAME_DEMO_STATE pState)

Free a GAME_DEMO_STATE object.

This should be called after initializing the object.

Parameters
pStateThe state to free.

◆ CSM_GameDemo_Init()

CAVESTORY_MOD_API void CSM_GameDemo_Init ( GAME_DEMO_STATE pState)

Initialize a GAME_DEMO_STATE object without linking it.

Parameters
pStateThe state to initialize.

◆ CSM_GameDemo_Init_Relink()

CAVESTORY_MOD_API void CSM_GameDemo_Init_Relink ( GAME_DEMO_STATE pState)

Initialize a GAME_DEMO_STATE object whilst also re-linking it.

Parameters
pStateThe state to initialize.

◆ CSM_GameDemo_Link()

CAVESTORY_MOD_API void CSM_GameDemo_Link ( GAME_DEMO_STATE pState)

Register a demo to the active linkage list.

Parameters
pStateThe state to be registered.

◆ CSM_GameDemo_Load()

CAVESTORY_MOD_API int CSM_GameDemo_Load ( GAME_DEMO_STATE pState,
const char *  pFileName 
)

Load a game demo.

Parameters
pStateThe state to load the demo into.
pFileNameThe name of the file to load into pState.
Returns
Returns 0 on success, otherwise returns a non-zero error code.

◆ CSM_GameDemo_LoadGamestate()

CAVESTORY_MOD_API void CSM_GameDemo_LoadGamestate ( GAME_DEMO_STATE pState)

Load a demo's gamestate.

Parameters
pStateThe demo to simulate the game with.

◆ CSM_GameDemo_Optimize()

CAVESTORY_MOD_API bool CSM_GameDemo_Optimize ( GAME_DEMO_STATE pState,
bool  bSaveAndLoad 
)

Optimize a game demo.

Parameters
pStateThe state to optimize.
bSaveAndLoadSave the game before optimizing the demo, and then load the save afterwards.
Returns
Returns true on success.

◆ CSM_GameDemo_Players_Add()

CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCT* CSM_GameDemo_Players_Add ( GAME_DEMO_STATE pState,
const char *  pName,
SafeClientInterface pInterface 
)

Add a player to the demo state.

Parameters
pStateThe gamedemo state to manipulate.
pNameThe name of the client.
pInterfaceA safe client interface. Can be NULL.
Returns
Returns a pointer to newly allocated PXDEMO_PLAYER_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Players_Find()

CAVESTORY_MOD_API PXDEMO_PLAYER_STRUCT* CSM_GameDemo_Players_Find ( GAME_DEMO_STATE pState,
const char *  pName,
int *  pIndex = NULL 
)

Find a player's object by name.

Parameters
pStateThe gamedemo state to manipulate.
pNameThe name of the player to find.
pIndexA pointer to an int that will hold the index at which the entry was found at. Can be NULL.
Returns
Returns a pointer to the specified player's PXDEMO_PLAYER_STRUCT on success, otherwise returns NULL.

◆ CSM_GameDemo_Players_Remove()

CAVESTORY_MOD_API bool CSM_GameDemo_Players_Remove ( GAME_DEMO_STATE pState,
const char *  pName 
)

Remove a player from the demo state.

Parameters
pStateThe gamedemo state to manipulate.
pNameThe name of the player to remove.
Returns
Returns true on success.

◆ CSM_GameDemo_Record_Camera()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_Camera ( GAME_DEMO_STATE pState)

Record the game camera's current details.

Parameters
pStateThe gamedemo state.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_Fade()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_Fade ( GAME_DEMO_STATE pState,
PXDEMO_FADE_TYPE  iType,
Directions  iDirect 
)

Record a screen fade.

Parameters
pStateThe gamedemo state.
iTypeThe type of fade.
iDirectThe direction of the fade.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_MapTileChange()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_MapTileChange ( GAME_DEMO_STATE pState,
unsigned short  iTileX,
unsigned short  iTileY,
unsigned int  iOldTileID,
unsigned int  iNewTileID,
bool  bCreateSmoke,
bool  bOnlyUndo 
)

Record a maptile change.

Parameters
pStateThe gamedemo state.
iTileXThe X coordinate for the tile that was modified.
iTileYThe Y coordinate for the tile that was modified.
iOldTileIDThe old tile ID.
iNewTileIDThe new tile ID.
bCreateSmokeWhether this should create smoke or not.
bOnlyUndoWhether this should only be undone.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_NewFrame()

CAVESTORY_MOD_API int CSM_GameDemo_Record_NewFrame ( GAME_DEMO_STATE pState)

Increment the simulated frame count.

Parameters
pStateThe gamedemo state.
Returns
Returns the current simulated frame number.

◆ CSM_GameDemo_Record_NpcState()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_NpcState ( GAME_DEMO_STATE pState,
NPCHAR pNpc,
int  iIndex 
)

Record the state of an NPC.

Parameters
pStateThe gamedemo state.
pNpcThe NPC to record the state of.
iIndexThe NPC index.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_PlayerState()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_PlayerState ( GAME_DEMO_STATE pState,
const char *  pName,
SafeClientInterface pInterface 
)

Record a player's state.

Parameters
pStateThe gamedemo state.
pNameThe name of the client.
pInterfaceAn interface to the player's details.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_RandomSeed()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_RandomSeed ( GAME_DEMO_STATE pState)

Record the current random seed.

Parameters
pStateThe gamedemo state.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_Stage()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_Stage ( GAME_DEMO_STATE pState)

Record the current stage index.

Parameters
pStateThe gamedemo state.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Record_Timer()

CAVESTORY_MOD_API PXDEMO_EVENT_STRUCT* CSM_GameDemo_Record_Timer ( GAME_DEMO_STATE pState)

Record the game's timer.

Parameters
pStateThe gamedemo state.
Returns
Returns a pointer to the added event on success, otherwise returns NULL.

◆ CSM_GameDemo_Save()

CAVESTORY_MOD_API int CSM_GameDemo_Save ( GAME_DEMO_STATE pState,
const char *  pFileName 
)

Save a game demo.

Parameters
pStateThe state to save the demo into.
pFileNameThe output name of the file.
Returns
Returns 0 on success, otherwise returns a non-zero error code.

◆ CSM_GameDemo_StopRecord()

CAVESTORY_MOD_API void CSM_GameDemo_StopRecord ( GAME_DEMO_STATE pState)

Stop recording a demo.

Parameters
pStateA pointer to the state to hold the recorded gamestate.

◆ CSM_GameDemo_Unlink()

CAVESTORY_MOD_API void CSM_GameDemo_Unlink ( GAME_DEMO_STATE pState)

Unregister a demo from the active linkage list.

Parameters
pStateThe state to be unregistered.

Variable Documentation

◆ gRecordingDemo

CAVESTORY_MOD_API GAME_DEMO_STATE* gRecordingDemo
extern

A pointer to the current recording demo.

If NULL, then the game is not being recorded.