This commit is contained in:
Treeku
2014-05-12 17:50:59 +01:00
6 changed files with 65 additions and 11 deletions
@@ -84,7 +84,7 @@ public class TangibleObject extends SWGObject implements Serializable {
private transient TangibleMessageBuilder messageBuilder;
//private TreeSet<TreeMap<String,Integer>> lootSpecification = new TreeSet<TreeMap<String,Integer>>();
private List<LootGroup> lootGroups = new ArrayList<LootGroup>();
private transient List<LootGroup> lootGroups = new ArrayList<LootGroup>();
@NotPersistent
private transient boolean looted = false; // These 4 should not need to be persisted, since a looted corpse will get wiped with server restart
@@ -507,13 +507,22 @@ public class TangibleObject extends SWGObject implements Serializable {
public List<LootGroup> getLootGroups() {
return lootGroups;
}
public void setLootGroups(List<LootGroup> lootGroups) {
this.lootGroups = lootGroups;
}
public void addToLootGroups(String[] lootPoolNames, double[] lootPoolChances, double lootGroupChance) {
System.out.println("lootPoolNames[0] " + lootPoolNames[0]);
//System.out.println("lootPoolNames[0] " + lootPoolNames[0]);
LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance);
this.lootGroups.add(lootGroup);
}
public void addToLootGroups(LootGroup lootGroup) {
this.lootGroups.add(lootGroup);
}
public boolean isLooted() {
return looted;
}
+22 -3
View File
@@ -36,6 +36,8 @@ import java.util.Map;
import resources.common.FileUtilities;
import resources.objects.building.BuildingObject;
import resources.objects.cell.CellObject;
import services.ai.AIActor;
import services.spawn.MobileTemplate;
import main.NGECore;
import engine.clientdata.ClientFileManager;
import engine.clientdata.visitors.PortalVisitor;
@@ -94,6 +96,11 @@ public class StaticService implements INetworkDispatch {
}
public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ) {
return spawnObject(template, planetName, cellId, x, y, z, qW, qX, qY, qZ, -1);
}
public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ, int respawnTime) {
Planet planet = core.terrainService.getPlanetByName(planetName);
if (planet == null) {
@@ -113,10 +120,22 @@ public class StaticService implements INetworkDispatch {
long objectId = core.objectService.getDOId(planetName, template, 0, buildingId, cellNumber, x, y, z);
SWGObject object;
SWGObject object = null;
MobileTemplate mobileTemplate = core.spawnService.getMobileTemplate(template);
if (core.spawnService.getMobileTemplate(template) != null) {
object = core.spawnService.spawnCreature(template, objectId, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1);
if (mobileTemplate != null) {
if(respawnTime > 0) {
try {
MobileTemplate clone = (MobileTemplate) mobileTemplate.clone();
object = core.spawnService.spawnCreature(template, objectId, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1);
clone.setRespawnTime(respawnTime);
((AIActor) object.getAttachment("AI")).setMobileTemplate(clone);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
} else {
object = core.spawnService.spawnCreature(template, objectId, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1);
}
} else {
object = core.objectService.createObject(template, objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ), null, true, true);
}
+3 -3
View File
@@ -214,9 +214,9 @@ public class BaseSWGCommand implements Cloneable {
this.commandCRC = commandCRC;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
public boolean isGmCommand() {
return (godLevel > 0);
+3 -2
View File
@@ -128,7 +128,7 @@ public class HousingService implements INetworkDispatch {
String playerFirstName = actor.getCustomName().split(" ")[0];
if (sign != null) {
sign.setCustomName2(playerFirstName + "'s House");
sign.setCustomName(playerFirstName + "'s House");
}
//building.add(sign);
@@ -168,7 +168,8 @@ public class HousingService implements INetworkDispatch {
}
}
//core.objectService.persistObject(building.getObjectID(), building, core.getSWGObjectODB());
core.objectService.persistObject(building.getObjectID(), building, core.getSWGObjectODB());
core.getSWGObjectODB().getEnvironment().sync();
}
+23 -1
View File
@@ -21,12 +21,14 @@
******************************************************************************/
package services.spawn;
import java.util.List;
import java.util.Vector;
import resources.datatables.Options;
import resources.datatables.PvpStatus;
import resources.loot.LootGroup;
public class MobileTemplate {
public class MobileTemplate implements Cloneable {
private Vector<String> templates;
private int optionBitmask = Options.ATTACKABLE;
@@ -57,6 +59,8 @@ public class MobileTemplate {
private String meatType, milkType, boneType, hideType;
private int meatAmount, milkAmount, boneAmount, hideAmount;
private int respawnTime = 0;
private List<LootGroup> lootGroups;
public Vector<String> getTemplates() {
return templates;
@@ -337,5 +341,23 @@ public class MobileTemplate {
public void setRespawnTime(int respawnTime) {
this.respawnTime = respawnTime;
}
public List<LootGroup> getLootGroups() {
return lootGroups;
}
public void setLootGroups(List<LootGroup> lootGroups) {
this.lootGroups = lootGroups;
}
public void addToLootGroups(String[] lootPoolNames, double[] lootPoolChances, double lootGroupChance) {
//System.out.println("lootPoolNames[0] " + lootPoolNames[0]);
LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance);
this.lootGroups.add(lootGroup);
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
+3
View File
@@ -100,6 +100,9 @@ public class SpawnService {
creature.setWeaponId(mobileTemplate.getCustomWeapon().getObjectID());
}*/
if(mobileTemplate.getLootGroups() != null)
creature.setLootGroups(mobileTemplate.getLootGroups());
creature.setOptionsBitmask(mobileTemplate.getOptionBitmask());
creature.setPvPBitmask(mobileTemplate.getPvpBitmask());
creature.setStfFilename("mob/creature_names"); // TODO: set other STFs for NPCs other than creatures