parent
6e1372bd89
commit
9ba24f89f5
|
@ -6589,6 +6589,9 @@ Player properties need to be saved manually.
|
||||||
-- deleted when the block gets unloaded.
|
-- deleted when the block gets unloaded.
|
||||||
-- The get_staticdata() callback is never called then.
|
-- The get_staticdata() callback is never called then.
|
||||||
-- Defaults to 'true'.
|
-- Defaults to 'true'.
|
||||||
|
|
||||||
|
damage_texture_modifier = "^[brighten",
|
||||||
|
-- Texture modifier to be applied for a short duration when object is hit
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity definition
|
Entity definition
|
||||||
|
|
|
@ -1532,7 +1532,7 @@ void GenericCAO::processMessage(const std::string &data)
|
||||||
} else if (cmd == AO_CMD_SET_TEXTURE_MOD) {
|
} else if (cmd == AO_CMD_SET_TEXTURE_MOD) {
|
||||||
std::string mod = deSerializeString(is);
|
std::string mod = deSerializeString(is);
|
||||||
|
|
||||||
// immediatly reset a engine issued texture modifier if a mod sends a different one
|
// immediately reset a engine issued texture modifier if a mod sends a different one
|
||||||
if (m_reset_textures_timer > 0) {
|
if (m_reset_textures_timer > 0) {
|
||||||
m_reset_textures_timer = -1;
|
m_reset_textures_timer = -1;
|
||||||
updateTextures(m_previous_texture_modifier);
|
updateTextures(m_previous_texture_modifier);
|
||||||
|
@ -1646,13 +1646,11 @@ void GenericCAO::processMessage(const std::string &data)
|
||||||
m_smgr, m_env, m_position,
|
m_smgr, m_env, m_position,
|
||||||
v2f(m_prop.visual_size.X, m_prop.visual_size.Y) * BS);
|
v2f(m_prop.visual_size.X, m_prop.visual_size.Y) * BS);
|
||||||
m_env->addSimpleObject(simple);
|
m_env->addSimpleObject(simple);
|
||||||
} else if (m_reset_textures_timer < 0) {
|
} else if (m_reset_textures_timer < 0 && !m_prop.damage_texture_modifier.empty()) {
|
||||||
// TODO: Execute defined fast response
|
|
||||||
// Flashing shall suffice as there is no definition
|
|
||||||
m_reset_textures_timer = 0.05;
|
m_reset_textures_timer = 0.05;
|
||||||
if(damage >= 2)
|
if(damage >= 2)
|
||||||
m_reset_textures_timer += 0.05 * damage;
|
m_reset_textures_timer += 0.05 * damage;
|
||||||
updateTextures(m_current_texture_modifier + "^[brighten");
|
updateTextures(m_current_texture_modifier + m_prop.damage_texture_modifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1723,13 +1721,11 @@ bool GenericCAO::directReportPunch(v3f dir, const ItemStack *punchitem,
|
||||||
v2f(m_prop.visual_size.X, m_prop.visual_size.Y) * BS);
|
v2f(m_prop.visual_size.X, m_prop.visual_size.Y) * BS);
|
||||||
m_env->addSimpleObject(simple);
|
m_env->addSimpleObject(simple);
|
||||||
}
|
}
|
||||||
// TODO: Execute defined fast response
|
if (m_reset_textures_timer < 0 && !m_prop.damage_texture_modifier.empty()) {
|
||||||
// Flashing shall suffice as there is no definition
|
|
||||||
if (m_reset_textures_timer < 0) {
|
|
||||||
m_reset_textures_timer = 0.05;
|
m_reset_textures_timer = 0.05;
|
||||||
if (result.damage >= 2)
|
if (result.damage >= 2)
|
||||||
m_reset_textures_timer += 0.05 * result.damage;
|
m_reset_textures_timer += 0.05 * result.damage;
|
||||||
updateTextures(m_current_texture_modifier + "^[brighten");
|
updateTextures(m_current_texture_modifier + m_prop.damage_texture_modifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ std::string ObjectProperties::dump()
|
||||||
os << ", eye_height=" << eye_height;
|
os << ", eye_height=" << eye_height;
|
||||||
os << ", zoom_fov=" << zoom_fov;
|
os << ", zoom_fov=" << zoom_fov;
|
||||||
os << ", use_texture_alpha=" << use_texture_alpha;
|
os << ", use_texture_alpha=" << use_texture_alpha;
|
||||||
|
os << ", damage_texture_modifier=" << damage_texture_modifier;
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ void ObjectProperties::serialize(std::ostream &os) const
|
||||||
writeF32(os, eye_height);
|
writeF32(os, eye_height);
|
||||||
writeF32(os, zoom_fov);
|
writeF32(os, zoom_fov);
|
||||||
writeU8(os, use_texture_alpha);
|
writeU8(os, use_texture_alpha);
|
||||||
|
os << serializeString(damage_texture_modifier);
|
||||||
|
|
||||||
// Add stuff only at the bottom.
|
// Add stuff only at the bottom.
|
||||||
// Never remove anything, because we don't want new versions of this
|
// Never remove anything, because we don't want new versions of this
|
||||||
|
@ -166,4 +168,7 @@ void ObjectProperties::deSerialize(std::istream &is)
|
||||||
eye_height = readF32(is);
|
eye_height = readF32(is);
|
||||||
zoom_fov = readF32(is);
|
zoom_fov = readF32(is);
|
||||||
use_texture_alpha = readU8(is);
|
use_texture_alpha = readU8(is);
|
||||||
|
try {
|
||||||
|
damage_texture_modifier = deSerializeString(is);
|
||||||
|
} catch (SerializationError &e) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ struct ObjectProperties
|
||||||
std::string mesh = "";
|
std::string mesh = "";
|
||||||
v3f visual_size = v3f(1, 1, 1);
|
v3f visual_size = v3f(1, 1, 1);
|
||||||
std::vector<std::string> textures;
|
std::vector<std::string> textures;
|
||||||
|
std::string damage_texture_modifier = "^[brighten";
|
||||||
std::vector<video::SColor> colors;
|
std::vector<video::SColor> colors;
|
||||||
v2s16 spritediv = v2s16(1, 1);
|
v2s16 spritediv = v2s16(1, 1);
|
||||||
v2s16 initial_sprite_basepos;
|
v2s16 initial_sprite_basepos;
|
||||||
|
|
|
@ -327,6 +327,8 @@ void read_object_properties(lua_State *L, int index,
|
||||||
|
|
||||||
getfloatfield(L, -1, "zoom_fov", prop->zoom_fov);
|
getfloatfield(L, -1, "zoom_fov", prop->zoom_fov);
|
||||||
getboolfield(L, -1, "use_texture_alpha", prop->use_texture_alpha);
|
getboolfield(L, -1, "use_texture_alpha", prop->use_texture_alpha);
|
||||||
|
|
||||||
|
getstringfield(L, -1, "damage_texture_modifier", prop->damage_texture_modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -409,6 +411,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
|
||||||
lua_setfield(L, -2, "zoom_fov");
|
lua_setfield(L, -2, "zoom_fov");
|
||||||
lua_pushboolean(L, prop->use_texture_alpha);
|
lua_pushboolean(L, prop->use_texture_alpha);
|
||||||
lua_setfield(L, -2, "use_texture_alpha");
|
lua_setfield(L, -2, "use_texture_alpha");
|
||||||
|
lua_pushlstring(L, prop->damage_texture_modifier.c_str(), prop->damage_texture_modifier.size());
|
||||||
|
lua_setfield(L, -2, "damage_texture_modifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue