mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-08-04 05:16:21 -04:00
@@ -15,13 +15,16 @@ def run(core, actor, target, commandString):
|
||||
if container == oldContainer:
|
||||
print 'Error: New container is same as old container.'
|
||||
return;
|
||||
|
||||
if oldContainer == actor.getSlottedObject('appearance_inventory'):
|
||||
core.equipmentService.unequipAppearance(actor, target)
|
||||
|
||||
oldContainer.transferTo(actor, container, target)
|
||||
|
||||
if container == actor.getSlottedObject('appearance_inventory'):
|
||||
core.equipmentService.equipAppearance(actor, target)
|
||||
|
||||
|
||||
if oldContainer == actor:
|
||||
core.equipmentService.unequip(actor, target)
|
||||
elif oldContainer == actor.getSlottedObject('appearance_inventory'):
|
||||
core.equipmentService.unequipAppearance(actor, target)
|
||||
elif container == actor:
|
||||
core.equipmentService.equip(actor, target)
|
||||
elif container == actor.getSlottedObject('appearance_inventory'):
|
||||
core.equipmentService.equipAppearance(actor, target)
|
||||
else:
|
||||
oldContainer.transferTo(actor, container, target)
|
||||
|
||||
return
|
||||
|
||||
@@ -58,12 +58,15 @@ def run(core, actor, target, commandString):
|
||||
print 'Error: New container is same as old container.'
|
||||
return;
|
||||
|
||||
if oldContainer == actor.getSlottedObject('appearance_inventory'):
|
||||
if oldContainer == actor:
|
||||
core.equipmentService.unequip(actor, target)
|
||||
elif oldContainer == actor.getSlottedObject('appearance_inventory'):
|
||||
core.equipmentService.unequipAppearance(actor, target)
|
||||
|
||||
oldContainer.transferTo(actor, container, target)
|
||||
|
||||
if container == actor.getSlottedObject('appearance_inventory'):
|
||||
elif container == actor:
|
||||
core.equipmentService.equip(actor, target)
|
||||
elif container == actor.getSlottedObject('appearance_inventory'):
|
||||
core.equipmentService.equipAppearance(actor, target)
|
||||
else:
|
||||
oldContainer.transferTo(actor, container, target)
|
||||
|
||||
return
|
||||
|
||||
@@ -16,7 +16,11 @@ def run(core, actor, target, commandString):
|
||||
print 'Error: New container is same as old container.'
|
||||
return;
|
||||
|
||||
oldContainer.transferTo(actor, container, target)
|
||||
if oldContainer == actor:
|
||||
core.equipmentService.unequip(actor, target)
|
||||
elif container == actor:
|
||||
core.equipmentService.equip(actor, target)
|
||||
else:
|
||||
oldContainer.transferTo(actor, container, target)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -899,7 +899,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
public boolean isWearing(SWGObject object) {
|
||||
for (Equipment equipment : getEquipmentList()) {
|
||||
if (equipment.getObjectId() == object.getObjectId()) {
|
||||
if (equipment.getObjectId() == object.getObjectID()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -907,10 +907,26 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Equipment getEquipmentForObject(SWGObject object) {
|
||||
for (Equipment equipment : getEquipmentList()) {
|
||||
if (equipment.getObjectId() == object.getObjectID()) {
|
||||
return equipment;
|
||||
}
|
||||
}
|
||||
|
||||
for (Equipment equipment : getAppearanceEquipmentList()) {
|
||||
if (equipment.getObjectId() == object.getObjectID()) {
|
||||
return equipment;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeObjectFromEquipList(SWGObject object) {
|
||||
if (object instanceof TangibleObject) {
|
||||
for (Equipment equipment : getEquipmentList()) {
|
||||
if (equipment.getObjectId() == object.getObjectId()) {
|
||||
if (equipment.getObjectId() == object.getObjectID()) {
|
||||
getEquipmentList().remove(equipment);
|
||||
}
|
||||
}
|
||||
@@ -1131,7 +1147,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
public boolean isWearingAppearance(SWGObject object) {
|
||||
for (Equipment equipment : getAppearanceEquipmentList()) {
|
||||
if (equipment.getObjectId() == object.getObjectId()) {
|
||||
if (equipment.getObjectId() == object.getObjectID()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1142,7 +1158,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
public void removeObjectFromAppearanceEquipList(SWGObject object) {
|
||||
if (object instanceof TangibleObject) {
|
||||
for (Equipment equipment : getAppearanceEquipmentList()) {
|
||||
if (equipment.getObjectId() == object.getObjectId()) {
|
||||
if (equipment.getObjectId() == object.getObjectID()) {
|
||||
getAppearanceEquipmentList().remove(equipment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -787,27 +787,24 @@ public class PlayerService implements INetworkDispatch {
|
||||
public void resetLevel(CreatureObject creature, boolean unequipItems) {
|
||||
PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");
|
||||
SWGObject inventory = creature.getSlottedObject("inventory");
|
||||
SWGObject appearance = creature.getSlottedObject("appearance_inventory");
|
||||
|
||||
if (unequipItems) {
|
||||
try {
|
||||
for (Equipment equipmentObject : new ArrayList<Equipment>(creature.getEquipmentList())) {
|
||||
|
||||
SWGObject equipment = core.objectService.getObject(equipmentObject.getObjectId());
|
||||
|
||||
if (equipment == null || equipment.getTemplate().startsWith("object/tangible/hair/")) {
|
||||
continue;
|
||||
String[] slots = { "hat", "earring_r", "earring_l", "eyes", "mouth", "neck", "cloak", "back", "chest1", "chest2", "chest3_r", "chest3_l", "bicep_r", "bicep_l", "bracer_lower_r", "bracer_upper_r", "bracer_lower_l", "bracer_upper_l", "wrist_r", "wrist_l", "gloves", "hold_r", "hold_l", "ring_r", "ring_l", "utility_belt", "pants1", "pants2", "shoes" };
|
||||
|
||||
for (String slot : slots) {
|
||||
if (creature.getSlottedObject(slot) != null) {
|
||||
core.equipmentService.unequip(creature, creature.getSlottedObject(slot));
|
||||
}
|
||||
|
||||
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:
|
||||
creature.transferTo(creature, inventory, equipment);
|
||||
}
|
||||
|
||||
|
||||
slots = { "hat", "earring_r", "earring_l", "eyes", "mouth", "neck", "cloak", "back", "chest1", "chest2", "chest3_r", "chest3_l", "bicep_r", "bicep_l", "bracer_lower_r", "bracer_upper_r", "bracer_lower_l", "bracer_upper_l", "wrist_r", "wrist_l", "gloves", "utility_belt", "pants1", "pants2", "shoes" };
|
||||
|
||||
for (String slot : slots) {
|
||||
if (appearance.getSlottedObject(slot) != null) {
|
||||
core.equipmentService.unequip(creature, creature.getSlottedObject(slot));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -815,10 +812,6 @@ public class PlayerService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
//for (SWGObject equipment : creature.getAppearanceEquipmentList()) {
|
||||
//core.equipmentService.unequip(creature, equipment);
|
||||
//}
|
||||
|
||||
for (Buff buff : creature.getBuffList().values().toArray(new Buff[] { })) {
|
||||
if (buff.isRemoveOnRespec()) {
|
||||
core.buffService.removeBuffFromCreature(creature, buff);
|
||||
|
||||
@@ -63,14 +63,38 @@ public class EquipmentService implements INetworkDispatch {
|
||||
|
||||
public void equip(CreatureObject actor, SWGObject item) {
|
||||
SWGObject container = actor;
|
||||
SWGObject oldContainer = item.getContainer();
|
||||
|
||||
if (canWear(actor, container, item)) {
|
||||
Vector<String> slotNames = container.getSlotNamesForObject(item);
|
||||
List<Equipment> replacedEquipment = new ArrayList<Equipment>();
|
||||
|
||||
for (String slotName : slotNames) {
|
||||
if (container.getSlottedObject(slotName) != null && !slotNames.iterator().hasNext()) {
|
||||
for (String slotName : container.getSlotNamesForObject(item)) {
|
||||
if (container.getSlottedObject(slotName) != null) {
|
||||
replacedEquipment.add(actor.getEquipmentForObject(container.getSlottedObject(slotName)));
|
||||
container.transferTo(actor, actor.getSlottedObject("inventory"), container.getSlottedObject(slotName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldContainer == null) {
|
||||
container.add(item);
|
||||
} else {
|
||||
oldContainer.transferTo(actor, container, item);
|
||||
}
|
||||
|
||||
for (SWGObject replacedItem : replacedEquipment) {
|
||||
if (actor.isWearing(replacedItem)) {
|
||||
String template = ((replacedItem.getAttachment("customServerTemplate") == null) ? replacedItem.getTemplate() : (replacedItem.getTemplate().split("shared_")[0] + "shared_" + ((String) replacedItem.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(replacedItem));
|
||||
}
|
||||
|
||||
processItemAtrributes(actor, replacedItem, false);
|
||||
} else {
|
||||
replacedEquipment.remove(replacedItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,9 +107,14 @@ public class EquipmentService implements INetworkDispatch {
|
||||
func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item));
|
||||
}
|
||||
|
||||
actor.addObjectToEquipList(item);
|
||||
processItemAtrributes(actor, item, true);
|
||||
|
||||
if (replacedEquipment.size() > 0) {
|
||||
actor.getEquipmentList().removeAll(replacedEquipment);
|
||||
}
|
||||
|
||||
actor.addObjectToEquipList(item);
|
||||
|
||||
if (item instanceof WeaponObject) {
|
||||
actor.setWeaponId(item.getObjectID());
|
||||
}
|
||||
@@ -93,7 +122,16 @@ public class EquipmentService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public void unequip(CreatureObject actor, SWGObject item) {
|
||||
SWGObject container = actor.getSlottedObject("inventory");
|
||||
SWGObject oldContainer = item.getContainer();
|
||||
|
||||
if (actor.isWearing(item)) {
|
||||
if (item instanceof WeaponObject) {
|
||||
actor.setWeaponId(actor.getSlottedObject("default_weapon").getObjectID());
|
||||
}
|
||||
|
||||
oldContainer.transferTo(actor, container, 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", "");
|
||||
|
||||
@@ -103,33 +141,40 @@ public class EquipmentService implements INetworkDispatch {
|
||||
func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item));
|
||||
}
|
||||
|
||||
if (item instanceof WeaponObject) {
|
||||
actor.setWeaponId(actor.getSlottedObject("default_weapon").getObjectID());
|
||||
}
|
||||
processItemAtrributes(actor, item, false);
|
||||
|
||||
actor.removeObjectFromEquipList(item);
|
||||
processItemAtrributes(actor, item, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void equipAppearance(CreatureObject actor, SWGObject item) {
|
||||
SWGObject container = actor.getSlottedObject("appearance_inventory");
|
||||
SWGObject oldContainer = item.getContainer();
|
||||
|
||||
if (canWear(actor, container, item)) {
|
||||
Vector<String> slotNames = container.getSlotNamesForObject(item);
|
||||
|
||||
for (String slotName : slotNames) {
|
||||
if (container.getSlottedObject(slotName) != null && !slotNames.iterator().hasNext()) {
|
||||
for (String slotName : container.getSlotNamesForObject(item)) {
|
||||
if (container.getSlottedObject(slotName) != null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldContainer == null) {
|
||||
container.add(item);
|
||||
} else {
|
||||
container.transferTo(actor, container, item);
|
||||
}
|
||||
|
||||
actor.addObjectToAppearanceEquipList(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void unequipAppearance(CreatureObject actor, SWGObject item) {
|
||||
if (actor.isWearingAppearance(item) ) {
|
||||
SWGObject container = actor.getSlottedObject("inventory");
|
||||
SWGObject oldContainer = item.getContainer();
|
||||
|
||||
if (actor.isWearingAppearance(item)) {
|
||||
oldContainer.transferTo(actor, container, item);
|
||||
|
||||
actor.removeObjectFromAppearanceEquipList(item);
|
||||
}
|
||||
}
|
||||
@@ -154,9 +199,7 @@ public class EquipmentService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
if (item.getAttributes().toString().contains("cat_armor")) {
|
||||
if (actor.hasAbility("wear_all_armor")) {
|
||||
return true;
|
||||
} else {
|
||||
if (!actor.hasAbility("wear_all_armor")) {
|
||||
actor.sendSystemMessage("@error_message:insufficient_skill", DisplayType.Broadcast); // I am unsure if this is the right message
|
||||
return false;
|
||||
}
|
||||
@@ -166,27 +209,21 @@ public class EquipmentService implements INetworkDispatch {
|
||||
String classRequired = item.getStringAttribute("class_required");
|
||||
String profession = ((PlayerObject) actor.getSlottedObject("ghost")).getProfession();
|
||||
|
||||
if (classRequired.contains(core.playerService.getFormalProfessionName(profession)) || classRequired.equals("None")) {
|
||||
return true;
|
||||
} else {
|
||||
if (!classRequired.contains(core.playerService.getFormalProfessionName(profession)) && !classRequired.equals("None")) {
|
||||
actor.sendSystemMessage("@error_message:insufficient_skill", DisplayType.Broadcast); // I am unsure if this is the right message
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getStringAttribute("faction_restriction") != null) {
|
||||
if (item.getStringAttribute("faction_restriction").toLowerCase().contentEquals(actor.getFaction()) && actor.getFactionStatus() >= FactionStatus.Combatant) {
|
||||
return true;
|
||||
} else {
|
||||
if (!item.getStringAttribute("faction_restriction").toLowerCase().contentEquals(actor.getFaction()) || actor.getFactionStatus() < FactionStatus.Combatant) {
|
||||
actor.sendSystemMessage("@faction_recruiter:must_be_faction_member_use", DisplayType.Broadcast); // will have to somehow manage prose %TO for faction name
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getAttributes().containsKey("required_combat_level")) {
|
||||
if (actor.getLevel() >= item.getIntAttribute("required_combat_level")) {
|
||||
return true;
|
||||
} else {
|
||||
if (actor.getLevel() < item.getIntAttribute("required_combat_level")) {
|
||||
actor.sendSystemMessage("@error_message:insufficient_skill", DisplayType.Broadcast); // I am unsure if this is the right message
|
||||
return false;
|
||||
}
|
||||
@@ -623,7 +660,7 @@ public class EquipmentService implements INetworkDispatch {
|
||||
FileVisitor<Path> fv = new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
core.scriptService.callScript("scripts/equipment/bonus_sets/", file.getFileName().toString().replace(".py", ""), "addBonusSet", core);
|
||||
core.scriptService.callScript("scripts/equipment/bonus_sets/", file.getFileName().toString().replace(".py", ""), "addBonusSet", core);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user