biome specific player damage

This commit is contained in:
darkrose 2017-07-25 16:03:22 +10:00
parent ed36251850
commit f95db8f184
5 changed files with 123 additions and 9 deletions

View File

@ -3974,8 +3974,12 @@ void ClientEnvironment::step(float dtime)
v3f pf = lplayer->getPosition();
v3s16 pp = floatToInt(pf, BS);
s16 coldzone = 60;
bool possible_cold = (pp.Y > coldzone && pp.Y < 1024);
uint32_t time = getTimeOfDay();
uint16_t season = getSeason();
uint8_t biome = BIOME_UNKNOWN;
MapBlock *block = m_map->getBlockNoCreateNoEx(getNodeBlockPos(pp));
if (block)
biome = block->getBiome();
v3f ps[7] = {
v3f(0, BS*-0.1, 0),
@ -4018,6 +4022,7 @@ void ClientEnvironment::step(float dtime)
break;
case CONTENT_FIRE:
case CONTENT_FIRE_SHORTTERM:
case CONTENT_CAMPFIRE:
t = DAMAGE_FIRE;
break;
case CONTENT_TNT:
@ -4047,13 +4052,117 @@ void ClientEnvironment::step(float dtime)
}
}
// cold zone
if (possible_cold) {
switch (biome) {
case BIOME_JUNGLE:
if (season == ENV_SEASON_WINTER && time > 4000 && time < 8000) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_OCEAN:
if (season == ENV_SEASON_WINTER) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_DESERT:
break;
case BIOME_PLAINS:
if (season == ENV_SEASON_WINTER && (time < 6000 || time > 18000)) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_FOREST:
if (season == ENV_SEASON_WINTER) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_SKY:
case BIOME_SNOWCAP:
{
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_LAKE:
if (
season == ENV_SEASON_WINTER
|| (
season == ENV_SEASON_AUTUMN
&& (time < 6000 || time > 18000)
) || (
season == ENV_SEASON_SPRING
&& time > 4000
&& time < 8000
)
) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_BEACH:
if (season == ENV_SEASON_WINTER) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
break;
case BIOME_SPACE:
break;
case BIOME_THEDEEP:
if (lplayer->shadow_timer >= 5.0) {
/* this means it takes 5 seconds to start taking damage, then damage every second after that */
lplayer->shadow_timer -= 2.0;
damageLocalPlayer(PLAYER_ALL,DAMAGE_SHADOW,5);
}
if (lplayer->light < 8) {
lplayer->shadow_timer += 1.0;
}else{
lplayer->shadow_timer = 0.0;
}
break;
case BIOME_WASTELANDS:
{
std::vector<content_t> search;
search.push_back(CONTENT_LIFE_SUPPORT);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_POISON,5);
}
break;
case BIOME_UNKNOWN:
case BIOME_WOODLANDS:
if (season == ENV_SEASON_WINTER) {
std::vector<content_t> search;
search.push_back(CONTENT_FIRE);
search.push_back(CONTENT_CAMPFIRE);
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
}
default:
break;
}
}
if (m_hunger_interval.step(dtime,5.0)) {

View File

@ -671,7 +671,8 @@ void hud_draw(
gettext("Fire"),
gettext("TNT"),
gettext("Steam"),
gettext("Poison")
gettext("Poison"),
gettext("Shadows")
};
std::wstring t = narrow_to_wide(damage_types[damage_type]);

View File

@ -483,6 +483,10 @@ void MapBlockMesh::animate(float time)
for (std::map<u32, AnimationData>::iterator it = m_animation_data.begin();
it != m_animation_data.end(); ++it) {
// Make sure we don't cause an overflow
if (it->first >= m_mesh->getMeshBufferCount())
return;
const TileSpec &tile = it->second.tile;
// Figure out current frame
@ -496,10 +500,6 @@ void MapBlockMesh::animate(float time)
m_animation_data[it->first].frame = frame;
// Make sure we don't cause an overflow. Can get removed in future if no problems occuring
if (it->first >= m_mesh->getMeshBufferCount())
return;
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(it->first);
// Create new texture name from original

View File

@ -854,6 +854,7 @@ LocalPlayer::LocalPlayer():
last_speed(v3f(0,0,0)),
last_pitch(0),
last_yaw(0),
shadow_timer(0.0),
m_sneak_node(32767,32767,32767),
m_sneak_node_exists(false),
m_can_use_energy(true),

View File

@ -92,6 +92,7 @@
#define DAMAGE_TNT 0x0C
#define DAMAGE_STEAM 0x0D
#define DAMAGE_POISON 0x0E
#define DAMAGE_SHADOW 0x0F
class Map;
@ -368,6 +369,7 @@ public:
case DAMAGE_COLD:
v += content_clothesitem_features(i->getContent())->warmth;
break;
case DAMAGE_POISON:
case DAMAGE_SPACE:
v += content_clothesitem_features(i->getContent())->vacuum;
break;
@ -662,6 +664,7 @@ public:
v3f last_speed;
float last_pitch;
float last_yaw;
float shadow_timer;
private:
// This is used for determining the sneaking range