Skip to main content
gamedev.net
🔒 Locked

RPG NPC saving

Started by Muzlack 3 replies 600+ views
Original Post
Muzlack
Muzlack
Ok, on a map there are npcs. Now, some of these are unimportant that say stupid things like "My grandpa is the owner of the town." Then there are complex ones that progress the storyline such as a guard telling the main character that he cannot pass. Now lets say after accomplishing this task, he steps aside. no biggy. Now, lets say you step outside of the map you were on. Then you come back in. The guard is still there! Now, I know of two ways to fix this. Lets say you set a boolean to true after you talk to the guard. Now, when you enter the map again, there''ll be an optional script to run at map entrance. Also, I could make it that when you exit the map, it saves the new npc locations in a file that will eventually be tacked on to the end of a savegame file. Which way is better? I see good things and drawbacks at both sides
--Muzlack
--Muzlack
Luctus
Luctus
If your game is script-driven, you must have state variables, right? So say that when you get the guard to move, you set the flag GUARD_IS_OUT_OF_THE_WAY = true, then you just load the state variables for each map.

That''s the way I would do it, but that''s me..

-Luctus
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams
Kylotan
Kylotan
You should have a flag for important events like that one, and base the NPC''s state around the flags. Don''t just move the NPC and then try and work out the game state from that. It''s hard to explain this as it should become intuitive, but the NPC''s position should be thought of as a ''symptom'' of the event, not the event itself.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
pyroGX
pyroGX
I would have a seperate script assigned to the map when it loads that could do things like check states and assign new properties according to which flags are set. In this case say in your map, the guard is at position 30, 20; the entrance to the gate. When your map loads it runs the script that could have something similar to:

if GOT_PERMISSION_TO_ENTER_FLAG is true
Set NPC(guard) location to 31, 30
endif

This depends largely on how powerful your scripting is though, but I think having a script that a map can run on load is a good idea for things like that.
simon10k
simon10k
Guard1_Y--;
-----------------------------Language: C++API: Win32, DirectXCompiler: VC++ 2003

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.