Dargo Dynamic Needs [Living Cities Jam]

Do you want to connect your neighbourhood to an energy grid, and have the houses go dark or light up at runtime, depending on how much electricity they have access to? Do you want your citizens to gradually become more and more outraged by the news from rogue stations and rebel broadcasts, to later break out into a protest? Or, simply, just to make sure that an entity or an NPC will warm up if placed near a fire? All those things present a Need that must be satisfied by a Resource, and this package lets you do just that. Electricity for the buildings, information for the citizens, and heat for whatever’s next to the fire.


There’s three: the Campfire Example (basic needs system), the NPC Example (emote system), and the Generator Example (stockpile system. You can see them in action in the showcase here, or drag them out into your game and play around with them.

Overview & Quickstart

DDN, excluding the templates, contains four scripts: npcNeeds, entityNeeds, needsSource, needsStockpile. All you need to get started is needsSource and one of the two Needs scripts, depending on whether you want to take advantage of the NPC functionalities or not.

Quickstart guide
  1. Place needsSourceTmp inside your game.

  2. Set the name of the resource it is providing in the resource_name tab: “Heat”, for example, if it’s a fire.

  3. Place entityNeedsTmp inside your game, within the range of the source you previously placed. Make sure it can be damaged.

  4. Set the name of the resource this entity wants to be the same your source provides. Be careful - it has to be exactly the same.

  5. Adjust other settings - such as starting values, additional functionalities, or tick speed - in both scripts to your preference. Everything has a tooltip - if you don’t know what something does, just hover it.

  6. That’s it! You’re done.

That’s just for the basic needs system. There’s three additional ones which depend on it: the Events System, the Stockpile System, and the Emote System (for NPCs only).

Basic Needs System

A needsSource script regularly sends a radial damage check. If an entity with an entityNeeds or npcNeeds script is within range, and it can be damaged, it will receive the damage and check if entityNeeds’ resource variable is the same as its own - in other words, if it is producing the kind of resource it wants. If that’s the case, it will increase a needsValue number within the script.

Events System

Every time an entity or npcNeeds script’s need value changes, the event system will run a series of checks and execute any events of your choice according to the results of those checks. You can make it so that if the need value’s is equal to the max value, something happens. Or if it reaches a specific threshold, say, 50% of the maximum, something else happens. To activate it, you will need to enable the events system boolean in the editor.

Stockpile System

The stockpile system does not currently work with npcNeeds, only entityNeeds.

This requires the needsStockpile script to be somewhere in the game. You will also need to enable the Stockpile System boolean and select the entity which holds the needsStockpile script in the Stockpile Entity property in both your entityNeeds and needsSource scripts. It has to be the same to allow interaction between any number of needsSource and needsEntity/NPC scripts.
Additionally, you will need to add a field to both Stockpile Names and Stockpile Values, and name the first field after the resource the Need produces and the Source wants.

Regardless of whether it’s in range or not, a needsStockpile will receive a set amount of resources from needsSource. Then, a needsEntity will be able to withdraw a specific amount. All of this regulated through editor properties, letting you set up regular withdrawhals and additions. It functions, in a sense, like an automated bank.

Emote system

The emote system is only available for npcNeeds, and requires the script to be attached to an NPC. It functions exactly like the Events system, but it will play emotes instead of events.


This is such a fantastic idea. I hope it will get used in SimCity type games in the future!

1 Like