ink12345 1 Posted October 14, 2023 I am writing a script and I want to perform certain actions (change attack styles or equip new gear) when hitting level thresholds. I have written an ExperienceListener and overridden the onLevelUp method, and am logging the skill along with the level that was reached class LevelTracker implements ExperienceListener { @Override public void onLevelUp(ExperienceEvent e) { log("Leveled up " + e.getSkill().toString() + " to " + Skills.getRealLevel(e.getSkill())); } } However Skills.getRealLevel() always seems to return the previous level rather than the new one. For example, if I just hit 20 attack, it would log "Leveled up Attack to level 19". Is this intended? Should I just use Skills.getRealLevel() + 1 for this type of action?
sloppybot 18 Posted October 15, 2023 1 hour ago, ink12345 said: I am writing a script and I want to perform certain actions (change attack styles or equip new gear) when hitting level thresholds. I have written an ExperienceListener and overridden the onLevelUp method, and am logging the skill along with the level that was reached class LevelTracker implements ExperienceListener { @Override public void onLevelUp(ExperienceEvent e) { log("Leveled up " + e.getSkill().toString() + " to " + Skills.getRealLevel(e.getSkill())); } } However Skills.getRealLevel() always seems to return the previous level rather than the new one. For example, if I just hit 20 attack, it would log "Leveled up Attack to level 19". Is this intended? Should I just use Skills.getRealLevel() + 1 for this type of action? Did you start SkillTracker? SkillTracker.start(); // Starts tracking all skills SkillTracker.start(Skill skillA, Skill skillB,....); // Starts tracking defined Skills
Hashtag 8987 Posted October 15, 2023 It's possible it's intended, I'm not sure. But instead of doing Skills.getLevel(e.getSkill()) + 1 you should be doing Skills.getLevel(e.getSkill()) + e.getChange() in case you level up multiple levels at once. That's more common in quests, but just to be sure. sloppybot and ink12345 1 1
sloppybot 18 Posted October 15, 2023 (edited) 1 hour ago, Hashtag said: It's possible it's intended, I'm not sure. But instead of doing Skills.getLevel(e.getSkill()) + 1 you should be doing Skills.getLevel(e.getSkill()) + e.getChange() in case you level up multiple levels at once. That's more common in quests, but just to be sure. It's always a good idea to follow best practices, even when they may not seem necessary at first. 👍 Edited October 15, 2023 by sloppybot ink12345 1
ink12345 1 Author Posted October 15, 2023 I am not sure what the skill tracker would help with in this situation, even after gaining multiple levels the log message was always the level that was leveled up from. I implemented it using getRealLevel() + getChange() and it's been working fine that way. Thanks!
sloppybot 18 Posted October 15, 2023 (edited) 11 minutes ago, ink12345 said: I am not sure what the skill tracker would help with in this situation, even after gaining multiple levels the log message was always the level that was leveled up from. I implemented it using getRealLevel() + getChange() and it's been working fine that way. Thanks! I apologize for the misunderstanding. I was reading the forums while waiting for my taxi to the airport, and I had only gotten 3.5 hours of sleep, which led to me completely misinterpreting the question. Glad you got the help you needed. Edited October 15, 2023 by sloppybot
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now