diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 10:57:40 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-12-02 10:57:40 +0200 |
commit | c3579851354e92a24991c2c3a7844295b7d13a26 (patch) | |
tree | 965768539709d009abba03fcebfa68b032ffb27d /src/content_cao.cpp | |
parent | ae2b7f952368174aeac90a5076eadd90ddc7fff3 (diff) | |
download | minetest-c3579851354e92a24991c2c3a7844295b7d13a26.tar.gz minetest-c3579851354e92a24991c2c3a7844295b7d13a26.tar.bz2 minetest-c3579851354e92a24991c2c3a7844295b7d13a26.zip |
Make hitting players make a visual damage flash to the player texture and the screen of the local player
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r-- | src/content_cao.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp index eed5a8337..b9dc91e63 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -2274,6 +2274,13 @@ public: { pos_translator.translate(dtime); updateNodePos(); + + if(m_damage_visual_timer > 0){ + m_damage_visual_timer -= dtime; + if(m_damage_visual_timer <= 0){ + updateTextures(""); + } + } } void processMessage(const std::string &data) @@ -2293,6 +2300,17 @@ public: updateNodePos(); } + else if(cmd == 1) // punched + { + // damage + s16 damage = readS16(is); + + if(m_is_local_player) + m_env->damageLocalPlayer(damage, false); + + m_damage_visual_timer = 0.5; + updateTextures("^[brighten"); + } } void updateTextures(const std::string &mod) @@ -2318,12 +2336,6 @@ public: } } } - - bool directReportPunch(const std::string &toolname, v3f dir) - { - updateTextures("^[brighten"); - return false; - } }; // Prototype |