[Scummvm-cvs-logs] SF.net SVN: scummvm: [25875] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Mon Feb 26 03:50:24 CET 2007


Revision: 25875
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25875&view=rev
Author:   dreammaster
Date:     2007-02-25 18:50:23 -0800 (Sun, 25 Feb 2007)

Log Message:
-----------
Added saving of the random actions set state, and implemented NPC opcode 29, which allows for an NPC to be given a custom talk record

Modified Paths:
--------------
    scummvm/trunk/engines/lure/hotspots.cpp
    scummvm/trunk/engines/lure/hotspots.h
    scummvm/trunk/engines/lure/luredefs.h
    scummvm/trunk/engines/lure/res.cpp
    scummvm/trunk/engines/lure/res_struct.cpp
    scummvm/trunk/engines/lure/res_struct.h

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2007-02-26 02:47:27 UTC (rev 25874)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2007-02-26 02:50:23 UTC (rev 25875)
@@ -980,7 +980,7 @@
 		&Hotspot::doExamine, 
 		NULL, NULL,
 		&Hotspot::npcSetRoomAndBlockedOffset, 
-		&Hotspot::npcUnknown1, 
+		&Hotspot::npcHeySir, 
 		&Hotspot::npcExecScript, 
 		&Hotspot::npcResetPausedList, 
 		&Hotspot::npcSetRandomDest,
@@ -1673,9 +1673,32 @@
 	endAction();
 }
 
