srunobantana
Active Member
- Joined
- Oct 24, 2021
- Messages
- 55
- Reaction score
- 34
By Google translation
My idea is that the player should not receive any XP if they do not meet the requirements defined in "MonsterRequirements" (exp_block.lua). This is already working properly when the player is alone.
However, when the player is in a party, the current system still allows everyone to gain XP. What I want is that if any member of the party fails to meet the requirements, then no one in the party should receive XP.
I also want the monster to drop no loot at all if it is killed by a player or a party that does not meet the "MonsterRequirements".
I would really appreciate if someone could help me with this or at least point me in the right direction to implement it properly, even if it’s just a guide on how to structure the logic within the scripts. I already have part of the system working, but I'm not sure how to apply this to party XP and loot behavior.
My idea is that the player should not receive any XP if they do not meet the requirements defined in "MonsterRequirements" (exp_block.lua). This is already working properly when the player is alone.
However, when the player is in a party, the current system still allows everyone to gain XP. What I want is that if any member of the party fails to meet the requirements, then no one in the party should receive XP.
I also want the monster to drop no loot at all if it is killed by a player or a party that does not meet the "MonsterRequirements".
I would really appreciate if someone could help me with this or at least point me in the right direction to implement it properly, even if it’s just a guide on how to structure the logic within the scripts. I already have part of the system working, but I'm not sure how to apply this to party XP and loot behavior.
Code:
function Player:onGainExperience(source, exp, rawExp)
if not source or source:isPlayer() then
return exp
end
local monsterName = source:getName()
local requirements = MonsterRequirements[monsterName]
if not requirements then
return hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
end
if self:getLevel() < requirements.level then
self:sendTextMessage(MESSAGE_STATUS_WARNING,
string.format("Requisito: Level %d (seu: %d) para enfrentar %s.",
requirements.level, self:getLevel(), monsterName))
return 0
end
if self:getRebirth() < requirements.rebirth then
self:sendTextMessage(MESSAGE_STATUS_WARNING,
string.format("Requisito: Rebirth %d (seu: %d) para enfrentar %s.",
requirements.rebirth, self:getRebirth(), monsterName))
return 0
end
local vocation = self:getVocation()
if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
self:addCondition(soulCondition)
end
exp = exp * Game.getExperienceStage(self:getLevel())
if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
useStamina(self)
local staminaMinutes = self:getStamina()
if staminaMinutes > 2400 and self:isPremium() then
exp = exp * 1.5
elseif staminaMinutes <= 840 then
exp = exp * 0.5
end
end
return hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
end
LUA:
MonsterRequirements = {
["Gang Member"] = {level = 50, rebirth = 0},
["Assassin"] = {level = 80, rebirth = 2},
}
local function printMonsterRequirements()
print("\n=== MONSTER REQUIREMENTS ===")
for monsterName, req in pairs(MonsterRequirements) do
print(string.format("%s: Level %d, Rebirth %d", monsterName, req.level, req.rebirth))
end
print("==========================\n")
end
printMonsterRequirements()