OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Script Class Reference

Game script loader. More...

#include <Script.h>

Collaboration diagram for Script:
[legend]

Public Types

enum  ScriptLanguage {
  S_English = 0, S_French = 1, S_German = 2, S_American = 3,
  S_Japanese = 4
}
 
enum  ScriptOpCode {
  OP_PICTURE = 0, OP_PSX_TRACK = 1, OP_PSX_FMV = 2, OP_FMV = 3,
  OP_GAME = 4, OP_CUT = 5, OP_COMPLETE = 6, OP_DEMO = 7,
  OP_PSX_DEMO = 8, OP_END = 9, OP_TRACK = 10, OP_SUNSET = 11,
  OP_LOAD_PIC = 12, OP_DEADLY_WATER = 13, OP_REMOVE_WEAPONS = 14, OP_GAMECOMPLETE = 15,
  OP_CUTANGLE = 16, OP_NOFLOOR = 17, OP_STARTINV = 18, OP_STARTANIM = 19,
  OP_SECRETS = 20, OP_KILLTOCOMPLETE = 21, OP_REMOVE_AMMO = 22, OP_UNKNOWN = 23
}
 
enum  ScriptItem {
  OP_WEAPON_PISTOLS = 0, OP_WEAPON_SHOTGUN = 1, OP_WEAPON_AUTOPISTOLS = 2, OP_WEAPON_UZIS = 3,
  OP_WEAPON_HARPOON = 4, OP_WEAPON_M16 = 5, OP_WEAPON_ROCKET = 6, OP_AMMO_PISTOLS = 7,
  OP_AMMO_SHOTGUN = 8, OP_AMMO_AUTOPISTOLS = 9, OP_AMMO_UZIS = 10, OP_AMMO_HARPOON = 11,
  OP_AMMO_M16 = 12, OP_AMMO_ROCKET = 13, OP_ITEM_FLARE = 14, OP_ITEM_MEDI = 15,
  OP_ITEM_BIGMEDI = 16, OP_ITEM_PICKUP1 = 17, OP_ITEM_PICKUP2 = 18, OP_ITEM_PUZZLE1 = 19,
  OP_ITEM_PUZZLE2 = 20, OP_ITEM_PUZZLE3 = 21, OP_ITEM_PUZZLE4 = 22, OP_ITEM_KEY1 = 23,
  OP_ITEM_KEY2 = 24, OP_ITEM_KEY3 = 25, OP_ITEM_KEY4 = 26, OP_ITEM_UNKNOWN = 27
}
 

Public Member Functions

 Script ()
 
int load (std::string file)
 
unsigned int levelCount ()
 
std::string getLevelName (unsigned int i)
 
std::string getLevelFilename (unsigned int i)
 
unsigned int pictureCount ()
 
std::string getPictureFilename (unsigned int i)
 
unsigned int cutsceneCount ()
 
std::string getCutsceneFilename (unsigned int i)
 
unsigned int titleCount ()
 
std::string getTitleFilename (unsigned int i)
 
unsigned int videoCount ()
 
std::string getVideoFilename (unsigned int i)
 
unsigned int gameStringCount ()
 
std::string getGameString (unsigned int i)
 
unsigned int pcStringCount ()
 
std::string getPCString (unsigned int i)
 
std::string getPuzzleString (unsigned int i, unsigned int j)
 
std::string getPickupString (unsigned int i, unsigned int j)
 
std::string getKeyString (unsigned int i, unsigned int j)
 
void registerScriptHandler (ScriptOpCode op, std::function< int(bool, uint16_t)> func)
 
int runScript (unsigned int level)
 
std::string getDescription ()
 
std::string getLanguage ()
 

Private Types

enum  ScriptFlag {
  S_DemoVersion = (1 << 0), S_TitleDisabled = (1 << 1), S_CheatModeCheckDisabled = (1 << 2), S_NoInputTimeout = (1 << 3),
  S_LoadSaveDisabled = (1 << 4), S_ScreenSizingDisabled = (1 << 5), S_LockOutOptionRing = (1 << 6), S_DOZYCheatEnabled = (1 << 7),
  S_UseSecurityTag = (1 << 8), S_Unknown = (1 << 9), S_SelectAnyLevel = (1 << 10), S_EnableCheatCode = (1 << 11)
}
 

