MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / OnHitSpring

Method OnHitSpring

Sources/Jazz2/Actors/Player.cpp:1854–1938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1852 }
1853
1854 void Player::OnHitSpring(Vector2f pos, Vector2f force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove)
1855 {
1856 std::int32_t sign = ((force.X + force.Y) > std::numeric_limits<float>::epsilon() ? 1 : -1);
1857 if (std::abs(force.X) > 0.0f) {
1858 MoveInstantly(Vector2f(_pos.X, (_pos.Y + pos.Y) * 0.5f), MoveType::Absolute);
1859
1860 _copterFramesLeft = 0.0f;
1861 //speedX = force.X;
1862 _speed.X = (1.0f + std::abs(force.X)) * sign;
1863 _externalForce.X = force.X * 0.6f;
1864 _springCooldown = 10.0f;
1865 SetState(ActorState::CanJump, false);
1866
1867 _wasActivelyPushing = false;
1868 _keepRunningTime = 100.0f;
1869
1870 if (!keepSpeedY) {
1871 _speed.Y = 0.0f;
1872 _externalForce.Y = 0.0f;
1873 }
1874
1875 if (_currentSpecialMove != SpecialMoveType::Sidekick) {
1876 if (_inIdleTransition) {
1877 _inIdleTransition = false;
1878 CancelTransition();
1879 }
1880
1881 removeSpecialMove = true;
1882 _controllableTimeout = 2.0f;
1883 if (_activeModifier == Modifier::None) {
1884 SetAnimation(_currentAnimation->State & ~(AnimState::Crouch | AnimState::Lookup | AnimState::Buttstomp));
1885 SetPlayerTransition(AnimState::Dash | AnimState::Jump, true, false, SpecialMoveType::None);
1886 }
1887 }
1888
1889 _levelHandler->PlayerExecuteRumble(this, "Spring"_s);
1890 } else if (std::abs(force.Y) > 0.0f) {
1891 MoveInstantly(Vector2f(lerp(_pos.X, pos.X, 0.3f), _pos.Y), MoveType::Absolute);
1892
1893 if (_activeModifier == Modifier::None && _copterFramesLeft > 0.0f) {
1894 _copterFramesLeft = 0.0f;
1895 SetAnimation(_currentAnimation->State & ~AnimState::Copter);
1896 SetState(ActorState::ApplyGravitation, true);
1897 }
1898
1899 _speed.Y = (4.0f + std::abs(force.Y)) * sign;
1900 if (!GetState(ActorState::ApplyGravitation)) {
1901 _externalForce.Y = force.Y * 0.14f;
1902 } else if (_levelHandler->IsReforged()) {
1903 _externalForce.Y = force.Y;
1904 } else {
1905 _externalForce.Y = force.Y * 0.8f;
1906 }
1907 _springCooldown = 10.0f;
1908 SetState(ActorState::CanJump, false);
1909
1910 if (!keepSpeedX) {
1911 _speed.X = 0.0f;

Callers 1

MpLevelHandler.cppFile · 0.45

Calls 3

lerpFunction · 0.85
IsReforgedMethod · 0.80
PlayerExecuteRumbleMethod · 0.45

Tested by

no test coverage detected