private int getForceProtection(SWGObject item) { return core.scriptService .getMethod( "scripts/equipment/", "force_protection", item.getAttachment("type") + "_" + item.getStringAttribute("protection_level")) .__call__() .asInt(); }
public boolean canEquip(CreatureObject actor, SWGObject item) { // TODO: Species restrictions // TODO: Gender restrictions boolean result = true; if (item == null) return false; if (item.getAttributes().toString().contains("cat_armor")) { 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(core.playerService.getFormalProfessionName(profession)) || item.getStringAttribute("class_required").contentEquals("None")) result = true; else return false; } if (item.getStringAttribute("faction_restriction") != null) if (item.getStringAttribute("faction_restriction") .toLowerCase() .contentEquals(actor.getFaction()) && actor.getFactionStatus() >= FactionStatus.Combatant) result = true; else 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; }
private int getWeaponCriticalChance(CreatureObject actor, SWGObject item) { int weaponCriticalChance = 0; String weaponCriticalSkillMod = (core.scriptService .getMethod( "scripts/equipment/", "weapon_critical", item.getStringAttribute("cat_wpn_damage.wpn_category")) .__call__() .asString()); if (weaponCriticalSkillMod.contains(" ")) weaponCriticalSkillMod.replace(" ", ""); if (weaponCriticalSkillMod.contains("-")) weaponCriticalSkillMod.replace("-", ""); if (actor.getSkillMod(weaponCriticalSkillMod) != null) weaponCriticalChance = actor.getSkillModBase(weaponCriticalSkillMod); return weaponCriticalChance; }
private void calculateArmorProtection(CreatureObject creature, boolean equipping) { int wornArmourPieces = 0, forceProtection = 0; Map<String, Float> protection = new TreeMap<String, Float>(); for (SWGObject item : new ArrayList<SWGObject>(creature.getEquipmentList())) { Map<String, Object> attributes = new TreeMap<String, Object>(item.getAttributes()); boolean incPieceCount = false; if (item.getStringAttribute("protection_level") != null) { forceProtection = getForceProtection(item); break; } for (Entry<String, Object> 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 (protection.size() == 0) { protection.put("kinetic", (float) 0); protection.put("energy", (float) 0); protection.put("heat", (float) 0); protection.put("cold", (float) 0); protection.put("acid", (float) 0); protection.put("electricity", (float) 0); } for (Entry<String, Float> e : protection.entrySet()) { core.skillModService.deductSkillMod( creature, e.getKey(), creature.getSkillModBase(e.getKey())); core.skillModService.addSkillMod(creature, e.getKey(), forceProtection); if (wornArmourPieces >= 3) core.skillModService.addSkillMod(creature, e.getKey(), (int) e.getValue().floatValue()); } }
public void processItemAtrributes(CreatureObject creature, SWGObject item, boolean equipping) { // TODO: crit enhancement from crafted weapons // TODO: check for armor category in order to add resistance to certain DoT types Map<String, Object> attributes = new TreeMap<String, Object>(item.getAttributes()); if (equipping) { if (item.getStringAttribute("cat_wpn_damage.wpn_category") != null) creature.addSkillMod("display_only_critical", getWeaponCriticalChance(creature, item)); if (item.getStringAttribute("proc_name") != null) core.buffService.addBuffToCreature( creature, item.getStringAttribute("proc_name").replace("@ui_buff:", ""), creature); for (Entry<String, Object> 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_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("proc_name") != null) core.buffService.removeBuffFromCreatureByName( creature, item.getStringAttribute("proc_name").replace("@ui_buff:", "")); for (Entry<String, Object> 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_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())); } } } calculateArmorProtection(creature, equipping); if (item.getAttachment("setBonus") != null) { BonusSetTemplate bonus = bonusSetTemplates.get((String) item.getAttachment("setBonus")); bonus.callScript(creature); } }