Feature: Monoids support for speed and jump; Bad physics override mode.
parent
4c25bf9273
commit
231c0c2c77
|
@ -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
|
||||
|
|
23
init.lua
23
init.lua
|
@ -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() --
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
BIN
util/version.png
BIN
util/version.png
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue