Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public class WeaponAbility
Firing on Input#FIRE: projectiles (a blaster, a bow) or a melee swing, with a
cooldown, optional ammunition and eight-way aiming from the held directions.
A melee weapon (speed 0) is a short-lived projectile that does not move,
placed in front of the actor, so one mechanism covers both.
Fields
public String projectileType | The projectile’s art type. |
public int speed | Projectile speed, fixed point per tick; 0 makes a melee weapon. |
public int size | Projectile size, fixed point. |
public int gravity | Gravity on the projectile, 0 for straight shots. |
public int damage | Damage per hit. |
public int cooldownTicks | Ticks between shots. |
public int lifeTicks | Ticks a projectile lives (its range). |
public int ammo | Rounds left; negative is unlimited. |
public boolean eightWay | Whether up/down aim the shot diagonally or vertically. |
public boolean automatic | Whether the trigger can be held for automatic fire. |
public boolean hitscan | Whether the shot is instant (a laser, a rifle): it travels range in the tick it is fired, stops at the first solid tile and hits the first actor of another team on the way. |
public int range | How far a hitscan shot reaches, fixed point. |
Constructors
public WeaponAbility() |
Methods
public void process(Actor c, PlatformWorld world) | Sets velocity and claims a MovementState. |
public long hashState(long h) | Mixes the ability’s own state into a hash, so two runs that diverge inside an ability are caught. |
public void reset() | Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death. |
Inherited methods
From Ability
Field details
projectileType
public String projectileTypeThe projectile’s art type.
speed
public int speedProjectile speed, fixed point per tick; 0 makes a melee weapon.
size
public int sizeProjectile size, fixed point.
gravity
public int gravityGravity on the projectile, 0 for straight shots.
damage
public int damageDamage per hit.
cooldownTicks
public int cooldownTicksTicks between shots.
lifeTicks
public int lifeTicksTicks a projectile lives (its range).
ammo
public int ammoRounds left; negative is unlimited.
eightWay
public boolean eightWayWhether up/down aim the shot diagonally or vertically.
automatic
public boolean automaticWhether the trigger can be held for automatic fire.
hitscan
public boolean hitscanWhether the shot is instant (a laser, a rifle): it travels
range in
the tick it is fired, stops at the first solid tile and hits the first
actor of another team on the way. No projectile is made.range
public int rangeHow far a hitscan shot reaches, fixed point.
Constructor details
WeaponAbility
public WeaponAbility()Method details
process
public void process(Actor c, PlatformWorld world)Sets velocity and claims a
MovementState.Parameters
cActor- the actor
worldPlatformWorld- the world
hashState
public long hashState(long h)Mixes the ability’s own state into a hash, so two runs that diverge inside
an ability are caught. The default mixes nothing.
Parameters
hlong- the running hash
Returns
the updated hash
reset
public void reset()Forgets what the ability was in the middle of, when its actor
respawns: a dash, a buffered jump or a grip does not outlive a death.
The default does nothing; an ability with per-run state overrides it.