-void Hotspot::npcUnknown1(HotspotData *hotspot) {
-	warning("Not yet implemented");
-	endAction();
+void Hotspot::npcHeySir(HotspotData *hotspot) {
+	Resources &res = Resources::getReference();
+
+	// If player is performing an action, wait until it's done
+	Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID);
+	if (!playerHotspot->currentActions().isEmpty()) {
+		setDelayCtr(12);
+		setCharacterMode(CHARMODE_PAUSED);
+		setActionCtr(0);
+		return;
+	}
+
+	// TODO: Check storage of hotspot Id in data_1090/data_1091=0
+
+	// Get the npc to say "Hey Sir" to player
+	showMessage(0x22, PLAYER_ID);
+
+	// Get the character to remain in place for a while
+	setDelayCtr(130);
+	setCharacterMode(CHARMODE_4);
+
+	// Set the talk override to the specified Id
+	CharacterScheduleEntry &entry = _currentActions.top().supportData();
+	_data->talkOverride = entry.param(0);
+
+	doNothing(hotspot);
 }
 
 void Hotspot::npcExecScript(HotspotData *hotspot) {
@@ -1822,9 +1845,19 @@
 uint16 Hotspot::getTalkId(HotspotData *charHotspot) {
 	Resources &res = Resources::getReference();
 	uint16 talkIndex;
+	TalkHeaderData *headerEntry;
 
+	// If the hotspot has a talk data override, return it
+	if (charHotspot->talkOverride != 0)
+	{
+		// Has an override, so return it and reset back to zero
+		uint16 result = charHotspot->talkOverride;
+		charHotspot->talkOverride = 0;
+		return result;
+	}
+
 	// Get offset of talk set to use
-	TalkHeaderData *headerEntry = res.getTalkHeader(charHotspot->hotspotId);
+	headerEntry = res.getTalkHeader(charHotspot->hotspotId);
 
 	// Calculate talk index to use
 	if (charHotspot->nameId == STRANGER_ID)
@@ -2586,7 +2619,7 @@
 	ValueTableData &fields = res.fieldList();
 	Hotspot *player = res.getActiveHotspot(PLAYER_ID);
 
-	if ((fields.getField(37) == 0) && (h.currentActions().size() <= 1))	{
+	if ((fields.getField(37) == 0) && h.currentActions().isEmpty()) {
 		if (h.roomNumber() != player->roomNumber()) {
 			// Character in different room than player
 			if (h.hotspotId() == GOEWIN_ID) 
@@ -2629,7 +2662,11 @@
 
 	// Handle selecting a random action for the character to do
 	RandomActionSet *set = res.randomActions().getRoom(h.roomNumber());
-	if (!set) return;
+	if (!set) {
+		standardCharacterAnimHandler(h);
+		return;
+	}
+
 	Common::RandomSource rnd;
 	RandomActionType actionType;
 	uint16 scheduleId;

Modified: scummvm/trunk/engines/lure/hotspots.h
===================================================================
--- scummvm/trunk/engines/lure/hotspots.h	2007-02-26 02:47:27 UTC (rev 25874)
+++ scummvm/trunk/engines/lure/hotspots.h	2007-02-26 02:50:23 UTC (rev 25875)
@@ -260,7 +260,7 @@
 	uint8 _exitCtr;
 	bool _walkFlag;
 	uint16 _startRoomNumber;
-
+	
 	// Support methods
 	uint16 getTalkId(HotspotData *charHotspot);
 	void startTalk(HotspotData *charHotspot, uint16 id);
@@ -294,7 +294,7 @@
 	void doBribe(HotspotData *hotspot);
 	void doExamine(HotspotData *hotspot);
 	void npcSetRoomAndBlockedOffset(HotspotData *hotspot);
-	void npcUnknown1(HotspotData *hotspot); 
+	void npcHeySir(HotspotData *hotspot); 
 	void npcExecScript(HotspotData *hotspot); 
 	void npcResetPausedList(HotspotData *hotspot); 
 	void npcSetRandomDest(HotspotData *hotspot);

Modified: scummvm/trunk/engines/lure/luredefs.h
===================================================================
--- scummvm/trunk/engines/lure/luredefs.h	2007-02-26 02:47:27 UTC (rev 25874)
+++ scummvm/trunk/engines/lure/luredefs.h	2007-02-26 02:50:23 UTC (rev 25875)
@@ -31,7 +31,7 @@
 
 #define SUPPORT_FILENAME "lure.dat"
 #define LURE_DAT_MAJOR 1
-#define LURE_DAT_MINOR 14
+#define LURE_DAT_MINOR 15
 
 #define LURE_DEBUG 1
 
@@ -213,9 +213,8 @@
 #define ROOM_PATHS_RESOURCE_ID 0x3f13
 #define EXIT_COORDINATES_RESOURCE_ID 0x3f14
 #define EXIT_HOTSPOT_ID_LIST 0x3f15
+#define STRING_LIST_RESOURCE_ID 0x3f16
 
-#define STRING_LIST_RESOURCE_ID 0x3f17
-
 // Script constants
 #define STARTUP_SCRIPT 0x23FC
 

Modified: scummvm/trunk/engines/lure/res.cpp
===================================================================
--- scummvm/trunk/engines/lure/res.cpp	2007-02-26 02:47:27 UTC (rev 25874)
+++ scummvm/trunk/engines/lure/res.cpp	2007-02-26 02:50:23 UTC (rev 25875)
@@ -640,6 +640,7 @@
 	_hotspotData.saveToStream(stream);
 	_activeHotspots.saveToStream(stream);
 	_fieldList.saveToStream(stream);
+	_randomActions.saveToStream(stream);
 }
 
 void Resources::loadFromStream(Common::ReadStream *stream) {
@@ -649,6 +650,8 @@
 	_activeHotspots.loadFromStream(stream);
 	debugC(ERROR_DETAILED, kLureDebugScripts, "Loading fields");
 	_fieldList.loadFromStream(stream);
+	debugC(ERROR_DETAILED, kLureDebugScripts, "Loading random actions");
+	_randomActions.loadFromStream(stream);
 	debugC(ERROR_DETAILED, kLureDebugScripts, "Finished loading");
 }
 

Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp	2007-02-26 02:47:27 UTC (rev 25874)
+++ scummvm/trunk/engines/lure/res_struct.cpp	2007-02-26 02:50:23 UTC (rev 25875)
@@ -312,6 +312,7 @@
 	useHotspotId = 0;
 	v2b = 0;
 	actionHotspotId = 0;
+	talkOverride = 0;
 }
 
 void HotspotData::saveToStream(WriteStream *stream) {
@@ -351,6 +352,7 @@
 	stream->writeUint16LE(use2HotspotId);
 	stream->writeUint16LE(v2b);
 	stream->writeUint16LE(actionHotspotId);
+	stream->writeUint16LE(talkOverride);
 }
 
 void HotspotData::loadFromStream(ReadStream *stream) {
@@ -390,6 +392,7 @@
 	use2HotspotId = stream->readUint16LE();
 	v2b = stream->readUint16LE();
 	actionHotspotId = stream->readUint16LE();
+	talkOverride = stream->readUint16LE();
 }
 
 // Hotspot data list
@@ -806,17 +809,30 @@
 	return NULL;
 }
 
-void RandomActionList::saveToStream(Common::WriteStream *stream) {
+void RandomActionSet::saveToStream(Common::WriteStream *stream) {
+	stream->writeByte(numActions());
+	for (int actionIndex = 0; actionIndex < _numActions; ++actionIndex)
+		stream->writeByte((byte)_types[actionIndex]);
+}
 
+void RandomActionSet::loadFromStream(Common::ReadStream *stream) {
+	int amount = stream->readByte();
+	assert(amount == _numActions);
+	for (int actionIndex = 0; actionIndex < _numActions; ++actionIndex)
+		_types[actionIndex] = (RandomActionType)stream->readByte();
 }
 
-void RandomActionList::loadFromStream(Common::ReadStream *stream) {
 
+void RandomActionList::saveToStream(Common::WriteStream *stream) {
+	for (iterator i = begin(); i != end(); ++i) 
+		(*i)->saveToStream(stream);
 }
 
+void RandomActionList::loadFromStream(Common::ReadStream *stream) {
+	for (iterator i = begin(); i != end(); ++i) 
+		(*i)->loadFromStream(stream);
+}
 
-
-
 // This class handles an indexed hotspot entry - which is used by the NPC code to
 // determine whether exiting a room to another given room has an exit hotspot or not
 

Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h	2007-02-26 02:47:27 UTC (rev 25874)
+++ scummvm/trunk/engines/lure/res_struct.h	2007-02-26 02:50:23 UTC (rev 25875)
@@ -438,6 +438,7 @@
 	uint16 use2HotspotId;
 	uint16 v2b;
 	uint16 actionHotspotId;
+	uint16 talkOverride;
 
 	void enable() { flags |= 0x80; }
 	void disable() { flags &= 0x7F; }
@@ -649,18 +650,18 @@
 
 	uint16 roomNumber() { return _roomNumber; }
 	int numActions() { return _numActions; }
-	void getEntry(int index, RandomActionType &actionType, uint16 &id)
-	{
+	void getEntry(int index, RandomActionType &actionType, uint16 &id) {
 		assert((index >= 0) && (index < _numActions));
 		actionType = _types[index];
 		id = _ids[index];
 	}
-	void setDone(int index)
-	{
+	void setDone(int index) {
 		assert((index >= 0) && (index < _numActions));
 		assert(_types[index] == REPEAT_ONCE);
 		_types[index] = REPEAT_ONCE_DONE;
 	}
+	void saveToStream(Common::WriteStream *stream);
+	void loadFromStream(Common::ReadStream *stream);
 };
 
 class RandomActionList: public ManagedList<RandomActionSet *> {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list