mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-05 20:12:51 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
This commit is contained in:
+347
-231
@@ -58,19 +58,19 @@ import protocol.swg.ShowHelmet;
|
||||
import protocol.swg.objectControllerObjects.ChangeRoleIconChoice;
|
||||
import protocol.swg.objectControllerObjects.ShowFlyText;
|
||||
import protocol.swg.objectControllerObjects.ShowLootBox;
|
||||
import resources.buffs.Buff;
|
||||
import resources.common.BountyListItem;
|
||||
import resources.common.FileUtilities;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
import resources.common.Opcodes;
|
||||
import resources.common.OutOfBand;
|
||||
import resources.common.ProsePackage;
|
||||
import resources.common.RGB;
|
||||
import resources.common.SpawnPoint;
|
||||
import resources.common.StringUtilities;
|
||||
import resources.datatables.DisplayType;
|
||||
import resources.datatables.Options;
|
||||
import resources.datatables.PlayerFlags;
|
||||
import resources.datatables.Professions;
|
||||
import resources.guild.Guild;
|
||||
import resources.objects.Buff;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
@@ -78,6 +78,7 @@ import resources.objects.player.PlayerMessageBuilder;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
import services.sui.SUIService.InputBoxType;
|
||||
import services.sui.SUIService.ListBoxType;
|
||||
import services.sui.SUIWindow;
|
||||
import services.sui.SUIWindow.Trigger;
|
||||
@@ -88,8 +89,8 @@ import engine.clientdata.visitors.CrcStringTableVisitor;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.common.RGB;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.DraftSchematic;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
@@ -114,16 +115,42 @@ public class PlayerService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public void postZoneIn(final CreatureObject creature) {
|
||||
|
||||
if(schedulers.get(creature.getObjectID()) != null)
|
||||
return;
|
||||
|
||||
List<ScheduledFuture<?>> scheduleList = new ArrayList<ScheduledFuture<?>>();
|
||||
|
||||
scheduleList.add(scheduler.scheduleAtFixedRate(() -> {
|
||||
ServerTimeMessage time = new ServerTimeMessage(core.getGalacticTime() / 1000);
|
||||
IoBuffer packet = time.serialize();
|
||||
creature.getClient().getSession().write(packet);
|
||||
}, 45, 45, TimeUnit.SECONDS));
|
||||
|
||||
scheduleList.add(scheduler.scheduleAtFixedRate(() -> {
|
||||
if (creature.isInStealth() && !creature.getOption(Options.INVULNERABLE) && ((PlayerObject) creature.getSlottedObject("ghost")).getGodLevel() == 0) {
|
||||
List<SWGObject> objects = core.simulationService.get(creature.getPlanet(), creature.getPosition().x, creature.getPosition().z, 64);
|
||||
|
||||
for (SWGObject object : objects) {
|
||||
if (object == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(object instanceof CreatureObject)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CreatureObject observer = (CreatureObject) object;
|
||||
|
||||
int camoflauge = creature.getSkillModBase("camoflauge") - observer.getSkillModBase("detectcamo");
|
||||
camoflauge -= (64 - creature.getPosition().getDistance(observer.getPosition()));
|
||||
|
||||
if (new Random(camoflauge).nextInt() == camoflauge) {
|
||||
creature.setInStealth(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 15, 15, TimeUnit.SECONDS));
|
||||
|
||||
scheduleList.add(scheduler.scheduleAtFixedRate(() -> {
|
||||
PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");
|
||||
player.setTotalPlayTime((int) (player.getTotalPlayTime() + ((System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000)));
|
||||
@@ -133,7 +160,7 @@ public class PlayerService implements INetworkDispatch {
|
||||
|
||||
scheduleList.add(scheduler.scheduleAtFixedRate(() -> {
|
||||
if(creature.getAction() < creature.getMaxAction() && creature.getPosture() != 14) {
|
||||
if(creature.getCombatFlag() == 0)
|
||||
if(!creature.isInCombat())
|
||||
creature.setAction(creature.getAction() + (15 + creature.getLevel() * 5));
|
||||
else
|
||||
creature.setAction(creature.getAction() + ((15 + creature.getLevel() * 5) / 2));
|
||||
@@ -141,10 +168,11 @@ public class PlayerService implements INetworkDispatch {
|
||||
}, 0, 1000, TimeUnit.MILLISECONDS));
|
||||
|
||||
scheduleList.add(scheduler.scheduleAtFixedRate(() -> {
|
||||
if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0 && creature.getPosture() != 13 && creature.getPosture() != 14)
|
||||
if(creature.getHealth() < creature.getMaxHealth() && !creature.isInCombat() && creature.getPosture() != 13 && creature.getPosture() != 14)
|
||||
creature.setHealth(creature.getHealth() + (36 + creature.getLevel() * 4));
|
||||
}, 0, 1000, TimeUnit.MILLISECONDS));
|
||||
schedulers.put(creature.getObjectID(), scheduleList);
|
||||
|
||||
/*final PlayerObject ghost = (PlayerObject) creature.getSlottedObject("ghost");
|
||||
scheduler.schedule(new Runnable() {
|
||||
|
||||
@@ -157,7 +185,6 @@ public class PlayerService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
}, 1, TimeUnit.SECONDS);*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -461,15 +488,15 @@ public class PlayerService implements INetworkDispatch {
|
||||
|
||||
SWGObject preDesignatedCloner = null;
|
||||
|
||||
if(creature.getAttachment("preDesignatedCloner") != null) {
|
||||
preDesignatedCloner = core.objectService.getObject((long) creature.getAttachment("preDesignatedCloner"));
|
||||
if(creature.getPlayerObject().getBindLocation() != 0) {
|
||||
preDesignatedCloner = core.objectService.getObject((long) creature.getPlayerObject().getBindLocation());
|
||||
if(preDesignatedCloner != null)
|
||||
cloneData.put(preDesignatedCloner.getObjectID(), core.mapService.getClosestCityName(preDesignatedCloner) /*+ " (" + String.valueOf(position.getDistance2D(cloner.getPosition())) + "m)"*/);
|
||||
cloneData.put(preDesignatedCloner.getObjectID(), "@base_player:clone_location_registered_select_begin " + core.mapService.getClosestCityName(preDesignatedCloner) + " @base_player:clone_location_registered_select_end");
|
||||
}
|
||||
final long preDesignatedObjectId = (preDesignatedCloner != null) ? preDesignatedCloner.getObjectID() : 0;
|
||||
cloners.stream().filter(c -> c.getObjectID() != preDesignatedObjectId).forEach(c -> cloneData.put(c.getObjectID(), core.mapService.getClosestCityName(c)));
|
||||
|
||||
final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@base_player:revive_title", "Select the desired option and click OK.",
|
||||
final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@base_player:revive_title", "@base_player:clone_prompt_header",
|
||||
cloneData, creature, null, 0);
|
||||
Vector<String> returnList = new Vector<String>();
|
||||
returnList.add("List.lstList:SelectedRow");
|
||||
@@ -526,7 +553,7 @@ public class PlayerService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
creature.setFactionStatus(0);
|
||||
core.buffService.addBuffToCreature(creature, "cloning_sickness");
|
||||
core.buffService.addBuffToCreature(creature, "cloning_sickness", creature);
|
||||
|
||||
}
|
||||
|
||||
@@ -546,12 +573,37 @@ public class PlayerService implements INetworkDispatch {
|
||||
return;
|
||||
}
|
||||
|
||||
player.setProfession(profession);
|
||||
|
||||
String xpType = ((profession.contains("entertainer")) ? "entertainer" : ((profession.contains("trader")) ? "crafting" : "combat_general"));
|
||||
|
||||
int experience = player.getXp(xpType);
|
||||
|
||||
// Remove old profession abilties
|
||||
|
||||
try {
|
||||
String[] skills;
|
||||
|
||||
DatatableVisitor skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class);
|
||||
|
||||
for (int s = 0; s < skillTemplate.getRowCount(); s++) {
|
||||
if (skillTemplate.getObject(s, 0) != null) {
|
||||
if (((String) skillTemplate.getObject(s, 0)).equals(player.getProfession())) {
|
||||
skills = ((String) skillTemplate.getObject(s, 4)).split(",");
|
||||
|
||||
for (String skill : skills) {
|
||||
core.skillService.removeSkill(creature, skill);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
core.skillService.resetExpertise(creature);
|
||||
|
||||
player.setProfession(profession);
|
||||
|
||||
try {
|
||||
experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class);
|
||||
|
||||
@@ -577,25 +629,27 @@ public class PlayerService implements INetworkDispatch {
|
||||
public void resetLevel(CreatureObject creature) {
|
||||
PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");
|
||||
|
||||
try
|
||||
{
|
||||
for (SWGObject equipment : new ArrayList<SWGObject>(creature.getEquipmentList())) {
|
||||
if (equipment == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (equipment.getTemplate()) {
|
||||
case "object/tangible/inventory/shared_character_inventory.iff":
|
||||
case "object/tangible/inventory/shared_appearance_inventory.iff":
|
||||
case "object/tangible/datapad/shared_character_datapad.iff":
|
||||
case "object/tangible/bank/shared_character_bank.iff":
|
||||
case "object/tangible/mission_bag/shared_mission_bag.iff":
|
||||
case "object/weapon/creature/shared_creature_default_weapon.iff":
|
||||
continue;
|
||||
default:
|
||||
core.equipmentService.unequip(creature, equipment);
|
||||
}
|
||||
try {
|
||||
for (Long equipmentId : new ArrayList<Long>(creature.getEquipmentList())) {
|
||||
|
||||
SWGObject equipment = core.objectService.getObject(equipmentId);
|
||||
|
||||
if (equipment == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (equipment.getTemplate()) {
|
||||
case "object/tangible/inventory/shared_character_inventory.iff":
|
||||
case "object/tangible/inventory/shared_appearance_inventory.iff":
|
||||
case "object/tangible/datapad/shared_character_datapad.iff":
|
||||
case "object/tangible/bank/shared_character_bank.iff":
|
||||
case "object/tangible/mission_bag/shared_mission_bag.iff":
|
||||
case "object/weapon/creature/shared_creature_default_weapon.iff":
|
||||
continue;
|
||||
default:
|
||||
core.equipmentService.unequip(creature, equipment);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -738,18 +792,20 @@ public class PlayerService implements INetworkDispatch {
|
||||
|
||||
int arrayLength = items.length;
|
||||
|
||||
if (wookieeItems.length > 0 && creature.getStfName().contains("wookiee"))
|
||||
if (wookieeItems.length > 0 && creature.getStfName().contains("wookiee")) {
|
||||
arrayLength = wookieeItems.length;
|
||||
else if (ithorianItems.length > 0 && creature.getStfName().contains("ithorian"))
|
||||
} else if (ithorianItems.length > 0 && creature.getStfName().contains("ithorian")) {
|
||||
arrayLength = ithorianItems.length;
|
||||
|
||||
}
|
||||
|
||||
for (int n = 0; n < arrayLength; n++) {
|
||||
String item = items[n];
|
||||
|
||||
if (creature.getStfName().contains("wookiee"))
|
||||
if (creature.getStfName().contains("wookiee")) {
|
||||
item = wookieeItems[n];
|
||||
else if (creature.getStfName().contains("ithorian"))
|
||||
} else if (creature.getStfName().contains("ithorian")) {
|
||||
item = ithorianItems[n];
|
||||
}
|
||||
|
||||
try {
|
||||
String customServerTemplate = null;
|
||||
@@ -769,8 +825,7 @@ public class PlayerService implements INetworkDispatch {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -847,194 +902,195 @@ public class PlayerService implements INetworkDispatch {
|
||||
return;
|
||||
}
|
||||
|
||||
//synchronized(objectMutex) {
|
||||
try {
|
||||
experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class);
|
||||
|
||||
// Cannot gain more than half of the XP needed for the next level in one go
|
||||
// Do check
|
||||
|
||||
int experienceBonus = creature.getSkillModBase("flush_with_success");
|
||||
|
||||
experience += ((experience * experienceBonus) / 100);
|
||||
|
||||
// 1. Add the experience.
|
||||
if (experience > 0 && !creature.isStationary()) {
|
||||
creature.showFlyText(OutOfBand.ProsePackage("@base_player:prose_flytext_xp", experience), 2.5f, new RGB(180, 60, 240), 1, true);
|
||||
}
|
||||
|
||||
String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general"));
|
||||
|
||||
if (player.getXpList().containsKey(xpType)) {
|
||||
experience += player.getXp(xpType);
|
||||
}
|
||||
|
||||
player.setXp(xpType, experience);
|
||||
|
||||
// 2. See if they need to level up.
|
||||
for (int i = 0; i < experienceTable.getRowCount(); i++) {
|
||||
if (experienceTable.getObject(i, 0) != null) {
|
||||
if (experience >= ((Integer) experienceTable.getObject(i, 1))) {
|
||||
if (creature.getLevel() < (Integer) experienceTable.getObject(i, 0)) {
|
||||
creature.playEffectObject("clienteffect/level_granted.cef", "");
|
||||
creature.getClient().getSession().write((new ClientMfdStatusUpdateMessage((float) ((creature.getLevel() == 90) ? 90 : (creature.getLevel() + 1)), "/GroundHUD.MFDStatus.vsp.role.targetLevel")).serialize());
|
||||
creature.setLevel(((Integer) experienceTable.getObject(i, 0)).shortValue());
|
||||
core.scriptService.callScript("scripts/collections/", "master_" + player.getProfession(), "addMasterBadge", core, creature);
|
||||
|
||||
// 3. Add the relevant health/action and expertise points.
|
||||
float luck = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getLuck").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getLuck").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("luck")));
|
||||
float precision = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getPrecision").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getPrecision").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("precision")));
|
||||
float strength = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStrength").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStrength").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("strength")));
|
||||
float constitution = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getConstitution").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getConstitution").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("constitution")));
|
||||
float stamina = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStamina").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStamina").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("stamina")));
|
||||
float agility = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getAgility").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getAgility").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("agility")));
|
||||
float health = 100;
|
||||
float action = 75;
|
||||
|
||||
int healthGranted = ((Integer) experienceTable.getObject(i, 4));
|
||||
|
||||
if (luck >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "luck", (int) luck);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_0", (int) luck), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (precision >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "precision", (int) precision);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_1", (int) precision), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (strength >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "strength", (int) strength);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_2", (int) strength), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (constitution >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "constitution", (int) constitution);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_3", (int) constitution), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (stamina >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "stamina", (int) stamina);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_4", (int) stamina), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (agility >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "agility", (int) agility);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_5", (int) agility), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (health >= 1) {
|
||||
creature.setMaxHealth((creature.getMaxHealth() + (int) health + (healthGranted - creature.getGrantedHealth())));
|
||||
creature.setHealth(creature.getMaxHealth());
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_6", (((int) health) + (((int) constitution) * 8) + (((int) stamina) * 2))), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (action >= 1) {
|
||||
creature.setMaxAction((creature.getMaxAction() + (int) action));
|
||||
creature.setAction(creature.getMaxAction());
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_7", (((int) action) + (((int) stamina) * 8) + (((int) constitution) * 2))), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
creature.setGrantedHealth(((Integer) experienceTable.getObject(i, 4)));
|
||||
// -> Expertise point added automatically by client
|
||||
creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:level_up"), 2.5f, new RGB(100, 149, 237), 0, true);
|
||||
|
||||
// 4. Adds roadmap rewards
|
||||
int level = creature.getLevel();
|
||||
|
||||
if ((level == 4 || level == 7 || level == 10) || ((level > 10) && (((creature.getLevel() - 10) % 4) == 0))) {
|
||||
int skill = ((level <= 10) ? ((level - 1) / 3) : ((((level - 10) / 4)) + 3));
|
||||
String roadmapSkillName = "";
|
||||
DatatableVisitor skillTemplate, roadmap;
|
||||
|
||||
try {
|
||||
skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class);
|
||||
|
||||
for (int s = 0; s < skillTemplate.getRowCount(); s++) {
|
||||
if (skillTemplate.getObject(s, 0) != null) {
|
||||
if (((String) skillTemplate.getObject(s, 0)).equals(player.getProfession())) {
|
||||
String[] skillArray = ((String) skillTemplate.getObject(s, 4)).split(",");
|
||||
roadmapSkillName = skillArray[skill];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:skill_up"), 2.5f, new RGB(154, 205, 50), 0, true);
|
||||
creature.playEffectObject("clienteffect/skill_granted.cef", "");
|
||||
creature.playMusic("sound/music_acq_bountyhunter.snd");
|
||||
core.skillService.addSkill(creature, roadmapSkillName);
|
||||
player.setProfessionWheelPosition(roadmapSkillName);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
roadmap = ClientFileManager.loadFile("datatables/roadmap/item_rewards.iff", DatatableVisitor.class);
|
||||
|
||||
Vector<SWGObject> rewards = new Vector<SWGObject>();
|
||||
|
||||
for (int s = 0; s < roadmap.getRowCount(); s++) {
|
||||
if (roadmap.getObject(s, 0) != null) {
|
||||
if (((String) roadmap.getObject(s, 1)).equals(roadmapSkillName)) {
|
||||
String[] apts = ((String) roadmap.getObject(s, 2)).split(",");
|
||||
String[] items = ((String) roadmap.getObject(s, 4)).split(",");
|
||||
String[] wookieeItems = ((String) roadmap.getObject(s, 5)).split(",");
|
||||
String[] ithorianItems = ((String) roadmap.getObject(s, 6)).split(",");
|
||||
|
||||
for (int n = 0; n < items.length; n++) {
|
||||
String item = items[n];
|
||||
|
||||
if (wookieeItems[0].length() > 0 && creature.getStfName().contains("wookiee")) {
|
||||
item = wookieeItems[n];
|
||||
} else if (ithorianItems[0].length() > 0 && creature.getStfName().contains("ithorian")) {
|
||||
item = ithorianItems[n];
|
||||
}
|
||||
|
||||
try {
|
||||
String customServerTemplate = null;
|
||||
|
||||
if (item.contains("/")) {
|
||||
item = (item.substring(0, (item.lastIndexOf("/") + 1)) + "shared_" + item.substring((item.lastIndexOf("/") + 1)));
|
||||
} else {
|
||||
customServerTemplate = item;
|
||||
item = core.scriptService.callScript("scripts/roadmap/", player.getProfession(), "getRewards", item).asString();
|
||||
}
|
||||
|
||||
if (item != null && item != "") {
|
||||
SWGObject itemObj = core.objectService.createObject(item, 0, creature.getPlanet(), new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), customServerTemplate);
|
||||
rewards.add(itemObj);
|
||||
} else {
|
||||
//System.out.println("Can't find template: " + item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rewards != null && !rewards.isEmpty()) {
|
||||
giveItems(creature, rewards);
|
||||
}
|
||||
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class);
|
||||
|
||||
// Cannot gain more than half of the XP needed for the next level in one go
|
||||
// TODO: Do check
|
||||
|
||||
int experienceBonus = creature.getSkillModBase("flush_with_success");
|
||||
|
||||
experience += ((experience * experienceBonus) / 100);
|
||||
|
||||
// 1. Add the experience.
|
||||
if (experience > 0 && !creature.isStationary()) {
|
||||
creature.showFlyText(OutOfBand.ProsePackage("@base_player:prose_flytext_xp", experience), 2.5f, new RGB(180, 60, 240), 1, true);
|
||||
}
|
||||
|
||||
if(player.getProfession().equals("entertainer_1a") && creature.getLevel() == (short) 90 && creature.getEntertainerExperience() != null)
|
||||
creature.getEntertainerExperience().cancel(true);
|
||||
//}
|
||||
String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general"));
|
||||
|
||||
if (player.getXpList().containsKey(xpType)) {
|
||||
experience += player.getXp(xpType);
|
||||
}
|
||||
|
||||
player.setXp(xpType, experience);
|
||||
|
||||
// 2. See if they need to level up.
|
||||
for (int i = 0; i < experienceTable.getRowCount(); i++) {
|
||||
if (experienceTable.getObject(i, 0) != null) {
|
||||
if (experience >= ((Integer) experienceTable.getObject(i, 1))) {
|
||||
if (creature.getLevel() < (Integer) experienceTable.getObject(i, 0)) {
|
||||
creature.playEffectObject("clienteffect/level_granted.cef", "");
|
||||
creature.getClient().getSession().write((new ClientMfdStatusUpdateMessage((float) ((creature.getLevel() == 90) ? 90 : (creature.getLevel() + 1)), "/GroundHUD.MFDStatus.vsp.role.targetLevel")).serialize());
|
||||
creature.setLevel(((Integer) experienceTable.getObject(i, 0)).shortValue());
|
||||
core.scriptService.callScript("scripts/collections/", "master_" + player.getProfession(), "addMasterBadge", core, creature);
|
||||
|
||||
// 3. Add the relevant health/action and expertise points.
|
||||
float luck = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getLuck").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getLuck").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("luck")));
|
||||
float precision = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getPrecision").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getPrecision").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("precision")));
|
||||
float strength = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStrength").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStrength").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("strength")));
|
||||
float constitution = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getConstitution").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getConstitution").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("constitution")));
|
||||
float stamina = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStamina").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStamina").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("stamina")));
|
||||
float agility = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getAgility").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getAgility").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("agility")));
|
||||
float health = 100;
|
||||
float action = 75;
|
||||
|
||||
int healthGranted = ((Integer) experienceTable.getObject(i, 4));
|
||||
|
||||
if (luck >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "luck", (int) luck);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_0", (int) luck), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (precision >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "precision", (int) precision);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_1", (int) precision), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (strength >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "strength", (int) strength);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_2", (int) strength), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (constitution >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "constitution", (int) constitution);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_3", (int) constitution), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (stamina >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "stamina", (int) stamina);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_4", (int) stamina), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (agility >= 1) {
|
||||
core.skillModService.addSkillMod(creature, "agility", (int) agility);
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_5", (int) agility), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (health >= 1) {
|
||||
creature.setMaxHealth((creature.getMaxHealth() + (int) health + (healthGranted - creature.getGrantedHealth())));
|
||||
creature.setHealth(creature.getMaxHealth());
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_6", (((int) health) + (((int) constitution) * 8) + (((int) stamina) * 2))), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
if (action >= 1) {
|
||||
creature.setMaxAction((creature.getMaxAction() + (int) action));
|
||||
creature.setAction(creature.getMaxAction());
|
||||
creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_7", (((int) action) + (((int) stamina) * 8) + (((int) constitution) * 2))), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
creature.setGrantedHealth(((Integer) experienceTable.getObject(i, 4)));
|
||||
// -> Expertise point added automatically by client
|
||||
creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:level_up"), 2.5f, new RGB(100, 149, 237), 0, true);
|
||||
|
||||
// 4. Adds roadmap rewards
|
||||
int level = creature.getLevel();
|
||||
|
||||
if ((level == 4 || level == 7 || level == 10) || ((level > 10) && (((creature.getLevel() - 10) % 4) == 0))) {
|
||||
int skill = ((level <= 10) ? ((level - 1) / 3) : ((((level - 10) / 4)) + 3));
|
||||
String roadmapSkillName = "";
|
||||
DatatableVisitor skillTemplate, roadmap;
|
||||
|
||||
try {
|
||||
skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class);
|
||||
|
||||
for (int s = 0; s < skillTemplate.getRowCount(); s++) {
|
||||
if (skillTemplate.getObject(s, 0) != null) {
|
||||
if (((String) skillTemplate.getObject(s, 0)).equals(player.getProfession())) {
|
||||
String[] skillArray = ((String) skillTemplate.getObject(s, 4)).split(",");
|
||||
roadmapSkillName = skillArray[skill];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:skill_up"), 2.5f, new RGB(154, 205, 50), 0, true);
|
||||
creature.playEffectObject("clienteffect/skill_granted.cef", "");
|
||||
creature.playMusic("sound/music_acq_bountyhunter.snd");
|
||||
core.skillService.addSkill(creature, roadmapSkillName);
|
||||
player.setProfessionWheelPosition(roadmapSkillName);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
roadmap = ClientFileManager.loadFile("datatables/roadmap/item_rewards.iff", DatatableVisitor.class);
|
||||
|
||||
Vector<SWGObject> rewards = new Vector<SWGObject>();
|
||||
|
||||
for (int s = 0; s < roadmap.getRowCount(); s++) {
|
||||
if (roadmap.getObject(s, 0) != null) {
|
||||
if (((String) roadmap.getObject(s, 1)).equals(roadmapSkillName)) {
|
||||
String[] apts = ((String) roadmap.getObject(s, 2)).split(",");
|
||||
String[] items = ((String) roadmap.getObject(s, 4)).split(",");
|
||||
String[] wookieeItems = ((String) roadmap.getObject(s, 5)).split(",");
|
||||
String[] ithorianItems = ((String) roadmap.getObject(s, 6)).split(",");
|
||||
|
||||
int arrayLength = items.length;
|
||||
|
||||
if (wookieeItems.length > 0 && creature.getStfName().contains("wookiee")) {
|
||||
arrayLength = wookieeItems.length;
|
||||
} else if (ithorianItems.length > 0 && creature.getStfName().contains("ithorian")) {
|
||||
arrayLength = ithorianItems.length;
|
||||
}
|
||||
|
||||
for (int n = 0; n < arrayLength; n++) {
|
||||
String item = items[n];
|
||||
|
||||
if (creature.getStfName().contains("wookiee")) {
|
||||
item = wookieeItems[n];
|
||||
} else if (creature.getStfName().contains("ithorian")) {
|
||||
item = ithorianItems[n];
|
||||
}
|
||||
|
||||
try {
|
||||
String customServerTemplate = null;
|
||||
|
||||
if (item.contains("/")) {
|
||||
item = (item.substring(0, (item.lastIndexOf("/") + 1)) + "shared_" + item.substring((item.lastIndexOf("/") + 1)));
|
||||
} else {
|
||||
customServerTemplate = item;
|
||||
item = core.scriptService.callScript("scripts/roadmap/", player.getProfession(), "getRewards", item).asString();
|
||||
}
|
||||
|
||||
if (item != null && item != "") {
|
||||
SWGObject itemObj = core.objectService.createObject(item, 0, creature.getPlanet(), new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), customServerTemplate);
|
||||
} else {
|
||||
//System.out.println("Can't find template: " + item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rewards != null && !rewards.isEmpty()) {
|
||||
giveItems(creature, rewards);
|
||||
}
|
||||
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerTitle(PlayerObject player, String title) {
|
||||
@@ -1182,7 +1238,7 @@ public class PlayerService implements INetworkDispatch {
|
||||
// need to set a unity attachment.
|
||||
ringList.get(0).setAttachment("unity", (Boolean) true);
|
||||
|
||||
if(!acceptor.getEquipmentList().contains(ringList.get(0)))
|
||||
if(!acceptor.getEquipmentList().contains(ringList.get(0).getObjectId()))
|
||||
core.equipmentService.equip(acceptor, ringList.get(0));
|
||||
|
||||
aGhost.setSpouseName(proposer.getCustomName());
|
||||
@@ -1217,7 +1273,7 @@ public class PlayerService implements INetworkDispatch {
|
||||
SWGObject selectedRing = core.objectService.getObject(ringWindow.getObjectIdByIndex(index));
|
||||
selectedRing.setAttachment("unity", (Boolean) true);
|
||||
|
||||
if(!actor.getEquipmentList().contains(selectedRing))
|
||||
if(!actor.getEquipmentList().contains(selectedRing.getObjectId()))
|
||||
core.equipmentService.equip(actor, selectedRing);
|
||||
|
||||
PlayerObject aGhost = (PlayerObject) actor.getSlottedObject("ghost");
|
||||
@@ -1242,8 +1298,9 @@ public class PlayerService implements INetworkDispatch {
|
||||
actor.sendSystemMessage("@unity:decline", (byte) 0);
|
||||
proposer.sendSystemMessage("@unity:declined", (byte) 0);
|
||||
actor.setAttachment("proposer", null);
|
||||
for(SWGObject obj : proposer.getEquipmentList()) {
|
||||
if(obj.getAttachment("unity") != null) {
|
||||
for(Long objId : proposer.getEquipmentList()) {
|
||||
SWGObject obj = core.objectService.getObject(objId);
|
||||
if(obj != null && obj.getAttachment("unity") != null) {
|
||||
obj.setAttachment("unity", null);
|
||||
break;
|
||||
}
|
||||
@@ -1253,6 +1310,65 @@ public class PlayerService implements INetworkDispatch {
|
||||
core.suiService.openSUIWindow(ringWindow);
|
||||
}
|
||||
|
||||
public void sendSetBountyWindow(final CreatureObject victim, final CreatureObject attacker) {
|
||||
SUIWindow bountyWindow = core.suiService.createInputBox(InputBoxType.INPUT_BOX_OK_CANCEL, "@bounty_hunter:setbounty_title", "@bounty_hunter:setbounty_prompt1 " + attacker.getCustomName() + "?" + "\n@bounty_hunter:setbounty_prompt2 "
|
||||
+ String.valueOf(victim.getBankCredits() + victim.getCashCredits()), victim, null, (float) 10, new SUICallback() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
|
||||
if (eventType == 0 && returnList.get(0) != null) {
|
||||
int bounty = Integer.parseInt(returnList.get(0));
|
||||
int totalFunds = victim.getBankCredits() + victim.getCashCredits();
|
||||
|
||||
if (bounty > totalFunds) {
|
||||
victim.sendSystemMessage("@bounty_hunter:setbounty_too_much", DisplayType.Broadcast);
|
||||
sendSetBountyWindow(victim, attacker);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bounty < 20000) {
|
||||
victim.sendSystemMessage("@bounty_hunter:setbounty_too_little", DisplayType.Broadcast);
|
||||
sendSetBountyWindow(victim, attacker);
|
||||
return;
|
||||
} else if (bounty > 1000000) {
|
||||
victim.sendSystemMessage("@bounty_hunter:setbounty_cap", DisplayType.Broadcast);
|
||||
bounty = 1000000;
|
||||
}
|
||||
|
||||
if (core.getBountiesODB().contains(attacker.getObjectID())) {
|
||||
if (((BountyListItem) core.getBountiesODB().get(attacker.getObjectID())).getCreditReward() >= 20000000) {
|
||||
victim.sendSystemMessage("@bounty_hunter:max_bounty", DisplayType.Broadcast);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Try removing bounty amount from the bank first then cash. Remove amount accordingly if bank/cash is less than placed bounty.
|
||||
if (bounty > victim.getBankCredits()) {
|
||||
int difference = bounty - victim.getBankCredits();
|
||||
|
||||
victim.setCashCredits(victim.getCashCredits() - difference);
|
||||
victim.setBankCredits(0);
|
||||
} else if (bounty > victim.getCashCredits()) {
|
||||
int difference = bounty - victim.getCashCredits();
|
||||
|
||||
victim.setBankCredits(victim.getBankCredits() - difference);
|
||||
victim.setCashCredits(0);
|
||||
} else { victim.setBankCredits(victim.getBankCredits() - bounty); }
|
||||
|
||||
if (!core.missionService.addToExistingBounty(attacker.getObjectID(), victim.getObjectID(), bounty))
|
||||
core.missionService.createNewBounty(attacker, victim.getObjectID(), bounty);
|
||||
|
||||
victim.sendSystemMessage("You have placed a bounty for " + bounty + " credits on the head of " + attacker.getCustomName(), (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
bountyWindow.setProperty("txtInput:NumericInteger", "true");
|
||||
bountyWindow.setProperty("txtInput:MaxLength", "7");
|
||||
bountyWindow.setProperty("inputBox:Size", "306,306");
|
||||
core.suiService.openSUIWindow(bountyWindow);
|
||||
}
|
||||
|
||||
public String getFormalProfessionName(String template) {
|
||||
String formalName = "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user