mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Merge 31adcec585
into 1297ccc537
This commit is contained in:
commit
d4bf931924
7 changed files with 94 additions and 11 deletions
|
@ -10111,6 +10111,13 @@ Used by `core.register_node`.
|
||||||
|
|
||||||
climbable = false, -- If true, can be climbed on like a ladder
|
climbable = false, -- If true, can be climbed on like a ladder
|
||||||
|
|
||||||
|
climb_factor = 1.0,
|
||||||
|
-- The speed at which a climbable node can be climbed up and down
|
||||||
|
-- is multiplied by this number. Must not be negative. No effect if
|
||||||
|
-- node isn't climbable.
|
||||||
|
-- Note: The base climbing speed is controlled by the setting
|
||||||
|
-- `movement_speed_climb` multiplied by the physics override `speed_climb`.
|
||||||
|
|
||||||
move_resistance = 0,
|
move_resistance = 0,
|
||||||
-- Slows down movement of players through this node (max. 7).
|
-- Slows down movement of players through this node (max. 7).
|
||||||
-- If this is nil, it will be equal to liquid_viscosity.
|
-- If this is nil, it will be equal to liquid_viscosity.
|
||||||
|
|
|
@ -209,6 +209,49 @@ core.register_node("testnodes:climbable", {
|
||||||
groups = {dig_immediate=3},
|
groups = {dig_immediate=3},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("testnodes:climbable_fast", {
|
||||||
|
description = S("Fast Climbable Node").."\n"..
|
||||||
|
S("You can climb up and down, faster than usual"),
|
||||||
|
climbable = true,
|
||||||
|
climb_factor = 2.0,
|
||||||
|
walkable = false,
|
||||||
|
|
||||||
|
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
is_ground_content = false,
|
||||||
|
tiles = {
|
||||||
|
"testnodes_climbable_top.png^[colorize:#FFFFFF:140",
|
||||||
|
"testnodes_climbable_top.png^[colorize:#FFFFFF:140",
|
||||||
|
"testnodes_climbable_side.png^[colorize:#FFFFFF:140"
|
||||||
|
},
|
||||||
|
use_texture_alpha = "clip",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = climbable_nodebox,
|
||||||
|
groups = {dig_immediate=3},
|
||||||
|
})
|
||||||
|
minetest.register_node("testnodes:climbable_slow", {
|
||||||
|
description = S("Slow Climbable Node").."\n"..
|
||||||
|
S("You can climb up and down, slower than usual"),
|
||||||
|
climbable = true,
|
||||||
|
climb_factor = 0.5,
|
||||||
|
walkable = false,
|
||||||
|
|
||||||
|
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
is_ground_content = false,
|
||||||
|
tiles = {
|
||||||
|
"testnodes_climbable_top.png^[colorize:#000000:140",
|
||||||
|
"testnodes_climbable_top.png^[colorize:#000000:140",
|
||||||
|
"testnodes_climbable_side.png^[colorize:#000000:140"
|
||||||
|
},
|
||||||
|
use_texture_alpha = "clip",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = climbable_nodebox,
|
||||||
|
groups = {dig_immediate=3},
|
||||||
|
})
|
||||||
|
|
||||||
-- Climbable only downwards with sneak key
|
-- Climbable only downwards with sneak key
|
||||||
core.register_node("testnodes:climbable_nojump", {
|
core.register_node("testnodes:climbable_nojump", {
|
||||||
description = S("Downwards-climbable Node").."\n"..
|
description = S("Downwards-climbable Node").."\n"..
|
||||||
|
@ -219,7 +262,11 @@ core.register_node("testnodes:climbable_nojump", {
|
||||||
groups = {disable_jump=1, dig_immediate=3},
|
groups = {disable_jump=1, dig_immediate=3},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = climbable_nodebox,
|
node_box = climbable_nodebox,
|
||||||
tiles = {"testnodes_climbable_nojump_top.png","testnodes_climbable_nojump_top.png","testnodes_climbable_nojump_side.png"},
|
tiles = {
|
||||||
|
"testnodes_climbable_nojump_top.png",
|
||||||
|
"testnodes_climbable_nojump_top.png",
|
||||||
|
"testnodes_climbable_nojump_side.png"
|
||||||
|
},
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
@ -227,28 +274,38 @@ core.register_node("testnodes:climbable_nojump", {
|
||||||
|
|
||||||
|
|
||||||
core.register_node("testnodes:climbable_nodescend", {
|
core.register_node("testnodes:climbable_nodescend", {
|
||||||
description = S("Upwards-climbable Node"),
|
description = S("Upwards-climbable Node").."\n"..
|
||||||
|
S("You can climb only upwards"),
|
||||||
climbable = true,
|
climbable = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
|
||||||
groups = {disable_descend=1, dig_immediate=3},
|
groups = {disable_descend=1, dig_immediate=3},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = climbable_nodebox,
|
node_box = climbable_nodebox,
|
||||||
tiles = {"testnodes_climbable_nodescend_top.png","testnodes_climbable_nodescend_top.png","testnodes_climbable_nodescend_side.png"},
|
tiles = {
|
||||||
|
"testnodes_climbable_nodescend_top.png",
|
||||||
|
"testnodes_climbable_nodescend_top.png",
|
||||||
|
"testnodes_climbable_nodescend_side.png"
|
||||||
|
},
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
core.register_node("testnodes:climbable_nodescend_nojump", {
|
core.register_node("testnodes:climbable_nodescend_nojump", {
|
||||||
description = S("Horizontal-only Climbable Node"),
|
description = S("Horizontal-only Climbable Node").."\n"..
|
||||||
|
S("You hold on to this node but can't climb vertically"),
|
||||||
climbable = true,
|
climbable = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
|
||||||
groups = {disable_jump=1, disable_descend=1, dig_immediate=3},
|
groups = {disable_jump=1, disable_descend=1, dig_immediate=3},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = climbable_nodebox,
|
node_box = climbable_nodebox,
|
||||||
tiles = {"testnodes_climbable_noclimb_top.png","testnodes_climbable_noclimb_top.png","testnodes_climbable_noclimb_side.png"},
|
tiles = {
|
||||||
|
"testnodes_climbable_noclimb_top.png",
|
||||||
|
"testnodes_climbable_noclimb_top.png",
|
||||||
|
"testnodes_climbable_noclimb_side.png"
|
||||||
|
},
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
|
|
@ -314,8 +314,13 @@ void LocalPlayer::move(f32 dtime, Environment *env,
|
||||||
if (!(is_valid_position && is_valid_position2)) {
|
if (!(is_valid_position && is_valid_position2)) {
|
||||||
is_climbing = false;
|
is_climbing = false;
|
||||||
} else {
|
} else {
|
||||||
is_climbing = (nodemgr->get(node.getContent()).climbable ||
|
const ContentFeatures &cf_upper = nodemgr->get(node.getContent());
|
||||||
nodemgr->get(node2.getContent()).climbable) && !free_move;
|
const ContentFeatures &cf_lower = nodemgr->get(node2.getContent());
|
||||||
|
is_climbing = (cf_upper.climbable || cf_lower.climbable) && !free_move;
|
||||||
|
if (is_climbing) {
|
||||||
|
node_climb_factor = cf_lower.climbable
|
||||||
|
? cf_lower.climb_factor : cf_upper.climb_factor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player object property step height is multiplied by BS in
|
// Player object property step height is multiplied by BS in
|
||||||
|
@ -582,7 +587,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
|
||||||
speedV.Y = -speed_walk;
|
speedV.Y = -speed_walk;
|
||||||
swimming_vertical = true;
|
swimming_vertical = true;
|
||||||
} else if (is_climbing && !m_disable_descend) {
|
} else if (is_climbing && !m_disable_descend) {
|
||||||
speedV.Y = -movement_speed_climb * physics_override.speed_climb;
|
speedV.Y = -movement_speed_climb * physics_override.speed_climb * node_climb_factor;
|
||||||
} else {
|
} else {
|
||||||
// If not free movement but fast is allowed, aux1 is
|
// If not free movement but fast is allowed, aux1 is
|
||||||
// "Turbo button"
|
// "Turbo button"
|
||||||
|
@ -618,9 +623,9 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
|
||||||
swimming_vertical = true;
|
swimming_vertical = true;
|
||||||
} else if (is_climbing && !m_disable_descend) {
|
} else if (is_climbing && !m_disable_descend) {
|
||||||
if (fast_climb)
|
if (fast_climb)
|
||||||
speedV.Y = -speed_fast;
|
speedV.Y = -speed_fast * node_climb_factor;
|
||||||
else
|
else
|
||||||
speedV.Y = -movement_speed_climb * physics_override.speed_climb;
|
speedV.Y = -movement_speed_climb * physics_override.speed_climb * node_climb_factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,7 +678,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
|
||||||
if (fast_climb)
|
if (fast_climb)
|
||||||
speedV.Y = speed_fast;
|
speedV.Y = speed_fast;
|
||||||
else
|
else
|
||||||
speedV.Y = movement_speed_climb * physics_override.speed_climb;
|
speedV.Y = movement_speed_climb * physics_override.speed_climb * node_climb_factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
// Slows down the player when moving through
|
// Slows down the player when moving through
|
||||||
u8 move_resistance = 0;
|
u8 move_resistance = 0;
|
||||||
bool is_climbing = false;
|
bool is_climbing = false;
|
||||||
|
f32 node_climb_factor = 1.0f;
|
||||||
bool swimming_vertical = false;
|
bool swimming_vertical = false;
|
||||||
bool swimming_pitch = false;
|
bool swimming_pitch = false;
|
||||||
|
|
||||||
|
|
|
@ -373,6 +373,7 @@ void ContentFeatures::reset()
|
||||||
pointable = PointabilityType::POINTABLE;
|
pointable = PointabilityType::POINTABLE;
|
||||||
diggable = true;
|
diggable = true;
|
||||||
climbable = false;
|
climbable = false;
|
||||||
|
climb_factor = 1.0f;
|
||||||
buildable_to = false;
|
buildable_to = false;
|
||||||
floodable = false;
|
floodable = false;
|
||||||
rightclickable = true;
|
rightclickable = true;
|
||||||
|
@ -535,6 +536,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
|
||||||
writeU8(os, move_resistance);
|
writeU8(os, move_resistance);
|
||||||
writeU8(os, liquid_move_physics);
|
writeU8(os, liquid_move_physics);
|
||||||
writeU8(os, post_effect_color_shaded);
|
writeU8(os, post_effect_color_shaded);
|
||||||
|
writeF32(os, climb_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentFeatures::deSerialize(std::istream &is, u16 protocol_version)
|
void ContentFeatures::deSerialize(std::istream &is, u16 protocol_version)
|
||||||
|
@ -665,6 +667,11 @@ void ContentFeatures::deSerialize(std::istream &is, u16 protocol_version)
|
||||||
if (is.eof())
|
if (is.eof())
|
||||||
throw SerializationError("");
|
throw SerializationError("");
|
||||||
post_effect_color_shaded = tmp;
|
post_effect_color_shaded = tmp;
|
||||||
|
|
||||||
|
f32 ftmp = readF32(is);
|
||||||
|
if (is.eof())
|
||||||
|
throw SerializationError("");
|
||||||
|
climb_factor = ftmp;
|
||||||
} catch (SerializationError &e) {};
|
} catch (SerializationError &e) {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,6 +392,8 @@ struct ContentFeatures
|
||||||
bool diggable;
|
bool diggable;
|
||||||
// Player can climb these
|
// Player can climb these
|
||||||
bool climbable;
|
bool climbable;
|
||||||
|
// Climb speed factor
|
||||||
|
f32 climb_factor;
|
||||||
// Player can build on these
|
// Player can build on these
|
||||||
bool buildable_to;
|
bool buildable_to;
|
||||||
// Player cannot build to these (placement prediction disabled)
|
// Player cannot build to these (placement prediction disabled)
|
||||||
|
|
|
@ -869,6 +869,8 @@ void read_content_features(lua_State *L, ContentFeatures &f, int index)
|
||||||
getboolfield(L, index, "diggable", f.diggable);
|
getboolfield(L, index, "diggable", f.diggable);
|
||||||
// Player can climb these
|
// Player can climb these
|
||||||
getboolfield(L, index, "climbable", f.climbable);
|
getboolfield(L, index, "climbable", f.climbable);
|
||||||
|
// Multiplies climb speed on climbable node
|
||||||
|
getfloatfield(L, index, "climb_factor", f.climb_factor);
|
||||||
// Player can build on these
|
// Player can build on these
|
||||||
getboolfield(L, index, "buildable_to", f.buildable_to);
|
getboolfield(L, index, "buildable_to", f.buildable_to);
|
||||||
// Liquids flow into and replace node
|
// Liquids flow into and replace node
|
||||||
|
@ -1146,6 +1148,8 @@ void push_content_features(lua_State *L, const ContentFeatures &c)
|
||||||
lua_setfield(L, -2, "move_resistance");
|
lua_setfield(L, -2, "move_resistance");
|
||||||
lua_pushboolean(L, c.liquid_move_physics);
|
lua_pushboolean(L, c.liquid_move_physics);
|
||||||
lua_setfield(L, -2, "liquid_move_physics");
|
lua_setfield(L, -2, "liquid_move_physics");
|
||||||
|
lua_pushnumber(L, c.climb_factor);
|
||||||
|
lua_setfield(L, -2, "climb_factor");
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue