2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 The ScummVM project
|
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
|
|
|
#include "saga/gfx.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/game_mod.h"
|
2004-08-10 18:31:33 +00:00
|
|
|
#include "saga/console.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/rscfile_mod.h"
|
2004-08-12 23:57:45 +00:00
|
|
|
#include "saga/script.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/sndres.h"
|
2004-08-03 01:07:34 +00:00
|
|
|
#include "saga/sprite.h"
|
2004-08-03 00:06:18 +00:00
|
|
|
#include "saga/font.h"
|
2004-08-03 00:40:16 +00:00
|
|
|
#include "saga/text.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/sound.h"
|
2004-10-08 01:22:39 +00:00
|
|
|
#include "saga/scene.h"
|
|
|
|
#include "saga/actionmap.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/actor.h"
|
|
|
|
#include "saga/actordata.h"
|
2004-12-15 00:24:12 +00:00
|
|
|
#include "saga/stream.h"
|
2004-12-19 13:38:11 +00:00
|
|
|
#include "saga/interface.h"
|
2004-12-21 06:49:07 +00:00
|
|
|
#include "common/config-manager.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
static int actorCompare(const ActorDataPointer& actor1, const ActorDataPointer& actor2) {
|
2004-12-19 13:38:11 +00:00
|
|
|
if (actor1->actorY == actor2->actorY) {
|
2004-12-15 00:24:12 +00:00
|
|
|
return 0;
|
2004-12-19 13:38:11 +00:00
|
|
|
} else if (actor1->actorY < actor2->actorY) {
|
2004-12-15 00:24:12 +00:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 15:47:42 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
ACTIONTIMES ActionTDeltas[] = {
|
2004-05-01 06:16:57 +00:00
|
|
|
{ ACTION_IDLE, 80 },
|
|
|
|
{ ACTION_WALK, 80 },
|
|
|
|
{ ACTION_SPEAK, 200 }
|
2004-04-12 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
Actor::Actor(SagaEngine *vm) : _vm(vm) {
|
2004-04-12 21:40:49 +00:00
|
|
|
int i;
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "Actor::Actor()");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Get actor resource file context
|
2004-11-15 03:03:48 +00:00
|
|
|
_actorContext = GAME_GetFileContext(GAME_RESOURCEFILE, 0);
|
|
|
|
if (_actorContext == NULL) {
|
2004-08-02 15:47:42 +00:00
|
|
|
error("Actor::Actor(): Couldn't load actor module resource context.");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
for (i = 0; i < ACTORCOUNT; i++) {
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = &_actors[i];
|
2004-12-18 20:33:02 +00:00
|
|
|
actor->actorId = ACTOR_INDEX_TO_ID(i);
|
|
|
|
actor->index = i;
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "init actorId=0x%X index=0x%X", actor->actorId, actor->index);
|
2004-12-18 20:33:02 +00:00
|
|
|
actor->nameIndex = ActorTable[i].nameIndex;
|
2004-12-17 20:38:17 +00:00
|
|
|
actor->spriteListResourceId = ActorTable[i].spriteListResourceId;
|
|
|
|
actor->frameListResourceId = ActorTable[i].frameListResourceId;
|
2004-12-18 16:08:59 +00:00
|
|
|
actor->speechColor = ActorTable[i].speechColor;
|
2004-12-18 20:33:02 +00:00
|
|
|
actor->sceneNumber = ActorTable[i].sceneIndex;
|
|
|
|
|
|
|
|
actor->flags = ActorTable[i].flags;
|
2004-12-17 20:38:17 +00:00
|
|
|
actor->orient = ACTOR_DEFAULT_ORIENT;
|
|
|
|
actor->def_action = 0;
|
|
|
|
actor->def_action_flags = 0;
|
|
|
|
actor->action = 0;
|
|
|
|
actor->action_flags = 0;
|
|
|
|
actor->action_time = 0;
|
|
|
|
actor->action_frame = 0;
|
2004-12-18 16:08:59 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
actor->disabled = !loadActorResources(actor);
|
|
|
|
if (actor->disabled) {
|
|
|
|
warning("Disabling actorId=0x%X index=0x%X", actor->actorId, actor->index);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-02 15:47:42 +00:00
|
|
|
Actor::~Actor() {
|
2004-12-17 20:38:17 +00:00
|
|
|
int i;
|
|
|
|
ActorData *actor;
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "Actor::~Actor()");
|
2004-12-17 20:38:17 +00:00
|
|
|
//release resources
|
|
|
|
for (i = 0; i < ACTORCOUNT; i++) {
|
|
|
|
actor = &_actors[i];
|
|
|
|
free(actor->frames);
|
|
|
|
_vm->_sprite->freeSprite(actor->spriteList);
|
|
|
|
}
|
2004-12-17 11:18:56 +00:00
|
|
|
}
|
|
|
|
|
2004-12-18 16:08:59 +00:00
|
|
|
bool Actor::loadActorResources(ActorData * actor) {
|
2004-12-17 20:38:17 +00:00
|
|
|
byte *resourcePointer;
|
|
|
|
size_t resourceLength;
|
2004-12-18 20:33:02 +00:00
|
|
|
int framesCount;
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorFrame *framesPointer;
|
|
|
|
int lastFrame;
|
|
|
|
int i, orient;
|
|
|
|
int result;
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "Loading frame resource id 0x%X", actor->frameListResourceId);
|
2004-12-17 20:38:17 +00:00
|
|
|
result = RSC_LoadResource(_actorContext, actor->frameListResourceId, &resourcePointer, &resourceLength);
|
|
|
|
if (result != SUCCESS) {
|
|
|
|
warning("Couldn't load sprite action index resource");
|
2004-12-18 16:08:59 +00:00
|
|
|
return false;
|
2004-12-17 20:38:17 +00:00
|
|
|
}
|
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
framesCount = resourceLength / 16;
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "Frame resource contains %d frames", framesCount);
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * framesCount);
|
2004-12-17 20:38:17 +00:00
|
|
|
if (framesPointer == NULL) {
|
2004-12-18 16:08:59 +00:00
|
|
|
error("Couldn't allocate memory for sprite frames");
|
2004-12-17 20:38:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MemoryReadStreamEndian readS(resourcePointer, resourceLength, IS_BIG_ENDIAN);
|
|
|
|
|
|
|
|
lastFrame = 0;
|
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
for (i = 0; i < framesCount; i++) {
|
2004-12-17 20:38:17 +00:00
|
|
|
for (orient = 0; orient < ACTOR_ORIENTATION_COUNT; orient++) {
|
|
|
|
// Load all four orientations
|
|
|
|
framesPointer[i].dir[orient].frameIndex = readS.readUint16();
|
|
|
|
framesPointer[i].dir[orient].frameCount = readS.readUint16();
|
|
|
|
if (framesPointer[i].dir[orient].frameIndex > lastFrame) {
|
|
|
|
lastFrame = framesPointer[i].dir[orient].frameIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RSC_FreeResource(resourcePointer);
|
|
|
|
|
|
|
|
actor->frames = framesPointer;
|
2004-12-18 20:33:02 +00:00
|
|
|
actor->framesCount = framesCount;
|
2004-12-17 20:38:17 +00:00
|
|
|
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "Loading sprite resource id 0x%X", actor->spriteListResourceId);
|
2004-12-17 20:38:17 +00:00
|
|
|
if (_vm->_sprite->loadList(actor->spriteListResourceId, &actor->spriteList) != SUCCESS) {
|
|
|
|
warning("Unable to load sprite list");
|
2004-12-18 16:08:59 +00:00
|
|
|
return false;
|
2004-12-17 20:38:17 +00:00
|
|
|
}
|
|
|
|
|
2004-12-18 16:08:59 +00:00
|
|
|
i = _vm->_sprite->getListLen(actor->spriteList);
|
|
|
|
|
|
|
|
if ( (lastFrame >= i)) {
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "Appending to sprite list 0x%X", actor->spriteListResourceId);
|
2004-12-17 20:38:17 +00:00
|
|
|
if (_vm->_sprite->appendList(actor->spriteListResourceId + 1, actor->spriteList) != SUCCESS) {
|
|
|
|
warning("Unable append sprite list");
|
2004-12-18 16:08:59 +00:00
|
|
|
return false;
|
2004-12-17 20:38:17 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2004-12-18 16:08:59 +00:00
|
|
|
return true;
|
2004-12-17 11:18:56 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *Actor::getActor(uint16 actorId) {
|
2004-12-18 16:08:59 +00:00
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
if (!IS_VALID_ACTOR_ID(actorId))
|
2004-12-17 20:38:17 +00:00
|
|
|
error("Actor::getActor Wrong actorId 0x%X", actorId);
|
|
|
|
|
2004-12-18 16:08:59 +00:00
|
|
|
actor = &_actors[ACTOR_ID_TO_INDEX(actorId)];
|
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
if (actor->disabled)
|
2004-12-18 16:08:59 +00:00
|
|
|
error("Actor::getActor disabled actorId 0x%X", actorId);
|
|
|
|
|
|
|
|
return actor;
|
2004-12-17 20:38:17 +00:00
|
|
|
}
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
void Actor::updateActorsScene() {
|
|
|
|
int i;
|
|
|
|
ActorData *actor;
|
2004-12-17 20:38:17 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
for (i = 0; i < ACTORCOUNT; i++) {
|
|
|
|
actor = &_actors[i];
|
|
|
|
if (actor->flags & (kProtagonist | kFollower)) {
|
|
|
|
actor->sceneNumber = _vm->_scene->currentSceneNumber();
|
2004-12-17 20:38:17 +00:00
|
|
|
}
|
2004-12-18 20:33:02 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
void Actor::handleSpeech(int msec) {
|
|
|
|
int stringLength;
|
|
|
|
int sampleLength;
|
|
|
|
bool removeFirst;
|
|
|
|
int i;
|
|
|
|
int talkspeed;
|
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
if (!isSpeaking()) return;
|
|
|
|
|
|
|
|
stringLength = strlen(_activeSpeech.strings[0]);
|
|
|
|
|
|
|
|
if (stringLength == 0)
|
|
|
|
error("Empty strings not allowed");
|
|
|
|
|
|
|
|
if (_vm->_script->_skipSpeeches) {
|
|
|
|
_activeSpeech.stringsCount = 0;
|
|
|
|
_vm->_sound->stopVoice();
|
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeSpeech);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_activeSpeech.playing) { // just added
|
|
|
|
talkspeed = ConfMan.getInt("talkspeed");
|
|
|
|
if (_activeSpeech.speechFlags & kSpeakSlow) {
|
|
|
|
if (_activeSpeech.slowModeCharIndex >= stringLength)
|
|
|
|
error("Wrong string index");
|
|
|
|
|
|
|
|
debug(0 , "Slow string!");
|
|
|
|
_activeSpeech.playingTime = 10 * talkspeed;
|
|
|
|
// 10 - fix it
|
|
|
|
|
|
|
|
} else {
|
|
|
|
sampleLength = _vm->_sndRes->getVoiceLength(_activeSpeech.sampleResourceId); //fixme - too fast
|
|
|
|
|
|
|
|
if (sampleLength < 0) {
|
|
|
|
_activeSpeech.playingTime = stringLength * talkspeed;
|
|
|
|
} else {
|
|
|
|
_activeSpeech.playingTime = sampleLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-21 10:30:49 +00:00
|
|
|
if (_activeSpeech.sampleResourceId != -1) {
|
2004-12-21 06:49:07 +00:00
|
|
|
_vm->_sndRes->playVoice(_activeSpeech.sampleResourceId);
|
2004-12-21 10:30:49 +00:00
|
|
|
_activeSpeech.sampleResourceId++;
|
|
|
|
}
|
2004-12-21 06:49:07 +00:00
|
|
|
|
|
|
|
if (_activeSpeech.actorIds[0] != 0) {
|
|
|
|
actor = getActor(_activeSpeech.actorIds[0]);
|
|
|
|
if (!(_activeSpeech.speechFlags & kSpeakNoAnimate)) {
|
|
|
|
actor->currentAction = kActionSpeak;
|
|
|
|
//a->actionCycle = rand() % 64; todo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_activeSpeech.playing = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_activeSpeech.playingTime -= msec;
|
|
|
|
|
|
|
|
removeFirst = false;
|
|
|
|
if (_activeSpeech.playingTime <= 0) {
|
|
|
|
if (_activeSpeech.speechFlags & kSpeakSlow) {
|
|
|
|
_activeSpeech.slowModeCharIndex++;
|
|
|
|
if (_activeSpeech.slowModeCharIndex >= stringLength)
|
|
|
|
removeFirst = true;
|
|
|
|
} else {
|
|
|
|
removeFirst = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (removeFirst) {
|
|
|
|
for (i = 1; i < _activeSpeech.stringsCount; i++) {
|
|
|
|
_activeSpeech.strings[i - 1] = _activeSpeech.strings[i];
|
|
|
|
}
|
|
|
|
_activeSpeech.stringsCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isSpeaking())
|
|
|
|
_vm->_script->wakeUpThreadsDelayed(kWaitTypeSpeech, ticksToMSec(kScriptTimeTicksPerSecond / 3));
|
|
|
|
}
|
|
|
|
|
2004-08-02 15:47:42 +00:00
|
|
|
int Actor::direct(int msec) {
|
2004-12-18 20:33:02 +00:00
|
|
|
int i;
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
ActorIntentList::iterator actorIntentIterator;
|
2004-10-27 21:32:28 +00:00
|
|
|
ACTORINTENT *a_intent;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
int o_idx;
|
|
|
|
int action_tdelta;
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Walk down the actor list and direct each actor
|
2004-12-18 20:33:02 +00:00
|
|
|
for (i = 0; i < ACTORCOUNT; i++) {
|
|
|
|
actor = &_actors[i];
|
|
|
|
if (actor->disabled) continue;
|
2004-12-15 00:24:12 +00:00
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Process the actor intent list
|
2004-12-15 00:24:12 +00:00
|
|
|
actorIntentIterator = actor->a_intentlist.begin();
|
|
|
|
if (actorIntentIterator != actor->a_intentlist.end()) {
|
|
|
|
a_intent = actorIntentIterator.operator->();
|
2004-04-12 21:40:49 +00:00
|
|
|
switch (a_intent->a_itype) {
|
|
|
|
case INTENT_NONE:
|
2004-05-01 06:16:57 +00:00
|
|
|
// Actor doesn't really feel like doing anything at all
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
case INTENT_PATH:
|
2004-05-01 06:16:57 +00:00
|
|
|
// Actor intends to go somewhere. Well good for him
|
2004-04-12 21:40:49 +00:00
|
|
|
{
|
2004-12-17 11:18:56 +00:00
|
|
|
handleWalkIntent(actor, &a_intent->walkIntent, &a_intent->a_idone, msec);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-05-01 06:16:57 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// If this actor intent was flagged as completed, remove it.
|
2004-04-12 21:40:49 +00:00
|
|
|
if (a_intent->a_idone) {
|
2004-12-15 00:24:12 +00:00
|
|
|
actor->a_intentlist.erase(actorIntentIterator);
|
2004-04-12 21:40:49 +00:00
|
|
|
actor->action = actor->def_action;
|
|
|
|
actor->action_flags = actor->def_action_flags;
|
|
|
|
actor->action_frame = 0;
|
|
|
|
actor->action_time = 0;
|
|
|
|
}
|
|
|
|
} else {
|
2004-05-01 06:16:57 +00:00
|
|
|
// Actor has no intent, idle?
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Process actor actions
|
2004-04-12 21:40:49 +00:00
|
|
|
actor->action_time += msec;
|
|
|
|
|
|
|
|
if (actor->action >= ACTION_COUNT) {
|
|
|
|
action_tdelta = ACTOR_ACTIONTIME;
|
|
|
|
} else {
|
|
|
|
action_tdelta = ActionTDeltas[actor->action].time;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor->action_time >= action_tdelta) {
|
|
|
|
actor->action_time -= action_tdelta;
|
|
|
|
actor->action_frame++;
|
|
|
|
|
|
|
|
o_idx = ActorOrientationLUT[actor->orient];
|
2004-12-17 20:38:17 +00:00
|
|
|
if (actor->frames[actor->action].dir[o_idx].frameCount <= actor->action_frame) {
|
2004-04-12 21:40:49 +00:00
|
|
|
if (actor->action_flags & ACTION_LOOP) {
|
|
|
|
actor->action_frame = 0;
|
|
|
|
} else {
|
|
|
|
actor->action_frame--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-01 06:16:57 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
//process speech
|
|
|
|
handleSpeech(msec);
|
2004-10-27 21:32:28 +00:00
|
|
|
return SUCCESS;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
void Actor::createDrawOrderList() {
|
|
|
|
int i;
|
2004-12-19 13:38:11 +00:00
|
|
|
int beginSlope, endSlope, middle;
|
2004-12-18 20:33:02 +00:00
|
|
|
ActorData *actor;
|
|
|
|
|
|
|
|
_drawOrderList.clear();
|
2004-12-21 06:49:07 +00:00
|
|
|
for (i = 0; i < ACTORCOUNT; i++) {
|
2004-12-18 20:33:02 +00:00
|
|
|
actor = &_actors[i];
|
|
|
|
if (actor->disabled) continue;
|
2004-12-19 13:38:11 +00:00
|
|
|
if (actor->sceneNumber != _vm->_scene->currentSceneNumber()) continue;
|
2004-12-18 20:33:02 +00:00
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
_drawOrderList.pushBack(actor, actorCompare);
|
|
|
|
|
|
|
|
middle = ITE_STATUS_Y - actor->actorY / ACTOR_LMULT,
|
|
|
|
|
|
|
|
_vm->_scene->getSlopes(beginSlope, endSlope);
|
|
|
|
|
|
|
|
actor->screenDepth = (14 * middle) / endSlope + 1;
|
|
|
|
|
|
|
|
if (middle <= beginSlope) {
|
|
|
|
actor->screenScale = 256;
|
|
|
|
} else {
|
|
|
|
if (middle >= endSlope) {
|
|
|
|
actor->screenScale = 1;
|
|
|
|
} else {
|
|
|
|
middle -= beginSlope;
|
|
|
|
endSlope -= beginSlope;
|
|
|
|
actor->screenScale = 256 - (middle * 256) / endSlope;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
actor->screenPosition.x = (actor->actorX / ACTOR_LMULT);
|
|
|
|
actor->screenPosition.y = (actor->actorY / ACTOR_LMULT) - actor->actorZ;
|
2004-12-18 20:33:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Actor::drawActors() {
|
|
|
|
ActorOrderList::iterator actorDrawOrderIterator;
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
int o_idx; //Orientation index
|
2004-04-12 21:40:49 +00:00
|
|
|
int sprite_num;
|
|
|
|
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
SURFACE *back_buf;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-01 11:48:53 +00:00
|
|
|
back_buf = _vm->_gfx->getBackBuffer();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
createDrawOrderList();
|
|
|
|
|
|
|
|
for (actorDrawOrderIterator = _drawOrderList.begin(); actorDrawOrderIterator != _drawOrderList.end(); ++actorDrawOrderIterator) {
|
|
|
|
actor = actorDrawOrderIterator.operator*();
|
2004-12-19 13:38:11 +00:00
|
|
|
if (actor->framesCount == 0) {
|
|
|
|
warning("actor->framesCount == 0 actorId 0x%X", actor->actorId);
|
|
|
|
continue;
|
|
|
|
}
|
2004-12-18 16:08:59 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
o_idx = ActorOrientationLUT[actor->orient];
|
2004-12-17 20:38:17 +00:00
|
|
|
sprite_num = actor->frames[actor->action].dir[o_idx].frameIndex;
|
2004-04-12 21:40:49 +00:00
|
|
|
sprite_num += actor->action_frame;
|
2004-12-19 13:38:11 +00:00
|
|
|
if (actor->spriteList->sprite_count <= sprite_num) {
|
|
|
|
warning("(actor->spriteList->sprite_count <= sprite_num) actorId 0x%X", actor->actorId);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
_vm->_sprite->drawOccluded(back_buf, actor->spriteList, sprite_num, actor->screenPosition, actor->screenScale, actor->screenDepth);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
// draw speeches
|
|
|
|
if (isSpeaking() && !_vm->_script->_skipSpeeches) {
|
|
|
|
int i;
|
|
|
|
int textDrawFlags, speechColor;
|
|
|
|
Point speechCoord;
|
|
|
|
char oneChar[2];
|
|
|
|
oneChar[1] = 0;
|
|
|
|
const char *outputString;
|
|
|
|
|
|
|
|
if (_activeSpeech.speechFlags & kSpeakSlow) {
|
|
|
|
outputString = oneChar;
|
|
|
|
oneChar[0] = _activeSpeech.strings[0][_activeSpeech.slowModeCharIndex];
|
|
|
|
} else {
|
|
|
|
outputString = _activeSpeech.strings[0];
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
textDrawFlags = FONT_CENTERED;
|
|
|
|
if (_activeSpeech.outlineColor != 0) {
|
|
|
|
textDrawFlags |= FONT_OUTLINE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
if (_activeSpeech.actorIds[0] != 0) {
|
|
|
|
|
|
|
|
for (i = 0; i < _activeSpeech.actorsCount; i++){
|
|
|
|
actor = getActor(_activeSpeech.actorIds[i]);
|
|
|
|
speechCoord.x = actor->screenPosition.x;
|
|
|
|
speechCoord.y = actor->screenPosition.y;
|
|
|
|
speechCoord.y -= ACTOR_DIALOGUE_HEIGHT;
|
|
|
|
if (_activeSpeech.actorsCount > 1)
|
|
|
|
speechColor = actor->speechColor;
|
|
|
|
else
|
|
|
|
speechColor = _activeSpeech.speechColor;
|
|
|
|
|
|
|
|
_vm->textDraw(MEDIUM_FONT_ID, back_buf, outputString, speechCoord.x, speechCoord.y, speechColor, _activeSpeech.outlineColor, textDrawFlags);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
} else { // non actors speech
|
|
|
|
warning("non actors speech occures");
|
|
|
|
//todo: write it
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
return SUCCESS;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
void Actor::setOrientation(uint16 actorId, int orient) {
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = getActor(actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
if ((orient < 0) || (orient > 7)) {
|
2004-12-17 11:18:56 +00:00
|
|
|
error("Actor::setOrientation wrong orientation 0x%X", orient);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actor->orient = orient;
|
|
|
|
}
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
void Actor::setAction(uint16 actorId, int action_n, uint16 action_flags) {
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = getActor(actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
if ((action_n < 0) || (action_n >= actor->framesCount)) {
|
2004-12-17 11:18:56 +00:00
|
|
|
error("Actor::setAction wrong action_n 0x%X", action_n);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actor->action = action_n;
|
|
|
|
actor->action_flags = action_flags;
|
|
|
|
actor->action_frame = 0;
|
|
|
|
actor->action_time = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
void Actor::setDefaultAction(uint16 actorId, int action_n, uint16 action_flags) {
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = getActor(actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-18 20:33:02 +00:00
|
|
|
if ((action_n < 0) || (action_n >= actor->framesCount)) {
|
2004-12-17 11:18:56 +00:00
|
|
|
error("Actor::setDefaultAction wrong action_n 0x%X", action_n);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actor->def_action = action_n;
|
|
|
|
actor->def_action_flags = action_flags;
|
|
|
|
}
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
void Actor::walkTo(uint16 actorId, const Point *walk_pt, uint16 flags, SEMAPHORE *sem) {
|
2004-10-27 21:32:28 +00:00
|
|
|
ACTORINTENT actor_intent;
|
2004-12-17 20:38:17 +00:00
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
assert(walk_pt != NULL);
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = getActor(actorId);
|
2004-12-17 11:18:56 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
actor_intent.a_itype = INTENT_PATH;
|
|
|
|
actor_intent.a_iflags = 0;
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
actor_intent.walkIntent.wi_flags = flags;
|
|
|
|
actor_intent.walkIntent.sem_held = 1;
|
|
|
|
actor_intent.walkIntent.sem = sem;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 15:47:42 +00:00
|
|
|
// handleWalkIntent() will create path on initialization
|
2004-12-17 11:18:56 +00:00
|
|
|
actor_intent.walkIntent.wi_init = 0;
|
|
|
|
actor_intent.walkIntent.dst_pt = *walk_pt;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
actor->a_intentlist.push_back(actor_intent);
|
2004-12-18 20:33:02 +00:00
|
|
|
int is = actor->a_intentlist.size();
|
2004-12-21 06:49:07 +00:00
|
|
|
debug(9, "actor->a_intentlist.size() %i", is);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
if (sem != NULL) {
|
2004-08-12 23:57:45 +00:00
|
|
|
_vm->_script->SThreadHoldSem(sem);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
int Actor::setPathNode(WALKINTENT *walk_int, const Point &src_pt, Point *dst_pt, SEMAPHORE *sem) {
|
2004-10-27 21:32:28 +00:00
|
|
|
WALKNODE new_node;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
walk_int->wi_active = 1;
|
2004-12-19 13:38:11 +00:00
|
|
|
walk_int->org = src_pt;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
assert((walk_int != NULL) && (dst_pt != NULL));
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
new_node.node_pt = *dst_pt;
|
|
|
|
new_node.calc_flag = 0;
|
2004-12-15 00:24:12 +00:00
|
|
|
|
|
|
|
walk_int->nodelist.push_back(new_node);
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
return SUCCESS;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
int Actor::handleWalkIntent(ActorData *actor, WALKINTENT *a_walkint, int *complete_p, int delta_time) {
|
2004-12-15 00:24:12 +00:00
|
|
|
WalkNodeList::iterator walkNodeIterator;
|
|
|
|
WalkNodeList::iterator nextWalkNodeIterator;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
WALKNODE *node_p;
|
2004-04-12 21:40:49 +00:00
|
|
|
int dx;
|
|
|
|
int dy;
|
|
|
|
|
|
|
|
double path_a;
|
|
|
|
double path_b;
|
|
|
|
double path_slope;
|
|
|
|
|
|
|
|
double path_x;
|
|
|
|
double path_y;
|
|
|
|
int path_time;
|
|
|
|
|
|
|
|
double new_a_x;
|
|
|
|
double new_a_y;
|
|
|
|
|
|
|
|
int actor_x;
|
|
|
|
int actor_y;
|
|
|
|
|
|
|
|
char buf[100];
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Initialize walk intent
|
2004-04-12 21:40:49 +00:00
|
|
|
if (!a_walkint->wi_init) {
|
2004-12-19 13:38:11 +00:00
|
|
|
setPathNode(a_walkint, Point(actor->actorX,actor->actorY), &a_walkint->dst_pt, a_walkint->sem);
|
2004-12-18 20:33:02 +00:00
|
|
|
setDefaultAction(actor->actorId, ACTION_IDLE, ACTION_NONE);
|
2004-04-12 21:40:49 +00:00
|
|
|
a_walkint->wi_init = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(a_walkint->wi_active);
|
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
walkNodeIterator = a_walkint->nodelist.begin();
|
|
|
|
nextWalkNodeIterator = walkNodeIterator;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
node_p = walkNodeIterator.operator->();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
if (node_p->calc_flag == 0) {
|
|
|
|
|
2004-05-05 13:05:45 +00:00
|
|
|
debug(2, "Calculating new path vector to point (%d, %d)", node_p->node_pt.x, node_p->node_pt.y);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
dx = a_walkint->org.x - node_p->node_pt.x;
|
|
|
|
dy = a_walkint->org.y - node_p->node_pt.y;
|
|
|
|
|
|
|
|
if (dx == 0) {
|
|
|
|
|
2004-05-05 13:05:45 +00:00
|
|
|
debug(0, "Vertical paths not implemented.");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
a_walkint->nodelist.erase(walkNodeIterator);
|
2004-04-12 21:40:49 +00:00
|
|
|
a_walkint->wi_active = 0;
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Release path semaphore
|
2004-04-12 21:40:49 +00:00
|
|
|
if ((a_walkint->sem != NULL) && a_walkint->sem_held) {
|
2004-08-12 23:57:45 +00:00
|
|
|
_vm->_script->SThreadReleaseSem(a_walkint->sem);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*complete_p = 1;
|
2004-10-27 21:32:28 +00:00
|
|
|
return FAILURE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
a_walkint->slope = (float)dy / dx;
|
|
|
|
|
|
|
|
if (dx > 0) {
|
|
|
|
a_walkint->x_dir = -1;
|
|
|
|
if (!(a_walkint->wi_flags & WALK_NOREORIENT)) {
|
|
|
|
if (a_walkint->slope > 1.0) {
|
|
|
|
actor->orient = ORIENT_N;
|
|
|
|
} else if (a_walkint->slope < -1.0) {
|
|
|
|
actor->orient = ORIENT_S;
|
|
|
|
} else {
|
|
|
|
actor->orient = ORIENT_W;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
a_walkint->x_dir = 1;
|
|
|
|
if (!(a_walkint->wi_flags & WALK_NOREORIENT)) {
|
|
|
|
if (a_walkint->slope > 1.0) {
|
|
|
|
actor->orient = ORIENT_S;
|
|
|
|
} else if (a_walkint->slope < -1.0) {
|
|
|
|
actor->orient = ORIENT_N;
|
|
|
|
} else {
|
|
|
|
actor->orient = ORIENT_E;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(buf, "%f", a_walkint->slope);
|
|
|
|
|
2004-05-05 13:05:45 +00:00
|
|
|
debug(2, "Path slope: %s.", buf);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
actor->action = ACTION_WALK;
|
|
|
|
actor->action_flags = ACTION_LOOP;
|
|
|
|
a_walkint->time = 0;
|
|
|
|
node_p->calc_flag = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
a_walkint->time += delta_time;
|
|
|
|
path_time = a_walkint->time;
|
|
|
|
|
|
|
|
path_a = ACTOR_BASE_SPEED * path_time;
|
|
|
|
path_b = ACTOR_BASE_SPEED * path_time * ACTOR_BASE_ZMOD;
|
|
|
|
path_slope = a_walkint->slope * a_walkint->x_dir;
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
path_x = (path_a * path_b) / sqrt((path_a * path_a) * (path_slope * path_slope) + (path_b * path_b));
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
path_y = path_slope * path_x;
|
|
|
|
path_x = path_x * a_walkint->x_dir;
|
|
|
|
|
|
|
|
new_a_x = path_x + a_walkint->org.x;
|
|
|
|
new_a_y = path_y + a_walkint->org.y;
|
|
|
|
|
2004-10-07 22:31:39 +00:00
|
|
|
if (((a_walkint->x_dir == 1) && new_a_x >= node_p->node_pt.x) ||
|
|
|
|
((a_walkint->x_dir != 1) && (new_a_x <= node_p->node_pt.x))) {
|
2004-10-08 01:22:39 +00:00
|
|
|
Point endpoint;
|
|
|
|
int exitNum;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-08 01:22:39 +00:00
|
|
|
debug(2, "Path complete.");
|
2004-12-15 00:24:12 +00:00
|
|
|
a_walkint->nodelist.erase(walkNodeIterator);
|
2004-10-08 01:22:39 +00:00
|
|
|
a_walkint->wi_active = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-08 01:22:39 +00:00
|
|
|
// Release path semaphore
|
|
|
|
if (a_walkint->sem != NULL) {
|
|
|
|
_vm->_script->SThreadReleaseSem(a_walkint->sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
actor->action_frame = 0;
|
|
|
|
actor->action = ACTION_IDLE;
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
endpoint.x = (int)new_a_x / ACTOR_LMULT;
|
|
|
|
endpoint.y = (int)new_a_y / ACTOR_LMULT;
|
2004-10-08 01:22:39 +00:00
|
|
|
if ((exitNum = _vm->_scene->_actionMap->hitTest(endpoint)) != -1) {
|
2004-10-26 07:02:32 +00:00
|
|
|
if (actor->flags & kProtagonist)
|
2004-10-21 06:49:11 +00:00
|
|
|
_vm->_scene->changeScene(_vm->_scene->_actionMap->getExitScene(exitNum));
|
2004-10-08 01:22:39 +00:00
|
|
|
}
|
|
|
|
*complete_p = 1;
|
2004-10-27 21:32:28 +00:00
|
|
|
return FAILURE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
actor_x = (int)new_a_x;
|
|
|
|
actor_y = (int)new_a_y;
|
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
actor->actorX = (int)new_a_x;
|
|
|
|
actor->actorY = (int)new_a_y;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
return SUCCESS;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
void Actor::move(uint16 actorId, const Point &movePoint) {
|
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = getActor(actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
actor->actorX = movePoint.x;
|
|
|
|
actor->actorY = movePoint.y;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
void Actor::moveRelative(uint16 actorId, const Point &movePoint) {
|
|
|
|
ActorData *actor;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
actor = getActor(actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
actor->actorX += movePoint.x;
|
|
|
|
actor->actorY += movePoint.y;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
void Actor::StoA(Point &actorPoint, const Point &screenPoint) {
|
|
|
|
actorPoint.x = (screenPoint.x * ACTOR_LMULT);
|
|
|
|
actorPoint.y = (screenPoint.y * ACTOR_LMULT);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
void Actor::actorSpeech(uint16 actorId, const char **strings, int stringsCount, uint16 sampleResourceId, int speechFlags) {
|
|
|
|
ActorData *actor;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
actor = getActor(actorId);
|
|
|
|
for (i = 0; i < stringsCount; i++) {
|
|
|
|
_activeSpeech.strings[i] = strings[i];
|
|
|
|
}
|
|
|
|
_activeSpeech.stringsCount = stringsCount;
|
|
|
|
_activeSpeech.speechFlags = speechFlags;
|
|
|
|
_activeSpeech.actorsCount = 1;
|
|
|
|
_activeSpeech.actorIds[0] = actorId;
|
|
|
|
_activeSpeech.speechColor = actor->speechColor;
|
|
|
|
_activeSpeech.outlineColor = 15; // fixme - BLACK
|
|
|
|
_activeSpeech.sampleResourceId = sampleResourceId;
|
|
|
|
_activeSpeech.playing = false;
|
|
|
|
_activeSpeech.slowModeCharIndex = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Actor::nonActorSpeech(const char **strings, int stringsCount, int speechFlags) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
_vm->_script->wakeUpThreads(kWaitTypeSpeech);
|
|
|
|
|
|
|
|
for (i = 0; i < stringsCount; i++) {
|
|
|
|
_activeSpeech.strings[i] = strings[i];
|
|
|
|
}
|
|
|
|
_activeSpeech.stringsCount = stringsCount;
|
|
|
|
_activeSpeech.speechFlags = speechFlags;
|
|
|
|
_activeSpeech.actorsCount = 1;
|
|
|
|
_activeSpeech.actorIds[0] = 0;
|
|
|
|
//_activeSpeech.speechColor = ;
|
|
|
|
//_activeSpeech.outlineColor = ;
|
|
|
|
_activeSpeech.sampleResourceId = -1;
|
|
|
|
_activeSpeech.playing = false;
|
|
|
|
_activeSpeech.slowModeCharIndex = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Actor::simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount, int speechFlags) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < actorIdsCount; i++) {
|
|
|
|
_activeSpeech.actorIds[i] = actorIds[i];
|
|
|
|
}
|
|
|
|
_activeSpeech.strings[0] = string;
|
|
|
|
_activeSpeech.stringsCount = 1;
|
|
|
|
_activeSpeech.speechFlags = speechFlags;
|
|
|
|
//_activeSpeech.speechColor = ; // get's from every actor
|
|
|
|
_activeSpeech.outlineColor = 0; // disable outline
|
|
|
|
_activeSpeech.sampleResourceId = -1;
|
|
|
|
_activeSpeech.playing = false;
|
|
|
|
_activeSpeech.slowModeCharIndex = 0;
|
|
|
|
|
|
|
|
// caller should call thread->wait(kWaitTypeSpeech) by itself
|
|
|
|
}
|
|
|
|
|
|
|
|
void Actor::abortAllSpeeches() {
|
|
|
|
if (_vm->_script->_abortEnabled)
|
|
|
|
_vm->_script->_skipSpeeches = true;
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
_vm->_script->executeThreads(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Actor::abortSpeech() {
|
|
|
|
_vm->_sound->stopVoice();
|
|
|
|
_activeSpeech.playingTime = 0;
|
|
|
|
}
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
// Console wrappers - must be safe to run
|
|
|
|
// TODO - checkup ALL arguments, cause wrong arguments may fall function with "error"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
void Actor::CF_actor_move(int argc, const char **argv) {
|
2004-12-17 11:18:56 +00:00
|
|
|
uint16 actorId = (uint16) atoi(argv[1]);
|
2004-12-17 20:38:17 +00:00
|
|
|
Point movePoint;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
movePoint.x = atoi(argv[2]);
|
|
|
|
movePoint.y = atoi(argv[3]);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
if (!IS_VALID_ACTOR_ID(actorId)) {
|
|
|
|
_vm->_console->DebugPrintf("Actor::CF_actor_move Invalid actorId 0x%X.\n", actorId);
|
2004-12-17 11:18:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
move(actorId, movePoint);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
void Actor::CF_actor_moverel(int argc, const char **argv) {
|
2004-12-17 11:18:56 +00:00
|
|
|
uint16 actorId = (uint16) atoi(argv[1]);
|
2004-12-17 20:38:17 +00:00
|
|
|
Point movePoint;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
movePoint.x = atoi(argv[2]);
|
|
|
|
movePoint.y = atoi(argv[3]);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
if (!IS_VALID_ACTOR_ID(actorId)) {
|
|
|
|
_vm->_console->DebugPrintf("Actor::CF_actor_moverel Invalid actorId 0x%X.\n", actorId);
|
2004-12-17 11:18:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
moveRelative(actorId, movePoint);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
void Actor::CF_actor_seto(int argc, const char **argv) {
|
2004-12-17 11:18:56 +00:00
|
|
|
uint16 actorId = (uint16) atoi(argv[1]);
|
2004-04-12 21:40:49 +00:00
|
|
|
int orient;
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
orient = atoi(argv[2]);
|
2004-12-17 11:18:56 +00:00
|
|
|
//TODO orient check
|
2004-12-17 20:38:17 +00:00
|
|
|
if (!IS_VALID_ACTOR_ID(actorId)) {
|
2004-12-17 11:18:56 +00:00
|
|
|
_vm->_console->DebugPrintf("Actor::CF_actor_seto Invalid actorId 0x%X.\n",actorId);
|
|
|
|
return;
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
setOrientation(actorId, orient);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
void Actor::CF_actor_setact(int argc, const char **argv) {
|
2004-12-17 11:18:56 +00:00
|
|
|
uint16 actorId = (uint16) atoi(argv[1]);
|
2004-04-12 21:40:49 +00:00
|
|
|
int action_n = 0;
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
action_n = atoi(argv[2]);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-17 20:38:17 +00:00
|
|
|
if (!IS_VALID_ACTOR_ID(actorId)) {
|
2004-12-17 11:18:56 +00:00
|
|
|
_vm->_console->DebugPrintf("Actor::CF_actor_setact Invalid actorId 0x%X.\n",actorId);
|
2004-04-12 21:40:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-17 11:18:56 +00:00
|
|
|
//TODO action_n check
|
|
|
|
/* if ((action_n < 0) || (action_n >= actor->action_ct)) {
|
2004-12-03 19:15:44 +00:00
|
|
|
_vm->_console->DebugPrintf("Invalid action number.\n");
|
2004-04-12 21:40:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
_vm->_console->DebugPrintf("Action frame counts: %d %d %d %d.\n",
|
2004-05-01 06:16:57 +00:00
|
|
|
actor->act_tbl[action_n].dir[0].frame_count,
|
|
|
|
actor->act_tbl[action_n].dir[1].frame_count,
|
|
|
|
actor->act_tbl[action_n].dir[2].frame_count,
|
|
|
|
actor->act_tbl[action_n].dir[3].frame_count);
|
2004-12-17 11:18:56 +00:00
|
|
|
*/
|
|
|
|
setAction(actorId, action_n, ACTION_LOOP);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Saga
|