• Add Review
  • Subscribe
  • Nominate
  • Submit Media
  • RSS

Advanced Scripting: Building a Furniture System

From the start, an Animal Crossing style furniture system was a core goal. As players explore, clear minigames, and dungeon crawl, they'll earn furniture to decorate the hero's house. The player can customize what furniture is placed and where it goes.


One way the player's house can be arranged.

Creating

Each piece of furniture is an item in the database. There's a special <furniture> tag read by a script. The tag defines what tile the furniture is drawn with, it's width and height, whether it can only be placed on walls, and a type (remember this for later).



Placing

Placing furniture is mostly event driven. Player's use an item, called Floor Plan, to begin placing furniture. This item triggers a common event that flips a switch when in the hero's house. From there, an autorun event turns the player into a cursor to let them pick a spot, followed by a Select Key Item event call to choose the piece of furniture.

Actually placing and drawing the furniture is when the script call shows up. There's a 2D grid stored in the save file that matches the size of the house. Each grid space represents a tile and holds what furniture is stored in that tile. Before placing the furniture, we check the grid to confirm the space is empty. Then we update our grid with the new furniture data.

There's an extra feature where chairs can't be placed on walls. To determine if a grid space is a wall or not, a special region id is added to each wall tile in the map editor.

Rewarding

I wanted to reward players for spending an hour fiddling around with their perfect house setup. The furniture system only made sense if it can tie back into the core gameplay.

My original idea was to give combat buffs based on what furniture is in the house. Adding a fireplace gives the party +15% fire resistance.

My testers told me this was a terrible idea (and it kinda was). They wanted to be rewarded for furniture placement that made sense. Chairs next to a desk. A nightstand besides a bed. A zombie at the dinner table.

Enter the Joyful Home Association. Each night, a strange man will enter your house to rate the furniture. Based on the points you earn, you will be awarded with gold, consumables, crafting items, and other things useful in combat.



Rewards are defined in a script. When assessing the player's house, the condition of each reward is checked to determine if the player earns points.

# A reward definition copy + pasted from the game
{:title => "Dinner Guest",
 :description => "Pet at the dinner table",
 :reward => "+2 Points",
 :points => 2,
 :condition => all(is_a("pet"), is_next_to("table"))
}


Here we reference the type field defined when creating the furniture. For this reward, we check the condition against all pieces of furniture. If it has type "pet" and is next to furniture of type "table", then the reward is earned.

Posts

Pages: 1
OzzyTheOne
Future Ruler of Gam Mak
4696
Wow! This sounds like some very nifty stuff! You sure made an amazing system here, can't imagine how much work it must've taken!
Pages: 1