Adapt playerplus mod

This commit is contained in:
philipmi 2021-06-03 16:46:57 +02:00
parent 6cedcc7b84
commit d05b22e38d
3 changed files with 26 additions and 72 deletions

View file

@ -1,4 +0,0 @@
default?
3d_armor?
player_monoids?
pova?

View file

@ -13,10 +13,6 @@ playerplus = {}
-- detect minetest 5.0 -- detect minetest 5.0
local mt50 = minetest.registered_nodes["default:permafrost"] local mt50 = minetest.registered_nodes["default:permafrost"]
-- cache if player_monoids mod active?
local monoids = minetest.get_modpath("player_monoids")
local pova_mod = minetest.get_modpath("pova")
-- get node but use fallback for nil or unknown -- get node but use fallback for nil or unknown
local node_ok = function(pos, fallback) local node_ok = function(pos, fallback)
@ -32,7 +28,6 @@ local node_ok = function(pos, fallback)
end end
local armor_mod = minetest.get_modpath("3d_armor")
local time = 0 local time = 0
@ -85,16 +80,6 @@ if name and playerplus[name] then
playerplus[name].nod_feet = node_ok({ playerplus[name].nod_feet = node_ok({
x = pos.x, y = pos.y + 0.2, z = pos.z}) x = pos.x, y = pos.y + 0.2, z = pos.z})
-- get player physics
def = player:get_physics_override()
if armor_mod and armor and armor.def then
-- get player physics from armor
def.speed = armor.def[name].speed or def.speed
def.jump = armor.def[name].jump or def.jump
def.gravity = armor.def[name].gravity or def.gravity
end
-- are we standing on any nodes that speed player up? -- are we standing on any nodes that speed player up?
nfast = nil nfast = nil
if playerplus[name].nod_stand == "default:ice" then if playerplus[name].nod_stand == "default:ice" then
@ -110,78 +95,33 @@ if name and playerplus[name] then
-- apply speed changes -- apply speed changes
if nfast and not playerplus[name].nfast then if nfast and not playerplus[name].nfast then
if monoids then physics.set(name, "playerplus:nfast", {speed = 1.2})
playerplus[name].nfast = player_monoids.speed:add_change(
player, def.speed + 0.4)
elseif pova_mod then
pova.add_override(name, "playerplus:nfast", {speed = 0.4})
pova.do_override(player)
else
def.speed = def.speed + 0.4
end
playerplus[name].nfast = true playerplus[name].nfast = true
elseif not nfast and playerplus[name].nfast then elseif not nfast and playerplus[name].nfast then
if monoids then physics.remove(name, "playerplus:nfast")
player_monoids.speed:del_change(player, playerplus[name].nfast)
playerplus[name].nfast = nil
elseif pova_mod then
pova.del_override(name, "playerplus:nfast")
pova.do_override(player)
else
def.speed = def.speed - 0.4
end
playerplus[name].nfast = nil playerplus[name].nfast = nil
end end
-- apply slowdown changes -- apply slowdown changes
if nslow and not playerplus[name].nslow then if nslow and not playerplus[name].nslow then
if monoids then physics.set(name, "playerplus:nslow", {speed = 0.85})
playerplus[name].nslow = player_monoids.speed:add_change(
player, def.speed - 0.3)
elseif pova_mod then
pova.add_override(name, "playerplus:nslow", {speed = -0.3})
pova.do_override(player)
else
def.speed = def.speed - 0.3
end
playerplus[name].nslow = true playerplus[name].nslow = true
elseif not nslow and playerplus[name].nslow then elseif not nslow and playerplus[name].nslow then
if monoids then physics.remove(name, "playerplus:nslow")
player_monoids.speed:del_change(player, playerplus[name].nslow)
playerplus[name].nslow = nil
elseif pova_mod then
pova.del_override(name, "playerplus:nslow")
pova.do_override(player)
else
def.speed = def.speed + 0.3
end
playerplus[name].nslow = nil playerplus[name].nslow = nil
end end
-- set player physics
if not monoids and not pova_mod then
player:set_physics_override({
speed = def.speed,
jump = def.jump,
gravity = def.gravity
})
end
--[[
print ("Speed: " .. def.speed
.. " / Jump: " .. def.jump
.. " / Gravity: " .. def.gravity)
]]
-- Is player suffocating inside a normal node without no_clip privs? -- Is player suffocating inside a normal node without no_clip privs?
local ndef = minetest.registered_nodes[playerplus[name].nod_head] local ndef = minetest.registered_nodes[playerplus[name].nod_head]
if ndef.walkable == true if not ctf_match.is_in_build_time()
and ndef.walkable == true
and ndef.drowning == 0 and ndef.drowning == 0
and ndef.damage_per_second <= 0 and ndef.damage_per_second <= 0
and ndef.groups.disable_suffocation ~= 1 and ndef.groups.disable_suffocation ~= 1
@ -253,6 +193,14 @@ if minetest.settings:get_bool("player_knockback") == true then
local punchy = function( local punchy = function(
player, hitter, time_from_last_punch, tool_capabilities, dir, damage) player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
-- disable knockback during build time
if ctf_match.is_in_build_time() then return end
-- check if player and hitter are in the same team
if ctf.player(player:get_player_name()).team == ctf.player(hitter:get_player_name()).team then
return
end
if not dir then return end if not dir then return end
-- check if player has 'no_knockback' privelage -- check if player has 'no_knockback' privelage
@ -281,6 +229,16 @@ local punchy = function(
end end
damage = damage + (tool_capabilities.damage_groups[group] or 0) * tmp damage = damage + (tool_capabilities.damage_groups[group] or 0) * tmp
-- limit knockback
if damage > 8 then
damage = 8
end
end
-- disable knockback for swords
if tool_capabilities.damage_groups["sword"] then
damage = 0
end end
-- check for knockback value -- check for knockback value

View file

@ -1,4 +1,4 @@
name = playerplus name = playerplus
depends = depends = ctf_match, physics, ctf
optional_depends = default, 3d_armor, player_monoids, pova optional_depends = default
description = Add speed effects, suffocation and cactus damage to players. description = Add speed effects, suffocation and cactus damage to players.