Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for composite behaviors #19

Open
shawncplus opened this issue Sep 2, 2017 · 2 comments
Open

Allow for composite behaviors #19

shawncplus opened this issue Sep 2, 2017 · 2 comments
Labels
Milestone

Comments

@shawncplus
Copy link
Member

There are currently 2 tiers of scripting for entities: a script, one-off and specific for a single entity; and behaviors shareable/configurable chunk of code.

The use case for composite behaviors is the following:

I have 3 types of town guard: gate guard, tower archers, and cityguards. I want all guards to wander, I want them all to attack any npc from a different area that is currently attacking an npc in this area or a player. The wander configurations differ between the archers and the cityguards but regardless they both wander, but the "aggro" behavior config is the same between them and quite complex.

Currently to accomplish this I would have to copy and paste the behavior configuration for each guard. Hence the need for "composite behaviors".

Currently behaviors live in behaviors/<entity type>/<name.js> a new file would need to be created in `behaviors//composites.yml"

  • Composite behaviors should be able to be recursive: so a composite behavior can be a collection of composite behaviors as long as there is no circular dependency.
  • Composite behaviors should not share a name with an existing behavior of the same entity type. NOTE: There is likely currently a bug where if two bundles define a behavior with the same name weird shit will happen.
  • Composite behaviors should be able to be used exactly like standard behaviors such that when using a composite behavior one should be able to override the configurations.

Example composites.yml file:

# name of composite behavior
ranvier-guard:
  # list of behavior configurations (essentially exactly what you would otherwise put in the `behaviors` setting for a single entity
  ranvier-wander:
    areaRestricted: true
  ranvier-aggro:
    players: false
    # attack any NPC that is not from this area that wanders into it (unless it is a follower of a player)
    areaDefender: true
    # attack anything attacking an npc with the entityRef in this list, i.e., they are teammates with these npcs
    teammates: [ "somearea:cityguard", "somearea:archer-guard", "somearea:gateguard" ]

When using this composite behavior it would be like any other behavior, example in npcs.yml

- id: cityguard
  name: Cityguard
  behaviors:
    # cityguard doesn't need any extra configuration on top of ranvier-guard
    ranvier-guard: true
- id: archer-guard
  name: Tower Archer
  behaviors:
    # the tower archer wanders only along the tower wall
    ranvier-guard:
      ranvier-wander:
        restrictTo: [ "somearea:towerwall-1", "somearea:towerwall-2", "somearea:towerwall-3" ]
- id: gateguard
  name: City Gate Guard
  behaviors:
    # the gate guard doesn't wander from their room
    ranvier-guard:
      ranvier-wander:
        disabled: true
@samjaninf
Copy link

Hmmm, If I recall correctly I suggested something similar to this behavior with mob type inheritance. SO You could have a basic guard mob with the aggro, wander and the guard behaviors. Then you just clone the basic guard three times as the archer, city and gate guard, it comes with the basic stats and behaviors already assigned to basic guard as that would be it's prototype/parent. Then just change the wander areaRestricted on the archer.

@shawncplus
Copy link
Member Author

@samjaninf this could technically be done right now with no changes necessary by using YAML anchors but I'd rather have it codified than depend on a YAML feature

@shawncplus shawncplus transferred this issue from RanvierMUD/ranviermud Jan 8, 2019
@shawncplus shawncplus added this to the 3.2 milestone Aug 22, 2019
seanohue added a commit to seanohue/core that referenced this issue Nov 2, 2021
…mg-metadata

Avoid using object in damage/heal metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants