mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-06 21:12:59 -04:00
addCollection adds reward XP
This commit is contained in:
@@ -38,7 +38,6 @@ import main.NGECore;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.StfTable;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
@@ -360,6 +359,76 @@ public class CollectionService implements INetworkDispatch {
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_collection_complete", "TO", "@collection_n:" + collectionName), DisplayType.Broadcast);
|
||||
|
||||
if (!noReward) {
|
||||
try {
|
||||
StfTable stf = new StfTable("clientdata/string/en/collection_reward.stf");
|
||||
|
||||
for (int s = 1; s < stf.getRowCount(); s++) {
|
||||
String key = stf.getStringById(s).getKey();
|
||||
|
||||
if (key != null && key.equals(collectionName)) {
|
||||
String reward = stf.getStringById(s).getValue();
|
||||
|
||||
if (reward != null && reward.length() > 0) {
|
||||
int xp = 0;
|
||||
|
||||
// Give experience
|
||||
|
||||
try {
|
||||
DatatableVisitor experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class);
|
||||
|
||||
for (int i = 0; i < experienceTable.getRowCount(); i++) {
|
||||
if (experienceTable.getObject(i, 0) != null) {
|
||||
if (creature.getLevel() == (Integer) experienceTable.getObject(i, 0)) {
|
||||
int nextLevelRequiredXp = (Integer) experienceTable.getObject((i + 1), 1);
|
||||
int currentLevelRequiredXp = (Integer) experienceTable.getObject(i, 1);
|
||||
xp = nextLevelRequiredXp - currentLevelRequiredXp;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (reward.contains("small amount of XP")) {
|
||||
xp = 10 / 100 * xp;
|
||||
} else if (reward.contains("medium amount of XP")) {
|
||||
xp = 20 / 100 * xp;
|
||||
} else if (reward.contains("large amount of XP")) {
|
||||
xp = 30 / 100 * xp;
|
||||
} else if (reward.contains("Space XP")) {
|
||||
// TODO calculate space XP
|
||||
} else if (reward.contains("XP")) {
|
||||
String[] array = reward.split(" ");
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i].equals("XP")) {
|
||||
if (i == 0) {
|
||||
xp = 20 / 100 * xp;
|
||||
} else {
|
||||
try {
|
||||
xp = Integer.parseInt(array[i - 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
xp = 20 / 100 * xp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (xp > 0) {
|
||||
if (key.contains("space")) {
|
||||
// TODO add XP to space (not currently implemented)
|
||||
} else {
|
||||
core.playerService.giveExperience(creature, xp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (FileUtilities.doesFileExist("scripts/collections/" + collectionName + ".py")) {
|
||||
PyObject method = core.scriptService.getMethod("scripts/collections/", collectionName, "complete");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user