1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-07-11 12:20:21 +02:00

add new mod player_physics and update sprint and 3d_armor to use player_physics

This commit is contained in:
2017-04-07 23:18:55 +02:00
parent cfd80c090c
commit 84e858fccf
9 changed files with 840 additions and 30 deletions

View File

@ -1 +1,2 @@
hudbars?
player_physics

View File

@ -182,35 +182,12 @@ end)
function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
local player = minetest.get_player_by_name(playerName)
local bonus_speed = 0
local bonus_jump = 0
if minetest.get_modpath("3d_armor") then
local player_inv = player:get_inventory()
if player_inv then
for i=1, player_inv:get_size("armor") do
local stack = player_inv:get_stack("armor", i)
if stack:get_count() > 0 then
local def = stack:get_definition()
if def and def.groups then
if def.groups["physics_speed"] then
bonus_speed = bonus_speed + def.groups["physics_speed"]
end
if def.groups["physics_jump"] then
bonus_jump = bonus_jump + def.groups["physics_jump"]
end
end
end
end
end
end
if sprint.players[playerName] then
sprint.players[playerName]["sprinting"] = sprinting
if sprinting == true then
player:set_physics_override({speed=SPRINT_SPEED + bonus_speed,jump=SPRINT_JUMP + bonus_jump})
player_physics.set_stats(player, "sprint", {speed=SPRINT_SPEED, jump=SPRINT_JUMP})
elseif sprinting == false then
player:set_physics_override({speed=1.0 + bonus_speed,jump=1.0 + bonus_jump})
player_physics.set_stats(player, "sprint", {speed=0, jump=0})
end
return true
end

View File

@ -9,8 +9,8 @@ distributed without any warranty.
--Configuration variables, these are all explained in README.md
SPRINT_METHOD = 1
SPRINT_SPEED = 1.35
SPRINT_JUMP = 1.1
SPRINT_SPEED = 0.35
SPRINT_JUMP = 0.1
SPRINT_STAMINA = 10
SPRINT_TIMEOUT = 0.5 --Only used if SPRINT_METHOD = 0

View File

@ -140,11 +140,11 @@ function setState(playerName, state) --Sets the state of a player (0=stopped, 1=
if players[playerName] then
players[playerName]["state"] = state
if state == 0 then--Stopped
player:set_physics_override({speed=1.0,jump=1.0})
player_physics.set_stats(player, "sprint", {speed=0, jump=0})
elseif state == 2 then --Primed
players[playerName]["timeOut"] = gameTime
elseif state == 3 then --Sprinting
player:set_physics_override({speed=SPRINT_SPEED,jump=SPRINT_JUMP})
player_physics.set_stats(player, "sprint", {speed=SPRINT_SPEED, jump=SPRINT_JUMP})
end
return true
end