add feather falling (#73)

* add feather falling

add feather falling

* add feather falling to init.lua

add feather falling routine to globalstep

* add feather falling to readme

add feather falling to readme
This commit is contained in:
tenplus1 2022-04-02 15:16:23 +00:00 committed by GitHub
parent ac445a6cd0
commit e1a262ba20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

@ -254,7 +254,7 @@ The above allows armor to block/prevent new damage types but you also need to as
## Groups used by 3d_Armor
3d_armor has many default groups already registered, these are categorized under 4 main headings
- **Elements:** armor_head, armor_torso, armor_legs, armor_feet
- **Attributes:** armor_heal, armor_fire, armor_water
- **Attributes:** armor_heal, armor_fire, armor_water, armor_feather
- **Physics:** physics_jump, physics_speed, physics_gravity
- **Durability:** armor_use, flammable
@ -334,6 +334,9 @@ The below Diamond chestplate has a 12% chance to completely block all damage (ar
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
})
#### Armor_feather
***"Armor_feather"*** will slow a player when falling. This only has one level or state, which is armor_feather=1
### Physics
The physics attributes supported by 3d_armor are ***physics_jump, physics_speed and physics_gravity***. Although 3d_armor supports the use of this with no other mods it is recommended that the mod [player_monoids](https://forum.minetest.net/viewtopic.php?t=14895) is used to help with intermod compatability.

@ -112,7 +112,7 @@ armor = {
timer = 0,
elements = {"head", "torso", "legs", "feet"},
physics = {"jump", "speed", "gravity"},
attributes = {"heal", "fire", "water"},
attributes = {"heal", "fire", "water", "feather"},
formspec = "image[2.5,0;2,4;armor_preview]"..
default.gui_bg..
default.gui_bg_img..
@ -183,6 +183,7 @@ armor.config = {
water_protect = true,
fire_protect = minetest.get_modpath("ethereal") ~= nil,
fire_protect_torch = minetest.get_modpath("ethereal") ~= nil,
feather_fall = true,
punch_damage = true,
}

@ -440,6 +440,20 @@ end, true)
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if armor.config.feather_fall == true then
for _,player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if armor.def[name].feather > 0 then
local vel_y = player:get_velocity().y
if vel_y < 0 and vel_y < 3 then
vel_y = -(vel_y * 0.05)
player:add_velocity({x = 0, y = vel_y, z = 0})
end
end
end
end
if timer <= armor.config.init_delay then
return
end