|
26 | 26 |
|
27 | 27 | import org.apache.mina.core.buffer.IoBuffer; |
28 | 28 | import org.apache.mina.core.session.IoSession; |
| 29 | +import org.python.core.Py; |
| 30 | +import org.python.core.PyObject; |
29 | 31 |
|
30 | 32 | import protocol.swg.ExpertiseRequestMessage; |
31 | 33 |
|
@@ -147,10 +149,32 @@ public void addSkill(CreatureObject creature, String skill) { |
147 | 149 | } |
148 | 150 | } |
149 | 151 |
|
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 { |
151 | 161 | for (String ability : abilities) { |
152 | 162 | creature.addAbility(ability); |
153 | 163 | } |
| 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 | + } |
154 | 178 | } |
155 | 179 |
|
156 | 180 | for (String skillMod : skillMods) { |
@@ -214,7 +238,15 @@ public void removeSkill(CreatureObject creature, String skill) { |
214 | 238 | //creature.addExpertisePoints(pointsRequired); |
215 | 239 | } |
216 | 240 |
|
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 { |
218 | 250 | for (String ability : abilities) { |
219 | 251 | creature.removeAbility(ability); |
220 | 252 | } |
@@ -271,12 +303,8 @@ public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { |
271 | 303 | return; |
272 | 304 |
|
273 | 305 | 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 |
276 | 307 | addSkill(creature, expertiseName); |
277 | | - if(!FileUtilities.doesFileExist("scripts/expertise/" + expertiseName + ".py")) |
278 | | - continue; |
279 | | - core.scriptService.callScript("scripts/expertise/", expertiseName, "addAbilities", core, creature, player); |
280 | 308 | } |
281 | 309 | } |
282 | 310 | } |
|
0 commit comments