Skip to content

Commit

Permalink
add feather falling (#73)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tenplus1 committed Apr 2, 2022
1 parent ac445a6 commit e1a262b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion 3d_armor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion 3d_armor/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand Down Expand Up @@ -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,
}

Expand Down
14 changes: 14 additions & 0 deletions 3d_armor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e1a262b

Please sign in to comment.