-
Notifications
You must be signed in to change notification settings - Fork 2
Game Data: NPCs
The file ./game/data(.new)/npcs.json
contains all the NPCs which can be added to the game.
We will use the Drug Dealer NPC object from this point forward. The Drug Dealer NPC object has the following structure:
"drug-dealer" : {
"type" : "Drug Dealer",
"stats" : {
"health" : 750,
"money" : 55330,
"exp": -1250
},
"abilities" : {
"acc" : 70
},
"skills" : {}, // ignore skills (not implemented)
"inventory": [
{
"equipped_slot": "ranged",
"item_id": "ak47",
"modifiers": {}
},
{
"equipped_slot": "armor",
"item_id": "kevlarvest",
"modifiers": {}
},
{
"equipped_slot": "ammo",
"item_id": "ammohp",
"modifiers": {}
},
{
"item_id": "ammohp",
"modifiers": {}
}
],
"shop": "drug-dealer",
"logic": {
"timers": {
"move": [60, 180],
"attack": 2
},
"respawn": 1800,
"remainHostile": true
}
}
Each NPC object are required to have type, stats and abilities defined.
-
type
: The NPCs type is what we will show after the NPC name, to the client. The type is only used client-side. -
stats
: An object containing the following date:-
health
: The amount of health they have. -
money
: The amount of money a player will get when they kill them (can be negative). -
exp
: The amount of exp a player will get when they kill them (can be negative)
-
-
abilities
: An object with the keys being the ability id, and the value being the value of the ability. At time of writing, only accuracy exists, and it must be specified for the NPC to be able to do combat.
The inventory is an array with, containing item objects which the NPC will be carrying.
Note about durability: NPC's will not reduce the durability of items on use.
An item object consists of the following:
-
equipped_slot
: (optional) set the slot the item is equipped to. -
item_id
: The item ID -
modifiers
: Will overwrite the item's stats with whichever stats are defined in here. Eg. you can specify{"durability": 10}
to add 10 of a given item to the inventory, if the item is stackable.
NPCs can have shops the player can access like a structure's shop. Simply add "shop": "shopID"
to the object.
Shop ID's are defined in the ./game/data(.new)/shops.json
.
The logic object specifies how quick an NPC will respawn once killed, to often an NPC moves.
The logic object has the following definition:
-
timers
: Timers define how often an NPC will do certain actions.-
move
: How often an NPC will move. Defined as a specific number or an array with a min,max value in seconds (eg[10, 60]
will move the character every 10-60 seconds). -
attack
: How often an NPC will attck. Defined as a specific number or an array with a min,max value in seconds (eg[2, 5]
will attack once every 2-5 seconds).
-
-
respawn
: How long (in seconds) from the NPC dies til it respawns. -
remainHostile
: Whether an NPC will remain hostil with anyone who attacks it, even if combat is disengaged.