forked from oerkki/voxelands
biome specific player damage
This commit is contained in:
parent
ed36251850
commit
f95db8f184
|
@ -3974,8 +3974,12 @@ void ClientEnvironment::step(float dtime)
|
||||||
v3f pf = lplayer->getPosition();
|
v3f pf = lplayer->getPosition();
|
||||||
v3s16 pp = floatToInt(pf, BS);
|
v3s16 pp = floatToInt(pf, BS);
|
||||||
|
|
||||||
s16 coldzone = 60;
|
uint32_t time = getTimeOfDay();
|
||||||
bool possible_cold = (pp.Y > coldzone && pp.Y < 1024);
|
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 ps[7] = {
|
||||||
v3f(0, BS*-0.1, 0),
|
v3f(0, BS*-0.1, 0),
|
||||||
|
@ -4018,6 +4022,7 @@ void ClientEnvironment::step(float dtime)
|
||||||
break;
|
break;
|
||||||
case CONTENT_FIRE:
|
case CONTENT_FIRE:
|
||||||
case CONTENT_FIRE_SHORTTERM:
|
case CONTENT_FIRE_SHORTTERM:
|
||||||
|
case CONTENT_CAMPFIRE:
|
||||||
t = DAMAGE_FIRE;
|
t = DAMAGE_FIRE;
|
||||||
break;
|
break;
|
||||||
case CONTENT_TNT:
|
case CONTENT_TNT:
|
||||||
|
@ -4047,13 +4052,117 @@ void ClientEnvironment::step(float dtime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cold zone
|
switch (biome) {
|
||||||
if (possible_cold) {
|
case BIOME_JUNGLE:
|
||||||
|
if (season == ENV_SEASON_WINTER && time > 4000 && time < 8000) {
|
||||||
std::vector<content_t> search;
|
std::vector<content_t> search;
|
||||||
search.push_back(CONTENT_FIRE);
|
search.push_back(CONTENT_FIRE);
|
||||||
|
search.push_back(CONTENT_CAMPFIRE);
|
||||||
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
|
if (!searchNear(pp,v3s16(-4,-2,-4),v3s16(5,5,5),search,NULL))
|
||||||
damageLocalPlayer(PLAYER_ALL,DAMAGE_COLD,5);
|
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)) {
|
if (m_hunger_interval.step(dtime,5.0)) {
|
||||||
|
|
|
@ -671,7 +671,8 @@ void hud_draw(
|
||||||
gettext("Fire"),
|
gettext("Fire"),
|
||||||
gettext("TNT"),
|
gettext("TNT"),
|
||||||
gettext("Steam"),
|
gettext("Steam"),
|
||||||
gettext("Poison")
|
gettext("Poison"),
|
||||||
|
gettext("Shadows")
|
||||||
};
|
};
|
||||||
|
|
||||||
std::wstring t = narrow_to_wide(damage_types[damage_type]);
|
std::wstring t = narrow_to_wide(damage_types[damage_type]);
|
||||||
|
|
|
@ -483,6 +483,10 @@ void MapBlockMesh::animate(float time)
|
||||||
for (std::map<u32, AnimationData>::iterator it = m_animation_data.begin();
|
for (std::map<u32, AnimationData>::iterator it = m_animation_data.begin();
|
||||||
it != m_animation_data.end(); ++it) {
|
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;
|
const TileSpec &tile = it->second.tile;
|
||||||
|
|
||||||
// Figure out current frame
|
// Figure out current frame
|
||||||
|
@ -496,10 +500,6 @@ void MapBlockMesh::animate(float time)
|
||||||
|
|
||||||
m_animation_data[it->first].frame = frame;
|
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);
|
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(it->first);
|
||||||
|
|
||||||
// Create new texture name from original
|
// Create new texture name from original
|
||||||
|
|
|
@ -854,6 +854,7 @@ LocalPlayer::LocalPlayer():
|
||||||
last_speed(v3f(0,0,0)),
|
last_speed(v3f(0,0,0)),
|
||||||
last_pitch(0),
|
last_pitch(0),
|
||||||
last_yaw(0),
|
last_yaw(0),
|
||||||
|
shadow_timer(0.0),
|
||||||
m_sneak_node(32767,32767,32767),
|
m_sneak_node(32767,32767,32767),
|
||||||
m_sneak_node_exists(false),
|
m_sneak_node_exists(false),
|
||||||
m_can_use_energy(true),
|
m_can_use_energy(true),
|
||||||
|
|
|
@ -92,6 +92,7 @@
|
||||||
#define DAMAGE_TNT 0x0C
|
#define DAMAGE_TNT 0x0C
|
||||||
#define DAMAGE_STEAM 0x0D
|
#define DAMAGE_STEAM 0x0D
|
||||||
#define DAMAGE_POISON 0x0E
|
#define DAMAGE_POISON 0x0E
|
||||||
|
#define DAMAGE_SHADOW 0x0F
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
|
@ -368,6 +369,7 @@ public:
|
||||||
case DAMAGE_COLD:
|
case DAMAGE_COLD:
|
||||||
v += content_clothesitem_features(i->getContent())->warmth;
|
v += content_clothesitem_features(i->getContent())->warmth;
|
||||||
break;
|
break;
|
||||||
|
case DAMAGE_POISON:
|
||||||
case DAMAGE_SPACE:
|
case DAMAGE_SPACE:
|
||||||
v += content_clothesitem_features(i->getContent())->vacuum;
|
v += content_clothesitem_features(i->getContent())->vacuum;
|
||||||
break;
|
break;
|
||||||
|
@ -662,6 +664,7 @@ public:
|
||||||
v3f last_speed;
|
v3f last_speed;
|
||||||
float last_pitch;
|
float last_pitch;
|
||||||
float last_yaw;
|
float last_yaw;
|
||||||
|
float shadow_timer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This is used for determining the sneaking range
|
// This is used for determining the sneaking range
|
||||||
|
|
Loading…
Reference in New Issue