1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 02:00:37 +01:00

improve pclasses to fix class stats don't change on equip/unequip/destroy armor

This commit is contained in:
crabman77 2017-04-08 18:23:57 +02:00 committed by LeMagnesium
parent 5786374fe3
commit ee58c4930f
8 changed files with 50 additions and 8 deletions

View File

@ -249,6 +249,7 @@ armor.set_player_armor = function(self, player)
player:set_armor_groups(armor_groups)
--player:set_physics_override(physics_o)
player_physics.set_stats(player, "3d_armor", {speed=physics_o.speed-1, jump=physics_o.jump-1, gravity=physics_o.gravity-1})
pclasses.api.util.on_update(name)
self.textures[name].armor = armor_texture
self.textures[name].preview = preview
self.def[name].state = state

View File

@ -11,9 +11,12 @@ pclasses.api.register_class("admin", {
if inform then
minetest.chat_send_player(pname, "Hello admin.")
end
pclasses.api.util.on_update(pname)
end,
on_unassigned = function(pname)
end,
on_update = function(pname)
end,
switch_params = {
color = {r = 255, g = 00, b = 224},
holo_item = "maptools:pick_admin"

View File

@ -12,17 +12,24 @@ pclasses.api.register_class("hunter", {
minetest.chat_send_player(pname, "You are now a hunter")
minetest.sound_play("pclasses_full_hunter", {to_player=pname, gain=1})
end
local reinforced = pclasses.api.util.does_wear_full_armor(pname, "reinforcedleather", true)
if reinforced then
sprint.increase_maxstamina(pname, 40)
else
sprint.increase_maxstamina(pname, 30)
end
pclasses.api.util.on_update(pname)
minetest.log("action", "[PClasses] Player " .. pname .. " become a hunter")
end,
on_unassigned = function(pname)
sprint.set_default_maxstamina(pname)
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
else
staminavalue = staminavalue + 10
end
sprint.set_maxstamina(pname, staminavalue)
mana.setmax(pname, manavalue)
end,
switch_params = {
color = {r = 30, g = 170, b = 00},
tile = "default_wood.png",

View File

@ -12,12 +12,18 @@ pclasses.api.register_class("warrior", {
minetest.sound_play("pclasses_full_warrior", {to_player=pname, gain=1})
minetest.chat_send_player(pname, "You are now a warrior")
end
sprint.set_maxstamina(pname, 20)
pclasses.api.util.on_update(pname)
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a warrior")
end,
on_unassigned = function(pname)
sprint.set_default_maxstamina(pname)
end,
on_update = function(pname)
local staminavalue = 20
local manavalue = 100
sprint.set_maxstamina(pname, staminavalue)
mana.setmax(pname, manavalue)
end,
switch_params = {
color = {r = 06, g = 06, b = 30},
tile = "default_steel_block.png",

View File

@ -13,12 +13,18 @@ pclasses.api.register_class("wizard", {
minetest.chat_send_player(pname, "You are now a wizard.")
end
-- Add specs here
mana.setmax(pname, mana.getmax(pname)+100)
pclasses.api.util.on_update(pname)
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a wizard")
end,
on_unassigned = function(pname)
mana.setmax(pname, mana.getmax(pname)-100)
end,
on_update = function(pname)
local staminavalue = 30
local manavalue = 200
sprint.set_maxstamina(pname, staminavalue)
mana.setmax(pname, manavalue)
end,
switch_params = {
color = {r = 230, g = 230, b = 0},
holo_item = "default:book"

View File

@ -42,6 +42,7 @@ Yet another class mod for Minetest.
- Def is a definition table that can contain many functions/values :
- `on_assigned` which is a function, receiving as argument the player name
- `on_unassigned` which is a function, receiving as argument the player name
- `on_update` which is a function, receiving as argument the player name
- `switch_params`, which is a table, containing parameters for the switch pedestal :
- `holo_item` is mandatory. It's the itemstring of the item to be put over the pedestal
- `color` is optional. Default is white. It's a RGB table.
@ -78,6 +79,10 @@ Yet another class mod for Minetest.
- Arguments : pname, itemname
- Returns true if player `pname` can have items `itemstring` in his main inventory, according to his class
### pclasses.api.util.on_update
- Arguments : pname
- Update player's stats
### pclasses.api.reserve_item
- Arguments : cname, itemstring
- Adds an entry in the reserved items' table. Players will need to belong to class `cname` in order to have items `itemstring` in their main inventory

View File

@ -12,9 +12,16 @@ pclasses.api.register_class("adventurer", {
if inform then
minetest.chat_send_player(pname, "You are now an adventurer")
end
pclasses.api.util.on_update(pname)
end,
on_unassigned = function(pname)
end,
on_update = function(pname)
local staminavalue = 10
local manavalue = 100
sprint.set_maxstamina(pname, staminavalue)
mana.setmax(pname, manavalue)
end,
informations = pclasses.api.textify("Adventurer, the casual players, or hardcore players. Whatever end of the spectrum\n" ..
"you're in, adventurer will bring you what you want : no advantages, no help. Maybe you\n" ..
"don't want that if you just began playing. If that's the case.. just pick another tab and\n" ..

View File

@ -100,6 +100,13 @@ function pclasses.api.util.can_have_item(pname, itemname)
return false
end
function pclasses.api.util.on_update(pname)
local cname = pclasses.api.get_player_class(pname)
if cname ~= nil and pclasses.api.get_class_by_name(cname) and pclasses.api.get_class_by_name(cname).on_update then
pclasses.api.get_class_by_name(cname).on_update(pname)
end
end
-- TEMPORARY CLASS SHIFT SYSTEM
-- Used to test on local servers
--