Private Member Functions

void readStringPackage (BinaryFile &f, std::vector< std::string > &v, unsigned int n)
 
void readScriptPackage (BinaryFile &f, std::vector< std::vector< uint16_t >> &v, unsigned int n)
 

Private Attributes

uint32_t version
 
std::string description
 
uint32_t firstOption
 
int32_t titleReplace
 
uint32_t onDeathDemoMode
 
uint32_t onDeathInGame
 
uint32_t noInputTime
 
uint32_t onDemoInterrupt
 
uint32_t onDemoEnd
 
uint16_t numLevels
 
uint16_t numPictures
 
uint16_t numTitles
 
uint16_t numFMVs
 
uint16_t numCutscenes
 
uint16_t numDemos
 
uint16_t titleTrack
 
int16_t singleLevel
 
uint16_t flags
 
uint8_t cypherCode
 
uint8_t language
 
uint16_t secretTrack
 
uint16_t numPCStrings
 
uint16_t numGameStrings
 
std::vector< std::string > levelNames
 
std::vector< std::string > pictureFilenames
 
std::vector< std::string > titleFilenames
 
std::vector< std::string > fmvFilenames
 
std::vector< std::string > levelFilenames
 
std::vector< std::string > cutsceneFilenames
 
std::vector< std::vector< uint16_t > > script
 
std::vector< std::string > gameStrings
 
std::vector< std::string > pcStrings
 
std::vector< std::vector< std::string > > puzzles
 
std::vector< std::vector< std::string > > pickups
 
std::vector< std::vector< std::string > > keys
 
std::function< int(bool, uint16_t)> scriptHandlers [OP_UNKNOWN]
 

Static Private Attributes

static const bool opcodeHasOperand [OP_UNKNOWN]
 

Detailed Description

Game script loader.

Definition at line 21 of file Script.h.

Member Enumeration Documentation

Enumerator
S_English 
S_French 
S_German 
S_American 
S_Japanese 

Definition at line 24 of file Script.h.

Enumerator
OP_PICTURE 

Unused in TR2. Or PSX? Used in TR3.

OP_PSX_TRACK 

Does not compile. PSX?

OP_PSX_FMV 

Does not compile. PSX?

OP_FMV 

Display FMV.

OP_GAME 

Start a playable level.

OP_CUT 

Display a cutscene.

OP_COMPLETE 

Display level-completion stats.

OP_DEMO 

Display demo sequence.

OP_PSX_DEMO 

Does not compile. PSX?

OP_END 

Closes script sequence.

OP_TRACK 

Play soundtrack (precedes level opcode)

OP_SUNSET 

Unknown, nothing changes in TR2. Start in Motorboat?

OP_LOAD_PIC 

Does not compile. PSX? Used in TR3.

OP_DEADLY_WATER 

Unknown, nothing changes in TR2.

OP_REMOVE_WEAPONS 

Start level without weapons.

OP_GAMECOMPLETE 

End of game. Show stats, start credits sequence, music ID 52 in TR2.

OP_CUTANGLE 

Match N-S orientation of Room and animated characters.

OP_NOFLOOR 

Lara dies when her feet reach given depth.

OP_STARTINV 

Items given to Lara at level start (+1000), or at all secrets found (+0)

OP_STARTANIM 

Special animation of Lara when level starts.

OP_SECRETS 

If zero, level does not account for secrets.

OP_KILLTOCOMPLETE 

Kill all enemies to finish the level.

OP_REMOVE_AMMO 

Lara starts level without ammo or medi packs.

OP_UNKNOWN 

Definition at line 32 of file Script.h.

Enumerator
OP_WEAPON_PISTOLS 

Add standard pistols (2)

OP_WEAPON_SHOTGUN 

Add shotgun (1)

OP_WEAPON_AUTOPISTOLS 

Add automatic pistols (2)

OP_WEAPON_UZIS 

Add uzis (2)

OP_WEAPON_HARPOON 

Add harpoon gun (1)

OP_WEAPON_M16 

Add M16 (1)

OP_WEAPON_ROCKET 

Add grenade launcher (1)

OP_AMMO_PISTOLS 

No effect, infinite ammo.

