Skip to content

Commit 9c30dbc

Browse files
committed
Fixed expertise abilities
1 parent fac85f5 commit 9c30dbc

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

src/services/SkillService.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import org.apache.mina.core.buffer.IoBuffer;
2828
import org.apache.mina.core.session.IoSession;
29+
import org.python.core.Py;
30+
import org.python.core.PyObject;
2931

3032
import protocol.swg.ExpertiseRequestMessage;
3133

@@ -147,10 +149,32 @@ public void addSkill(CreatureObject creature, String skill) {
147149
}
148150
}
149151

150-
if(!skill.contains("expertise")) { // only mark 1 abilities in datatable need to remove abilities per script
152+
if (skill.contains("expertise")) {
153+
if (FileUtilities.doesFileExist("scripts/expertise/" + skill + ".py")) {
154+
PyObject method = core.scriptService.getMethod("scripts/expertise/", skill, "addAbilities");
155+
156+
if (method != null && method.isCallable()) {
157+
method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(player));
158+
}
159+
}
160+
} else {
151161
for (String ability : abilities) {
152162
creature.addAbility(ability);
153163
}
164+
165+
// When leveling, add all new unadded expertise abilities
166+
// It's up to the script to not add abilities that are already added
167+
for (String expertiseName : creature.getSkills()) {
168+
if (expertiseName.startsWith("expertise")) {
169+
if (FileUtilities.doesFileExist("scripts/expertise/" + expertiseName + ".py")) {
170+
PyObject method = core.scriptService.getMethod("scripts/expertise/", expertiseName, "addAbilities");
171+
172+
if (method != null && method.isCallable()) {
173+
method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(player));
174+
}
175+
}
176+
}
177+
}
154178
}
155179

156180
for (String skillMod : skillMods) {
@@ -214,7 +238,15 @@ public void removeSkill(CreatureObject creature, String skill) {
214238
//creature.addExpertisePoints(pointsRequired);
215239
}
216240

217-
if(!skill.contains("expertise")) { // only mark 1 abilities in datatable need to remove abilities per script
241+
if (skill.contains("expertise")) {
242+
if (FileUtilities.doesFileExist("scripts/expertise/" + skill + ".py")) {
243+
PyObject method = core.scriptService.getMethod("scripts/expertise/", skill, "removeAbilities");
244+
245+
if (method != null && method.isCallable()) {
246+
method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(player));
247+
}
248+
}
249+
} else {
218250
for (String ability : abilities) {
219251
creature.removeAbility(ability);
220252
}
@@ -271,12 +303,8 @@ public void handlePacket(IoSession session, IoBuffer buffer) throws Exception {
271303
return;
272304

273305
for(String expertiseName : expertise.getExpertiseSkills()) {
274-
if(expertiseName.startsWith("expertise_") && ((caluclateExpertisePoints(creature) - 1) >= 0)) // Prevent possible glitches/exploits
275-
{
306+
if(expertiseName.startsWith("expertise_") && ((caluclateExpertisePoints(creature) - 1) >= 0)) { // Prevent possible glitches/exploits
276307
addSkill(creature, expertiseName);
277-
if(!FileUtilities.doesFileExist("scripts/expertise/" + expertiseName + ".py"))
278-
continue;
279-
core.scriptService.callScript("scripts/expertise/", expertiseName, "addAbilities", core, creature, player);
280308
}
281309
}
282310
}

0 commit comments

Comments
 (0)