mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 05:01:43 +00:00
Reworked hotspot actions so that talking to characters work properly
svn-id: r26675
This commit is contained in:
parent
c0d487830e
commit
885f687ae5
@ -105,13 +105,12 @@ bool Debugger::cmd_enterRoom(int argc, const char **argv) {
|
||||
|
||||
bool Debugger::cmd_listRooms(int argc, const char **argv) {
|
||||
RoomDataList &rooms = Resources::getReference().roomData();
|
||||
RoomDataList::iterator i;
|
||||
StringData &strings = StringData::getReference();
|
||||
char buffer[MAX_DESC_SIZE];
|
||||
int ctr = 0;
|
||||
|
||||
DebugPrintf("Available rooms are:\n");
|
||||
for (i = rooms.begin(); i != rooms.end(); ++i) {
|
||||
for (RoomDataList::iterator i = rooms.begin(); i != rooms.end(); ++i) {
|
||||
RoomData *room = *i;
|
||||
strings.getString(room->roomNumber, buffer);
|
||||
// DEBUG: Explictly note the second drawbridge room as "Alt" for now
|
||||
@ -131,6 +130,18 @@ bool Debugger::cmd_listRooms(int argc, const char **argv) {
|
||||
}
|
||||
DebugPrintf("\n");
|
||||
DebugPrintf("Current room: %d\n", Room::getReference().roomNumber());
|
||||
|
||||
Resources &res = Resources::getReference();
|
||||
HotspotDataList &list = res.hotspotData();
|
||||
for (HotspotDataList::iterator i = list.begin(); i != list.end(); ++i)
|
||||
{
|
||||
HotspotData *data = *i;
|
||||
strings.getString(data->nameId, buffer);
|
||||
|
||||
DebugPrintf("%xh - %s\n", data->hotspotId, buffer);
|
||||
}
|
||||
DebugPrintf("\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -298,8 +309,8 @@ bool Debugger::cmd_hotspot(int argc, const char **argv) {
|
||||
DebugPrintf("Talk bubble offset = %d,%d\n", hs->talkX, hs->talkY);
|
||||
DebugPrintf("load offset = %xh, script load = %d\n", hs->loadOffset, hs->scriptLoadFlag);
|
||||
DebugPrintf("Animation Id = %xh, Colour offset = %d\n", hs->animRecordId, hs->colourOffset);
|
||||
DebugPrintf("Script offset = %xh, Tick Script offset = %xh\n",
|
||||
hs->sequenceOffset, hs->tickSequenceOffset);
|
||||
DebugPrintf("Talk Script offset = %xh, Tick Script offset = %xh\n",
|
||||
hs->talkScriptOffset, hs->tickScriptOffset);
|
||||
DebugPrintf("Tick Proc offset = %xh\n", hs->tickProcOffset);
|
||||
DebugPrintf("Tick timeout = %d\n", hs->tickTimeout);
|
||||
DebugPrintf("NPC Shcedule = %xh\n", hs->npcSchedule);
|
||||
|
@ -62,7 +62,7 @@ Hotspot::Hotspot(HotspotData *res): _pathFinder(this) {
|
||||
_talkX = res->talkX;
|
||||
_talkY = res->talkY;
|
||||
_layer = res->layer;
|
||||
_sequenceOffset = res->sequenceOffset;
|
||||
_hotspotScriptOffset = res->hotspotScriptOffset;
|
||||
_tickCtr = res->tickTimeout;
|
||||
_colourOffset = res->colourOffset;
|
||||
|
||||
@ -404,7 +404,7 @@ void Hotspot::setSize(uint16 newWidth, uint16 newHeight) {
|
||||
}
|
||||
|
||||
bool Hotspot::executeScript() {
|
||||
if (_data->sequenceOffset == 0xffff)
|
||||
if (_data->hotspotScriptOffset == 0xffff)
|
||||
return false;
|
||||
else
|
||||
return HotspotScript::execute(this);
|
||||
@ -672,7 +672,7 @@ void Hotspot::converse(uint16 destCharacterId, uint16 messageId, bool standStill
|
||||
HotspotData *hotspot = Resources::getReference().getHotspot(destCharacterId);
|
||||
_data->talkCountdown += hotspot->talkCountdown;
|
||||
|
||||
_data->talkDestCharacterId = _hotspotId;
|
||||
_data->talkDestCharacterId = destCharacterId;
|
||||
_data->talkGate = 0;
|
||||
}
|
||||
|
||||
@ -845,7 +845,7 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) {
|
||||
} else {
|
||||
// loc_886
|
||||
setActionCtr(0);
|
||||
converse(NOONE_ID, 0xE);
|
||||
showMessage(14, NOONE_ID);
|
||||
return PC_FAILED;
|
||||
}
|
||||
} else {
|
||||
@ -860,7 +860,7 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) {
|
||||
|
||||
} else if (hotspot->actionHotspotId != _hotspotId) {
|
||||
if (fields.getField(82) != 2) {
|
||||
converse(NOONE_ID, 5);
|
||||
showMessage(5, hotspot->hotspotId);
|
||||
setDelayCtr(4);
|
||||
}
|
||||
|
||||
@ -2019,7 +2019,7 @@ void Hotspot::saveToStream(Common::WriteStream *stream) {
|
||||
stream->writeUint16LE(_talkX);
|
||||
stream->writeUint16LE(_talkY);
|
||||
stream->writeByte(_layer);
|
||||
stream->writeUint16LE(_sequenceOffset);
|
||||
stream->writeUint16LE(_hotspotScriptOffset);
|
||||
stream->writeUint16LE(_tickCtr);
|
||||
stream->writeByte(_colourOffset);
|
||||
stream->writeUint16LE(_animId);
|
||||
@ -2054,7 +2054,7 @@ void Hotspot::loadFromStream(Common::ReadStream *stream) {
|
||||
_talkX = stream->readUint16LE();
|
||||
_talkY = stream->readUint16LE();
|
||||
_layer = stream->readByte();
|
||||
_sequenceOffset = stream->readUint16LE();
|
||||
_hotspotScriptOffset = stream->readUint16LE();
|
||||
_tickCtr = stream->readUint16LE();
|
||||
_colourOffset = stream->readByte();
|
||||
setAnimation(stream->readUint16LE());
|
||||
@ -2180,7 +2180,7 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
|
||||
if (h.talkGate() == 0x2A) {
|
||||
fields.setField(ACTIVE_HOTSPOT_ID, h.talkGate());
|
||||
fields.setField(USE_HOTSPOT_ID, h.resource()->talkDestCharacterId);
|
||||
Script::execute(h.script());
|
||||
Script::execute(h.talkScript());
|
||||
h.resource()->talkDestCharacterId = 0;
|
||||
} else {
|
||||
h.updateMovement();
|
||||
@ -2970,7 +2970,7 @@ void HotspotTickHandlers::teaAnimHandler(Hotspot &h) {
|
||||
|
||||
if (h.executeScript()) {
|
||||
// Signal that the tea is done
|
||||
h.setScript(0xB82);
|
||||
h.setHotspotScript(0xB82);
|
||||
Resources::getReference().fieldList().setField(27, 1);
|
||||
}
|
||||
}
|
||||
@ -2997,14 +2997,14 @@ void HotspotTickHandlers::prisonerAnimHandler(Hotspot &h) {
|
||||
if (h.actionCtr() != 0) {
|
||||
if (h.executeScript() == 0) {
|
||||
h.setActionCtr(0);
|
||||
h.setScript(0x3E0);
|
||||
h.setHotspotScript(0x3E0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((fields.getField(PRISONER_DEAD) == 0) && (rnd.getRandomNumber(65536) >= 6)) {
|
||||
h.setActionCtr(1);
|
||||
h.setScript(0x3F6);
|
||||
h.setHotspotScript(0x3F6);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3028,7 +3028,7 @@ void HotspotTickHandlers::morkusAnimHandler(Hotspot &h) {
|
||||
if (h.executeScript()) {
|
||||
// Script is done - set new script to one of two alternates randomly
|
||||
Common::RandomSource rnd;
|
||||
h.setScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
|
||||
h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
|
||||
h.setFrameCtr(20 + rnd.getRandomNumber(63));
|
||||
}
|
||||
}
|
||||
@ -3514,7 +3514,7 @@ void HotspotTickHandlers::rackSerfAnimHandler(Hotspot &h) {
|
||||
|
||||
switch (h.actionCtr()) {
|
||||
case 1:
|
||||
h.setScript(RACK_SERF_SCRIPT_ID_1);
|
||||
h.setHotspotScript(RACK_SERF_SCRIPT_ID_1);
|
||||
h.setActionCtr(2);
|
||||
break;
|
||||
|
||||
@ -3524,7 +3524,7 @@ void HotspotTickHandlers::rackSerfAnimHandler(Hotspot &h) {
|
||||
break;
|
||||
|
||||
case 3:
|
||||
h.setScript(RACK_SERF_SCRIPT_ID_2);
|
||||
h.setHotspotScript(RACK_SERF_SCRIPT_ID_2);
|
||||
h.setActionCtr(4);
|
||||
h.setLayer(2);
|
||||
|
||||
|
@ -249,7 +249,7 @@ private:
|
||||
uint16 _frameNumber;
|
||||
Direction _direction;
|
||||
uint8 _layer;
|
||||
uint16 _sequenceOffset;
|
||||
uint16 _hotspotScriptOffset;
|
||||
uint16 _tickCtr;
|
||||
uint8 _colourOffset;
|
||||
bool _persistant;
|
||||
@ -359,7 +359,11 @@ public:
|
||||
uint16 yCorrection() { return _yCorrection; }
|
||||
uint16 charRectY() { return _charRectY; }
|
||||
uint16 roomNumber() { return _roomNumber; }
|
||||
uint16 script() { return _sequenceOffset; }
|
||||
uint16 talkScript() {
|
||||
assert(_data);
|
||||
return _data->talkScriptOffset;
|
||||
}
|
||||
uint16 hotspotScript() { return _hotspotScriptOffset; }
|
||||
uint8 layer() { return _layer; }
|
||||
uint16 tickCtr() { return _tickCtr; }
|
||||
bool skipFlag() { return _skipFlag; }
|
||||
@ -404,10 +408,10 @@ public:
|
||||
void setHeight(uint16 newHeight) {
|
||||
_height = newHeight;
|
||||
}
|
||||
void setScript(uint16 offset) {
|
||||
void setHotspotScript(uint16 offset) {
|
||||
assert(_data != NULL);
|
||||
_sequenceOffset = offset;
|
||||
_data->sequenceOffset = offset;
|
||||
_hotspotScriptOffset = offset;
|
||||
_data->hotspotScriptOffset = offset;
|
||||
}
|
||||
void setLayer(uint8 newLayer) {
|
||||
assert(_data != NULL);
|
||||
|
@ -31,7 +31,7 @@ namespace Lure {
|
||||
|
||||
#define SUPPORT_FILENAME "lure.dat"
|
||||
#define LURE_DAT_MAJOR 1
|
||||
#define LURE_DAT_MINOR 18
|
||||
#define LURE_DAT_MINOR 19
|
||||
|
||||
#define LURE_DEBUG 1
|
||||
|
||||
|
@ -321,10 +321,11 @@ HotspotData::HotspotData(HotspotResource *rec) {
|
||||
talkY = rec->talkY;
|
||||
colourOffset = FROM_LE_16(rec->colourOffset);
|
||||
animRecordId = FROM_LE_16(rec->animRecordId);
|
||||
sequenceOffset = FROM_LE_16(rec->sequenceOffset);
|
||||
hotspotScriptOffset = FROM_LE_16(rec->hotspotScriptOffset);
|
||||
talkScriptOffset = FROM_LE_16(rec->talkScriptOffset);
|
||||
tickProcOffset = FROM_LE_16(rec->tickProcOffset);
|
||||
tickTimeout = FROM_LE_16(rec->tickTimeout);
|
||||
tickSequenceOffset = FROM_LE_16(rec->tickSequenceOffset);
|
||||
tickScriptOffset = FROM_LE_16(rec->tickScriptOffset);
|
||||
npcSchedule = FROM_LE_16(rec->npcSchedule);
|
||||
characterMode = (CharacterMode) FROM_LE_16(rec->characterMode);
|
||||
delayCtr = FROM_LE_16(rec->delayCtr);
|
||||
@ -362,10 +363,10 @@ void HotspotData::saveToStream(WriteStream *stream) {
|
||||
stream->writeUint16LE(widthCopy);
|
||||
stream->writeUint16LE(heightCopy);
|
||||
stream->writeUint16LE(yCorrection);
|
||||
stream->writeUint16LE(sequenceOffset);
|
||||
stream->writeUint16LE(hotspotScriptOffset);
|
||||
stream->writeUint16LE(tickProcOffset);
|
||||
stream->writeUint16LE(tickTimeout);
|
||||
stream->writeUint16LE(tickSequenceOffset);
|
||||
stream->writeUint16LE(tickScriptOffset);
|
||||
stream->writeUint16LE(characterMode);
|
||||
stream->writeUint16LE(delayCtr);
|
||||
|
||||
@ -402,10 +403,10 @@ void HotspotData::loadFromStream(ReadStream *stream) {
|
||||
widthCopy = stream->readUint16LE();
|
||||
heightCopy = stream->readUint16LE();
|
||||
yCorrection = stream->readUint16LE();
|
||||
sequenceOffset = stream->readUint16LE();
|
||||
hotspotScriptOffset = stream->readUint16LE();
|
||||
tickProcOffset = stream->readUint16LE();
|
||||
tickTimeout = stream->readUint16LE();
|
||||
tickSequenceOffset = stream->readUint16LE();
|
||||
tickScriptOffset = stream->readUint16LE();
|
||||
characterMode = (CharacterMode) stream->readUint16LE();
|
||||
delayCtr = stream->readUint16LE();
|
||||
|
||||
|
@ -78,10 +78,11 @@ struct HotspotResource {
|
||||
int8 talkY;
|
||||
uint16 colourOffset;
|
||||
uint16 animRecordId;
|
||||
uint16 sequenceOffset;
|
||||
uint16 hotspotScriptOffset;
|
||||
uint16 talkScriptOffset;
|
||||
uint16 tickProcOffset;
|
||||
uint16 tickTimeout;
|
||||
uint16 tickSequenceOffset;
|
||||
uint16 tickScriptOffset;
|
||||
uint16 npcSchedule;
|
||||
uint16 characterMode;
|
||||
uint16 delayCtr;
|
||||
@ -416,10 +417,11 @@ public:
|
||||
int8 talkY;
|
||||
uint16 colourOffset;
|
||||
uint16 animRecordId;
|
||||
uint16 sequenceOffset;
|
||||
uint16 hotspotScriptOffset;
|
||||
uint16 talkScriptOffset;
|
||||
uint16 tickProcOffset;
|
||||
uint16 tickTimeout;
|
||||
uint16 tickSequenceOffset;
|
||||
uint16 tickScriptOffset;
|
||||
uint16 npcSchedule;
|
||||
CharacterMode characterMode;
|
||||
uint16 delayCtr;
|
||||
|
@ -59,7 +59,7 @@ void Script::setHotspotScript(uint16 hotspotId, uint16 scriptIndex, uint16 v3) {
|
||||
uint16 offset = r.getHotspotScript(scriptIndex);
|
||||
Hotspot *hotspot = r.getActiveHotspot(hotspotId);
|
||||
assert(hotspot);
|
||||
hotspot->setScript(offset);
|
||||
hotspot->setHotspotScript(offset);
|
||||
}
|
||||
|
||||
void Script::method2(uint16 v1, uint16 v2, uint16 v3) {
|
||||
@ -265,7 +265,7 @@ void Script::setBlockingHotspotScript(uint16 charId, uint16 scriptIndex, uint16
|
||||
uint16 offset = r.getHotspotScript(scriptIndex);
|
||||
|
||||
Hotspot *hs = r.getActiveHotspot(charId);
|
||||
hs->setScript(offset);
|
||||
hs->setHotspotScript(offset);
|
||||
hs->currentActions().top().setAction(EXEC_HOTSPOT_SCRIPT);
|
||||
hs->setOccupied(true);
|
||||
}
|
||||
@ -359,7 +359,7 @@ void Script::transformPlayer(uint16 v1, uint16 v2, uint16 v3) {
|
||||
|
||||
Hotspot *activeHotspot = res.addHotspot(TRANSFORM_ID);
|
||||
activeHotspot->setFrameNumber(0);
|
||||
activeHotspot->setScript(0x630);
|
||||
activeHotspot->setHotspotScript(0x630);
|
||||
}
|
||||
|
||||
// Marks the jail door in room 14 for closing
|
||||
@ -396,6 +396,15 @@ void Script::doorOpen(uint16 hotspotId, uint16 v2, uint16 v3) {
|
||||
joinRec->blocked = 0;
|
||||
}
|
||||
|
||||
// Makes the specified NPC wait for the player to walk to them
|
||||
|
||||
void Script::npcWait(uint16 hotspotId, uint16 v2, uint16 v3) {
|
||||
Hotspot *hotspot = Resources::getReference().getActiveHotspot(hotspotId);
|
||||
assert(hotspot);
|
||||
hotspot->setCharacterMode(CHARMODE_WAIT_FOR_INTERACT);
|
||||
hotspot->setDelayCtr(130);
|
||||
}
|
||||
|
||||
// Lookup the given message Id for the specified character and display in a dialog
|
||||
|
||||
void Script::displayMessage(uint16 messageId, uint16 characterId, uint16 unknownVal) {
|
||||
@ -579,6 +588,7 @@ SequenceMethodRecord scriptMethods[] = {
|
||||
{40, Script::checkDroppedDesc},
|
||||
{42, Script::doorClose},
|
||||
{44, Script::doorOpen},
|
||||
{45, Script::npcWait},
|
||||
{47, Script::displayMessage},
|
||||
{48, Script::setNewSupportData},
|
||||
{49, Script::setSupportData},
|
||||
@ -936,7 +946,7 @@ bool HotspotScript::execute(Hotspot *h)
|
||||
{
|
||||
Resources &r = Resources::getReference();
|
||||
MemoryBlock *scriptData = r.hotspotScriptData();
|
||||
uint16 offset = h->script();
|
||||
uint16 offset = h->hotspotScript();
|
||||
int16 opcode = 0;
|
||||
int16 param1, param2;
|
||||
uint32 actions;
|
||||
@ -954,7 +964,7 @@ bool HotspotScript::execute(Hotspot *h)
|
||||
debugC(ERROR_DETAILED, kLureDebugScripts, "SET FRAME_CTR = %d", param1);
|
||||
|
||||
h->setTickCtr(param1);
|
||||
h->setScript(offset);
|
||||
h->setHotspotScript(offset);
|
||||
breakFlag = true;
|
||||
break;
|
||||
|
||||
@ -1029,7 +1039,7 @@ bool HotspotScript::execute(Hotspot *h)
|
||||
debugC(ERROR_DETAILED, kLureDebugScripts, "SET FRAME NUMBER = %d", opcode);
|
||||
|
||||
h->setFrameNumber(opcode);
|
||||
h->setScript(offset);
|
||||
h->setHotspotScript(offset);
|
||||
breakFlag = true;
|
||||
break;
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ public:
|
||||
static void doorClose(uint16 hotspotId, uint16 v2, uint16 v3);
|
||||
static void displayMessage(uint16 messageId, uint16 characterId, uint16 unknownVal);
|
||||
static void doorOpen(uint16 hotspotId, uint16 v2, uint16 v3);
|
||||
static void npcWait(uint16 hotspotId, uint16 v2, uint16 v3);
|
||||
static void setNewSupportData(uint16 hotspotId, uint16 index, uint16 v3);
|
||||
static void setSupportData(uint16 hotspotId, uint16 index, uint16 v3);
|
||||
static void givePlayerItem(uint16 hotspotId, uint16 v2, uint16 v3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user