1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Players stay in environment even when dead, damage flash and fall damage fixes

Don't set m_removed on dead players (dead players are indicated by hp == 0). Local
damage flash is shown whatever the cause was (even from Lua set_hp). PlayerCAO
damage flash matches duration of local damage flash. Fall damage is dealt much more consistently (this is done by disallowing jumping when speed.Y is very negative, up to now jumping could sometimes negate fall damage)
This commit is contained in:
Kahrl 2012-01-24 00:00:26 +01:00 committed by Perttu Ahola
parent e15de8b70d
commit 88cdd3a363
8 changed files with 104 additions and 70 deletions

View file

@ -2067,6 +2067,7 @@ private:
bool m_is_local_player;
LocalPlayer *m_local_player;
float m_damage_visual_timer;
bool m_dead;
public:
PlayerCAO(IGameDef *gamedef, ClientEnvironment *env):
@ -2078,7 +2079,8 @@ public:
m_yaw(0),
m_is_local_player(false),
m_local_player(NULL),
m_damage_visual_timer(0)
m_damage_visual_timer(0),
m_dead(false)
{
if(gamedef == NULL)
ClientActiveObject::registerType(getType(), create);
@ -2100,6 +2102,8 @@ public:
m_position = readV3F1000(is);
// yaw
m_yaw = readF1000(is);
// dead
m_dead = readU8(is);
pos_translator.init(m_position);
@ -2129,6 +2133,8 @@ public:
{
if(m_is_local_player)
return NULL;
if(m_dead)
return NULL;
return &m_selection_box;
}
v3f getPosition()
@ -2204,6 +2210,7 @@ public:
m_text->setPosition(v3f(0, (f32)BS*2.1, 0));
updateTextures("");
updateVisibility();
updateNodePos();
}
@ -2221,11 +2228,11 @@ public:
if(m_node == NULL)
return;
m_node->setVisible(true);
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
setMeshColor(m_node->getMesh(), color);
updateVisibility();
}
v3s16 getLightPosition()
@ -2233,6 +2240,14 @@ public:
return floatToInt(m_position+v3f(0,BS*1.5,0), BS);
}
void updateVisibility()
{
if(m_node == NULL)
return;
m_node->setVisible(!m_dead);
}
void updateNodePos()
{
if(m_node == NULL)
@ -2248,6 +2263,7 @@ public:
void step(float dtime, ClientEnvironment *env)
{
pos_translator.translate(dtime);
updateVisibility();
updateNodePos();
if(m_damage_visual_timer > 0){
@ -2279,13 +2295,16 @@ public:
{
// damage
s16 damage = readS16(is);
if(m_is_local_player)
m_env->damageLocalPlayer(damage, false);
m_damage_visual_timer = 0.5;
m_damage_visual_timer = 0.05;
if(damage >= 2)
m_damage_visual_timer += 0.05 * damage;
updateTextures("^[brighten");
}
else if(cmd == 2) // died or respawned
{
m_dead = readU8(is);
updateVisibility();
}
}
void updateTextures(const std::string &mod)