Equipment changes, see extended

Fixed an issue where attributes weren't being removed when unequipping
items.

EquipmentList and ApperaranceList are currently broken and will cause
crashes when modified, thus when equipping an item in any way will cause
a crash.  Expect a fix for that from Treeku shortly.
This commit is contained in:
R. Uvanni
2014-08-24 22:57:13 -04:00
parent a2f1eabcbf
commit 538bb789d2
5 changed files with 19 additions and 31 deletions
-6
View File
@@ -39,12 +39,6 @@ def run(core, actor, target, commandString):
if object != None:
actor.transferTo(actor, oldContainer, object)
if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'):
core.equipmentService.equip(actor, target)
for object in replacedObjects:
core.equipmentService.unequip(actor, object)
oldContainer.transferTo(actor, container, target)
+1 -7
View File
@@ -78,13 +78,7 @@ def run(core, actor, target, commandString):
if object != None:
container.transferTo(actor, container, object)
if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'):
core.equipmentService.equip(actor, target)
for object in replacedObjects:
core.equipmentService.unequip(actor, object) # Needs to be verified due to the new structure of the script
oldContainer.transferTo(actor, container, target)
if oldContainer == actor.getSlottedObject('appearance_inventory'):
+1 -9
View File
@@ -5,8 +5,6 @@ def setup():
def run(core, actor, target, commandString):
parsedMsg = commandString.split(' ', 3)
objService = core.objectService
containerID = long(parsedMsg[1])
@@ -39,13 +37,7 @@ def run(core, actor, target, commandString):
if object != None:
container.transferTo(actor, container, object)
if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'):
core.equipmentService.equip(actor, target)
for object in replacedObjects:
core.equipmentService.unequip(actor, object)
oldContainer.transferTo(actor, container, target)
return
@@ -931,6 +931,15 @@ public class CreatureObject extends TangibleObject implements IPersistent {
}
}
public boolean isWearing(SWGObject object)
{
for (Equipment equipment : getEquipmentList())
{
if (equipment.getObjectId() == object.getObjectId()) return true;
}
return false;
}
public void removeObjectFromEquipList(SWGObject object) {
if (object instanceof TangibleObject) {
for (Equipment equipment : getEquipmentList()) {
+8 -9
View File
@@ -163,15 +163,14 @@ public class EquipmentService implements INetworkDispatch {
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(!actor.getEquipmentList().contains(item.getObjectID()))
if(func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item));
if(!actor.isWearing(item))
{
//if(item instanceof WeaponObject){
//A rifle is not identified as a true WeaponObject ?!?!?!?!
if (item.getTemplate().contains("object/weapon/")){
actor.setWeaponId(item.getObjectID()); // This line causes the rifle lockup
//System.out.println("WEAPON IDENTIFIED!");
}
if (item.getTemplate().startsWith("object/weapon/")) actor.setWeaponId(item.getObjectID());
actor.addObjectToEquipList(item);
processItemAtrributes(actor, item, true);
}
@@ -185,10 +184,10 @@ public class EquipmentService implements INetworkDispatch {
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(actor.getEquipmentList().contains(item.getObjectID()))
if(actor.isWearing(item))
{
if(item instanceof WeaponObject) actor.setWeaponId(actor.getSlottedObject("default_weapon").getObjectID());
// This should be changed to instanceof WeaponObject eventually... see comment in equip()
if (item.getTemplate().startsWith("object/weapon/")) actor.setWeaponId(actor.getSlottedObject("default_weapon").getObjectID());
actor.removeObjectFromEquipList(item);
processItemAtrributes(actor, item, false);