From dd39f1617c6cd644db51ef4996fd69a430bac30f Mon Sep 17 00:00:00 2001 From: Seefo Date: Sat, 21 Jun 2014 03:35:28 -0400 Subject: [PATCH] Fixed several equipment bugs where stats wouldn't be properly removed or added Updated engine must be committed for this fix to work - please wait --- scripts/commands/transferitemarmor.py | 72 +++++----- scripts/commands/transferitemmisc.py | 130 +++++++++---------- scripts/commands/transferitemweapon.py | 34 ++--- src/services/equipment/EquipmentService.java | 4 + 4 files changed, 106 insertions(+), 134 deletions(-) diff --git a/scripts/commands/transferitemarmor.py b/scripts/commands/transferitemarmor.py index 8e166cbc..c78c862c 100644 --- a/scripts/commands/transferitemarmor.py +++ b/scripts/commands/transferitemarmor.py @@ -12,51 +12,41 @@ def run(core, actor, target, commandString): canEquip = core.equipmentService.canEquip(actor, target) + if target and container and target.getContainer(): + oldContainer = target.getContainer() + + if container == oldContainer: + print 'Error: New container is same as old container.' + return; + if canEquip[0] is False and container == actor: actor.sendSystemMessage(canEquip[1], 0) return + + replacedObject = None + slotName = None + replacedObjects = [] + slotNames = None + + if actor == container: + slotNames = container.getSlotNamesForObject(target) + + for slotName in slotNames: + object = container.getSlottedObject(slotName) + + if not object in replacedObjects and not object == None: + replacedObjects.append(object) + + if object != None: + actor.transferTo(actor, oldContainer, object) - if target and container and target.getContainer(): - oldContainer = target.getContainer() - if container == oldContainer: - print 'Error: New container is same as old container.' - return; - replacedObject = None - slotName = None - replacedObjects = [] - slotNames = None - if actor == container: - slotNames = container.getSlotNamesForObject(target) - for slotName in slotNames: - object = container.getSlottedObject(slotName) - if not object in replacedObjects and not object == None: - replacedObjects.append(object) - - oldContainer.transferTo(actor, container, target) - - if actor == container: - if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): - core.equipmentService.equip(actor, target) - for object in replacedObjects: - core.equipmentService.unequip(actor, object) - #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' - #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') - #core.scriptService.callScript(path, 'equip', module, core, actor, target) - - if container == actor.getSlottedObject('appearance_inventory'): - actor.addObjectToAppearanceEquipList(target) - for object in replacedObjects: - actor.removeObjectFromAppearanceEquipList(object) - - if oldContainer == actor.getSlottedObject('appearance_inventory'): - actor.removeObjectFromAppearanceEquipList(target) - - if actor == oldContainer: - if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): - #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' - #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') - #core.scriptService.callScript(path, 'unequip', module, core, actor, target) - core.equipmentService.unequip(actor, target, replacedObject) + oldContainer.transferTo(actor, container, target) + if oldContainer == actor.getSlottedObject('appearance_inventory'): + actor.removeObjectFromAppearanceEquipList(target) + + if container == actor.getSlottedObject('appearance_inventory'): + actor.addObjectToAppearanceEquipList(target) + return \ No newline at end of file diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 9680da3e..fe26a0fa 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -2,102 +2,90 @@ import sys from engine.resources.scene import Quaternion def setup(): - return - + return + def run(core, actor, target, commandString): - parsedMsg = commandString.split(' ', 3) - objService = core.objectService - containerID = long(parsedMsg[1]) - container = objService.getObject(containerID) - actorContainer = actor.getContainer() - - if container == None: return - - if not 'cell' in container.getTemplate() and container.isFull(): - actor.sendSystemMessage('@container_error_message:container03', 0) - return - if container.getTemplate().startswith("object/tangible/inventory/shared_lightsaber_inventory") or target.getContainer().getTemplate().startswith("object/tangible/inventory/shared_lightsaber_inventory"): - core.equipmentService.calculateLightsaberAttributes(actor, target, container) - return; + parsedMsg = commandString.split(' ', 3) + objService = core.objectService + containerID = long(parsedMsg[1]) + container = objService.getObject(containerID) + actorContainer = actor.getContainer() + + if container == None: return + + if not 'cell' in container.getTemplate() and container.isFull(): + actor.sendSystemMessage('@container_error_message:container03', 0) + return - if target.getTemplate() == 'object/tangible/item/shared_loot_cash.iff': - core.lootService.handleCreditPickUp(actor,target) - if target.getGrandparent().getInventoryItemCount()==1: - core.lootService.setLooted(actor,target.getGrandparent()) - core.objectService.destroyObject(target) - return + if container.getTemplate().startswith("object/tangible/inventory/shared_lightsaber_inventory") or target.getContainer().getTemplate().startswith("object/tangible/inventory/shared_lightsaber_inventory"): + core.equipmentService.calculateLightsaberAttributes(actor, target, container) + return; + + if target.getTemplate() == 'object/tangible/item/shared_loot_cash.iff': + core.lootService.handleCreditPickUp(actor,target) + if target.getGrandparent().getInventoryItemCount()==1: + core.lootService.setLooted(actor,target.getGrandparent()) + core.objectService.destroyObject(target) + return - if target.isLootItem(): - target.setLootItem(0) - actor.sendSystemMessage('You looted ' + target.getObjectName().getStfValue() + ' from corpse.', 0) - #actor.sendSystemMessage('container.getInventoryItemCount() %s' % target.getGrandparent().getInventoryItemCount(), 0) - if target.getGrandparent().getInventoryItemCount()==1: - core.lootService.setLooted(actor,target.getGrandparent()) - - if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): + if target.isLootItem(): + target.setLootItem(0) + actor.sendSystemMessage('You looted ' + target.getObjectName().getStfValue() + ' from corpse.', 0) + #actor.sendSystemMessage('container.getInventoryItemCount() %s' % target.getGrandparent().getInventoryItemCount(), 0) + if target.getGrandparent().getInventoryItemCount()==1: + core.lootService.setLooted(actor,target.getGrandparent()) + + if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): target.getContainer().transferTo(actor, container, target) core.simulationService.teleport(target, actor.getPosition(), Quaternion(1,0,0,0), containerID) return - elif target.getContainer().getTemplate() == "object/cell/shared_cell.iff" and core.housingService.getPermissions(actor, target.getContainer()): + elif target.getContainer().getTemplate() == "object/cell/shared_cell.iff" and core.housingService.getPermissions(actor, target.getContainer()): target.getContainer().transferTo(actor, container, target) return - elif actorContainer != None and container.getTemplate() == "object/cell/shared_cell.iff": - actor.sendSystemMessage("You do not have permission to access that container!", 0) - return + elif actorContainer != None and container.getTemplate() == "object/cell/shared_cell.iff": + actor.sendSystemMessage("You do not have permission to access that container!", 0) + return - canEquip = core.equipmentService.canEquip(actor, target) + canEquip = core.equipmentService.canEquip(actor, target) - if canEquip[0] is False and container == actor: - actor.sendSystemMessage(canEquip[1], 0) - return + if canEquip[0] is False and container == actor: + actor.sendSystemMessage(canEquip[1], 0) + return - if target and container and target.getContainer(): - oldContainer = target.getContainer() - - if container == oldContainer: - print 'Error: New container is same as old container.' - return; - + if target and container and target.getContainer(): + oldContainer = target.getContainer() + + if container == oldContainer: + print 'Error: New container is same as old container.' + return; + replacedObject = None slotName = None - replacedObjects = [] + replacedObjects = [] slotNames = None - if actor == container: + + if actor == container: slotNames = container.getSlotNamesForObject(target) + for slotName in slotNames: object = container.getSlottedObject(slotName) + if not object in replacedObjects and not object == None: replacedObjects.append(object) - - oldContainer.transferTo(actor, container, target) - - for object in replacedObjects: - core.equipmentService.unequip(actor, object) - - if actor == container: - if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): - core.equipmentService.equip(actor, target) - #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' - #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') - #core.scriptService.callScript(path, 'equip', module, core, actor, target) - if container == actor.getSlottedObject('appearance_inventory'): - actor.addObjectToAppearanceEquipList(target) - for object in replacedObjects: - actor.removeObjectFromAppearanceEquipList(object) + if object != None: + container.transferTo(actor, container, object) + + oldContainer.transferTo(actor, container, target) if oldContainer == actor.getSlottedObject('appearance_inventory'): actor.removeObjectFromAppearanceEquipList(target) + + if container == actor.getSlottedObject('appearance_inventory'): + actor.addObjectToAppearanceEquipList(target) - if actor == oldContainer: - if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): - #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' - #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') - #core.scriptService.callScript(path, 'unequip', module, core, actor, target) - core.equipmentService.unequip(actor, target) - - return + return diff --git a/scripts/commands/transferitemweapon.py b/scripts/commands/transferitemweapon.py index b07c4e03..500ee505 100644 --- a/scripts/commands/transferitemweapon.py +++ b/scripts/commands/transferitemweapon.py @@ -14,8 +14,8 @@ def run(core, actor, target, commandString): if target and container and target.getContainer(): oldContainer = target.getContainer() if container == oldContainer: - print 'Error: New container is same as old container.' - return; + print 'Error: New container is same as old container.' + return; canEquip = core.equipmentService.canEquip(actor, target) @@ -25,32 +25,22 @@ def run(core, actor, target, commandString): replacedObject = None slotName = None - replacedObjects = [] + replacedObjects = [] slotNames = None - if actor == container: + + if actor == container: slotNames = container.getSlotNamesForObject(target) + for slotName in slotNames: object = container.getSlottedObject(slotName) + if not object in replacedObjects and not object == None: replacedObjects.append(object) + + if object != None: + container.transferTo(actor, container, object) + + oldContainer.transferTo(actor, container, target) - oldContainer.transferTo(actor, container, target) - - if actor == container: - if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): - core.equipmentService.equip(actor, target) - for object in replacedObjects: - core.equipmentService.unequip(actor, object) - #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' - #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') - #core.scriptService.callScript(path, 'equip', module, core, actor, target) - - if actor == oldContainer: - if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): - #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' - #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') - #core.scriptService.callScript(path, 'unequip', module, core, actor, target) - core.equipmentService.unequip(actor, target, replacedObject) - actor.setWeaponId(target.getObjectID()) return \ No newline at end of file diff --git a/src/services/equipment/EquipmentService.java b/src/services/equipment/EquipmentService.java index 5da16f29..9a989109 100644 --- a/src/services/equipment/EquipmentService.java +++ b/src/services/equipment/EquipmentService.java @@ -166,6 +166,8 @@ public class EquipmentService implements INetworkDispatch { if(!actor.getEquipmentList().contains(item.getObjectID())) { + if(item instanceof WeaponObject) actor.setWeaponId(item.getObjectID()); + actor.addObjectToEquipList(item); processItemAtrributes(actor, item, true); } @@ -182,6 +184,8 @@ public class EquipmentService implements INetworkDispatch { if(actor.getEquipmentList().contains(item.getObjectID())) { + if(item instanceof WeaponObject) actor.setWeaponId(actor.getSlottedObject("default_weapon").getObjectID()); + actor.removeObjectFromEquipList(item); processItemAtrributes(actor, item, false); }