SBSPSS/source/script/function.cpp

295 lines
6.5 KiB
C++
Raw Normal View History

2001-01-05 20:25:07 +01:00
/*
//text to speech hooks
question/response
//give item
*/
2000-12-14 22:46:02 +01:00
/*=========================================================================
function.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "script\function.h"
#ifndef __SYSTEM_DBG_H__
#include "system\dbg.h"
#endif
2000-12-20 21:15:24 +01:00
#ifndef __SYSTEM_GSTATE_H__
#include "system\gstate.h"
#endif
2001-01-10 18:27:12 +01:00
#ifndef __GAME_CONVO_H__
#include "game\convo.h"
#endif
2001-07-14 00:10:16 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2000-12-14 22:46:02 +01:00
/* Std Lib
------- */
/* Data
---- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
2001-07-14 00:10:16 +02:00
// For getAmmoCount(), setAmmoCount()
enum
{
AMMO_BUBBLEWAND,
};
// For isHoldingWeapon()
enum
{
WEAPON_BUBBLEWAND,
2001-07-18 18:48:49 +02:00
WEAPON_BALLOON,
2001-07-14 00:10:16 +02:00
};
2000-12-14 22:46:02 +01:00
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
typedef struct
{
2000-12-15 21:29:33 +01:00
signed short (*m_func)(unsigned short *_args);
2000-12-14 22:46:02 +01:00
int m_argCount;
} FunctionDef;
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
2000-12-20 21:15:24 +01:00
static signed short func_setCharacterAnimation(unsigned short *_args);
2000-12-15 21:29:33 +01:00
static signed short func_setText(unsigned short *_args);
2001-01-05 20:25:07 +01:00
static signed short func_setResponseOptions(unsigned short *_args);
static signed short func_getResponse(unsigned short *_args);
2001-07-14 00:10:16 +02:00
static signed short func_getAmmoCount(unsigned short *_args);
static signed short func_setAmmoCount(unsigned short *_args);
static signed short func_isHoldingWeapon(unsigned short *_args);
2001-07-18 18:48:49 +02:00
static signed short func_giveWeapon(unsigned short *_args);
2000-12-15 21:29:33 +01:00
2000-12-14 22:46:02 +01:00
/*----------------------------------------------------------------------
Vars
---- */
static FunctionDef s_functionDefs[]=
{
2001-01-05 20:25:07 +01:00
{ func_setCharacterAnimation, 2 }, // characterId,animationId
{ func_setText, 2 }, // characterId,textId
{ func_setResponseOptions, 1 }, // optionsId
{ func_getResponse, 0 }, //
2001-07-14 00:10:16 +02:00
{ func_getAmmoCount, 1 }, // ammoId
{ func_setAmmoCount, 2 }, // ammoId,amount
{ func_isHoldingWeapon, 1 }, // weaponId
2001-07-18 18:48:49 +02:00
{ func_giveWeapon, 1 }, // weaponId
2000-12-14 22:46:02 +01:00
};
2000-12-15 21:29:33 +01:00
static const int s_numFunctionDefs=sizeof(s_functionDefs)/sizeof(FunctionDef);
2000-12-14 22:46:02 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2000-12-15 21:29:33 +01:00
signed short callFunction(int _functionNumber,int _argCount,unsigned short *_args)
{
FunctionDef *fd;
ASSERT(_functionNumber<s_numFunctionDefs);
fd=&s_functionDefs[_functionNumber];
ASSERT(_argCount==fd->m_argCount);
return fd->m_func(_args);
}
/*----------------------------------------------------------------------
Function:
2001-01-05 20:25:07 +01:00
Purpose: Set characters animation state
Params: characterId,animationId
Returns: 0
2000-12-15 21:29:33 +01:00
---------------------------------------------------------------------- */
2000-12-20 21:15:24 +01:00
static signed short func_setCharacterAnimation(unsigned short *_args)
2000-12-15 21:29:33 +01:00
{
2001-01-05 20:25:07 +01:00
return 0;
2000-12-15 21:29:33 +01:00
}
/*----------------------------------------------------------------------
Function:
2001-01-05 20:25:07 +01:00
Purpose: Set text/speech/character for ingame texts
Params: characterId, textId
Returns: 0
2000-12-15 21:29:33 +01:00
---------------------------------------------------------------------- */
static signed short func_setText(unsigned short *_args)
{
2001-01-10 18:27:12 +01:00
CConversation::setCharacterAndText(_args[0],_args[1]);
2001-01-05 20:25:07 +01:00
return 0;
}
/*----------------------------------------------------------------------
Function:
Purpose: Sets the allowable responses for a question
Params: optionsId
Returns: 0
---------------------------------------------------------------------- */
static signed short func_setResponseOptions(unsigned short *_args)
{
2001-01-10 18:27:12 +01:00
CConversation::setResponseOptions(_args[0]);
2001-01-05 20:25:07 +01:00
return 0;
}
/*----------------------------------------------------------------------
Function:
Purpose: Gets the response from a question
Params: optionsId
Returns: 0
---------------------------------------------------------------------- */
static signed short func_getResponse(unsigned short *_args)
{
2001-01-10 18:27:12 +01:00
return CConversation::getResponse();
2000-12-15 21:29:33 +01:00
}
2000-12-14 22:46:02 +01:00
2000-12-20 21:15:24 +01:00
/*----------------------------------------------------------------------
Function:
2001-07-14 00:10:16 +02:00
Purpose:
Params: ammoId
Returns: ammoCount
---------------------------------------------------------------------- */
static signed short func_getAmmoCount(unsigned short *_args)
{
int ammo=0;
switch(_args[0])
{
case AMMO_BUBBLEWAND:
ammo=GameScene.getPlayer()->getBubbleAmmo();
break;
default:
ASSERT(!"BAD AMMO TYPE IN func_getAmmoCount()");
break;
}
return ammo;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params: ammoId,amount
2001-01-05 20:25:07 +01:00
Returns: 0
2000-12-20 21:15:24 +01:00
---------------------------------------------------------------------- */
2001-07-14 00:10:16 +02:00
static signed short func_setAmmoCount(unsigned short *_args)
2000-12-20 21:15:24 +01:00
{
2001-07-14 00:10:16 +02:00
switch(_args[0])
2000-12-20 21:15:24 +01:00
{
2001-07-14 00:10:16 +02:00
case AMMO_BUBBLEWAND:
GameScene.getPlayer()->setBubbleAmmo(_args[1]);
break;
default:
ASSERT(!"BAD AMMO TYPE IN func_setAmmoCount()");
break;
2000-12-20 21:15:24 +01:00
}
return 0;
}
/*----------------------------------------------------------------------
Function:
2001-07-14 00:10:16 +02:00
Purpose:
Params: weaponId
Returns: true(1) or false(0)
2000-12-20 21:15:24 +01:00
---------------------------------------------------------------------- */
2001-07-14 00:10:16 +02:00
static signed short func_isHoldingWeapon(unsigned short *_args)
2000-12-20 21:15:24 +01:00
{
2001-07-14 00:10:16 +02:00
int held=0;
switch(_args[0])
{
case WEAPON_BUBBLEWAND:
if(GameScene.getPlayer()->isHoldingBubbleWand())
{
held=1;
}
break;
2001-07-18 18:48:49 +02:00
case WEAPON_BALLOON:
if(GameScene.getPlayer()->isHoldingBalloon())
{
held=1;
}
break;
2001-07-14 00:10:16 +02:00
default:
2001-07-18 18:48:49 +02:00
ASSERT(!"BAD WEAPON TYPE IN func_isHoldingWeapon()");
2001-07-14 00:10:16 +02:00
break;
}
return held;
2000-12-20 21:15:24 +01:00
}
2001-07-18 18:48:49 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params: weaponId
Returns: true(1) or false(0)
---------------------------------------------------------------------- */
static signed short func_giveWeapon(unsigned short *_args)
{
switch(_args[0])
{
case WEAPON_BUBBLEWAND:
GameScene.getPlayer()->setMode(PLAYER_MODE_BUBBLE_MIXTURE);
break;
case WEAPON_BALLOON:
GameScene.getPlayer()->setMode(PLAYER_MODE_BALLOON);
break;
default:
ASSERT(!"BAD WEAPON TYPE IN func_giveWeapon()");
break;
}
return 0;
}
2000-12-14 22:46:02 +01:00
/*===========================================================================
end */