From b26374faf7196c9c8b627d0139996c6e65e00a3b Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Tue, 24 Dec 2013 00:23:17 +0100 Subject: [PATCH] Items - Profession restrictions --- scripts/commands/transferitemarmor.py | 3 ++ scripts/commands/transferitemmisc.py | 3 ++ scripts/commands/transferitemweapon.py | 3 ++ src/services/EquipmentService.java | 53 +++++++++++++++++++++----- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/scripts/commands/transferitemarmor.py b/scripts/commands/transferitemarmor.py index b5090996..2b890936 100644 --- a/scripts/commands/transferitemarmor.py +++ b/scripts/commands/transferitemarmor.py @@ -4,6 +4,9 @@ def setup(): return def run(core, actor, target, commandString): + if core.equipmentService.canEquip(actor, target) is False: + return + parsedMsg = commandString.split(' ', 3) objService = core.objectService containerID = long(parsedMsg[1]) diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 7a3f5199..79ef9455 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -4,6 +4,9 @@ def setup(): return def run(core, actor, target, commandString): + if core.equipmentService.canEquip(actor, target) is False: + return + parsedMsg = commandString.split(' ', 3) objService = core.objectService containerID = long(parsedMsg[1]) diff --git a/scripts/commands/transferitemweapon.py b/scripts/commands/transferitemweapon.py index 8c54e57a..9b403eaf 100644 --- a/scripts/commands/transferitemweapon.py +++ b/scripts/commands/transferitemweapon.py @@ -4,6 +4,9 @@ def setup(): return def run(core, actor, target, commandString): + if core.equipmentService.canEquip(actor, target) is False: + return + parsedMsg = commandString.split(' ', 3) objService = core.objectService containerID = long(parsedMsg[1]) diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index 975125ce..417bf093 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -33,6 +33,7 @@ import main.NGECore; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; +import resources.objects.player.PlayerObject; public class EquipmentService implements INetworkDispatch { @@ -88,11 +89,42 @@ public class EquipmentService implements INetworkDispatch { } } + 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; + + if (item.getStringAttribute("class_required") != null) { + String profession = ((PlayerObject) actor.getSlottedObject("ghost")).getProfession(); + if (item.getStringAttribute("class_required").contentEquals(getFormalProfessionName(profession))) { + result = true; + } else{ + return false; + } + } + + return result; + } + public void equip(CreatureObject actor, SWGObject item) { - //if(replacedItem != null) - // unequip(actor, replacedItem); - 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"); @@ -100,14 +132,18 @@ public class EquipmentService implements INetworkDispatch { func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item)); // TODO: add health/action bonus from crafted weapon with augmentations (also seen with cybernetics) - // TODO: faction restrictions - // TODO: Species restrictions? - // TODO: Gender restrictions? + // TODO: faction restrictions - You had to be a Combatant as minimum in order to EQUIP an item. + // TODO: Species restrictions + // TODO: Gender restrictions // TODO: crit enhancement from crafted weapons // TODO: Jedi robes Force Protection Intensity // TODO: check for armor category in order to add resistance to certain DoT types - // TODO: if weapon, add the weapon specific crit to display_only_critical - // TODO: bio-link + // 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 it as a character name). + // TODO: item level requirement. if actorLevel >= itemLevel + // TODO: refactor equipable items that grant buffs. use setAttachment("itemBuff", "buffname") - example: object.setAttachment("itemBuff", "fs_buff_def_1_1") + // if(item.getAttachment("itemBuff") != null ) + // core.buffService.addBuffToCreature(actor, item.getAttachment("itemBuff")); if (actor.getSlotNameForObject(item).contentEquals("hold_r") == true) weaponCriticalToDisplay(actor, item, true); @@ -115,7 +151,6 @@ public class EquipmentService implements INetworkDispatch { 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())); }