Battle System

For now we only have the most basic battle types which are:

  • Player(s) vs player(s): this works in a "free way", you can hit anyone and anyone can hit you.
  • Player(s) vs environment: where the first player to hit an enemy will be the one that will enter in battle-mode, be chased, and awarded by that enemy. Note: other players could hit the same target and the damage will be applied normally, but the first player will be the only one considered as target until the battle finished, and he will get ALL the prizes.

The current battle system works in real-time (no turns or waits). If you hit an enemy it will chase you and hit you back automatically.

The battle area is by default the respawn area for that enemy on the current map (this doesn't apply for PvP, for which case the battle area is the entire map).

Configuring battles in the admin panel

A battle is a sequence of skills: every attack, from a player or from an enemy, is a skill execution, and the damage comes from the stats of the attacker and the target. In the admin panel you define the skills, the stats they use and who can use each skill.

1. Check the skill types

  1. Log in to the admin panel at /reldens-admin with an admin user (the path can be changed with the RELDENS_ADMIN_ROUTE_PATH environment variable).
  2. Open Skills > Skill Types in the sidebar (/reldens-admin/skills-skill-type).
  3. The list shows the five types handled by the engine: base, attack, effect, physical_attack and physical_effect. They are installed with the basic configuration and you only pick one of them when you create a skill, do not edit or remove them.
Admin Panel - Skill Types list

2. Create the skills

  1. Open Skills > Skills (/reldens-admin/skills-skill) and click Create New.
  2. Set the Key and the Label, and pick the Type: attack for a direct hit, physical_attack for a projectile (the battle starts when the projectile hits the target), effect or physical_effect for buffs, debuffs and heals.
  3. Set the Range in pixels, the SkillDelay (cooldown in milliseconds), the CastTime and the critical values, then click Save.
  4. For attack skills open Skills > Attack Properties, click Create New, select the skill and set the damage: the affected property (stats/hp), the HitDamage, the stats compared to scale the damage (attack against defense) and the stats compared to decide a miss (aim against dodge).
  5. For physical skills add a row in Skills > Physics Data with the projectile speed (Magnitude) and size.
  6. For effect skills add the stat changes in Skills > Target Effects Properties (or in Skills > Owner Effects for the effects applied to the caster).
Admin Panel - Skills list Admin Panel - Create new skill form

3. Define the stats

  1. Open Users > Stats (/reldens-admin/stats). The list holds every stat used by the players and the enemies (hp, mp, atk, def, dodge, aim, speed, etc.).
  2. Click Create New to add a stat: the Key (used in the skills as stats/ plus the key), the Label, the Description and the Base Value (the value every new player starts with).
  3. Use the stat keys in the skill Attack Properties, for example stats/atk,stats/speed as attack properties and stats/def,stats/speed as defense properties.
Admin Panel - Stats list Admin Panel - Create new stat form

4. Give the skills to players and enemies

  • Players: open Classes & Levels > Levels Skills and create a row with the class path, the level and the skill. The players of that class path get the skill when they reach the level.
  • Enemies: open Game Objects > Objects - Skills and create a row with the enemy object, the skill and the target. The enemy stats are set in Game Objects > Objects - Stats, an enemy without stats rows uses the enemies/initialStats/* config rows.
  • Targets: Game Objects > Objects - Target Options lists the targets available in the Objects - Skills form. The installation ships object and player, and the sample enemies use player.
Admin Panel - Target Options list

Restart the server after the changes: the skills, the stats and the objects are loaded when the server starts.

Configuration reference

Skill fields

  • Key and Label - unique identifier and display name.
  • Type - one of the skill types listed above.
  • SkillDelay - cooldown in milliseconds before the skill can be used again.
  • CastTime - milliseconds between the activation and the execution of the skill.
  • UsesLimit - maximum number of uses, 0 for unlimited.
  • Range - maximum distance in pixels between the owner and the target. RangeAutomaticValidation checks it automatically, and the RangeProperty fields name the position properties (state/x and state/y in the sample skills).
  • AllowSelfTarget - the owner can target itself (used by the sample heal skill).
  • CriticalChance, CriticalMultiplier and CriticalFixedValue - chance in percent of a critical hit, the critical damage multiplier and a fixed critical bonus.

Attack Properties fields

  • AffectedProperty - target property that receives the damage, stats/hp in the sample skills.
  • HitDamage - base damage of the skill.
  • ApplyDirectDamage - apply the HitDamage as it is, without the attack and defense calculation.
  • AttackProperties and DefenseProperties - comma separated owner and target properties compared to scale the damage.
  • AimProperties and DodgeProperties - owner and target properties compared to decide if the attack misses.
  • DodgeFullEnabled and DodgeOverAimSuccess - with the flag on, the attack is fully dodged when the target dodge is higher than the owner aim multiplied by DodgeOverAimSuccess.
  • DamageAffected and CriticalAffected - reduce the damage and the critical damage when the target dodge is higher than the owner aim.
  • AllowEffectBelowZero - let the affected property go below zero.

Physics Data fields

  • Magnitude - projectile speed.
  • ObjectWidth and ObjectHeight - projectile body size.
  • ValidateTargetOnHit - when disabled (the sample skills use 0), any target hit by the projectile starts the battle, not only the selected one.

Battle config rows

Open Settings > Config (/reldens-admin/config) and type the path in the search box:

  • actions/pvp/battleTimeOff (server, 20000) - milliseconds without attacks before a player versus player battle with that target ends.
  • actions/pvp/timerType (server, bt) - bt keeps one battle timer per target, bg uses a single timer for all the targets.
  • actions/pvp/enabled (server, boolean, not installed) - add it with the value 0 to disable the player versus player battles in every room. A single room can disable them with "pvpEnabled": false in its CustomData (Rooms > Rooms).
  • enemies/default/skillKey (server, attackShort) and enemies/default/affectedProperty (server, stats/hp) - skill every enemy can use besides its Objects - Skills rows, and the property it damages.
  • enemies/initialStats/* (server) - stats of the enemies that have no Objects - Stats rows.
  • actions/damage/* (client) - how the damage numbers are shown (color, font, size, duration, showAll).

Each enemy can also set its own battle timer with battleTimeOff (milliseconds, 20000 when missing) in the object Private Params JSON: when that time passes without attacks the enemy stops chasing the player.

Code integration (advanced)

The notes below describe the engine behavior behind the battles and where the battle code lives.

Both (current) battle types extend from the same Battle class that can be found in packages/actions/server. This class contains the method runBattle, which is the one that handles the current action execution (in Reldens every skill is an action).

The first important thing to note is: the battle starts when the target is actually affected by the action. So for example, if you create a skill that uses a physics body (like throwing a rock or a fireball), the battle won't start until the bullet-body hits the target. This doesn't count for normal attacks or effects that will be executed without using a physics body and always automatically affect the target (after cast time ends).

The battle can be configured with a timer, so enemies will stop chasing you if you are in their area for more than the specified time without attacking them.

This is a basic implementation that will be improved in future releases, and in the future we will even include turn-based battles.

Related Documentation

Go Up