Visit Blog

Explore Tumblr blogs with no restrictions, modern design and the best experience.

Fun Fact

There's almost an equal split between the sexes on Tumblr - 51% male, 49% female.

Trending Blogs
#programming

Today I worked on one of the encounters you can have in the various dungeons while exploring. Sometimes you’ll encounter random neutral robots that you can talk to - here in the video I demonstrate talking to a cheeky robot who will take 2 of an item and give you 1 back (yes, that is an SMT reference).

Depending on the dungeon characteristics, you may be more or less likely to find these types of encounters, and the dungeons also determine how friendly/unfriendly these will be. Some will give you nice items, scrap, or even join your party, while other ones will either trick you or fight you if you aren’t careful!

Initially I was thinking that the game would deterministically generate the robot/quest/reward using a seed based on where the object’s x,y position and other information. However, this algorithm would be unstable and prone to change if, after launch, the list of enemies or items was updated, and plus I would have had less control over the process overall. I was thinking to do it this way because I’d avoid having to save another data structure.

However, after talking it over with a friend, I instead decided to bite the bullet and just make a new data structure. While it was more work up-front, this proved to be the correct choice as I was not only able to save the selected enemy, what it wants, and what it’ll give, but I can ALSO mark if the quest has been completed. As you can see, talking to the enemy again just gives a thank you message. This log will be available to players to view as a result of saving the information, which is a double bonus! 

Once that was done, I then needed to edit the feature displaying object. I wrote code to say “if a quest entry exists at this location, display the enemy, and if it doesn’t, create one”. I put in some placeholder values for now, but I am saving those values into the data structure and pulling them out later.

Finally, I had to edit my generic object interaction script to get these values, and determine what dialog/response to generate. Seeing so many parts of my code interact cleanly with each other, with very few hardcoded values was really satisfying!!

21 notes · See All
Next Page