Behaviors are scripts that you can reuse for the same entity types across multiple areas/bundles. For example, maybe you
want to have many different NPCs wander around at random, or immediately attack players upon entering the room; you can
use behaviors to re-use the same script.

Behaviors are defined similarly to normal scripts, and also rely on events, but are created inside the behaviors/ directory inside your
bundle, which is outside of your areas/ directory. Another key difference is that they are configurable in the entity's .yaml definition (see each entity type's documentation for some examples, and below for details on configuration).

Again, see the relevant entity type's scripting guide section below for more on how to add behaviors to that entity.

Tip: Behaviors can be used as flags. For example, if you say behaviors: ['combat'] on an NPC, you don't need to
actually create a combat.js behavior file, npc.hasBehavior('combat') will still return true. This is used, as an
example, in the kill command in ranvier-combat to differentiate pacifist NPCs from NPCs that can enter combat.

'use strict';module.exports=srcPath=>{return{/* The familiar bundle script file format we've seen in commands and quests returns here. To listen for an event, simply add a new key (which is the event name) to 'listeners'. The value for each listener is a closure accepting GameState (seen here as state, see the Ranvier server executable for more) and returning a function whose arguments are dependent on the event. See the Default Events section below for to see some examples of arguments being passed to the listeners. */listeners:{someEvent:state=>(/* event args */)=>{// do stuff here}}};};

NOTE: Behaviors are written differently because the first argument to their listener is
alwaysconfig, an object that will be equal to the behavior config as defined in that
entity's yml file. As an example, the following is what an item with a 'test' behavior
that listens for the 'foo' event would look like:

In items.yml:

-id:9name:'MyItem'behaviors:test:hello:"World"

When event is fired:

// the config is automatically prepended to the arguments, you DO NOT have to manually// send it in when emitting eventsmyItem.emit('foo',player,'baz');

In your behavior listeners:

listeners:{foo:state=>(config,player,thing)=>{console.log(config);/* This will output as per the 'test' behaviors config in items.yml { hello: "World" } */console.log(player,thing);/* Player, 'baz' */}}

Combat has ended, emitted when an NPC's list of combatants becomes empty

combatStart(Character target)

Combat has started against target, emitted when NPC was not in combat and now is. Event is not fired if the NPC
was already in combat when new combatants are added

damaged(Damage damage)

Something has decreased one of the NPC's attributes. This emits when any attribute is damaged, not just health. See src/Damage.js
for details of information available from damage argument.

healed(Heal heal)

Same as damaged but increased attribute instead of decreased.

hit(Damage damage, Character target)

This NPC caused damage to the target. Target may be itself.

heal(Heal heal, Character target)

Same as hit but increased attribute instead of decreased.

spawn

NPC is initially created; this event emits immediately after NPC is placed in its target room.

updateTick

This event is special in that it automatically fires every tenth of a second on Rooms, Items, NPCs, and Players.
This event should be used for any event that is based on time, e.g., NPC should wander around every N seconds.