OP_AMMO_SHOTGUN 

Add 2 shells.

OP_AMMO_AUTOPISTOLS 

Add 2 shells.

OP_AMMO_UZIS 

Add 2 shells.

OP_AMMO_HARPOON 

Add 2 harpoons.

OP_AMMO_M16 

Add 2 shells.

OP_AMMO_ROCKET 

Add 1 grenade.

OP_ITEM_FLARE 

Add 1 flare.

OP_ITEM_MEDI 

Add 1 small MediPack.

OP_ITEM_BIGMEDI 

Add 1 big MediPack.

OP_ITEM_PICKUP1 

Add Pickup Item 1.

OP_ITEM_PICKUP2 

Add Pickup Item 2.

OP_ITEM_PUZZLE1 

Add Puzzle Item 1.

OP_ITEM_PUZZLE2 

Add Puzzle Item 2.

OP_ITEM_PUZZLE3 

Add Puzzle Item 3.

OP_ITEM_PUZZLE4 

Add Puzzle Item 4.

OP_ITEM_KEY1 

Add Key Item 1.

OP_ITEM_KEY2 

Add Key Item 2.

OP_ITEM_KEY3 

Add Key Item 3.

OP_ITEM_KEY4 

Add Key Item 4.

OP_ITEM_UNKNOWN 

Definition at line 62 of file Script.h.

enum Script::ScriptFlag
private
Enumerator
S_DemoVersion 

Don't load a MAIN.SFX.

S_TitleDisabled 

If set, game has no title screen.

S_CheatModeCheckDisabled 

Disable flare/step/rotate/jump sequence.

S_NoInputTimeout 

If set don't timeout input to start demo.

S_LoadSaveDisabled 

Don't allow load/save.

S_ScreenSizingDisabled 

Don't change screen resolution.

S_LockOutOptionRing 

No option ring while in level.

S_DOZYCheatEnabled 

DOZY flying cheat.

S_UseSecurityTag 

Strings XORed with cypherCode.

S_Unknown 

Usually set, no known effect.

S_SelectAnyLevel 

Level selectable in Title.

S_EnableCheatCode 

No known effect.

Definition at line 131 of file Script.h.

Constructor & Destructor Documentation

Script::Script ( )

Definition at line 18 of file Script.cpp.

Member Function Documentation

int Script::load ( std::string  file)

Definition at line 43 of file Script.cpp.

unsigned int Script::levelCount ( )

Definition at line 229 of file Script.cpp.

std::string Script::getLevelName ( unsigned int  i)

Definition at line 233 of file Script.cpp.

std::string Script::getLevelFilename ( unsigned int  i)

Definition at line 238 of file Script.cpp.

unsigned int Script::pictureCount ( )

Definition at line 243 of file Script.cpp.

std::string Script::getPictureFilename ( unsigned int  i)

Definition at line 247 of file Script.cpp.

unsigned int Script::cutsceneCount ( )

Definition at line 252 of file Script.cpp.

std::string Script::getCutsceneFilename ( unsigned int  i)

Definition at line 256 of file Script.cpp.

unsigned int Script::titleCount ( )

Definition at line 261 of file Script.cpp.

std::string Script::getTitleFilename ( unsigned int  i)

Definition at line 265 of file Script.cpp.

unsigned int Script::videoCount ( )

Definition at line 270 of file Script.cpp.

std::string Script::getVideoFilename ( unsigned int  i)

Definition at line 274 of file Script.cpp.

unsigned int Script::gameStringCount ( )

Definition at line 279 of file Script.cpp.

std::string Script::getGameString ( unsigned int  i)

Definition at line 283 of file Script.cpp.

unsigned int Script::pcStringCount ( )

Definition at line 288 of file Script.cpp.

std::string Script::getPCString ( unsigned int  i)

Definition at line 292 of file Script.cpp.

std::string Script::getPuzzleString ( unsigned int  i,
unsigned int  j 
)

Definition at line 297 of file Script.cpp.

std::string Script::getPickupString ( unsigned int  i,
unsigned int  j 
)

Definition at line 303 of file Script.cpp.

std::string Script::getKeyString ( unsigned int  i,
unsigned int  j 
)

Definition at line 309 of file Script.cpp.

