Merge pull request 'Swimming animations' (#1074) from epCode/MineClone2:master into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1074
This commit is contained in:
Elias Fleckenstein 2021-02-07 14:05:05 +00:00
commit 26037157f8
5 changed files with 324 additions and 302 deletions

View File

@ -359,6 +359,10 @@ mcl_player.player_register_model("mcl_armor_character.b3d", {
sneak_mine = {x=346, y=366}, sneak_mine = {x=346, y=366},
sneak_walk = {x=304, y=323}, sneak_walk = {x=304, y=323},
sneak_walk_mine = {x=325, y=344}, sneak_walk_mine = {x=325, y=344},
swim_walk = {x=368, y=387},
swim_walk_mine = {x=389, y=408},
swim_stand = {x=434, y=434},
swim_mine = {x=411, y=430},
}, },
}) })

View File

@ -147,6 +147,9 @@ minetest.register_globalstep(function(dtime)
animation_speed_mod = animation_speed_mod / 2 animation_speed_mod = animation_speed_mod / 2
end end
-- ask if player is swiming
local standing_on_water = minetest.get_item_group(mcl_playerinfo[name].node_stand, "water") ~= 0
-- Apply animations based on what the player is doing -- Apply animations based on what the player is doing
if player:get_hp() == 0 then if player:get_hp() == 0 then
player_set_animation(player, "lay") player_set_animation(player, "lay")
@ -155,20 +158,28 @@ minetest.register_globalstep(function(dtime)
player_anim[name] = nil player_anim[name] = nil
player_sneak[name] = controls.sneak player_sneak[name] = controls.sneak
end end
if controls.LMB and not controls.sneak then if controls.LMB and not controls.sneak and standing_on_water then
player_set_animation(player, "swim_walk_mine", animation_speed_mod)
elseif not controls.sneak and standing_on_water then
player_set_animation(player, "swim_walk", animation_speed_mod)
elseif controls.LMB and not controls.sneak and not standing_on_water then
player_set_animation(player, "walk_mine", animation_speed_mod) player_set_animation(player, "walk_mine", animation_speed_mod)
elseif controls.LMB and controls.sneak then elseif controls.LMB and controls.sneak and not standing_on_water then
player_set_animation(player, "sneak_walk_mine", animation_speed_mod) player_set_animation(player, "sneak_walk_mine", animation_speed_mod)
elseif not controls.sneak then elseif not controls.sneak and not standing_on_water then
player_set_animation(player, "walk", animation_speed_mod) player_set_animation(player, "walk", animation_speed_mod)
else else
player_set_animation(player, "sneak_walk", animation_speed_mod) player_set_animation(player, "sneak_walk", animation_speed_mod)
end end
elseif controls.LMB and not controls.sneak then elseif controls.LMB and not controls.sneak and standing_on_water then
player_set_animation(player, "swim_mine")
elseif controls.LMB and not controls.sneak and not standing_on_water then
player_set_animation(player, "mine") player_set_animation(player, "mine")
elseif controls.LMB and controls.sneak then elseif controls.LMB and controls.sneak then
player_set_animation(player, "sneak_mine") player_set_animation(player, "sneak_mine")
elseif not controls.sneak then elseif not controls.sneak and standing_on_water then
player_set_animation(player, "swim_stand", animation_speed_mod)
elseif not controls.sneak and not standing_on_water then
player_set_animation(player, "stand", animation_speed_mod) player_set_animation(player, "stand", animation_speed_mod)
else else
player_set_animation(player, "sneak_stand", animation_speed_mod) player_set_animation(player, "sneak_stand", animation_speed_mod)

View File

@ -39,6 +39,13 @@ minetest.register_globalstep(function(dtime)
if player:get_properties().collisionbox ~= {-0.35,0,-0.35,0.35,1.35,0.35} then if player:get_properties().collisionbox ~= {-0.35,0,-0.35,0.35,1.35,0.35} then
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.35,0.35}, eye_height = 1.35, nametag_color = { r = 255, b = 225, a = 0, g = 225 }}) player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.35,0.35}, eye_height = 1.35, nametag_color = { r = 255, b = 225, a = 0, g = 225 }})
end end
elseif minetest.get_item_group(mcl_playerinfo[name].node_stand, "water") ~= 0 then
-- controls head pitch when swiming
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90,0,0))
-- sets collisionbox, eye height, and nametag color accordingly
if player:get_properties().collisionbox ~= {-0.35,0.2,-0.35,0.35,1.8,0.35} then
player:set_properties({collisionbox = {-0.35,0.2,-0.35,0.35,1.8,0.35}, eye_height = 1.65, nametag_color = { r = 255, b = 225, a = 225, g = 225 }})
end
else else
-- controls head pitch when not sneaking -- controls head pitch when not sneaking
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch,0,0)) player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch,0,0))