mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 18:20:36 +01:00
improve pclasses to fix class stats don't change on equip/unequip/destroy armor
This commit is contained in:
parent
5786374fe3
commit
ee58c4930f
@ -249,6 +249,7 @@ armor.set_player_armor = function(self, player)
|
|||||||
player:set_armor_groups(armor_groups)
|
player:set_armor_groups(armor_groups)
|
||||||
--player:set_physics_override(physics_o)
|
--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})
|
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].armor = armor_texture
|
||||||
self.textures[name].preview = preview
|
self.textures[name].preview = preview
|
||||||
self.def[name].state = state
|
self.def[name].state = state
|
||||||
|
@ -11,9 +11,12 @@ pclasses.api.register_class("admin", {
|
|||||||
if inform then
|
if inform then
|
||||||
minetest.chat_send_player(pname, "Hello admin.")
|
minetest.chat_send_player(pname, "Hello admin.")
|
||||||
end
|
end
|
||||||
|
pclasses.api.util.on_update(pname)
|
||||||
end,
|
end,
|
||||||
on_unassigned = function(pname)
|
on_unassigned = function(pname)
|
||||||
end,
|
end,
|
||||||
|
on_update = function(pname)
|
||||||
|
end,
|
||||||
switch_params = {
|
switch_params = {
|
||||||
color = {r = 255, g = 00, b = 224},
|
color = {r = 255, g = 00, b = 224},
|
||||||
holo_item = "maptools:pick_admin"
|
holo_item = "maptools:pick_admin"
|
||||||
|
@ -12,17 +12,24 @@ pclasses.api.register_class("hunter", {
|
|||||||
minetest.chat_send_player(pname, "You are now a hunter")
|
minetest.chat_send_player(pname, "You are now a hunter")
|
||||||
minetest.sound_play("pclasses_full_hunter", {to_player=pname, gain=1})
|
minetest.sound_play("pclasses_full_hunter", {to_player=pname, gain=1})
|
||||||
end
|
end
|
||||||
local reinforced = pclasses.api.util.does_wear_full_armor(pname, "reinforcedleather", true)
|
pclasses.api.util.on_update(pname)
|
||||||
if reinforced then
|
|
||||||
sprint.increase_maxstamina(pname, 40)
|
|
||||||
else
|
|
||||||
sprint.increase_maxstamina(pname, 30)
|
|
||||||
end
|
|
||||||
minetest.log("action", "[PClasses] Player " .. pname .. " become a hunter")
|
minetest.log("action", "[PClasses] Player " .. pname .. " become a hunter")
|
||||||
end,
|
end,
|
||||||
on_unassigned = function(pname)
|
on_unassigned = function(pname)
|
||||||
sprint.set_default_maxstamina(pname)
|
sprint.set_default_maxstamina(pname)
|
||||||
end,
|
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 = {
|
switch_params = {
|
||||||
color = {r = 30, g = 170, b = 00},
|
color = {r = 30, g = 170, b = 00},
|
||||||
tile = "default_wood.png",
|
tile = "default_wood.png",
|
||||||
|
@ -12,12 +12,18 @@ pclasses.api.register_class("warrior", {
|
|||||||
minetest.sound_play("pclasses_full_warrior", {to_player=pname, gain=1})
|
minetest.sound_play("pclasses_full_warrior", {to_player=pname, gain=1})
|
||||||
minetest.chat_send_player(pname, "You are now a warrior")
|
minetest.chat_send_player(pname, "You are now a warrior")
|
||||||
end
|
end
|
||||||
sprint.set_maxstamina(pname, 20)
|
pclasses.api.util.on_update(pname)
|
||||||
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a warrior")
|
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a warrior")
|
||||||
end,
|
end,
|
||||||
on_unassigned = function(pname)
|
on_unassigned = function(pname)
|
||||||
sprint.set_default_maxstamina(pname)
|
sprint.set_default_maxstamina(pname)
|
||||||
end,
|
end,
|
||||||
|
on_update = function(pname)
|
||||||
|
local staminavalue = 20
|
||||||
|
local manavalue = 100
|
||||||
|
sprint.set_maxstamina(pname, staminavalue)
|
||||||
|
mana.setmax(pname, manavalue)
|
||||||
|
end,
|
||||||
switch_params = {
|
switch_params = {
|
||||||
color = {r = 06, g = 06, b = 30},
|
color = {r = 06, g = 06, b = 30},
|
||||||
tile = "default_steel_block.png",
|
tile = "default_steel_block.png",
|
||||||
|
@ -13,12 +13,18 @@ pclasses.api.register_class("wizard", {
|
|||||||
minetest.chat_send_player(pname, "You are now a wizard.")
|
minetest.chat_send_player(pname, "You are now a wizard.")
|
||||||
end
|
end
|
||||||
-- Add specs here
|
-- 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")
|
minetest.log("action", "[PClasses] Player " .. pname .. " becomes a wizard")
|
||||||
end,
|
end,
|
||||||
on_unassigned = function(pname)
|
on_unassigned = function(pname)
|
||||||
mana.setmax(pname, mana.getmax(pname)-100)
|
mana.setmax(pname, mana.getmax(pname)-100)
|
||||||
end,
|
end,
|
||||||
|
on_update = function(pname)
|
||||||
|
local staminavalue = 30
|
||||||
|
local manavalue = 200
|
||||||
|
sprint.set_maxstamina(pname, staminavalue)
|
||||||
|
mana.setmax(pname, manavalue)
|
||||||
|
end,
|
||||||
switch_params = {
|
switch_params = {
|
||||||
color = {r = 230, g = 230, b = 0},
|
color = {r = 230, g = 230, b = 0},
|
||||||
holo_item = "default:book"
|
holo_item = "default:book"
|
||||||
|
@ -42,6 +42,7 @@ Yet another class mod for Minetest.
|
|||||||
- Def is a definition table that can contain many functions/values :
|
- Def is a definition table that can contain many functions/values :
|
||||||
- `on_assigned` which is a function, receiving as argument the player name
|
- `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_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 :
|
- `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
|
- `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.
|
- `color` is optional. Default is white. It's a RGB table.
|
||||||
@ -78,6 +79,10 @@ Yet another class mod for Minetest.
|
|||||||
- Arguments : pname, itemname
|
- Arguments : pname, itemname
|
||||||
- Returns true if player `pname` can have items `itemstring` in his main inventory, according to his class
|
- 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
|
### pclasses.api.reserve_item
|
||||||
- Arguments : cname, itemstring
|
- 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
|
- 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
|
||||||
|
@ -12,9 +12,16 @@ pclasses.api.register_class("adventurer", {
|
|||||||
if inform then
|
if inform then
|
||||||
minetest.chat_send_player(pname, "You are now an adventurer")
|
minetest.chat_send_player(pname, "You are now an adventurer")
|
||||||
end
|
end
|
||||||
|
pclasses.api.util.on_update(pname)
|
||||||
end,
|
end,
|
||||||
on_unassigned = function(pname)
|
on_unassigned = function(pname)
|
||||||
end,
|
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" ..
|
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" ..
|
"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" ..
|
"don't want that if you just began playing. If that's the case.. just pick another tab and\n" ..
|
||||||
|
@ -100,6 +100,13 @@ function pclasses.api.util.can_have_item(pname, itemname)
|
|||||||
return false
|
return false
|
||||||
end
|
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
|
-- TEMPORARY CLASS SHIFT SYSTEM
|
||||||
-- Used to test on local servers
|
-- Used to test on local servers
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user