void Script::registerScriptHandler ( ScriptOpCode  op,
std::function< int(bool, uint16_t)>  func 
)

Definition at line 315 of file Script.cpp.

int Script::runScript ( unsigned int  level)

Definition at line 320 of file Script.cpp.

std::string Script::getDescription ( )
inline

Definition at line 126 of file Script.h.

std::string Script::getLanguage ( )

Definition at line 350 of file Script.cpp.

void Script::readStringPackage ( BinaryFile f,
std::vector< std::string > &  v,
unsigned int  n 
)
private

Definition at line 124 of file Script.cpp.

void Script::readScriptPackage ( BinaryFile f,
std::vector< std::vector< uint16_t >> &  v,
unsigned int  n 
)
private

Definition at line 148 of file Script.cpp.

Member Data Documentation

const bool Script::opcodeHasOperand
staticprivate
Initial value:
{
true, true, true, true, true, true,
false, true, true, false, true, false,
true, false, false, false, true, true,
true, true, true, false, false
}

Definition at line 149 of file Script.h.

uint32_t Script::version
private

Definition at line 152 of file Script.h.

std::string Script::description
private

Definition at line 153 of file Script.h.

uint32_t Script::firstOption
private

Definition at line 156 of file Script.h.

int32_t Script::titleReplace
private

Definition at line 157 of file Script.h.

uint32_t Script::onDeathDemoMode
private

Definition at line 158 of file Script.h.

uint32_t Script::onDeathInGame
private

Definition at line 159 of file Script.h.

uint32_t Script::noInputTime
private

Definition at line 160 of file Script.h.

uint32_t Script::onDemoInterrupt
private

Definition at line 161 of file Script.h.

uint32_t Script::onDemoEnd
private

Definition at line 162 of file Script.h.

uint16_t Script::numLevels
private

Definition at line 163 of file Script.h.

uint16_t Script::numPictures
private

Definition at line 164 of file Script.h.

uint16_t Script::numTitles
private

Definition at line 165 of file Script.h.

uint16_t Script::numFMVs
private

Definition at line 166 of file Script.h.

uint16_t Script::numCutscenes
private

Definition at line 167 of file Script.h.

uint16_t Script::numDemos
private

Definition at line 168 of file Script.h.

uint16_t Script::titleTrack
private

Definition at line 169 of file Script.h.

int16_t Script::singleLevel
private

Definition at line 170 of file Script.h.

uint16_t Script::flags
private

Definition at line 171 of file Script.h.

uint8_t Script::cypherCode
private

Definition at line 172 of file Script.h.

uint8_t Script::language
private

Definition at line 173 of file Script.h.

uint16_t Script::secretTrack
private

Definition at line 174 of file Script.h.

uint16_t Script::numPCStrings
private

Definition at line 176 of file Script.h.

uint16_t Script::numGameStrings
private

Definition at line 177 of file Script.h.

std::vector<std::string> Script::levelNames
private

Definition at line 180 of file Script.h.

std::vector<std::string> Script::pictureFilenames
private

Definition at line 181 of file Script.h.

std::vector<std::string> Script::titleFilenames
private

Definition at line 182 of file Script.h.

std::vector<std::string> Script::fmvFilenames
private

Definition at line 183 of file Script.h.

std::vector<std::string> Script::levelFilenames
private

Definition at line 184 of file Script.h.

std::vector<std::string> Script::cutsceneFilenames
private

Definition at line 185 of file Script.h.

std::vector<std::vector<uint16_t> > Script::script
private

Definition at line 186 of file Script.h.

std::vector<std::string> Script::gameStrings
private

Definition at line 187 of file Script.h.

std::vector<std::string> Script::pcStrings
private

Definition at line 188 of file Script.h.

std::vector<std::vector<std::string> > Script::puzzles
private

Definition at line 189 of file Script.h.

std::vector<std::vector<std::string> > Script::pickups
private

Definition at line 190 of file Script.h.

std::vector<std::vector<std::string> > Script::keys
private

Definition at line 191 of file Script.h.

std::function<int (bool, uint16_t)> Script::scriptHandlers[OP_UNKNOWN]
private

Definition at line 193 of file Script.h.


The documentation for this class was generated from the following files: