mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-12-17 23:55:23 +01:00
[mff_pclasses] Stop using asbolute stats values
- Stop using absolute stats values for stamina and manamax when you can add/subtract in on_assign and on_unassign - Use on_update for hunters to determine whether or not to add the sprint bonus from the full reinforced leather armor set
This commit is contained in:
@@ -6,28 +6,33 @@
|
||||
-- See https://github.com/Ombridride/minetest-minetestforfun-server/issues/114
|
||||
--
|
||||
|
||||
local tmp = {}
|
||||
|
||||
pclasses.api.register_class("hunter", {
|
||||
on_assigned = function(pname, inform)
|
||||
if inform then
|
||||
minetest.chat_send_player(pname, "You are now a hunter")
|
||||
minetest.sound_play("pclasses_full_hunter", {to_player=pname, gain=1})
|
||||
end
|
||||
sprint.increase_maxstamina(pname, 10)
|
||||
minetest.log("action", "[PClasses] Player " .. pname .. " become a hunter")
|
||||
end,
|
||||
on_unassigned = function(pname)
|
||||
sprint.set_default_maxstamina(pname)
|
||||
sprint.decrease_maxstamina(pname, 10)
|
||||
end,
|
||||
on_update = function(pname)
|
||||
local staminavalue = 30
|
||||
local manavalue = 100
|
||||
local reinforced = pclasses.api.util.does_wear_full_armor(pname, "reinforcedleather", true)
|
||||
if reinforced then
|
||||
staminavalue = staminavalue + 20
|
||||
if not tmp[pname] then
|
||||
tmp[pname] = true
|
||||
sprint.increase_maxstamina(pname, 10) -- 10 more
|
||||
end
|
||||
else
|
||||
staminavalue = staminavalue + 10
|
||||
if tmp[pname] then
|
||||
tmp[pname] = false
|
||||
sprint.decrease_maxstamina(pname, 10)
|
||||
end
|
||||
end
|
||||
sprint.set_maxstamina(pname, staminavalue)
|
||||
mana.setmax(pname, manavalue)
|
||||
end,
|
||||
switch_params = {
|
||||
color = {r = 30, g = 170, b = 00},
|
||||
|
||||
Reference in New Issue
Block a user