From ec74046a7d825ca8bc436eca6dec76834f78393f Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 2 Apr 2014 14:11:43 -0400 Subject: [PATCH 01/26] Started cleaning up Equipment Service --- src/services/EquipmentService.java | 234 ++++++++++++++--------------- src/services/PlayerService.java | 19 +++ 2 files changed, 129 insertions(+), 124 deletions(-) diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index bcd0a519..00795fe9 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -83,33 +83,6 @@ public class EquipmentService implements INetworkDispatch { return weaponCriticalChance; } - private void addWeaponCriticalChance(CreatureObject actor, SWGObject item) { - actor.addSkillMod("display_only_critical", getWeaponCriticalChance(actor, item)); - } - - private void deductWeaponCriticalChance(CreatureObject actor, SWGObject item) { - actor.deductSkillMod("display_only_critical", getWeaponCriticalChance(actor, item)); - } - - public String getFormalProfessionName(String stfName) { - String formalName = ""; - - switch (stfName) { - case "force_sensitive_1a": formalName = "Jedi"; break; - case "bounty_hunter_1a": formalName = "Bounty Hunter"; break; - case "officer_1a": formalName = "Officer"; break; - case "smuggler_1a": formalName = "Smuggler"; break; - case "entertainer_1a": formalName = "Entertainer"; break; - case "spy_1a": formalName = "Spy"; break; - case "medic_1a": formalName = "Medic"; break; - case "commando_1a": formalName = "Commando"; break; - - default: formalName = "Trader"; break; // Ziggy: Trader profession names are a bit irregular, so this is used. - - } - return formalName; - } - public boolean canEquip(CreatureObject actor, SWGObject item) { boolean result = true; @@ -117,14 +90,14 @@ public class EquipmentService implements INetworkDispatch { return false; if (item.getAttributes().toString().contains("cat_armor")) - if (actor.getLevel() >= 22) - result = true; - else - return false; + { + if (actor.hasAbility("wear_all_armor")) result = true; // Change to "wear_all_armor" ability instead of lvl 22 + else return false; + } if (item.getStringAttribute("class_required") != null) { String profession = ((PlayerObject) actor.getSlottedObject("ghost")).getProfession(); - if (item.getStringAttribute("class_required").contentEquals(getFormalProfessionName(profession)) || item.getStringAttribute("class_required").contentEquals("None")) + if (item.getStringAttribute("class_required").contentEquals(core.playerService.getFormalProfessionName(profession)) || item.getStringAttribute("class_required").contentEquals("None")) result = true; else return false; @@ -137,10 +110,18 @@ public class EquipmentService implements INetworkDispatch { return false; if (item.getAttributes().containsKey("required_combat_level")) + { if (actor.getLevel() >= item.getIntAttribute("required_combat_level")) result = true; else return false; + } + + if(item.getAttachment("unity") != null) + { + actor.sendSystemMessage("@unity:cannot_remove_ring", (byte) 0); + return false; + } return result; } @@ -150,7 +131,7 @@ public class EquipmentService implements INetworkDispatch { } private void addArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { - actor.addSkillMod(protectionType, (int) (calculateArmorProtection(protection, slotName))); + actor.addSkillMod(protectionType, (int) Math.ceil(calculateArmorProtection(protection, slotName))); } private void deductArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { @@ -179,17 +160,14 @@ public class EquipmentService implements INetworkDispatch { return core.scriptService.getMethod("scripts/equipment/", "force_protection", item.getAttachment("type") + "_" + item.getStringAttribute("protection_level")).__call__().asInt(); } - public void equip(CreatureObject actor, SWGObject item) { + public void equip(CreatureObject actor, SWGObject item) + { String template = ((item.getAttachment("customServerTemplate") == null) ? item.getTemplate() : (item.getTemplate().split("shared_")[0] + "shared_" + ((String) item.getAttachment("customServerTemplate")) + ".iff")); String serverTemplate = template.replace(".iff", ""); - PyObject func = core.scriptService.getMethod("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", ""), serverTemplate.split("shared_" , 2)[1], "equip"); - if(func != null) - func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item)); - - if (item.getStringAttribute("protection_level") != null) - addForceProtection(actor, item); - // TODO: faction restrictions - You had to be a Combatant as minimum in order to EQUIP an item. + PyObject func = core.scriptService.getMethod("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", ""), serverTemplate.split("shared_" , 2)[1], "equip"); + if(func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item)); + // TODO: Species restrictions // TODO: Gender restrictions // TODO: crit enhancement from crafted weapons @@ -197,107 +175,115 @@ public class EquipmentService implements INetworkDispatch { // TODO: Calculate actual armor values (REMINDER: Check if the player is wearing a jedi robe/cloak (look for force protection intensity). If they are, they shouldn't receive any additional protection from other items with armour.) // TODO: bio-link (assign it by objectID with setAttachment and then just display the customName for that objectID). - if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) - addWeaponCriticalChance(actor, item); - - Map attributes = new TreeMap(item.getAttributes()); - - for(Entry e : attributes.entrySet()) { - if(e.getKey().startsWith("cat_skill_mod_bonus.@stat_n:")) { - core.skillModService.addSkillMod(actor, e.getKey().replace("cat_skill_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); - } - - if(e.getKey().startsWith("cat_stat_mod_bonus.@stat_n:")) { - core.skillModService.addSkillMod(actor, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); - } - - if(e.getKey().startsWith("cat_armor_standard_protection")) { - addArmorProtection(actor, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); - } - - if(e.getKey().startsWith("cat_armor_special_protection")) { - addArmorProtection(actor, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); - } - - if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { - actor.setMaxHealth(actor.getMaxHealth() + Integer.parseInt((String) e.getValue())); - } - - if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_action")) { - actor.setMaxAction(actor.getMaxAction() + Integer.parseInt((String) e.getValue())); - } - - } - - if(item.getStringAttribute("proc_name") != null) core.buffService.addBuffToCreature(actor, item.getStringAttribute("proc_name").replace("@ui_buff:", ""), actor); - - - if(!actor.getEquipmentList().contains(item)) - actor.addObjectToEquipList(item); - - if(item.getAttachment("setBonus") != null) + if(!actor.getEquipmentList().contains(item)) { - BonusSetTemplate bonus = bonusSetTemplates.get((String)item.getAttachment("setBonus")); - bonus.callScript(actor); + actor.addObjectToEquipList(item); + processItemAtrributes(actor, item, true); } } - public void unequip(CreatureObject actor, SWGObject item) { + public void unequip(CreatureObject actor, SWGObject item) + { String template = ((item.getAttachment("customServerTemplate") == null) ? item.getTemplate() : (item.getTemplate().split("shared_")[0] + "shared_" + ((String) item.getAttachment("customServerTemplate")) + ".iff")); String serverTemplate = template.replace(".iff", ""); + PyObject func = core.scriptService.getMethod("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", ""), serverTemplate.split("shared_" , 2)[1], "unequip"); - if(func != null) - func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item)); + if(func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item)); - if (item.getStringAttribute("protection_level") != null) - deductForceProtection(actor, item); - - if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) - deductWeaponCriticalChance(actor, item); + if(actor.getEquipmentList().contains(item)) + { + actor.removeObjectFromEquipList(item); + processItemAtrributes(actor, item, false); + } + } + + public void processItemAtrributes(CreatureObject creature, SWGObject item, boolean equipping) + { Map attributes = new TreeMap(item.getAttributes()); - for(Entry e : attributes.entrySet()) { - - if(e.getKey().startsWith("cat_skill_mod_bonus.@stat_n:")) { - core.skillModService.deductSkillMod(actor, e.getKey().replace("cat_skill_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); - } - if(e.getKey().startsWith("cat_stat_mod_bonus.@stat_n:")) { - core.skillModService.deductSkillMod(actor, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); - } - - if(e.getKey().startsWith("cat_armor_standard_protection")) { - deductArmorProtection(actor, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); - } - - if(e.getKey().startsWith("cat_armor_special_protection")) { - deductArmorProtection(actor, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), actor.getSlotNameForObject(item)); - } - - if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { - actor.setMaxHealth(actor.getMaxHealth() - Integer.parseInt((String) e.getValue())); - } - if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_action")) { - actor.setMaxAction(actor.getMaxAction() - Integer.parseInt((String) e.getValue())); + if(equipping) + { + if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) creature.addSkillMod("display_only_critical", getWeaponCriticalChance(creature, item)); + if(item.getStringAttribute("protection_level") != null) addForceProtection(creature, item); + if(item.getStringAttribute("proc_name") != null) core.buffService.addBuffToCreature(creature, item.getStringAttribute("proc_name").replace("@ui_buff:", ""), creature); + + for(Entry e : attributes.entrySet()) + { + if(e.getKey().startsWith("cat_skill_mod_bonus.@stat_n:")) + { + core.skillModService.addSkillMod(creature, e.getKey().replace("cat_skill_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); + } + + if(e.getKey().startsWith("cat_stat_mod_bonus.@stat_n:")) + { + core.skillModService.addSkillMod(creature, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); + } + + if(e.getKey().startsWith("cat_armor_standard_protection")) + { + addArmorProtection(creature, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); + } + + if(e.getKey().startsWith("cat_armor_special_protection")) + { + addArmorProtection(creature, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); + } + + if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) + { + creature.setMaxHealth(creature.getMaxHealth() + Integer.parseInt((String) e.getValue())); + } + + if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_action")) + { + creature.setMaxAction(creature.getMaxAction() + Integer.parseInt((String) e.getValue())); + } + } + } + else + { + if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) creature.deductSkillMod("display_only_critical", getWeaponCriticalChance(creature, item)); + if(item.getStringAttribute("protection_level") != null) deductForceProtection(creature, item); + if(item.getStringAttribute("proc_name") != null) core.buffService.removeBuffFromCreatureByName(creature, item.getStringAttribute("proc_name").replace("@ui_buff:", "")); - } - - if(item.getAttachment("unity") != null) { - actor.sendSystemMessage("@unity:cannot_remove_ring", (byte) 0); - return; + for(Entry e : attributes.entrySet()) + { + if(e.getKey().startsWith("cat_skill_mod_bonus.@stat_n:")) + { + core.skillModService.deductSkillMod(creature, e.getKey().replace("cat_skill_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); + } + if(e.getKey().startsWith("cat_stat_mod_bonus.@stat_n:")) + { + core.skillModService.deductSkillMod(creature, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); + } + + if(e.getKey().startsWith("cat_armor_standard_protection")) + { + deductArmorProtection(creature, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); + } + + if(e.getKey().startsWith("cat_armor_special_protection")) + { + deductArmorProtection(creature, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); + } + + if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) + { + creature.setMaxHealth(creature.getMaxHealth() - Integer.parseInt((String) e.getValue())); + } + if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_action")) + { + creature.setMaxAction(creature.getMaxAction() - Integer.parseInt((String) e.getValue())); + } + } } - if(item.getStringAttribute("proc_name") != null) core.buffService.removeBuffFromCreatureByName(actor, item.getStringAttribute("proc_name").replace("@ui_buff:", "")); - - - if(actor.getEquipmentList().contains(item)) - actor.removeObjectFromEquipList(item); - if(item.getAttachment("setBonus") != null) { BonusSetTemplate bonus = bonusSetTemplates.get((String)item.getAttachment("setBonus")); - bonus.callScript(actor); + bonus.callScript(creature); } } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 2d106485..a4c9cb94 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -1206,6 +1206,25 @@ public class PlayerService implements INetworkDispatch { core.suiService.openSUIWindow(ringWindow); } + public String getFormalProfessionName(String template) { + String formalName = ""; + + switch (template) { + case "force_sensitive_1a": formalName = "Jedi"; break; + case "bounty_hunter_1a": formalName = "Bounty Hunter"; break; + case "officer_1a": formalName = "Officer"; break; + case "smuggler_1a": formalName = "Smuggler"; break; + case "entertainer_1a": formalName = "Entertainer"; break; + case "spy_1a": formalName = "Spy"; break; + case "medic_1a": formalName = "Medic"; break; + case "commando_1a": formalName = "Commando"; break; + + default: formalName = "Trader"; break; // Ziggy: Trader profession names are a bit irregular, so this is used. + + } + return formalName; + } + @Override public void shutdown() { // TODO Auto-generated method stub From 317d374ebb6635d693c20d209e2b100d28d1285b Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 12:17:24 +0100 Subject: [PATCH 02/26] resetLevel() no longer removes basic skills --- src/services/PlayerService.java | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 0c36d31c..1309f1f4 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -576,18 +576,13 @@ public class PlayerService implements INetworkDispatch { 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": { + case "object/weapon/creature/shared_creature_default_weapon.iff": continue; - } - default: { - // - } + default: + core.equipmentService.unequip(creature, equipment); } - - core.equipmentService.unequip(creature, equipment); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } @@ -598,7 +593,19 @@ public class PlayerService implements INetworkDispatch { core.buffService.clearBuffs(creature); for (String skill : creature.getSkills()) { - core.skillService.removeSkill(creature, skill); + if (skill.startsWith("species_")) { + continue; + } + + switch (skill) { + case "language_basic_comprehend": + case "language_basic_speak": + case "creature_harvesting": + case "language_wookiee_comprehend": + continue; + default: + core.skillService.removeSkill(creature, skill); + } } String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general")); From e6d21a86208a935382e6f70056741e7fe8818f79 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 12:40:35 +0100 Subject: [PATCH 03/26] No longer able to gain XP beyond level 90 --- src/services/PlayerService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 1309f1f4..e56accc1 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -809,6 +809,11 @@ public class PlayerService implements INetworkDispatch { DatatableVisitor experienceTable; PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); experience *= xpMultiplier; + + if (creature.getLevel() >= 90) { + return; + } + //synchronized(objectMutex) { try { experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class); From 6bcb2999133d483838caf7fc33591046d3e7cb07 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 12:46:46 +0100 Subject: [PATCH 04/26] XP flytxt no longer shows if performing/stationary --- src/services/PlayerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index e56accc1..f4ffbb60 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -826,7 +826,7 @@ public class PlayerService implements INetworkDispatch { experience += ((experience * experienceBonus) / 100); // 1. Add the experience. - if (experience > 0) { + if (experience > 0 && !creature.isStationary()) { creature.showFlyText("base_player", "prose_flytext_xp", "", experience, (float) 2.5, new RGB(180, 60, 240), 1); } From d7aba7dc7a8e8cc8b5c10b649aa9dfd1e7cb3bde Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 13:37:11 +0100 Subject: [PATCH 05/26] resetLvl only remvs class/expertise skills (safer) It's better to only remove class/expertise skills, rather than remove all but certain skills. The previous method would remove all chronicles, politician and basic language and harvesting skills! --- src/services/PlayerService.java | 34 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index f4ffbb60..7ccc070e 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -592,22 +592,30 @@ public class PlayerService implements INetworkDispatch { core.buffService.clearBuffs(creature); - for (String skill : creature.getSkills()) { - if (skill.startsWith("species_")) { - continue; - } + try { + String[] skills; - switch (skill) { - case "language_basic_comprehend": - case "language_basic_speak": - case "creature_harvesting": - case "language_wookiee_comprehend": - continue; - default: - core.skillService.removeSkill(creature, skill); + 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) { + creature.removeSkill(skill); + } + + break; + } + } } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); } - + + core.skillService.resetExpertise(creature); + String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general")); player.setXp(xpType, 0); From 1f58d98000d7842ebb51b58db3ffe98494a7d79b Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 14:00:23 +0100 Subject: [PATCH 06/26] Added agility medic buff ability Mark I (example) The level for most expertise abilities can be seen in the buff table because it's specified in the Priority column for buffs (yay!). The names are way too different and it would be too resource intensive/too much server work to try and do this automatically, especially when the data isn't *always* there and isn't always correct when it is. --- scripts/expertise/expertise_me_agility_1.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/expertise/expertise_me_agility_1.py b/scripts/expertise/expertise_me_agility_1.py index 29ea50ff..41c69725 100644 --- a/scripts/expertise/expertise_me_agility_1.py +++ b/scripts/expertise/expertise_me_agility_1.py @@ -36,13 +36,11 @@ def removeExpertisePoint(core, actor): return -# this checks what abilities the player gets by level, need to also call this on level-up def addAbilities(core, actor, player): - - + if actor.getLevel() == 10: + actor.addAbility("me_enhance_agility_1") return def removeAbilities(core, actor, player): - - + actor.removeAbility("me_enhance_agility_1") return From b5b99ddd686b5207b513391fc610e1948be6330a Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 14:06:42 +0100 Subject: [PATCH 07/26] Should actually always be >= otherwise it'll bug --- scripts/expertise/expertise_me_agility_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/expertise/expertise_me_agility_1.py b/scripts/expertise/expertise_me_agility_1.py index 41c69725..165385c4 100644 --- a/scripts/expertise/expertise_me_agility_1.py +++ b/scripts/expertise/expertise_me_agility_1.py @@ -37,7 +37,7 @@ def removeExpertisePoint(core, actor): return def addAbilities(core, actor, player): - if actor.getLevel() == 10: + if actor.getLevel() >= 10: actor.addAbility("me_enhance_agility_1") return From d37440c682d937d311f3590fa44333833aaf4a7c Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 14:19:07 +0100 Subject: [PATCH 08/26] Wrong script --- scripts/expertise/expertise_me_agility_1.py | 39 --------------------- 1 file changed, 39 deletions(-) diff --git a/scripts/expertise/expertise_me_agility_1.py b/scripts/expertise/expertise_me_agility_1.py index 165385c4..30d90811 100644 --- a/scripts/expertise/expertise_me_agility_1.py +++ b/scripts/expertise/expertise_me_agility_1.py @@ -1,46 +1,7 @@ import sys -def addExpertisePoint(core, actor): - - player = actor.getSlottedObject('ghost') - - if not player: - return - - if not player.getProfession() == 'medic_1a': - return - - actor.addSkill('expertise_me_agility_1') - - actor.addSkillMod('agility_modified', 25) - - addAbilities(core, actor, player) - - return - -def removeExpertisePoint(core, actor): - - player = actor.getSlottedObject('ghost') - - if not player: - return - - if not player.getProfession() == 'medic_1a': - return - - actor.removeSkill('expertise_me_agility_1') - - actor.removeSkillMod('agility_modified', 25) - - removeAbilities(core, actor, player) - - return - def addAbilities(core, actor, player): - if actor.getLevel() >= 10: - actor.addAbility("me_enhance_agility_1") return def removeAbilities(core, actor, player): - actor.removeAbility("me_enhance_agility_1") return From cecd55ffcd8df909bfcd713b65c436b46c1f1c36 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 14:22:06 +0100 Subject: [PATCH 09/26] Better example of adding expertise abilities --- .../expertise_me_enhance_agility_1.py | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/scripts/expertise/expertise_me_enhance_agility_1.py b/scripts/expertise/expertise_me_enhance_agility_1.py index fd112eb9..bf7958db 100644 --- a/scripts/expertise/expertise_me_enhance_agility_1.py +++ b/scripts/expertise/expertise_me_enhance_agility_1.py @@ -1,48 +1,14 @@ import sys -def addExpertisePoint(core, actor): - - player = actor.getSlottedObject('ghost') - - if not player: - return - - if not player.getProfession() == 'medic_1a': - return - - actor.addSkill('expertise_me_enhance_agility_1') - - - addAbilities(core, actor, player) - - return - -def removeExpertisePoint(core, actor): - - player = actor.getSlottedObject('ghost') - - if not player: - return - - if not player.getProfession() == 'medic_1a': - return - - actor.removeSkill('expertise_me_enhance_agility_1') - - - removeAbilities(core, actor, player) - - return - -# this checks what abilities the player gets by level, need to also call this on level-up def addAbilities(core, actor, player): - - actor.addAbility('me_enhance_agility_1') - + if actor.getLevel() >= 10: + actor.addAbility("me_enhance_agility_1") + if actor.getLevel() >= 34: + actor.addAbility("me_enhance_agility_2") + if actor.getLevel() >= 62: + actor.addAbility("me_enhance_agility_3") return def removeAbilities(core, actor, player): - - actor.removeAbility('me_enhance_agility_1') - + actor.removeAbility("me_enhance_agility_1") return From e57cefd8a56f5fff15bd6c76b69dd82ef3ddab8a Mon Sep 17 00:00:00 2001 From: Seefo Date: Thu, 3 Apr 2014 09:47:05 -0400 Subject: [PATCH 10/26] Added Jedi Items category to frog --- src/services/DevService.java | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/services/DevService.java b/src/services/DevService.java index 102e6155..7fcb2d5e 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -80,11 +80,10 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 12, "Reset expertise"); break; case 2: // Items - suiOptions.put((long) 20, "(Light) Jedi Robe"); - suiOptions.put((long) 21, "(Dark) Jedi Robe"); - suiOptions.put((long) 22, "Armor"); - suiOptions.put((long) 23, "Weapons"); - suiOptions.put((long) 24, "Misc Items"); + suiOptions.put((long) 20, "Armor"); + suiOptions.put((long) 21, "Weapons"); + suiOptions.put((long) 22, "Misc Items"); + suiOptions.put((long) 23, "Jedi Items"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -115,6 +114,11 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 81, "Ithorian Guardian"); suiOptions.put((long) 82, "Kashyyykian Ceremonial"); break; + case 9: // [Items] Reconnaissance Armor + suiOptions.put((long) 90, "(Light) Jedi Robe"); + suiOptions.put((long) 91, "(Dark) Jedi Robe"); + suiOptions.put((long) 92, "Belt of Master Bodo Baas"); + break; } final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "Character Builder Terminal", "Select the desired option and click OK.", suiOptions, creature, null, 10); @@ -164,22 +168,19 @@ public class DevService implements INetworkDispatch { return; // Items - case 20: // (Light) Jedi Robe - inventory.add(core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_light_s03.iff", planet)); - return; - case 21: // (Dark) Jedi Robe - inventory.add(core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_dark_s03.iff", planet)); - return; - case 22: // Armor + case 20: // Armor sendCharacterBuilderSUI(player, 5); return; - case 23: // Weapons + case 21: // Weapons sendCharacterBuilderSUI(player, 3); return; - - case 24: // Misc Items + case 22: // Misc Items sendCharacterBuilderSUI(player, 4); return; + case 23: // Jedi Items + sendCharacterBuilderSUI(player, 9); + return; + // [Items] Weapons case 30: // Jedi Weapons TangibleObject lightsaber1 = (TangibleObject) core.objectService.createObject("object/weapon/melee/sword/crafted_saber/shared_sword_lightsaber_one_handed_gen5.iff", planet); @@ -889,6 +890,16 @@ public class DevService implements INetworkDispatch { inventory.add(cer_chest); return; + + case 90: // (Light) Jedi Robe + inventory.add(core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_light_s03.iff", planet)); + return; + case 91: // (Dark) Jedi Robe + inventory.add(core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_dark_s03.iff", planet)); + return; + case 92: // Belt of Master Bodo Baas + inventory.add(core.objectService.createObject("object/tangible/wearables/backpack/shared_fannypack_s01.iff", planet)); + return; } } }); From 967aba6652b4ad65fc60771cea48249619906e67 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:34:30 +0100 Subject: [PATCH 11/26] Fixed skillMods --- .../objects/creature/CreatureObject.java | 68 +++++++------------ 1 file changed, 23 insertions(+), 45 deletions(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 5a26a8bf..8791b4cc 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -49,6 +49,7 @@ import engine.clients.Client; import resources.objects.Buff; import resources.objects.DamageOverTime; import resources.objects.SWGList; +import resources.objects.SWGMap; import resources.objects.SkillMod; import engine.resources.objects.IPersistent; import engine.resources.objects.MissionCriticalObject; @@ -59,7 +60,7 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=4) +@Entity(version=5) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -83,9 +84,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { // CREO 4 private float accelerationMultiplierBase = 1; private float accelerationMultiplierMod = 1; - private SWGList skillMods; - @NotPersistent - private int skillModsUpdateCounter = 0; + private SWGMap skillMods; private float speedMultiplierBase = 1; private float speedMultiplierMod = 1; private float runSpeed = (float) 7.3; @@ -184,7 +183,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { messageBuilder = new CreatureMessageBuilder(this); loadTemplateData(); skills = new SWGList(messageBuilder, 1, 3); - skillMods = new SWGList(messageBuilder, 4, 3); + skillMods = new SWGMap(messageBuilder, 4, 3); abilities = new SWGList(messageBuilder, 4, 14); missionCriticalObjects = new SWGList(messageBuilder, 4, 13); equipmentList = new SWGList(messageBuilder, 6, 0x17); @@ -559,20 +558,13 @@ public class CreatureObject extends TangibleObject implements IPersistent { this.accelerationMultiplierMod = accelerationMultiplierMod; } } - - public SWGList getSkillMods() { + + public SWGMap getSkillMods() { return skillMods; } public SkillMod getSkillMod(String name) { - synchronized(skillMods.getMutex()) { - for(SkillMod skillMod : skillMods.get()) { - if(skillMod.getName().equals(name)) - return skillMod; - } - } - - return null; + return skillMods.get(name); } public int getSkillModBase(String name) { @@ -581,54 +573,40 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public void addSkillMod(String name, int base) { - if(getSkillMod(name) == null) { - // TODO: Send skill mods delta in sendListDelta - SkillMod skillMod = new SkillMod(); - skillMod.setBase(base); - skillMod.setName(name); - skillMod.setModifier(0); - skillMods.add(skillMod); + SkillMod mod; + + if (getSkillMod(name) == null) { + mod = new SkillMod(); + mod.setBase(base); + mod.setName(name); + mod.setModifier(0); } else { - - SkillMod mod = getSkillMod(name); + mod = getSkillMod(name); mod.setBase(mod.getBase() + base); - - if(getClient() != null) { - setSkillModsUpdateCounter((short) (getSkillModsUpdateCounter() + 1)); - getClient().getSession().write(messageBuilder.buildAddSkillModDelta(name, mod.getBase())); - } } + skillMods.put(name, mod); } public void deductSkillMod(String name, int base) { - - if(getSkillMod(name) == null) + if (getSkillMod(name) == null) { return; + } SkillMod mod = getSkillMod(name); mod.setBase(mod.getBase() - base); - if(mod.getBase() <= 0) { + if (mod.getBase() <= 0) { removeSkillMod(mod); } else { - skillMods.set(skillMods.indexOf(mod), mod); - if(getClient() != null) { - setSkillModsUpdateCounter((short) (getSkillModsUpdateCounter() + 1)); - getClient().getSession().write(messageBuilder.buildAddSkillModDelta(name, mod.getBase())); - } + skillMods.put(name, mod); } } - + public void removeSkillMod(SkillMod mod) { - skillMods.remove(mod); - - if(getClient() != null) { - setSkillModsUpdateCounter((short) (getSkillModsUpdateCounter() + 1)); - getClient().getSession().write(messageBuilder.buildRemoveSkillModDelta(mod.getName(), mod.getBase())); - } + skillMods.remove(mod.getName()); } - + public short getSkillModsUpdateCounter() { synchronized(objectMutex) { return (short) skillModsUpdateCounter; From de21f019349ea06d066bdcb43380d2b9186d53ab Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:35:33 +0100 Subject: [PATCH 12/26] Forgot something --- src/resources/objects/creature/CreatureObject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 8791b4cc..cc673abe 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -183,7 +183,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { messageBuilder = new CreatureMessageBuilder(this); loadTemplateData(); skills = new SWGList(messageBuilder, 1, 3); - skillMods = new SWGMap(messageBuilder, 4, 3); + skillMods = new SWGMap(messageBuilder, 4, 3); abilities = new SWGList(messageBuilder, 4, 14); missionCriticalObjects = new SWGList(messageBuilder, 4, 13); equipmentList = new SWGList(messageBuilder, 6, 0x17); From 121ec2b40810c051e1b52dbf80aab1392befc91c Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:36:30 +0100 Subject: [PATCH 13/26] And one other thing --- src/resources/objects/creature/CreatureObject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index cc673abe..806efd32 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -84,7 +84,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { // CREO 4 private float accelerationMultiplierBase = 1; private float accelerationMultiplierMod = 1; - private SWGMap skillMods; + private SWGMap skillMods; private float speedMultiplierBase = 1; private float speedMultiplierMod = 1; private float runSpeed = (float) 7.3; From fff7c85437d592edb0c4a6953c3e1f8640b54307 Mon Sep 17 00:00:00 2001 From: Seefo Date: Thu, 3 Apr 2014 11:38:11 -0400 Subject: [PATCH 14/26] Armour calculations are now correct - still working on the Equipment Service. --- scripts/equipment/slot_protection.py | 2 +- src/services/DevService.java | 2 +- src/services/EquipmentService.java | 133 ++++++++++++++++++--------- 3 files changed, 91 insertions(+), 46 deletions(-) diff --git a/scripts/equipment/slot_protection.py b/scripts/equipment/slot_protection.py index 3e16a86c..e6de1f33 100644 --- a/scripts/equipment/slot_protection.py +++ b/scripts/equipment/slot_protection.py @@ -1,7 +1,7 @@ import sys def chest2(): - return "35.71" + return "35.70" def pants1(): return "21.43" diff --git a/src/services/DevService.java b/src/services/DevService.java index 7fcb2d5e..efe65147 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -114,7 +114,7 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 81, "Ithorian Guardian"); suiOptions.put((long) 82, "Kashyyykian Ceremonial"); break; - case 9: // [Items] Reconnaissance Armor + case 9: // [Items] Jedi Items suiOptions.put((long) 90, "(Light) Jedi Robe"); suiOptions.put((long) 91, "(Dark) Jedi Robe"); suiOptions.put((long) 92, "Belt of Master Bodo Baas"); diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index 00795fe9..3edd96f7 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -45,6 +45,7 @@ import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; import services.equipment.BonusSetTemplate; import services.spawn.MobileTemplate; @@ -126,40 +127,57 @@ public class EquipmentService implements INetworkDispatch { return result; } - private float calculateArmorProtection (float protection, String slotName) { - return protection *= (Float.parseFloat(core.scriptService.getMethod("scripts/equipment/", "slot_protection", slotName).__call__().asString()) / 100); + private void calculateArmorProtection(CreatureObject creature, boolean equipping)//float protection, String slotName) + { + int wornArmourPieces = 0; + Map protection = new TreeMap(); + + for(SWGObject item : creature.getEquipmentList()) + { + Map attributes = new TreeMap(item.getAttributes()); + //if(attributes.containsKey("")) wornArmourPieces++; + boolean incPieceCount = false; + + for(Entry e : attributes.entrySet()) + { + if(e.getKey().startsWith("cat_armor_standard_protection")) + { + String protectionType = e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""); + float modifier = Float.parseFloat(core.scriptService.getMethod("scripts/equipment/", "slot_protection", creature.getSlotNameForObject(item)).__call__().asString()) / 100; + Float protectionAmount = Float.parseFloat((String) e.getValue()) * modifier; + + if(protection.containsKey(protectionType)) protection.replace(protectionType, protection.get(protectionType) + protectionAmount); + else protection.put(protectionType, protectionAmount); + incPieceCount = true; + } + else if(e.getKey().startsWith("cat_armor_special_protection")) + { + String protectionType = e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""); + float modifier = Float.parseFloat(core.scriptService.getMethod("scripts/equipment/", "slot_protection", creature.getSlotNameForObject(item)).__call__().asString()) / 100; + Float protectionAmount = Float.parseFloat((String) e.getValue()) * modifier; + + if(protection.containsKey(protectionType)) protection.replace(protectionType, protection.get(protectionType) + protectionAmount); + else protection.put(protectionType, protectionAmount); + incPieceCount = true; + } + } + if(incPieceCount) wornArmourPieces++; + } + + //if(wornArmourPieces >= 3) + //{ + for(Entry e : protection.entrySet()) + { + System.out.println("ProtectionType: " + e.getKey()); + System.out.println("ProtectionAmount: " + e.getValue()); + + core.skillModService.deductSkillMod(creature, e.getKey(), creature.getSkillModBase(e.getKey())); + core.skillModService.addSkillMod(creature, e.getKey(), (int) e.getValue().floatValue()); + } + //} + } - - private void addArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { - actor.addSkillMod(protectionType, (int) Math.ceil(calculateArmorProtection(protection, slotName))); - } - - private void deductArmorProtection(CreatureObject actor, String protectionType, float protection, String slotName) { - actor.deductSkillMod(protectionType, (int) calculateArmorProtection(protection, slotName)); - } - - private void addForceProtection(CreatureObject actor, SWGObject item) { - actor.addSkillMod("kinetic", getForceProtection(item)); - actor.addSkillMod("energy", getForceProtection(item)); - actor.addSkillMod("heat", getForceProtection(item)); - actor.addSkillMod("cold", getForceProtection(item)); - actor.addSkillMod("acid", getForceProtection(item)); - actor.addSkillMod("electricity", getForceProtection(item)); - } - - private void deductForceProtection(CreatureObject actor, SWGObject item) { - actor.deductSkillMod("kinetic", getForceProtection(item)); - actor.deductSkillMod("energy", getForceProtection(item)); - actor.deductSkillMod("heat", getForceProtection(item)); - actor.deductSkillMod("cold", getForceProtection(item)); - actor.deductSkillMod("acid", getForceProtection(item)); - actor.deductSkillMod("electricity", getForceProtection(item)); - } - - private int getForceProtection(SWGObject item) { - return core.scriptService.getMethod("scripts/equipment/", "force_protection", item.getAttachment("type") + "_" + item.getStringAttribute("protection_level")).__call__().asInt(); - } - + public void equip(CreatureObject actor, SWGObject item) { String template = ((item.getAttachment("customServerTemplate") == null) ? item.getTemplate() : (item.getTemplate().split("shared_")[0] + "shared_" + ((String) item.getAttachment("customServerTemplate")) + ".iff")); @@ -202,12 +220,14 @@ public class EquipmentService implements INetworkDispatch { { Map attributes = new TreeMap(item.getAttributes()); + calculateArmorProtection(creature, equipping); + if(equipping) { if(item.getStringAttribute("cat_wpn_damage.wpn_category") != null) creature.addSkillMod("display_only_critical", getWeaponCriticalChance(creature, item)); if(item.getStringAttribute("protection_level") != null) addForceProtection(creature, item); if(item.getStringAttribute("proc_name") != null) core.buffService.addBuffToCreature(creature, item.getStringAttribute("proc_name").replace("@ui_buff:", ""), creature); - + for(Entry e : attributes.entrySet()) { if(e.getKey().startsWith("cat_skill_mod_bonus.@stat_n:")) @@ -220,7 +240,7 @@ public class EquipmentService implements INetworkDispatch { core.skillModService.addSkillMod(creature, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); } - if(e.getKey().startsWith("cat_armor_standard_protection")) + /*if(e.getKey().startsWith("cat_armor_standard_protection")) { addArmorProtection(creature, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); } @@ -228,7 +248,7 @@ public class EquipmentService implements INetworkDispatch { if(e.getKey().startsWith("cat_armor_special_protection")) { addArmorProtection(creature, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); - } + } */ if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { @@ -259,7 +279,7 @@ public class EquipmentService implements INetworkDispatch { core.skillModService.deductSkillMod(creature, e.getKey().replace("cat_stat_mod_bonus.@stat_n:", ""), Integer.parseInt((String) e.getValue())); } - if(e.getKey().startsWith("cat_armor_standard_protection")) + /*if(e.getKey().startsWith("cat_armor_standard_protection")) { deductArmorProtection(creature, e.getKey().replace("cat_armor_standard_protection.armor_eff_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); } @@ -267,7 +287,7 @@ public class EquipmentService implements INetworkDispatch { if(e.getKey().startsWith("cat_armor_special_protection")) { deductArmorProtection(creature, e.getKey().replace("cat_armor_special_protection.special_protection_type_", ""), Float.parseFloat((String) e.getValue()), creature.getSlotNameForObject(item)); - } + } */ if(e.getKey().startsWith("cat_attrib_mod_bonus.attr_health")) { @@ -294,17 +314,42 @@ public class EquipmentService implements INetworkDispatch { public void loadBonusSets() { Path p = Paths.get("scripts/equipment/bonus_sets/"); - FileVisitor fv = new SimpleFileVisitor() { + FileVisitor fv = new SimpleFileVisitor() + { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException + { core.scriptService.callScript("scripts/equipment/bonus_sets/", file.getFileName().toString().replace(".py", ""), "addBonusSet", core); return FileVisitResult.CONTINUE; } }; - try { + try + { Files.walkFileTree(p, fv); - } catch (IOException e) { - e.printStackTrace(); - } + } + catch (IOException e) { e.printStackTrace(); } + } + + // Need to refactor below + private void addForceProtection(CreatureObject actor, SWGObject item) { + actor.addSkillMod("kinetic", getForceProtection(item)); + actor.addSkillMod("energy", getForceProtection(item)); + actor.addSkillMod("heat", getForceProtection(item)); + actor.addSkillMod("cold", getForceProtection(item)); + actor.addSkillMod("acid", getForceProtection(item)); + actor.addSkillMod("electricity", getForceProtection(item)); + } + + private void deductForceProtection(CreatureObject actor, SWGObject item) { + actor.deductSkillMod("kinetic", getForceProtection(item)); + actor.deductSkillMod("energy", getForceProtection(item)); + actor.deductSkillMod("heat", getForceProtection(item)); + actor.deductSkillMod("cold", getForceProtection(item)); + actor.deductSkillMod("acid", getForceProtection(item)); + actor.deductSkillMod("electricity", getForceProtection(item)); + } + + private int getForceProtection(SWGObject item) { + return core.scriptService.getMethod("scripts/equipment/", "force_protection", item.getAttachment("type") + "_" + item.getStringAttribute("protection_level")).__call__().asInt(); } } From ef1d499a97f4454442b4a0f4acc1d3dc037ec197 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:39:32 +0100 Subject: [PATCH 15/26] Uncommented line in sendListDelta() --- src/resources/objects/creature/CreatureMessageBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 8b96fced..0ac1fa79 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -1226,7 +1226,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer = createDelta("CREO", (byte) 4, (short) 1, (byte) 3, buffer.flip(), buffer.array().length + 4); if (object.getClient() != null && object.getClient().getSession() != null) { - //object.getClient().getSession().write(buffer); + object.getClient().getSession().write(buffer); } break; } From d187b0b3ea1d174b4488a3d5a771478cc682fed3 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:46:12 +0100 Subject: [PATCH 16/26] Removed skillModUpdateCounter functions --- src/resources/objects/creature/CreatureObject.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 806efd32..e7185b29 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -607,19 +607,6 @@ public class CreatureObject extends TangibleObject implements IPersistent { skillMods.remove(mod.getName()); } - public short getSkillModsUpdateCounter() { - synchronized(objectMutex) { - return (short) skillModsUpdateCounter; - } - } - - public void setSkillModsUpdateCounter(short skillModsUpdateCounter) { - synchronized(objectMutex) { - this.skillModsUpdateCounter = skillModsUpdateCounter; - } - } - - public float getSpeedMultiplierBase() { synchronized(objectMutex) { return speedMultiplierBase; From 4f45f62d0b0dee789f09eb5f49ca273b72e22571 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:51:20 +0100 Subject: [PATCH 17/26] Updated skillMod baseline, removed old deltas --- .../creature/CreatureMessageBuilder.java | 59 ++----------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 0ac1fa79..e5ea5109 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -157,20 +157,13 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(0); // HAM Encumberance List unused in NGE buffer.putInt(0); - if(creature.getSkillMods().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(creature.getSkillMods().size()); - buffer.putInt(creature.getSkillMods().getUpdateCounter()); - - for(SkillMod skillMod : creature.getSkillMods()) { - buffer.put((byte) 0); - buffer.put(getAsciiString(skillMod.getName())); - buffer.putInt(skillMod.getBase()); - buffer.putInt((int) skillMod.getModifier()); - } + buffer.putInt(creature.getSkillMods().size()); + buffer.putInt(creature.getSkillMods().getUpdateCounter()); + for (SkillMod skillMod : creature.getSkillMods().values()) { + buffer.put((byte) 0); + buffer.put(skillMod.getBytes()); } + buffer.putFloat(creature.getSpeedMultiplierBase()); buffer.putFloat(creature.getSpeedMultiplierMod()); @@ -850,46 +843,6 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } - public IoBuffer buildAddSkillModDelta(String name, int base) { - - CreatureObject creature = (CreatureObject) object; - - IoBuffer buffer = bufferPool.allocate(19 + name.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(1); - buffer.putInt(creature.getSkillModsUpdateCounter()); - buffer.put((byte) 0); - buffer.put(getAsciiString(name)); - buffer.putInt(base); - buffer.putInt(0); - - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 3, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildRemoveSkillModDelta(String name, int base) { - - CreatureObject creature = (CreatureObject) object; - - IoBuffer buffer = bufferPool.allocate(19 + name.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(1); - buffer.putInt(creature.getSkillModsUpdateCounter()); - buffer.put((byte) 1); - buffer.put(getAsciiString(name)); - buffer.putInt(base); - buffer.putInt(0); - - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 3, buffer, size + 4); - - return buffer; - - } - public IoBuffer buildAddSkillDelta(String name) { CreatureObject creature = (CreatureObject) object; From 977f18e5331668583a531384327bbd29d7531c13 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:54:38 +0100 Subject: [PATCH 18/26] Fixed error --- src/resources/objects/creature/CreatureObject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index e7185b29..32601efb 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -559,7 +559,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { } } - public SWGMap getSkillMods() { + public SWGMap getSkillMods() { return skillMods; } From f97b23ae5c5c8d2f6b7f9341e9b83a11943d566c Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:57:51 +0100 Subject: [PATCH 19/26] Updated SkillMod.java to work with a map --- src/resources/objects/SkillMod.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/resources/objects/SkillMod.java b/src/resources/objects/SkillMod.java index d155b882..a9550ce4 100644 --- a/src/resources/objects/SkillMod.java +++ b/src/resources/objects/SkillMod.java @@ -67,12 +67,9 @@ public class SkillMod extends Delta { @Override public byte[] getBytes() { - IoBuffer buffer = createBuffer(name.length() + 10); - - buffer.put(getAsciiString(name)); + IoBuffer buffer = createBuffer(8); buffer.putInt(base); buffer.putInt((int) modifier); - return buffer.array(); } From 401c575ead8670f2e9251fa30a27f08116230967 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 16:59:09 +0100 Subject: [PATCH 20/26] Fixed skillMod-related crash --- src/resources/objects/creature/CreatureMessageBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index e5ea5109..fd27ace9 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -161,6 +161,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(creature.getSkillMods().getUpdateCounter()); for (SkillMod skillMod : creature.getSkillMods().values()) { buffer.put((byte) 0); + buffer.put(skillMod.getName()); buffer.put(skillMod.getBytes()); } From 40e17095f7e40d3d4b1888d39303cb395c2c7c22 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 17:14:38 +0100 Subject: [PATCH 21/26] Fixed crash --- src/resources/objects/creature/CreatureMessageBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index fd27ace9..23b6ed4f 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -161,7 +161,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(creature.getSkillMods().getUpdateCounter()); for (SkillMod skillMod : creature.getSkillMods().values()) { buffer.put((byte) 0); - buffer.put(skillMod.getName()); + buffer.put(getAsciiString(skillMod.getName())); buffer.put(skillMod.getBytes()); } From 068398371042a794db8a78c2db4388b9c51bc112 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 18:01:52 +0100 Subject: [PATCH 22/26] Added null check for removing skillMods --- src/resources/objects/creature/CreatureObject.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 32601efb..78ac322c 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -604,7 +604,9 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public void removeSkillMod(SkillMod mod) { - skillMods.remove(mod.getName()); + if (mod != null) { + skillMods.remove(mod.getName()); + } } public float getSpeedMultiplierBase() { From 4aa2daa1ac6b86c2f1bba58af9d74cc84d53173c Mon Sep 17 00:00:00 2001 From: Seefo Date: Thu, 3 Apr 2014 13:03:57 -0400 Subject: [PATCH 23/26] Fixed an error in the Player Service --- src/services/PlayerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 7ccc070e..cd7d95a5 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -595,7 +595,7 @@ public class PlayerService implements INetworkDispatch { try { String[] skills; - skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class); + 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) { From 1fdb6f0ad1e59e2012e4f53d6a336cdc77f48782 Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 18:16:00 +0100 Subject: [PATCH 24/26] Some SWGMap fixes --- src/resources/objects/SWGMap.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/resources/objects/SWGMap.java b/src/resources/objects/SWGMap.java index 0227a725..923ccff4 100644 --- a/src/resources/objects/SWGMap.java +++ b/src/resources/objects/SWGMap.java @@ -119,13 +119,17 @@ public class SWGMap implements Map { if (map.containsKey(key)) { V oldValue = map.put(key, value); - queue(item(2, (String) key, ((IDelta) value).getBytes(), true, true)); + if (oldValue != null) { + queue(item(2, (String) key, ((IDelta) value).getBytes(), true, true)); + } return oldValue; } else { V oldValue = map.put(key, value); - queue(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + if (oldValue != null) { + queue(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + } return oldValue; } @@ -170,7 +174,9 @@ public class SWGMap implements Map { key instanceof Integer || key instanceof Float || key instanceof Long) { V value = map.remove(key); - queue(item(1, key, ((IDelta) map.get(key)).getBytes(), true, true)); + if (value != null) { + queue(item(1, key, ((IDelta) map.get(key)).getBytes(), true, true)); + } return value; } @@ -230,6 +236,7 @@ public class SWGMap implements Map { } } if (useData) buffer.put(data); + buffer.flip(); updateCounter++; @@ -241,6 +248,7 @@ public class SWGMap implements Map { buffer.putInt(1); buffer.putInt(updateCounter); buffer.put(data); + buffer.flip(); messageBuilder.sendListDelta(viewType, updateType, buffer); } @@ -255,6 +263,7 @@ public class SWGMap implements Map { buffer.putInt(data.size()); buffer.putInt(updateCounter); for (byte[] queued : data) buffer.put(queued); + buffer.flip(); messageBuilder.sendListDelta(viewType, updateType, buffer); } From f3f57b5d75a89fc50da7afc60ee357231b8b9fde Mon Sep 17 00:00:00 2001 From: Treeku Date: Thu, 3 Apr 2014 18:24:42 +0100 Subject: [PATCH 25/26] Fixed problem with grantLevel --- src/services/PlayerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index cd7d95a5..074eedf5 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -558,7 +558,7 @@ public class PlayerService implements INetworkDispatch { } /* - * Resets to level 0 + * Resets to level 1 */ public void resetLevel(CreatureObject creature) { PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); @@ -634,7 +634,7 @@ public class PlayerService implements INetworkDispatch { creature.setAction(300); creature.setGrantedHealth(0); - creature.setLevel((short) 0); + creature.setLevel((short) 1); } /* From f6c03c19aa548f900e938773d4293be03a43b5a3 Mon Sep 17 00:00:00 2001 From: Seefo Date: Thu, 3 Apr 2014 13:42:53 -0400 Subject: [PATCH 26/26] Fixed remove skill mod error, some equipment stuff aswell --- .../objects/creature/CreatureObject.java | 2 +- src/services/EquipmentService.java | 24 +++++++++---------- src/services/PlayerService.java | 6 ++--- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 78ac322c..40f7d8f0 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -605,7 +605,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void removeSkillMod(SkillMod mod) { if (mod != null) { - skillMods.remove(mod.getName()); + skillMods.remove(mod); } } diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index 3edd96f7..1f5c9348 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -332,21 +332,21 @@ public class EquipmentService implements INetworkDispatch { // Need to refactor below private void addForceProtection(CreatureObject actor, SWGObject item) { - actor.addSkillMod("kinetic", getForceProtection(item)); - actor.addSkillMod("energy", getForceProtection(item)); - actor.addSkillMod("heat", getForceProtection(item)); - actor.addSkillMod("cold", getForceProtection(item)); - actor.addSkillMod("acid", getForceProtection(item)); - actor.addSkillMod("electricity", getForceProtection(item)); + core.skillModService.addSkillMod(actor, "kinetic", getForceProtection(item)); + core.skillModService.addSkillMod(actor, "energy", getForceProtection(item)); + core.skillModService.addSkillMod(actor, "heat", getForceProtection(item)); + core.skillModService.addSkillMod(actor, "cold", getForceProtection(item)); + core.skillModService.addSkillMod(actor, "acid", getForceProtection(item)); + core.skillModService.addSkillMod(actor, "electricity", getForceProtection(item)); } private void deductForceProtection(CreatureObject actor, SWGObject item) { - actor.deductSkillMod("kinetic", getForceProtection(item)); - actor.deductSkillMod("energy", getForceProtection(item)); - actor.deductSkillMod("heat", getForceProtection(item)); - actor.deductSkillMod("cold", getForceProtection(item)); - actor.deductSkillMod("acid", getForceProtection(item)); - actor.deductSkillMod("electricity", getForceProtection(item)); + core.skillModService.deductSkillMod(actor, "kinetic", getForceProtection(item)); + core.skillModService.deductSkillMod(actor, "energy", getForceProtection(item)); + core.skillModService.deductSkillMod(actor, "heat", getForceProtection(item)); + core.skillModService.deductSkillMod(actor, "cold", getForceProtection(item)); + core.skillModService.deductSkillMod(actor, "acid", getForceProtection(item)); + core.skillModService.deductSkillMod(actor, "electricity", getForceProtection(item)); } private int getForceProtection(SWGObject item) { diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 074eedf5..9df745c2 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -652,11 +652,9 @@ public class PlayerService implements INetworkDispatch { return; } - resetLevel(creature); + if(level == 0) return; - if (level == 0) { - return; - } + resetLevel(creature); try { experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class);