From 4abab8f004374b0e2b34b6f0bf2cb5c2d06f7f90 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Mon, 15 Dec 2014 10:46:59 -0500 Subject: [PATCH] Changed CreatureObject to use attribute lists in the baseline --- .../objects/creature/CreatureObject.java | 128 +++++++++++------- 1 file changed, 77 insertions(+), 51 deletions(-) diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index d7431544d..acc11d4e6 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -21,8 +21,6 @@ public class CreatureObject extends TangibleObject { private Posture posture = Posture.STANDING; private Race race = Race.HUMAN; - private int attributes = 0; - private int maxAttributes = 0; private int unmodifiedMaxAtributes = 0; private int attributeBonus = 0; private int shockWounds = 0; @@ -50,24 +48,41 @@ public class CreatureObject extends TangibleObject { private int cashBalance = 0; private int bankBalance = 0; - private SWGList skills = new SWGList(BaselineType.CREO, 1, 4, false, StringType.ASCII); - private SWGList hamEncumbList = new SWGList(BaselineType.CREO, 4, 2); - private SWGList equipmentList = new SWGList(BaselineType.CREO, 6, 15); - private SWGList appearanceList = new SWGList(BaselineType.CREO, 6, 26); + private SWGList baseAttributes = new SWGList(BaselineType.CREO, 1, 3); + private SWGList skills = new SWGList(BaselineType.CREO, 1, 4, false, StringType.ASCII); + private SWGList hamEncumbList = new SWGList(BaselineType.CREO, 4, 0); // TODO: UpdateType + private SWGList attributes = new SWGList(BaselineType.CREO, 6, 0); // TODO: UpdateType + private SWGList maxAttributes = new SWGList(BaselineType.CREO, 6, 0); // TODO: UpdateType + private SWGList equipmentList = new SWGList(BaselineType.CREO, 6, 0); // TODO: UpdateType + private SWGList appearanceList = new SWGList(BaselineType.CREO, 6, 0); // TODO: UpdateType public CreatureObject(long objectId) { super(objectId); + + attributes.add(1000); // Health + attributes.add(0); + attributes.add(300); // Action + attributes.add(0); + attributes.add(300); // ?? + attributes.add(0); + + maxAttributes.addAll(attributes); + baseAttributes.addAll(attributes); } public void addEquipment(SWGObject obj) { - if (obj instanceof WeaponObject) - equipmentList.add(new Equipment((WeaponObject) obj)); - else - equipmentList.add(new Equipment(obj.getObjectId(), obj.getTemplate())); + synchronized(equipmentList) { + if (obj instanceof WeaponObject) + equipmentList.add(new Equipment((WeaponObject) obj)); + else + equipmentList.add(new Equipment(obj.getObjectId(), obj.getTemplate())); + } } public void addAppearanceItem(SWGObject obj) { - appearanceList.add(new Equipment(obj.getObjectId(), obj.getTemplate())); + synchronized(appearanceList) { + appearanceList.add(new Equipment(obj.getObjectId(), obj.getTemplate())); + } } public SWGList getEquipmentList() { @@ -98,14 +113,6 @@ public class CreatureObject extends TangibleObject { return race; } - public int getAttributes() { - return attributes; - } - - public int getMaxAttributes() { - return maxAttributes; - } - public int getUnmodifiedMaxAtributes() { return unmodifiedMaxAtributes; } @@ -222,14 +229,6 @@ public class CreatureObject extends TangibleObject { this.bankBalance = bankBalance; } - public void setAttributes(int attributes) { - this.attributes = attributes; - } - - public void setMaxAttributes(int maxAttributes) { - this.maxAttributes = maxAttributes; - } - public void setUnmodifiedMaxAtributes(int unmodifiedMaxAtributes) { this.unmodifiedMaxAtributes = unmodifiedMaxAtributes; } @@ -326,6 +325,54 @@ public class CreatureObject extends TangibleObject { this.beast = beast; } + public int getHealth() { + return attributes.get(0); + } + + public int getMaxHealth() { + return maxAttributes.get(0); + } + + public int getBaseHealth() { + return baseAttributes.get(0); + } + + public int getAction() { + return attributes.get(2); + } + + public int getMaxAction() { + return attributes.get(2); + } + + public int getBaseAction() { + return attributes.get(2); + } + + public void setHealth(int health) { + synchronized(attributes) { + attributes.set(0, health); + } + } + + public void setMaxHealth(int maxHealth) { + synchronized(maxAttributes) { + maxAttributes.set(0, maxHealth); + } + } + + public void setAction(int action) { + synchronized(attributes) { + attributes.set(2, action); + } + } + + public void setMaxAction(int maxAction) { + synchronized(maxAttributes) { + maxAttributes.set(2, maxAction); + } + } + public void createObject(Player target) { sendSceneCreateObject(target); @@ -369,14 +416,7 @@ public class CreatureObject extends TangibleObject { super.createBaseline1(target, bb); bb.addInt(cashBalance); bb.addInt(bankBalance); - bb.addInt(6); // Base HAM Mod List Size (List, Integer) - bb.addInt(0); // update counter - bb.addInt(1000); // Max Health - bb.addInt(0); // ?? - bb.addInt(300); // Max Action - bb.addInt(0); // ?? - bb.addInt(300); // Max Mind - bb.addInt(0); // ?? + bb.addObject(baseAttributes); // Attributes player has without any gear on bb.addObject(skills); bb.incremeantOperandCount(4); @@ -437,22 +477,8 @@ public class CreatureObject extends TangibleObject { bb.addByte(0); // Mood ID bb.addInt(0); // Performance Counter bb.addInt(0); // Performance ID - bb.addInt(6); // Attributes List Size (List, Integer) - bb.addInt(5); - bb.addInt(2363); // Health - bb.addInt(0); - bb.addInt(3050); // Action - bb.addInt(0); - bb.addInt(1000); // ?? it's 300 on new characters - bb.addInt(0); - bb.addInt(6); // Max Attributes List Size (List, Integer) - bb.addInt(5); - bb.addInt(2363); // Health - bb.addInt(0); - bb.addInt(3050); // Action - bb.addInt(0); - bb.addInt(1000); // ?? it's 300 on new characters - bb.addInt(0); + bb.addObject(attributes); + bb.addObject(maxAttributes); bb.addObject(equipmentList); bb.addAscii(""); // Appearance (costume) bb.addBoolean(true); // Visible