From d00aa83050cbcd34fc9c1f9cd4d1752c27d4a207 Mon Sep 17 00:00:00 2001 From: Seefo Date: Sun, 23 Mar 2014 12:27:42 -0400 Subject: [PATCH] Fixed a few exploits. See extended. Skills obtained through the expertise system are now validated to make sure they are legitimate expertise skills. Player expertise points are also now factored in instead of letting the client do all the calculations. Command "setcurrentskilltitle" now checks if the player has obtained the skill title to prevent abuse of the command. --- scripts/commands/setcurrentskilltitle.py | 3 ++- src/services/SkillService.java | 29 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/commands/setcurrentskilltitle.py b/scripts/commands/setcurrentskilltitle.py index 43e9e5f4..160c9091 100644 --- a/scripts/commands/setcurrentskilltitle.py +++ b/scripts/commands/setcurrentskilltitle.py @@ -11,5 +11,6 @@ def run(core, actor, target, commandString): if playerObject is None: return - playerObject.setTitle(str(commandString)) + if str(commandString) in playerObject.getTitleList() or str(commandString) == "citizenship" or str(commandString) == "": playerObject.setTitle(str(commandString)) + return \ No newline at end of file diff --git a/src/services/SkillService.java b/src/services/SkillService.java index de024d6d..c3926f7b 100644 --- a/src/services/SkillService.java +++ b/src/services/SkillService.java @@ -271,16 +271,33 @@ public class SkillService implements INetworkDispatch { return; for(String expertiseName : expertise.getExpertiseSkills()) { - addSkill(creature, expertiseName); - if(!FileUtilities.doesFileExist("scripts/expertise/" + expertiseName + ".py")) - continue; - core.scriptService.callScript("scripts/expertise/", expertiseName, "addAbilities", core, creature, player); - } - + if(expertiseName.startsWith("expertise_") && ((caluclateExpertisePoints(creature) - 1) > 0)) // Prevent possible glitches/exploits + { + addSkill(creature, expertiseName); + if(!FileUtilities.doesFileExist("scripts/expertise/" + expertiseName + ".py")) + continue; + core.scriptService.callScript("scripts/expertise/", expertiseName, "addAbilities", core, creature, player); + } + } } }); } + + public int caluclateExpertisePoints(CreatureObject creature) + { + int expertisePoints = 0; + + try + { + DatatableVisitor table = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class); + for (int i = 0; i <= creature.getLevel(); i++) expertisePoints += (int) table.getObject(i, 5); + } + catch (Exception e) { e.printStackTrace(); } + + System.out.println("Player should have " + expertisePoints + " expertise points."); + return expertisePoints; + } @Override public void shutdown() {