Added code to prevent NPCs from moving when being talked to

svn-id: r26546
This commit is contained in:
Paul Gilbert
2007-04-19 06:46:56 +00:00
parent a3bde14ead
commit fdea5abb34
6 changed files with 35 additions and 25 deletions
+16 -14
View File
@@ -659,12 +659,15 @@ void Hotspot::converse(uint16 destCharacterId, uint16 messageId, bool standStill
// in case the destination is already in process of talking
HotspotData *hotspot = Resources::getReference().getHotspot(destCharacterId);
_data->talkCountdown += hotspot->talkCountdown;
_data->talkDestCharacterId = _hotspotId;
_data->talkGate = 0;
}
if (standStill) {
setDelayCtr(_data->talkCountdown);
_data->characterMode = CHARMODE_CONVERSING;
//TODO: HS[3Eh]=use_hotspot_id, HS[40h]=active_hotspot_id
//TODO: HS[3Eh]=character_hotspot_id, HS[40h]=active_hotspot_id
}
}
@@ -845,8 +848,8 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) {
} else if (hotspot->actionHotspotId != _hotspotId) {
if (fields.getField(88) == 2) {
// loc_882
hotspot->v2b = 0x2A;
hotspot->useHotspotId = _hotspotId;
hotspot->talkGate = 0x2A;
hotspot->talkDestCharacterId = _hotspotId;
return PC_WAIT;
} else {
converse(NOONE_ID, 5);
@@ -1349,7 +1352,7 @@ void Hotspot::doGive(HotspotData *hotspot) {
endAction();
if ((hotspot->hotspotId != PRISONER_ID) || (usedId != BOTTLE_HOTSPOT_ID))
showMessage(7);
showMessage(7, hotspot->hotspotId);
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, GIVE);
@@ -1380,7 +1383,7 @@ void Hotspot::doTalkTo(HotspotData *hotspot) {
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
if ((hotspot->hotspotId != SKORL_ID) && ((hotspot->roomNumber != 28) ||
(hotspot->hotspotId != 0x3EB))) {
(hotspot->hotspotId != BLACKSMITH_ID))) {
HotspotPrecheckResult result = actionPrecheck(hotspot);
if (result == PC_WAIT) return;
@@ -2156,14 +2159,14 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
// Handle any active hotspot the character is using (for example, if the player is
// talking to a character, this stops them from moving for the duration)
if (h.useHotspotId() != 0) {
debugC(ERROR_DETAILED, kLureDebugAnimations, "Use Hotspot Id = %xh, v2b = %d",
h.useHotspotId(), h.v2b());
if (h.v2b() == 0x2A) {
fields.setField(ACTIVE_HOTSPOT_ID, h.v2b());
fields.setField(USE_HOTSPOT_ID, h.useHotspotId());
if (h.resource()->talkDestCharacterId != 0) {
debugC(ERROR_DETAILED, kLureDebugAnimations, "Use Hotspot Id = %xh, talk_gate = %d",
h.resource()->talkDestCharacterId, h.talkGate());
if (h.talkGate() == 0x2A) {
fields.setField(ACTIVE_HOTSPOT_ID, h.talkGate());
fields.setField(USE_HOTSPOT_ID, h.resource()->talkDestCharacterId);
Script::execute(h.script());
h.setUseHotspotId(0);
h.resource()->talkDestCharacterId = 0;
} else {
h.updateMovement();
return;
@@ -3248,7 +3251,7 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
h.setFrameCtr(barEntry.currentCustomer->serveFlags);
barEntry.currentCustomer->serveFlags &= 0xf8;
} else if (!h.useHotspotId() == 0) {
} else if (h.resource()->talkDestCharacterId == 0) {
// Player is not currently talking
// Clear entry from list
barEntry.currentCustomer->hotspotId = 0;
@@ -3271,7 +3274,6 @@ void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
barEntry.currentCustomer = &barEntry.customers[index];
Hotspot *hotspot = res.getActiveHotspot(barEntry.customers[index].hotspotId);
assert(hotspot);
//DEBUG/TODO: Reaching here too early, so servee's x can be outside the bar range
h.setSupportValue(hotspot->x()); // Save the position to move to
h.setFrameCtr(0x80); // Flag for movement
return;
+4 -4
View File
@@ -459,13 +459,13 @@ public:
assert(_data);
_data->useHotspotId = value;
}
uint16 v2b() {
uint16 talkGate() {
assert(_data);
return _data->v2b;
return _data->talkGate;
}
void setV2b(uint16 value) {
void setTalkGate(uint16 value) {
assert(_data);
_data->v2b = value;
_data->talkGate = value;
}
uint16 supportValue() { return _supportValue; }
void setSupportValue(uint16 value) { _supportValue = value; }
+1
View File
@@ -225,6 +225,7 @@ enum Action {
#define PLAYER_ID 0x3E8
#define RATPOUCH_ID 0x3E9
#define SKORL_ID 0x3EA
#define BLACKSMITH_ID 0x3EB
#define GOEWIN_ID 0x3EF
#define FIRST_NONCHARACTER_ID 0x408
#define SACK_ID 0x40D
+7
View File
@@ -445,6 +445,13 @@ void Resources::setTalkingCharacter(uint16 id) {
HotspotData *charHotspot = res.getHotspot(_talkingCharacter);
assert(charHotspot);
charHotspot->talkCountdown = 0;
if (charHotspot->talkDestCharacterId != 0) {
HotspotData *destHotspot = res.getHotspot(charHotspot->talkDestCharacterId);
if (destHotspot != NULL)
destHotspot->talkDestCharacterId = 0;
}
charHotspot->talkDestCharacterId = 0;
}
_talkingCharacter = id;
+3 -4
View File
@@ -339,9 +339,8 @@ HotspotData::HotspotData(HotspotResource *rec) {
talkMessageId = 0;
talkDestCharacterId = 0;
talkCountdown = 0;
pauseCtr = 0;
useHotspotId = 0;
v2b = 0;
pauseCtr = 0;
actionHotspotId = 0;
talkOverride = 0;
}
@@ -381,7 +380,7 @@ void HotspotData::saveToStream(WriteStream *stream) {
stream->writeUint16LE(pauseCtr);
stream->writeUint16LE(useHotspotId);
stream->writeUint16LE(use2HotspotId);
stream->writeUint16LE(v2b);
stream->writeUint16LE(talkGate);
stream->writeUint16LE(actionHotspotId);
stream->writeUint16LE(talkOverride);
}
@@ -421,7 +420,7 @@ void HotspotData::loadFromStream(ReadStream *stream) {
pauseCtr = stream->readUint16LE();
useHotspotId = stream->readUint16LE();
use2HotspotId = stream->readUint16LE();
v2b = stream->readUint16LE();
talkGate = stream->readUint16LE();
actionHotspotId = stream->readUint16LE();
talkOverride = stream->readUint16LE();
}
+4 -3
View File
@@ -435,12 +435,13 @@ public:
uint16 talkDestCharacterId;
uint16 talkCountdown;
uint16 pauseCtr;
uint16 useHotspotId;
uint16 use2HotspotId;
uint16 v2b;
uint16 useHotspotId;
uint16 talkGate;
uint16 actionHotspotId;
uint16 talkOverride;
uint16 use2HotspotId;
void enable() { flags |= 0x80; }
void disable() { flags &= 0x7F; }
Direction nonVisualDirection() { return (Direction) scriptLoadFlag; }