Jazz2::Actors::Weapons::ShotBase class

Base class of a shot from a player's weapon.

Common base for the weapon projectiles fired by the player, providing shared damage, ownership, lifetime, movement and ricochet handling.

Base classes

class Jazz2::Actors::ActorBase
Base class of an object.

Derived classes

class BlasterShot
Blaster (shot).
class BouncerShot
Bouncer (shot).
class CustomShot
Shot of a custom weapon of the level.
class ElectroShot
Electro (shot).
class FreezerShot
Freezer (shot).
class PepperShot
Pepper (shot).
class RFShot
RF (shot).
class SeekerShot
Seeker (shot).
class ShieldFireShot
Fire shield (shot).
class ShieldLightningShot
Lightning shield (shot).
class ShieldWaterShot
Water shield (shot).
class Thunderbolt
Thunderbolt (shot).
class ToasterShot
Toaster (shot).

Public static variables

static float TickSpeedScale constexpr
Converts a speed in px per tick of the original to px per frame.
static float TickAccelScale constexpr
Converts an acceleration in px per tick squared of the original to px per frame squared.
static float TicksToFrames constexpr
Converts a duration in ticks of the original to frames.

Constructors, destructors, conversion operators

ShotBase()
Creates a new instance.

Public functions

auto OnHandleCollision(ActorBase* other) -> bool override
Called when the object collides with another object.
auto GetStrength() -> std::int32_t
Returns strength (damage).
void SetStrength(std::int32_t value)
Sets strength (damage).
auto GetOwner() -> Player*
Returns owner of the shot.
auto GetWeaponType() -> WeaponType virtual
Returns weapon type.
auto GetSourceWeapon() -> WeaponType virtual
Returns the weapon of the level that fired the shot, the same as GetWeaponType() unless the level made its own.
auto IsUpgraded() const -> bool
Returns true if the shot is of the powered-up weapon.
void TriggerRicochet(ActorBase* other)
Triggers shot ricochet.
auto GetFrozenDuration() const -> float
Returns how long the shot freezes what it hits, 0 if it doesn't.
void SetFrozenDuration(float value)
Sets how long the shot freezes what it hits, 0 if it doesn't.
auto ThawsFrozen() const -> bool virtual
Returns true if the shot thaws what's frozen.

Protected functions

auto OnActivatedAsync(const ActorActivationDetails& details) -> Task<bool> override
Called when the object is created and activated.
void OnUpdate(float timeMult) override
Called every frame to update the object state.
void OnRicochet() virtual
Called on shot ricochet.
void OnRicochetExact()
Ricochet as the weapons of the game do it, mirrors the horizontal speed and randomizes the vertical one.
auto AdvanceCarriedSpeed(float timeMult) -> float
Returns the distance the carried speed moves the shot by in a step and fades the speed, for shots that don't use TryMovement().
void ShortenUpShotLifetime(float sinAngle)
Makes the shot live a third shorter if it flies straight up, as the original does.
void RevealPastMuzzle(Vector2f gunspotPos)
Shows a shot that starts hidden inside the player once it is past the muzzle.
void SetCarriedSpeed(float playerSpeedX, bool decays)
Sets the speed of the player the shot carries along, clamped, optionally fading out.
void SetAcceleration(Vector2f direction, float acceleration, float speedCap)
Makes the shot speed up along a direction, speedCap limits its own speed if positive.
void TryMovement(float timeMult, Tiles::TileCollisionParams& params)
auto GetMovementSubstepCount(float timeMult) const -> std::int32_t
Returns how many sub-steps a shot's movement should be split into.

Protected static variables

static float MaxCarriedSpeed constexpr
Most speed of the player a shot carries, in px per tick.
static float CarriedSpeedDecay constexpr
Rate the carried speed of the player fades at, in px per tick squared.
static std::int32_t MaxTileRicochets constexpr
Most shot ricochets off the tiles.
static float RicochetRandomSpeedY constexpr
Range of the random vertical speed a ricochet adds, in px per tick.

Function documentation

std::int32_t Jazz2::Actors::Weapons::ShotBase::GetMovementSubstepCount(float timeMult) const protected

Returns how many sub-steps a shot's movement should be split into.

TryMovement() only tests the destination of a move, so no single step may be long enough to pass through thin geometry. The count therefore comes from the distance the shot actually covers this frame, bounded against MaxMovementStep exactly as ActorBase::TryStandardMovement() bounds it, which makes it independent of both the frame rate and the shot's speed.