Skills and weapons
Skills, weapons and items can all declare an action that Action Battle executes on the map: melee hits, projectiles, areas and thrown items.Skill and weapon actions
Skills and weapons can define anaction block for action-battle selection,
while their effect stays automatic by default.
BattleAi evaluates every learned skill and uses attackSkill as a priority
hint. A skill that is cooling down, too expensive, out of range, or unable to
cover the target does not block a normal attack. Player hotbar skills, enemy
skills, and configured equipped weapons use the same executor, so onUse
receives the same context in every case.
onUse, action-battle applies the standard RPGJS skill effect:
SP cost, hit rate, states, and damage formulas. For weapons, the default effect
is a physical hit using the equipped weapon stats and action-battle hit hooks.
action.target can be "enemy", "ally", "self", or "any"; enemy
resolution uses the attacker’s action-battle faction and targets selector.
Projectile direction uses the same generic projectile options as
map.projectiles.emit(), including spreadDegrees and accuracy.
player.useSkill() follows the action
On a map where action-battle is enabled, player.useSkill(id, target?) runs a
skill that has an action with the action-battle rules: SP cost, cooldown,
projectile, damage formula, factions, states and hit reactions. Without a
target, it aims at the nearest enemy within the reach of the action
(action.range, otherwise the skill targeting range), whatever the player
faces, and turns the player toward it; with none in reach, it is used straight
ahead. (A skill key pressed by the player keeps the soft targeting in front of
the player.)
A skill without action keeps the native RPGJS rule. This is what a hotbar
skill, your own server code and the scripts ($player.useSkill) call, so they
all hit the same way:
false) when the skill is not
learned, too expensive or cooling down. Another battle system can plug into
player.useSkill the same way with registerSkillUseHandler from
@rpgjs/server.
Play an effect of the game at cast
skills.playEffect plays the effect of a skill or a combat item when it is
cast (server only), for an action with a visual or a projectile. It receives
the attacker, the first target, the skill or item, its action and its
visual. Return false (or nothing) when it played nothing: the castFx and
impactFx particles stay. Return true or a result when it played something:
those particles are turned off, and the result can
- delay the hit of an instant or melee action without
onUsewithhitDelayMs, so the damage lands when the effect reaches the target; - give a projectile its path and its look with
projectile(merged intoaction.projectile:type,trajectory,pattern,params…); - replace the
areaof the action (a bomb that explodes where it ends).
visual.effect names the effect of the game (with visual.split,
castEffect plays on the caster and impactEffect on the target). The Studio
preset (createStudioActionBattlePreset) plays the Visual Effects and the
Projectiles of the Studio database this way.
Ranged weapons and projectile behaviors
A weapon whoseaction.mode is projectile turns the basic attack into a
shot: instead of swinging a hitbox, the attacker releases the projectile at the
end of the attack startupMs, so the release matches the draw of the bow.
Soft targeting then looks for a target up to action.range, and the shot aims
straight at it; besides enemies, it also picks scenery that declares
onProjectileHit, such as a switch. A ranged weapon keeps the timing of its own
attackProfile: the melee combo steps do not apply to it. This runs on the
server for players and enemies alike.
To play a bow animation, resolve the attack animation from the equipment,
with the same function on the server and on the client. LPCSpritesheetPreset
provides a shoot animation:
arrow type is declared on the client with
projectiles.looks.
action.projectile accepts the behaviors of the
projectile system: trajectory, landing,
linger, pierce, wall, collide and delay (a wind-up in ms, for skills
that are not tied to an attack profile). An arc lands on the target of the
action.
Action Battle projectiles collide with:
- the targets allowed by
action.target, which take the action effect; - walls, which stop them (or follow
projectile.wall); - events that declare
onProjectileHitwithout being combatants, such as a switch or a bush: they react through their own hook and take no damage.
onUse(user, target, ctx) only when the action needs custom logic:
ctx.defaultEffect():
Attack profile model
Useattack.profile to describe the timing model of a player attack in one
typed object. A profile separates the attack into startup, active, and recovery
phases so combat systems can share the same vocabulary.
350ms. The player attack runtime uses
startupMs before creating the hitbox, activeMs to keep the hitbox active,
and totalDurationMs for movement and direction locks.
Weapons can override the player attack profile from their database entry:
Thrown items in the hotbar
An item that declares anaction, like a skill, is thrown from the hotbar
through the combat flow instead of useItem(). It is removed from the inventory
when it is thrown, unless it is consumable: false.
- When the client sends a point with the hotbar action
(
engine.processAction("action-battle:use-hotbar", { slot, target })), the item is aimed at it and anarclands on it when it is in range. Otherwise it is thrown in the facing direction. action.projectileaccepts every projectile behavior:trajectory,collide,pierce,wallandlinger. See Projectiles.action.areausesmap.queryArea()and hits each target through the combat flow (stats, knockback, hit-stop, damage numbers). With a projectile, it is applied where the projectile ends instead of on contact. Setfalloff: falsefor full damage everywhere andhitsUser: truefor a bomb that also catches its thrower.- Events that react to projectiles with
onProjectileHit(a switch, a bush) are hit by these items too, without damage. - Items without
actionkeep the regular hotbar behavior.
ATK comes from the
equipment), so give the thrower a weapon or a damage formula that suits your
game.
Use skills for attacks
attackSkill makes one skill
the preferred opener without excluding the others. Melee skills require contact,
projectiles use their configured travel range, and instant area skills use
targeting.range plus aoeMask. While no action is ready, the enemy approaches,
retreats, or strafes toward the useful range of its next action.
Self-targeted healing and support skills are used automatically below 60% HP.
Ally-targeted skills are outside the current automatic planner.