mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 22:52:25 +01:00
Add disable_jump and fall_damage_add_percent node groups
This commit is contained in:
parent
6a16075912
commit
b17d3e7ad7
@ -453,6 +453,8 @@ Special groups
|
|||||||
- 2: node is removed without tool wear after 0.5 seconds or so
|
- 2: node is removed without tool wear after 0.5 seconds or so
|
||||||
(rail, sign)
|
(rail, sign)
|
||||||
- 3: node is removed without tool wear immediately (torch)
|
- 3: node is removed without tool wear immediately (torch)
|
||||||
|
- disable_jump: Player (and possibly other things) cannot jump from node
|
||||||
|
- fall_damage_add_percent: damage speed = speed * (1 + value/100)
|
||||||
|
|
||||||
Known damage and digging time defining groups
|
Known damage and digging time defining groups
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
@ -2040,6 +2040,11 @@ void ClientEnvironment::step(float dtime)
|
|||||||
//f32 tolerance = BS*12; // 3 without damage
|
//f32 tolerance = BS*12; // 3 without damage
|
||||||
f32 tolerance = BS*14; // 5 without damage
|
f32 tolerance = BS*14; // 5 without damage
|
||||||
f32 factor = 1;
|
f32 factor = 1;
|
||||||
|
const ContentFeatures &f = m_gamedef->ndef()->
|
||||||
|
get(m_map->getNodeNoEx(lplayer->getStandingNodePos()));
|
||||||
|
// Determine fall damage multiplier
|
||||||
|
int addp = itemgroup_get(f.groups, "fall_damage_add_percent");
|
||||||
|
info.speed *= (1.0 + (float)addp/100.0);
|
||||||
if(info.speed > tolerance)
|
if(info.speed > tolerance)
|
||||||
{
|
{
|
||||||
f32 damage_f = (info.speed - tolerance)/BS*factor;
|
f32 damage_f = (info.speed - tolerance)/BS*factor;
|
||||||
|
@ -38,7 +38,8 @@ LocalPlayer::LocalPlayer(IGameDef *gamedef):
|
|||||||
m_sneak_node_exists(false),
|
m_sneak_node_exists(false),
|
||||||
m_old_node_below(32767,32767,32767),
|
m_old_node_below(32767,32767,32767),
|
||||||
m_old_node_below_type("air"),
|
m_old_node_below_type("air"),
|
||||||
m_need_to_get_new_sneak_node(true)
|
m_need_to_get_new_sneak_node(true),
|
||||||
|
m_can_jump(false)
|
||||||
{
|
{
|
||||||
// Initialize hp to 0, so that no hearts will be shown if server
|
// Initialize hp to 0, so that no hearts will be shown if server
|
||||||
// doesn't support health points
|
// doesn't support health points
|
||||||
@ -314,6 +315,15 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
|||||||
*/
|
*/
|
||||||
m_old_node_below = floatToInt(position - v3f(0,BS/2,0), BS);
|
m_old_node_below = floatToInt(position - v3f(0,BS/2,0), BS);
|
||||||
m_old_node_below_type = nodemgr->get(map.getNodeNoEx(m_old_node_below)).name;
|
m_old_node_below_type = nodemgr->get(map.getNodeNoEx(m_old_node_below)).name;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check properties of the node on which the player is standing
|
||||||
|
*/
|
||||||
|
const ContentFeatures &f = nodemgr->get(map.getNodeNoEx(getStandingNodePos()));
|
||||||
|
// Determine if jumping is possible
|
||||||
|
m_can_jump = touching_ground;
|
||||||
|
if(itemgroup_get(f.groups, "disable_jump"))
|
||||||
|
m_can_jump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
|
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
|
||||||
@ -459,7 +469,7 @@ void LocalPlayer::applyControl(float dtime)
|
|||||||
speed.Y = walkspeed_max;
|
speed.Y = walkspeed_max;
|
||||||
setSpeed(speed);
|
setSpeed(speed);
|
||||||
}
|
}
|
||||||
else if(touching_ground)
|
else if(m_can_jump)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
NOTE: The d value in move() affects jump height by
|
NOTE: The d value in move() affects jump height by
|
||||||
|
@ -101,6 +101,7 @@ private:
|
|||||||
std::string m_old_node_below_type;
|
std::string m_old_node_below_type;
|
||||||
// Whether recalculation of the sneak node is needed
|
// Whether recalculation of the sneak node is needed
|
||||||
bool m_need_to_get_new_sneak_node;
|
bool m_need_to_get_new_sneak_node;
|
||||||
|
bool m_can_jump;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user