Bouncy element 
Makes a thrown movable rebound after it hits something, losing distance on every rebound.
- Striking a wall, structure or mob reflects the object off the obstacle's side.
- Landing on a hard floor can hop it onward in the same direction. Lava and soft or non-solid turfs
(those without a
bullet_bounce_sound, such as grass, carpet, water and space) absorb it, as does landing on a surface things are thrown onto, such as a table, rack or hydroponics tray. - Nothing bounces where it is about to fall, through open space or into a chasm.
- Objects can also hop away in a random direction when ejected: ammo casings from a ballistic gun, or anything thrown at its own tile with no thrower, such as a slimeperson's core when its body melts.
Rebounds of a tile or more are real throws with a hop arc. A rebound under a tile cannot leave its turf, so it becomes a decelerating slide within the turf, which ends the chain.
The throw a player makes behaves exactly as before, including damage and catching. Only the rebounds are new, and a rebound never strikes the obstacles it runs into: it does no damage, pushes nothing, cannot be caught and sets off no hitby() reactions. Bump reactions, such as a door opening or a portal teleporting it, still happen. Rebounds are skipped without gravity, where thrown objects already drift.
Vars | |
| bounce_sound | Sound played at each rebound, on top of the object's own landing sounds. Null for none. |
|---|---|
| bounce_sound_volume | Volume of /datum/element/bouncy/var/bounce_sound. |
| bounces_this_tick | Bounces started in the current tick, across every bouncy profile. See BOUNCE_MAX_PER_TICK. |
| budget_tick | world.time of the tick /datum/element/bouncy/var/bounces_this_tick counts. Shared by every bouncy profile. |
| deflect_chance | Percent chance for each rebound to veer 45 degrees off its ideal direction. |
| eject_hop_range | Tiles the object travels in a random direction when ejected from a ballistic gun as a casing. Zero disables ejection hops. |
| max_bounces | Most rebounds one throw or ejection can chain into. |
| restitution | Fraction (0 to 1) of the incoming travel distance each rebound keeps. Lower values settle sooner. |
Procs | |
| hop | Plays a rise-and-fall arc on the object's vertical draw offset, without moving it. |
| on_ejected | Sends an ejected ammo casing hopping away from the gun. |
| on_impact | Queues the first rebound after an ordinary throw, unless the thing hit caught or blocked the object. |
| queue_rebound | Works out where the rebound from one impact goes and schedules it. |
| rebound | Performs one rebound, if the object is still loose where it landed. |
| reflect_direction | Reflects a travel direction off an obstacle. |
| schedule_rebound | Schedules a bounce, if it is at least BOUNCE_MINIMUM_DISTANCE and the shared per-tick budget has room for it. The bounce is capped at BOUNCE_MAX_DISTANCE. |
| slide_within_turf | Slides the object part of a tile in a direction, decelerating to rest without leaving its turf. |
Var Details
bounce_sound 
Sound played at each rebound, on top of the object's own landing sounds. Null for none.
bounce_sound_volume 
Volume of /datum/element/bouncy/var/bounce_sound.
bounces_this_tick 
Bounces started in the current tick, across every bouncy profile. See BOUNCE_MAX_PER_TICK.
budget_tick 
world.time of the tick /datum/element/bouncy/var/bounces_this_tick counts. Shared by every bouncy profile.
deflect_chance 
Percent chance for each rebound to veer 45 degrees off its ideal direction.
eject_hop_range 
Tiles the object travels in a random direction when ejected from a ballistic gun as a casing. Zero disables ejection hops.
max_bounces 
Most rebounds one throw or ejection can chain into.
restitution 
Fraction (0 to 1) of the incoming travel distance each rebound keeps. Lower values settle sooner.
Proc Details
hop
Plays a rise-and-fall arc on the object's vertical draw offset, without moving it.
Uses relative pixel_z steps in parallel, so it composes with spin animations, movement gliding and the pixel_x/pixel_y offsets items rest at.
Arguments:
- source - The bouncing movable.
- height - Peak of the arc, in pixels. Below 1 plays nothing.
- duration - Deciseconds for the whole arc.
on_ejected
Sends an ejected ammo casing hopping away from the gun.
COMSIG_CASING_EJECTED is sent before the wielder tries to catch the casing, so a caught casing is in a hand by the time /datum/element/bouncy/proc/rebound checks it, and stays there. The hop lands silently, since everything that sends the signal also plays the casing's clatter itself, through bounce_away().
on_impact
Queues the first rebound after an ordinary throw, unless the thing hit caught or blocked the object.
A throw with no thrower aimed at the object's own tile, such as a slimeperson's core tossed loose by its melting body, lands at once. The object then pops away in a random direction as far as the throw's range. Small explosions can toss things the same way, too weakly to do more than nudge them.
queue_rebound
Works out where the rebound from one impact goes and schedules it.
Arguments:
- source - The bouncing movable.
- hit_atom - What the throw struck. Its own turf when it landed on the floor.
- throwingdatum - The throw that just ended.
- bounces_left - Rebounds still allowed, including the one being queued.
rebound
Performs one rebound, if the object is still loose where it landed.
A rebound of at least one tile is thrown. A shorter one slides within the turf instead and ends the chain.
Arguments:
- source_ref - Weak reference to the bouncing movable.
- direction - Direction of the rebound.
- distance - Tiles the rebound travels. May be fractional.
- speed - Throw speed, in tiles per decisecond.
- bounces_left - Rebounds this rebound may chain into after it lands.
- silent_landing - Whether the rebound lands without an impact, so the object's landing sounds do not play. Not on lava, whose impact is what burns things.
reflect_direction
Reflects a travel direction off an obstacle.
Flips each axis of travel that points toward the obstacle, like a ball glancing off a wall. An obstacle that no travel axis points toward, such as one sharing the object's turf, sends it straight back.
Arguments:
- travel_dir - Direction the object was travelling.
- obstacle_dir - Direction from the object to the obstacle, or 0 when they share a turf.
schedule_rebound
Schedules a bounce, if it is at least BOUNCE_MINIMUM_DISTANCE and the shared per-tick budget has room for it. The bounce is capped at BOUNCE_MAX_DISTANCE.
Arguments:
- source - The bouncing movable.
- direction - Direction of the bounce.
- distance - Tiles the bounce travels. May be fractional.
- speed - Throw speed, in tiles per decisecond.
- bounces_left - Rebounds this bounce may chain into after it lands.
- silent_landing - Whether the bounce lands without an impact, so the object's landing sounds do not play. Not on lava, whose impact is what burns things.
Returns whether the bounce was scheduled.
slide_within_turf
Slides the object part of a tile in a direction, decelerating to rest without leaving its turf.
Arguments:
- source - The bouncing movable.
- direction - Direction of the slide.
- distance - Fraction of a tile, below 1, that the slide would cover unobstructed.