2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Scripting module script function component
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/gfx.h"
|
|
|
|
#include "saga/actor.h"
|
|
|
|
#include "saga/animation.h"
|
2004-08-10 18:31:33 +00:00
|
|
|
#include "saga/console.h"
|
2005-01-06 16:07:46 +00:00
|
|
|
#include "saga/events.h"
|
2004-12-29 16:10:53 +00:00
|
|
|
#include "saga/font.h"
|
2004-08-06 01:39:17 +00:00
|
|
|
#include "saga/interface.h"
|
2004-09-23 06:46:44 +00:00
|
|
|
#include "saga/music.h"
|
2005-01-28 12:54:09 +00:00
|
|
|
#include "saga/itedata.h"
|
2005-05-23 02:23:34 +00:00
|
|
|
#include "saga/puzzle.h"
|
2004-12-29 16:10:53 +00:00
|
|
|
#include "saga/render.h"
|
2004-10-19 17:12:53 +00:00
|
|
|
#include "saga/sound.h"
|
|
|
|
#include "saga/sndres.h"
|
2007-07-30 11:55:11 +00:00
|
|
|
#include "saga/rscfile.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/script.h"
|
2005-01-22 19:21:38 +00:00
|
|
|
#include "saga/objectmap.h"
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2004-10-27 22:17:11 +00:00
|
|
|
#include "saga/scene.h"
|
2005-04-03 15:32:04 +00:00
|
|
|
#include "saga/isomap.h"
|
2006-05-13 10:30:38 +00:00
|
|
|
#include "saga/sagaresnames.h"
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2004-12-24 11:11:01 +00:00
|
|
|
#define OPCODE(x) {&Script::x, #x}
|
2004-08-12 23:57:45 +00:00
|
|
|
|
|
|
|
void Script::setupScriptFuncList(void) {
|
2005-07-21 01:33:28 +00:00
|
|
|
static const ScriptFunctionDescription ITEscriptFunctionsList[ITE_SCRIPT_FUNCTION_MAX] = {
|
2005-01-22 19:21:38 +00:00
|
|
|
OPCODE(sfPutString),
|
2004-12-22 21:04:50 +00:00
|
|
|
OPCODE(sfWait),
|
2005-01-22 19:21:38 +00:00
|
|
|
OPCODE(sfTakeObject),
|
|
|
|
OPCODE(sfIsCarried),
|
2005-01-02 20:29:27 +00:00
|
|
|
OPCODE(sfStatusBar),
|
2005-01-22 19:21:38 +00:00
|
|
|
OPCODE(sfMainMode),
|
2004-12-24 20:44:39 +00:00
|
|
|
OPCODE(sfScriptWalkTo),
|
2005-01-22 19:21:38 +00:00
|
|
|
OPCODE(sfScriptDoAction),
|
2004-12-22 21:04:50 +00:00
|
|
|
OPCODE(sfSetActorFacing),
|
2004-12-28 03:44:07 +00:00
|
|
|
OPCODE(sfStartBgdAnim),
|
|
|
|
OPCODE(sfStopBgdAnim),
|
2005-01-06 14:02:53 +00:00
|
|
|
OPCODE(sfLockUser),
|
2005-01-22 19:21:38 +00:00
|
|
|
OPCODE(sfPreDialog),
|
|
|
|
OPCODE(sfKillActorThreads),
|
2005-01-06 19:15:01 +00:00
|
|
|
OPCODE(sfFaceTowards),
|
2004-12-22 21:04:50 +00:00
|
|
|
OPCODE(sfSetFollower),
|
2005-01-22 21:40:54 +00:00
|
|
|
OPCODE(sfScriptGotoScene),
|
2005-04-24 15:17:38 +00:00
|
|
|
OPCODE(sfSetObjImage),
|
|
|
|
OPCODE(sfSetObjName),
|
|
|
|
OPCODE(sfGetObjImage),
|
2005-06-19 14:06:20 +00:00
|
|
|
OPCODE(sfGetNumber),
|
2004-12-28 21:27:18 +00:00
|
|
|
OPCODE(sfScriptOpenDoor),
|
|
|
|
OPCODE(sfScriptCloseDoor),
|
2004-12-28 03:44:07 +00:00
|
|
|
OPCODE(sfSetBgdAnimSpeed),
|
2004-11-06 22:33:08 +00:00
|
|
|
OPCODE(SF_cycleColors),
|
2004-12-28 21:27:18 +00:00
|
|
|
OPCODE(sfDoCenterActor),
|
2004-12-28 03:44:07 +00:00
|
|
|
OPCODE(sfStartBgdAnimSpeed),
|
2004-12-29 21:49:25 +00:00
|
|
|
OPCODE(sfScriptWalkToAsync),
|
2005-04-16 20:59:24 +00:00
|
|
|
OPCODE(sfEnableZone),
|
2004-12-24 10:22:01 +00:00
|
|
|
OPCODE(sfSetActorState),
|
2005-01-22 21:40:54 +00:00
|
|
|
OPCODE(sfScriptMoveTo),
|
2005-04-17 11:53:25 +00:00
|
|
|
OPCODE(sfSceneEq),
|
2005-04-23 12:34:35 +00:00
|
|
|
OPCODE(sfDropObject),
|
2004-12-28 04:09:10 +00:00
|
|
|
OPCODE(sfFinishBgdAnim),
|
2004-12-22 21:04:50 +00:00
|
|
|
OPCODE(sfSwapActors),
|
|
|
|
OPCODE(sfSimulSpeech),
|
2004-12-29 21:49:25 +00:00
|
|
|
OPCODE(sfScriptWalk),
|
2004-12-22 21:04:50 +00:00
|
|
|
OPCODE(sfCycleFrames),
|
|
|
|
OPCODE(sfSetFrame),
|
2004-12-30 18:45:48 +00:00
|
|
|
OPCODE(sfSetPortrait),
|
|
|
|
OPCODE(sfSetProtagPortrait),
|
|
|
|
OPCODE(sfChainBgdAnim),
|
2005-04-16 11:03:34 +00:00
|
|
|
OPCODE(sfScriptSpecialWalk),
|
2004-12-22 21:04:50 +00:00
|
|
|
OPCODE(sfPlaceActor),
|
2005-04-17 11:53:25 +00:00
|
|
|
OPCODE(sfCheckUserInterrupt),
|
2005-04-16 11:03:34 +00:00
|
|
|
OPCODE(sfScriptWalkRelative),
|
|
|
|
OPCODE(sfScriptMoveRelative),
|
2005-05-22 01:20:47 +00:00
|
|
|
OPCODE(sfSimulSpeech2),
|
2004-12-30 14:54:40 +00:00
|
|
|
OPCODE(sfPlacard),
|
|
|
|
OPCODE(sfPlacardOff),
|
2005-04-21 01:30:07 +00:00
|
|
|
OPCODE(sfSetProtagState),
|
2004-12-28 04:09:10 +00:00
|
|
|
OPCODE(sfResumeBgdAnim),
|
2005-06-05 16:53:53 +00:00
|
|
|
OPCODE(sfThrowActor),
|
2005-01-22 21:40:54 +00:00
|
|
|
OPCODE(sfWaitWalk),
|
2005-04-16 16:55:35 +00:00
|
|
|
OPCODE(sfScriptSceneID),
|
2005-06-05 16:53:53 +00:00
|
|
|
OPCODE(sfChangeActorScene),
|
|
|
|
OPCODE(sfScriptClimb),
|
2004-12-28 21:27:18 +00:00
|
|
|
OPCODE(sfSetDoorState),
|
2005-06-12 21:21:14 +00:00
|
|
|
OPCODE(sfSetActorZ),
|
2005-06-15 19:30:11 +00:00
|
|
|
OPCODE(sfScriptText),
|
2005-06-12 21:21:14 +00:00
|
|
|
OPCODE(sfGetActorX),
|
|
|
|
OPCODE(sfGetActorY),
|
|
|
|
OPCODE(sfEraseDelta),
|
2004-12-30 18:45:48 +00:00
|
|
|
OPCODE(sfPlayMusic),
|
2005-07-01 17:29:23 +00:00
|
|
|
OPCODE(sfPickClimbOutPos),
|
|
|
|
OPCODE(sfTossRif),
|
2005-06-20 12:17:22 +00:00
|
|
|
OPCODE(sfShowControls),
|
2005-07-03 20:02:56 +00:00
|
|
|
OPCODE(sfShowMap),
|
2005-05-23 02:23:34 +00:00
|
|
|
OPCODE(sfPuzzleWon),
|
2004-12-30 18:45:48 +00:00
|
|
|
OPCODE(sfEnableEscape),
|
|
|
|
OPCODE(sfPlaySound),
|
2005-06-19 21:18:00 +00:00
|
|
|
OPCODE(sfPlayLoopedSound),
|
2005-04-16 20:59:24 +00:00
|
|
|
OPCODE(sfGetDeltaFrame),
|
2005-05-18 18:28:10 +00:00
|
|
|
OPCODE(sfShowProtect),
|
|
|
|
OPCODE(sfProtectResult),
|
2004-12-30 18:45:48 +00:00
|
|
|
OPCODE(sfRand),
|
2005-06-19 21:18:00 +00:00
|
|
|
OPCODE(sfFadeMusic),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfPlayVoice)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const ScriptFunctionDescription IHNMscriptFunctionsList[IHNM_SCRIPT_FUNCTION_MAX] = {
|
|
|
|
OPCODE(sfNull),
|
|
|
|
OPCODE(sfWait),
|
|
|
|
OPCODE(sfTakeObject),
|
|
|
|
OPCODE(sfIsCarried),
|
|
|
|
OPCODE(sfStatusBar),
|
|
|
|
OPCODE(sfMainMode),
|
|
|
|
OPCODE(sfScriptWalkTo),
|
|
|
|
OPCODE(sfScriptDoAction),
|
|
|
|
OPCODE(sfSetActorFacing),
|
|
|
|
OPCODE(sfStartBgdAnim),
|
|
|
|
OPCODE(sfStopBgdAnim),
|
2007-06-03 15:50:25 +00:00
|
|
|
OPCODE(sfLockUser),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfPreDialog),
|
|
|
|
OPCODE(sfKillActorThreads),
|
|
|
|
OPCODE(sfFaceTowards),
|
|
|
|
OPCODE(sfSetFollower),
|
|
|
|
OPCODE(sfScriptGotoScene),
|
|
|
|
OPCODE(sfSetObjImage),
|
|
|
|
OPCODE(sfSetObjName),
|
|
|
|
OPCODE(sfGetObjImage),
|
|
|
|
OPCODE(sfGetNumber),
|
|
|
|
OPCODE(sfScriptOpenDoor),
|
|
|
|
OPCODE(sfScriptCloseDoor),
|
|
|
|
OPCODE(sfSetBgdAnimSpeed),
|
|
|
|
OPCODE(SF_cycleColors),
|
|
|
|
OPCODE(sfDoCenterActor),
|
|
|
|
OPCODE(sfStartBgdAnimSpeed),
|
|
|
|
OPCODE(sfScriptWalkToAsync),
|
|
|
|
OPCODE(sfEnableZone),
|
|
|
|
OPCODE(sfSetActorState),
|
|
|
|
OPCODE(sfScriptMoveTo),
|
|
|
|
OPCODE(sfSceneEq),
|
|
|
|
OPCODE(sfDropObject),
|
|
|
|
OPCODE(sfFinishBgdAnim),
|
|
|
|
OPCODE(sfSwapActors),
|
|
|
|
OPCODE(sfSimulSpeech),
|
|
|
|
OPCODE(sfScriptWalk),
|
|
|
|
OPCODE(sfCycleFrames),
|
|
|
|
OPCODE(sfSetFrame),
|
|
|
|
OPCODE(sfSetPortrait),
|
|
|
|
OPCODE(sfSetProtagPortrait),
|
|
|
|
OPCODE(sfChainBgdAnim),
|
|
|
|
OPCODE(sfScriptSpecialWalk),
|
|
|
|
OPCODE(sfPlaceActor),
|
|
|
|
OPCODE(sfCheckUserInterrupt),
|
|
|
|
OPCODE(sfScriptWalkRelative),
|
|
|
|
OPCODE(sfScriptMoveRelative),
|
|
|
|
OPCODE(sfSimulSpeech2),
|
2005-07-25 02:38:43 +00:00
|
|
|
OPCODE(sfPsychicProfile),
|
|
|
|
OPCODE(sfPsychicProfileOff),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfSetProtagState),
|
|
|
|
OPCODE(sfResumeBgdAnim),
|
|
|
|
OPCODE(sfThrowActor),
|
|
|
|
OPCODE(sfWaitWalk),
|
|
|
|
OPCODE(sfScriptSceneID),
|
|
|
|
OPCODE(sfChangeActorScene),
|
|
|
|
OPCODE(sfScriptClimb),
|
|
|
|
OPCODE(sfSetDoorState),
|
|
|
|
OPCODE(sfSetActorZ),
|
|
|
|
OPCODE(sfScriptText),
|
|
|
|
OPCODE(sfGetActorX),
|
|
|
|
OPCODE(sfGetActorY),
|
|
|
|
OPCODE(sfEraseDelta),
|
|
|
|
OPCODE(sfPlayMusic),
|
|
|
|
OPCODE(sfNull),
|
|
|
|
OPCODE(sfEnableEscape),
|
|
|
|
OPCODE(sfPlaySound),
|
|
|
|
OPCODE(sfPlayLoopedSound),
|
|
|
|
OPCODE(sfGetDeltaFrame),
|
|
|
|
OPCODE(sfNull),
|
|
|
|
OPCODE(sfNull),
|
|
|
|
OPCODE(sfRand),
|
|
|
|
OPCODE(sfFadeMusic),
|
|
|
|
OPCODE(sfNull),
|
2005-10-04 23:38:19 +00:00
|
|
|
OPCODE(sfSetChapterPoints),
|
2005-10-04 17:44:41 +00:00
|
|
|
OPCODE(sfSetPortraitBgColor),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfScriptStartCutAway),
|
|
|
|
OPCODE(sfReturnFromCutAway),
|
|
|
|
OPCODE(sfEndCutAway),
|
|
|
|
OPCODE(sfGetMouseClicks),
|
|
|
|
OPCODE(sfResetMouseClicks),
|
|
|
|
OPCODE(sfWaitFrames),
|
|
|
|
OPCODE(sfScriptFade),
|
2005-09-25 00:08:13 +00:00
|
|
|
OPCODE(sfScriptStartVideo),
|
|
|
|
OPCODE(sfScriptReturnFromVideo),
|
|
|
|
OPCODE(sfScriptEndVideo),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfSetActorZ),
|
2007-08-02 14:43:10 +00:00
|
|
|
OPCODE(sfShowIHNMDemoHelpBg),
|
|
|
|
OPCODE(sfAddIHNMDemoHelpTextLine),
|
|
|
|
OPCODE(sfShowIHNMDemoHelpPage),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfVstopFX),
|
|
|
|
OPCODE(sfVstopLoopedFX),
|
2007-08-17 06:08:18 +00:00
|
|
|
OPCODE(sfDemoSetInteractive), // only used in the demo version of IHNM
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfDemoIsInteractive),
|
2005-07-24 13:41:49 +00:00
|
|
|
OPCODE(sfVsetTrack),
|
2005-09-25 00:08:13 +00:00
|
|
|
OPCODE(sfGetPoints),
|
|
|
|
OPCODE(sfSetGlobalFlag),
|
|
|
|
OPCODE(sfClearGlobalFlag),
|
|
|
|
OPCODE(sfTestGlobalFlag),
|
|
|
|
OPCODE(sfSetPoints),
|
2005-08-10 17:39:29 +00:00
|
|
|
OPCODE(sfSetSpeechBox),
|
2005-07-21 01:33:28 +00:00
|
|
|
OPCODE(sfDebugShowData),
|
2005-08-07 00:00:43 +00:00
|
|
|
OPCODE(sfWaitFramesEsc),
|
2007-07-06 12:39:00 +00:00
|
|
|
OPCODE(sfQueueMusic),
|
2005-10-04 23:38:19 +00:00
|
|
|
OPCODE(sfDisableAbortSpeeches)
|
2004-08-12 23:57:45 +00:00
|
|
|
};
|
2005-07-21 01:33:28 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
|
|
|
_scriptFunctionsList = IHNMscriptFunctionsList;
|
|
|
|
else
|
|
|
|
_scriptFunctionsList = ITEscriptFunctionsList;
|
2004-08-12 23:57:45 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #0 (0x00)
|
2004-11-07 15:23:00 +00:00
|
|
|
// Print a debugging message
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPutString(SCRIPTFUNC_PARAMS) {
|
|
|
|
const char *str;
|
|
|
|
str = thread->_strings->getString(thread->pop());
|
2004-11-07 15:23:00 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
_vm->_console->DebugPrintf("sfPutString: %s\n",str);
|
|
|
|
debug(0, "sfPutString: %s", str);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #1 (0x01) blocking
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param1: time in ticks
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfWait(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 time;
|
|
|
|
time = thread->pop();
|
2004-10-27 02:27:54 +00:00
|
|
|
|
|
|
|
if (!_skipSpeeches) {
|
2007-07-06 13:21:43 +00:00
|
|
|
thread->waitDelay(_vm->ticksToMSec(time)); // put thread to sleep
|
2004-10-27 02:27:54 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #2 (0x02)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfTakeObject(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId = thread->pop();
|
|
|
|
ObjectData *obj;
|
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
if (obj->_sceneNumber != ITE_SCENE_INV) {
|
|
|
|
obj->_sceneNumber = ITE_SCENE_INV;
|
2007-07-29 19:06:17 +00:00
|
|
|
|
|
|
|
// WORKAROUND for two incorrect object sprites in the IHNM demo
|
|
|
|
// (the mirror and the icon in Ted's part). Set them correctly here
|
|
|
|
if (_vm->getGameId() == GID_IHNM_DEMO) {
|
2007-07-30 21:13:51 +00:00
|
|
|
if (obj->_spriteListResourceId == 4 && objectId == 16408)
|
2007-07-29 19:06:17 +00:00
|
|
|
obj->_spriteListResourceId = 24;
|
2007-07-30 21:13:51 +00:00
|
|
|
if (obj->_spriteListResourceId == 3 && objectId == 16409)
|
2007-07-29 19:06:17 +00:00
|
|
|
obj->_spriteListResourceId = 25;
|
|
|
|
}
|
|
|
|
|
2005-04-18 10:26:43 +00:00
|
|
|
_vm->_interface->addToInventory(objectId);
|
2004-11-07 15:11:04 +00:00
|
|
|
}
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #3 (0x03)
|
2004-11-01 10:49:21 +00:00
|
|
|
// Check if an object is carried.
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfIsCarried(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId = thread->pop();
|
2005-05-15 17:45:59 +00:00
|
|
|
CommonObjectData *object;
|
|
|
|
if (_vm->_actor->validObjId(objectId)) {
|
|
|
|
object = _vm->_actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
thread->_returnValue = (object->_sceneNumber == ITE_SCENE_INV) ? 1 : 0;
|
2005-05-15 17:45:59 +00:00
|
|
|
} else {
|
|
|
|
thread->_returnValue = 0;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #4 (0x04) nonblocking
|
|
|
|
// Set the command display to the specified text string
|
|
|
|
// Param1: dialogue index of string
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfStatusBar(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 stringIndex = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
_vm->_interface->setStatusText(thread->_strings->getString(stringIndex));
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #5 (0x05)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfMainMode(SCRIPTFUNC_PARAMS) {
|
|
|
|
_vm->_actor->_centerActor = _vm->_actor->_protagonist;
|
2005-07-29 16:37:06 +00:00
|
|
|
|
|
|
|
showVerb();
|
2005-01-06 14:02:53 +00:00
|
|
|
_vm->_interface->activate();
|
2005-05-22 11:59:22 +00:00
|
|
|
_vm->_interface->setMode(kPanelMain);
|
2007-08-25 19:21:43 +00:00
|
|
|
// Sometimes, the active cutaway is cleared after this opcode is called,
|
|
|
|
// resulting in an incorrect mode being set. An example is Ellen's chapter
|
|
|
|
// in IHNM, when using the computer with the chaos trebler CD. Make sure
|
|
|
|
// that the saved mode is kPanelMain, so that it won't get overwritten
|
|
|
|
// by an incorrect stored mode
|
|
|
|
_vm->_interface->rememberMode();
|
2005-07-21 01:33:28 +00:00
|
|
|
|
|
|
|
if (_vm->getGameType() == GType_ITE)
|
|
|
|
setPointerVerb();
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #6 (0x06) blocking
|
|
|
|
// Param1: actor id
|
2004-12-24 20:44:39 +00:00
|
|
|
// Param2: actor x
|
|
|
|
// Param3: actor y
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfScriptWalkTo(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 actorId;
|
2005-01-15 20:12:49 +00:00
|
|
|
Location actorLocation;
|
2004-12-24 20:44:39 +00:00
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2004-12-24 20:44:39 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actorLocation.z = actor->_location.z;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_flags &= ~kFollower;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-24 20:44:39 +00:00
|
|
|
if (_vm->_actor->actorWalkTo(actorId, actorLocation)) {
|
|
|
|
thread->waitWalk(actor);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #7 (0x07)
|
2005-01-22 19:21:38 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: action
|
|
|
|
// Param3: theObject
|
|
|
|
// Param4: withObject
|
|
|
|
void Script::sfScriptDoAction(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId;
|
|
|
|
uint16 action;
|
|
|
|
uint16 theObject;
|
|
|
|
uint16 withObject;
|
|
|
|
int16 scriptEntryPointNumber;
|
|
|
|
int16 moduleNumber;
|
|
|
|
ActorData *actor;
|
|
|
|
ObjectData *obj;
|
|
|
|
const HitZone *hitZone;
|
2005-08-10 14:11:22 +00:00
|
|
|
Event event;
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
objectId = thread->pop();
|
|
|
|
action = thread->pop();
|
|
|
|
theObject = thread->pop();
|
|
|
|
withObject = thread->pop();
|
|
|
|
|
|
|
|
switch (objectTypeId(objectId)) {
|
|
|
|
case kGameObjectObject:
|
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
scriptEntryPointNumber = obj->_scriptEntrypointNumber;
|
2005-01-22 19:21:38 +00:00
|
|
|
if (scriptEntryPointNumber <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
moduleNumber = 0;
|
2007-08-26 01:29:35 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
|
|
|
moduleNumber = _vm->_scene->getScriptModuleNumber();
|
2005-01-22 19:21:38 +00:00
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
case kGameObjectActor:
|
|
|
|
actor = _vm->_actor->getActor(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
scriptEntryPointNumber = actor->_scriptEntrypointNumber;
|
2005-01-22 19:21:38 +00:00
|
|
|
if (scriptEntryPointNumber <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
2005-08-10 14:53:17 +00:00
|
|
|
if (actor->_flags & (kProtagonist | kFollower)) {
|
2005-07-29 17:58:00 +00:00
|
|
|
moduleNumber = 0;
|
2005-01-22 19:21:38 +00:00
|
|
|
} else {
|
|
|
|
moduleNumber = _vm->_scene->getScriptModuleNumber();
|
|
|
|
}
|
2007-08-26 01:29:35 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
|
|
|
moduleNumber = _vm->_scene->getScriptModuleNumber();
|
2005-01-22 19:21:38 +00:00
|
|
|
break;
|
|
|
|
case kGameObjectHitZone:
|
|
|
|
case kGameObjectStepZone:
|
2007-06-06 16:37:10 +00:00
|
|
|
if (objectTypeId(objectId) == kGameObjectHitZone)
|
2005-01-22 19:21:38 +00:00
|
|
|
hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId));
|
2007-06-05 15:04:25 +00:00
|
|
|
else
|
2005-01-22 19:21:38 +00:00
|
|
|
hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(objectId));
|
2007-06-05 15:04:25 +00:00
|
|
|
|
2007-06-06 16:37:10 +00:00
|
|
|
if (hitZone == NULL)
|
|
|
|
return;
|
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
scriptEntryPointNumber = hitZone->getScriptNumber();
|
2005-07-29 17:58:00 +00:00
|
|
|
moduleNumber = _vm->_scene->getScriptModuleNumber();
|
2005-01-22 19:21:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-08-16 17:59:49 +00:00
|
|
|
error("Script::sfScriptDoAction wrong object type 0x%X", objectId);
|
2005-01-22 19:21:38 +00:00
|
|
|
}
|
2004-11-12 15:19:32 +00:00
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kScriptEvent;
|
|
|
|
event.op = kEventExecNonBlocking;
|
2005-01-22 19:21:38 +00:00
|
|
|
event.time = 0;
|
|
|
|
event.param = moduleNumber;
|
|
|
|
event.param2 = scriptEntryPointNumber;
|
|
|
|
event.param3 = action; // Action
|
|
|
|
event.param4 = theObject; // Object
|
2005-06-05 09:26:41 +00:00
|
|
|
event.param5 = withObject; // With Object
|
2005-01-22 19:21:38 +00:00
|
|
|
event.param6 = objectId;
|
|
|
|
|
|
|
|
_vm->_events->queue(&event);
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #8 (0x08) nonblocking
|
|
|
|
// Param1: actor id
|
|
|
|
// Param2: actor orientation
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetActorFacing(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2004-12-22 21:04:50 +00:00
|
|
|
int actorDirection;
|
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
2005-10-11 17:39:31 +00:00
|
|
|
actorDirection = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_facingDirection = actor->_actionDirection = actorDirection;
|
|
|
|
actor->_targetObject = ID_NOTHING;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #9 (0x09)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfStartBgdAnim(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId = thread->pop();
|
|
|
|
int16 cycles = thread->pop();
|
2004-12-28 03:44:07 +00:00
|
|
|
|
|
|
|
_vm->_anim->setCycles(animId, cycles);
|
2007-07-06 13:21:43 +00:00
|
|
|
_vm->_anim->setFrameTime(animId, _vm->ticksToMSec(kRepeatSpeedTicks));
|
2005-06-25 15:55:43 +00:00
|
|
|
_vm->_anim->play(animId, 0);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
debug(1, "sfStartBgdAnim(%d, %d)", animId, cycles);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #10 (0x0A)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfStopBgdAnim(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId = thread->pop();
|
2004-12-28 03:44:07 +00:00
|
|
|
|
|
|
|
_vm->_anim->stop(animId);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
debug(1, "sfStopBgdAnim(%d)", animId);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #11 (0x0B) nonblocking
|
|
|
|
// If the parameter is true, the user interface is disabled while script
|
2005-07-29 17:58:00 +00:00
|
|
|
// continues to run. If the parameter is false, the user interface is
|
2004-05-01 14:34:00 +00:00
|
|
|
// reenabled.
|
|
|
|
// Param1: boolean
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfLockUser(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 lock;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
lock = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
if (lock) {
|
2004-08-06 01:39:17 +00:00
|
|
|
_vm->_interface->deactivate();
|
2004-04-12 21:40:49 +00:00
|
|
|
} else {
|
2004-08-06 01:39:17 +00:00
|
|
|
_vm->_interface->activate();
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #12 (0x0C)
|
|
|
|
// Disables mouse input, etc.
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPreDialog(SCRIPTFUNC_PARAMS) {
|
2005-01-06 14:02:53 +00:00
|
|
|
_vm->_interface->deactivate();
|
2005-04-18 10:26:43 +00:00
|
|
|
_vm->_interface->converseClear();
|
2005-01-06 14:02:53 +00:00
|
|
|
if (_vm->_interface->isInMainMode())
|
|
|
|
_vm->_interface->setMode(kPanelConverse);
|
|
|
|
else
|
2005-04-18 20:03:14 +00:00
|
|
|
_vm->_interface->converseDisplayText();
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-06 14:02:53 +00:00
|
|
|
_vm->_interface->setMode(kPanelNull);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #13 (0x0D)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfKillActorThreads(SCRIPTFUNC_PARAMS) {
|
|
|
|
ScriptThread *anotherThread;
|
|
|
|
ScriptThreadList::iterator threadIterator;
|
|
|
|
int16 actorId;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
|
|
|
|
for (threadIterator = _threadList.begin(); threadIterator != _threadList.end(); ++threadIterator) {
|
|
|
|
anotherThread = threadIterator.operator->();
|
|
|
|
if ((anotherThread != thread) && (anotherThread->_threadVars[kThreadVarActor] == actorId)) {
|
2005-04-16 11:03:34 +00:00
|
|
|
anotherThread->_flags &= ~kTFlagWaiting;
|
|
|
|
anotherThread->_flags |= kTFlagAborted;
|
2005-01-22 19:21:38 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #14 (0x0E)
|
2005-01-06 19:15:01 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: object id
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfFaceTowards(SCRIPTFUNC_PARAMS) {
|
2005-01-06 19:15:01 +00:00
|
|
|
int16 actorId;
|
|
|
|
int16 targetObject;
|
|
|
|
ActorData *actor;
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
targetObject = thread->pop();
|
2005-01-06 19:15:01 +00:00
|
|
|
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_targetObject = targetObject;
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #15 (0x0F)
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: target object
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetFollower(SCRIPTFUNC_PARAMS) {
|
2004-12-30 18:45:48 +00:00
|
|
|
int16 actorId;
|
|
|
|
int16 targetObject;
|
2004-12-22 21:04:50 +00:00
|
|
|
|
|
|
|
ActorData *actor;
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
targetObject = thread->pop();
|
2004-12-30 18:45:48 +00:00
|
|
|
|
2005-01-08 20:30:07 +00:00
|
|
|
debug(1, "sfSetFollower(%d, %d) [%d]", actorId, targetObject, _vm->_actor->actorIdToIndex(actorId));
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_targetObject = targetObject;
|
2004-12-22 21:04:50 +00:00
|
|
|
if (targetObject != ID_NOTHING) {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_flags |= kFollower;
|
|
|
|
actor->_actorFlags &= ~kActorNoFollow;
|
2004-12-22 21:04:50 +00:00
|
|
|
} else {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_flags &= ~kFollower;
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-10-27 02:27:54 +00:00
|
|
|
// Script function #16 (0x10)
|
2005-01-22 21:40:54 +00:00
|
|
|
void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 sceneNumber;
|
|
|
|
int16 entrance;
|
|
|
|
|
|
|
|
sceneNumber = thread->pop();
|
|
|
|
entrance = thread->pop();
|
2007-07-05 03:37:23 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
|
|
|
_vm->_gfx->setCursor(kCursorBusy);
|
2005-01-22 21:40:54 +00:00
|
|
|
}
|
2005-01-23 17:06:15 +00:00
|
|
|
|
2007-08-27 13:04:35 +00:00
|
|
|
if (_vm->getGameType() == GType_ITE && sceneNumber < 0) {
|
2007-07-05 03:37:23 +00:00
|
|
|
_vm->shutDown();
|
|
|
|
return;
|
|
|
|
}
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2007-08-27 13:04:35 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM && sceneNumber == 0) {
|
|
|
|
_vm->_scene->creditsScene();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-04 14:37:52 +00:00
|
|
|
// It is possible to leave scene when converse panel is on,
|
|
|
|
// particulalrly it may happen at Moneychanger tent. This
|
2007-08-25 16:02:48 +00:00
|
|
|
// prevents this from happening.
|
2005-06-04 14:37:52 +00:00
|
|
|
if (_vm->_interface->getMode() == kPanelConverse) {
|
|
|
|
_vm->_interface->setMode(kPanelMain);
|
|
|
|
}
|
|
|
|
|
2007-07-05 03:37:23 +00:00
|
|
|
// changeScene calls loadScene which calls setVerb. setVerb resets all pending objects and object flags
|
2007-06-19 02:42:59 +00:00
|
|
|
if (sceneNumber == -1 && _vm->getGameType() == GType_IHNM) {
|
2007-08-13 01:09:48 +00:00
|
|
|
// Return back to the character selection screen in IHNM
|
2007-06-19 02:42:59 +00:00
|
|
|
_vm->_scene->changeScene(154, entrance, kTransitionFade, 8);
|
|
|
|
} else {
|
|
|
|
_vm->_scene->changeScene(sceneNumber, entrance, (sceneNumber == ITE_SCENE_ENDCREDIT1) ? kTransitionFade : kTransitionNoFade);
|
|
|
|
}
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2007-07-05 03:37:23 +00:00
|
|
|
if (_vm->_interface->getMode() == kPanelPlacard ||
|
|
|
|
_vm->_interface->getMode() == kPanelCutaway ||
|
|
|
|
_vm->_interface->getMode() == kPanelVideo) {
|
|
|
|
_vm->_gfx->showCursor(true);
|
|
|
|
_vm->_interface->setMode(kPanelMain);
|
|
|
|
}
|
|
|
|
|
2006-01-13 20:20:01 +00:00
|
|
|
_pendingVerb = _vm->_script->getVerbType(kVerbNone);
|
2005-01-22 21:40:54 +00:00
|
|
|
_currentObject[0] = _currentObject[1] = ID_NOTHING;
|
2007-07-05 03:37:23 +00:00
|
|
|
showVerb(); // calls setStatusText("")
|
|
|
|
|
2007-08-25 16:02:48 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
2007-08-27 14:22:24 +00:00
|
|
|
// There are some cutaways which are not removed by game scripts, like the cutaway
|
|
|
|
// after the intro of IHNM or the cutaway at the end of Ellen's part in the IHNM demo.
|
|
|
|
// Clear any remaining cutaways here
|
|
|
|
_vm->_anim->clearCutaway();
|
2007-07-05 03:37:23 +00:00
|
|
|
_vm->_gfx->setCursor(kCursorNormal);
|
2007-08-25 16:02:48 +00:00
|
|
|
}
|
2004-10-27 02:27:54 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #17 (0x11)
|
2005-04-24 15:17:38 +00:00
|
|
|
// Param1: object id
|
|
|
|
// Param2: sprite index
|
|
|
|
void Script::sfSetObjImage(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId;
|
|
|
|
uint16 spriteId;
|
|
|
|
ObjectData *obj;
|
2004-11-07 15:28:20 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
objectId = thread->pop();
|
|
|
|
spriteId = thread->pop();
|
2004-11-07 15:28:20 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2007-08-13 01:20:42 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
|
|
|
obj->_spriteListResourceId = spriteId;
|
|
|
|
else
|
|
|
|
obj->_spriteListResourceId = OBJ_SPRITE_BASE + spriteId;
|
2005-04-24 15:17:38 +00:00
|
|
|
_vm->_interface->refreshInventory();
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #18 (0x12)
|
2005-04-24 15:17:38 +00:00
|
|
|
// Param1: object id
|
|
|
|
// Param2: name index
|
|
|
|
void Script::sfSetObjName(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId;
|
|
|
|
uint16 nameIdx;
|
|
|
|
ObjectData *obj;
|
2004-11-07 15:35:42 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
objectId = thread->pop();
|
|
|
|
nameIdx = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
obj->_nameIndex = nameIdx;
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #19 (0x13)
|
2005-04-24 15:17:38 +00:00
|
|
|
// Param1: object id
|
|
|
|
void Script::sfGetObjImage(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId;
|
|
|
|
ObjectData *obj;
|
2004-11-07 15:35:42 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
objectId = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-07-21 01:33:28 +00:00
|
|
|
|
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
2005-08-10 14:53:17 +00:00
|
|
|
thread->_returnValue = obj->_spriteListResourceId;
|
2005-07-21 01:33:28 +00:00
|
|
|
else
|
2005-08-10 14:53:17 +00:00
|
|
|
thread->_returnValue = obj->_spriteListResourceId - OBJ_SPRITE_BASE;
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #20 (0x14)
|
2005-06-19 14:06:20 +00:00
|
|
|
void Script::sfGetNumber(SCRIPTFUNC_PARAMS) {
|
|
|
|
if (_vm->_interface->_statusTextInputState == kStatusTextInputFirstRun) {
|
|
|
|
_vm->_interface->enterStatusString();
|
|
|
|
thread->wait(kWaitTypeStatusTextInput);
|
|
|
|
disContinue = true;
|
|
|
|
} else {
|
|
|
|
if (_vm->_interface->_statusTextInputState == kStatusTextInputAborted) {
|
|
|
|
thread->_returnValue = -1;
|
|
|
|
} else {
|
|
|
|
thread->_returnValue = atoi(_vm->_interface->_statusTextInputString);
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-06-19 14:06:20 +00:00
|
|
|
_vm->_interface->_statusTextInputState = kStatusTextInputFirstRun;
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #21 (0x15)
|
2004-12-28 21:27:18 +00:00
|
|
|
// Param1: door #
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfScriptOpenDoor(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 doorNumber;
|
|
|
|
doorNumber = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-01-07 22:18:53 +00:00
|
|
|
if (_vm->_scene->getFlags() & kSceneFlagISO) {
|
2005-04-03 15:32:04 +00:00
|
|
|
_vm->_isoMap->setTileDoorState(doorNumber, 1);
|
2004-12-28 21:27:18 +00:00
|
|
|
} else {
|
|
|
|
_vm->_scene->setDoorState(doorNumber, 0);
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #22 (0x16)
|
2004-12-28 21:27:18 +00:00
|
|
|
// Param1: door #
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfScriptCloseDoor(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 doorNumber;
|
|
|
|
doorNumber = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-01-07 22:18:53 +00:00
|
|
|
if (_vm->_scene->getFlags() & kSceneFlagISO) {
|
2005-04-03 15:32:04 +00:00
|
|
|
_vm->_isoMap->setTileDoorState(doorNumber, 0);
|
2004-12-28 21:27:18 +00:00
|
|
|
} else {
|
|
|
|
_vm->_scene->setDoorState(doorNumber, 0xff);
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #23 (0x17)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetBgdAnimSpeed(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId = thread->pop();
|
|
|
|
int16 speed = thread->pop();
|
2004-12-28 03:44:07 +00:00
|
|
|
|
2007-07-06 13:21:43 +00:00
|
|
|
_vm->_anim->setFrameTime(animId, _vm->ticksToMSec(speed));
|
2004-12-28 03:44:07 +00:00
|
|
|
debug(1, "sfSetBgdAnimSpeed(%d, %d)", animId, speed);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #24 (0x18)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::SF_cycleColors(SCRIPTFUNC_PARAMS) {
|
2005-08-10 17:39:29 +00:00
|
|
|
SF_stub("SF_cycleColors", thread, nArgs);
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-08-10 17:39:29 +00:00
|
|
|
error("Please, report this to sev");
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #25 (0x19)
|
2004-12-28 21:27:18 +00:00
|
|
|
// Param1: actor id
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfDoCenterActor(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
|
|
|
actorId = thread->pop();
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
_vm->_actor->_centerActor = _vm->_actor->getActor(actorId);
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #26 (0x1A) nonblocking
|
2005-07-29 17:58:00 +00:00
|
|
|
// Starts the specified animation
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfStartBgdAnimSpeed(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId = thread->pop();
|
|
|
|
int16 cycles = thread->pop();
|
|
|
|
int16 speed = thread->pop();
|
2004-12-28 03:44:07 +00:00
|
|
|
|
|
|
|
_vm->_anim->setCycles(animId, cycles);
|
2007-07-06 13:21:43 +00:00
|
|
|
_vm->_anim->setFrameTime(animId, _vm->ticksToMSec(speed));
|
2005-06-25 15:55:43 +00:00
|
|
|
_vm->_anim->play(animId, 0);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
debug(1, "sfStartBgdAnimSpeed(%d, %d, %d)", animId, cycles, speed);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #27 (0x1B) nonblocking
|
|
|
|
// Param1: actor id
|
2004-12-29 21:49:25 +00:00
|
|
|
// Param2: actor x
|
|
|
|
// Param3: actor y
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfScriptWalkToAsync(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2005-01-15 20:12:49 +00:00
|
|
|
Location actorLocation;
|
2004-12-29 21:49:25 +00:00
|
|
|
ActorData *actor;
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actorLocation.z = actor->_location.z;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_flags &= ~kFollower;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
_vm->_actor->actorWalkTo(actorId, actorLocation);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #28 (0x1C)
|
2005-04-16 20:59:24 +00:00
|
|
|
void Script::sfEnableZone(SCRIPTFUNC_PARAMS) {
|
2005-04-22 16:41:44 +00:00
|
|
|
uint16 objectId = thread->pop();
|
2005-04-16 20:59:24 +00:00
|
|
|
int16 flag = thread->pop();
|
|
|
|
HitZone *hitZone;
|
|
|
|
|
2007-06-05 22:38:43 +00:00
|
|
|
if (objectTypeId(objectId) == 0)
|
2007-06-04 23:10:59 +00:00
|
|
|
return;
|
2007-06-05 15:04:25 +00:00
|
|
|
else if (objectTypeId(objectId) == kGameObjectHitZone)
|
|
|
|
hitZone = _vm->_scene->_objectMap->getHitZone(objectIdToIndex(objectId));
|
|
|
|
else
|
2005-04-22 16:41:44 +00:00
|
|
|
hitZone = _vm->_scene->_actionMap->getHitZone(objectIdToIndex(objectId));
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2007-06-06 16:37:10 +00:00
|
|
|
if (hitZone == NULL)
|
|
|
|
return;
|
|
|
|
|
2005-04-16 20:59:24 +00:00
|
|
|
if (flag) {
|
|
|
|
hitZone->setFlag(kHitZoneEnabled);
|
|
|
|
} else {
|
|
|
|
hitZone->clearFlag(kHitZoneEnabled);
|
2005-08-10 14:53:17 +00:00
|
|
|
_vm->_actor->_protagonist->_lastZone = NULL;
|
2005-04-16 20:59:24 +00:00
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #29 (0x1D)
|
2004-12-24 10:22:01 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: current action
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetActorState(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2004-12-24 10:22:01 +00:00
|
|
|
int currentAction;
|
|
|
|
ActorData *actor;
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
currentAction = thread->pop();
|
2004-12-24 10:22:01 +00:00
|
|
|
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
|
|
|
|
|
|
|
if ((currentAction >= kActionWalkToPoint) && (currentAction <= kActionWalkToPoint)) {
|
|
|
|
wakeUpActorThread(kWaitTypeWalk, actor);
|
|
|
|
}
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_currentAction = currentAction;
|
|
|
|
actor->_actorFlags &= ~kActorBackwards;
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #30 (0x1E) nonblocking
|
|
|
|
// Param1: actor id
|
|
|
|
// Param2: actor pos x
|
|
|
|
// Param3: actor pos y
|
2005-01-22 21:40:54 +00:00
|
|
|
void Script::sfScriptMoveTo(SCRIPTFUNC_PARAMS) {
|
2005-06-04 17:52:37 +00:00
|
|
|
int16 objectId;
|
|
|
|
Location location;
|
2004-12-22 21:04:50 +00:00
|
|
|
ActorData *actor;
|
2005-06-04 17:52:37 +00:00
|
|
|
ObjectData *obj;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-04 17:52:37 +00:00
|
|
|
objectId = thread->pop();
|
|
|
|
location.x = thread->pop();
|
|
|
|
location.y = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-04 17:52:37 +00:00
|
|
|
if (_vm->_actor->validActorId(objectId)) {
|
|
|
|
actor = _vm->_actor->getActor(objectId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_location.x = location.x;
|
|
|
|
actor->_location.y = location.y;
|
2005-06-04 17:52:37 +00:00
|
|
|
} else {
|
|
|
|
if (_vm->_actor->validObjId(objectId)) {
|
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
obj->_location.x = location.x;
|
|
|
|
obj->_location.y = location.y;
|
2005-06-04 17:52:37 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-10-27 22:17:11 +00:00
|
|
|
// Script function #31 (0x21)
|
2005-05-08 14:04:06 +00:00
|
|
|
// Param1: sceneNumber
|
2005-04-17 11:53:25 +00:00
|
|
|
void Script::sfSceneEq(SCRIPTFUNC_PARAMS) {
|
2005-05-08 14:04:06 +00:00
|
|
|
int16 sceneNumber = thread->pop();
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
if (_vm->_scene->getSceneResourceId(sceneNumber) == _vm->_scene->currentSceneResourceId())
|
2005-01-21 21:55:54 +00:00
|
|
|
thread->_returnValue = 1;
|
2005-07-29 17:58:00 +00:00
|
|
|
else
|
2005-01-21 21:55:54 +00:00
|
|
|
thread->_returnValue = 0;
|
2004-10-27 22:17:11 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #32 (0x20)
|
2005-04-23 12:34:35 +00:00
|
|
|
void Script::sfDropObject(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 objectId;
|
|
|
|
uint16 spriteId;
|
|
|
|
int16 x;
|
|
|
|
int16 y;
|
2005-04-18 10:26:43 +00:00
|
|
|
ObjectData *obj;
|
2004-11-07 15:11:04 +00:00
|
|
|
|
2005-04-23 12:34:35 +00:00
|
|
|
objectId = thread->pop();
|
|
|
|
spriteId = thread->pop();
|
|
|
|
x = thread->pop();
|
|
|
|
y = thread->pop();
|
2004-11-07 15:11:04 +00:00
|
|
|
|
2005-04-23 12:34:35 +00:00
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-04-18 10:26:43 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
if (obj->_sceneNumber == ITE_SCENE_INV) {
|
2005-04-23 12:34:35 +00:00
|
|
|
_vm->_interface->removeFromInventory(objectId);
|
2004-11-07 15:11:04 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
obj->_sceneNumber = _vm->_scene->currentSceneNumber();
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2007-08-24 11:44:18 +00:00
|
|
|
// HACK for the compact disk in Ellen's chapter
|
2007-06-20 16:36:29 +00:00
|
|
|
// Change the scene number of the compact disk so that it's not shown. It will be shown
|
|
|
|
// once Ellen says that there's something different (i.e. after speaking with AM)
|
2007-08-24 11:44:18 +00:00
|
|
|
// See Actor::actorSpeech for the other part of this hack
|
2007-06-20 16:36:29 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 3 &&
|
|
|
|
_vm->_scene->currentSceneNumber() == 59 && obj->_id == 16385)
|
|
|
|
obj->_sceneNumber = -1;
|
|
|
|
|
2007-07-29 19:06:17 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
|
|
|
if (_vm->getGameId() != GID_IHNM_DEMO) {
|
|
|
|
obj->_spriteListResourceId = spriteId;
|
|
|
|
} else {
|
|
|
|
// Don't update the object's _spriteListResourceId in the IHNM demo, as this function is
|
|
|
|
// called incorrectly there (with spriteId == 0, which resets the object sprites)
|
|
|
|
}
|
|
|
|
} else {
|
2005-08-10 14:53:17 +00:00
|
|
|
obj->_spriteListResourceId = OBJ_SPRITE_BASE + spriteId;
|
2007-07-29 19:06:17 +00:00
|
|
|
}
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
obj->_location.x = x;
|
|
|
|
obj->_location.y = y;
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #33 (0x21)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfFinishBgdAnim(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId = thread->pop();
|
2004-12-28 04:09:10 +00:00
|
|
|
|
|
|
|
_vm->_anim->finish(animId);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2004-12-28 04:09:10 +00:00
|
|
|
debug(1, "sfFinishBgdAnim(%d)", animId);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #34 (0x22)
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param1: actor id 1
|
|
|
|
// Param2: actor id 2
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSwapActors(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId1;
|
|
|
|
int16 actorId2;
|
2004-12-22 21:04:50 +00:00
|
|
|
ActorData *actor1;
|
|
|
|
ActorData *actor2;
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId1 = thread->pop();
|
|
|
|
actorId2 = thread->pop();
|
2004-12-22 21:04:50 +00:00
|
|
|
|
|
|
|
actor1 = _vm->_actor->getActor(actorId1);
|
|
|
|
actor2 = _vm->_actor->getActor(actorId2);
|
2005-05-11 06:57:58 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
SWAP(actor1->_location, actor2->_location);
|
2004-12-22 21:04:50 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
if (actor1->_flags & kProtagonist) {
|
|
|
|
actor1->_flags &= ~kProtagonist;
|
|
|
|
actor2->_flags |= kProtagonist;
|
2004-12-22 21:04:50 +00:00
|
|
|
_vm->_actor->_protagonist = _vm->_actor->_centerActor = actor2;
|
2007-06-17 15:45:09 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
|
|
|
_vm->_scene->setProtag(actorId2);
|
2005-08-10 14:53:17 +00:00
|
|
|
} else if (actor2->_flags & kProtagonist) {
|
|
|
|
actor2->_flags &= ~kProtagonist;
|
|
|
|
actor1->_flags |= kProtagonist;
|
2004-12-22 21:04:50 +00:00
|
|
|
_vm->_actor->_protagonist = _vm->_actor->_centerActor = actor1;
|
2007-06-17 15:45:09 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM)
|
|
|
|
_vm->_scene->setProtag(actorId1);
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #35 (0x23)
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param1: string rid
|
|
|
|
// Param2: actorscount
|
|
|
|
// Param3: actor id1
|
|
|
|
///....
|
|
|
|
// Param3: actor idN
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSimulSpeech(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 stringId;
|
|
|
|
int16 actorsCount;
|
2004-12-22 21:04:50 +00:00
|
|
|
int i;
|
|
|
|
uint16 actorsIds[ACTOR_SPEECH_ACTORS_MAX];
|
|
|
|
const char *string;
|
2005-05-22 01:20:47 +00:00
|
|
|
int16 sampleResourceId = -1;
|
2004-12-22 21:04:50 +00:00
|
|
|
|
|
|
|
stringId = thread->pop();
|
2005-01-21 21:55:54 +00:00
|
|
|
actorsCount = thread->pop();
|
2004-12-22 21:04:50 +00:00
|
|
|
|
|
|
|
if (actorsCount > ACTOR_SPEECH_ACTORS_MAX)
|
|
|
|
error("sfSimulSpeech actorsCount=0x%X exceed ACTOR_SPEECH_ACTORS_MAX", actorsCount);
|
|
|
|
|
|
|
|
for (i = 0; i < actorsCount; i++)
|
2005-01-21 21:55:54 +00:00
|
|
|
actorsIds[i] = thread->pop();
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
string = thread->_strings->getString(stringId);
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-05-22 01:20:47 +00:00
|
|
|
if (thread->_voiceLUT->voices) {
|
2005-07-21 01:33:28 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM && stringId >= 338) {
|
2005-05-22 01:20:47 +00:00
|
|
|
sampleResourceId = -1;
|
2005-07-21 01:33:28 +00:00
|
|
|
} else {
|
|
|
|
sampleResourceId = thread->_voiceLUT->voices[stringId];
|
|
|
|
if (sampleResourceId <= 0 || sampleResourceId > 4000)
|
|
|
|
sampleResourceId = -1;
|
|
|
|
}
|
2005-05-22 01:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_actor->simulSpeech(string, actorsIds, actorsCount, 0, sampleResourceId);
|
|
|
|
thread->wait(kWaitTypeSpeech);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #36 (0x24) ?
|
|
|
|
// Param1: actor id
|
2004-12-29 21:49:25 +00:00
|
|
|
// Param2: actor x
|
|
|
|
// Param3: actor y
|
|
|
|
// Param4: actor walk flag
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfScriptWalk(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2005-01-15 20:12:49 +00:00
|
|
|
Location actorLocation;
|
2004-12-29 21:49:25 +00:00
|
|
|
ActorData *actor;
|
|
|
|
uint16 walkFlags;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
|
|
|
walkFlags = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actorLocation.z = actor->_location.z;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
_vm->_actor->realLocation(actorLocation, ID_NOTHING, walkFlags);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_flags &= ~kFollower;
|
2004-12-29 21:49:25 +00:00
|
|
|
|
|
|
|
if (_vm->_actor->actorWalkTo(actorId, actorLocation) && !(walkFlags & kWalkAsync)) {
|
|
|
|
thread->waitWalk(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (walkFlags & kWalkBackPedal) {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags |= kActorBackwards;
|
2004-12-29 21:49:25 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags = (actor->_actorFlags & ~kActorFacingMask) | (walkFlags & kActorFacingMask);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #37 (0x25) nonblocking
|
|
|
|
// Param1: actor id
|
2004-11-01 10:49:21 +00:00
|
|
|
// Param2: flags telling how to cycle the frames
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param3: cycle frame number
|
|
|
|
// Param4: cycle delay
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2005-06-05 16:53:53 +00:00
|
|
|
int16 flags;
|
2004-12-25 11:17:03 +00:00
|
|
|
int cycleFrameSequence;
|
2004-12-22 21:04:50 +00:00
|
|
|
int cycleDelay;
|
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
flags = thread->pop();
|
|
|
|
cycleFrameSequence = thread->pop();
|
2005-10-11 17:39:31 +00:00
|
|
|
cycleDelay = thread->pop();
|
2004-12-22 21:04:50 +00:00
|
|
|
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
|
|
|
|
|
|
|
if (flags & kCyclePong) {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_currentAction = kActionPongFrames;
|
2004-12-22 21:04:50 +00:00
|
|
|
} else {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_currentAction = kActionCycleFrames;
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags &= ~(kActorContinuous | kActorRandom | kActorBackwards);
|
2004-12-22 21:04:50 +00:00
|
|
|
|
|
|
|
if (!(flags & kCycleOnce)) {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags |= kActorContinuous;
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
|
|
|
if (flags & kCycleRandom) {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags |= kActorRandom;
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
|
|
|
if (flags & kCycleReverse) {
|
2007-07-07 00:53:16 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM &&
|
|
|
|
_vm->_scene->currentChapterNumber() == 2 && _vm->_scene->currentSceneNumber() == 41) {
|
|
|
|
// Prevent Benny from walking backwards after talking to the child via the monitor. This occurs in the
|
|
|
|
// original as well, and is fixed by not setting the kActorBackwards flag at this point
|
|
|
|
} else {
|
|
|
|
actor->_actorFlags |= kActorBackwards;
|
|
|
|
}
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-10-11 18:11:58 +00:00
|
|
|
actor->_cycleFrameSequence = cycleFrameSequence;
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_cycleTimeCount = 0;
|
|
|
|
actor->_cycleDelay = cycleDelay;
|
|
|
|
actor->_actionCycle = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #38 (0x26) nonblocking
|
|
|
|
// Param1: actor id
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param2: frame type
|
|
|
|
// Param3: frame offset
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetFrame(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2004-12-22 21:04:50 +00:00
|
|
|
int frameType;
|
|
|
|
int frameOffset;
|
|
|
|
ActorData *actor;
|
|
|
|
ActorFrameRange *frameRange;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
frameType = thread->pop();
|
|
|
|
frameOffset = thread->pop();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
frameRange = _vm->_actor->getActorFrameRange(actorId, frameType);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_frameNumber = frameRange->frameIndex + frameOffset;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
if (actor->_currentAction != kActionFall) {
|
|
|
|
actor->_currentAction = kActionFreeze;
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #39 (0x27)
|
|
|
|
// Sets the right-hand portrait
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetPortrait(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 param = thread->pop();
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
_vm->_interface->setRightPortrait(param);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #40 (0x28)
|
|
|
|
// Sets the left-hand portrait
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetProtagPortrait(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 param = thread->pop();
|
2004-10-21 06:49:11 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
_vm->_interface->setLeftPortrait(param);
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #41 (0x29) nonblocking
|
|
|
|
// Links the specified animations for playback
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Param1: ?
|
|
|
|
// Param2: total linked frame count
|
|
|
|
// Param3: animation id link target
|
|
|
|
// Param4: animation id link source
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfChainBgdAnim(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId1 = thread->pop();
|
|
|
|
int16 animId = thread->pop();
|
|
|
|
int16 cycles = thread->pop();
|
|
|
|
int16 speed = thread->pop();
|
2004-12-30 18:45:48 +00:00
|
|
|
|
|
|
|
if (speed >= 0) {
|
|
|
|
_vm->_anim->setCycles(animId, cycles);
|
|
|
|
_vm->_anim->stop(animId);
|
2007-07-06 13:21:43 +00:00
|
|
|
_vm->_anim->setFrameTime(animId, _vm->ticksToMSec(speed));
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-30 18:45:48 +00:00
|
|
|
_vm->_anim->link(animId1, animId);
|
|
|
|
debug(1, "sfChainBgdAnim(%d, %d, %d, %d)", animId1, animId, cycles, speed);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #42 (0x2A)
|
2005-04-16 11:03:34 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: actor x
|
|
|
|
// Param3: actor y
|
|
|
|
// Param4: frame seq
|
|
|
|
void Script::sfScriptSpecialWalk(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
int16 walkFrameSequence;
|
|
|
|
Location actorLocation;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
2005-10-11 17:39:31 +00:00
|
|
|
walkFrameSequence = thread->pop();
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actorLocation.z = actor->_location.z;
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
_vm->_actor->actorWalkTo(actorId, actorLocation);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_walkFrameSequence = walkFrameSequence;
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #43 (0x2B) nonblocking
|
|
|
|
// Param1: actor id
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param2: actor x
|
|
|
|
// Param3: actor y
|
|
|
|
// Param4: actor direction
|
2004-05-01 14:34:00 +00:00
|
|
|
// Param5: actor action
|
2004-12-22 21:04:50 +00:00
|
|
|
// Param6: actor frame number
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPlaceActor(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 actorId;
|
2005-01-15 20:12:49 +00:00
|
|
|
Location actorLocation;
|
2004-12-22 21:04:50 +00:00
|
|
|
int actorDirection;
|
|
|
|
int frameType;
|
|
|
|
int frameOffset;
|
|
|
|
ActorData *actor;
|
|
|
|
ActorFrameRange *frameRange;
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
2005-10-11 17:39:31 +00:00
|
|
|
actorDirection = thread->pop();
|
|
|
|
frameType = thread->pop();
|
|
|
|
frameOffset = thread->pop();
|
2005-01-02 20:29:27 +00:00
|
|
|
|
2005-10-07 05:31:13 +00:00
|
|
|
debug(1, "sfPlaceActor(id = 0x%x, x=%d, y=%d, dir=%d, frameType=%d, frameOffset=%d)", actorId, actorLocation.x,
|
2005-01-02 20:29:27 +00:00
|
|
|
actorLocation.y, actorDirection, frameType, frameOffset);
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_location.x = actorLocation.x;
|
|
|
|
actor->_location.y = actorLocation.y;
|
|
|
|
actor->_facingDirection = actor->_actionDirection = actorDirection;
|
2004-12-24 10:22:01 +00:00
|
|
|
|
2005-10-09 01:43:08 +00:00
|
|
|
if (!actor->_frames)
|
2006-01-13 20:20:01 +00:00
|
|
|
_vm->_actor->loadActorResources(actor); //? is not it already loaded ?
|
2005-10-09 01:43:08 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
if (frameType >= 0) {
|
|
|
|
frameRange = _vm->_actor->getActorFrameRange(actorId, frameType);
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-03-18 17:11:37 +00:00
|
|
|
if (frameRange->frameCount <= frameOffset) {
|
2007-05-28 00:36:11 +00:00
|
|
|
warning("Wrong frameOffset 0x%X", frameOffset);
|
2005-03-18 17:11:37 +00:00
|
|
|
}
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_frameNumber = frameRange->frameIndex + frameOffset;
|
|
|
|
actor->_currentAction = kActionFreeze;
|
2004-12-22 21:04:50 +00:00
|
|
|
} else {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_currentAction = kActionWait;
|
2004-12-22 21:04:50 +00:00
|
|
|
}
|
2004-12-17 20:38:17 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_targetObject = ID_NOTHING;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 14:34:00 +00:00
|
|
|
// Script function #44 (0x2C) nonblocking
|
2005-07-29 17:58:00 +00:00
|
|
|
// Checks to see if the user has interrupted a currently playing
|
|
|
|
// game cinematic. Pushes a zero or positive value if the game
|
2004-05-01 14:34:00 +00:00
|
|
|
// has not been interrupted.
|
2005-04-17 11:53:25 +00:00
|
|
|
void Script::sfCheckUserInterrupt(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
thread->_returnValue = (_skipSpeeches == true);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #45 (0x2D)
|
2005-04-16 11:03:34 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: object id
|
|
|
|
// Param3: actor x
|
|
|
|
// Param4: actor y
|
|
|
|
// Param5: actor walk flag
|
|
|
|
void Script::sfScriptWalkRelative(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
int16 objectId;
|
|
|
|
uint16 walkFlags;
|
|
|
|
Location actorLocation;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
objectId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
2005-10-11 17:39:31 +00:00
|
|
|
walkFlags = thread->pop();
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actorLocation.z = actor->_location.z;
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
_vm->_actor->realLocation(actorLocation, objectId, walkFlags);
|
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_flags &= ~kFollower;
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
if (_vm->_actor->actorWalkTo(actorId, actorLocation) && !(walkFlags & kWalkAsync)) {
|
|
|
|
thread->waitWalk(actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (walkFlags & kWalkBackPedal) {
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags |= kActorBackwards;
|
2005-04-16 11:03:34 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_actorFlags = (actor->_actorFlags & ~kActorFacingMask) | (walkFlags & kActorFacingMask);
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #46 (0x2E)
|
2005-04-16 11:03:34 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: object id
|
|
|
|
// Param3: actor x
|
|
|
|
// Param4: actor y
|
|
|
|
// Param5: actor walk flag
|
|
|
|
void Script::sfScriptMoveRelative(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
int16 objectId;
|
|
|
|
uint16 walkFlags;
|
|
|
|
Location actorLocation;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
objectId = thread->pop();
|
|
|
|
actorLocation.x = thread->pop();
|
|
|
|
actorLocation.y = thread->pop();
|
2005-10-11 17:39:31 +00:00
|
|
|
walkFlags = thread->pop();
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actorLocation.z = actor->_location.z;
|
2005-04-16 11:03:34 +00:00
|
|
|
|
|
|
|
_vm->_actor->realLocation(actorLocation, objectId, walkFlags);
|
|
|
|
|
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_location = actorLocation;
|
|
|
|
actor->_actorFlags = (actor->_actorFlags & ~kActorFacingMask) | (walkFlags & kActorFacingMask);
|
2004-10-27 22:17:11 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #47 (0x2F)
|
2005-05-22 01:20:47 +00:00
|
|
|
void Script::sfSimulSpeech2(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 stringId;
|
|
|
|
int16 actorsCount;
|
|
|
|
int16 speechFlags;
|
|
|
|
int i;
|
|
|
|
uint16 actorsIds[ACTOR_SPEECH_ACTORS_MAX];
|
|
|
|
const char *string;
|
|
|
|
int16 sampleResourceId = -1;
|
|
|
|
|
|
|
|
stringId = thread->pop();
|
|
|
|
actorsCount = thread->pop();
|
|
|
|
speechFlags = thread->pop();
|
|
|
|
|
|
|
|
if (actorsCount > ACTOR_SPEECH_ACTORS_MAX)
|
|
|
|
error("sfSimulSpeech2 actorsCount=0x%X exceed ACTOR_SPEECH_ACTORS_MAX", actorsCount);
|
|
|
|
|
|
|
|
for (i = 0; i < actorsCount; i++)
|
|
|
|
actorsIds[i] = thread->pop();
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-05-22 01:20:47 +00:00
|
|
|
string = thread->_strings->getString(stringId);
|
|
|
|
|
|
|
|
if (thread->_voiceLUT->voices) {
|
|
|
|
sampleResourceId = thread->_voiceLUT->voices[stringId];
|
|
|
|
if (sampleResourceId <= 0 || sampleResourceId > 4000)
|
|
|
|
sampleResourceId = -1;
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-05-22 01:20:47 +00:00
|
|
|
_vm->_actor->simulSpeech(string, actorsIds, actorsCount, speechFlags, sampleResourceId);
|
|
|
|
thread->wait(kWaitTypeSpeech);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 16:07:46 +00:00
|
|
|
|
2004-10-27 22:17:11 +00:00
|
|
|
// Script function #48 (0x30)
|
2005-01-03 21:17:32 +00:00
|
|
|
// Param1: string rid
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPlacard(SCRIPTFUNC_PARAMS) {
|
2005-01-03 21:17:32 +00:00
|
|
|
int stringId;
|
2005-07-09 16:23:45 +00:00
|
|
|
Surface *backBuffer = _vm->_gfx->getBackBuffer();
|
|
|
|
static PalEntry cur_pal[PAL_ENTRIES];
|
|
|
|
PalEntry *pal;
|
2005-08-10 14:11:22 +00:00
|
|
|
Event event;
|
|
|
|
Event *q_event;
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2005-01-06 16:07:46 +00:00
|
|
|
thread->wait(kWaitTypePlacard);
|
|
|
|
|
|
|
|
_vm->_interface->rememberMode();
|
|
|
|
_vm->_interface->setMode(kPanelPlacard);
|
2004-12-29 16:10:53 +00:00
|
|
|
|
2005-01-06 16:07:46 +00:00
|
|
|
stringId = thread->pop();
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kCursorEvent;
|
|
|
|
event.op = kEventHide;
|
2005-01-06 16:07:46 +00:00
|
|
|
|
|
|
|
q_event = _vm->_events->queue(&event);
|
|
|
|
|
2004-12-29 16:10:53 +00:00
|
|
|
_vm->_gfx->getCurrentPal(cur_pal);
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kPalEvent;
|
|
|
|
event.op = kEventPalToBlack;
|
2005-01-06 16:07:46 +00:00
|
|
|
event.time = 0;
|
|
|
|
event.duration = kNormalFadeDuration;
|
|
|
|
event.data = cur_pal;
|
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kInterfaceEvent;
|
|
|
|
event.op = kEventClearStatus;
|
2005-01-06 16:07:46 +00:00
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2004-12-29 16:10:53 +00:00
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kGraphicsEvent;
|
|
|
|
event.op = kEventSetFlag;
|
2005-01-06 16:07:46 +00:00
|
|
|
event.param = RF_PLACARD;
|
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kGraphicsEvent;
|
|
|
|
event.op = kEventFillRect;
|
2005-07-09 16:23:45 +00:00
|
|
|
event.data = backBuffer;
|
2005-01-06 16:07:46 +00:00
|
|
|
event.param = 138;
|
|
|
|
event.param2 = 0;
|
2005-10-08 15:20:11 +00:00
|
|
|
event.param3 = _vm->_scene->getHeight();
|
2005-01-06 16:07:46 +00:00
|
|
|
event.param4 = 0;
|
2005-01-09 23:41:22 +00:00
|
|
|
event.param5 = _vm->getDisplayWidth();
|
2005-01-06 16:07:46 +00:00
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2004-12-29 16:10:53 +00:00
|
|
|
|
2004-12-31 17:39:57 +00:00
|
|
|
// Put the text in the center of the viewport, assuming it will fit on
|
|
|
|
// one line. If we cannot make that assumption we'll need to extend
|
|
|
|
// the text drawing function so that it can center text around a point.
|
|
|
|
// It doesn't end up in exactly the same spot as the original did it,
|
|
|
|
// but it's close enough for now at least.
|
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
TextListEntry textEntry;
|
2005-01-06 16:07:46 +00:00
|
|
|
|
2005-11-26 12:08:05 +00:00
|
|
|
textEntry.knownColor = kKnownColorBrightWhite;
|
|
|
|
textEntry.effectKnownColor = kKnownColorBlack;
|
2005-07-14 17:46:21 +00:00
|
|
|
textEntry.point.x = _vm->getDisplayWidth() / 2;
|
2005-11-19 12:41:23 +00:00
|
|
|
textEntry.point.y = (_vm->_scene->getHeight() - _vm->_font->getHeight(kKnownFontMedium)) / 2;
|
2005-11-03 18:20:12 +00:00
|
|
|
textEntry.font = kKnownFontMedium;
|
2005-07-14 17:46:21 +00:00
|
|
|
textEntry.flags = (FontEffectFlags)(kFontOutline | kFontCentered);
|
|
|
|
textEntry.text = thread->_strings->getString(stringId);
|
2004-12-29 16:10:53 +00:00
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
_placardTextEntry = _vm->_scene->_textList.addEntry(textEntry);
|
2005-01-06 16:07:46 +00:00
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kTextEvent;
|
|
|
|
event.op = kEventDisplay;
|
2005-07-14 17:46:21 +00:00
|
|
|
event.data = _placardTextEntry;
|
2005-01-06 16:07:46 +00:00
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2004-12-29 16:10:53 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_scene->getBGPal(pal);
|
2004-12-29 16:10:53 +00:00
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kPalEvent;
|
|
|
|
event.op = kEventBlackToPal;
|
2005-01-06 16:07:46 +00:00
|
|
|
event.time = 0;
|
|
|
|
event.duration = kNormalFadeDuration;
|
|
|
|
event.data = pal;
|
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kScriptEvent;
|
|
|
|
event.op = kEventThreadWake;
|
2005-01-06 16:07:46 +00:00
|
|
|
event.param = kWaitTypePlacard;
|
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2005-01-02 20:29:27 +00:00
|
|
|
|
2004-10-27 22:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #49 (0x31)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) {
|
2005-01-06 16:07:46 +00:00
|
|
|
thread->wait(kWaitTypePlacard);
|
|
|
|
|
2007-07-30 14:22:53 +00:00
|
|
|
_vm->_scene->clearPlacard();
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2005-07-25 02:38:43 +00:00
|
|
|
void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) {
|
2007-07-30 11:55:11 +00:00
|
|
|
thread->wait(kWaitTypePlacard);
|
|
|
|
|
2007-08-02 01:04:44 +00:00
|
|
|
int stringId = thread->pop();
|
|
|
|
_vm->_scene->showPsychicProfile(thread->_strings->getString(stringId));
|
2005-07-25 02:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfPsychicProfileOff(SCRIPTFUNC_PARAMS) {
|
2007-07-30 14:22:53 +00:00
|
|
|
thread->wait(kWaitTypePlacard);
|
|
|
|
|
2007-07-31 17:41:10 +00:00
|
|
|
// This is called a while after the psychic profile is
|
|
|
|
// opened, to close it automatically
|
|
|
|
_vm->_scene->clearPsychicProfile();
|
2005-07-25 02:38:43 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #50 (0x32)
|
2005-04-21 01:30:07 +00:00
|
|
|
void Script::sfSetProtagState(SCRIPTFUNC_PARAMS) {
|
|
|
|
int protagState = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-04-21 01:30:07 +00:00
|
|
|
_vm->_actor->setProtagState(protagState);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #51 (0x33)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfResumeBgdAnim(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 animId = thread->pop();
|
|
|
|
int16 cycles = thread->pop();
|
2004-12-28 04:09:10 +00:00
|
|
|
|
|
|
|
_vm->_anim->resume(animId, cycles);
|
|
|
|
debug(1, "sfResumeBgdAnimSpeed(%d, %d)", animId, cycles);
|
2004-11-06 22:33:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #52 (0x34)
|
2005-06-05 16:53:53 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: x
|
|
|
|
// Param3: y
|
|
|
|
// Param4: unknown
|
|
|
|
// Param5: actionCycle
|
|
|
|
// Param6: flags
|
|
|
|
void Script::sfThrowActor(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
ActorData *actor;
|
|
|
|
int16 flags;
|
|
|
|
int32 actionCycle;
|
|
|
|
Location location;
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-06-05 16:53:53 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
location.x = thread->pop();
|
|
|
|
location.y = thread->pop();
|
2005-07-29 17:58:00 +00:00
|
|
|
thread->pop();
|
2005-06-05 16:53:53 +00:00
|
|
|
actionCycle = thread->pop();
|
|
|
|
flags = thread->pop();
|
2005-04-17 11:53:25 +00:00
|
|
|
|
2005-06-05 16:53:53 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
location.z = actor->_location.z;
|
|
|
|
actor->_currentAction = kActionFall;
|
|
|
|
actor->_actionCycle = actionCycle;
|
|
|
|
actor->_fallAcceleration = -20;
|
|
|
|
actor->_fallVelocity = - (actor->_fallAcceleration * actor->_actionCycle) / 2;
|
|
|
|
actor->_fallPosition = actor->_location.z << 4;
|
|
|
|
|
|
|
|
actor->_finalTarget = location;
|
|
|
|
actor->_actionCycle--;
|
2005-06-05 16:53:53 +00:00
|
|
|
if (!(flags & kWalkAsync)) {
|
|
|
|
thread->waitWalk(actor);
|
|
|
|
}
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #53 (0x35)
|
2005-01-22 21:40:54 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: target object
|
|
|
|
void Script::sfWaitWalk(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
if ((actor->_currentAction == kActionWalkToPoint) ||
|
|
|
|
(actor->_currentAction == kActionWalkToLink) ||
|
|
|
|
(actor->_currentAction == kActionFall)) {
|
2005-01-22 21:40:54 +00:00
|
|
|
thread->waitWalk(actor);
|
|
|
|
}
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #54 (0x36)
|
2005-04-16 16:55:35 +00:00
|
|
|
void Script::sfScriptSceneID(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
thread->_returnValue = _vm->_scene->currentSceneNumber();
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #55 (0x37)
|
2005-06-05 16:53:53 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: scene number
|
|
|
|
void Script::sfChangeActorScene(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
int32 sceneNumber;
|
|
|
|
ActorData *actor;
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-06-05 16:53:53 +00:00
|
|
|
actorId = thread->pop();
|
|
|
|
sceneNumber = thread->pop();
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_sceneNumber = sceneNumber;
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #56 (0x38)
|
2005-06-05 16:53:53 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: z
|
|
|
|
// Param3: frame seq
|
|
|
|
// Param4: flags
|
|
|
|
void Script::sfScriptClimb(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
int16 z;
|
|
|
|
ActorData *actor;
|
|
|
|
uint16 flags;
|
|
|
|
int cycleFrameSequence;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
z = thread->pop();
|
|
|
|
cycleFrameSequence = thread->pop();
|
|
|
|
flags = thread->pop();
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-06-05 16:53:53 +00:00
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_finalTarget.z = z;
|
|
|
|
actor->_flags &= ~kFollower;
|
|
|
|
actor->_actionCycle = 1;
|
|
|
|
actor->_cycleFrameSequence = cycleFrameSequence;
|
|
|
|
actor->_currentAction = kActionClimb;
|
2005-06-05 16:53:53 +00:00
|
|
|
if (!(flags & kWalkAsync)) {
|
|
|
|
thread->waitWalk(actor);
|
|
|
|
}
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #57 (0x39)
|
2004-12-28 21:27:18 +00:00
|
|
|
// Param1: door #
|
|
|
|
// Param2: door state
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfSetDoorState(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 doorNumber;
|
|
|
|
int16 doorState;
|
|
|
|
doorNumber = thread->pop();
|
|
|
|
doorState = thread->pop();
|
2004-12-28 21:27:18 +00:00
|
|
|
|
2005-01-07 22:18:53 +00:00
|
|
|
if (_vm->_scene->getFlags() & kSceneFlagISO) {
|
2005-04-03 15:32:04 +00:00
|
|
|
_vm->_isoMap->setTileDoorState(doorNumber, doorState);
|
2004-12-28 21:27:18 +00:00
|
|
|
} else {
|
|
|
|
_vm->_scene->setDoorState(doorNumber, doorState);
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #58 (0x3A)
|
2005-06-12 21:21:14 +00:00
|
|
|
// Param1: actor id
|
|
|
|
// Param2: z
|
|
|
|
void Script::sfSetActorZ(SCRIPTFUNC_PARAMS) {
|
2005-06-16 15:33:44 +00:00
|
|
|
int16 objectId;
|
2005-06-12 21:21:14 +00:00
|
|
|
ActorData *actor;
|
2005-06-16 15:33:44 +00:00
|
|
|
ObjectData *obj;
|
|
|
|
int16 z;
|
2005-06-12 21:21:14 +00:00
|
|
|
|
2005-06-16 15:33:44 +00:00
|
|
|
objectId = thread->pop();
|
2005-06-12 21:21:14 +00:00
|
|
|
z = thread->pop();
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-06-16 15:33:44 +00:00
|
|
|
|
|
|
|
if (_vm->_actor->validActorId(objectId)) {
|
|
|
|
actor = _vm->_actor->getActor(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
actor->_location.z = z;
|
2005-06-16 15:33:44 +00:00
|
|
|
} else {
|
|
|
|
if (_vm->_actor->validObjId(objectId)) {
|
|
|
|
obj = _vm->_actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
obj->_location.z = z;
|
2005-06-16 15:33:44 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #59 (0x3B)
|
2005-06-15 19:30:11 +00:00
|
|
|
// Param1: stringId
|
|
|
|
// Param2: flags
|
|
|
|
// Param3: color
|
|
|
|
// Param4: x
|
|
|
|
// Param5: y
|
|
|
|
void Script::sfScriptText(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 stringId;
|
|
|
|
int16 flags;
|
2005-07-14 17:46:21 +00:00
|
|
|
Rect rect;
|
|
|
|
int color;
|
2005-06-15 19:30:11 +00:00
|
|
|
Point point;
|
2005-07-14 17:46:21 +00:00
|
|
|
int width;
|
|
|
|
const char*text;
|
2005-06-15 19:30:11 +00:00
|
|
|
stringId = thread->pop();
|
|
|
|
flags = thread->pop();
|
2005-07-14 17:46:21 +00:00
|
|
|
color = thread->pop();
|
2005-06-15 19:30:11 +00:00
|
|
|
point.x = thread->pop();
|
|
|
|
point.y = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
text = thread->_strings->getString(stringId);
|
2005-09-29 15:57:41 +00:00
|
|
|
|
2005-11-03 18:20:12 +00:00
|
|
|
width = _vm->_font->getStringWidth(kKnownFontScript, text, 0, kFontOutline);
|
2005-07-14 17:46:21 +00:00
|
|
|
rect.top = point.y - 6;
|
2005-07-29 17:58:00 +00:00
|
|
|
rect.setHeight(12);
|
2005-07-14 17:46:21 +00:00
|
|
|
rect.left = point.x - width / 2;
|
|
|
|
rect.setWidth(width);
|
|
|
|
|
2005-11-26 12:08:05 +00:00
|
|
|
_vm->_actor->setSpeechColor(color, _vm->KnownColor2ColorId(kKnownColorBlack));
|
2005-07-15 15:23:19 +00:00
|
|
|
_vm->_actor->nonActorSpeech(rect, &text, 1, -1, flags);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #60 (0x3C)
|
2005-06-12 21:21:14 +00:00
|
|
|
// Param1: actor id
|
|
|
|
void Script::sfGetActorX(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
thread->_returnValue = actor->_location.x >> 2;
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #61 (0x3D)
|
2005-06-12 21:21:14 +00:00
|
|
|
// Param1: actor id
|
|
|
|
void Script::sfGetActorY(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 actorId;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
actorId = thread->pop();
|
|
|
|
actor = _vm->_actor->getActor(actorId);
|
2004-10-27 22:17:11 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
thread->_returnValue = actor->_location.y >> 2;
|
2004-05-13 01:41:23 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #62 (0x3E)
|
2005-06-12 21:21:14 +00:00
|
|
|
void Script::sfEraseDelta(SCRIPTFUNC_PARAMS) {
|
2005-07-09 16:23:45 +00:00
|
|
|
Surface *backGroundSurface;
|
2005-07-08 16:56:03 +00:00
|
|
|
BGInfo backGroundInfo;
|
2005-06-12 21:21:14 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
backGroundSurface = _vm->_render->getBackGroundSurface();
|
2005-07-08 16:56:03 +00:00
|
|
|
_vm->_scene->getBGInfo(backGroundInfo);
|
2005-06-12 21:21:14 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
backGroundSurface->blit(backGroundInfo.bounds, backGroundInfo.buffer);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #63 (0x3F)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPlayMusic(SCRIPTFUNC_PARAMS) {
|
2005-01-16 17:06:40 +00:00
|
|
|
if (_vm->getGameType() == GType_ITE) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 param = thread->pop() + 9;
|
2004-09-23 06:53:46 +00:00
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
if (param >= 9 && param <= 34) {
|
2007-07-31 01:21:25 +00:00
|
|
|
_vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1);
|
2005-01-16 17:06:40 +00:00
|
|
|
_vm->_music->play(param);
|
2005-06-19 21:18:00 +00:00
|
|
|
} else {
|
2005-01-16 17:06:40 +00:00
|
|
|
_vm->_music->stop();
|
2005-06-19 21:18:00 +00:00
|
|
|
}
|
2005-01-16 17:06:40 +00:00
|
|
|
} else {
|
2005-08-30 11:16:11 +00:00
|
|
|
int16 param1 = thread->pop();
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 param2 = thread->pop();
|
2005-01-16 17:06:40 +00:00
|
|
|
|
2005-08-30 12:25:15 +00:00
|
|
|
if (param1 < 0) {
|
2005-08-30 11:16:11 +00:00
|
|
|
_vm->_music->stop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-30 12:25:15 +00:00
|
|
|
if (param1 >= _vm->_music->_songTableLen) {
|
|
|
|
warning("sfPlayMusic: Wrong song number (%d > %d)", param1, _vm->_music->_songTableLen - 1);
|
2005-08-30 11:16:11 +00:00
|
|
|
} else {
|
2007-07-31 01:21:25 +00:00
|
|
|
_vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1);
|
2005-09-21 10:44:22 +00:00
|
|
|
_vm->_music->play(_vm->_music->_songTable[param1], param2 ? MUSIC_LOOP : MUSIC_NORMAL);
|
2007-06-19 11:23:20 +00:00
|
|
|
if (!_vm->_scene->haveChapterPointsChanged()) {
|
|
|
|
_vm->_scene->setCurrentMusicTrack(param1);
|
|
|
|
_vm->_scene->setCurrentMusicRepeat(param2);
|
|
|
|
} else {
|
|
|
|
// Don't save this music track when saving in IHNM
|
|
|
|
_vm->_scene->setChapterPointsChanged(false);
|
|
|
|
}
|
2005-08-30 11:16:11 +00:00
|
|
|
}
|
2005-01-16 17:06:40 +00:00
|
|
|
}
|
2004-09-23 06:53:46 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #64 (0x40)
|
2005-07-01 17:29:23 +00:00
|
|
|
void Script::sfPickClimbOutPos(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 u, v, t;
|
|
|
|
ActorData *protagonist = _vm->_actor->_protagonist;
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
u = (_vm->_rnd.getRandomNumber(63) & 63) + 40;
|
|
|
|
v = (_vm->_rnd.getRandomNumber(63) & 63) + 40;
|
|
|
|
t = _vm->_isoMap->getTileIndex(u, v, 6);
|
|
|
|
if (t == 65) {
|
2005-08-10 14:53:17 +00:00
|
|
|
protagonist->_location.u() = (u << 4) + 4;
|
|
|
|
protagonist->_location.v() = (v << 4) + 4;
|
|
|
|
protagonist->_location.z = 48;
|
2005-07-01 17:29:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-07-01 17:29:23 +00:00
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #65 (0x41)
|
2005-07-01 17:29:23 +00:00
|
|
|
void Script::sfTossRif(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 uc , vc;
|
|
|
|
uint16 direction;
|
|
|
|
ActorData *protagonist = _vm->_actor->_protagonist;
|
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
uc = protagonist->_location.u() >> 4;
|
|
|
|
vc = protagonist->_location.v() >> 4;
|
2005-07-01 17:29:23 +00:00
|
|
|
if (_vm->_isoMap->findNearestChasm(uc, vc, direction)) {
|
|
|
|
uc <<= 4;
|
|
|
|
vc <<= 4;
|
2005-08-10 14:53:17 +00:00
|
|
|
protagonist->_facingDirection = direction;
|
|
|
|
|
|
|
|
protagonist->_finalTarget.u() = uc;
|
|
|
|
protagonist->_finalTarget.v() = vc;
|
|
|
|
protagonist->_finalTarget.z = -40;
|
|
|
|
protagonist->_currentAction = kActionFall;
|
|
|
|
protagonist->_actionCycle = 24;
|
|
|
|
protagonist->_fallAcceleration = - 20;
|
|
|
|
protagonist->_fallVelocity = - (protagonist->_fallAcceleration * 16) / 2 - (44 / 12);
|
|
|
|
protagonist->_fallPosition = protagonist->_location.z << 4;
|
|
|
|
protagonist->_actionCycle--;
|
2005-07-01 17:29:23 +00:00
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #66 (0x42)
|
2005-06-20 12:17:22 +00:00
|
|
|
void Script::sfShowControls(SCRIPTFUNC_PARAMS) {
|
|
|
|
// It has zero implementation in Win rerelase, and in DOS
|
|
|
|
// release it deals with video ports.
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #67 (0x43)
|
2005-07-03 20:02:56 +00:00
|
|
|
void Script::sfShowMap(SCRIPTFUNC_PARAMS) {
|
|
|
|
_vm->_interface->setMode(kPanelMap);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #68 (0x44)
|
2005-05-23 02:23:34 +00:00
|
|
|
void Script::sfPuzzleWon(SCRIPTFUNC_PARAMS) {
|
|
|
|
thread->_returnValue = _vm->_puzzle->isSolved();
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #69 (0x45)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfEnableEscape(SCRIPTFUNC_PARAMS) {
|
2004-10-27 02:27:54 +00:00
|
|
|
if (thread->pop())
|
|
|
|
_abortEnabled = true;
|
|
|
|
else {
|
|
|
|
_skipSpeeches = false;
|
|
|
|
_abortEnabled = false;
|
|
|
|
}
|
2004-10-20 22:38:24 +00:00
|
|
|
}
|
|
|
|
|
2004-09-25 10:11:17 +00:00
|
|
|
// Script function #70 (0x46)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfPlaySound(SCRIPTFUNC_PARAMS) {
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 param = thread->pop();
|
2005-01-17 18:49:00 +00:00
|
|
|
int res;
|
2004-10-19 17:12:53 +00:00
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
if (param >= 0 && param < _vm->_sndRes->_fxTableLen) {
|
|
|
|
res = _vm->_sndRes->_fxTable[param].res;
|
2005-01-17 18:49:00 +00:00
|
|
|
if (_vm->getFeatures() & GF_CD_FX)
|
|
|
|
res -= 14;
|
2005-08-07 00:00:43 +00:00
|
|
|
_vm->_sndRes->playSound(res, _vm->_sndRes->_fxTable[param].vol, false);
|
2005-01-17 18:49:00 +00:00
|
|
|
} else {
|
2004-10-19 17:12:53 +00:00
|
|
|
_vm->_sound->stopSound();
|
2005-01-17 18:49:00 +00:00
|
|
|
}
|
2004-09-25 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #71 (0x47)
|
2005-06-19 21:18:00 +00:00
|
|
|
void Script::sfPlayLoopedSound(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 param = thread->pop();
|
|
|
|
int res;
|
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
if (param >= 0 && param < _vm->_sndRes->_fxTableLen) {
|
|
|
|
res = _vm->_sndRes->_fxTable[param].res;
|
2005-06-19 21:18:00 +00:00
|
|
|
if (_vm->getFeatures() & GF_CD_FX)
|
|
|
|
res -= 14;
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
_vm->_sndRes->playSound(res, _vm->_sndRes->_fxTable[param].vol, true);
|
2005-06-19 21:18:00 +00:00
|
|
|
} else {
|
|
|
|
_vm->_sound->stopSound();
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #72 (0x48)
|
2005-04-16 20:59:24 +00:00
|
|
|
void Script::sfGetDeltaFrame(SCRIPTFUNC_PARAMS) {
|
|
|
|
uint16 animId = (uint16)thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-04-16 20:59:24 +00:00
|
|
|
thread->_returnValue = _vm->_anim->getCurrentFrame(animId);
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #73 (0x49)
|
2005-05-18 18:28:10 +00:00
|
|
|
void Script::sfShowProtect(SCRIPTFUNC_PARAMS) {
|
2005-10-17 03:28:21 +00:00
|
|
|
if (_vm->_copyProtection) {
|
|
|
|
thread->wait(kWaitTypeRequest);
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-10-17 03:28:21 +00:00
|
|
|
_vm->_interface->setMode(kPanelProtect);
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #74 (0x4A)
|
2005-05-18 18:28:10 +00:00
|
|
|
void Script::sfProtectResult(SCRIPTFUNC_PARAMS) {
|
2005-10-17 03:28:21 +00:00
|
|
|
if (_vm->_copyProtection) {
|
|
|
|
thread->_returnValue = _vm->_interface->getProtectHash();
|
|
|
|
} else {
|
|
|
|
int protectHash;
|
|
|
|
|
|
|
|
//cheating
|
|
|
|
protectHash = thread->pop();
|
|
|
|
thread->push(protectHash);
|
|
|
|
thread->_returnValue = protectHash;
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2005-03-08 15:06:57 +00:00
|
|
|
// Script function #75 (0x4b)
|
2005-01-22 19:21:38 +00:00
|
|
|
void Script::sfRand(SCRIPTFUNC_PARAMS) {
|
2005-03-08 15:28:01 +00:00
|
|
|
int16 param;
|
|
|
|
|
2005-07-21 01:33:28 +00:00
|
|
|
param = thread->pop();
|
|
|
|
thread->_returnValue = _vm->_rnd.getRandomNumber(param - 1);
|
2004-10-27 22:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script function #76 (0x4c)
|
2005-06-19 21:18:00 +00:00
|
|
|
void Script::sfFadeMusic(SCRIPTFUNC_PARAMS) {
|
|
|
|
_vm->_music->setVolume(0, 1000);
|
2004-10-27 22:17:11 +00:00
|
|
|
}
|
|
|
|
|
2004-11-06 22:33:08 +00:00
|
|
|
// Script function #77 (0x4d)
|
2005-06-19 21:18:00 +00:00
|
|
|
void Script::sfPlayVoice(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 param = thread->pop();
|
2004-11-06 22:33:08 +00:00
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
warning("sfPlayVoice(%d)", param);
|
|
|
|
if (param > 0) {
|
|
|
|
_vm->_sndRes->playVoice(param + 3712);
|
|
|
|
} else {
|
|
|
|
_vm->_sound->stopSound();
|
|
|
|
}
|
2004-11-06 22:33:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-10 00:36:01 +00:00
|
|
|
void Script::finishDialog(int strID, int replyID, int flags, int bitOffset) {
|
2005-01-23 21:52:43 +00:00
|
|
|
byte *addr;
|
2007-06-10 00:36:01 +00:00
|
|
|
const char *str;
|
2005-01-23 21:52:43 +00:00
|
|
|
|
2005-01-17 23:11:31 +00:00
|
|
|
if (_conversingThread) {
|
|
|
|
_vm->_interface->setMode(kPanelNull);
|
|
|
|
|
2007-06-10 00:36:01 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
|
|
|
str = _conversingThread->_strings->getString(strID);
|
2007-06-10 03:21:16 +00:00
|
|
|
if (*str != '[') {
|
2007-06-10 00:36:01 +00:00
|
|
|
int sampleResourceId = -1;
|
|
|
|
sampleResourceId = _conversingThread->_voiceLUT->voices[strID];
|
|
|
|
if (sampleResourceId < 0 || sampleResourceId > 4000)
|
|
|
|
sampleResourceId = -1;
|
|
|
|
|
|
|
|
_vm->_actor->actorSpeech(_vm->_actor->_protagonist->_id, &str, 1, sampleResourceId, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
_conversingThread->_flags &= ~kTFlagWaiting;
|
2005-01-17 23:11:31 +00:00
|
|
|
|
|
|
|
_conversingThread->push(replyID);
|
|
|
|
|
|
|
|
if (flags & kReplyOnce) {
|
2005-01-23 21:52:43 +00:00
|
|
|
addr = _conversingThread->_staticBase + (bitOffset >> 3);
|
2005-10-11 17:39:31 +00:00
|
|
|
*addr |= (1 << (bitOffset & 7));
|
2005-01-17 23:11:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_conversingThread = NULL;
|
|
|
|
wakeUpThreads(kWaitTypeDialogBegin);
|
|
|
|
}
|
|
|
|
|
2005-10-04 23:38:19 +00:00
|
|
|
void Script::sfSetChapterPoints(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 ethics = thread->pop();
|
|
|
|
int16 barometer = thread->pop();
|
|
|
|
int chapter = _vm->_scene->currentChapterNumber();
|
2007-08-25 18:24:32 +00:00
|
|
|
static PalEntry cur_pal[PAL_ENTRIES];
|
2005-10-04 23:38:19 +00:00
|
|
|
|
|
|
|
_vm->_ethicsPoints[chapter] = ethics;
|
2005-10-11 01:00:56 +00:00
|
|
|
_vm->_spiritualBarometer = ethics * 256 / barometer;
|
2007-06-19 11:23:20 +00:00
|
|
|
_vm->_scene->setChapterPointsChanged(true); // don't save this music when saving in IHNM
|
2007-08-17 06:08:18 +00:00
|
|
|
|
|
|
|
if (_vm->_spiritualBarometer > 255)
|
|
|
|
_vm->_gfx->setPaletteColor(kIHNMColorPortrait, 0xff, 0xff, 0xff);
|
|
|
|
else
|
|
|
|
_vm->_gfx->setPaletteColor(kIHNMColorPortrait,
|
|
|
|
_vm->_spiritualBarometer * _vm->_interface->_portraitBgColor.red / 256,
|
|
|
|
_vm->_spiritualBarometer * _vm->_interface->_portraitBgColor.green / 256,
|
|
|
|
_vm->_spiritualBarometer * _vm->_interface->_portraitBgColor.blue / 256);
|
|
|
|
|
2007-08-25 18:24:32 +00:00
|
|
|
_vm->_gfx->getCurrentPal(cur_pal);
|
|
|
|
_vm->_gfx->setPalette(cur_pal);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2005-10-04 17:44:41 +00:00
|
|
|
void Script::sfSetPortraitBgColor(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 red = thread->pop();
|
|
|
|
int16 green = thread->pop();
|
|
|
|
int16 blue = thread->pop();
|
|
|
|
|
2005-10-04 18:19:14 +00:00
|
|
|
_vm->_interface->setPortraitBgColor(red, green, blue);
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 17:39:29 +00:00
|
|
|
void Script::sfScriptStartCutAway(SCRIPTFUNC_PARAMS) {
|
2005-09-24 10:13:17 +00:00
|
|
|
int16 cut;
|
|
|
|
int16 fade;
|
|
|
|
|
|
|
|
cut = thread->pop();
|
|
|
|
thread->pop(); // Not used
|
|
|
|
fade = thread->pop();
|
|
|
|
|
2007-06-07 12:11:33 +00:00
|
|
|
_vm->_anim->setCutAwayMode(kPanelCutaway);
|
2005-09-24 10:13:17 +00:00
|
|
|
_vm->_anim->playCutaway(cut, fade != 0);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2005-08-10 17:39:29 +00:00
|
|
|
void Script::sfReturnFromCutAway(SCRIPTFUNC_PARAMS) {
|
2005-09-24 19:29:55 +00:00
|
|
|
_vm->_anim->returnFromCutaway();
|
2007-06-17 01:00:06 +00:00
|
|
|
thread->wait(kWaitTypeWakeUp);
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfEndCutAway(SCRIPTFUNC_PARAMS) {
|
2005-09-24 19:29:55 +00:00
|
|
|
_vm->_anim->endCutaway();
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfGetMouseClicks(SCRIPTFUNC_PARAMS) {
|
2007-06-06 19:46:10 +00:00
|
|
|
thread->_returnValue = _vm->getMouseClickCount();
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfResetMouseClicks(SCRIPTFUNC_PARAMS) {
|
2007-06-06 19:46:10 +00:00
|
|
|
_vm->resetMouseClickCount();
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
2007-06-03 19:15:59 +00:00
|
|
|
// Used in IHNM only
|
2007-06-02 15:26:05 +00:00
|
|
|
// Param1: frames
|
2005-07-21 01:33:28 +00:00
|
|
|
void Script::sfWaitFrames(SCRIPTFUNC_PARAMS) {
|
2007-06-02 15:26:05 +00:00
|
|
|
int16 frames;
|
|
|
|
frames = thread->pop();
|
|
|
|
|
|
|
|
if (!_skipSpeeches)
|
|
|
|
thread->waitFrames(_vm->_frameCount + frames);
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfScriptFade(SCRIPTFUNC_PARAMS) {
|
2007-08-23 13:56:25 +00:00
|
|
|
int16 firstPalEntry = thread->pop();
|
|
|
|
int16 lastPalEntry = thread->pop();
|
2007-06-06 18:09:52 +00:00
|
|
|
int16 startingBrightness = thread->pop();
|
|
|
|
int16 endingBrightness = thread->pop();
|
2007-06-10 00:36:01 +00:00
|
|
|
Event event;
|
2007-08-23 13:56:25 +00:00
|
|
|
static PalEntry cur_pal[PAL_ENTRIES];
|
2007-06-06 18:04:25 +00:00
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(cur_pal);
|
|
|
|
|
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kPalEvent;
|
2007-08-23 13:56:25 +00:00
|
|
|
event.op = kEventPalFade;
|
2007-06-06 18:04:25 +00:00
|
|
|
event.time = 0;
|
2007-08-23 13:56:25 +00:00
|
|
|
event.duration = kNormalFadeDuration;
|
2007-06-06 18:04:25 +00:00
|
|
|
event.data = cur_pal;
|
2007-08-23 13:56:25 +00:00
|
|
|
event.param = startingBrightness;
|
|
|
|
event.param2 = endingBrightness;
|
|
|
|
event.param3 = firstPalEntry;
|
|
|
|
event.param4 = lastPalEntry - firstPalEntry + 1;
|
2007-06-06 18:04:25 +00:00
|
|
|
|
2007-08-23 13:56:25 +00:00
|
|
|
_vm->_events->queue(&event);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfScriptStartVideo(SCRIPTFUNC_PARAMS) {
|
2007-06-06 19:46:10 +00:00
|
|
|
int16 vid;
|
|
|
|
int16 fade;
|
|
|
|
vid = thread->pop();
|
|
|
|
fade = thread->pop();
|
|
|
|
|
2007-06-07 12:11:33 +00:00
|
|
|
_vm->_anim->setCutAwayMode(kPanelVideo);
|
2007-06-06 19:46:10 +00:00
|
|
|
_vm->_anim->startVideo(vid, fade != 0);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
2005-07-21 01:33:28 +00:00
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfScriptReturnFromVideo(SCRIPTFUNC_PARAMS) {
|
2007-06-06 19:46:10 +00:00
|
|
|
_vm->_anim->returnFromVideo();
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfScriptEndVideo(SCRIPTFUNC_PARAMS) {
|
2007-06-06 19:46:10 +00:00
|
|
|
_vm->_anim->endVideo();
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 14:43:10 +00:00
|
|
|
void Script::sfShowIHNMDemoHelpBg(SCRIPTFUNC_PARAMS) {
|
2007-08-02 01:56:45 +00:00
|
|
|
_ihnmDemoCurrentY = 0;
|
2007-08-02 14:57:18 +00:00
|
|
|
_vm->_scene->_textList.clear();
|
|
|
|
_vm->_interface->setMode(kPanelConverse);
|
2007-08-02 01:04:44 +00:00
|
|
|
_vm->_scene->showPsychicProfile(NULL);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 14:43:10 +00:00
|
|
|
void Script::sfAddIHNMDemoHelpTextLine(SCRIPTFUNC_PARAMS) {
|
2007-08-02 01:04:44 +00:00
|
|
|
int stringId, textHeight;
|
|
|
|
TextListEntry textEntry;
|
|
|
|
Event event;
|
|
|
|
|
|
|
|
stringId = thread->pop();
|
|
|
|
|
|
|
|
textHeight = _vm->_font->getHeight(kKnownFontVerb, thread->_strings->getString(stringId), 226, kFontCentered);
|
|
|
|
|
|
|
|
textEntry.knownColor = kKnownColorBlack;
|
|
|
|
textEntry.useRect = true;
|
|
|
|
textEntry.rect.left = 245;
|
|
|
|
textEntry.rect.setHeight(210 + 76);
|
|
|
|
textEntry.rect.setWidth(226);
|
2007-08-02 01:56:45 +00:00
|
|
|
textEntry.rect.top = 76 + _ihnmDemoCurrentY;
|
2007-08-02 01:04:44 +00:00
|
|
|
textEntry.font = kKnownFontVerb;
|
|
|
|
textEntry.flags = (FontEffectFlags)(kFontCentered);
|
|
|
|
textEntry.text = thread->_strings->getString(stringId);
|
|
|
|
|
|
|
|
TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry);
|
|
|
|
|
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kTextEvent;
|
|
|
|
event.op = kEventDisplay;
|
|
|
|
event.data = _psychicProfileTextEntry;
|
|
|
|
|
|
|
|
_vm->_events->queue(&event);
|
2007-08-02 01:56:45 +00:00
|
|
|
|
|
|
|
_ihnmDemoCurrentY += 10;
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 14:43:10 +00:00
|
|
|
void Script::sfShowIHNMDemoHelpPage(SCRIPTFUNC_PARAMS) {
|
|
|
|
// Note: The IHNM demo changes panel mode to 8 (kPanelProtect in ITE)
|
|
|
|
// when changing pages
|
|
|
|
_vm->_interface->setMode(kPanelPlacard);
|
2007-08-02 01:56:45 +00:00
|
|
|
_ihnmDemoCurrentY = 0;
|
2005-07-21 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfVstopFX(SCRIPTFUNC_PARAMS) {
|
|
|
|
_vm->_sound->stopSound();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfVstopLoopedFX(SCRIPTFUNC_PARAMS) {
|
|
|
|
_vm->_sound->stopSound();
|
|
|
|
}
|
|
|
|
|
2007-08-17 06:08:18 +00:00
|
|
|
void Script::sfDemoSetInteractive(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 interactiveFlag = thread->pop();
|
|
|
|
|
|
|
|
if (interactiveFlag == 0) {
|
|
|
|
_vm->_interface->deactivate();
|
|
|
|
_vm->_interface->setMode(kPanelNull);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: the original also sets an appropriate flag here, but we don't,
|
|
|
|
// as we don't use it
|
2007-07-30 23:30:08 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 01:33:28 +00:00
|
|
|
void Script::sfDemoIsInteractive(SCRIPTFUNC_PARAMS) {
|
|
|
|
thread->_returnValue = 0;
|
|
|
|
}
|
|
|
|
|
2005-07-24 13:41:49 +00:00
|
|
|
void Script::sfVsetTrack(SCRIPTFUNC_PARAMS) {
|
2005-08-07 00:00:43 +00:00
|
|
|
int16 chapter = thread->pop();
|
|
|
|
int16 sceneNumber = thread->pop();
|
|
|
|
int16 actorsEntrance = thread->pop();
|
2005-07-21 22:13:06 +00:00
|
|
|
|
2005-08-11 14:00:26 +00:00
|
|
|
debug(2, "sfVsetTrrack(%d, %d, %d)", chapter, sceneNumber, actorsEntrance);
|
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
_vm->_scene->changeScene(sceneNumber, actorsEntrance, kTransitionFade, chapter);
|
2005-07-21 22:13:06 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfGetPoints(SCRIPTFUNC_PARAMS) {
|
2005-09-26 07:22:32 +00:00
|
|
|
int16 index = thread->pop();
|
|
|
|
|
|
|
|
if (index >= 0 && index < ARRAYSIZE(_vm->_ethicsPoints))
|
|
|
|
thread->_returnValue = _vm->_ethicsPoints[index];
|
|
|
|
else
|
|
|
|
thread->_returnValue = 0;
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfSetGlobalFlag(SCRIPTFUNC_PARAMS) {
|
2005-09-26 07:22:32 +00:00
|
|
|
int16 flag = thread->pop();
|
|
|
|
|
|
|
|
if (flag >= 0 && flag < 32)
|
|
|
|
_vm->_globalFlags |= (1 << flag);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfClearGlobalFlag(SCRIPTFUNC_PARAMS) {
|
2005-09-26 07:22:32 +00:00
|
|
|
int16 flag = thread->pop();
|
|
|
|
|
|
|
|
if (flag >= 0 && flag < 32)
|
|
|
|
_vm->_globalFlags &= ~(1 << flag);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfTestGlobalFlag(SCRIPTFUNC_PARAMS) {
|
2005-09-26 07:22:32 +00:00
|
|
|
int16 flag = thread->pop();
|
|
|
|
|
|
|
|
if (flag >= 0 && flag < 32 && _vm->_globalFlags & (1 << flag))
|
|
|
|
thread->_returnValue = 1;
|
|
|
|
else
|
|
|
|
thread->_returnValue = 0;
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-09-25 00:08:13 +00:00
|
|
|
void Script::sfSetPoints(SCRIPTFUNC_PARAMS) {
|
2005-09-26 07:22:32 +00:00
|
|
|
int16 index = thread->pop();
|
|
|
|
int16 points = thread->pop();
|
|
|
|
|
|
|
|
if (index >= 0 && index < ARRAYSIZE(_vm->_ethicsPoints))
|
|
|
|
_vm->_ethicsPoints[index] = points;
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::sfSetSpeechBox(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 param1 = thread->pop();
|
|
|
|
int16 param2 = thread->pop();
|
|
|
|
int16 param3 = thread->pop();
|
|
|
|
int16 param4 = thread->pop();
|
|
|
|
|
|
|
|
_vm->_actor->_speechBoxScript.left = param1;
|
|
|
|
_vm->_actor->_speechBoxScript.top = param2;
|
2007-06-13 13:00:25 +00:00
|
|
|
_vm->_actor->_speechBoxScript.setWidth(param3 - param1);
|
|
|
|
_vm->_actor->_speechBoxScript.setHeight(param4 - param2);
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 01:33:28 +00:00
|
|
|
void Script::sfDebugShowData(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 param = thread->pop();
|
|
|
|
char buf[50];
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-21 01:33:28 +00:00
|
|
|
snprintf(buf, 50, "Reached breakpoint %d", param);
|
|
|
|
|
|
|
|
_vm->_interface->setStatusText(buf);
|
|
|
|
}
|
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
void Script::sfWaitFramesEsc(SCRIPTFUNC_PARAMS) {
|
2005-09-28 15:49:20 +00:00
|
|
|
thread->_returnValue = _vm->_framesEsc;
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 12:39:00 +00:00
|
|
|
void Script::sfQueueMusic(SCRIPTFUNC_PARAMS) {
|
|
|
|
int16 param1 = thread->pop();
|
|
|
|
int16 param2 = thread->pop();
|
|
|
|
Event event;
|
|
|
|
|
|
|
|
if (param1 < 0) {
|
|
|
|
_vm->_music->stop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param1 >= _vm->_music->_songTableLen) {
|
|
|
|
warning("sfQueueMusic: Wrong song number (%d > %d)", param1, _vm->_music->_songTableLen - 1);
|
|
|
|
} else {
|
2007-07-31 01:21:25 +00:00
|
|
|
_vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1);
|
2007-07-06 12:39:00 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kMusicEvent;
|
|
|
|
event.param = _vm->_music->_songTable[param1];
|
|
|
|
event.param2 = param2 ? MUSIC_LOOP : MUSIC_NORMAL;
|
|
|
|
event.op = kEventPlay;
|
2007-07-06 13:21:43 +00:00
|
|
|
event.time = _vm->ticksToMSec(500); // I find the delay in the original to be too long, so I've set it to
|
|
|
|
// wait for half the time, which sounds better when chapter points
|
|
|
|
// change
|
|
|
|
// FIXME: If this is too short for other cases apart from chapter
|
|
|
|
// point change, set it back to 1000
|
2007-07-06 12:39:00 +00:00
|
|
|
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
|
|
|
|
if (!_vm->_scene->haveChapterPointsChanged()) {
|
|
|
|
_vm->_scene->setCurrentMusicTrack(param1);
|
|
|
|
_vm->_scene->setCurrentMusicRepeat(param2);
|
|
|
|
} else {
|
|
|
|
// Don't save this music track when saving in IHNM
|
|
|
|
_vm->_scene->setChapterPointsChanged(false);
|
|
|
|
}
|
|
|
|
}
|
2005-08-10 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
2005-10-04 23:38:19 +00:00
|
|
|
void Script::sfDisableAbortSpeeches(SCRIPTFUNC_PARAMS) {
|
|
|
|
int value = thread->pop();
|
|
|
|
|
|
|
|
_vm->_interface->disableAbortSpeeches(value != 0);
|
2005-08-07 00:00:43 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 01:33:28 +00:00
|
|
|
void Script::sfNull(SCRIPTFUNC_PARAMS) {
|
|
|
|
for (int i = 0; i < nArgs; i++)
|
|
|
|
thread->pop();
|
|
|
|
}
|
|
|
|
|
2005-08-10 17:39:29 +00:00
|
|
|
void Script::SF_stub(const char *name, ScriptThread *thread, int nArgs) {
|
|
|
|
char buf[256], buf1[100];
|
|
|
|
|
|
|
|
snprintf(buf, 256, "STUB: %s(", name);
|
|
|
|
|
|
|
|
for (int i = 0; i < nArgs; i++) {
|
|
|
|
snprintf(buf1, 100, "%d", thread->pop());
|
|
|
|
strncat(buf, buf1, 256);
|
|
|
|
if (i + 1 < nArgs)
|
|
|
|
strncat(buf, ", ", 256);
|
|
|
|
}
|
2005-01-28 03:47:12 +00:00
|
|
|
|
2005-08-10 17:39:29 +00:00
|
|
|
debug(0, "%s)", buf);
|
2005-01-28 03:47:12 +00:00
|
|
|
}
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|