mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-21 06:13:13 -04:00
Merge remote-tracking branch 'origin/master' into Wave_Missions
Conflicts: src/main/NGECore.java src/protocol/swg/chat/ChatFriendsListUpdate.java src/services/MissionService.java
This commit is contained in:
@@ -36,16 +36,14 @@ import resources.objects.creature.CreatureObject;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.resources.common.CRC;
|
||||
|
||||
@Persistent(version=8)
|
||||
@Persistent(version=10)
|
||||
public class Buff implements IDelta {
|
||||
|
||||
@NotPersistent
|
||||
private SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
private String group1;
|
||||
private String group1, group2;
|
||||
private int priority;
|
||||
private float duration;
|
||||
private String buffName;
|
||||
@@ -69,12 +67,43 @@ public class Buff implements IDelta {
|
||||
private ScheduledFuture<?> removalTask;
|
||||
private int stacks = 1;
|
||||
private long groupBufferId;
|
||||
private int buffCRC;
|
||||
|
||||
public Buff(String buffName, long ownerId) {
|
||||
public Buff(Buff baseBuff, long ownerId) {
|
||||
this.buffName = baseBuff.getBuffName();
|
||||
this.buffCRC = baseBuff.getBuffCRC();
|
||||
this.group1 = baseBuff.getGroup1();
|
||||
this.group2 = baseBuff.getGroup2();
|
||||
this.priority = baseBuff.getPriority();
|
||||
this.duration = baseBuff.getDuration();
|
||||
this.effect1Name = baseBuff.getEffect1Name();
|
||||
this.effect1Value = baseBuff.getEffect1Value();
|
||||
this.effect2Name = baseBuff.getEffect2Name();
|
||||
this.effect2Value = baseBuff.getEffect2Value();
|
||||
this.effect3Name = baseBuff.getEffect3Name();
|
||||
this.effect3Value = baseBuff.getEffect3Value();
|
||||
this.effect4Name = baseBuff.getEffect4Name();
|
||||
this.effect4Value = baseBuff.getEffect4Value();
|
||||
this.effect5Name = baseBuff.getEffect5Name();
|
||||
this.effect5Value = baseBuff.getEffect5Value();
|
||||
this.callback = baseBuff.getCallback();
|
||||
this.particleEffect = baseBuff.getParticleEffect();
|
||||
this.isDebuff = baseBuff.isDebuff();
|
||||
this.removeOnDeath = baseBuff.isRemoveOnDeath();
|
||||
this.isRemovableByPlayer = baseBuff.isRemovableByPlayer();
|
||||
this.maxStacks = baseBuff.getMaxStacks();
|
||||
this.isPersistent = baseBuff.isPersistent();
|
||||
this.removeOnRespec = baseBuff.isRemoveOnRespec();
|
||||
this.aiRemoveOnEndCombat = baseBuff.isAiRemoveOnEndCombat();
|
||||
this.decayOnPvPDeath = baseBuff.isDecayOnPvPDeath();
|
||||
}
|
||||
|
||||
/*public Buff(String buffName, long ownerId) {
|
||||
|
||||
this.buffName = buffName;
|
||||
this.ownerId = ownerId;
|
||||
|
||||
this.buffCRC = CRC.StringtoCRC(buffName);
|
||||
|
||||
DatatableVisitor visitor;
|
||||
|
||||
try {
|
||||
@@ -86,6 +115,7 @@ public class Buff implements IDelta {
|
||||
if(((String) visitor.getObject(i, 0)).equalsIgnoreCase(buffName)) {
|
||||
|
||||
group1 = (String) visitor.getObject(i, 1);
|
||||
group2 = (String) visitor.getObject(i, 2);
|
||||
priority = (int) visitor.getObject(i, 4);
|
||||
duration = (Float) visitor.getObject(i, 6);
|
||||
effect1Name = (String) visitor.getObject(i, 7);
|
||||
@@ -116,12 +146,8 @@ public class Buff implements IDelta {
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Buff() { }
|
||||
|
||||
@Override
|
||||
@@ -156,7 +182,7 @@ public class Buff implements IDelta {
|
||||
this.group1 = group1;
|
||||
}
|
||||
|
||||
public float getPriority() {
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
@@ -429,7 +455,7 @@ public class Buff implements IDelta {
|
||||
}
|
||||
|
||||
public boolean isGroupBuff() {
|
||||
return effect1Name.equals("group");
|
||||
return effect1Name == null ? false : effect1Name.equals("group");
|
||||
}
|
||||
|
||||
public long getGroupBufferId() {
|
||||
@@ -440,4 +466,20 @@ public class Buff implements IDelta {
|
||||
this.groupBufferId = groupBufferId;
|
||||
}
|
||||
|
||||
public String getGroup2() {
|
||||
return group2;
|
||||
}
|
||||
|
||||
public void setGroup2(String group2) {
|
||||
this.group2 = group2;
|
||||
}
|
||||
|
||||
public int getBuffCRC() {
|
||||
return buffCRC;
|
||||
}
|
||||
|
||||
public void setBuffCRC(int buffCRC) {
|
||||
this.buffCRC = buffCRC;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,47 +16,59 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent
|
||||
public class BuffItem {
|
||||
private String skillName;
|
||||
private int affectAmount;
|
||||
private int entertainerBonus;
|
||||
private int invested;
|
||||
private int bonusAmount; // expertise bonus (50%*4 = 200) which would then result in bonusAmount + (maxTimesApplied * affectAmount) = result
|
||||
|
||||
private String skillName;
|
||||
|
||||
public BuffItem() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BuffItem(String skillName, int invested, int amount) {
|
||||
|
||||
public BuffItem(String skillName, int invested, int entBonus) {
|
||||
this.skillName = skillName;
|
||||
this.invested = invested;
|
||||
this.bonusAmount = amount;
|
||||
this.entertainerBonus = entBonus;
|
||||
}
|
||||
|
||||
public String getSkillName() {
|
||||
return skillName;
|
||||
public int getAffectAmount() {
|
||||
return affectAmount;
|
||||
}
|
||||
|
||||
public void setSkillName(String skillName) {
|
||||
this.skillName = skillName;
|
||||
public int getEntertainerBonus() {
|
||||
return entertainerBonus;
|
||||
}
|
||||
|
||||
public int getInvested() {
|
||||
return invested;
|
||||
}
|
||||
|
||||
public String getSkillName() {
|
||||
return skillName;
|
||||
}
|
||||
|
||||
public void setAffectAmount(int amount) {
|
||||
this.affectAmount = amount;
|
||||
}
|
||||
|
||||
public void setEntertainerBonus(int entertainerBonus) {
|
||||
this.entertainerBonus = entertainerBonus;
|
||||
}
|
||||
|
||||
public void setInvested(int invested) {
|
||||
this.invested = invested;
|
||||
}
|
||||
|
||||
public int getBonusAmount() {
|
||||
return bonusAmount;
|
||||
}
|
||||
|
||||
public void setBonusAmount(int amount) {
|
||||
this.bonusAmount = amount;
|
||||
public void setSkillName(String skillName) {
|
||||
this.skillName = skillName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,19 +22,27 @@
|
||||
package resources.objects;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.buffer.SimpleBufferAllocator;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.common.StringUtilities;
|
||||
|
||||
|
||||
@Persistent
|
||||
public abstract class Delta implements IDelta {
|
||||
|
||||
public Delta() { }
|
||||
|
||||
@NotPersistent
|
||||
protected final Object objectMutex = new Object();
|
||||
public SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
@NotPersistent
|
||||
private static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
|
||||
public Delta() {
|
||||
|
||||
}
|
||||
|
||||
protected String getAsciiString(ByteBuffer buffer) {
|
||||
return StringUtilities.getAsciiString(buffer);
|
||||
@@ -56,4 +64,13 @@ public abstract class Delta implements IDelta {
|
||||
return ((byte) ((variable) ? 1 : 0));
|
||||
}
|
||||
|
||||
public static IoBuffer createBuffer(int size) {
|
||||
return IoBuffer.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
public static IoBuffer resizeBuffer(IoBuffer buffer) {
|
||||
int size = buffer.position();
|
||||
return buffer == null ? createBuffer(0) : createBuffer(size).put(buffer.flip().array(), 0, size).flip();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,11 +24,18 @@ package resources.objects;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.python.google.common.collect.Lists;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -384,5 +391,51 @@ public class SWGList<E> implements List<E> {
|
||||
|
||||
messageBuilder.sendListDelta(viewType, updateType, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<E> reverseGet()
|
||||
{
|
||||
return Lists.reverse(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<E> stream() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<E> parallelStream() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super E> action) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceAll(UnaryOperator<E> operator) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sort(Comparator<? super E> c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<E> spliterator() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
@@ -116,7 +119,9 @@ public class SWGMap<K, V> implements Map<K, V> {
|
||||
if (map.containsKey(key)) {
|
||||
V oldValue = map.put(key, value);
|
||||
|
||||
queue(item(2, (String) key, ((IDelta) value).getBytes(), true, true));
|
||||
if (oldValue != null) {
|
||||
queue(item(2, (String) key, ((IDelta) value).getBytes(), true, true));
|
||||
}
|
||||
|
||||
return oldValue;
|
||||
} else {
|
||||
@@ -167,7 +172,9 @@ public class SWGMap<K, V> implements Map<K, V> {
|
||||
key instanceof Integer || key instanceof Float || key instanceof Long) {
|
||||
V value = map.remove(key);
|
||||
|
||||
queue(item(1, key, ((IDelta) map.get(key)).getBytes(), true, true));
|
||||
if (value != null) {
|
||||
queue(item(1, (String) key, ((IDelta) value).getBytes(), true, true));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -227,6 +234,7 @@ public class SWGMap<K, V> implements Map<K, V> {
|
||||
}
|
||||
}
|
||||
if (useData) buffer.put(data);
|
||||
buffer.flip();
|
||||
|
||||
updateCounter++;
|
||||
|
||||
@@ -238,6 +246,7 @@ public class SWGMap<K, V> implements Map<K, V> {
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(updateCounter);
|
||||
buffer.put(data);
|
||||
buffer.flip();
|
||||
messageBuilder.sendListDelta(viewType, updateType, buffer);
|
||||
}
|
||||
|
||||
@@ -252,8 +261,80 @@ public class SWGMap<K, V> implements Map<K, V> {
|
||||
buffer.putInt(data.size());
|
||||
buffer.putInt(updateCounter);
|
||||
for (byte[] queued : data) buffer.put(queued);
|
||||
buffer.flip();
|
||||
|
||||
messageBuilder.sendListDelta(viewType, updateType, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getOrDefault(Object key, V defaultValue) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(BiConsumer<? super K, ? super V> action) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceAll(
|
||||
BiFunction<? super K, ? super V, ? extends V> function) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public V putIfAbsent(K key, V value) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V replace(K key, V value) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V computeIfAbsent(K key,
|
||||
Function<? super K, ? extends V> mappingFunction) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V computeIfPresent(K key,
|
||||
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V compute(K key,
|
||||
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V merge(K key, V value,
|
||||
BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent(version=1)
|
||||
public class SkillMod extends Delta {
|
||||
|
||||
private int base;
|
||||
private float modifier;
|
||||
private String name;
|
||||
|
||||
public SkillMod() {
|
||||
}
|
||||
|
||||
public SkillMod(String name, int base, int modifier) {
|
||||
this.name = name;
|
||||
this.base = base;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public int getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public void setBase(int base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public float getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public void setModifier(float modifier) {
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() {
|
||||
IoBuffer buffer = createBuffer(8);
|
||||
buffer.putInt(base);
|
||||
buffer.putInt((int) modifier);
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,10 @@
|
||||
package resources.objects.building;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
|
||||
public class BuildingMessageBuilder extends ObjectMessageBuilder {
|
||||
@@ -107,7 +110,7 @@ public class BuildingMessageBuilder extends ObjectMessageBuilder {
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TANO", (byte) 8, buffer, size);
|
||||
buffer = createBaseline("BUIO", (byte) 8, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@@ -118,10 +121,30 @@ public class BuildingMessageBuilder extends ObjectMessageBuilder {
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TANO", (byte) 9, buffer, size);
|
||||
buffer = createBaseline("BUIO", (byte) 9, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildPermissionListCreate(Vector<String> permissionList, String listName) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
int listSize = permissionList.size();
|
||||
buffer.putShort((short)4);
|
||||
buffer.putInt(0x52F364B8);
|
||||
buffer.putInt(listSize);
|
||||
for (String name : permissionList){
|
||||
buffer.put(getUnicodeString(name));
|
||||
}
|
||||
//buffer.putInt(0x61);
|
||||
buffer.putInt(0);
|
||||
//buffer.putShort((short)0);
|
||||
buffer.put(getUnicodeString(listName));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,38 +21,57 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.building;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import main.NGECore;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Entity(version=0)
|
||||
@Entity(version=6)
|
||||
public class BuildingObject extends TangibleObject implements IPersistent {
|
||||
|
||||
@NotPersistent
|
||||
private BuildingMessageBuilder messageBuilder;
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
private float maintenanceAmount = 0;
|
||||
private int BMR = 0;
|
||||
private String deedTemplate="";
|
||||
private boolean residency=false;
|
||||
private byte privacy=(byte)0;
|
||||
public static byte PRIVATE = (byte)0;
|
||||
public static byte PUBLIC = (byte)1;
|
||||
private short maximumStorageCapacity=0;
|
||||
private Vector<Long> entryList = new Vector<Long>(); // Preferably the OIDs should be stored, because of name changes
|
||||
private Vector<Long> banList = new Vector<Long>();
|
||||
|
||||
public BuildingObject() {
|
||||
super();
|
||||
messageBuilder = new BuildingMessageBuilder(this);
|
||||
this.setConditionDamage(100);
|
||||
}
|
||||
|
||||
public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
|
||||
super(objectID, planet, Template, position, orientation);
|
||||
messageBuilder = new BuildingMessageBuilder(this);
|
||||
this.setConditionDamage(100);
|
||||
}
|
||||
|
||||
public CellObject getCellByCellNumber(final int cellNumber) {
|
||||
@@ -60,24 +79,143 @@ public class BuildingObject extends TangibleObject implements IPersistent {
|
||||
final AtomicReference<CellObject> ref = new AtomicReference<CellObject>();
|
||||
|
||||
synchronized(objectMutex) {
|
||||
|
||||
this.viewChildren(this, true, false, new Traverser() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject obj) {
|
||||
|
||||
if(obj instanceof CellObject && ((CellObject) obj).getCellNumber() == cellNumber)
|
||||
ref.set((CellObject) obj);
|
||||
|
||||
}
|
||||
|
||||
this.viewChildren(this, true, false, (obj) -> {
|
||||
if(obj instanceof CellObject && ((CellObject) obj).getCellNumber() == cellNumber)
|
||||
ref.set((CellObject) obj);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return ref.get();
|
||||
|
||||
}
|
||||
|
||||
public float getMaintenanceAmount() {
|
||||
return maintenanceAmount;
|
||||
}
|
||||
|
||||
public void setMaintenanceAmount(float maintenanceAmount) {
|
||||
this.maintenanceAmount = maintenanceAmount;
|
||||
}
|
||||
|
||||
public void setDeedTemplate(String deedTemplate){
|
||||
this.deedTemplate = deedTemplate;
|
||||
}
|
||||
|
||||
public String getDeedTemplate(){
|
||||
return this.deedTemplate;
|
||||
}
|
||||
|
||||
public String getBuildingName() {
|
||||
return this.getCustomName();
|
||||
}
|
||||
|
||||
public void setBuildingName(String buildingName, CreatureObject owner) {
|
||||
//owner.getClient().getSession().write(messageBuilder.buildCustomNameDelta(this,buildingName));
|
||||
this.setCustomName(buildingName);
|
||||
((CreatureObject)owner).sendSystemMessage("Structure renamed.", (byte) 0);
|
||||
}
|
||||
|
||||
public int getBMR() {
|
||||
return BMR;
|
||||
}
|
||||
|
||||
public void setBMR(int BMR) {
|
||||
this.BMR = BMR;
|
||||
}
|
||||
|
||||
public void setResidency(CreatureObject owner){
|
||||
owner.sendSystemMessage("@player_structure:declared_residency", (byte) 1);
|
||||
residency = true;
|
||||
}
|
||||
|
||||
public boolean getResidency(){
|
||||
return this.residency;
|
||||
}
|
||||
|
||||
public byte getPrivacy() {
|
||||
return privacy;
|
||||
}
|
||||
|
||||
public String getPrivacyString() {
|
||||
if (privacy==PRIVATE)
|
||||
return "private";
|
||||
if (privacy==PUBLIC)
|
||||
return "public";
|
||||
return "42";
|
||||
}
|
||||
|
||||
public void setPrivacy(byte privacy) {
|
||||
this.privacy = privacy;
|
||||
}
|
||||
|
||||
public Vector<TangibleObject> getItemsList() {
|
||||
Vector<TangibleObject> items = new Vector<TangibleObject>();
|
||||
getCells().forEach(c -> c.viewChildren(c, true, false, (item) -> {
|
||||
if(!(item instanceof CreatureObject) && item.getTemplate() != "object/tangible/terminal/shared_terminal_player_structure.iff")
|
||||
items.add((TangibleObject) item);
|
||||
}));
|
||||
return items;
|
||||
}
|
||||
|
||||
public short getMaximumStorageCapacity() {
|
||||
return maximumStorageCapacity;
|
||||
}
|
||||
|
||||
public void setMaximumStorageCapacity(short maximumStorageCapacity) {
|
||||
this.maximumStorageCapacity = maximumStorageCapacity;
|
||||
}
|
||||
|
||||
public void setPermissionEntry(String name,CreatureObject owner){
|
||||
Vector<String> entryListFirstNames = new Vector<String>();
|
||||
for (long oid : entryList){
|
||||
String firstName = NGECore.getInstance().characterService.getPlayerFirstName(oid);
|
||||
entryListFirstNames.add(firstName);
|
||||
}
|
||||
entryListFirstNames.add("Peter");
|
||||
entryListFirstNames.add("Jackson");
|
||||
owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(entryListFirstNames, name));
|
||||
}
|
||||
|
||||
public void setPermissionBan(String name,CreatureObject owner){
|
||||
Vector<String> banListFirstNames = new Vector<String>();
|
||||
for (long oid : banList){
|
||||
String firstName = NGECore.getInstance().characterService.getPlayerFirstName(oid);
|
||||
banListFirstNames.add(firstName);
|
||||
}
|
||||
banListFirstNames.add("Peter");
|
||||
banListFirstNames.add("Smith");
|
||||
owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(banListFirstNames, name));
|
||||
}
|
||||
|
||||
public void addPlayerToEntryList(CreatureObject owner,long oid, String firstName){
|
||||
if (!entryList.contains(oid)){
|
||||
this.entryList.add(oid);
|
||||
owner.sendSystemMessage(firstName+ " added to the list.", (byte)1); // player_added %NO added to the list.
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerFromEntryList(CreatureObject owner,long oid, String firstName){
|
||||
if (entryList.contains(oid)){
|
||||
this.entryList.remove(oid);
|
||||
owner.sendSystemMessage(firstName+ " removed to the list.", (byte)1); // player_removed %NO removed from the list.
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayerToBanList(CreatureObject owner,long oid, String firstName){
|
||||
if (!banList.contains(oid)){
|
||||
this.banList.add(oid);
|
||||
owner.sendSystemMessage(firstName+ " added to the list.", (byte)1);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerFromBanList(CreatureObject owner,long oid, String firstName){
|
||||
if (banList.contains(oid)){
|
||||
this.banList.remove(oid);
|
||||
owner.sendSystemMessage(firstName+ " removed to the list.", (byte)1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
@@ -100,5 +238,14 @@ public class BuildingObject extends TangibleObject implements IPersistent {
|
||||
txn = env.beginTransaction(null, null);
|
||||
txn.setLockTimeout(500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
||||
public Vector<CellObject> getCells() {
|
||||
final Vector<CellObject> cells = new Vector<CellObject>();
|
||||
this.viewChildren(this, true, false, (obj) -> {
|
||||
if(obj instanceof CellObject)
|
||||
cells.add((CellObject) obj);
|
||||
});
|
||||
return cells;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.craft;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent
|
||||
public class DraftSchematic extends SWGObject {
|
||||
|
||||
|
||||
public DraftSchematic(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, position, orientation, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ package resources.objects.creature;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -31,9 +32,8 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import engine.resources.common.CRC;
|
||||
import resources.objects.Buff;
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.SkillMod;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.objects.SkillMod;
|
||||
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
@@ -72,7 +72,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
} else {
|
||||
buffer.putInt(creature.getSkills().size());
|
||||
buffer.putInt(creature.getSkillsUpdateCounter());
|
||||
for(String skill : creature.getSkills().get())
|
||||
for(String skill : creature.getSkills())
|
||||
buffer.put(getAsciiString(skill));
|
||||
}
|
||||
int size = buffer.position();
|
||||
@@ -89,6 +89,11 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
if(creature.getStfName() == null || creature.getStfFilename() == null) {
|
||||
creature.setStfName("");
|
||||
creature.setStfFilename("");
|
||||
}
|
||||
|
||||
buffer.putShort((short) 19); // Object Count
|
||||
buffer.putFloat(1);
|
||||
@@ -97,7 +102,8 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.put(getAsciiString(creature.getStfName()));
|
||||
if (creature.getCustomName() == null) { creature.setCustomName(""); }//Not all CreatureObjects have CustomName (Shuttles)
|
||||
buffer.put(getUnicodeString(creature.getCustomName()));
|
||||
buffer.putInt(0x000F4240); // volume
|
||||
// buffer.putInt(0x000F4240); // volume
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(CRC.StringtoCRC(creature.getFaction()));
|
||||
|
||||
buffer.putInt(creature.getFactionStatus());
|
||||
@@ -110,11 +116,11 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putShort((short) customizationData.length);
|
||||
buffer.put(customizationData);
|
||||
}
|
||||
buffer.putInt(1);
|
||||
//buffer.putInt(1);
|
||||
buffer.putInt(0); // TANO Data
|
||||
buffer.putInt(0);
|
||||
// buffer.putInt(creature.getOptionsBitmask()); // 0x80 = Player, 0x08 = Quest NPC,
|
||||
buffer.putInt(0x80);
|
||||
buffer.putInt(creature.getOptionsBitmask()); // 0x80 = Player, 0x08 = Quest NPC,
|
||||
//buffer.putInt(0x80);
|
||||
buffer.putInt(creature.getIncapTimer());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0x3A98);
|
||||
@@ -126,8 +132,8 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putLong(creature.getOwnerId());
|
||||
|
||||
float height = creature.getHeight();
|
||||
if (height < 0.7 || height > 1.5)
|
||||
height = 1;
|
||||
//if (height < 0.7 || height > 1.5)
|
||||
// height = 1;
|
||||
buffer.putFloat(height);
|
||||
buffer.putInt(0); // battle fatigue
|
||||
buffer.putLong(creature.getStateBitmask());
|
||||
@@ -152,23 +158,21 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(0); // HAM Encumberance List unused in NGE
|
||||
buffer.putInt(0);
|
||||
|
||||
if(creature.getSkillMods().isEmpty()) {
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
} else {
|
||||
buffer.putInt(creature.getSkillMods().size());
|
||||
buffer.putInt(creature.getSkillModsUpdateCounter());
|
||||
|
||||
for(SkillMod skillMod : creature.getSkillMods().get()) {
|
||||
buffer.put((byte) 0);
|
||||
buffer.put(getAsciiString(skillMod.getSkillModString()));
|
||||
buffer.putInt(skillMod.getBase());
|
||||
buffer.putInt(skillMod.getModifier());
|
||||
}
|
||||
buffer.putInt(creature.getSkillMods().size());
|
||||
buffer.putInt(creature.getSkillMods().getUpdateCounter());
|
||||
for (SkillMod skillMod : creature.getSkillMods().values()) {
|
||||
buffer.put((byte) 0);
|
||||
buffer.put(getAsciiString(skillMod.getName()));
|
||||
buffer.put(skillMod.getBytes());
|
||||
}
|
||||
|
||||
buffer.putFloat(creature.getSpeedMultiplierBase());
|
||||
buffer.putFloat(creature.getSpeedMultiplierMod());
|
||||
buffer.putLong(creature.getListenToId());
|
||||
|
||||
if(creature.getPerformanceListenee() != null)
|
||||
buffer.putLong(creature.getPerformanceListenee().getObjectId());
|
||||
else
|
||||
buffer.putLong(0);
|
||||
|
||||
buffer.putFloat(creature.getRunSpeed());
|
||||
|
||||
@@ -195,7 +199,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(1);
|
||||
}
|
||||
}
|
||||
buffer.putInt(0); // unk
|
||||
buffer.putInt(creature.getXpBarValue()); // xp bar value
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
@@ -212,21 +216,23 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short) 0x23);
|
||||
buffer.putInt(0x43);
|
||||
buffer.putInt(0x43); // serverId
|
||||
|
||||
buffer.putInt(0); // defenders list unused in NGE
|
||||
buffer.putInt(0);
|
||||
buffer.putShort((short) 0); // detaiLStfFilename
|
||||
buffer.putInt(0); // detailStfSpacer
|
||||
buffer.putShort((short) 0); // detailStfName
|
||||
|
||||
// TANO 6 lists TODO: research
|
||||
|
||||
buffer.put(creature.getCombatFlag());
|
||||
|
||||
buffer.putLong(0);
|
||||
buffer.putLong(0);
|
||||
buffer.putLong(0); // Vehicle vars or TANO 6 vars TODO: research
|
||||
buffer.putLong(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putLong(0); //List<Long> possibly defenders list
|
||||
buffer.putInt(0); //Int
|
||||
buffer.putLong(0); //List<Long>
|
||||
buffer.putLong(0); //List<Int>
|
||||
buffer.putLong(0); //List<Unknown>
|
||||
|
||||
buffer.putShort(creature.getLevel());
|
||||
//buffer.putShort((short) 90);
|
||||
buffer.putInt(creature.getGrantedHealth()); // From player_level.iff. Ranges from 0-2000 as you level, consistent with that table.
|
||||
|
||||
//0A
|
||||
@@ -252,8 +258,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putLong(creature.getInviteCounter());
|
||||
|
||||
buffer.putInt(creature.getGuildId());
|
||||
//10
|
||||
buffer.putLong(creature.getTargetId());
|
||||
|
||||
buffer.putLong(creature.getLookAtTarget()); // lookAtTarget 0x10
|
||||
buffer.putLong(creature.getIntendedTarget()); // intendedTarget 0x11
|
||||
buffer.put(creature.getMoodId());
|
||||
buffer.putInt(creature.getPerformanceCounter());
|
||||
/*
|
||||
@@ -261,9 +268,6 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
* in the CREO, otherwise the evul note bubbles appear
|
||||
*/
|
||||
buffer.putInt((creature.getPerformanceType()) ? 0 : creature.getPerformanceId());
|
||||
|
||||
buffer.putInt(0); // unks
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(6); // Current HAM
|
||||
buffer.putInt(creature.getHamListCounter());
|
||||
@@ -296,7 +300,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
for(SWGObject obj : creature.getEquipmentList().get()) {
|
||||
|
||||
if(obj instanceof TangibleObject) {
|
||||
if(obj instanceof TangibleObject && !(obj instanceof WeaponObject)) {
|
||||
TangibleObject tangible = (TangibleObject) obj;
|
||||
if(tangible.getCustomization() == null || tangible.getCustomization().length == 0) {
|
||||
buffer.putShort((short) 0);
|
||||
@@ -331,9 +335,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
buffer.putShort((short) 0);
|
||||
buffer.putShort((short) 0); // costume
|
||||
//buffer.put(getAsciiString("appearance/gungan_m.sat"));
|
||||
buffer.put((byte) 1); // 0 = cloak
|
||||
buffer.put((byte) (creature.isInStealth() ? 0 : 1));
|
||||
|
||||
if(creature.getBuffList().isEmpty()) {
|
||||
buffer.putInt(0);
|
||||
@@ -353,11 +357,14 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");
|
||||
|
||||
for(Buff buff : creature.getBuffList().get()) {
|
||||
|
||||
buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
|
||||
|
||||
if(player != null)
|
||||
buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
|
||||
else
|
||||
buff.setTotalPlayTime(0);
|
||||
buffer.put((byte) 1);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(CRC.StringtoCRC(buff.getBuffName()));
|
||||
buffer.putInt(CRC.StringtoCRC(buff.getBuffName().toLowerCase()));
|
||||
if(buff.getDuration() > 0) {
|
||||
buffer.putInt((int) (buff.getTotalPlayTime() + buff.getRemainingDuration()));
|
||||
buffer.putInt(0);
|
||||
@@ -376,10 +383,15 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
buffer.put((byte) 0); // crashes if 1
|
||||
buffer.put((byte) (creature.isStationary() ? 1 : 0)); // if the server accepts transforms from the object
|
||||
buffer.put(creature.getDifficulty());
|
||||
buffer.putInt(0xFFFFFFFF); // -1 normal appearance, 0 hologram
|
||||
buffer.put((byte) 1); // crashes if 0
|
||||
|
||||
if(creature.isHologram())
|
||||
buffer.putInt(0);
|
||||
else
|
||||
buffer.putInt(0xFFFFFFFF);
|
||||
|
||||
buffer.put((byte) (creature.isRadarVisible() ? 1 : 0));
|
||||
buffer.put((byte) 0); // no effect for 1?
|
||||
buffer.put((byte) 0); // no effect for 1?
|
||||
|
||||
@@ -412,8 +424,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.putInt(0); // unk list
|
||||
buffer.putInt(0);
|
||||
buffer.putLong(0); // unk long
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
@@ -664,16 +675,22 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildTargetDelta(long targetId) {
|
||||
|
||||
public IoBuffer buildLookAtTargetDelta(long targetId) {
|
||||
IoBuffer buffer = bufferPool.allocate(8, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putLong(targetId);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x10, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildIntendedTargetDelta(long targetId) {
|
||||
IoBuffer buffer = bufferPool.allocate(8, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putLong(targetId);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x11, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildHealthDelta(int health) {
|
||||
@@ -758,7 +775,10 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
IoBuffer buffer = bufferPool.allocate(37, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getBuffListCounter());
|
||||
buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
|
||||
if(player != null)
|
||||
buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
|
||||
else
|
||||
buff.setTotalPlayTime(0);
|
||||
buffer.put((byte) 0);
|
||||
buffer.put(buff.getBytes());
|
||||
int size = buffer.position();
|
||||
@@ -794,7 +814,10 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
IoBuffer buffer = bufferPool.allocate(37, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getBuffListCounter());
|
||||
buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
|
||||
if(player != null)
|
||||
buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000));
|
||||
else
|
||||
buff.setTotalPlayTime(0);
|
||||
buffer.put((byte) 2);
|
||||
buffer.put(buff.getBytes());
|
||||
int size = buffer.position();
|
||||
@@ -822,46 +845,6 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildAddSkillModDelta(String name, int base) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(19 + name.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getSkillModsUpdateCounter());
|
||||
buffer.put((byte) 0);
|
||||
buffer.put(getAsciiString(name));
|
||||
buffer.putInt(base);
|
||||
buffer.putInt(0);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 3, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildRemoveSkillModDelta(String name, int base) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
IoBuffer buffer = bufferPool.allocate(19 + name.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(creature.getSkillModsUpdateCounter());
|
||||
buffer.put((byte) 1);
|
||||
buffer.put(getAsciiString(name));
|
||||
buffer.putInt(base);
|
||||
buffer.putInt(0);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 3, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildAddSkillDelta(String name) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
@@ -1049,13 +1032,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1C, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildAddEquipmentDelta(TangibleObject item) {
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
@@ -1156,12 +1133,73 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder {
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildXPBarDelta(int xpBarValue) {
|
||||
IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putInt(xpBarValue);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 0x0F, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// TODO: This seems to be somehow related to chairs as well.
|
||||
public IoBuffer buildOwnerIdDelta(long ownerId) {
|
||||
IoBuffer buffer = bufferPool.allocate(8, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putLong(ownerId);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 3, (short) 1, (short) 0x0F, buffer, size + 4); // This is the correct one
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildStealthFlagDelta(boolean flag) {
|
||||
IoBuffer buffer = bufferPool.allocate(8, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put((byte) (flag ? 0 : 1));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x19, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildRadarVisibleFlagDelta(boolean flag) {
|
||||
IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put((byte) (flag ? 1 : 0));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1E, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
switch (viewType) {
|
||||
case 4: {
|
||||
switch (updateType) {
|
||||
case 3: {
|
||||
buffer = createDelta("CREO", (byte) 4, (short) 1, (byte) 3, buffer, buffer.array().length + 4);
|
||||
|
||||
if (object.getClient() != null && object.getClient().getSession() != null) {
|
||||
object.getClient().getSession().write(buffer);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
case 3:
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.deed;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
public class Deed extends TangibleObject {
|
||||
|
||||
public Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.deed;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
@Persistent(version=0)
|
||||
public class Harvester_Deed extends Deed {
|
||||
|
||||
private String name;
|
||||
private String structureTemplate;
|
||||
private String constructorTemplate;
|
||||
private int outputHopperCapacity=0;
|
||||
private int BER=0;
|
||||
private int BMR=0;
|
||||
private int surplusMaintenance=0;
|
||||
private int surplusPower=0;
|
||||
private int lotRequirement;
|
||||
|
||||
|
||||
public Harvester_Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
}
|
||||
|
||||
public int getOutputHopperCapacity() {
|
||||
return outputHopperCapacity;
|
||||
}
|
||||
public void setOutputHopperCapacity(int outputHopperCapacity) {
|
||||
this.outputHopperCapacity = outputHopperCapacity;
|
||||
}
|
||||
public int getBER() {
|
||||
return BER;
|
||||
}
|
||||
public void setBER(int bER) {
|
||||
this.BER = bER;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getStructureTemplate() {
|
||||
return structureTemplate;
|
||||
}
|
||||
public void setStructureTemplate(String structureTemplate) {
|
||||
this.structureTemplate = structureTemplate;
|
||||
}
|
||||
public int getLotRequirement() {
|
||||
return lotRequirement;
|
||||
}
|
||||
public void setLotRequirement(int lotRequirement) {
|
||||
this.lotRequirement = lotRequirement;
|
||||
}
|
||||
public String getConstructorTemplate() {
|
||||
return constructorTemplate;
|
||||
}
|
||||
public void setConstructorTemplate(String constructorTemplate) {
|
||||
this.constructorTemplate = constructorTemplate;
|
||||
}
|
||||
public int getBMR() {
|
||||
return BMR;
|
||||
}
|
||||
public void setBMR(int BMR) {
|
||||
this.BMR = BMR;
|
||||
}
|
||||
public int getSurplusMaintenance() {
|
||||
return surplusMaintenance;
|
||||
}
|
||||
public void setSurplusMaintenance(int surplusMaintenance) {
|
||||
this.surplusMaintenance = surplusMaintenance;
|
||||
}
|
||||
|
||||
public int getSurplusPower() {
|
||||
return surplusPower;
|
||||
}
|
||||
|
||||
public void setSurplusPower(int surplusPower) {
|
||||
this.surplusPower = surplusPower;
|
||||
}
|
||||
|
||||
|
||||
public void setAttributes() {
|
||||
this.getAttributes().put("@obj_attr_n:volume", "1");
|
||||
this.getAttributes().put("@obj_attr_n:examine_maintenance_rate", ""+this.getBMR() + "/hour");
|
||||
if (this.getSurplusMaintenance()>0)
|
||||
this.getAttributes().put("@obj_attr_n:examine_maintenance", ""+this.getSurplusMaintenance());
|
||||
|
||||
//this.getAttributes().put("@obj_attr_n:energy_maintenance", "0");
|
||||
if (this.getSurplusPower()>0)
|
||||
this.getAttributes().put("@obj_attr_n:examine_power", ""+this.getSurplusPower());
|
||||
|
||||
this.getAttributes().put("@obj_attr_n:examine_hoppersize", ""+this.getOutputHopperCapacity());
|
||||
this.getAttributes().put("@obj_attr_n:examine_extractionrate", ""+this.getBER());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.deed;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
/**
|
||||
* @author Seefo
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class Player_House_Deed extends Deed {
|
||||
|
||||
private String name;
|
||||
private String structureTemplate;
|
||||
private String constructorTemplate;
|
||||
private int BMR=0;
|
||||
private int surplusMaintenance=0;
|
||||
private int lotRequirement;
|
||||
|
||||
|
||||
public Player_House_Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getStructureTemplate() {
|
||||
return structureTemplate;
|
||||
}
|
||||
public void setStructureTemplate(String structureTemplate) {
|
||||
this.structureTemplate = structureTemplate;
|
||||
}
|
||||
public int getLotRequirement() {
|
||||
return lotRequirement;
|
||||
}
|
||||
public void setLotRequirement(int lotRequirement) {
|
||||
this.lotRequirement = lotRequirement;
|
||||
}
|
||||
public String getConstructorTemplate() {
|
||||
return constructorTemplate;
|
||||
}
|
||||
public void setConstructorTemplate(String constructorTemplate) {
|
||||
this.constructorTemplate = constructorTemplate;
|
||||
}
|
||||
public int getBMR() {
|
||||
return BMR;
|
||||
}
|
||||
public void setBMR(int BMR) {
|
||||
this.BMR = BMR;
|
||||
}
|
||||
public int getSurplusMaintenance() {
|
||||
return surplusMaintenance;
|
||||
}
|
||||
public void setSurplusMaintenance(int surplusMaintenance) {
|
||||
this.surplusMaintenance = surplusMaintenance;
|
||||
}
|
||||
|
||||
public void setAttributes() {
|
||||
this.getAttributes().put("@obj_attr_n:volume", "1");
|
||||
this.getAttributes().put("@obj_attr_n:examine_maintenance_rate", ""+this.getBMR() + "/hour");
|
||||
if (this.getSurplusMaintenance()>0)
|
||||
this.getAttributes().put("@obj_attr_n:examine_maintenance", ""+this.getSurplusMaintenance());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,156 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.factorycrate;
|
||||
|
||||
public class FactoryCrateMessageBuilder {
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceContainerObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
public class FactoryCrateMessageBuilder extends ObjectMessageBuilder{
|
||||
|
||||
public FactoryCrateMessageBuilder(FactoryCrateObject factoryCrateObject) {
|
||||
setObject(factoryCrateObject);
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline3() {
|
||||
FactoryCrateObject factoryCrateObject = (FactoryCrateObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putFloat(1.0f); //op0
|
||||
buffer.put(getAsciiString("factory_n"));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString("food_crate"));
|
||||
|
||||
if (factoryCrateObject.getCustomName().length()>0)
|
||||
buffer.put(getUnicodeString(factoryCrateObject.getCustomName()));
|
||||
else
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(1);
|
||||
buffer.putShort((short)0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0x2100); // optionsbitmask
|
||||
buffer.putInt((int)factoryCrateObject.getQuantity()); // Quantity // op9
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0x64); // condition maybe
|
||||
|
||||
buffer.put((byte)1);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TYCF", (byte) 3, buffer, size);
|
||||
|
||||
return buffer;
|
||||
|
||||
// 01 00 00 00
|
||||
// 00 00
|
||||
// 00 00 00 00
|
||||
// 00 00 00 00
|
||||
// 00 00 00 00
|
||||
// 00 00 00 00
|
||||
// 00 21 00 00
|
||||
// 2A 00 00 00
|
||||
// 00 00 00 00
|
||||
// 64 00 00 00
|
||||
// 01
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline6() {
|
||||
FactoryCrateObject factoryCrateObject = (FactoryCrateObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short)6);
|
||||
buffer.putInt(3);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.put((byte)0);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TYCF", (byte) 6, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline8() {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)0);
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("RCNO", (byte) 8, buffer, size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline9() {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)0);
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TYCF", (byte) 9, buffer, size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDelta3() {
|
||||
FactoryCrateObject factoryCrateObject = (FactoryCrateObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putInt(factoryCrateObject.getQuantity());
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("TYCF", (byte) 3, (short) 1, (short) 9, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,250 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.factorycrate;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import protocol.swg.SceneCreateObjectByCrc;
|
||||
import protocol.swg.SceneDestroyObject;
|
||||
import protocol.swg.SceneEndBaselines;
|
||||
import protocol.swg.UpdateContainmentMessage;
|
||||
import protocol.swg.UpdatePVPStatusMessage;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class FactoryCrateObject extends TangibleObject {
|
||||
|
||||
private Vector<TangibleObject> contents;
|
||||
private byte capacity;
|
||||
private byte contentObjectQuantity;
|
||||
private int contentCRC;
|
||||
private TangibleObject contentObjectType;
|
||||
|
||||
@NotPersistent
|
||||
private FactoryCrateMessageBuilder messageBuilder;
|
||||
|
||||
public FactoryCrateObject() {
|
||||
|
||||
}
|
||||
|
||||
public FactoryCrateObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) {
|
||||
super(objectID, planet, template, position, orientation);
|
||||
this.messageBuilder = new FactoryCrateMessageBuilder(this);
|
||||
this.contents = new Vector<TangibleObject>();
|
||||
this.contentObjectQuantity = 0;
|
||||
this.capacity = 25;
|
||||
this.getAttributes().put("@obj_attr_n:condition", "100/100");
|
||||
this.getAttributes().put("@obj_attr_n:volume", "1");
|
||||
this.getAttributes().put("@obj_attr_n:quantity", "1");
|
||||
this.getAttributes().put("@obj_attr_n:factory_count", "1");
|
||||
this.getAttributes().put("@obj_attr_n:factory_attribs", "------------");
|
||||
this.getAttributes().put("@obj_attr_n:type", "@got_n:component");
|
||||
this.getAttributes().put("@obj_attr_n:serial_number", "123");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean setContentType(TangibleObject contentObject) {
|
||||
synchronized(objectMutex) {
|
||||
this.contentObjectType = contentObject;
|
||||
if (contentObject.getTemplate().length()>0)
|
||||
this.contentCRC = CRC.StringtoCRC(contentObject.getTemplate());
|
||||
else
|
||||
this.contentCRC = 0;
|
||||
|
||||
Map<String,String> contentAttributes = contentObject.getAttributes();
|
||||
for (Map.Entry<String, String> entry : contentAttributes.entrySet())
|
||||
{
|
||||
//if (!entry.getKey().equals(@obj_attr_n:condition))
|
||||
this.getAttributes().put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public TangibleObject getContentType() {
|
||||
return this.contentObjectType;
|
||||
}
|
||||
|
||||
public boolean setContentTypeAndQuantity(TangibleObject contentObject, int quantity) {
|
||||
synchronized(objectMutex) {
|
||||
this.contentObjectType = contentObject;
|
||||
if (contentObject.getTemplate().length()>0)
|
||||
this.contentCRC = CRC.StringtoCRC(contentObject.getTemplate());
|
||||
else{
|
||||
this.contentCRC = 0;
|
||||
return false; // Does it make sense to continue anyway?
|
||||
}
|
||||
|
||||
Map<String,String> contentAttributes = contentObject.getAttributes();
|
||||
for (Map.Entry<String, String> entry : contentAttributes.entrySet())
|
||||
{
|
||||
//if (!entry.getKey().equals(@obj_attr_n:condition))
|
||||
this.getAttributes().put(entry.getKey(), entry.getValue());
|
||||
System.out.println(entry.getKey() + " " + entry.getValue());
|
||||
}
|
||||
if (quantity<capacity) {
|
||||
contentObject.setSerialNumber(contentObject.getSerialNumber());
|
||||
for (int i=0;i<quantity;i++){
|
||||
contents.add(contentObject);
|
||||
}
|
||||
contentObjectQuantity = (byte) quantity;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addToCrate(TangibleObject contentObject) {
|
||||
synchronized(objectMutex) {
|
||||
if (contentObjectQuantity<capacity) {
|
||||
if (! contents.isEmpty()) {
|
||||
TangibleObject serialProvider = contents.firstElement();
|
||||
contentObject.setSerialNumber(serialProvider.getSerialNumber());
|
||||
}
|
||||
contents.add(contentObject);
|
||||
contentObjectQuantity ++;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getContentFilename() {
|
||||
if (!contents.isEmpty()) {
|
||||
return contents.firstElement().getStfFilename();
|
||||
} else {
|
||||
System.err.println("Crate is empty");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void getObjectOutOfCrate(CreatureObject player,NGECore core) {
|
||||
synchronized(objectMutex) {
|
||||
if (this.getQuantity()>0){
|
||||
TangibleObject contentType = this.getContentType();
|
||||
if (contentType==null)
|
||||
return; // Bad, crate had no content type set
|
||||
TangibleObject contentItem = (TangibleObject) core.objectService.createObject(contentType.getTemplate(), player.getPlanet());
|
||||
contentItem.setOptions(resources.datatables.Options.SERIAL, true);
|
||||
int crc = this.getContentCRC();//CRC.StringtoCRC("object/tangible/food/crafted/shared_drink_alcohol.iff");
|
||||
SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(contentItem.getObjectID(), player.getOrientation().x, player.getOrientation().y, player.getOrientation().z, player.getOrientation().w, player.getPosition().x, player.getPosition().y, player.getPosition().z, crc, (byte) 0);
|
||||
player.getClient().getSession().write(createObjectMsg.serialize());
|
||||
contentItem.sendBaselines(player.getClient()); // TANO 3,6,8,9 Baselines
|
||||
SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(contentItem.getObjectID());
|
||||
player.getClient().getSession().write(sceneEndBaselinesMsg.serialize());
|
||||
|
||||
long parentId = this.getParentId();
|
||||
SWGObject parentContainer = core.objectService.getObject(parentId);
|
||||
if (parentContainer==null)
|
||||
return; // crate has no parent, error
|
||||
UpdateContainmentMessage updateContainmentMessage= new UpdateContainmentMessage(contentItem.getObjectID(), parentContainer.getObjectID(), -1);
|
||||
player.getClient().getSession().write(updateContainmentMessage.serialize());
|
||||
|
||||
this.sendSetQuantity(player.getClient(),this.getQuantity()-1);
|
||||
if (this.getQuantity()==0){ // Crate is empty now, delete it
|
||||
parentContainer._remove(this);
|
||||
SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(this.getObjectID());
|
||||
player.getClient().getSession().write(destroyObjectMsg.serialize());
|
||||
core.objectService.destroyObject(this);
|
||||
}
|
||||
} else { // should give players the chance to clean faulty, empty crates from their containers
|
||||
long parentId = this.getParentId();
|
||||
SWGObject parentContainer = core.objectService.getObject(parentId);
|
||||
if (parentContainer==null)
|
||||
return; // crate has no parent, error
|
||||
parentContainer._remove(this);
|
||||
SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(this.getObjectID());
|
||||
player.getClient().getSession().write(destroyObjectMsg.serialize());
|
||||
core.objectService.destroyObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte getQuantity() {
|
||||
return contentObjectQuantity;
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
if (!contents.isEmpty()) {
|
||||
return contents.firstElement().getSerialNumber();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getContentCRC() {
|
||||
return contentCRC;
|
||||
}
|
||||
|
||||
}
|
||||
public void setContentCRC(int contentCRC) {
|
||||
synchronized(objectMutex) {
|
||||
this.contentCRC = contentCRC;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSplit(){
|
||||
|
||||
}
|
||||
|
||||
public void sendAddItem(Client destination) {
|
||||
destination.getSession().write(messageBuilder.buildDelta3());
|
||||
this.getAttributes().put("@obj_attr_n:factory_count", ""+this.getQuantity());
|
||||
this.getAttributes().put("@obj_attr_n:quantity", ""+this.getQuantity());
|
||||
//services.CharonPacketUtils.printAnalysis(messageBuilder.buildDelta3(),"FCYT3 Delta");
|
||||
}
|
||||
|
||||
public void sendSetQuantity(Client destination,int quantity) {
|
||||
contentObjectQuantity = (byte) quantity;
|
||||
destination.getSession().write(messageBuilder.buildDelta3());
|
||||
this.getAttributes().put("@obj_attr_n:factory_count", ""+quantity);
|
||||
this.getAttributes().put("@obj_attr_n:quantity", ""+this.getQuantity());
|
||||
//services.CharonPacketUtils.printAnalysis(messageBuilder.buildDelta3(),"FCYT3 Delta");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
|
||||
if(destination == null || destination.getSession() == null) {
|
||||
System.out.println("NULL destination");
|
||||
return;
|
||||
}
|
||||
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
destination.getSession().write(messageBuilder.buildBaseline8());
|
||||
destination.getSession().write(messageBuilder.buildBaseline9());
|
||||
|
||||
// services.CharonPacketUtils.printAnalysis(messageBuilder.buildBaseline3(),"FCYT3 Baseline");
|
||||
// services.CharonPacketUtils.printAnalysis(messageBuilder.buildBaseline6(),"FCYT6 Baseline");
|
||||
// services.CharonPacketUtils.printAnalysis(messageBuilder.buildBaseline8(),"FCYT8 Baseline");
|
||||
// services.CharonPacketUtils.printAnalysis(messageBuilder.buildBaseline9(),"FCYT9 Baseline");
|
||||
}
|
||||
|
||||
public void sendDelta3(Client destination) {
|
||||
destination.getSession().write(messageBuilder.buildDelta3());
|
||||
this.getAttributes().put("@obj_attr_n:factory_count", ""+this.getQuantity());
|
||||
//services.CharonPacketUtils.printAnalysis(messageBuilder.buildDelta3(),"FCYT3 Delta");
|
||||
}
|
||||
}
|
||||
@@ -39,9 +39,15 @@ public class GroupObject extends UniverseObject {
|
||||
private short groupLevel;
|
||||
private int lootMode;
|
||||
private GroupMessageBuilder messageBuilder;
|
||||
private int chatRoomId;
|
||||
|
||||
public static int FREE_FOR_ALL = 0;
|
||||
public static int MASTER_LOOTER = 1;
|
||||
public static int LOTTERY = 2;
|
||||
|
||||
|
||||
public GroupObject(long objectId) {
|
||||
super(objectId, null, new Point3D(0, 0, 0), new Quaternion(0, 0, 0, 1), "object/group/shared_group_object.iff");
|
||||
super(objectId, null, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/group/shared_group_object.iff");
|
||||
messageBuilder = new GroupMessageBuilder(this);
|
||||
}
|
||||
|
||||
@@ -108,7 +114,19 @@ public class GroupObject extends UniverseObject {
|
||||
this.lootMode = lootMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getChatRoomId() {
|
||||
synchronized(objectMutex) {
|
||||
return chatRoomId;
|
||||
}
|
||||
}
|
||||
|
||||
public void setChatRoomId(int chatRoomId) {
|
||||
synchronized(objectMutex) {
|
||||
this.chatRoomId = chatRoomId;
|
||||
}
|
||||
}
|
||||
|
||||
public void addMember(SWGObject member) {
|
||||
|
||||
if(memberList.size() >= 8 || member.getClient() == null)
|
||||
@@ -147,5 +165,4 @@ public class GroupObject extends UniverseObject {
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,12 +46,11 @@ import com.sleepycat.persist.model.NotPersistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Entity(version=0)
|
||||
@Entity(version=1)
|
||||
public class GuildObject extends UniverseObject implements IPersistent {
|
||||
|
||||
protected NGECore core;
|
||||
@@ -63,6 +62,8 @@ public class GuildObject extends UniverseObject implements IPersistent {
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
private long nextInstanceId = 0;
|
||||
|
||||
// GILD 3
|
||||
private float complexity = 0x803F0F00;
|
||||
private String STFFile = "string_id_table";
|
||||
@@ -281,6 +282,12 @@ public class GuildObject extends UniverseObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized long getNextInstanceId() {
|
||||
long ret = nextInstanceId;
|
||||
nextInstanceId++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
|
||||
@@ -21,6 +21,806 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.harvester;
|
||||
|
||||
public class HarvesterMessageBuilder {
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceContainerObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
public class HarvesterMessageBuilder extends ObjectMessageBuilder{
|
||||
|
||||
public HarvesterMessageBuilder(HarvesterObject harvesterObject) {
|
||||
setObject(harvesterObject);
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline3() {
|
||||
|
||||
HarvesterObject building = (HarvesterObject) object;
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short) 0x0D);
|
||||
buffer.putFloat(building.getComplexity());
|
||||
buffer.put(getAsciiString(building.getStfFilename()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(building.getStfName()));
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0xFF);
|
||||
//buffer.putInt(0x64);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putShort((short) 0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
// buffer.putInt(16777216);
|
||||
buffer.putInt(0x100);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(64);
|
||||
buffer.putInt(0x201C);
|
||||
buffer.put((byte) 1);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("BUIO", (byte) 3, buffer, size);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildHINO3Delta(HarvesterObject harvester,byte state) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(0xB);
|
||||
buffer.putShort((short)2);
|
||||
buffer.putShort((short)8);
|
||||
buffer.put((byte)1);
|
||||
buffer.putShort((short)1);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)0xD);
|
||||
buffer.put(state);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
// 0000: 05 00 53 21 86 12 33 01 0E BE 41 00 00 00 4F 4E ..S!..3...A...ON
|
||||
// 0010: 49 48 03 0B 00 00 00 02 00 08 00 01 01 00 00 0D IH..............
|
||||
// 0020: 00 01
|
||||
|
||||
|
||||
public IoBuffer buildHINO3Delta2(HarvesterObject harvester,byte state) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(0xB);
|
||||
buffer.putShort((short)2);
|
||||
buffer.putShort((short)8);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)1);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)0xD);
|
||||
buffer.put(state);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline6() {
|
||||
|
||||
HarvesterObject building = (HarvesterObject) object;
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short) 8);
|
||||
buffer.putInt(0x43);
|
||||
|
||||
buffer.put(getAsciiString(building.getDetailFilename()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(building.getDetailName()));
|
||||
buffer.putInt(0);
|
||||
buffer.put((byte) 0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("BUIO", (byte) 6, buffer, size);
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildHINO7Delta(HarvesterObject harvester,byte state) {
|
||||
|
||||
Vector<ResourceContainerObject> outputHopperContent = harvester.getOutputHopperContent();
|
||||
int hopperContentSize = outputHopperContent.size();
|
||||
int iHopperList = 1;
|
||||
if (hopperContentSize==0) {
|
||||
iHopperList = 0;
|
||||
}
|
||||
//int sizeP = 30 + 15*hopperContentSize;
|
||||
int sizeP = 30-2-4-4;
|
||||
//System.out.println("sizeP " + sizeP);
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
buffer.putInt(sizeP);
|
||||
// dOut.writeInt(0x2D);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put(state);
|
||||
buffer.putShort((short)9);
|
||||
buffer.putFloat(harvester.getActualExtractionRate());
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put(harvester.getUpdateCount());
|
||||
// buffer.putShort((short)0x0D);
|
||||
// buffer.putInt(iHopperList);
|
||||
// buffer.putInt(harvester.getResourceUpdateCount());
|
||||
int sumOfHopper = 0;
|
||||
int i = 0;
|
||||
sumOfHopper = 0;
|
||||
Vector<ResourceContainerObject> outputHopper = harvester.getOutputHopperContent();
|
||||
for (ResourceContainerObject cont : outputHopper){
|
||||
sumOfHopper += cont.getStackCount();
|
||||
i++;
|
||||
}
|
||||
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putInt(sumOfHopper);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildHINO7Delta2(HarvesterObject harvester,byte state) {
|
||||
|
||||
Vector<ResourceContainerObject> outputHopperContent = harvester.getOutputHopperContent();
|
||||
int hopperContentSize = outputHopperContent.size();
|
||||
int iHopperList = 1;
|
||||
if (hopperContentSize==0) {
|
||||
iHopperList = 0;
|
||||
}
|
||||
int sizeP = 30 + 15*hopperContentSize;
|
||||
//System.out.println("sizeP " + sizeP);
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
buffer.putInt(sizeP);
|
||||
// dOut.writeInt(0x2D);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put(state);
|
||||
buffer.putShort((short)9);
|
||||
buffer.putFloat(harvester.getActualExtractionRate());
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put(harvester.getUpdateCount());
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putInt(iHopperList);
|
||||
buffer.putInt(harvester.getResourceUpdateCount());
|
||||
int sumOfHopper = 0;
|
||||
|
||||
byte i = 0;
|
||||
for (ResourceContainerObject container : outputHopperContent){
|
||||
buffer.putShort((short)harvester.getResourceUpdateCount());
|
||||
buffer.put(i);
|
||||
buffer.putLong(container.getReferenceID());
|
||||
buffer.putInt(container.getStackCount());
|
||||
sumOfHopper += container.getStackCount();
|
||||
i++;
|
||||
}
|
||||
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putInt(sumOfHopper);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
// 2 + 2 + 1 + 2 + 4 + 2 + 1 + 2 + 4 + 4 + (hoppersize* 2+1+8+4=15) + 2 + 4
|
||||
|
||||
// 0000: 05 00 53 21 86 12 33 01 0E BE 41 00 00 00 4F 4E ..S!..3...A...ON
|
||||
// 0010: 49 48 07 2D 00 00 00 05 00 06 00 01 09 00 3F AE IH.-..........?.
|
||||
// 0020: 2D 42 0C 00 02 0D 00 01 00 00 00 01 00 00 00 02 -B..............
|
||||
// 0030: 00 00 5E C8 62 AB 41 00 00 00 CC F1 0A 40 0A 00 ..^.b.A......@..
|
||||
// 0040: CC F1 0A 40 ...@
|
||||
|
||||
public IoBuffer buildHINO7EmptyHopperDelta(HarvesterObject harvester) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
buffer.putInt(21);
|
||||
buffer.putShort((short)3);
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put((byte)harvester.getResourceUpdateCount());
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(harvester.getResourceUpdateCount());
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putFloat(harvester.getOutputHopperContent().size());
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildHINO7ExperimentalDelta(HarvesterObject harvester) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
buffer.putInt(0x18);
|
||||
buffer.putShort((short)3);
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put((byte)harvester.getResourceUpdateCount());
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(0x1E);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)0);
|
||||
buffer.putInt(harvester.getResourceUpdateCount());
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putFloat(0); // since it's 0 outputhoppercontent
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
// 0000: 05 00 53 21 86 12 53 D0 AC 41 3F 00 00 00 4F 4E ..S!..S..A?...ON
|
||||
// 0010: 49 48 07 18 00 00 00 03 00 0C 00 25 0D 00 01 00 IH.........%....
|
||||
// 0020: 00 00 1E 00 00 00 00 00 00 0A 00 00 00 00 00 ...............
|
||||
|
||||
|
||||
public IoBuffer buildHINO7ExperimentalDelta2(HarvesterObject harvester) {
|
||||
|
||||
int iHopperList = 0;
|
||||
if (harvester.getOutputHopperContent().size() >= 1) {
|
||||
iHopperList = 1;
|
||||
}
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
|
||||
buffer.putInt(36);
|
||||
buffer.putShort((short)3);
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put(harvester.getUpdateCount());
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putInt(iHopperList);
|
||||
buffer.putInt(harvester.getResourceUpdateCount());
|
||||
int i = 0;
|
||||
int totalStackCount = 0;
|
||||
Vector<ResourceContainerObject> outputHopper = harvester.getOutputHopperContent();
|
||||
for (ResourceContainerObject cont : outputHopper){
|
||||
totalStackCount += cont.getStackCount();
|
||||
if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) {
|
||||
buffer.put((byte)2);
|
||||
buffer.putShort((short) i);
|
||||
buffer.putLong(cont.getReferenceID());
|
||||
buffer.putFloat((float)cont.getStackCount());
|
||||
//System.out.println("TOTAL STACKCOUNT " + (float)cont.getStackCount());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putFloat((float)totalStackCount);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildHINO7ActivateDelta(HarvesterObject harvester) {
|
||||
|
||||
int iHopperList = 0;
|
||||
if (harvester.getOutputHopperContent().size() >= 1) {
|
||||
iHopperList = 1;
|
||||
}
|
||||
int factor = 0;
|
||||
Vector<ResourceContainerObject> outputHopper = harvester.getOutputHopperContent();
|
||||
for (ResourceContainerObject cont : outputHopper){
|
||||
if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) {
|
||||
factor = 1;
|
||||
}
|
||||
}
|
||||
|
||||
byte iHopperUpdateCounter = harvester.getResourceUpdateCount();
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
buffer.putInt(5+19+(15*factor));
|
||||
buffer.putShort((short)5);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put((byte)1);
|
||||
// 2 + 4 + 4 + 2 + 4 + (15*h) = 16 + 2 + 1 = 19
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put(harvester.getUpdateCount());
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putInt(iHopperList);
|
||||
buffer.putInt(iHopperUpdateCounter);
|
||||
int totalStackCount = 0;
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (ResourceContainerObject cont : outputHopper){
|
||||
totalStackCount += cont.getStackCount();
|
||||
if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) {
|
||||
buffer.put((byte)2);
|
||||
buffer.putShort((short) i);
|
||||
buffer.putLong(cont.getReferenceID());
|
||||
buffer.putFloat((float)cont.getStackCount());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putFloat((float)totalStackCount);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildHINO7ActivateDelta2(HarvesterObject harvester) {
|
||||
|
||||
int iHopperList = 0;
|
||||
if (harvester.getOutputHopperContent().size() >= 1) {
|
||||
iHopperList = 1;
|
||||
}
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
|
||||
buffer.putInt(11);
|
||||
buffer.putShort((short)2);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put((byte)1);
|
||||
buffer.putShort((short)9);
|
||||
buffer.putFloat(harvester.getActualExtractionRate());
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
//
|
||||
// 02 00 06 00 01 09 00 43 94 IH............C.
|
||||
// 0020: 59 42 YB
|
||||
|
||||
public IoBuffer buildHINO7ActivateDelta2old(HarvesterObject harvester) {
|
||||
|
||||
int iHopperList = 0;
|
||||
if (harvester.getOutputHopperContent().size() >= 1) {
|
||||
iHopperList = 1;
|
||||
}
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
|
||||
buffer.putInt(5);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put((byte)1);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildHINO7DeactivateDelta(HarvesterObject harvester) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
|
||||
buffer.putInt(14);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)9);
|
||||
buffer.putFloat(0);
|
||||
buffer.putShort((short)0xC);
|
||||
buffer.put((byte)5);
|
||||
|
||||
// new
|
||||
// buffer.putShort((short)6);
|
||||
// buffer.put((byte)0);
|
||||
// buffer.putShort((short)9);
|
||||
// buffer.put((byte)0);
|
||||
// buffer.putShort((short)0xC);
|
||||
// buffer.put((byte)5);
|
||||
|
||||
//
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildHINO7DeactivateDeltaold(HarvesterObject harvester) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
|
||||
buffer.putInt(5);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putShort((short)6);
|
||||
buffer.put((byte)0);
|
||||
|
||||
// new
|
||||
buffer.putShort((short)6);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)9);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short)0xC);
|
||||
buffer.put((byte)5);
|
||||
|
||||
//
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildHINO7ClearDelta(HarvesterObject harvester) {
|
||||
|
||||
int iHopperList = 0;
|
||||
if (harvester.getOutputHopperContent().size() >= 1) {
|
||||
iHopperList = 1;
|
||||
}
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x48494E4F);
|
||||
buffer.put((byte)7);
|
||||
|
||||
buffer.putInt(36);
|
||||
buffer.putShort((short)3);
|
||||
buffer.putShort((short)0x0C);
|
||||
buffer.put(harvester.getUpdateCount());
|
||||
buffer.putShort((short)0x0D);
|
||||
buffer.putInt(iHopperList);
|
||||
buffer.putInt(harvester.getResourceUpdateCount());
|
||||
buffer.put((byte)4);
|
||||
buffer.putShort((short)0x0A);
|
||||
buffer.putFloat((float)0.0F);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildDiscardResourceResponse(HarvesterObject harvester, byte actionMode, byte actionCounter,CreatureObject owner) {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x80CE5E46);
|
||||
buffer.putInt(0x0B);
|
||||
buffer.putInt(0xEE);
|
||||
buffer.putLong(owner.getObjectID());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0xED);
|
||||
buffer.put((byte)1);
|
||||
buffer.put(actionCounter);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
//0000: 05 00 46 5E CE 80 0B 00 00 00 EE 00 00 00 62 5F ..F^..........b_
|
||||
//0010: 02 15 00 00 01 00 00 00 00 00 ED 00 00 00 01 01 ................
|
||||
// ^^ weird but works, should be zero allowed too
|
||||
|
||||
public IoBuffer buildBaseline8() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putShort((short) 0);
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TANO", (byte) 8, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline9() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putShort((short) 0);
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("TANO", (byte) 9, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildHINOBaseline7(HarvesterObject harvester,Vector<GalacticResource> vSRD) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
int sizeP = 74;
|
||||
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x68A75F0C);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x4F4E4948);
|
||||
buffer.put((byte)7);
|
||||
|
||||
int iResourceCount = vSRD.size();
|
||||
Vector<ResourceContainerObject> outputHopperContent = harvester.getOutputHopperContent();
|
||||
int hopperContentSize = outputHopperContent.size();
|
||||
float outputHopperCount = 0;
|
||||
|
||||
//y = a + 4x + 16x + 12z = a + 20x + 12z
|
||||
sizeP += (iResourceCount * 4);
|
||||
sizeP += (iResourceCount * 16);
|
||||
|
||||
sizeP += (hopperContentSize * 12);
|
||||
|
||||
for (int i = 0; i < iResourceCount; i++) {
|
||||
sizeP += vSRD.get(i).getName().length();
|
||||
sizeP += vSRD.get(i).getFileName().length();
|
||||
}
|
||||
|
||||
buffer.putInt(sizeP);
|
||||
|
||||
for (ResourceContainerObject container : outputHopperContent){
|
||||
outputHopperCount += container.getStackCount();
|
||||
}
|
||||
|
||||
buffer.putShort((short)0x0F);
|
||||
buffer.put((byte)1);
|
||||
buffer.putInt(iResourceCount);
|
||||
buffer.putInt(iResourceCount);
|
||||
|
||||
for (int i = 0; i < iResourceCount; i++) {
|
||||
buffer.putLong(vSRD.get(i).getId());
|
||||
}
|
||||
buffer.putInt(iResourceCount);
|
||||
|
||||
buffer.putInt(iResourceCount);
|
||||
|
||||
for (int i = 0; i < iResourceCount; i++) {
|
||||
buffer.putLong(vSRD.get(i).getId());
|
||||
}
|
||||
|
||||
buffer.putInt(iResourceCount);
|
||||
|
||||
buffer.putInt(iResourceCount);
|
||||
|
||||
for (int i = 0; i < iResourceCount; i++) {
|
||||
buffer.put(getAsciiString(vSRD.get(i).getName()));
|
||||
}
|
||||
|
||||
buffer.putInt(iResourceCount);
|
||||
buffer.putInt(iResourceCount);
|
||||
for (int i = 0; i < iResourceCount; i++) {
|
||||
buffer.put(getAsciiString(vSRD.get(i).getFileName()));
|
||||
|
||||
}
|
||||
|
||||
if (harvester.getSelectedHarvestResource() != null) {
|
||||
buffer.putLong(harvester.getSelectedHarvestResource().getId());
|
||||
} else {
|
||||
buffer.putLong(0);
|
||||
}
|
||||
|
||||
buffer.put(harvester.isActivated() ? (byte)1 : (byte)0);
|
||||
|
||||
buffer.putInt(harvester.getSpecRate()); // SPEC RATE buffer.putInt(harvester.getBER());
|
||||
|
||||
buffer.putFloat(harvester.getBER());
|
||||
|
||||
buffer.putFloat(harvester.getActualExtractionRate());
|
||||
buffer.putFloat(outputHopperCount);
|
||||
buffer.putInt(harvester.getOutputHopperCapacity());
|
||||
buffer.put(harvester.getUpdateCount());
|
||||
buffer.putInt(hopperContentSize);
|
||||
buffer.putInt(0);
|
||||
for (ResourceContainerObject container : outputHopperContent){
|
||||
buffer.putLong(container.getReferenceID());
|
||||
buffer.putFloat(container.getStackCount());
|
||||
}
|
||||
buffer.put(harvester.getStructuralCondition());
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildCustomNameDelta(HarvesterObject harvester, String customName) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
int sizeP = 8;
|
||||
sizeP += 2*customName.length();
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
buffer.putInt(0x54414E4F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(sizeP);
|
||||
buffer.putShort((short)1);
|
||||
buffer.putShort((short)2);
|
||||
buffer.put(getUnicodeString(customName));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildPermissionListCreate(HarvesterObject harvester, Vector<String> permissionList, String listName) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
int listSize = permissionList.size();
|
||||
buffer.putShort((short)4);
|
||||
buffer.putInt(0x52F364B8);
|
||||
buffer.putInt(listSize);
|
||||
for (String name : permissionList){
|
||||
buffer.put(getUnicodeString(name));
|
||||
}
|
||||
//buffer.putInt(0x61);
|
||||
buffer.putInt(0);
|
||||
//buffer.putShort((short)0);
|
||||
buffer.put(getUnicodeString(listName));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
/*
|
||||
0000: 04 00 B8 64 F3 52 01 00 00 00 06 00 00 00 63 00 ...d.R........c.
|
||||
0010: 68 00 61 00 72 00 6F 00 6E 00 00 00 00 00 05 00 h.a.r.o.n.......
|
||||
0020: 00 00 41 00 44 00 4D 00 49 00 4E 00 ..A.D.M.I.N.
|
||||
*/
|
||||
|
||||
// Send this in response to the Radial Menu to manage harvesters,
|
||||
// it is necessary to send this *before* the 07 Baseline!
|
||||
//ResourceHarvesterActivatePageMessage (BD18C679)
|
||||
public IoBuffer buildResourceHarvesterActivatePageMessage(HarvesterObject harvester) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)2);
|
||||
buffer.putInt(0xBD18C679);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildHarvesterGetResourceData(HarvesterObject harvester,SWGObject owner,Vector<GalacticResource> planetResources) {
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x80CE5E46);
|
||||
buffer.putInt(0x0B);
|
||||
buffer.putInt(0x000000EA);
|
||||
buffer.putLong(owner.getObjectID());
|
||||
buffer.putInt(0);
|
||||
buffer.putLong(harvester.getObjectID());
|
||||
if (planetResources == null || planetResources.isEmpty()) {
|
||||
buffer.putInt(0);
|
||||
} else {
|
||||
buffer.putInt(planetResources.size());
|
||||
for (int i = 0; i < planetResources.size(); i++) {
|
||||
float localConcentration = planetResources.get(i).deliverConcentrationForSurvey(owner.getPlanetId(), owner.getPosition().x, owner.getPosition().z);
|
||||
buffer.putLong(planetResources.get(i).getId());
|
||||
buffer.put(getAsciiString(planetResources.get(i).getName()));
|
||||
buffer.put(getAsciiString(planetResources.get(i).getFileName()));
|
||||
buffer.put((byte)localConcentration);
|
||||
}
|
||||
}
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,391 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.harvester;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.installation.InstallationMessageBuilder;
|
||||
import resources.objects.installation.InstallationObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceContainerObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class HarvesterObject extends InstallationObject {
|
||||
|
||||
private HarvesterMessageBuilder messageBuilder;
|
||||
private InstallationMessageBuilder installationMessageBuilder;
|
||||
|
||||
public final static byte HARVESTER_TYPE_MINERAL = 0;
|
||||
public final static byte HARVESTER_TYPE_CHEMICAL = 1;
|
||||
public final static byte HARVESTER_TYPE_FLORA = 2;
|
||||
public final static byte HARVESTER_TYPE_GAS = 3;
|
||||
public final static byte HARVESTER_TYPE_WATER = 4;
|
||||
public final static byte HARVESTER_TYPE_SOLAR = 5;
|
||||
public final static byte HARVESTER_TYPE_WIND = 6;
|
||||
public final static byte HARVESTER_TYPE_FUSION = 7;
|
||||
public final static byte HARVESTER_TYPE_GEO = 8;
|
||||
|
||||
public String[] mineral_type_iff = new String[]{"object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff",
|
||||
"object/installation/mining_ore/shared_mining_ore_harvester_style_2.iff",
|
||||
"object/installation/mining_ore/shared_mining_ore_harvester_heavy.iff",
|
||||
"object/installation/mining_ore/shared_mining_ore_harvester_elite.iff"};
|
||||
|
||||
public String[] chemical_type_iff = new String[]{"object/installation/mining_liquid/shared_mining_liquid_harvester_style_1.iff",
|
||||
"object/installation/mining_liquid/shared_mining_liquid_harvester_style_2.iff",
|
||||
"object/installation/mining_liquid/shared_mining_liquid_harvester_style_3.iff",
|
||||
"object/installation/mining_liquid/shared_mining_liquid_harvester_style_4.iff"};
|
||||
|
||||
public String[] flora_type_iff = new String[]{"object/installation/mining_organic/shared_mining_organic_flora_farm.iff",
|
||||
"object/installation/mining_organic/shared_mining_organic_flora_farm_medium.iff",
|
||||
"object/installation/mining_organic/shared_mining_organic_flora_farm_heavy.iff",
|
||||
"object/installation/mining_organic/shared_mining_organic_flora_farm_elite.iff"};
|
||||
|
||||
public String[] water_type_iff = new String[]{"object/installation/mining_liquid/shared_mining_liquid_moisture_harvester.iff",
|
||||
"object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_medium.iff",
|
||||
"object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_heavy.iff",
|
||||
"object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_elite.iff"};
|
||||
|
||||
public String[] gas_type_iff = new String[]{"object/installation/mining_gas/shared_mining_gas_harvester_style_1.iff",
|
||||
"object/installation/mining_gas/shared_mining_gas_harvester_style_2.iff",
|
||||
"object/installation/mining_gas/shared_mining_gas_harvester_style_3.iff",
|
||||
"object/installation/mining_gas/shared_mining_gas_harvester_style_4.iff"};
|
||||
|
||||
public String[] wind_type_iff = new String[]{"object/installation/generators/shared_power_generator_wind_style_1.iff"};
|
||||
|
||||
public String[] solar_type_iff = new String[]{"object/installation/generators/shared_power_generator_solar_style_1.iff"};
|
||||
|
||||
public String[] fusion_type_iff = new String[]{"object/installation/generators/shared_power_generator_fusion_style_1.iff"};
|
||||
|
||||
public String[] geo_type_iff = new String[]{"object/installation/generators/shared_power_generator_geothermal_style_1.iff"};
|
||||
|
||||
//for nothing "object/installation/generators/shared_power_generator_photo_bio_style_1.iff"
|
||||
|
||||
|
||||
public byte harvester_type = 0;
|
||||
public byte harvester_size = 0;
|
||||
private Vector<ResourceContainerObject> outputHopperContent = new Vector<ResourceContainerObject>();
|
||||
private int outputHopperCapacity = 0;
|
||||
private int BER = 0;
|
||||
private float maintenanceAmount = 0;
|
||||
private float powerLevel = 0;
|
||||
private int powerCost = 0;
|
||||
private int maintenanceCost = 0;
|
||||
private byte structuralCondition = 100;
|
||||
private boolean activated = false;
|
||||
private boolean generator = false;
|
||||
private GalacticResource selectedHarvestResource;
|
||||
private float selectedResourceConcentration;
|
||||
private byte updateCount;
|
||||
private byte resourceUpdateCount;
|
||||
private Vector<String> adminList = new Vector<String>();
|
||||
private Vector<String> hopperList = new Vector<String>();
|
||||
private long owner;
|
||||
private float currentHarvestedCountFloat=0.0F;
|
||||
private String deedTemplate;
|
||||
|
||||
private int specRate;
|
||||
|
||||
|
||||
public HarvesterObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
this.setConditionDamage(100);
|
||||
messageBuilder = new HarvesterMessageBuilder(this);
|
||||
installationMessageBuilder = new InstallationMessageBuilder((InstallationObject)this);
|
||||
}
|
||||
|
||||
public int getBER() {
|
||||
return BER;
|
||||
}
|
||||
|
||||
|
||||
public void setBER(int baseExtractionRate) {
|
||||
this.BER = baseExtractionRate;
|
||||
}
|
||||
|
||||
|
||||
public float getActualExtractionRate() {
|
||||
//float resourceDraw = (getBER() * getSelectedResourceConcentration()) / 400; // /100
|
||||
float resourceDraw = 1.5F*(getBER() * getSelectedResourceConcentration()) / 100;
|
||||
// BER * concentration * publish 27 bonus * profession buffs = AER
|
||||
// 14* 0.83 * 1.5 * 1.05 = 18.3015 AER
|
||||
return resourceDraw;
|
||||
}
|
||||
|
||||
public int getSpecRate() {
|
||||
return specRate;
|
||||
}
|
||||
|
||||
public void setSpecRate(int specRate) {
|
||||
this.specRate = specRate;
|
||||
}
|
||||
|
||||
|
||||
public GalacticResource getSelectedHarvestResource() {
|
||||
return selectedHarvestResource;
|
||||
}
|
||||
|
||||
|
||||
public void setSelectedHarvestResource(GalacticResource selectedHarvestResource,CreatureObject owner) {
|
||||
this.selectedHarvestResource = selectedHarvestResource;
|
||||
setSelectedResourceConcentration(selectedHarvestResource.deliverConcentrationForSurvey(this.getPlanetId(), this.getPosition().x, this.getPosition().z));
|
||||
|
||||
owner.getClient().getSession().write(installationMessageBuilder.constructINSO7Var1((InstallationObject) this,selectedHarvestResource.getObjectId()));
|
||||
owner.getClient().getSession().write(installationMessageBuilder.constructINSO7Var2((InstallationObject) this,selectedHarvestResource.getObjectId()));
|
||||
}
|
||||
|
||||
|
||||
public float getSelectedResourceConcentration() {
|
||||
return selectedResourceConcentration;
|
||||
}
|
||||
|
||||
|
||||
private void setSelectedResourceConcentration(float selectedResourceConcentration) {
|
||||
this.selectedResourceConcentration = selectedResourceConcentration;
|
||||
}
|
||||
|
||||
|
||||
public void activateHarvester(CreatureObject owner){
|
||||
activated = true;
|
||||
this.setOwner(owner.getObjectID());
|
||||
owner.getClient().getSession().write(messageBuilder.buildHINO3Delta(this,(byte)1));
|
||||
owner.getClient().getSession().write(messageBuilder.buildHINO7ActivateDelta2(this));
|
||||
}
|
||||
|
||||
|
||||
public void deactivateHarvester(CreatureObject owner){
|
||||
activated = false;
|
||||
owner.getClient().getSession().write(messageBuilder.buildHINO3Delta2(this,(byte)0));
|
||||
owner.getClient().getSession().write(messageBuilder.buildHINO7DeactivateDelta(this));
|
||||
}
|
||||
|
||||
|
||||
public boolean isActivated(){
|
||||
return this.activated;
|
||||
}
|
||||
|
||||
|
||||
public byte getHarvester_type() {
|
||||
return harvester_type;
|
||||
}
|
||||
|
||||
|
||||
public void setHarvester_type(byte harvester_type) {
|
||||
this.harvester_type = harvester_type;
|
||||
}
|
||||
|
||||
|
||||
public Vector<ResourceContainerObject> getOutputHopperContent() {
|
||||
return outputHopperContent;
|
||||
}
|
||||
|
||||
|
||||
public void setOutputHopperContent(Vector<ResourceContainerObject> outputHopperContent) {
|
||||
this.outputHopperContent = outputHopperContent;
|
||||
}
|
||||
|
||||
|
||||
public byte getStructuralCondition() {
|
||||
return structuralCondition;
|
||||
}
|
||||
|
||||
|
||||
public void setStructuralCondition(byte structuralCondition) {
|
||||
this.structuralCondition = structuralCondition;
|
||||
}
|
||||
|
||||
|
||||
public int getOutputHopperCapacity() {
|
||||
return outputHopperCapacity;
|
||||
}
|
||||
|
||||
|
||||
public void setOutputHopperCapacity(int outputHopperCapacity) {
|
||||
this.outputHopperCapacity = outputHopperCapacity;
|
||||
}
|
||||
|
||||
|
||||
public byte getUpdateCount() {
|
||||
if (updateCount>254) updateCount = 0;
|
||||
return updateCount++;
|
||||
}
|
||||
|
||||
public byte getResourceUpdateCount() {
|
||||
if (resourceUpdateCount>254) resourceUpdateCount = 0;
|
||||
return resourceUpdateCount++;
|
||||
}
|
||||
|
||||
|
||||
public void setUpdateCount(byte updateCount) {
|
||||
this.updateCount = updateCount;
|
||||
}
|
||||
|
||||
|
||||
public Vector<String> getAdminList() {
|
||||
return adminList;
|
||||
}
|
||||
|
||||
|
||||
public void setAdminList(Vector<String> adminList) {
|
||||
this.adminList = adminList;
|
||||
}
|
||||
|
||||
|
||||
public Vector<String> getHopperList() {
|
||||
return hopperList;
|
||||
}
|
||||
|
||||
|
||||
public void setHopperList(Vector<String> hopperList) {
|
||||
this.hopperList = hopperList;
|
||||
}
|
||||
|
||||
|
||||
public float getPowerLevel() {
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
|
||||
public void setPowerLevel(float energyLevel) {
|
||||
this.powerLevel = energyLevel;
|
||||
}
|
||||
|
||||
|
||||
public float getMaintenanceAmount() {
|
||||
return maintenanceAmount;
|
||||
}
|
||||
|
||||
|
||||
public void setMaintenanceAmount(float maintenanceAmount) {
|
||||
this.maintenanceAmount = maintenanceAmount;
|
||||
}
|
||||
|
||||
public int getPowerCost() {
|
||||
return powerCost;
|
||||
}
|
||||
|
||||
|
||||
public void setPowerCost(int powerCost) {
|
||||
this.powerCost = powerCost;
|
||||
}
|
||||
|
||||
|
||||
public int getMaintenanceCost() {
|
||||
return maintenanceCost;
|
||||
}
|
||||
|
||||
|
||||
public void setMaintenanceCost(int maintenanceCost) {
|
||||
this.maintenanceCost = maintenanceCost;
|
||||
}
|
||||
|
||||
|
||||
public float getCurrentHarvestedCountFloat() {
|
||||
return currentHarvestedCountFloat;
|
||||
}
|
||||
|
||||
|
||||
public void setCurrentHarvestedCountFloat(float currentHarvestedCountFloat) {
|
||||
this.currentHarvestedCountFloat = currentHarvestedCountFloat;
|
||||
}
|
||||
|
||||
|
||||
public long getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
|
||||
public void setOwner(long owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public void setDeedTemplate(String deedTemplate){
|
||||
this.deedTemplate = deedTemplate;
|
||||
}
|
||||
|
||||
public String getDeedTemplate(){
|
||||
return this.deedTemplate;
|
||||
}
|
||||
|
||||
|
||||
public boolean isGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public void setGenerator(boolean generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
|
||||
public void setHarvesterName(String name,CreatureObject owner){
|
||||
owner.getClient().getSession().write(messageBuilder.buildCustomNameDelta(this,name));
|
||||
this.setCustomName(name);
|
||||
((CreatureObject)owner).sendSystemMessage("Structure renamed.", (byte) 0);
|
||||
}
|
||||
|
||||
public void setPermissionAdmin(String name,CreatureObject owner){
|
||||
Vector<String> permissionList = this.getAdminList();
|
||||
owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(this, permissionList, name));
|
||||
}
|
||||
|
||||
public void setPermissionHopper(String name,CreatureObject owner){
|
||||
Vector<String> permissionList = this.getAdminList();
|
||||
owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(this, permissionList, name));
|
||||
}
|
||||
|
||||
public void operateMachinery(CreatureObject owner){
|
||||
owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this));
|
||||
// Assemble resources at that spot
|
||||
// For later, it might be needed to also pass the template to differentiate liquid resources
|
||||
Vector<GalacticResource> planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type());
|
||||
owner.getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, owner, planetResourcesVector));
|
||||
owner.getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector));
|
||||
}
|
||||
|
||||
public void deActivate(){
|
||||
NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this));
|
||||
}
|
||||
|
||||
public void placeHarvester(){
|
||||
NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this));
|
||||
}
|
||||
|
||||
public void createNewHopperContainer(){
|
||||
Vector<GalacticResource> planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type());
|
||||
NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector));
|
||||
NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINO7Delta(this,(byte)1));
|
||||
}
|
||||
|
||||
public void continueHopperContainer(){
|
||||
Vector<GalacticResource> planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type());
|
||||
NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, NGECore.getInstance().objectService.getObject(owner), planetResourcesVector));
|
||||
NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
|
||||
if(destination == null || destination.getSession() == null) {
|
||||
System.out.println("NULL destination");
|
||||
return;
|
||||
}
|
||||
|
||||
destination.getSession().write(installationMessageBuilder.buildBaseline3(this));
|
||||
//destination.getSession().write(installationMessageBuilder.buildBaseline6(this));
|
||||
//destination.getSession().write(installationMessageBuilder.buildBaseline8());
|
||||
//destination.getSession().write(installationMessageBuilder.buildBaseline9());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,205 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.installation;
|
||||
|
||||
public class InstallationMessageBuilder {
|
||||
import java.nio.ByteOrder;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
public class InstallationMessageBuilder extends ObjectMessageBuilder{
|
||||
|
||||
public InstallationMessageBuilder(InstallationObject installationObject) {
|
||||
setObject(installationObject);
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline3(InstallationObject installationObject) {
|
||||
IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
int packSize = 66;
|
||||
packSize += installationObject.getStfName().length();
|
||||
packSize += installationObject.getStfFilename().length();
|
||||
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x68A75F0C);
|
||||
buffer.putLong(installationObject.getObjectID());
|
||||
buffer.putInt(0x494E534F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(packSize);
|
||||
buffer.putShort((short) 0x05);
|
||||
buffer.putFloat(installationObject.getComplexity());
|
||||
buffer.put(getAsciiString(installationObject.getStfFilename())); // installation_n
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(installationObject.getStfName()));
|
||||
buffer.put(getUnicodeString(""));//buffer.put(getUnicodeString(installationObject.getCustomName()));
|
||||
buffer.putInt(1);// int 1 // oper 3
|
||||
buffer.putShort((short)0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putLong(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.put((byte)1);
|
||||
buffer.put((byte)0);
|
||||
buffer.putFloat(0.0F);
|
||||
buffer.putFloat(0.0F);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
// 0000: 05 00 0C 5F A7 68 82 EC 7D 16 00 00 02 00 4F 53 ..._.h..}.....OS
|
||||
// 0010: 4E 49 06 0E 00 00 00 05 00 76 00 00 00 00 00 00 NI.......v......
|
||||
// 0020: 00 01 00 00 00 .....
|
||||
|
||||
public IoBuffer buildBaseline6(InstallationObject installationObject) {
|
||||
IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
int packSize = 14;
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x68A75F0C);
|
||||
buffer.putLong(installationObject.getObjectID());
|
||||
buffer.putInt(0x494E534F);
|
||||
buffer.put((byte)6);
|
||||
buffer.putInt(packSize);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x76);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(1);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline7() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putShort((short) 0);
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("INSO", (byte) 7, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline8() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putShort((short) 0);
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("INSO", (byte) 8, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildBaseline9() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.putShort((short) 0);
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
buffer.flip();
|
||||
buffer = createBaseline("INSO", (byte) 9, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDelta3(InstallationObject installationObject,IoBuffer packet,int packSize) {
|
||||
IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(installationObject.getObjectID());
|
||||
buffer.putInt(0x494E534F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(packSize);
|
||||
buffer.put(packet);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildDelta7(InstallationObject installationObject,IoBuffer packet,int packSize) {
|
||||
IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(installationObject.getObjectID());
|
||||
buffer.putInt(0x494E534F);
|
||||
buffer.put((byte)7);
|
||||
buffer.putInt(packSize);
|
||||
buffer.put(packet);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer constructINSO7Var1(InstallationObject installationObject,long selectedResource) {
|
||||
IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
int hopperContentsSize = ((HarvesterObject)installationObject).getOutputHopperContent().size()+1;
|
||||
byte updateCounter = ((HarvesterObject)installationObject).getUpdateCount();
|
||||
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)2); // buffer.putShort((short)updateCounter);
|
||||
buffer.putShort((short)0xC);
|
||||
buffer.put((byte)1);
|
||||
buffer.putShort((short)0xD);
|
||||
|
||||
buffer.putInt(1);//buffer.putInt(hopperContentsSize); // works once with 1! HopperContentsSize->Number of resources in hopper
|
||||
buffer.putInt(2); // UpdateCounter works once with 2!
|
||||
buffer.put((byte)1); // subtype : ADD
|
||||
buffer.putShort((short)0); // index was 0 buffer.putShort((short)(hopperContentsSize-1));
|
||||
buffer.putLong(selectedResource);
|
||||
buffer.putFloat(0);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
return buildDelta7(installationObject,IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(),size);
|
||||
}
|
||||
|
||||
// 0000: 05 00 53 21 86 12 82 EC 7D 16 00 00 02 00 4F 53 ..S!....}.....OS
|
||||
// 0010: 4E 49 07 1E 00 00 00 02 00 0C 00 01 0D 00 01 00 NI..............
|
||||
// 0020: 00 00 02 00 00 00 01 00 00 8A D3 79 16 00 00 0F ...........y....
|
||||
// 0030: 00 00 00 00 00 .....
|
||||
|
||||
public IoBuffer constructINSO7Var2(InstallationObject installationObject,long selectedResource) {
|
||||
IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)2);
|
||||
buffer.putShort((short)0x9);
|
||||
buffer.putFloat(0);
|
||||
buffer.putShort((short)0x5);
|
||||
buffer.putLong(selectedResource);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
return buildDelta7(installationObject,IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(),size);
|
||||
}
|
||||
|
||||
// 0000: 05 00 53 21 86 12 82 EC 7D 16 00 00 02 00 4F 53 ..S!....}.....OS
|
||||
// 0010: 4E 49 07 12 00 00 00 02 00 09 00 00 00 00 00 05 NI..............
|
||||
// 0020: 00 8A D3 79 16 00 00 0F 00 ...y.....
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,23 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.installation;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
@Persistent(version=0)
|
||||
@Entity(version=0)
|
||||
public class InstallationObject extends TangibleObject {
|
||||
|
||||
}
|
||||
|
||||
public InstallationObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.loot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LootDrop {
|
||||
|
||||
private List<String> elements = new ArrayList<String>();
|
||||
private String droppedItemTemplate;
|
||||
|
||||
public LootDrop(){
|
||||
|
||||
}
|
||||
|
||||
public void addElement(String element){
|
||||
elements.add(element);
|
||||
}
|
||||
|
||||
public List<String> getElements(){
|
||||
return elements;
|
||||
}
|
||||
|
||||
public String getDroppedItemTemplate() {
|
||||
return droppedItemTemplate;
|
||||
}
|
||||
|
||||
public void setDroppedItemTemplate(String droppedItemTemplate) {
|
||||
this.droppedItemTemplate = droppedItemTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.loot;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class LootGroup {
|
||||
|
||||
private String[] lootPoolNames;
|
||||
private int[] lootPoolChances;
|
||||
private int lootGroupChance;
|
||||
|
||||
public LootGroup(){
|
||||
|
||||
}
|
||||
|
||||
public LootGroup(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance){
|
||||
this.lootPoolNames = lootPoolNames;
|
||||
this.lootPoolChances = lootPoolChances;
|
||||
this.lootGroupChance = lootGroupChance;
|
||||
}
|
||||
|
||||
public void addLootData(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance){
|
||||
this.lootPoolNames = lootPoolNames;
|
||||
this.lootPoolChances = lootPoolChances;
|
||||
this.lootGroupChance = lootGroupChance;
|
||||
}
|
||||
|
||||
public String[] getLootPoolNames() {
|
||||
return lootPoolNames;
|
||||
}
|
||||
|
||||
public int[] getLootPoolChances() {
|
||||
return lootPoolChances;
|
||||
}
|
||||
|
||||
public int getLootGroupChance() {
|
||||
return lootGroupChance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.loot;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
public class LootPool {
|
||||
|
||||
public LootPool(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.loot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import main.NGECore;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
public class LootRollSession {
|
||||
|
||||
private String SessionID; // leaderName-SystemTime
|
||||
private boolean sessionValid;
|
||||
private GroupObject playerGroup;
|
||||
private CreatureObject requester;
|
||||
private List<TangibleObject> droppedItems;
|
||||
private Planet sessionPlanet;
|
||||
private List<String> errorMessages;
|
||||
private int sessionLootMode;
|
||||
private boolean allowRareLoot;
|
||||
private boolean increasedRLSChance;
|
||||
|
||||
public LootRollSession(){
|
||||
}
|
||||
|
||||
public LootRollSession(CreatureObject requester, TangibleObject lootedObject){
|
||||
long requesterGroupId = requester.getGroupId();
|
||||
if (requesterGroupId>0){
|
||||
this.playerGroup = (GroupObject) NGECore.getInstance().objectService.getObject(requesterGroupId);
|
||||
this.SessionID = playerGroup.getGroupLeader().getCustomName()+"-"+System.currentTimeMillis();
|
||||
|
||||
} else {
|
||||
this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (lootedObject instanceof CreatureObject){
|
||||
CreatureObject lootedCreature = (CreatureObject)lootedObject;
|
||||
// Exclude rare loot depending on creature level
|
||||
// For groups maybe average CL?
|
||||
if (requester.getLevel()-lootedCreature.getLevel()<=6){
|
||||
this.setAllowRareLoot(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Group situation
|
||||
if (this.getPlayerGroup()!=null){
|
||||
if (this.getPlayerGroup().getMemberList().size()>=4)
|
||||
this.setIncreasedRLSChance(true);
|
||||
}
|
||||
|
||||
// Possible AFKer check here
|
||||
|
||||
|
||||
droppedItems = new ArrayList<TangibleObject>();
|
||||
errorMessages = new ArrayList<String>();
|
||||
sessionPlanet = requester.getPlanet();
|
||||
this.requester = requester;
|
||||
allowRareLoot = false;
|
||||
}
|
||||
|
||||
public List<TangibleObject> getDroppedItems() {
|
||||
return droppedItems;
|
||||
}
|
||||
|
||||
public void addDroppedItem(TangibleObject droppedItem) {
|
||||
this.droppedItems.add(droppedItem);
|
||||
}
|
||||
|
||||
public String getSessionID() {
|
||||
return SessionID;
|
||||
}
|
||||
|
||||
public void setSessionID(String sessionID) {
|
||||
SessionID = sessionID;
|
||||
}
|
||||
|
||||
public void generateSessionID(String sessionID) {
|
||||
SessionID = sessionID;
|
||||
}
|
||||
|
||||
public Planet getSessionPlanet() {
|
||||
return sessionPlanet;
|
||||
}
|
||||
|
||||
public List<String> getErrorMessages() {
|
||||
return errorMessages;
|
||||
}
|
||||
|
||||
public void addErrorMessage(String errorMessage) {
|
||||
this.errorMessages.add(errorMessage);
|
||||
}
|
||||
|
||||
public int getSessionLootMode() {
|
||||
return sessionLootMode;
|
||||
}
|
||||
|
||||
public void setSessionLootMode(int sessionLootMode) {
|
||||
this.sessionLootMode = sessionLootMode;
|
||||
}
|
||||
|
||||
public boolean isAllowRareLoot() {
|
||||
return allowRareLoot;
|
||||
}
|
||||
|
||||
public void setAllowRareLoot(boolean allowRareLoot) {
|
||||
this.allowRareLoot = allowRareLoot;
|
||||
}
|
||||
|
||||
public GroupObject getPlayerGroup() {
|
||||
return playerGroup;
|
||||
}
|
||||
|
||||
public boolean isIncreasedRLSChance() {
|
||||
return increasedRLSChance;
|
||||
}
|
||||
|
||||
public void setIncreasedRLSChance(boolean increasedRLSChance) {
|
||||
this.increasedRLSChance = increasedRLSChance;
|
||||
}
|
||||
|
||||
public boolean isSessionValid() {
|
||||
return sessionValid;
|
||||
}
|
||||
|
||||
public void setSessionValid(boolean sessionValid) {
|
||||
this.sessionValid = sessionValid;
|
||||
}
|
||||
|
||||
public CreatureObject getRequester() {
|
||||
return requester;
|
||||
}
|
||||
|
||||
public void setRequester(CreatureObject requester) {
|
||||
this.requester = requester;
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,27 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.manufacture;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ManufactureSchematicObject extends IntangibleObject {
|
||||
public class ManufactureSchematicObject extends IntangibleObject{
|
||||
|
||||
//@NotPersistent
|
||||
//private ManufactureSchematicMessageBuilder messageBuilder;
|
||||
|
||||
public ManufactureSchematicObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) {
|
||||
super(objectID, planet, position, orientation, template);
|
||||
//messageBuilder = new ManufactureSchematicMessageBuilder(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.common.CRC;
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
|
||||
@@ -69,7 +68,7 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
else
|
||||
buffer.put(getAsciiString(player.getTitle()));
|
||||
|
||||
buffer.putInt(0); // born date?
|
||||
buffer.putInt(0); // born date - Needs to be in yyymmdd format - Stored as epoch time of character create
|
||||
|
||||
buffer.putInt(player.getTotalPlayTime()); // total play time?
|
||||
|
||||
@@ -85,8 +84,8 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.put(player.getCollections());
|
||||
buffer.putInt(0); // Unknown, part of one delta, maybe a list
|
||||
buffer.putInt(0); // Unknown, part of one delta, maybe a list
|
||||
buffer.put((byte) 0); // Unknown Boolean used in Tansarii
|
||||
buffer.put((byte) 0); // Unknown Boolean used in Tansarii
|
||||
buffer.put((byte) ((player.isShowBackpack()) ? 1 : 0));
|
||||
buffer.put((byte) ((player.isShowHelmet()) ? 1 : 0));
|
||||
|
||||
int size = buffer.position();
|
||||
|
||||
@@ -108,12 +107,10 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short) 0x11);
|
||||
buffer.putInt((short) 0x43);
|
||||
|
||||
buffer.put(getAsciiString("string_id_table"));
|
||||
|
||||
buffer.put((byte) 0); // unk
|
||||
buffer.putShort((short) 0); // unk
|
||||
buffer.putInt(0); // unk
|
||||
buffer.putInt(0); // probably stringId
|
||||
buffer.putShort((short) 0); // detailedDescription
|
||||
buffer.put(player.getGodLevel());
|
||||
buffer.putInt(0); // unk
|
||||
buffer.putInt(0); // unk
|
||||
buffer.putInt(0); // unk
|
||||
@@ -200,8 +197,8 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
buffer.putInt(100); // Current force power ?
|
||||
buffer.putInt(100); // Max force power ?
|
||||
buffer.putInt(0); // Current force power ?
|
||||
buffer.putInt(0); // Max force power ?
|
||||
buffer.putInt(0); // Current FS Quest List size ?
|
||||
buffer.putInt(0); // Current FS Quest List update counter ?
|
||||
|
||||
@@ -292,18 +289,6 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(3);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(2);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
@@ -314,7 +299,19 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(4); // jedi state???
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(0); // jedi state???
|
||||
buffer.putShort((short) 0);
|
||||
int size = buffer.position();
|
||||
|
||||
@@ -362,24 +359,31 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
PlayerObject player = (PlayerObject) object;
|
||||
player.setXpListUpdateCounter(player.getXpListUpdateCounter() + 1);
|
||||
|
||||
// Some problem with createDelta()
|
||||
IoBuffer result = bufferPool.allocate(42 + type.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
result.putShort((short) 5);
|
||||
result.putInt(CRC.StringtoCRC("BaselinesMessage"));
|
||||
result.putLong(object.getContainer().getObjectID());
|
||||
result.put("YALP".getBytes());
|
||||
result.put((byte) 8);
|
||||
result.putInt(19 + type.length());
|
||||
result.putShort((short) 1);
|
||||
result.putShort((short) 0);
|
||||
IoBuffer result = bufferPool.allocate(15 + type.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
result.putInt(1);
|
||||
result.putInt(player.getXpListUpdateCounter());
|
||||
result.put((byte) ((alreadyExists) ? 2 : 0));
|
||||
result.putShort((short) type.length());
|
||||
result.put(type.getBytes());
|
||||
result.put(getAsciiString(type));
|
||||
result.putInt(amount);
|
||||
|
||||
return result.flip();
|
||||
int size = result.position();
|
||||
result.flip();
|
||||
result = createDelta("PLAY", (byte) 8, (short) 1, (short) 0, result, size + 4);
|
||||
return result;
|
||||
}
|
||||
|
||||
public IoBuffer buildProfessionWheelPositionDelta(String professionWheelPosition) {
|
||||
IoBuffer buffer = bufferPool.allocate(2 + professionWheelPosition.length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(professionWheelPosition));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 8, buffer, size + 4);
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildWaypointAddDelta(WaypointObject waypoint) {
|
||||
@@ -625,6 +629,40 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildShowBackpackDelta(boolean showBackpack) {
|
||||
IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put((byte) (showBackpack ? 1 : 0));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 18, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildShowHelmetDelta(boolean showHelmet) {
|
||||
IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put((byte) (showHelmet ? 1 : 0));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 19, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildGodLevelDelta(byte godLevel) {
|
||||
IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put(godLevel);
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("PLAY", (byte) 6, (short) 1, (short) 0x02, buffer, size + 4);
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -29,7 +29,10 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
import resources.objects.resource.ResourceContainerObject;
|
||||
import resources.objects.tool.SurveyTool;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -41,7 +44,7 @@ import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=3)
|
||||
@Persistent(version=13)
|
||||
public class PlayerObject extends IntangibleObject {
|
||||
|
||||
// PLAY 3
|
||||
@@ -52,11 +55,13 @@ public class PlayerObject extends IntangibleObject {
|
||||
private List<Integer> flagsList = new ArrayList<Integer>();
|
||||
private List<Integer> profileList = new ArrayList<Integer>();
|
||||
private List<String> titleList = new ArrayList<String>();
|
||||
private int bornDate = 0;
|
||||
private long bornDate = 0;
|
||||
private int totalPlayTime = 0;
|
||||
private byte[] collections = new byte[] { };
|
||||
private int highestSetBit = 0;
|
||||
private int flagBitmask = 0;
|
||||
private boolean showHelmet = true;
|
||||
private boolean showBackpack = true;
|
||||
|
||||
// PLAY 6
|
||||
|
||||
@@ -116,6 +121,13 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
private int jediState = 0; // unused in NGE
|
||||
|
||||
private String biography = "";
|
||||
private String spouse;
|
||||
private String holoEmote;
|
||||
private int holoEmoteUses;
|
||||
|
||||
private int lotsRemaining = 10;
|
||||
|
||||
@NotPersistent
|
||||
private PlayerMessageBuilder messageBuilder;
|
||||
|
||||
@@ -124,6 +136,17 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
private Map<String, Integer> factionStandingMap = new TreeMap<String, Integer>();
|
||||
|
||||
private WaypointObject lastSurveyWaypoint;
|
||||
private SurveyTool lastUsedSurveyTool;
|
||||
private ResourceContainerObject recentContainer;
|
||||
|
||||
private byte godLevel = 0;
|
||||
|
||||
private List<Integer> chatChannels = new ArrayList<Integer>();
|
||||
|
||||
@NotPersistent
|
||||
private boolean callingCompanion = false;
|
||||
|
||||
public PlayerObject() {
|
||||
super();
|
||||
messageBuilder = new PlayerMessageBuilder(this);
|
||||
@@ -173,13 +196,13 @@ public class PlayerObject extends IntangibleObject {
|
||||
return profileList;
|
||||
}
|
||||
|
||||
public int getBornDate() {
|
||||
public long getBornDate() {
|
||||
synchronized(objectMutex) {
|
||||
return bornDate;
|
||||
}
|
||||
}
|
||||
|
||||
public void setBornDate(int bornDate) {
|
||||
public void setBornDate(long bornDate) {
|
||||
synchronized(objectMutex) {
|
||||
this.bornDate = bornDate;
|
||||
}
|
||||
@@ -195,7 +218,8 @@ public class PlayerObject extends IntangibleObject {
|
||||
synchronized(objectMutex) {
|
||||
this.totalPlayTime = totalPlayTime;
|
||||
}
|
||||
notifyObservers(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime), true);
|
||||
//notifyObservers(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime), true);
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime));
|
||||
}
|
||||
|
||||
public String getHome() {
|
||||
@@ -227,11 +251,15 @@ public class PlayerObject extends IntangibleObject {
|
||||
synchronized(objectMutex) {
|
||||
xpExists = xpList.containsKey(type);
|
||||
xpList.put(type, amount);
|
||||
//Console.println("Put " + type + " exp of " + amount + " in the map.");
|
||||
//Console.println("Map is now: " + xpList.get(type).intValue());
|
||||
}
|
||||
|
||||
if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildXPListDelta(type, amount, xpExists));
|
||||
((CreatureObject) getContainer()).setXpBarValue(amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getXpListUpdateCounter() {
|
||||
@@ -341,6 +369,9 @@ public class PlayerObject extends IntangibleObject {
|
||||
synchronized(objectMutex) {
|
||||
this.professionWheelPosition = professionWheelPosition;
|
||||
}
|
||||
if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildProfessionWheelPositionDelta(professionWheelPosition));
|
||||
}
|
||||
}
|
||||
|
||||
public int getExperimentationFlag() {
|
||||
@@ -596,13 +627,12 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
if(destination == null || destination.getSession() == null)
|
||||
return;
|
||||
|
||||
//if(destination.getParent().getObjectID() == getParentId()) { // only send to self
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
if(destination.getParent().getObjectID() == getParentId()) { // only send to self
|
||||
destination.getSession().write(messageBuilder.buildBaseline8());
|
||||
destination.getSession().write(messageBuilder.buildBaseline9());
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -664,6 +694,28 @@ public class PlayerObject extends IntangibleObject {
|
||||
}
|
||||
}
|
||||
|
||||
public String getBiography() {
|
||||
return biography;
|
||||
}
|
||||
|
||||
public void setBiography(String biography) {
|
||||
synchronized(objectMutex) {
|
||||
this.biography = biography;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSpouseName() {
|
||||
synchronized(objectMutex) {
|
||||
return spouse;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSpouseName(String spouse) {
|
||||
synchronized(objectMutex) {
|
||||
this.spouse = spouse;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFlagBitmask() {
|
||||
synchronized(objectMutex) {
|
||||
return flagBitmask;
|
||||
@@ -706,5 +758,145 @@ public class PlayerObject extends IntangibleObject {
|
||||
return ((flagBitmask & flags) == flags);
|
||||
}
|
||||
}
|
||||
|
||||
public String getHoloEmote() {
|
||||
return holoEmote;
|
||||
}
|
||||
|
||||
public void setHoloEmote(String holoEmote) {
|
||||
this.holoEmote = holoEmote;
|
||||
}
|
||||
|
||||
public int getHoloEmoteUses() {
|
||||
return holoEmoteUses;
|
||||
}
|
||||
|
||||
public void setHoloEmoteUses(int holoEmoteUses) {
|
||||
this.holoEmoteUses = holoEmoteUses;
|
||||
}
|
||||
|
||||
public boolean isShowHelmet() {
|
||||
return showHelmet;
|
||||
}
|
||||
|
||||
public void setShowHelmet(boolean showHelmet) {
|
||||
synchronized(objectMutex) {
|
||||
this.showHelmet = showHelmet;
|
||||
}
|
||||
|
||||
if (getContainer() != null) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildShowHelmetDelta(showHelmet));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isShowBackpack() {
|
||||
return showBackpack;
|
||||
}
|
||||
|
||||
public void setShowBackpack(boolean showBackpack) {
|
||||
synchronized(objectMutex) {
|
||||
this.showBackpack = showBackpack;
|
||||
}
|
||||
|
||||
if (getContainer() != null) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildShowBackpackDelta(showBackpack));
|
||||
}
|
||||
}
|
||||
|
||||
public WaypointObject getLastSurveyWaypoint() {
|
||||
return lastSurveyWaypoint;
|
||||
}
|
||||
|
||||
public void setLastSurveyWaypoint(WaypointObject lastSurveyWaypoint) {
|
||||
this.lastSurveyWaypoint = lastSurveyWaypoint;
|
||||
}
|
||||
|
||||
public SurveyTool getLastUsedSurveyTool() {
|
||||
synchronized(objectMutex) {
|
||||
return this.lastUsedSurveyTool;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLastUsedSurveyTool(SurveyTool surveyTool) {
|
||||
synchronized(objectMutex) {
|
||||
this.lastUsedSurveyTool = surveyTool;
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceContainerObject getRecentContainer() {
|
||||
return recentContainer;
|
||||
}
|
||||
|
||||
public void setRecentContainer(ResourceContainerObject recentContainer) {
|
||||
this.recentContainer = recentContainer;
|
||||
}
|
||||
|
||||
public void setLotsRemaining(int amount)
|
||||
{
|
||||
this.lotsRemaining = amount;
|
||||
}
|
||||
|
||||
public boolean addLots(int amount)
|
||||
{
|
||||
this.lotsRemaining += amount;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean deductLots(int amount)
|
||||
{
|
||||
if(this.lotsRemaining - amount >= 0)
|
||||
{
|
||||
this.lotsRemaining -= amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getLotsRemaining()
|
||||
{
|
||||
return this.lotsRemaining;
|
||||
}
|
||||
|
||||
public byte getGodLevel() {
|
||||
return godLevel;
|
||||
}
|
||||
|
||||
public void setGodLevel(int godLevel) {
|
||||
this.godLevel = (byte) godLevel;
|
||||
|
||||
if (getContainer() != null) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildGodLevelDelta((byte) godLevel));
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getJoinedChatChannels() {
|
||||
return chatChannels;
|
||||
}
|
||||
|
||||
public void addChannel(int roomId) {
|
||||
chatChannels.add(roomId);
|
||||
}
|
||||
|
||||
public void removeChannel(int roomId) {
|
||||
if (chatChannels.contains(roomId))
|
||||
chatChannels.remove(roomId);
|
||||
}
|
||||
|
||||
public boolean isMemberOfChannel(int roomId) {
|
||||
if (chatChannels.contains(roomId)) {
|
||||
System.out.println("Member of the channel!");
|
||||
return true;
|
||||
}
|
||||
System.out.println("Not a Member of the channel!");
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isCallingCompanion() {
|
||||
return callingCompanion;
|
||||
}
|
||||
|
||||
public void setCallingCompanion(boolean callingCompanion) {
|
||||
this.callingCompanion = callingCompanion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,683 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
import protocol.swg.SurveyMapUpdateMessage;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Entity(version=0)
|
||||
public class GalacticResource extends SWGObject implements IPersistent {
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
private String name;
|
||||
private String fileName;
|
||||
private String category;
|
||||
private Long id; // use server highest
|
||||
|
||||
private long spawnTime;
|
||||
private long vanishTime;
|
||||
|
||||
|
||||
@NotPersistent
|
||||
public static final int INT_COLDRESISTANCE = 0;
|
||||
@NotPersistent
|
||||
public static final int INT_CONDUCTIVITY = 1;
|
||||
@NotPersistent
|
||||
public static final int INT_DECAYRESISTANCE = 2;
|
||||
@NotPersistent
|
||||
public static final int INT_HEATRESISTANCE = 3;
|
||||
@NotPersistent
|
||||
public static final int INT_MALLEABILITY = 4;
|
||||
@NotPersistent
|
||||
public static final int INT_SHOCKRESISTANCE = 5;
|
||||
@NotPersistent
|
||||
public static final int INT_UNITTOUGHNESS = 6;
|
||||
@NotPersistent
|
||||
public static final int INT_ENTANGLERESISTANCE = 7;
|
||||
@NotPersistent
|
||||
public static final int INT_POTENTIALENERGY = 8;
|
||||
@NotPersistent
|
||||
public static final int INT_OVERALLQUALITY = 9;
|
||||
@NotPersistent
|
||||
public static final int INT_FLAVOR = 10;
|
||||
|
||||
@NotPersistent
|
||||
public static final String[] statNamesLookup = {"Cold Resistance",
|
||||
"Conductivity",
|
||||
"Decay Resistance",
|
||||
"Heat Resistance",
|
||||
"Malleability",
|
||||
"Shock Resistance",
|
||||
"Unit Toughness",
|
||||
"Entangle Resistance",
|
||||
"Potential Energy",
|
||||
"Overall Quality",
|
||||
"Flavor"};
|
||||
|
||||
|
||||
private byte poolNumber;
|
||||
private String stfName;
|
||||
private String iffName;
|
||||
private int type;
|
||||
private byte generalType;
|
||||
private byte containerType;
|
||||
private String resourceClass;
|
||||
private String getresourceType;
|
||||
|
||||
//@NotPersistent
|
||||
Vector<PlanetDeposits> galacticDepositList = new Vector<PlanetDeposits>();
|
||||
|
||||
//@NotPersistent
|
||||
Vector<Integer> spawnedPlanetIDs = new Vector<Integer>();
|
||||
|
||||
short[] resourceStats = new short[11];
|
||||
|
||||
@NotPersistent
|
||||
private static int RES_CAT_HI = 1; // Up to 99%, easy to find spots over 90%
|
||||
@NotPersistent
|
||||
private static int RES_CAT_MID = 2; // Up to 90%, often have to settle at around 80%
|
||||
@NotPersistent
|
||||
private static int RES_CAT_LO = 3; // Up to 70%, often have to settle around 60%
|
||||
@NotPersistent
|
||||
private static int RES_CAT_CRE = 4; // Creature resource
|
||||
|
||||
@NotPersistent // Direct Persistence Layer entity reference restriction
|
||||
private ResourceRoot resourceRoot;
|
||||
|
||||
private int resourceRootID; // This is for re-referencing the resourceRoot in the reloaded resourceRoot collection
|
||||
// due to the DPL entity reference restriction
|
||||
|
||||
@NotPersistent
|
||||
private double minDist = 99999.0;
|
||||
|
||||
|
||||
public GalacticResource(){
|
||||
super();
|
||||
}
|
||||
|
||||
public GalacticResource(long objectID, Planet planet, Point3D position, Quaternion orientation, String template){
|
||||
super(objectID, planet, position, orientation, template);
|
||||
this.id = objectID;
|
||||
}
|
||||
|
||||
public GalacticResource(long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public GalacticResource(String name, String fileName, String category){
|
||||
this.name = name;
|
||||
this.fileName = fileName;
|
||||
this.category = category;
|
||||
//this.type = type;
|
||||
long range = 1234567L;
|
||||
Random r = new Random();
|
||||
this.id = (long)(r.nextDouble()*range);
|
||||
}
|
||||
|
||||
public Long getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long Id){
|
||||
this.id = Id;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFileName(){
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public String getCategory(){
|
||||
return category;
|
||||
}
|
||||
|
||||
public byte getPoolNumber(){
|
||||
return poolNumber;
|
||||
}
|
||||
|
||||
public void setPoolNumber(byte poolNumber){
|
||||
this.poolNumber = poolNumber;
|
||||
}
|
||||
|
||||
public byte getGeneralType(){
|
||||
return generalType;
|
||||
}
|
||||
|
||||
public void setGeneralType(byte generalType){
|
||||
this.generalType = generalType;
|
||||
}
|
||||
|
||||
public boolean isSpawnedOn(int planetId){
|
||||
if (spawnedPlanetIDs.contains(planetId))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void initializeNewGalaxyResource(Vector<String> completeResourceNameHistory){
|
||||
galacticDepositList.clear();
|
||||
|
||||
constructResourceName(completeResourceNameHistory);
|
||||
generateResourceType();
|
||||
generateResourceStats();
|
||||
generatePlanetarySpawns();
|
||||
generateSpawnTimes();
|
||||
setIffFileName(resourceRoot.getResourceFileName());
|
||||
this.category = resourceRoot.getResourceClass();
|
||||
this.setGeneralType(resourceRoot.getGeneralType());
|
||||
this.setResourceRootID(resourceRoot.getResourceRootID()); // FK
|
||||
//setResourceContainerTemplateID(resourceRoot.getTemplateID());
|
||||
}
|
||||
|
||||
public void generateResourceType(){
|
||||
// this.setResourceType(template.getResourceType());
|
||||
// this.setResourceClass(template.getResourceClass());
|
||||
}
|
||||
|
||||
public void generateResourceStats(){
|
||||
// Generate the stats randomly, considering the caps
|
||||
for (int k=0;k<resourceRoot.getResourceMinCaps().length; k++) {
|
||||
short result = 0;
|
||||
short randomStatValue = 0;
|
||||
if ((resourceRoot.getResourceMaxCaps()[k]-resourceRoot.getResourceMinCaps()[k])>0)
|
||||
randomStatValue = (short) (resourceRoot.getResourceMinCaps()[k] + new Random().nextInt(resourceRoot.getResourceMaxCaps()[k]-resourceRoot.getResourceMinCaps()[k]));
|
||||
|
||||
resourceStats[k] = randomStatValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Better not to make this publically available
|
||||
private void setResourceStats(short[] statArray){
|
||||
this.resourceStats = statArray;
|
||||
}
|
||||
|
||||
public short[] getResourceStats(){
|
||||
return this.resourceStats;
|
||||
}
|
||||
|
||||
public void setResourceRoot(ResourceRoot root){
|
||||
this.resourceRoot = root;
|
||||
}
|
||||
|
||||
public ResourceRoot getResourceRoot(){
|
||||
return this.resourceRoot;
|
||||
}
|
||||
|
||||
public void setPlanetID(int planetID){
|
||||
spawnedPlanetIDs.add(planetID);
|
||||
}
|
||||
|
||||
public void generateSpawnTimes(){
|
||||
long minimumTime = resourceRoot.getMinimalLifeTime();
|
||||
long maximumTime = resourceRoot.getMaximalLifeTime();
|
||||
long randomTime = new Random(maximumTime).nextLong();
|
||||
this.spawnTime = System.currentTimeMillis();
|
||||
this.vanishTime = spawnTime + minimumTime + randomTime;
|
||||
}
|
||||
|
||||
public int[] generateRandomPlanetArray(){
|
||||
int planets = 6 + new Random().nextInt(2);
|
||||
int[] outpool = new int[planets];
|
||||
int[] pool = new int[10]; // 10 Number of SWG planets
|
||||
for (int i = 0; i < 10; i++) pool[i] = i+1;
|
||||
for (int i = 0; i < planets; i++) outpool[i] = i+1;
|
||||
shuffleArray(pool);
|
||||
for (int i = 0; i < outpool.length; i++)
|
||||
{
|
||||
outpool[i]=pool[i];
|
||||
}
|
||||
return outpool;
|
||||
}
|
||||
|
||||
public void shuffleArray(int[] ar)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
for (int i = ar.length - 1; i > 0; i--)
|
||||
{
|
||||
int index = rnd.nextInt(i + 1);
|
||||
int a = ar[index];
|
||||
ar[index] = ar[i];
|
||||
ar[i] = a;
|
||||
}
|
||||
}
|
||||
|
||||
public void generatePlanetarySpawns(){
|
||||
// Generate a number of planets the resource will spawn on
|
||||
int[] randomPlanetArray = generateRandomPlanetArray();
|
||||
if (poolNumber!=4){
|
||||
for (int i = 0; i < randomPlanetArray.length; i++){
|
||||
if (!spawnedPlanetIDs.contains(i)){
|
||||
PlanetDeposits planetDeposits = new PlanetDeposits();
|
||||
planetDeposits.setPlanetId(randomPlanetArray[i]);
|
||||
spawnedPlanetIDs.add(randomPlanetArray[i]);
|
||||
planetDeposits.addDeposits(generateDepositSpawns());
|
||||
galacticDepositList.add(planetDeposits);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PlanetDeposits planetDeposits = new PlanetDeposits();
|
||||
planetDeposits.setPlanetId(getAllSpawnedPlanetIds().get(0));
|
||||
planetDeposits.addDeposits(generateDepositSpawns());
|
||||
galacticDepositList.add(planetDeposits);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<ResourceDeposit> generateDepositSpawns(){
|
||||
Vector<ResourceDeposit> depositList = new Vector<ResourceDeposit>();
|
||||
|
||||
// Calculate deposit positions
|
||||
Random generator = new Random();
|
||||
int depositQuantity = 8 + generator.nextInt(24);
|
||||
|
||||
// datatables/clientregion -> cities
|
||||
|
||||
for (int i = 0; i < depositQuantity; i++) {
|
||||
ResourceDeposit deposit = new ResourceDeposit();
|
||||
generator = new Random(); // Exclude mountains at the edge of the maps
|
||||
int spawnCoordsX = generator.nextInt(15000) - 7500;
|
||||
int spawnCoordsZ = generator.nextInt(15000) - 7500;
|
||||
// check maybe for: if (!core.terrainService.isWater(player.getPlanetId(), spawnCoordsX, spawnCoordsZ)) ?
|
||||
generator = new Random();
|
||||
int spawnConcentration = 30 + generator.nextInt(70);
|
||||
generator = new Random();
|
||||
int spawnRadius = 360 + generator.nextInt(1200-360);
|
||||
deposit.setSpawnRadius(spawnRadius);
|
||||
deposit.setSpawnConcentration(spawnConcentration);
|
||||
//System.out.println("spawnConcentration " + spawnConcentration);
|
||||
deposit.setSpawnCoordinatesX(spawnCoordsX);
|
||||
deposit.setSpawnCoordinatesZ(spawnCoordsZ);
|
||||
depositList.add(deposit);
|
||||
}
|
||||
return depositList;
|
||||
}
|
||||
|
||||
public float deliverConcentrationForSurvey(int planetId, float coordsX, float coordsY) {
|
||||
float measuredOutput = 0;
|
||||
for (int i = 0; i < galacticDepositList.size(); i++) {
|
||||
PlanetDeposits deposits = galacticDepositList.get(i);
|
||||
if (deposits.getPlanetId()==planetId){
|
||||
List<ResourceDeposit> depositList = deposits.getDeposits();
|
||||
for (int j=0;j<depositList.size();j++){
|
||||
ResourceDeposit resourceDeposit = depositList.get(j);
|
||||
int spawnCoordsX = (int)resourceDeposit.getSpawnCoordinatesX();
|
||||
int spawnCoordsZ = (int)resourceDeposit.getSpawnCoordinatesZ();
|
||||
int spawnRadius = (int)resourceDeposit.getSpawnRadius();
|
||||
float deltaX = coordsX-spawnCoordsX;
|
||||
float deltaY = coordsY-spawnCoordsZ;
|
||||
float localConcentration=0;
|
||||
double hypothen = Math.sqrt(deltaX*deltaX+deltaY*deltaY);
|
||||
if (hypothen<minDist)
|
||||
minDist = hypothen;
|
||||
if (hypothen<spawnRadius) {
|
||||
double depositConcentrationFactor = 1.0f -(hypothen/spawnRadius);
|
||||
localConcentration = (float)(depositConcentrationFactor*resourceDeposit.getSpawnConcentration());
|
||||
if (localConcentration>measuredOutput) {
|
||||
measuredOutput=localConcentration;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (measuredOutput<=10.0f)
|
||||
return 0;
|
||||
//measuredOutput=80.0f;
|
||||
return measuredOutput;
|
||||
}
|
||||
|
||||
public Vector<ResourceConcentration> buildConcentrationsCollection(Point3D measurePos, GalacticResource resource, float radius,float differential, int planetId){
|
||||
float leftXCoordinate = measurePos.x - (0.5f*radius);
|
||||
float topZCoordinate = measurePos.z - (0.5f*radius);
|
||||
float cursorX = leftXCoordinate;
|
||||
float cursorZ = topZCoordinate;
|
||||
int divisions=5;
|
||||
if (radius<=192.0f){
|
||||
divisions = 4;
|
||||
}
|
||||
if (radius<=64.0f){
|
||||
divisions = 3;
|
||||
}
|
||||
|
||||
Vector<ResourceConcentration> concentrationsCollection = new Vector<ResourceConcentration>();
|
||||
for (int z=0;z<divisions;z++) {
|
||||
for (int x=0;x<divisions;x++) {
|
||||
ResourceConcentration concentration = new ResourceConcentration(cursorX,cursorZ,(resource.deliverConcentrationForSurvey(planetId, cursorX, cursorZ)));
|
||||
concentrationsCollection.add(concentration);
|
||||
cursorZ+=differential;
|
||||
}
|
||||
cursorZ=topZCoordinate;
|
||||
cursorX+=differential;
|
||||
}
|
||||
return concentrationsCollection;
|
||||
}
|
||||
|
||||
public void constructSurveyMapMessage(CreatureObject crafter, Vector<ResourceConcentration> concentrationMap, float radius){
|
||||
|
||||
int pointsAmount = 25;
|
||||
if (radius<=64.0f) {
|
||||
pointsAmount=9;
|
||||
} else if (radius<=128.0) {
|
||||
pointsAmount = 16;
|
||||
} else if (radius<=192.0f) {
|
||||
pointsAmount = 16;
|
||||
} else if (radius<=256.0f) {
|
||||
pointsAmount = 25;
|
||||
} else if (radius>=256.0f) {
|
||||
pointsAmount = 25;
|
||||
}
|
||||
|
||||
SurveyMapUpdateMessage smuMsg = new SurveyMapUpdateMessage(concentrationMap, pointsAmount);
|
||||
crafter.getClient().getSession().write(smuMsg.serialize());
|
||||
tools.CharonPacketUtils.printAnalysis(smuMsg.serialize());
|
||||
|
||||
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
|
||||
if (smuMsg.getHighestConcentration() > 0.10f){
|
||||
WaypointObject lastSurveyWaypoint = player.getLastSurveyWaypoint();
|
||||
WaypointObject surveyWaypoint = null;
|
||||
if (lastSurveyWaypoint==null){
|
||||
surveyWaypoint = (WaypointObject) NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", crafter.getPlanet(), smuMsg.getHighestX(), 0 ,smuMsg.getHighestZ());
|
||||
surveyWaypoint.setName("Survey location");
|
||||
surveyWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(crafter.getPlanet().getName()));
|
||||
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(),0, smuMsg.getHighestZ()));
|
||||
player.waypointAdd(surveyWaypoint);
|
||||
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(),0, smuMsg.getHighestZ()));
|
||||
surveyWaypoint.setActive(true);
|
||||
surveyWaypoint.setColor((byte)1);
|
||||
surveyWaypoint.setStringAttribute("", "");
|
||||
player.waypointAdd(surveyWaypoint);
|
||||
surveyWaypoint.setName("Survey location");
|
||||
surveyWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(crafter.getPlanet().getName()));
|
||||
player.setLastSurveyWaypoint(surveyWaypoint);
|
||||
} else {
|
||||
surveyWaypoint = lastSurveyWaypoint;
|
||||
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(),0, smuMsg.getHighestZ()));
|
||||
player.waypointUpdate(surveyWaypoint);
|
||||
}
|
||||
crafter.sendSystemMessage("@survey:survey_waypoint", (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Redundant just for Testing !!!
|
||||
public double getHelperMinDist(){
|
||||
return minDist;
|
||||
}
|
||||
|
||||
public void constructResourceName(Vector<String> completeResourceNameHistory){
|
||||
// ToDo: This is where the database check for past names must be added
|
||||
boolean check=true;
|
||||
while(check)
|
||||
{
|
||||
this.name = NAME_SYLLABLE_1[(int) new Random().nextInt(NAME_SYLLABLE_1.length-1)]
|
||||
+ NAME_SYLLABLE_2[(int) new Random().nextInt(NAME_SYLLABLE_2.length-1)]
|
||||
+ NAME_SYLLABLE_3[(int) new Random().nextInt(NAME_SYLLABLE_3.length-1)];
|
||||
check = completeResourceNameHistory.contains(this.name);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<PlanetDeposits> getGalacticDepositList(){
|
||||
return galacticDepositList;
|
||||
}
|
||||
|
||||
public Vector<Integer> getAllSpawnedPlanetIds() {
|
||||
return spawnedPlanetIDs;
|
||||
}
|
||||
|
||||
public void setIffFileName(String iffName) {
|
||||
this.iffName = iffName;
|
||||
this.fileName = iffName;
|
||||
}
|
||||
|
||||
public String getIffFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
// protected String getStfFileName() {
|
||||
// return stfName;
|
||||
// }
|
||||
//
|
||||
// protected void setSffFileName(String stfName) {
|
||||
// this.stfName = iffName;
|
||||
// }
|
||||
|
||||
public byte getContainerType() {
|
||||
return containerType;
|
||||
}
|
||||
|
||||
public void setContainerType(byte containerType) {
|
||||
this.containerType = containerType;
|
||||
}
|
||||
|
||||
public long getVanishTime() {
|
||||
return vanishTime;
|
||||
}
|
||||
|
||||
public void setVanishTime(long vanishTime) {
|
||||
this.vanishTime = vanishTime;
|
||||
}
|
||||
|
||||
@NotPersistent
|
||||
public final static String[] GENERAL_TYPES = {
|
||||
"resource_mineral",
|
||||
"resource_chemical",
|
||||
"resource_flora",
|
||||
"resource_gas",
|
||||
"resource_water",
|
||||
"resource_solar",
|
||||
"resource_wind",
|
||||
"resource_geothermal",
|
||||
"resource_tidal",
|
||||
"resource_hydron",
|
||||
"resource_bones",
|
||||
"resource_hide",
|
||||
"resource_meat",
|
||||
"resource_milk",
|
||||
"resource_JTL"
|
||||
};
|
||||
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_MINERAL = 0;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_CHEMICAL = 1;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_FLORA = 2;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_GAS = 3;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_WATER = 4;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_SOLAR = 5;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_WIND = 6;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_GEOTHERM = 7;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_TIDAL = 8;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_HYDRON = 9;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_BONES = 10;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_HORN = 11;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_HIDE = 12;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_MEAT = 13;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_MILK = 14;
|
||||
@NotPersistent
|
||||
public final static byte GENERAL_JTL = 15;
|
||||
|
||||
@NotPersistent
|
||||
public final static String[] CONTAINER_TYPES = {
|
||||
"inorganic_minerals_small",
|
||||
"inorganic_chemicals_small",
|
||||
"organic_food_small",
|
||||
"inorganic_gas_small",
|
||||
"inorganic_water_small",
|
||||
"energy_liquid_small",
|
||||
"energy_liquid_small",
|
||||
"energy_liquid_small",
|
||||
"energy_liquid_small",
|
||||
"energy_liquid_small",
|
||||
"organic_structure_small",
|
||||
"organic_structure_small",
|
||||
"organic_hide_small",
|
||||
"organic_food_small",
|
||||
"organic_milk_small",
|
||||
"resource_JTL"
|
||||
};
|
||||
|
||||
@NotPersistent
|
||||
private static String[] NAME_SYLLABLE_1 = {"Zi", "Ao", "Bo", "Gox",
|
||||
"Ru", "Su", "Tu", "Uu", "Vu", "Wu", "Xu", "Yu", "Zu",
|
||||
"Ie", "Ce", "Ia", "Tip", "Tri", "Rel", "Xio", "Che", "Fa", "Po",
|
||||
"Pae", "Doi", "Wa", "Rup", "Ovi", "Ove", "Tae", "Nao", "Lao",
|
||||
"Lin", "Lex", "Loex", "Paex", "Bib", "Jaw", "Xat", "Lape", "Su",
|
||||
"Sae", "Epo", "Vix", "Vu", "Ke", "Kel", "Koi", "Cix", "Pal", "Pla",
|
||||
"Sor", "Lak", "Lek", "Waf", "Weg", "Ga", "Gix", "Nai", "Su",
|
||||
"Aa", "Ba", "Ca", "Da", "Ea", "Fa", "Ga", "Ha", "Ia", "Ja", "Ka",
|
||||
"La", "Ma", "Na", "Oa", "Pa", "Qa", "Ra", "Sa", "Ta", "Ua", "Va",
|
||||
"Wa", "Xa", "Ya", "Za", "Ae", "Be", "Ce", "De", "Ee", "Fe", "Ge",
|
||||
"He", "Ie", "Je", "Ke", "Le", "Me", "Ne", "Oe", "Pe", "Qe", "Re",
|
||||
"Se", "Te", "Ue", "Ve", "We", "Xe", "Ye", "Ze", "Ai", "Bi", "Ci",
|
||||
"Di", "Ei", "Fi", "Gi", "Hi", "Ii", "Ji", "Ki", "Li", "Mi", "Ni",
|
||||
"Oi", "Pi", "Qi", "Ri", "Si", "Ti", "Ui", "Vi", "Wi", "Xi", "Yi",
|
||||
"Re", "Iso", "Nab", "Co", "Do", "Eo", "Fo", "Go", "Ho", "Io", "Jo",
|
||||
"Ko", "Lo", "Mo", "No", "Oo", "Po", "Qo", "Ro", "So", "To", "Uo",
|
||||
"Vo", "Wo", "Xo", "Yo", "Zo", "Au", "Bu", "Cu", "Du", "Eu", "Fu",
|
||||
"Or", "Ved", "Pos", "Xe", "Ex", "Sti", "Ir", "Ake", "Geh", "Fig",
|
||||
"Gu", "Hu", "Iu", "Ju", "Ku", "Lu", "Mu", "Nu", "Ou", "Pu", "Qu",
|
||||
"Rel", "Xio", "Ie", "Ce", "Ia", "Tip", "Tri", "Che", "Fa", "Po"};
|
||||
|
||||
@NotPersistent
|
||||
private static String[] NAME_SYLLABLE_2 = {"gi", "hi", "ii", "qo", "ro",
|
||||
"da", "ea", "fa", "ga", "ha", "ia", "ja", "ka", "la", "ma", "na",
|
||||
"oa", "pa", "qa", "ra", "sa", "ta", "ua", "va", "wa", "xa", "ya",
|
||||
"za", "ae", "be", "ce", "de", "ee", "fe", "ge", "he", "ie", "je",
|
||||
"ke", "le", "me", "ne", "oe", "pe", "qe", "re", "se", "te", "ue",
|
||||
"ve", "we", "xe", "ye", "ze", "ai", "bi", "ci", "di", "ei", "fi",
|
||||
"uu", "vu", "wu", "xu", "yu", "zu", "mi", "ni", "oi", "pi", "qi",
|
||||
"ri", "si", "ti", "ui", "vi", "wi", "xi", "yi", "zi", "ao", "bo",
|
||||
"co", "do", "eo", "fo", "go", "ho", "io", "jo", "ko", "lo", "mo",
|
||||
"no", "oo", "po", "so", "to", "uo", "vo", "wo", "xo", "mu", "nu",
|
||||
"yo", "zo", "au", "bu", "cu", "du", "eu", "fu", "gu", "hu", "iu",
|
||||
"aa", "ba", "ca", "ji", "ki", "li"};
|
||||
|
||||
@NotPersistent
|
||||
private static String[] NAME_SYLLABLE_3 = {"fui", "gti", "hsi", "dwi",
|
||||
"mna", "nma", "ola", "pka", "qja", "ria", "sha", "tga", "ufa",
|
||||
"eve", "fue", "gte", "hse", "ire", "jqe", "kpe", "loe", "mne",
|
||||
"wde", "xce", "ybe", "zae", "azi", "byi", "cxi", "dwi", "evi",
|
||||
"iri", "jqi", "kpi", "loi", "mni", "nmi", "aza", "bya", "cxa",
|
||||
"oli", "pki", "qji", "rii", "shi", "tgi", "ufi", "vei", "wdi",
|
||||
"xci", "ybi", "zai", "azo", "byo", "cxo", "dwo", "evo", "fuo",
|
||||
"dwa", "eva", "fua", "gta", "hsa", "ira", "jqa", "kpa", "loa",
|
||||
"gto", "hso", "iro", "jqo", "kpo", "loo", "mno", "nmo", "olo",
|
||||
"pko", "qjo", "rio", "sho", "tgo", "ufo", "veo", "wdo", "xco",
|
||||
"ybo", "zao", "azu", "byu", "cxu", "dwu", "evu", "fuu", "gtu",
|
||||
"nme", "ole", "pke", "qje", "rie", "she", "tge", "ufe", "vee",
|
||||
"hsu", "iru", "jqu", "kpu", "lou", "mnu", "nmu", "olu", "pku",
|
||||
"vea", "wda", "xca", "yba", "zaa", "aze", "bye", "cxe", "dwe",
|
||||
"qju", "riu", "shu", "tgu", "ufu", "veu", "wdu", "xcu", "ybu",
|
||||
"zau"};
|
||||
|
||||
|
||||
@Override
|
||||
public void createTransaction(Environment env) { txn = env.beginTransaction(null, null);}
|
||||
|
||||
|
||||
@Override
|
||||
public Transaction getTransaction() { return txn; }
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client arg0) {
|
||||
}
|
||||
|
||||
public int getResourceRootID() {
|
||||
return resourceRootID;
|
||||
}
|
||||
|
||||
public void setResourceRootID(int resourceRootID) {
|
||||
this.resourceRootID = resourceRootID;
|
||||
}
|
||||
|
||||
public String getResourceClass() {
|
||||
return resourceClass;
|
||||
}
|
||||
|
||||
public void setResourceClass(String resourceClass) {
|
||||
this.resourceClass = resourceClass;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return getresourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String getresourceType) {
|
||||
this.getresourceType = getresourceType;
|
||||
}
|
||||
|
||||
public GalacticResource convertToHistoricResource(){
|
||||
GalacticResource historicResource = new GalacticResource();
|
||||
historicResource.setName(this.getName());
|
||||
historicResource.setResourceClass(this.getResourceClass());
|
||||
historicResource.setResourceStats(this.getResourceStats());
|
||||
historicResource.setResourceType(this.getResourceType());
|
||||
historicResource.setGeneralType(this.getGeneralType());
|
||||
historicResource.setId(this.getId());
|
||||
historicResource.setIffFileName(this.getIffFileName());
|
||||
|
||||
return historicResource;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package resources.objects.resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class PlanetDeposits {
|
||||
|
||||
private int planetId;
|
||||
private List<ResourceDeposit> depositList;
|
||||
|
||||
public PlanetDeposits(){
|
||||
|
||||
}
|
||||
|
||||
public void setPlanetId(int planetId){
|
||||
this.planetId = planetId;
|
||||
}
|
||||
|
||||
public int getPlanetId(){
|
||||
return this.planetId;
|
||||
}
|
||||
|
||||
public void addDeposits(List<ResourceDeposit> depositList){
|
||||
this.depositList = depositList;
|
||||
}
|
||||
|
||||
public List<ResourceDeposit> getDeposits(){
|
||||
return this.depositList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package resources.objects.resource;
|
||||
|
||||
public class ResourceConcentration {
|
||||
private float coordsX;
|
||||
private float coordsZ;
|
||||
private float concentration;
|
||||
|
||||
public ResourceConcentration(){
|
||||
|
||||
}
|
||||
|
||||
public ResourceConcentration(float coordsX, float coordsZ, float concentration){
|
||||
this.coordsX = coordsX;
|
||||
this.coordsZ = coordsZ;
|
||||
this.concentration = concentration;
|
||||
}
|
||||
|
||||
public float getCoordsX() {
|
||||
return coordsX;
|
||||
}
|
||||
|
||||
public void setCoordsX(float coordsX) {
|
||||
this.coordsX = coordsX;
|
||||
}
|
||||
|
||||
public float getCoordsZ() {
|
||||
return coordsZ;
|
||||
}
|
||||
|
||||
public void setCoordsZ(float coordsZ) {
|
||||
this.coordsZ = coordsZ;
|
||||
}
|
||||
|
||||
public float getConcentration() {
|
||||
return concentration;
|
||||
}
|
||||
|
||||
public void setConcentration(float concentration) {
|
||||
this.concentration = concentration;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,268 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.resource;
|
||||
|
||||
public class ResourceContainerMessageBuilder {
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
|
||||
public class ResourceContainerMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
public ResourceContainerMessageBuilder(ResourceContainerObject resourceContainerObject) {
|
||||
setObject(resourceContainerObject);
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline3() {
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putShort((short)0x0F);
|
||||
buffer.putFloat(1.0f);
|
||||
buffer.put(getAsciiString("resource/resource_names"));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(resourceContainer.getResourceFileName()));
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putShort((short)0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(100); //MaxCondition
|
||||
buffer.put((byte)1);
|
||||
buffer.putInt(resourceContainer.getStackCount());
|
||||
//result.putInt(30000);
|
||||
buffer.putLong(resourceContainer.getReferenceID());
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("RCNO", (byte) 3, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline6() {
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
String iffFileName = resourceContainer.getResourceFileName();
|
||||
String contName = resourceContainer.getResourceName();
|
||||
|
||||
buffer.putShort((short)12); //0C
|
||||
buffer.putInt(0x8A);
|
||||
buffer.put(getAsciiString("resource_container_d"));
|
||||
buffer.putInt(0);
|
||||
// buffer.put(getAsciiString("inorganic_minerals_small"));
|
||||
buffer.put(getAsciiString(GalacticResource.CONTAINER_TYPES[resourceContainer.getGeneralType()]));
|
||||
|
||||
//37 x 00
|
||||
buffer.putLong(0);
|
||||
buffer.putLong(0);
|
||||
buffer.putLong(0);
|
||||
buffer.putLong(0);
|
||||
buffer.putInt(0);
|
||||
buffer.put((byte)0);
|
||||
|
||||
buffer.putInt(ResourceContainerObject.maximalStackCapacity);
|
||||
buffer.put(getAsciiString(iffFileName));
|
||||
buffer.put(getUnicodeString(contName));
|
||||
buffer.putLong(0);
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("RCNO", (byte) 6, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline8() {
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putInt(2);
|
||||
buffer.putShort((short)0);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("RCNO", (byte) 8, buffer, size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline9() {
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x68A75F0C);
|
||||
buffer.putLong(resourceContainer.getObjectID());
|
||||
buffer.putInt(0x52434E4F);
|
||||
buffer.put((byte)9);
|
||||
buffer.putInt(2);
|
||||
buffer.putShort((short)0);
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("RCNO", (byte) 9, buffer, size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDelta3() {
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) object;
|
||||
IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putInt(resourceContainer.getStackCount());
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("RCNO", (byte) 3, (short) 1, (short) 0x0D, buffer, size + 4); // 0x0D differs from pre-NGE specification !
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// This is a specific AttributeListMessage for the resource container
|
||||
// and represents no baseline or delta.
|
||||
public IoBuffer serialized_buildAttributeListMessage() {
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) object;
|
||||
IoBuffer result = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN);
|
||||
result.setAutoExpand(true);
|
||||
result.putShort((short)5);
|
||||
result.putInt(0xF3F12F2A); // !
|
||||
result.putLong(resourceContainer.getObjectID());
|
||||
result.putShort((short)0);
|
||||
|
||||
int countedSize = 0;
|
||||
if (resourceContainer.getColdResistance()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getConductivity()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getDecayResistance()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getHeatResistance()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getMalleability()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getOverallQuality()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getShockResistance()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getUnitToughness()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getFlavor()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getEntangleResistance()>0)
|
||||
countedSize++;
|
||||
if (resourceContainer.getPotentialEnergy()>0)
|
||||
countedSize++;
|
||||
|
||||
int attributeSize = 5 + countedSize;
|
||||
|
||||
result.putInt(attributeSize);//result.putInt(16);
|
||||
|
||||
result.put(getAsciiString("condition"));
|
||||
result.put(getUnicodeString("100/100"));
|
||||
|
||||
result.put(getAsciiString("volume"));
|
||||
result.put(getUnicodeString("1"));
|
||||
|
||||
result.put(getAsciiString("resource_contents"));
|
||||
result.put(getUnicodeString(resourceContainer.getStackCount()+"/"+ResourceContainerObject.maximalStackCapacity));
|
||||
|
||||
result.put(getAsciiString("resource_name"));
|
||||
result.put(getUnicodeString(resourceContainer.getResourceName()));
|
||||
|
||||
result.put(getAsciiString("resource_class"));
|
||||
result.put(getUnicodeString("@resource/resource_names:" + resourceContainer.getResourceFileName()));
|
||||
//result.put(getUnicodeString(resourceContainer.getResourceClass()));
|
||||
|
||||
if (resourceContainer.getColdResistance()>0){
|
||||
result.put(getAsciiString("res_cold_resist"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getColdResistance()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getConductivity()>0){
|
||||
result.put(getAsciiString("res_conductivity"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getConductivity()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getDecayResistance()>0){
|
||||
result.put(getAsciiString("res_decay_resist"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getDecayResistance()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getHeatResistance()>0){
|
||||
result.put(getAsciiString("res_heat_resist"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getHeatResistance()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getMalleability()>0){
|
||||
result.put(getAsciiString("res_malleability"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getMalleability()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getOverallQuality()>0){
|
||||
result.put(getAsciiString("res_quality"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getOverallQuality()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getShockResistance()>0){
|
||||
result.put(getAsciiString("res_shock_resistance"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getShockResistance()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getUnitToughness()>0){
|
||||
result.put(getAsciiString("res_toughness"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getUnitToughness()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getFlavor()>0){
|
||||
result.put(getAsciiString("res_flavor"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getFlavor()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getEntangleResistance()>0){
|
||||
result.put(getAsciiString("entangle_resistance"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getEntangleResistance()));
|
||||
}
|
||||
|
||||
if (resourceContainer.getPotentialEnergy()>0){
|
||||
result.put(getAsciiString("res_potential_energy"));
|
||||
result.put(getUnicodeString(""+resourceContainer.getPotentialEnergy()));
|
||||
}
|
||||
|
||||
result.putInt(10);
|
||||
int size = result.position();
|
||||
result.flip();
|
||||
tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(result.array(), 0, size).flip());
|
||||
return IoBuffer.allocate(size).put(result.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,531 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.resource;
|
||||
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ResourceContainerObject extends TangibleObject {
|
||||
|
||||
// Unique ID
|
||||
private long containerID;
|
||||
|
||||
private CreatureObject proprietor;
|
||||
private String resourceType;
|
||||
private String resourceClass="";
|
||||
private String resourceName;
|
||||
private byte generalType;
|
||||
private long referenceID;
|
||||
private String iffFileName;
|
||||
private String resourceFileName;
|
||||
private int stackCount=0;
|
||||
private byte containerType;
|
||||
|
||||
// Since this can represent a resource that already despawned
|
||||
// it needs to hold all resource stats:
|
||||
private short coldResistance;
|
||||
private short conductivity;
|
||||
private short decayResistance;
|
||||
private short heatResistance;
|
||||
private short malleability;
|
||||
private short shockResistance;
|
||||
private short unitToughness;
|
||||
private short entangleResistance;
|
||||
private short potentialEnergy;
|
||||
private short overallQuality;
|
||||
private short flavor;
|
||||
|
||||
/*
|
||||
private static byte CONTAINER_TYPE_INORGANIC_MINERALS = 0;
|
||||
private static byte CONTAINER_TYPE_INORGANIC_CHEMICALS = 1;
|
||||
private static byte CONTAINER_TYPE_INORGANIC_GAS = 2;
|
||||
private static byte CONTAINER_TYPE_INORGANIC_PETROCHEM_LIQUID = 3;
|
||||
private static byte CONTAINER_TYPE_INORGANIC_WATER = 4;
|
||||
private static byte CONTAINER_TYPE_INORGANIC_BOTTLE_WATER = 5;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_BEAN = 6;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_BOTTLE_MILK = 7;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_BRISTLEY_HIDE = 8;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_CORN = 9;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_FOOD = 10;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_FRUIT = 11;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_FUNGI = 12;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_GREEN_VEGETABLES = 13;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_HIDE = 14;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_LEATHERY_HIDE = 15;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_OATS = 16;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_RICE = 17;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_SCALEY_HIDE = 18;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_STRUCTURE = 19;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_TUBER = 20;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_WHEAT = 21;
|
||||
private static byte CONTAINER_TYPE_ORGANIC_WOOLY_HIDE = 22;
|
||||
private static byte CONTAINER_TYPE_ENERGY_GAS = 23;
|
||||
private static byte CONTAINER_TYPE_ENERGY_LIQUID = 24;
|
||||
private static byte CONTAINER_TYPE_ENERGY_RADIOACTIVE = 25;
|
||||
private static byte CONTAINER_TYPE_ENERGY_SOLID = 26;
|
||||
|
||||
private static String[] CONTAINER_TYPE_IFF_SIGNIFIER = new String[]{
|
||||
"object/resource_container/shared_resource_container_inorganic_minerals.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_chemicals.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_gas.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_petrochem_liquid.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_water.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_bottle_water.iff",
|
||||
"object/resource_container/shared_resource_container_organic_bean.iff",
|
||||
"object/resource_container/shared_resource_container_organic_bottle_milk.iff",
|
||||
"object/resource_container/shared_resource_container_organic_bristley_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_corn.iff",
|
||||
"object/resource_container/shared_resource_container_organic_food.iff",
|
||||
"object/resource_container/shared_resource_container_organic_fruit.iff",
|
||||
"object/resource_container/shared_resource_container_organic_fungi.iff",
|
||||
"object/resource_container/shared_resource_container_organic_green_vegetables.iff",
|
||||
"object/resource_container/shared_resource_container_organic_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_leathery_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_oats.iff",
|
||||
"object/resource_container/shared_resource_container_organic_rice.iff",
|
||||
"object/resource_container/shared_resource_container_organic_scaley_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_structure.iff",
|
||||
"object/resource_container/shared_resource_container_organic_tuber.iff",
|
||||
"object/resource_container/shared_resource_container_organic_wheat.iff",
|
||||
"object/resource_container/shared_resource_container_organic_wooly_hide.iff",
|
||||
"object/resource_container/shared_resource_container_energy_gas.iff",
|
||||
"object/resource_container/shared_resource_container_energy_liquid.iff",
|
||||
"object/resource_container/shared_resource_container_energy_radioactive.iff",
|
||||
"object/resource_container/shared_resource_container_energy_solid.iff"
|
||||
};
|
||||
*/
|
||||
|
||||
@NotPersistent
|
||||
public static int maximalStackCapacity = 100000;
|
||||
|
||||
@NotPersistent
|
||||
private ResourceContainerMessageBuilder messageBuilder;
|
||||
|
||||
public ResourceContainerObject(){
|
||||
|
||||
}
|
||||
|
||||
public ResourceContainerObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
messageBuilder = new ResourceContainerMessageBuilder(this);
|
||||
this.setAttachment("radial_filename", "resourceContainer");
|
||||
}
|
||||
|
||||
public void initializeStats(GalacticResource resource){
|
||||
this.setResourceName(resource.getName());
|
||||
this.setResourceClass(resource.getCategory());
|
||||
this.setColdResistance(resource.getResourceStats()[0]);
|
||||
this.setConductivity(resource.getResourceStats()[1]);
|
||||
this.setDecayResistance(resource.getResourceStats()[2]);
|
||||
this.setHeatResistance(resource.getResourceStats()[3]);
|
||||
this.setMalleability(resource.getResourceStats()[4]);
|
||||
this.setShockResistance(resource.getResourceStats()[5]);
|
||||
this.setUnitToughness(resource.getResourceStats()[6]);
|
||||
this.setEntangleResistance(resource.getResourceStats()[7]);
|
||||
this.setPotentialEnergy(resource.getResourceStats()[8]);
|
||||
this.setOverallQuality(resource.getResourceStats()[9]);
|
||||
this.setFlavor(resource.getResourceStats()[10]);
|
||||
this.setResourceType(resource.getResourceType());
|
||||
this.setGeneralType(resource.getGeneralType());
|
||||
this.setReferenceID(resource.getId());
|
||||
this.setResourceFileName(resource.getIffFileName());
|
||||
//this.setIffFileName(resource.getIffFileName());
|
||||
|
||||
// set attributes
|
||||
this.getAttributes().put("@obj_attr_n:condition", "100/100");
|
||||
this.getAttributes().put("@obj_attr_n:volume", "1");
|
||||
this.getAttributes().put("@obj_attr_n:resource_contents", this.getStackCount()+"/"+maximalStackCapacity);
|
||||
this.getAttributes().put("@obj_attr_n:resource_name", this.getResourceName());
|
||||
this.getAttributes().put("@obj_attr_n:resource_class", "@resource/resource_names:" + this.getResourceFileName());
|
||||
|
||||
if (this.getColdResistance()>0){
|
||||
this.getAttributes().put("res_cold_resist", ""+this.getColdResistance());
|
||||
resource.getAttributes().put("res_cold_resist", ""+this.getColdResistance());
|
||||
}
|
||||
|
||||
if (this.getConductivity()>0){
|
||||
this.getAttributes().put("res_conductivity", ""+this.getConductivity());
|
||||
resource.getAttributes().put("res_conductivity", ""+this.getConductivity());
|
||||
}
|
||||
|
||||
if (this.getDecayResistance()>0){
|
||||
this.getAttributes().put("res_decay_resist", ""+this.getDecayResistance());
|
||||
resource.getAttributes().put("res_decay_resist", ""+this.getDecayResistance());
|
||||
}
|
||||
|
||||
if (this.getHeatResistance()>0){
|
||||
this.getAttributes().put("res_heat_resist", ""+this.getHeatResistance());
|
||||
resource.getAttributes().put("res_heat_resist", ""+this.getHeatResistance());
|
||||
}
|
||||
|
||||
if (this.getMalleability()>0){
|
||||
this.getAttributes().put("res_malleability", ""+this.getMalleability());
|
||||
resource.getAttributes().put("res_malleability", ""+this.getMalleability());
|
||||
}
|
||||
|
||||
if (this.getOverallQuality()>0){
|
||||
this.getAttributes().put("res_quality", ""+this.getOverallQuality());
|
||||
resource.getAttributes().put("res_quality", ""+this.getOverallQuality());
|
||||
|
||||
}
|
||||
|
||||
if (this.getShockResistance()>0){
|
||||
this.getAttributes().put("res_shock_resistance", ""+this.getShockResistance());
|
||||
resource.getAttributes().put("res_shock_resistance", ""+this.getShockResistance());
|
||||
}
|
||||
|
||||
if (this.getUnitToughness()>0){
|
||||
this.getAttributes().put("res_toughness", ""+this.getUnitToughness());
|
||||
resource.getAttributes().put("res_toughness", ""+this.getUnitToughness());
|
||||
}
|
||||
|
||||
if (this.getFlavor()>0){
|
||||
this.getAttributes().put("res_flavor", ""+this.getFlavor());
|
||||
resource.getAttributes().put("res_flavor", ""+this.getFlavor());
|
||||
}
|
||||
|
||||
if (this.getEntangleResistance()>0){
|
||||
this.getAttributes().put("entangle_resistance", ""+this.getEntangleResistance());
|
||||
resource.getAttributes().put("entangle_resistance", ""+this.getEntangleResistance());
|
||||
}
|
||||
|
||||
if (this.getPotentialEnergy()>0){
|
||||
this.getAttributes().put("res_potential_energy", ""+this.getPotentialEnergy());
|
||||
resource.getAttributes().put("res_potential_energy", ""+this.getPotentialEnergy());
|
||||
}
|
||||
}
|
||||
|
||||
public void cloneStats(ResourceContainerObject original){
|
||||
this.setResourceName(original.getResourceName());
|
||||
this.setResourceClass(original.getResourceClass());
|
||||
this.setColdResistance(original.getColdResistance());
|
||||
this.setConductivity(original.getConductivity());
|
||||
this.setDecayResistance(original.getDecayResistance());
|
||||
this.setHeatResistance(original.getHeatResistance());
|
||||
this.setMalleability(original.getMalleability());
|
||||
this.setShockResistance(original.getShockResistance());
|
||||
this.setUnitToughness(original.getUnitToughness());
|
||||
this.setEntangleResistance(original.getEntangleResistance());
|
||||
this.setPotentialEnergy(original.getPotentialEnergy());
|
||||
this.setOverallQuality(original.getOverallQuality());
|
||||
this.setFlavor(original.getFlavor());
|
||||
this.setResourceType(original.getResourceType());
|
||||
this.setGeneralType(original.getGeneralType());
|
||||
this.setReferenceID(original.getReferenceID());
|
||||
this.setResourceFileName(original.getResourceFileName());
|
||||
|
||||
// set attributes
|
||||
this.getAttributes().put("@obj_attr_n:condition", "100/100");
|
||||
this.getAttributes().put("@obj_attr_n:volume", "1");
|
||||
this.getAttributes().put("@obj_attr_n:resource_contents", this.getStackCount()+"/"+maximalStackCapacity);
|
||||
this.getAttributes().put("@obj_attr_n:resource_name", this.getResourceName());
|
||||
this.getAttributes().put("@obj_attr_n:resource_class", "@resource/resource_names:" + this.getResourceFileName());
|
||||
|
||||
if (this.getColdResistance()>0){
|
||||
this.getAttributes().put("res_cold_resist", ""+this.getColdResistance());
|
||||
}
|
||||
|
||||
if (this.getConductivity()>0){
|
||||
this.getAttributes().put("res_conductivity", ""+this.getConductivity());
|
||||
}
|
||||
|
||||
if (this.getDecayResistance()>0){
|
||||
this.getAttributes().put("res_decay_resist", ""+this.getDecayResistance());
|
||||
}
|
||||
|
||||
if (this.getHeatResistance()>0){
|
||||
this.getAttributes().put("res_heat_resist", ""+this.getHeatResistance());
|
||||
}
|
||||
|
||||
if (this.getMalleability()>0){
|
||||
this.getAttributes().put("res_malleability", ""+this.getMalleability());
|
||||
}
|
||||
|
||||
if (this.getOverallQuality()>0){
|
||||
this.getAttributes().put("res_quality", ""+this.getOverallQuality());
|
||||
}
|
||||
|
||||
if (this.getShockResistance()>0){
|
||||
this.getAttributes().put("res_shock_resistance", ""+this.getShockResistance());
|
||||
}
|
||||
|
||||
if (this.getUnitToughness()>0){
|
||||
this.getAttributes().put("res_toughness", ""+this.getUnitToughness());
|
||||
}
|
||||
|
||||
if (this.getFlavor()>0){
|
||||
this.getAttributes().put("res_flavor", ""+this.getFlavor());
|
||||
}
|
||||
|
||||
if (this.getEntangleResistance()>0){
|
||||
this.getAttributes().put("entangle_resistance", ""+this.getEntangleResistance());
|
||||
}
|
||||
|
||||
if (this.getPotentialEnergy()>0){
|
||||
this.getAttributes().put("res_potential_energy", ""+this.getPotentialEnergy());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public long getContainerID() {
|
||||
return containerID;
|
||||
}
|
||||
|
||||
public void setContainerID(long containerID) {
|
||||
this.containerID = containerID;
|
||||
}
|
||||
|
||||
public CreatureObject getProprietor() {
|
||||
return proprietor;
|
||||
}
|
||||
|
||||
public void setProprietor(CreatureObject proprietor) {
|
||||
this.proprietor = proprietor;
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public int getStackCount() {
|
||||
return stackCount;
|
||||
}
|
||||
|
||||
public void setStackCount(int stackCount,boolean isNewContainer) {
|
||||
this.stackCount += stackCount;
|
||||
if (isNewContainer)
|
||||
this.stackCount = stackCount;
|
||||
}
|
||||
|
||||
public void setStackCount(int stackCount,CreatureObject owner) {
|
||||
this.stackCount = stackCount;
|
||||
this.getAttributes().put("@obj_attr_n:resource_contents", this.getStackCount()+"/"+maximalStackCapacity);
|
||||
if (stackCount>0)
|
||||
this.sendDelta3(owner.getClient());
|
||||
}
|
||||
|
||||
public short getColdResistance() {
|
||||
return coldResistance;
|
||||
}
|
||||
|
||||
public void setColdResistance(short coldResistance) {
|
||||
this.coldResistance = coldResistance;
|
||||
}
|
||||
|
||||
public short getConductivity() {
|
||||
return conductivity;
|
||||
}
|
||||
|
||||
public void setConductivity(short conductivity) {
|
||||
this.conductivity = conductivity;
|
||||
}
|
||||
|
||||
public short getDecayResistance() {
|
||||
return decayResistance;
|
||||
}
|
||||
|
||||
public void setDecayResistance(short decayResistance) {
|
||||
this.decayResistance = decayResistance;
|
||||
}
|
||||
|
||||
public short getHeatResistance() {
|
||||
return heatResistance;
|
||||
}
|
||||
|
||||
public void setHeatResistance(short heatResistance) {
|
||||
this.heatResistance = heatResistance;
|
||||
}
|
||||
|
||||
public short getMalleability() {
|
||||
return malleability;
|
||||
}
|
||||
|
||||
public void setMalleability(short malleability) {
|
||||
this.malleability = malleability;
|
||||
}
|
||||
|
||||
public short getShockResistance() {
|
||||
return shockResistance;
|
||||
}
|
||||
|
||||
public void setShockResistance(short shockResistance) {
|
||||
this.shockResistance = shockResistance;
|
||||
}
|
||||
|
||||
public short getUnitToughness() {
|
||||
return unitToughness;
|
||||
}
|
||||
|
||||
public void setUnitToughness(short unitToughness) {
|
||||
this.unitToughness = unitToughness;
|
||||
}
|
||||
|
||||
public short getEntangleResistance() {
|
||||
return entangleResistance;
|
||||
}
|
||||
|
||||
public void setEntangleResistance(short entangleResistance) {
|
||||
this.entangleResistance = entangleResistance;
|
||||
}
|
||||
|
||||
public short getPotentialEnergy() {
|
||||
return potentialEnergy;
|
||||
}
|
||||
|
||||
public void setPotentialEnergy(short potentialEnergy) {
|
||||
this.potentialEnergy = potentialEnergy;
|
||||
}
|
||||
|
||||
public short getOverallQuality() {
|
||||
return overallQuality;
|
||||
}
|
||||
|
||||
public void setOverallQuality(short overallQuality) {
|
||||
this.overallQuality = overallQuality;
|
||||
}
|
||||
|
||||
public short getFlavor() {
|
||||
return flavor;
|
||||
}
|
||||
|
||||
public void setFlavor(short flavor) {
|
||||
this.flavor = flavor;
|
||||
}
|
||||
|
||||
public String getResourceName() {
|
||||
return resourceName;
|
||||
}
|
||||
|
||||
public void setResourceName(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
public String getIffFileName() {
|
||||
return iffFileName;
|
||||
}
|
||||
|
||||
public void setIffFileName(String iffFileName) {
|
||||
this.iffFileName = iffFileName;
|
||||
}
|
||||
|
||||
public String getResourceClass() {
|
||||
return resourceClass;
|
||||
}
|
||||
|
||||
public void setResourceClass(String resourceClass) {
|
||||
this.resourceClass = resourceClass;
|
||||
}
|
||||
|
||||
public long getReferenceID() {
|
||||
return referenceID;
|
||||
}
|
||||
|
||||
public void setReferenceID(long referenceID) {
|
||||
this.referenceID = referenceID;
|
||||
}
|
||||
|
||||
public String getResourceFileName() {
|
||||
return resourceFileName;
|
||||
}
|
||||
|
||||
public void setResourceFileName(String resourceFileName) {
|
||||
this.resourceFileName = resourceFileName;
|
||||
}
|
||||
|
||||
public byte getGeneralType() {
|
||||
return generalType;
|
||||
}
|
||||
|
||||
public void setGeneralType(byte generalType) {
|
||||
this.generalType = generalType;
|
||||
}
|
||||
|
||||
public void setStackCount(int stackCount) {
|
||||
this.stackCount = stackCount;
|
||||
this.getAttributes().put("@obj_attr_n:resource_contents", this.getStackCount()+"/"+maximalStackCapacity);
|
||||
this.sendDelta3(this.getProprietor().getClient());
|
||||
}
|
||||
|
||||
public byte getContainerType() {
|
||||
return containerType;
|
||||
}
|
||||
|
||||
public void setContainerType(byte containerType) {
|
||||
this.containerType = containerType;
|
||||
}
|
||||
|
||||
public void buildAttributeListMessage(Client destination){
|
||||
destination.getSession().write(messageBuilder.serialized_buildAttributeListMessage());
|
||||
}
|
||||
|
||||
public void splitContainer(CreatureObject owner,ResourceContainerObject originalObject,String commandString){
|
||||
String[] splitArray = commandString.split(" ");
|
||||
if (splitArray.length<3)
|
||||
return;
|
||||
int cloneStackQuantity= Integer.parseInt(splitArray[0]);
|
||||
int parentcontainerID= Integer.parseInt(splitArray[1]);
|
||||
SWGObject objectParentContainer = (SWGObject) NGECore.getInstance().objectService.getObject(parentcontainerID);
|
||||
if (objectParentContainer==null || originalObject==null)
|
||||
return;
|
||||
CreatureObject proprietor = originalObject.getProprietor();
|
||||
ResourceContainerObject containerObject = (ResourceContainerObject) NGECore.getInstance().objectService.createObject(originalObject.getTemplate(), proprietor.getPlanet());
|
||||
containerObject.cloneStats(originalObject);
|
||||
containerObject.setProprietor(originalObject.getProprietor());
|
||||
containerObject.setStackCount(cloneStackQuantity);
|
||||
originalObject.setStackCount(originalObject.getStackCount()-cloneStackQuantity);
|
||||
objectParentContainer.add(containerObject);
|
||||
}
|
||||
|
||||
public void transferContainer(CreatureObject owner,ResourceContainerObject disposableObject,String commandString){
|
||||
String[] splitArray = commandString.split(" ");
|
||||
if (splitArray.length<2)
|
||||
return;
|
||||
int parentcontainerID= Integer.parseInt(splitArray[0]);
|
||||
int cloneStackQuantity= Integer.parseInt(splitArray[1]);
|
||||
ResourceContainerObject resourceContainer = (ResourceContainerObject) NGECore.getInstance().objectService.getObject(parentcontainerID);
|
||||
if (resourceContainer==null)
|
||||
return;
|
||||
resourceContainer.setStackCount(resourceContainer.getStackCount()+cloneStackQuantity);
|
||||
SWGObject objectParentContainer = (SWGObject) NGECore.getInstance().objectService.getObject(resourceContainer.getParentId());
|
||||
objectParentContainer.remove(disposableObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
if(destination == null || destination.getSession() == null)
|
||||
return;
|
||||
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
destination.getSession().write(messageBuilder.buildBaseline8());
|
||||
destination.getSession().write(messageBuilder.buildBaseline9());
|
||||
}
|
||||
|
||||
public void sendDelta3(Client destination) {
|
||||
|
||||
if(destination == null || destination.getSession() == null)
|
||||
return;
|
||||
|
||||
destination.getSession().write(messageBuilder.buildDelta3());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package resources.objects.resource;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ResourceDeposit {
|
||||
private float spawnCoordsX;
|
||||
private float spawnCoordsZ;
|
||||
private float spawnRadius;
|
||||
private float spawnConcentration;
|
||||
|
||||
public ResourceDeposit(){
|
||||
|
||||
}
|
||||
|
||||
public void setSpawnCoordinatesX(float spawnCoordsX){
|
||||
this.spawnCoordsX = spawnCoordsX;
|
||||
}
|
||||
|
||||
public float getSpawnCoordinatesX(){
|
||||
return this.spawnCoordsX;
|
||||
}
|
||||
|
||||
public void setSpawnCoordinatesZ(float spawnCoordsZ){
|
||||
this.spawnCoordsZ = spawnCoordsZ;
|
||||
}
|
||||
|
||||
public float getSpawnCoordinatesZ(){
|
||||
return this.spawnCoordsZ;
|
||||
}
|
||||
|
||||
public void setSpawnRadius(float spawnRadius){
|
||||
this.spawnRadius = spawnRadius;
|
||||
}
|
||||
|
||||
public float getSpawnRadius(){
|
||||
return spawnRadius;
|
||||
}
|
||||
|
||||
public void setSpawnConcentration(float spawnConcentration){
|
||||
this.spawnConcentration = spawnConcentration;
|
||||
}
|
||||
|
||||
public float getSpawnConcentration(){
|
||||
return this.spawnConcentration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.resource;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Entity(version=0)
|
||||
public class ResourceRoot {
|
||||
|
||||
// Publish 15:
|
||||
|
||||
// - Total: 61, Minimum pool: 15, Random pool: 24 (3 was removed), Fixed pool: 22.
|
||||
// - Possible spawns for rare non-Iron resources: 39.
|
||||
// - Indoor concentrations were fixed for creature harvesting.
|
||||
|
||||
|
||||
// 1) Minimum Pool (15 resources)
|
||||
//
|
||||
// 1 Steel not including Hardened and Crystallized from JTL
|
||||
// 1 Copper not including Conductive from JTL
|
||||
// 0 Iron
|
||||
// 1 Aluminium not including Perovskitic from JTL
|
||||
// 1 Extrusive Ore
|
||||
// 1 Intrusive Ore
|
||||
// 0 Siliclastic Ore not including Fermionic from JTL
|
||||
// 1 Carbonate Ore
|
||||
// 1 Crystalline Gemstone
|
||||
// 1 Armophous Gemstone
|
||||
// 1 Known Radioactive not including High Grade from JTL
|
||||
// 1 Known Solid Petrochemicals
|
||||
// 1 Known Liquid Petrochemicals
|
||||
// 2 Polymer
|
||||
// 2 Lubricating Oil
|
||||
// 0 Known Inert Gas
|
||||
// 0 Known Reactive Gas not including Unstable from JTL Gas
|
||||
//
|
||||
//
|
||||
//2) Random Pool (24 resources)
|
||||
//
|
||||
// Any Mineral except Iron and JTL resources.
|
||||
// Any Gas except JTL Gas.
|
||||
// Any Chemical except Fiberplast
|
||||
// Extra Water (Bonus Water in addition to the one in the Native Pool)
|
||||
//
|
||||
//
|
||||
//3) Fixed Pool (22 resources)
|
||||
//
|
||||
// 8 JTL Resources (Added just before Publish 11)
|
||||
// 14 Iron
|
||||
//
|
||||
//
|
||||
//4) Native Pool (420 resources)
|
||||
//
|
||||
// One Fiberplast for each planet
|
||||
// One Water for each planet
|
||||
// One Wind Energy and One Solar Energy for each planet
|
||||
// All 38 Organic types for each planet
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
private static int highestID = 0;
|
||||
|
||||
@PrimaryKey
|
||||
private int resourceRootID;
|
||||
|
||||
private String resourceClass;
|
||||
private String resourceType;
|
||||
private byte generalType;
|
||||
private byte containerType;
|
||||
private String resourceFileName;
|
||||
private short[] resourceMaxCaps;
|
||||
private short[] resourceMinCaps;
|
||||
private Long minimalLifeTime;
|
||||
private Long maximalLifeTime;
|
||||
// Non-JTL Inorganics: 6 to 11 days.
|
||||
// Organics: 6 to 22 days.
|
||||
// JTL resources: 13 to 22 days.
|
||||
|
||||
public static byte CONTAINER_TYPE_INORGANIC_MINERALS = 0;
|
||||
public static byte CONTAINER_TYPE_INORGANIC_CHEMICALS = 1;
|
||||
public static byte CONTAINER_TYPE_INORGANIC_GAS = 2;
|
||||
public static byte CONTAINER_TYPE_INORGANIC_PETROCHEM_LIQUID = 3;
|
||||
public static byte CONTAINER_TYPE_INORGANIC_WATER = 4;
|
||||
public static byte CONTAINER_TYPE_INORGANIC_BOTTLE_WATER = 5;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_BEAN = 6;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_BOTTLE_MILK = 7;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_BRISTLEY_HIDE = 8;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_CORN = 9;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_FOOD = 10;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_FRUIT = 11;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_FUNGI = 12;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_GREEN_VEGETABLES = 13;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_HIDE = 14;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_LEATHERY_HIDE = 15;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_OATS = 16;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_RICE = 17;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_SCALEY_HIDE = 18;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_STRUCTURE = 19;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_TUBER = 20;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_WHEAT = 21;
|
||||
public static byte CONTAINER_TYPE_ORGANIC_WOOLY_HIDE = 22;
|
||||
public static byte CONTAINER_TYPE_ENERGY_GAS = 23;
|
||||
public static byte CONTAINER_TYPE_ENERGY_LIQUID = 24;
|
||||
public static byte CONTAINER_TYPE_ENERGY_RADIOACTIVE = 25;
|
||||
public static byte CONTAINER_TYPE_ENERGY_SOLID = 26;
|
||||
|
||||
public static String[] CONTAINER_TYPE_IFF_SIGNIFIER = new String[]{
|
||||
"object/resource_container/shared_resource_container_inorganic_minerals.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_chemicals.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_gas.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_petrochem_liquid.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_water.iff",
|
||||
"object/resource_container/shared_resource_container_inorganic_bottle_water.iff",
|
||||
"object/resource_container/shared_resource_container_organic_bean.iff",
|
||||
"object/resource_container/shared_resource_container_organic_bottle_milk.iff",
|
||||
"object/resource_container/shared_resource_container_organic_bristley_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_corn.iff",
|
||||
"object/resource_container/shared_resource_container_organic_food.iff",
|
||||
"object/resource_container/shared_resource_container_organic_fruit.iff",
|
||||
"object/resource_container/shared_resource_container_organic_fungi.iff",
|
||||
"object/resource_container/shared_resource_container_organic_green_vegetables.iff",
|
||||
"object/resource_container/shared_resource_container_organic_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_leathery_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_oats.iff",
|
||||
"object/resource_container/shared_resource_container_organic_rice.iff",
|
||||
"object/resource_container/shared_resource_container_organic_scaley_hide.iff",
|
||||
"object/resource_container/shared_resource_container_organic_structure.iff",
|
||||
"object/resource_container/shared_resource_container_organic_tuber.iff",
|
||||
"object/resource_container/shared_resource_container_organic_wheat.iff",
|
||||
"object/resource_container/shared_resource_container_organic_wooly_hide.iff",
|
||||
"object/resource_container/shared_resource_container_energy_gas.iff",
|
||||
"object/resource_container/shared_resource_container_energy_liquid.iff",
|
||||
"object/resource_container/shared_resource_container_energy_radioactive.iff",
|
||||
"object/resource_container/shared_resource_container_energy_solid.iff"
|
||||
};
|
||||
|
||||
|
||||
public ResourceRoot(){
|
||||
this.resourceRootID = highestID++;
|
||||
resourceMinCaps = new short[11];
|
||||
resourceMaxCaps = new short[11];
|
||||
}
|
||||
|
||||
public String getResourceClass() {
|
||||
return resourceClass;
|
||||
}
|
||||
public void setResourceClass(String resourceClass) {
|
||||
this.resourceClass = resourceClass;
|
||||
}
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
public String getResourceFileName() {
|
||||
return resourceFileName;
|
||||
}
|
||||
public void setResourceFileName(String resourceFileName) {
|
||||
this.resourceFileName = resourceFileName;
|
||||
}
|
||||
public short[] getResourceMaxCaps() {
|
||||
return resourceMaxCaps;
|
||||
}
|
||||
public void setResourceMaxCaps(short[] resourceMaxCaps) {
|
||||
this.resourceMaxCaps = resourceMaxCaps;
|
||||
}
|
||||
public short[] getResourceMinCaps() {
|
||||
return resourceMinCaps;
|
||||
}
|
||||
public void setResourceMinCaps(short[] resourceMinCaps) {
|
||||
this.resourceMinCaps = resourceMinCaps;
|
||||
}
|
||||
public Long getMinimalLifeTime() {
|
||||
return minimalLifeTime;
|
||||
}
|
||||
public void setMinimalLifeTime(Long minimalLifeTime) {
|
||||
this.minimalLifeTime = minimalLifeTime;
|
||||
}
|
||||
public Long getMaximalLifeTime() {
|
||||
return maximalLifeTime;
|
||||
}
|
||||
public void setMaximalLifeTime(Long maximalLifeTime) {
|
||||
this.maximalLifeTime = maximalLifeTime;
|
||||
}
|
||||
|
||||
public byte getGeneralType(){
|
||||
return generalType;
|
||||
}
|
||||
|
||||
public void setgeneralType(byte generalType){
|
||||
this.generalType = generalType;
|
||||
}
|
||||
|
||||
public byte getContainerType() {
|
||||
return containerType;
|
||||
}
|
||||
|
||||
public void setContainerType(byte containerType) {
|
||||
this.containerType = containerType;
|
||||
}
|
||||
|
||||
public void setGeneralType(byte generalType) {
|
||||
this.generalType = generalType;
|
||||
}
|
||||
|
||||
public int getResourceRootID() {
|
||||
return resourceRootID;
|
||||
}
|
||||
|
||||
public void setResourceRootID(int resourceRootID) {
|
||||
this.resourceRootID = resourceRootID;
|
||||
}
|
||||
|
||||
public void createTransaction(Environment env) { txn = env.beginTransaction(null, null);}
|
||||
|
||||
public Transaction getTransaction() { return txn; }
|
||||
|
||||
}
|
||||
@@ -51,9 +51,9 @@ public class TangibleMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.put(getUnicodeString(object.getCustomName()));
|
||||
buffer.putInt(object.getVolume());
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0); // faction vars
|
||||
buffer.putInt(tangible.getFactionStatus()); // faction vars
|
||||
|
||||
if(tangible.getCustomization() == null || tangible.getCustomization().length < 1)
|
||||
if(tangible.getCustomization() == null || tangible.getCustomization().length <= 0)
|
||||
buffer.putShort((short) 0);
|
||||
else {
|
||||
buffer.putShort((short) tangible.getCustomization().length);
|
||||
@@ -64,8 +64,10 @@ public class TangibleMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(0);
|
||||
|
||||
//buffer.putInt(0);
|
||||
if(tangible.getOptionsBitmask() == 0)
|
||||
tangible.setOptionsBitmask(0x100);
|
||||
buffer.putInt(tangible.getOptionsBitmask());
|
||||
buffer.putInt(0); // number of item uses
|
||||
buffer.putInt(tangible.getUses()); // number of item uses
|
||||
buffer.putInt(tangible.getConditionDamage());
|
||||
buffer.putInt(tangible.getMaxDamage());
|
||||
buffer.put((byte) (tangible.isStaticObject() ? 1 : 0));
|
||||
@@ -138,6 +140,70 @@ public class TangibleMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildCustomNameDelta(String customName) {
|
||||
IoBuffer buffer = bufferPool.allocate(getUnicodeString(customName).length, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put(getUnicodeString(customName));
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("TANO", (byte) 3, (short) 1, (short) 2, buffer, size + 4);
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildCustomizationDelta(byte[] customization) {
|
||||
IoBuffer buffer = bufferPool.allocate(customization.length, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(customization);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("TANO", (byte) 3, (short) 1, (short) 6, buffer, size + 4);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDelta3() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(getObject().getObjectID());
|
||||
buffer.putInt(0x54414E4F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(8);//buffer.putInt(8+6);
|
||||
|
||||
buffer.putShort((short) 2);
|
||||
buffer.putShort((short)8);
|
||||
buffer.put((byte)0);
|
||||
buffer.putShort((short) 0x21);
|
||||
buffer.put((byte)0);
|
||||
|
||||
// buffer.putShort((short) 0);
|
||||
// buffer.putFloat(4.0F);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
public IoBuffer buildAssemblyDelta3() {
|
||||
IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putShort((short)5);
|
||||
buffer.putInt(0x12862153);
|
||||
buffer.putLong(getObject().getObjectID());
|
||||
buffer.putInt(0x54414E4F);
|
||||
buffer.put((byte)3);
|
||||
buffer.putInt(8);//buffer.putInt(8+6);
|
||||
|
||||
buffer.putShort((short) 1);
|
||||
buffer.putShort((short)0x0B);
|
||||
buffer.putInt(0x000003E8); // ?
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -21,30 +21,40 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.tangible;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.PlayClientEffectObjectMessage;
|
||||
import protocol.swg.StopClientEffectObjectByLabel;
|
||||
import protocol.swg.UpdatePVPStatusMessage;
|
||||
import protocol.swg.objectControllerObjects.ShowFlyText;
|
||||
|
||||
import resources.common.OutOfBand;
|
||||
import resources.common.RGB;
|
||||
import resources.datatables.Options;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.loot.LootGroup;
|
||||
import resources.visitors.IDManagerVisitor;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
@Persistent(version=11)
|
||||
public class TangibleObject extends SWGObject {
|
||||
|
||||
// TODO: Thread safety
|
||||
@@ -54,10 +64,13 @@ public class TangibleObject extends SWGObject {
|
||||
protected int pvpBitmask = 0;
|
||||
protected byte[] customization;
|
||||
private List<Integer> componentCustomizations = new ArrayList<Integer>();
|
||||
private Map<String, Byte> customizationVariables = new HashMap<String, Byte>();
|
||||
protected int optionsBitmask = 0;
|
||||
private int uses = 0;
|
||||
private int maxDamage = 1000;
|
||||
private boolean staticObject = true;
|
||||
protected String faction = "neutral"; // Says you're "Imperial Special Forces" if it's 0 for some reason
|
||||
protected String faction = ""; // Says you're "Imperial Special Forces" if it's 0 for some reason
|
||||
protected int factionStatus = 0;
|
||||
@NotPersistent
|
||||
private Vector<TangibleObject> defendersList = new Vector<TangibleObject>(); // unused in packets but useful for the server
|
||||
@NotPersistent
|
||||
@@ -66,6 +79,27 @@ public class TangibleObject extends SWGObject {
|
||||
private int respawnTime = 0;
|
||||
private Point3D spawnCoordinates = new Point3D(0, 0, 0);
|
||||
|
||||
//private TreeSet<TreeMap<String,Integer>> lootSpecification = new TreeSet<TreeMap<String,Integer>>();
|
||||
private List<LootGroup> lootGroups = new ArrayList<LootGroup>();
|
||||
|
||||
@NotPersistent
|
||||
private boolean looted = false; // These 4 should not need to be persisted, since a looted corpse will get wiped with server restart
|
||||
@NotPersistent
|
||||
private boolean lootLock = false;
|
||||
@NotPersistent
|
||||
private boolean creditRelieved = false;
|
||||
@NotPersistent
|
||||
private boolean lootItem = false;
|
||||
|
||||
private boolean stackable = false;
|
||||
private int stackCount = 1;
|
||||
private boolean noSell = false;
|
||||
private byte junkType = -1;
|
||||
private int junkDealerPrice = 0;
|
||||
|
||||
|
||||
private String serialNumber;
|
||||
|
||||
@NotPersistent
|
||||
private TangibleObject killer = null;
|
||||
|
||||
@@ -86,6 +120,12 @@ public class TangibleObject extends SWGObject {
|
||||
super();
|
||||
messageBuilder = new TangibleMessageBuilder(this);
|
||||
}
|
||||
|
||||
public void setCustomName2(String customName) {
|
||||
setCustomName(customName);
|
||||
|
||||
notifyObservers(messageBuilder.buildCustomNameDelta(customName), true);
|
||||
}
|
||||
|
||||
public int getIncapTimer() {
|
||||
return incapTimer;
|
||||
@@ -94,6 +134,15 @@ public class TangibleObject extends SWGObject {
|
||||
public void setIncapTimer(int incapTimer) {
|
||||
this.incapTimer = incapTimer;
|
||||
}
|
||||
|
||||
public int getUses() {
|
||||
return uses;
|
||||
}
|
||||
|
||||
public void setUses(int uses) {
|
||||
this.uses = uses;
|
||||
setIntAttribute("uses", uses);
|
||||
}
|
||||
|
||||
public synchronized int getConditionDamage() {
|
||||
return conditionDamage;
|
||||
@@ -116,7 +165,11 @@ public class TangibleObject extends SWGObject {
|
||||
}
|
||||
|
||||
public void setCustomization(byte[] customization) {
|
||||
this.customization = customization;
|
||||
synchronized(objectMutex) {
|
||||
this.customization = customization;
|
||||
}
|
||||
|
||||
notifyObservers(messageBuilder.buildCustomizationDelta(customization), false);
|
||||
}
|
||||
|
||||
public List<Integer> getComponentCustomizations() {
|
||||
@@ -207,6 +260,75 @@ public class TangibleObject extends SWGObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//updatePvpStatus();
|
||||
}
|
||||
|
||||
public void updatePvpStatus() {
|
||||
HashSet<Client> observers = new HashSet<Client>(getObservers());
|
||||
|
||||
for (Iterator<Client> it = observers.iterator(); it.hasNext();) {
|
||||
Client observer = it.next();
|
||||
|
||||
if (observer.getParent() != null) {
|
||||
observer.getSession().write(new UpdatePVPStatusMessage(this.getObjectID(), NGECore.getInstance().factionService.calculatePvpStatus((CreatureObject) observer.getParent(), this), getFaction()).serialize());
|
||||
if(getClient() != null)
|
||||
getClient().getSession().write(new UpdatePVPStatusMessage(observer.getParent().getObjectID(), NGECore.getInstance().factionService.calculatePvpStatus((CreatureObject) this, (CreatureObject) observer.getParent()), getFaction()).serialize());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (getClient() != null) {
|
||||
CreatureObject companion = NGECore.getInstance().mountService.getCompanion((CreatureObject) this);
|
||||
|
||||
if (companion != null) {
|
||||
companion.updatePvpStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomizationVariable(String type, byte value)
|
||||
{
|
||||
if(customizationVariables.containsKey(type)) customizationVariables.replace(type, value);
|
||||
else customizationVariables.put(type, value);
|
||||
|
||||
buildCustomizationBytes();
|
||||
}
|
||||
|
||||
public void removeCustomizationVariable(String type)
|
||||
{
|
||||
if(customizationVariables.containsKey(type))
|
||||
{
|
||||
customizationVariables.remove(type);
|
||||
buildCustomizationBytes();
|
||||
}
|
||||
}
|
||||
|
||||
private void buildCustomizationBytes()
|
||||
{
|
||||
//if(customizationVariables.size() == 0) customization = { 0x00 };
|
||||
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
try
|
||||
{
|
||||
IDManagerVisitor visitor = ClientFileManager.loadFile("customization/customization_id_manager.iff", IDManagerVisitor.class);
|
||||
|
||||
stream.write((byte)0x02); // Unk
|
||||
stream.write((byte)customizationVariables.size()); // Number of customization attributes
|
||||
|
||||
for(String type : customizationVariables.keySet())
|
||||
{
|
||||
stream.write(visitor.getAttributeIndex(type)); // Index of palette type within "customization/customization_id_manager.iff"
|
||||
stream.write(customizationVariables.get(type)); // Value/Index within palette
|
||||
|
||||
// Seperator/Footer
|
||||
stream.write((byte) 0xC3);
|
||||
stream.write((byte) 0xBF);
|
||||
stream.write((byte) 0x03);
|
||||
}
|
||||
customization = stream.toByteArray();
|
||||
}
|
||||
catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
public String getFaction() {
|
||||
@@ -219,14 +341,30 @@ public class TangibleObject extends SWGObject {
|
||||
synchronized(objectMutex) {
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
updatePvpStatus();
|
||||
}
|
||||
|
||||
|
||||
public int getFactionStatus() {
|
||||
synchronized(objectMutex) {
|
||||
return factionStatus;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFactionStatus(int factionStatus) {
|
||||
synchronized(objectMutex) {
|
||||
this.factionStatus = factionStatus;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<TangibleObject> getDefendersList() {
|
||||
return defendersList;
|
||||
synchronized(objectMutex) {
|
||||
return defendersList;
|
||||
}
|
||||
}
|
||||
|
||||
public void addDefender(TangibleObject defender) {
|
||||
|
||||
|
||||
defendersList.add(defender);
|
||||
|
||||
if(this instanceof CreatureObject) {
|
||||
@@ -285,32 +423,39 @@ public class TangibleObject extends SWGObject {
|
||||
|
||||
return getPvPBitmask() == 1 || getPvPBitmask() == 2;
|
||||
|
||||
}
|
||||
} else if(attacker.getSlottedObject("ghost") == null)
|
||||
return true;
|
||||
|
||||
return getPvPBitmask() == 1 || getPvPBitmask() == 2;
|
||||
}
|
||||
|
||||
public void showFlyText(String stfFile, String stfString, float scale, RGB color, int displayType) {
|
||||
Set<Client> observers = getObservers();
|
||||
|
||||
if (getClient() != null) {
|
||||
getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), stfFile, stfString, scale, color, displayType))).serialize());
|
||||
}
|
||||
|
||||
for (Client client : observers) {
|
||||
client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), stfFile, stfString, scale, color, displayType))).serialize());
|
||||
}
|
||||
public void showFlyText(OutOfBand outOfBand, float scale, RGB color, int displayType, boolean notifyObservers) {
|
||||
showFlyText("", outOfBand, scale, color, displayType, notifyObservers);
|
||||
}
|
||||
|
||||
public void showFlyText(String stfFile, String stfString, String customText, int xp, float scale, RGB color, int displayType) {
|
||||
Set<Client> observers = getObservers();
|
||||
|
||||
if (getClient() != null) {
|
||||
getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), 56, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize());
|
||||
public void showFlyText(String stf, float scale, RGB color, int displayType, boolean notifyObservers) {
|
||||
showFlyText(stf, new OutOfBand(), scale, color, displayType, notifyObservers);
|
||||
}
|
||||
|
||||
public void showFlyText(String stf, OutOfBand outOfBand, float scale, RGB color, int displayType, boolean notifyObservers) {
|
||||
if (outOfBand == null) {
|
||||
outOfBand = new OutOfBand();
|
||||
}
|
||||
|
||||
for (Client client : observers) {
|
||||
client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), 56, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize());
|
||||
if (color == null) {
|
||||
color = new RGB(255, 255, 255);
|
||||
}
|
||||
|
||||
if (getClient() != null) {
|
||||
getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), stf, outOfBand, scale, color, displayType))).serialize());
|
||||
}
|
||||
|
||||
if (notifyObservers) {
|
||||
Set<Client> observers = getObservers();
|
||||
|
||||
for (Client client : observers) {
|
||||
client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), stf, outOfBand, scale, color, displayType))).serialize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +491,114 @@ public class TangibleObject extends SWGObject {
|
||||
}
|
||||
}
|
||||
|
||||
public List<LootGroup> getLootGroups() {
|
||||
return lootGroups;
|
||||
}
|
||||
|
||||
public void addToLootGroups(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance) {
|
||||
System.out.println("lootPoolNames[0] " + lootPoolNames[0]);
|
||||
LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance);
|
||||
this.lootGroups.add(lootGroup);
|
||||
}
|
||||
|
||||
public boolean isLooted() {
|
||||
return looted;
|
||||
}
|
||||
|
||||
public void setLooted(boolean looted) {
|
||||
this.looted = looted;
|
||||
}
|
||||
|
||||
public boolean isLootLock() {
|
||||
return lootLock;
|
||||
}
|
||||
|
||||
public void setLootLock(boolean lootLock) {
|
||||
this.lootLock = lootLock;
|
||||
}
|
||||
|
||||
public boolean isLootItem() {
|
||||
return lootItem;
|
||||
}
|
||||
|
||||
public void setLootItem(boolean lootItem) {
|
||||
this.lootItem = lootItem;
|
||||
}
|
||||
|
||||
public boolean isStackable() {
|
||||
return stackable;
|
||||
}
|
||||
|
||||
public void setStackable(boolean stackable) {
|
||||
this.stackable = stackable;
|
||||
}
|
||||
|
||||
public int getStackCount() {
|
||||
return stackCount;
|
||||
}
|
||||
|
||||
public void setStackCount(int stackCount) {
|
||||
this.stackCount = stackCount;
|
||||
}
|
||||
|
||||
public boolean isNoSell() {
|
||||
return noSell;
|
||||
}
|
||||
|
||||
public void setNoSell(boolean noSell) {
|
||||
this.noSell = noSell;
|
||||
}
|
||||
|
||||
public byte getJunkType() {
|
||||
return junkType;
|
||||
}
|
||||
|
||||
public void setJunkType(byte junkType) {
|
||||
this.junkType = junkType;
|
||||
}
|
||||
|
||||
public int getJunkDealerPrice() {
|
||||
return junkDealerPrice;
|
||||
}
|
||||
|
||||
public void setJunkDealerPrice(int junkDealerPrice) {
|
||||
this.junkDealerPrice = junkDealerPrice;
|
||||
}
|
||||
|
||||
public boolean isCreditRelieved() {
|
||||
return creditRelieved;
|
||||
}
|
||||
|
||||
public void setCreditRelieved(boolean creditRelieved) {
|
||||
if (creditRelieved)
|
||||
this.creditRelieved = creditRelieved; // only allow one state change to prevent hacking
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
return getStringAttribute("serial_number");
|
||||
}
|
||||
|
||||
public void setSerialNumber(String serialNumber) {
|
||||
setStringAttribute("serial_number", serialNumber);
|
||||
setOptions(Options.SERIAL, true);
|
||||
}
|
||||
|
||||
public void sendDelta3(Client destination) {
|
||||
destination.getSession().write(messageBuilder.buildDelta3());
|
||||
//tools.CharonPacketUtils.printAnalysis(messageBuilder.buildDelta3(),"TANO3 Delta");
|
||||
}
|
||||
|
||||
public void sendAssemblyDelta3(Client destination) {
|
||||
destination.getSession().write(messageBuilder.buildAssemblyDelta3());
|
||||
//tools.CharonPacketUtils.printAnalysis(messageBuilder.buildAssemblyDelta3(),"TANO3 Assembly Delta");
|
||||
}
|
||||
|
||||
public void sendCustomizationDelta3(Client destination, String enteredName){
|
||||
destination.getSession().write(messageBuilder.buildCustomNameDelta(enteredName));
|
||||
//tools.CharonPacketUtils.printAnalysis(messageBuilder.buildCustomNameDelta(enteredName),"TANO3 Customization Delta");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
@@ -357,8 +610,8 @@ public class TangibleObject extends SWGObject {
|
||||
|
||||
destination.getSession().write(messageBuilder.buildBaseline3());
|
||||
destination.getSession().write(messageBuilder.buildBaseline6());
|
||||
//destination.getSession().write(messageBuilder.buildBaseline8());
|
||||
//destination.getSession().write(messageBuilder.buildBaseline9());
|
||||
destination.getSession().write(messageBuilder.buildBaseline8());
|
||||
destination.getSession().write(messageBuilder.buildBaseline9());
|
||||
|
||||
if(getPvPBitmask() != 0) {
|
||||
UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID());
|
||||
@@ -369,5 +622,4 @@ public class TangibleObject extends SWGObject {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.objects.tool;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceConcentration;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class SurveyTool extends TangibleObject{
|
||||
|
||||
private byte toolType=0;
|
||||
private long surveyResourceID;
|
||||
private long userID=0;
|
||||
private Long tanoID=0L;
|
||||
private byte SurveyRangeSetting=0;
|
||||
|
||||
@NotPersistent
|
||||
private String surveyEffectString="";
|
||||
@NotPersistent
|
||||
private String sampleEffectString="";
|
||||
@NotPersistent
|
||||
private boolean currentlySurveying=false;
|
||||
@NotPersistent
|
||||
private boolean currentlySampling=false;
|
||||
@NotPersistent
|
||||
private boolean currentlyCoolingDown=false;
|
||||
@NotPersistent
|
||||
private boolean exceptionalState=false;
|
||||
@NotPersistent
|
||||
private boolean recoveryMode=false;
|
||||
@NotPersistent
|
||||
private Long lastSurveyTime=0L;
|
||||
@NotPersistent
|
||||
private Long lastSampleTime=0L;
|
||||
@NotPersistent
|
||||
private Long recoveryTime=10L;
|
||||
|
||||
public static byte MineralSurveyDevice = 1;
|
||||
public static byte ChemicalSurveyDevice = 2;
|
||||
public static byte FloraSurveyTool = 3;
|
||||
public static byte GasPocketSurveyDevice = 4;
|
||||
public static byte WaterSurveyDevice = 5;
|
||||
public static byte WindCurrentSurveyingTool = 6;
|
||||
public static byte AmbientSolarEnergySurveyingTool = 7;
|
||||
public static byte CompleteResourceSurveyDevice = 8;
|
||||
|
||||
public SurveyTool() {
|
||||
super();
|
||||
this.exceptionalState = false;
|
||||
}
|
||||
|
||||
public SurveyTool(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
surveyEffectString = "";
|
||||
sampleEffectString = "";
|
||||
this.tanoID = objectID;
|
||||
this.exceptionalState = false;
|
||||
this.recoveryMode = false;
|
||||
switch (template) {
|
||||
case "object/tangible/survey_tool/shared_survey_tool_mineral.iff" :
|
||||
toolType = 1;
|
||||
surveyEffectString = "clienteffect/survey_tool_mineral.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_mineral.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_inorganic.iff" :
|
||||
toolType = 2;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_lumber.iff" :
|
||||
toolType = 3;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_gas.iff" :
|
||||
toolType = 4;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_moisture.iff" :
|
||||
toolType = 5;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_wind.iff" :
|
||||
toolType = 6;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_solar.iff" :
|
||||
toolType = 7;
|
||||
surveyEffectString = "clienteffect/survey_tool_moisture.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_moisture.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_all.iff" :
|
||||
toolType = 8;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
default: toolType = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public SurveyTool(String template, Long tanoID) {
|
||||
super();
|
||||
surveyEffectString = "";
|
||||
sampleEffectString = "";
|
||||
this.tanoID = tanoID;
|
||||
this.exceptionalState = false;
|
||||
switch (template) {
|
||||
case "object/tangible/survey_tool/shared_survey_tool_mineral.iff" :
|
||||
toolType = 1;
|
||||
surveyEffectString = "clienteffect/survey_tool_mineral.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_mineral.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_inorganic.iff" :
|
||||
toolType = 2;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_lumber.iff" :
|
||||
toolType = 3;
|
||||
surveyEffectString = "clienteffect/survey_tool_lumber.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_lumber.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_gas.iff" :
|
||||
toolType = 4;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_moisture.iff" :
|
||||
toolType = 5;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_wind.iff" :
|
||||
toolType = 6;
|
||||
surveyEffectString = "clienteffect/survey_tool_gas.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_gas.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_solar.iff" :
|
||||
toolType = 7;
|
||||
surveyEffectString = "clienteffect/survey_tool_moisture.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_moisture.cef";
|
||||
break;
|
||||
case "object/tangible/survey_tool/shared_survey_tool_all.iff" :
|
||||
toolType = 8;
|
||||
surveyEffectString = "clienteffect/survey_tool_liquid.cef";
|
||||
sampleEffectString = "clienteffect/survey_sample_liquid.cef";
|
||||
break;
|
||||
default: toolType = -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setToolType(byte toolType) {
|
||||
this.toolType = toolType;
|
||||
}
|
||||
|
||||
public byte getToolType() {
|
||||
return this.toolType;
|
||||
}
|
||||
|
||||
public String getSurveyEffectString() {
|
||||
return surveyEffectString;
|
||||
}
|
||||
|
||||
public String getSampleEffectString() {
|
||||
return sampleEffectString;
|
||||
}
|
||||
|
||||
public void setCurrentlySurveying(boolean toggle){
|
||||
this.currentlySurveying=toggle;
|
||||
}
|
||||
|
||||
public boolean getCurrentlySurveying(){
|
||||
return this.currentlySurveying;
|
||||
}
|
||||
|
||||
public void setCurrentlySampling(boolean toggle){
|
||||
this.currentlySampling=toggle;
|
||||
}
|
||||
|
||||
public boolean getCurrentlySampling(){
|
||||
return this.currentlySampling;
|
||||
}
|
||||
|
||||
public void setLastSurveyTime(Long time){
|
||||
this.lastSurveyTime = time;
|
||||
}
|
||||
|
||||
public Long getLastSurveyTime(){
|
||||
return this.lastSurveyTime;
|
||||
}
|
||||
|
||||
public void setLastSampleTime(Long time){
|
||||
this.lastSampleTime = time;
|
||||
}
|
||||
|
||||
public Long getLastSampleTime(){
|
||||
return this.lastSampleTime;
|
||||
}
|
||||
|
||||
public void setSurveyResourceID(long surveyResourceID){
|
||||
this.surveyResourceID = surveyResourceID;
|
||||
}
|
||||
|
||||
public long getSurveyResourceID(){
|
||||
return this.surveyResourceID;
|
||||
}
|
||||
|
||||
public boolean getCurrentlyCoolingDown() {
|
||||
return currentlyCoolingDown;
|
||||
}
|
||||
|
||||
public void setCurrentlyCoolingDown(boolean currentlyCoolingDown) {
|
||||
this.currentlyCoolingDown = currentlyCoolingDown;
|
||||
}
|
||||
|
||||
public Long getRecoveryTime() {
|
||||
return recoveryTime;
|
||||
}
|
||||
|
||||
public void setRecoveryTime(Long recoveryTime) {
|
||||
this.recoveryTime = recoveryTime;
|
||||
}
|
||||
|
||||
public long getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public void setUserID(long userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public Long getTanoID() {
|
||||
return tanoID;
|
||||
}
|
||||
|
||||
public void setTanoID(Long tanoID) {
|
||||
this.tanoID = tanoID;
|
||||
}
|
||||
|
||||
public boolean isExceptionalState() {
|
||||
return exceptionalState;
|
||||
}
|
||||
|
||||
public void setExceptionalState(boolean exceptionalState) {
|
||||
this.exceptionalState = exceptionalState;
|
||||
}
|
||||
|
||||
public boolean isRecoveryMode() {
|
||||
return this.recoveryMode;
|
||||
}
|
||||
|
||||
public void setRecoveryMode(boolean recoveryMode) {
|
||||
this.recoveryMode = recoveryMode;
|
||||
}
|
||||
|
||||
public byte getSurveyRangeSetting() {
|
||||
return SurveyRangeSetting;
|
||||
}
|
||||
|
||||
public void setSurveyRangeSetting(byte surveyRangeSetting) {
|
||||
SurveyRangeSetting = surveyRangeSetting;
|
||||
}
|
||||
|
||||
public void sendConstructSurveyMapMessage(){
|
||||
float surveyRadius = 64.0f;
|
||||
int surveyToolRangeSetting = this.getSurveyRangeSetting();
|
||||
//surveyToolRangeSetting = 4;
|
||||
int divisor = 0;
|
||||
if (surveyToolRangeSetting==0) {
|
||||
divisor = 2;
|
||||
surveyRadius = 64.0f;
|
||||
} else if (surveyToolRangeSetting==1) {
|
||||
divisor = 3;
|
||||
surveyRadius = 128.0f;
|
||||
} else if (surveyToolRangeSetting==2) {
|
||||
divisor = 3;
|
||||
surveyRadius = 192.0f;
|
||||
} else if (surveyToolRangeSetting==3) {
|
||||
divisor = 4;
|
||||
surveyRadius = 256.0f;
|
||||
} else if (surveyToolRangeSetting==4) {
|
||||
divisor = 4;
|
||||
surveyRadius = 320.0f;
|
||||
} else {
|
||||
divisor = 5;
|
||||
surveyRadius = 3072.0f;
|
||||
}
|
||||
|
||||
float differential = surveyRadius / (float) divisor;
|
||||
GalacticResource resourceToSurvey = (GalacticResource) NGECore.getInstance().objectService.getObject(this.getSurveyResourceID());
|
||||
CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(this.getUserID());
|
||||
if (resourceToSurvey==null || user==null)
|
||||
return;
|
||||
Vector<ResourceConcentration> concentrationMap = resourceToSurvey.buildConcentrationsCollection(user.getPosition(),resourceToSurvey, surveyRadius, differential, user.getPlanetId());
|
||||
resourceToSurvey.constructSurveyMapMessage(user, concentrationMap, surveyRadius);
|
||||
//this.getUser().sendSystemMessage("Distance to nearest Deposit : " + this.getSurveyResource().getHelperMinDist(), (byte) 0);
|
||||
}
|
||||
}
|
||||
@@ -26,14 +26,14 @@ import java.nio.ByteOrder;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
|
||||
import resources.datatables.Elemental;
|
||||
|
||||
public class WeaponMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
public WeaponMessageBuilder(WeaponObject weaponObject) {
|
||||
setObject(weaponObject);
|
||||
}
|
||||
|
||||
|
||||
public IoBuffer buildBaseline3() {
|
||||
WeaponObject weapon = (WeaponObject) object;
|
||||
IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
@@ -68,11 +68,12 @@ public class WeaponMessageBuilder extends ObjectMessageBuilder {
|
||||
buffer.putInt(0);
|
||||
buffer.putFloat(weapon.getMaxRange());
|
||||
buffer.putInt(0);
|
||||
|
||||
if( weapon.getElementalType() != null) // Weapon particle effect
|
||||
buffer.putInt(Elemental.getElementalNum(weapon.getElementalType()));
|
||||
else
|
||||
buffer.putInt(Elemental.getElementalNum(weapon.getDamageType()));
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(0); // those 2 ints have something to do with particle color
|
||||
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.weapon;
|
||||
|
||||
import resources.datatables.WeaponType;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
@@ -31,7 +32,7 @@ import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
@Persistent(version=1)
|
||||
public class WeaponObject extends TangibleObject {
|
||||
|
||||
// TODO: Thread safety
|
||||
@@ -39,53 +40,24 @@ public class WeaponObject extends TangibleObject {
|
||||
@NotPersistent
|
||||
private WeaponMessageBuilder messageBuilder;
|
||||
|
||||
private float attackSpeed = 1;
|
||||
private float maxRange;
|
||||
|
||||
public WeaponObject(long objectID, Planet planet, String template) {
|
||||
super(objectID, planet, template, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0));
|
||||
messageBuilder = new WeaponMessageBuilder(this);
|
||||
if (this.getClass().getSimpleName().equals("WeaponObject")) setIntAttribute("volume", 1);
|
||||
calculateRange();
|
||||
calculateAttackSpeed();
|
||||
setStringAttribute("cat_wpn_damage.damage", "0-0");
|
||||
}
|
||||
|
||||
public WeaponObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) {
|
||||
super(objectID, planet, template, position, orientation);
|
||||
messageBuilder = new WeaponMessageBuilder(this);
|
||||
if (this.getClass().getSimpleName().equals("WeaponObject")) setIntAttribute("volume", 1);
|
||||
calculateRange();
|
||||
calculateAttackSpeed();
|
||||
setStringAttribute("cat_wpn_damage.damage", "0-0");
|
||||
}
|
||||
|
||||
|
||||
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 12: 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() {
|
||||
@@ -118,7 +90,9 @@ public class WeaponObject extends TangibleObject {
|
||||
}
|
||||
|
||||
public void setMaxDamage(int maxDamage) {
|
||||
|
||||
setStringAttribute("cat_wpn_damage.damage", String.valueOf(getMinDamage()) + "-" + String.valueOf(maxDamage));
|
||||
setIntAttribute("cat_wpn_damage.dps", getDamagePerSecond());
|
||||
}
|
||||
|
||||
public int getMinDamage() {
|
||||
@@ -126,7 +100,9 @@ public class WeaponObject extends TangibleObject {
|
||||
}
|
||||
|
||||
public void setMinDamage(int minDamage) {
|
||||
|
||||
setStringAttribute("cat_wpn_damage.damage", String.valueOf(minDamage) + "-" + String.valueOf(getMaxDamage()));
|
||||
setIntAttribute("cat_wpn_damage.dps", getDamagePerSecond());
|
||||
}
|
||||
|
||||
public int getElementalDamage() {
|
||||
@@ -135,55 +111,44 @@ public class WeaponObject extends TangibleObject {
|
||||
|
||||
public void setElementalDamage(int elementalDamage) {
|
||||
setIntAttribute("cat_wpn_damage.wpn_elemental_value", elementalDamage);
|
||||
setIntAttribute("cat_wpn_damage.dps", getDamagePerSecond());
|
||||
}
|
||||
|
||||
public String getElementalType() {
|
||||
return getStringAttribute("cat_wpn_damage.wpn_elemental_type");
|
||||
if (getStringAttribute("cat_wpn_damage.wpn_elemental_type") != null )
|
||||
return getStringAttribute("cat_wpn_damage.wpn_elemental_type").replace("@obj_attr_n:elemental_", "");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setElementalType(String elementalType) {
|
||||
setStringAttribute("cat_wpn_damage.wpn_elemental_type", elementalType);
|
||||
setStringAttribute("cat_wpn_damage.wpn_elemental_type", "@obj_attr_n:elemental_" + elementalType);
|
||||
}
|
||||
|
||||
public String getDamageType() {
|
||||
return getStringAttribute("cat_wpn_damage.wpn_damage_type");
|
||||
return getStringAttribute("cat_wpn_damage.wpn_damage_type").replace("@obj_attr_n:armor_eff_", "");
|
||||
}
|
||||
|
||||
public void setDamageType(String damageType) {
|
||||
setStringAttribute("cat_wpn_damage.wpn_damage_type", damageType);
|
||||
setStringAttribute("cat_wpn_damage.wpn_damage_type", "@obj_attr_n:armor_eff_" + damageType);
|
||||
}
|
||||
|
||||
public int getDamagePerSecond() {
|
||||
return (int) (((getMaxDamage() + getElementalDamage() + getMinDamage() + getElementalDamage()) / 2 + getElementalDamage()) * (1 / getAttackSpeed()));
|
||||
if(getAttributes().containsKey("cat_wpn_damage.damage") && getAttributes().containsKey("cat_wpn_damage.wpn_attack_speed")) {
|
||||
|
||||
if (getElementalType() != null )
|
||||
return (int) (((getMaxDamage() + getElementalDamage() + getMinDamage() + getElementalDamage()) / 2 + getElementalDamage()) * (1 / getAttackSpeed()));
|
||||
else
|
||||
return (int) (((getMaxDamage() + getMinDamage()) / 2 ) * (1 / getAttackSpeed()));
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getWeaponType() {
|
||||
|
||||
int weaponType = -1;
|
||||
|
||||
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;
|
||||
if(template.contains("heavy")) weaponType = 12;
|
||||
if(template.contains("sword") || template.contains("baton")) weaponType = 4;
|
||||
if(template.contains("2h_sword") || template.contains("axe")) weaponType = 5;
|
||||
if(template.contains("unarmed")) weaponType = 6;
|
||||
if(template.contains("polearm") || template.contains("lance")) weaponType = 7;
|
||||
if(template.contains("thrown")) weaponType = 8;
|
||||
if(template.contains("lightsaber_one_handed")) weaponType = 9;
|
||||
if(template.contains("lightsaber_two_handed")) weaponType = 10;
|
||||
if(template.contains("lightsaber_polearm")) weaponType = 11;
|
||||
|
||||
if(weaponType == -1)
|
||||
weaponType = 6;
|
||||
|
||||
return weaponType;
|
||||
|
||||
return Integer.parseInt(getStringAttribute("cat_wpn_damage.wpn_category").replace("@obj_attr_n:wpn_category_", ""));
|
||||
}
|
||||
|
||||
public void setWeaponType(int weaponType) {
|
||||
setStringAttribute("cat_wpn_damage.wpn_category", "@obj_attr_n:wpn_category_" + weaponType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -201,11 +166,16 @@ public class WeaponObject extends TangibleObject {
|
||||
}
|
||||
|
||||
public float getAttackSpeed() {
|
||||
return attackSpeed;
|
||||
return getFloatAttribute("cat_wpn_damage.wpn_attack_speed");
|
||||
}
|
||||
|
||||
public void setAttackSpeed(float attackSpeed) {
|
||||
this.attackSpeed = attackSpeed;
|
||||
if((int) attackSpeed != attackSpeed)
|
||||
setFloatAttribute("cat_wpn_damage.wpn_attack_speed", attackSpeed);
|
||||
else
|
||||
setIntAttribute("cat_wpn_damage.wpn_attack_speed", (int) attackSpeed);
|
||||
|
||||
setIntAttribute("cat_wpn_damage.dps", getDamagePerSecond());
|
||||
}
|
||||
|
||||
public WeaponMessageBuilder getMessageBuilder() {
|
||||
@@ -213,18 +183,21 @@ public class WeaponObject extends TangibleObject {
|
||||
}
|
||||
|
||||
public float getMaxRange() {
|
||||
return maxRange;
|
||||
return Float.parseFloat(getStringAttribute("cat_wpn_damage.wpn_range").replace("0-", "").replace("m", ""));
|
||||
}
|
||||
|
||||
public void setMaxRange(float maxRange) {
|
||||
this.maxRange = maxRange;
|
||||
if((int) maxRange != maxRange)
|
||||
setStringAttribute("cat_wpn_damage.wpn_range", "0-" + String.valueOf(maxRange) + "m");
|
||||
else
|
||||
setStringAttribute("cat_wpn_damage.wpn_range", "0-" + String.valueOf((int) maxRange) + "m");
|
||||
}
|
||||
|
||||
public boolean isMelee() {
|
||||
|
||||
int weaponType = getWeaponType();
|
||||
|
||||
if(weaponType == 4 || weaponType == 5 || weaponType == 6 || weaponType == 7 || weaponType == 9 || weaponType == 10 || weaponType == 11)
|
||||
if(weaponType == WeaponType.ONEHANDEDMELEE || weaponType == WeaponType.TWOHANDEDMELEE || weaponType == WeaponType.UNARMED || weaponType == WeaponType.POLEARMMELEE || weaponType == WeaponType.ONEHANDEDSABER || weaponType == WeaponType.TWOHANDEDSABER || weaponType == WeaponType.POLEARMSABER)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -235,35 +208,11 @@ public class WeaponObject extends TangibleObject {
|
||||
|
||||
int weaponType = getWeaponType();
|
||||
|
||||
if(weaponType == 0 || weaponType == 1 || weaponType == 2 || weaponType == 3)
|
||||
if(weaponType == WeaponType.RIFLE || weaponType == WeaponType.CARBINE || weaponType == WeaponType.PISTOL || weaponType == WeaponType.FLAMETHROWER || weaponType == WeaponType.HEAVYWEAPON)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private void calculateAttackSpeed() {
|
||||
|
||||
int weaponType = getWeaponType();
|
||||
|
||||
switch(weaponType) {
|
||||
|
||||
case 0: attackSpeed = 0.8f; break;
|
||||
case 1: attackSpeed = 0.6f; break;
|
||||
case 2: attackSpeed = 0.4f; break;
|
||||
case 12: attackSpeed = 1; break;
|
||||
case 4: attackSpeed = 1; break;
|
||||
case 5: attackSpeed = 1; break;
|
||||
case 6: attackSpeed = 1; break;
|
||||
case 7: attackSpeed = 1; break;
|
||||
case 8: attackSpeed = 1; break;
|
||||
case 9: attackSpeed = 1; break;
|
||||
case 10: attackSpeed = 1; break;
|
||||
case 11: attackSpeed = 1; break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user