Feature: Monoids support for speed and jump; Bad physics override mode.

master
aa6 2019-06-23 22:06:01 +03:00
parent 4c25bf9273
commit 231c0c2c77
7 changed files with 73 additions and 22 deletions

View File

@ -1 +1 @@
0.9.1
0.10.0

View File

@ -4,6 +4,7 @@
minetest_wadsprint.HIDE_HUD_BARS = false
minetest_wadsprint.STAMINA_MAX_VALUE = 100
minetest_wadsprint.DYSPNEA_THRESHOLD_VALUE = 3
minetest_wadsprint.BAD_PHYSICS_OVERRIDE_MODE = false
minetest_wadsprint.SAVE_PLAYERS_STATS_TO_FILE = true
minetest_wadsprint.PLAYERS_STATS_FILE_LIMIT_RECORDS = 1000
minetest_wadsprint.PLAYER_STATS_UPDATE_PERIOD_SECONDS = 1

View File

@ -1,5 +1,6 @@
-- WAD SPRINTING minetest (https://minetest.net) mod (https://dev.minetest.net/Intro)
-- @link https://github.com/aa6/minetest_wadsprint
dofile(minetest.get_modpath(minetest.get_current_modname()).."/lib_round.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/lib_savetable.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/lib_file_exists.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()).."/lib_eventemitter.lua")
@ -170,27 +171,7 @@ end
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------- set_sprinting_physics() --
----------------------------------------------------------------------------------------------------
function minetest_wadsprint.set_sprinting_physics(player,is_on)
if player.is_sprinting_physics_on ~= is_on then
local physics = player.obj:get_physics_override()
if is_on == true then
player.obj:set_physics_override(
{
jump = physics.jump - 1 + minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT,
speed = physics.speed - 1 + minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT,
})
else
if player.is_sprinting_physics_on ~= nil then
player.obj:set_physics_override(
{
jump = physics.jump + 1 - minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT,
speed = physics.speed + 1 - minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT,
})
end
end
player.is_sprinting_physics_on = is_on
end
end
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init_set_sprinting_physics.lua")
----------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------- scan_player_controls() --
----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,62 @@
if minetest_wadsprint.BAD_PHYSICS_OVERRIDE_MODE == true then
function minetest_wadsprint.set_sprinting_physics(player,is_on)
if player.is_sprinting_physics_on ~= is_on then
local physics = player.obj:get_physics_override()
if is_on == true then
player.obj:set_physics_override(
{
jump = (round(physics.jump,0.01) - 1 + minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
speed = (round(physics.speed,0.01) - 1 + minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
})
elseif player.is_sprinting_physics_on ~= nil then
player.obj:set_physics_override(
{
jump = 1,
speed = 1,
})
end
player.is_sprinting_physics_on = is_on
end
end
elseif minetest.get_modpath("player_monoids") ~= nil then
function minetest_wadsprint.set_sprinting_physics(player,is_on)
if player.is_sprinting_physics_on ~= is_on then
if is_on == true then
player_monoids.jump:add_change(
player.obj,
minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT,
"minetest_wadsprint:jump"
)
player_monoids.speed:add_change(
player.obj,
minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT,
"minetest_wadsprint:speed"
)
elseif player.is_sprinting_physics_on ~= nil then
player_monoids.jump:del_change(player.obj, "minetest_wadsprint:jump")
player_monoids.speed:del_change(player.obj, "minetest_wadsprint:speed")
end
player.is_sprinting_physics_on = is_on
end
end
else
function minetest_wadsprint.set_sprinting_physics(player,is_on)
if player.is_sprinting_physics_on ~= is_on then
local physics = player.obj:get_physics_override()
if is_on == true then
player.obj:set_physics_override(
{
jump = (round(physics.jump,0.01) - 1 + minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
speed = (round(physics.speed,0.01) - 1 + minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
})
elseif player.is_sprinting_physics_on ~= nil then
player.obj:set_physics_override(
{
jump = (round(physics.jump,0.01) + 1 - minetest_wadsprint.SPRINT_JUMP_HEIGHT_BOOST_COEFFICIENT),
speed = (round(physics.speed,0.01) + 1 - minetest_wadsprint.SPRINT_RUN_SPEED_BOOST_COEFFICIENT),
})
end
player.is_sprinting_physics_on = is_on
end
end
end

4
lib_round.lua Normal file
View File

@ -0,0 +1,4 @@
function round(exact, quantum)
local quant,frac = math.modf(exact/quantum)
return quantum * (quant + (frac > 0.5 and 1 or 0))
end

View File

@ -4,6 +4,9 @@ minetest_wadsprint.ENABLE_INGAME_SETTINGS (ENABLE ALL THE MOD SETTINGS BELOW) bo
# If enabled, stamina HUD bar will not be shown.
minetest_wadsprint.HIDE_HUD_BARS (Hide HUD bars) bool false
# Can be used to establish compatibility with mods that don't support proper physics change or monoids. Strongly not recommended in other cases.
minetest_wadsprint.BAD_PHYSICS_OVERRIDE_MODE (Bad physics override mode) bool false
# Absolutely arbitrary value to make calculations more convenient.
minetest_wadsprint.STAMINA_MAX_VALUE (Stamina max value in points) int 100

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB