From be8d9f4b6c49507f6d424d2bf1773ff8df24aea2 Mon Sep 17 00:00:00 2001 From: MatusGuy Date: Wed, 28 Aug 2024 20:33:15 +0100 Subject: [PATCH] AFDIUHS --- src/object/player.cpp | 19 +++++++++++++++++-- src/object/player.hpp | 26 ++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/object/player.cpp b/src/object/player.cpp index 168a2a35244..6fe8d2b677b 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -1974,6 +1974,18 @@ Player::get_visible() const return m_visible; } +void +Player::set_is_intentionally_safe(bool safe) +{ + m_is_intentionally_safe = safe; +} + +bool +Player::get_is_intentionally_safe() const +{ + return m_is_intentionally_safe; +} + void Player::kick() { @@ -2365,7 +2377,7 @@ Player::collision(GameObject& other, const CollisionHit& hit) auto badguy = dynamic_cast (&other); if (badguy != nullptr) { - if (m_safe_timer.started() || m_invincible_timer.started()) + if (m_is_intentionally_safe || m_safe_timer.started() || m_invincible_timer.started()) return FORCE_MOVE; if (m_stone) return ABORT_MOVE; @@ -2411,7 +2423,7 @@ Player::kill(bool completely) if (m_dying || m_deactivated || is_winning() ) return; - if (!completely && (m_safe_timer.started() || m_invincible_timer.started())) + if (!completely && (m_is_intentionally_safe || m_safe_timer.started() || m_invincible_timer.started())) return; m_growing = false; @@ -3078,6 +3090,8 @@ Player::register_class(ssq::VM& vm) cls.addFunc("set_dir", &Player::set_dir); cls.addFunc("set_visible", &Player::set_visible); cls.addFunc("get_visible", &Player::get_visible); + cls.addFunc("set_is_intentionally_safe", &Player::set_is_intentionally_safe); + cls.addFunc("get_is_intentionally_safe", &Player::get_is_intentionally_safe); cls.addFunc("kill", &Player::kill); cls.addFunc("set_ghost_mode", &Player::set_ghost_mode); cls.addFunc("get_ghost_mode", &Player::get_ghost_mode); @@ -3100,6 +3114,7 @@ Player::register_class(ssq::VM& vm) cls.addFunc("get_input_released", &Player::get_input_released); cls.addVar("visible", &Player::m_visible); + cls.addVar("is_intentionally_safe", &Player::m_is_intentionally_safe); } /* EOF */ diff --git a/src/object/player.hpp b/src/object/player.hpp index 720ec781949..7efc3a94317 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -136,11 +136,11 @@ class Player final : public MovingObject bool is_dying() const { return m_dying; } /** - * Returns true if the player is currently alive + * Returns true if the player is currently alive * (not dying or dead) */ bool is_alive() const { return !is_dying() && !is_dead(); } - + /** * Returns true if the player can be controlled. * (alive and not currently in a win sequence) @@ -298,8 +298,8 @@ class Player final : public MovingObject /** * @scripting - * @description Set Tux visible or invisible. - * @param bool $visible + * @description Set Tux safe or invisible. + * @param bool $safe */ void set_visible(bool visible); /** @@ -308,6 +308,18 @@ class Player final : public MovingObject */ bool get_visible() const; + /** + * @scripting + * @description Set Tux visible or invisible. + * @param bool $visible + */ + void set_is_intentionally_safe(bool safe); + /** + * @scripting + * @description Returns ""true"" if Tux is currently visible (has not been set invisible by the ""set_visible()"" method). + */ + bool get_is_intentionally_safe() const; + bool on_ground() const; void set_on_ground(bool flag); @@ -535,7 +547,13 @@ class Player final : public MovingObject private: Timer m_skidding_timer; Timer m_safe_timer; + + /** + * @scripting + * @description Determines whether Tux is invincible. + */ bool m_is_intentionally_safe; + Timer m_kick_timer; Timer m_buttjump_timer;