mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-21 06:13:13 -04:00
Added preliminary terrain collision detection, added some combat functions, changed CreatureObjects superclass to Tangible Object
Updated engine Delete all files in odb/creature (creature superclass was changed so db wipe is needed)
This commit is contained in:
@@ -94,7 +94,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
buffer.putInt(creature.getFactionStatus());
|
||||
|
||||
byte[] customizationData = creature.getCustomizationData();
|
||||
byte[] customizationData = creature.getCustomization();
|
||||
|
||||
if(customizationData.length <= 0)
|
||||
buffer.putShort((short) 0);
|
||||
@@ -265,6 +265,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0x2C01);
|
||||
buffer.putInt(0);
|
||||
|
||||
|
||||
if(creature.getEquipmentList().isEmpty()) {
|
||||
buffer.putInt(0);
|
||||
@@ -594,6 +595,79 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildHealthDelta(int health) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 0);
|
||||
buffer.putInt(health);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x15, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildActionDelta(int action) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 2);
|
||||
buffer.putInt(action);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x15, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildMaxHealthDelta(int health) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 0);
|
||||
buffer.putInt(health);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x16, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildMaxActionDelta(int action) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
buffer.put((byte) 2);
|
||||
buffer.putShort((short) 2);
|
||||
buffer.putInt(action);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x16, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -54,7 +54,7 @@ import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
@Entity
|
||||
public class CreatureObject extends SWGObject implements IPersistent {
|
||||
public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
@@ -67,11 +67,7 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
private int skillsUpdateCounter = 0;
|
||||
|
||||
// CREO 3
|
||||
private byte[] customizationData;
|
||||
private int optionBitmask = 0;
|
||||
private int incapTimer = 10;
|
||||
private byte posture = 0;
|
||||
private String faction;
|
||||
private int factionStatus = 0;
|
||||
private float height;
|
||||
private int battleFatigue = 0;
|
||||
@@ -102,8 +98,6 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
|
||||
|
||||
// CREO6
|
||||
@NotPersistent
|
||||
private List<Long> defendersList = new ArrayList<Long>(); // unused in packets but useful for the server
|
||||
private byte combatFlag = 0;
|
||||
private short level = 0;
|
||||
private String currentAnimation;
|
||||
@@ -118,6 +112,15 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
private byte moodId = 0;
|
||||
private int performanceCounter = 0;
|
||||
private int performanceId = 0;
|
||||
private int health;
|
||||
private int action;
|
||||
@NotPersistent
|
||||
private int HAMListCounter = 0;
|
||||
private int maxHealth;
|
||||
private int maxAction;
|
||||
@NotPersistent
|
||||
private int maxHAMListCounter = 0;
|
||||
|
||||
private List<SWGObject> equipmentList = new ArrayList<SWGObject>();
|
||||
@NotPersistent
|
||||
private int equipmentListUpdateCounter = 0;
|
||||
@@ -136,7 +139,7 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
|
||||
|
||||
public CreatureObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
|
||||
super(objectID, planet, position, orientation, Template);
|
||||
super(objectID, planet, Template, position, orientation);
|
||||
messageBuilder = new CreatureMessageBuilder(this);
|
||||
}
|
||||
|
||||
@@ -195,27 +198,10 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getCustomizationData() {
|
||||
@Override
|
||||
public void setOptionsBitmask(int optionBitmask) {
|
||||
synchronized(objectMutex) {
|
||||
return customizationData;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomizationData(byte[] customizationData) {
|
||||
synchronized(objectMutex) {
|
||||
this.customizationData = customizationData;
|
||||
}
|
||||
}
|
||||
|
||||
public int getOptionBitmask() {
|
||||
synchronized(objectMutex) {
|
||||
return optionBitmask;
|
||||
}
|
||||
}
|
||||
|
||||
public void setOptionBitmask(int optionBitmask) {
|
||||
synchronized(objectMutex) {
|
||||
this.optionBitmask = optionBitmask;
|
||||
this.optionsBitmask = optionBitmask;
|
||||
}
|
||||
|
||||
IoBuffer optionDelta = messageBuilder.buildOptionMaskDelta(optionBitmask);
|
||||
@@ -224,18 +210,6 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
|
||||
}
|
||||
|
||||
public int getIncapTimer() {
|
||||
synchronized(objectMutex) {
|
||||
return incapTimer;
|
||||
}
|
||||
}
|
||||
|
||||
public void setIncapTimer(int incapTimer) {
|
||||
synchronized(objectMutex) {
|
||||
this.incapTimer = incapTimer;
|
||||
}
|
||||
}
|
||||
|
||||
public byte getPosture() {
|
||||
synchronized(objectMutex) {
|
||||
return posture;
|
||||
@@ -254,12 +228,7 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
notifyObservers(objController, true);
|
||||
}
|
||||
|
||||
public String getFaction() {
|
||||
synchronized(objectMutex) {
|
||||
return faction;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFaction(String faction) {
|
||||
synchronized(objectMutex) {
|
||||
this.faction = faction;
|
||||
@@ -523,10 +492,6 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
return missionCriticalObjects;
|
||||
}
|
||||
|
||||
public List<Long> getDefendersList() {
|
||||
return defendersList;
|
||||
}
|
||||
|
||||
public byte getCombatFlag() {
|
||||
synchronized(objectMutex) {
|
||||
return combatFlag;
|
||||
@@ -789,4 +754,84 @@ public class CreatureObject extends SWGObject implements IPersistent {
|
||||
|
||||
}
|
||||
|
||||
public int getHealth() {
|
||||
synchronized(objectMutex) {
|
||||
return health;
|
||||
}
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
synchronized(objectMutex) {
|
||||
this.health = health;
|
||||
setMaxHAMListCounter(getHamListCounter() + 1);
|
||||
}
|
||||
notifyObservers(messageBuilder.buildHealthDelta(health), true);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
synchronized(objectMutex) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
||||
public void setAction(int action) {
|
||||
synchronized(objectMutex) {
|
||||
this.action = action;
|
||||
setMaxHAMListCounter(getHamListCounter() + 1);
|
||||
}
|
||||
notifyObservers(messageBuilder.buildActionDelta(action), true);
|
||||
}
|
||||
|
||||
public int getHamListCounter() {
|
||||
synchronized(objectMutex) {
|
||||
return HAMListCounter;
|
||||
}
|
||||
}
|
||||
|
||||
public void setHamListCounter(int hamListCounter) {
|
||||
synchronized(objectMutex) {
|
||||
this.HAMListCounter = hamListCounter;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxHealth() {
|
||||
synchronized(objectMutex) {
|
||||
return maxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxHealth(int maxHealth) {
|
||||
synchronized(objectMutex) {
|
||||
this.maxHealth = maxHealth;
|
||||
setMaxHAMListCounter(getMaxHAMListCounter() + 1);
|
||||
}
|
||||
notifyObservers(messageBuilder.buildMaxHealthDelta(maxHealth), true);
|
||||
}
|
||||
|
||||
public int getMaxAction() {
|
||||
synchronized(objectMutex) {
|
||||
return maxAction;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxAction(int maxAction) {
|
||||
synchronized(objectMutex) {
|
||||
this.maxAction = maxAction;
|
||||
setMaxHAMListCounter(getMaxHAMListCounter() + 1);
|
||||
}
|
||||
notifyObservers(messageBuilder.buildMaxActionDelta(maxAction), true);
|
||||
}
|
||||
|
||||
public int getMaxHAMListCounter() {
|
||||
synchronized(objectMutex) {
|
||||
return maxHAMListCounter;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxHAMListCounter(int maxHAMListCounter) {
|
||||
synchronized(objectMutex) {
|
||||
this.maxHAMListCounter = maxHAMListCounter;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ package resources.objects.tangible;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
@@ -41,14 +46,17 @@ public class TangibleObject extends SWGObject {
|
||||
|
||||
// TODO: Thread safety
|
||||
|
||||
private int incapTimer = 10;
|
||||
protected int incapTimer = 10;
|
||||
private int conditionDamage = 0;
|
||||
|
||||
private byte[] customization;
|
||||
protected int pvpBitmask = 0;
|
||||
protected byte[] customization;
|
||||
private List<Integer> componentCustomizations = new ArrayList<Integer>();
|
||||
private int optionsBitmask = 0;
|
||||
protected int optionsBitmask = 0;
|
||||
private int maxDamage = 0;
|
||||
private boolean staticObject = false;
|
||||
protected String faction;
|
||||
@NotPersistent
|
||||
private Vector<TangibleObject> defendersList = new Vector<TangibleObject>(); // unused in packets but useful for the server
|
||||
@NotPersistent
|
||||
private TangibleMessageBuilder messageBuilder;
|
||||
|
||||
@@ -122,6 +130,100 @@ public class TangibleObject extends SWGObject {
|
||||
public void setStaticObject(boolean staticObject) {
|
||||
this.staticObject = staticObject;
|
||||
}
|
||||
|
||||
public int getPvPBitmask() {
|
||||
synchronized(objectMutex) {
|
||||
return optionsBitmask;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPvPBitmask(int pvpBitmask) {
|
||||
synchronized(objectMutex) {
|
||||
this.pvpBitmask = pvpBitmask;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFaction() {
|
||||
synchronized(objectMutex) {
|
||||
return faction;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFaction(String faction) {
|
||||
synchronized(objectMutex) {
|
||||
this.faction = faction;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<TangibleObject> getDefendersList() {
|
||||
return defendersList;
|
||||
}
|
||||
|
||||
public void addDefender(TangibleObject defender) {
|
||||
|
||||
defendersList.add(defender);
|
||||
|
||||
if(this instanceof CreatureObject) {
|
||||
CreatureObject creature = (CreatureObject) this;
|
||||
|
||||
if(creature.getCombatFlag() == 0)
|
||||
creature.setCombatFlag((byte) 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeDefender(TangibleObject defender) {
|
||||
|
||||
defendersList.remove(defender);
|
||||
|
||||
if(this instanceof CreatureObject) {
|
||||
CreatureObject creature = (CreatureObject) this;
|
||||
|
||||
if(creature.getCombatFlag() == 1 && defendersList.isEmpty())
|
||||
creature.setCombatFlag((byte) 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isAttackableBy(CreatureObject attacker) {
|
||||
|
||||
CreatureObject creature;
|
||||
|
||||
if(this instanceof CreatureObject) {
|
||||
creature = (CreatureObject) this;
|
||||
if(creature.getDuelList().contains(attacker) && attacker.getDuelList().contains(this))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(faction.equals("rebel") && attacker.getFaction().equals("rebel"))
|
||||
return false;
|
||||
else if(faction.equals("imperial") && attacker.getFaction().equals("imperial"))
|
||||
return false;
|
||||
else if(attacker.getSlottedObject("ghost") != null) {
|
||||
|
||||
if(this instanceof CreatureObject && getSlottedObject("ghost") != null) {
|
||||
|
||||
creature = (CreatureObject) this;
|
||||
|
||||
if(creature.getFactionStatus() == 2 && attacker.getFactionStatus() == 2)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if((faction.equals("rebel") || faction.equals("imperial")) && attacker.getFactionStatus() >= 1)
|
||||
return true;
|
||||
else if((faction.equals("rebel") || faction.equals("imperial")) && attacker.getFactionStatus() == 0)
|
||||
return false;
|
||||
|
||||
return getPvPBitmask() == 1 || getPvPBitmask() == 2;
|
||||
|
||||
}
|
||||
|
||||
return getPvPBitmask() == 1 || getPvPBitmask() == 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
@@ -50,23 +50,50 @@ public class WeaponObject extends SWGObject {
|
||||
private WeaponMessageBuilder messageBuilder;
|
||||
|
||||
private float attackSpeed = 1;
|
||||
private float maxRange;
|
||||
|
||||
public WeaponObject(long objectID, Planet planet, String template) {
|
||||
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0), template);
|
||||
messageBuilder = new WeaponMessageBuilder(this);
|
||||
calculateRange();
|
||||
}
|
||||
|
||||
|
||||
public WeaponObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) {
|
||||
super(objectID, planet, position, orientation, template);
|
||||
messageBuilder = new WeaponMessageBuilder(this);
|
||||
calculateRange();
|
||||
}
|
||||
|
||||
|
||||
public WeaponObject() {
|
||||
super();
|
||||
messageBuilder = new WeaponMessageBuilder(this);
|
||||
//calculateRange();
|
||||
}
|
||||
|
||||
private void calculateRange() {
|
||||
|
||||
int weaponType = getWeaponType();
|
||||
|
||||
switch(weaponType) {
|
||||
|
||||
case 0: maxRange = 64; break;
|
||||
case 1: maxRange = 50; break;
|
||||
case 2: maxRange = 35; break;
|
||||
case 3: maxRange = 64; break;
|
||||
case 4: maxRange = 5; break;
|
||||
case 5: maxRange = 5; break;
|
||||
case 6: maxRange = 5; break;
|
||||
case 7: maxRange = 5; break;
|
||||
case 8: maxRange = 64; break;
|
||||
case 9: maxRange = 5; break;
|
||||
case 10: maxRange = 5; break;
|
||||
case 11: maxRange = 5; break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getIncapTimer() {
|
||||
return incapTimer;
|
||||
}
|
||||
@@ -129,6 +156,9 @@ public class WeaponObject extends SWGObject {
|
||||
|
||||
String template = getTemplate();
|
||||
|
||||
if(template == null)
|
||||
return weaponType;
|
||||
|
||||
if(template.contains("rifle")) weaponType = 0;
|
||||
if(template.contains("carbine")) weaponType = 1;
|
||||
if(template.contains("pistol")) weaponType = 2;
|
||||
@@ -174,4 +204,12 @@ public class WeaponObject extends SWGObject {
|
||||
return messageBuilder;
|
||||
}
|
||||
|
||||
public float getMaxRange() {
|
||||
return maxRange;
|
||||
}
|
||||
|
||||
public void setMaxRange(float maxRange) {
|
||||
this.maxRange = maxRange;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user