This commit is contained in:
Light2
2014-06-09 02:38:36 +02:00
2050 changed files with 20797 additions and 8841 deletions
@@ -33,10 +33,18 @@ public class StopClientEffectObjectByLabel extends SWGMessage {
private long objectId;
private String effectFile;
private String commandString;
private byte unknownFlag;
public StopClientEffectObjectByLabel(long objectId, String commandString) {
this.objectId = objectId;
this.commandString = commandString;
this.unknownFlag = 1;
}
public StopClientEffectObjectByLabel(long objectId, String commandString, byte unknownFlag) {
this.objectId = objectId;
this.commandString = commandString;
this.unknownFlag = unknownFlag;
}
@Override
@@ -48,7 +56,7 @@ public class StopClientEffectObjectByLabel extends SWGMessage {
result.putInt(0xAD6F6B26);
result.putLong(objectId);
result.put(getAsciiString(commandString));
result.put((byte) 1);
result.put(unknownFlag);
return result.flip();
+10
View File
@@ -68,4 +68,14 @@ public class MathUtilities {
BigDecimal dec = new BigDecimal(seconds);
return dec.remainder(new BigDecimal(3600)).divide(new BigDecimal(60), BigDecimal.ROUND_FLOOR).intValue();
}
public float fastInverseSqrt(float x) {
float xHalf = 0.5F * x;
int temp = Float.floatToRawIntBits(x);
temp = 0x5F3759DF - (temp >> 1); // magic
float newX = Float.intBitsToFloat(temp);
newX = newX * (1.5F - xHalf * newX * newX);
return newX;
}
}
+47
View File
@@ -0,0 +1,47 @@
/*******************************************************************************
* 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.datatables;
public class GcwRank {
// Shared ranks
public static final int PRIVATE = 1;
public static final int SERGEANT = 4;
public static final int SERGEANTMAJOR = 6;
public static final int LIEUTENANT = 7;
public static final int CAPTAIN = 8;
public static final int MAJOR = 9;
public static final int COLONEL = 11;
public static final int GENERAL = 12;
// Rebel ranks
public static final int TROOPER = 2;
public static final int HIGHTROOPER = 3;
public static final int SENIORSERGEANT = 5;
public static final int COMMANDER = 10;
// Imperial ranks
public static final int CORPORAL = 2;
public static final int LANCECORPORAL = 3;
public static final int MASTERSERGEANT = 5;
public static final int LTCOLONEL = 10;
}
@@ -47,4 +47,8 @@ public final class Professions {
return map.get(profession);
}
public static boolean isProfession(String profession) {
return map.containsKey(profession);
}
}
+8 -15
View File
@@ -194,21 +194,14 @@ public class SWGMap<K, V> implements Map<K, V>, Serializable {
K key = entry.getKey();
V value = entry.getValue();
if (valid(key) && valid(value))
{
if (map.containsKey(key))
{
if (map.put(key, value) != null)
{
buffer.add(item(2, key, Baseline.toBytes(value), true, true));
}
}
else
{
if(map.put(key, value) == null)
{
buffer.add(item(0, key, Baseline.toBytes(value), true, true));
}
if (key != null && valid(key) && value != null && valid(value)) {
if (map.containsKey(key)) {
map.put(key, value);
buffer.add(item(2, key, Baseline.toBytes(value), true, true));
} else {
map.put(key, value);
buffer.add(item(0, key, Baseline.toBytes(value), true, true));
}
}
}
+1 -1
View File
@@ -335,7 +335,7 @@ public class SWGMultiMap<K, V> implements Multimap<K, V>, Serializable {
throw new IllegalArgumentException();
}
int size = 1 + ((useIndex) ? (2 + Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0);
int size = 1 + ((useIndex) ? (Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0);
IoBuffer buffer = Delta.createBuffer(size);
buffer.put((byte) type);
@@ -157,9 +157,9 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria
try {
PortalVisitor portal = ClientFileManager.loadFile(portalLayoutFilename, PortalVisitor.class);
for (int i = 1; i <= portal.cellCount; i++) {
for (int i = 0; i <= portal.cellCount; i++) {
if (cellName.equals(portal.cells.get(i).name)) {
return getCellByCellNumber(i);
return getCellByCellNumber(i + 1);
}
}
} catch (InstantiationException | IllegalAccessException e) {
@@ -289,7 +289,13 @@ public class CreatureMessageBuilder extends TangibleMessageBuilder {
buffer.putInt(0);
buffer.putInt(creature.getEquipmentListUpdateCounter());
} else {
buffer.putInt(creature.getEquipmentList().size());
int size = 0;
for (Long objId : creature.getEquipmentList().get()) {
size += ((NGECore.getInstance().objectService.getObject(objId) == null) ? 0 : 1);
}
buffer.putInt(size);
buffer.putInt(creature.getEquipmentListUpdateCounter());
for(Long objId : creature.getEquipmentList().get()) {
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.TimeUnit;
import org.apache.mina.core.buffer.IoBuffer;
@@ -110,7 +111,7 @@ public class PlayerObject extends IntangibleObject implements Serializable {
profileFlagsList.add(0);
baseline.put("profileFlagsList", profileFlagsList);
baseline.put("title", "");
baseline.put("bornDate", (int) (System.currentTimeMillis() / 1000L)); //Integer.parseInt(new SimpleDateFormat("yyyymmdd", Locale.ENGLISH).format(Calendar.getInstance().getTime())));
baseline.put("bornDate", (int) TimeUnit.DAYS.convert((System.currentTimeMillis() - 978220800000L), TimeUnit.MILLISECONDS));
baseline.put("totalPlayTime", 0);
baseline.put("professionIcon", 0);
baseline.put("profession", "trader_0a");
+5 -1
View File
@@ -228,6 +228,10 @@ public class CharacterService implements INetworkDispatch {
ClientCreateCharacter clientCreateCharacter = new ClientCreateCharacter();
clientCreateCharacter.deserialize(data);
if (!Professions.isProfession(clientCreateCharacter.getProfession())) {
return;
}
engine.resources.config.Config config = new engine.resources.config.Config();
config.setFilePath("nge.cfg");
if (!(config.loadConfigFile())) {
@@ -287,7 +291,7 @@ public class CharacterService implements INetworkDispatch {
player.setProfession(clientCreateCharacter.getProfession());
player.setProfessionIcon(Professions.get(clientCreateCharacter.getProfession()));
player.setProfessionWheelPosition(clientCreateCharacter.getProfessionWheelPosition());
player.setNextUpdateTime(core.gcwService.calculateNextUpdateTime() + player.getBornDate());
player.setNextUpdateTime(core.gcwService.calculateNextUpdateTime());
if(clientCreateCharacter.getHairObject().length() > 0) {
String sharedHairTemplate = clientCreateCharacter.getHairObject().replace("/hair_", "/shared_hair_");
TangibleObject hair = (TangibleObject) core.objectService.createObject(sharedHairTemplate, object.getPlanet());
+3 -1
View File
@@ -91,7 +91,9 @@ public class DevService implements INetworkDispatch {
if (creature.getClient().isGM()) {
suiOptions.put((long) 120, "House Deeds");
suiOptions.put((long) 125, "Crafting Tools");
suiOptions.put((long) 130, "Vehicle Deeds");
}
suiOptions.put((long) 130, "Vehicle Deeds");
if (creature.getClient().isGM()) {
suiOptions.put((long) 121, "Sandbox City");
}
+154 -20
View File
@@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import protocol.swg.PlayClientEffectObjectTransformMessage;
import protocol.swg.StopClientEffectObjectByLabel;
import resources.objects.craft.DraftSchematic;
import resources.common.OutOfBand;
import resources.datatables.DisplayType;
import resources.loot.LootGroup;
@@ -71,10 +70,13 @@ import engine.resources.service.INetworkRemoteEvent;
* @author Charon
*/
@SuppressWarnings("unused")
public class LootService implements INetworkDispatch {
private NGECore core;
private static int prepInvCnt = 0;
String testDropTemplate = null;
//String testDropTemplate = "kowakian_cage";
public LootService(NGECore core) {
this.core = core;
@@ -102,7 +104,7 @@ public class LootService implements INetworkDispatch {
}
SWGObject lootedObjectInventory = lootedObject.getSlottedObject("inventory");
core.simulationService.openContainer(requester, lootedObjectInventory);
setLooted(requester,lootedObject);
//setLooted(requester,lootedObject);
}
}
@@ -170,6 +172,8 @@ public class LootService implements INetworkDispatch {
int randomRareLoot = new Random().nextInt(100);
int chanceRequirement = 1;
chanceRequirement = 10; // This is for a test period to lift chest drop chance a bit
if (testDropTemplate!=null)
chanceRequirement = 100;
if (lootRollSession.getLootedObjectDifficulty()==1)
chanceRequirement+=2;
if (lootRollSession.getLootedObjectDifficulty()==2)
@@ -540,7 +544,8 @@ public class LootService implements INetworkDispatch {
if (randomItemFromPool<=remainder){
// this element has been chosen e.g. kraytpearl_flawless
//System.err.println("CHOSEN ITEM " + itemNames.get(i));
handleLootPoolItems(itemNames.get(i), lootRollSession);
handleLootPoolItems(itemNames.get(i), lootRollSession);
//handleLootPoolItems(testDropTemplate, lootRollSession);
//break;
return;
}
@@ -560,12 +565,12 @@ public class LootService implements INetworkDispatch {
rollSession.setSessionPlanet(requester.getPlanet());
handleLootPoolItems(template, rollSession);
if(rollSession.getDroppedItems().get(0) != null) return rollSession.getDroppedItems().get(0);
return null;
}
@SuppressWarnings("unused")
private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){
final Vector<String> foundPath = new Vector<String>();
@@ -611,9 +616,12 @@ public class LootService implements INetworkDispatch {
String requiredFaction = "";
Vector<String> customizationAttributes = null;
Vector<Integer> customizationValues = null;
int customColor1 = 0;
String lootDescriptor = "";
Vector<String> itemStats = null;
Vector<String> itemSkillMods = null;
Vector<String> STFparams = null;
String addToCollection = null;
if(core.scriptService.getMethod(itemPath,"","itemTemplate")==null){
String errorMessage = "Loot item '" + itemName + "' has no template function assigned in its script. Please contact Charon about this issue.";
@@ -641,6 +649,12 @@ public class LootService implements INetworkDispatch {
if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null)
customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(itemPath,"customizationValues");
if(core.scriptService.getMethod(itemPath,"","customColor1")!=null)
customColor1 = (Integer)core.scriptService.fetchInteger(itemPath,"customColor1");
if(core.scriptService.getMethod(itemPath,"","lootDescriptor")!=null)
lootDescriptor = (String)core.scriptService.fetchString(itemPath,"lootDescriptor");
if(core.scriptService.getMethod(itemPath,"","itemStats")!=null)
itemStats = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"itemStats");
@@ -671,6 +685,9 @@ public class LootService implements INetworkDispatch {
if(core.scriptService.getMethod(itemPath,"","STFparams")!=null)
STFparams = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"STFparams");
if(core.scriptService.getMethod(itemPath,"","AddToCollection")!=null)
addToCollection = (String)core.scriptService.fetchString(itemPath,"AddToCollection");
System.out.println("itemTemplate " + itemTemplate);
@@ -679,6 +696,10 @@ public class LootService implements INetworkDispatch {
droppedItem.setLootItem(true);
droppedItem.setAttachment("LootItemName", itemName);
droppedItem.setAttachment("customColor1", customColor1);
droppedItem.setAttachment("lootDescriptor", lootDescriptor);
droppedItem.setAttachment("customName", customName);
if(core.scriptService.getMethod(itemPath,"","randomStatJewelry")!=null){
customName = setRandomStatsJewelry(droppedItem, lootRollSession);
@@ -712,7 +733,7 @@ public class LootService implements INetworkDispatch {
lootRollSession.addErrorMessage(errorMessage);
return;
}
handleStats(droppedItem, itemStats);
handleStats(droppedItem, itemStats, lootRollSession);
}
if (itemSkillMods!=null){
@@ -723,6 +744,12 @@ public class LootService implements INetworkDispatch {
setSTFParams(droppedItem, STFparams);
}
if (addToCollection!=null){
droppedItem.getAttributes().put("@obj_attr_n:collection_name", "@collection_n:"+addToCollection);
//droppedItem.getAttributes().put("@obj_attr_n:collection_name", "\\#FFFF00 @collection_n:"+addToCollection + " \\#FFFFFF ");
//core.collectionService.addCollection(actor, "new_prof_officer_master")
}
// if (customizationValues!=null)
@@ -990,7 +1017,15 @@ public class LootService implements INetworkDispatch {
else
remainder += span;
if (randomItemFromPool<=remainder){
fillChest4(itemNames.get(i), owner, chest);
//fillChest4(itemNames.get(i), owner, chest);
if (testDropTemplate!=null)
fillChest4(testDropTemplate, owner, chest);
else
fillChest4(itemNames.get(i), owner, chest);
//fillChest4("colorcrystal", owner, chest);
//break;
return;
@@ -1050,7 +1085,7 @@ public class LootService implements INetworkDispatch {
Vector<String> itemStats = null;
Vector<String> itemSkillMods = null;
Vector<String> STFparams = null;
Vector<String> addToCollections = null;
String addToCollection = null;
if(core.scriptService.getMethod(itemPath,"","itemTemplate")==null){
String errorMessage = "Loot item '" + itemName + "' has no template function assigned in its script. Please contact Charon about this issue.";
@@ -1116,8 +1151,8 @@ public class LootService implements INetworkDispatch {
if(core.scriptService.getMethod(itemPath,"","STFparams")!=null)
STFparams = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"STFparams");
if(core.scriptService.getMethod(itemPath,"","AddToCollections")!=null)
addToCollections = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"AddToCollections");
if(core.scriptService.getMethod(itemPath,"","AddToCollection")!=null)
addToCollection = (String)core.scriptService.fetchString(itemPath,"AddToCollection");
System.out.println("itemTemplate " + itemTemplate);
@@ -1159,7 +1194,7 @@ public class LootService implements INetworkDispatch {
String errorMessage = "Loot item '" + itemName + "' has a wrong number of itemstats. Please contact Charon about this issue.";
return;
}
handleStats(droppedItem, itemStats);
handleStats(droppedItem, itemStats,null);
}
if (itemSkillMods!=null){
@@ -1169,6 +1204,13 @@ public class LootService implements INetworkDispatch {
if (STFparams!=null){
setSTFParams(droppedItem, STFparams);
}
if (addToCollection!=null){
droppedItem.getAttributes().put("@obj_attr_n:collection_name", "@collection_n:"+addToCollection);
//droppedItem.getAttributes().put("@obj_attr_n:collection_name", "\\#FFFF00 @collection_n:"+addToCollection + " \\#FFFFFF ");
//core.collectionService.addCollection(actor, "new_prof_officer_master")
}
setCustomization(droppedItem, itemName, customizationAttributes, customizationValues); // for now
@@ -1234,6 +1276,10 @@ public class LootService implements INetworkDispatch {
droppedItem.getAttributes().put("@obj_attr_n:color", resources.datatables.LightsaberColors.get(crystalColor));
droppedItem.setAttachment("radial_filename", "item/tunable");
//droppedItem.getAttributes().put("@obj_attr_n:color", "@jedi_spam:saber_color_" + crystalColor); // Commented out for now
String[] crystalColorElementalMapping = new String[]{"heat","heat","acid","acid","cold","cold","cold","acid","electricity","electricity","heat","heat"};
setCrystalStat(droppedItem, "elemtype", crystalColorElementalMapping[crystalColor],crystalColorElementalMapping[crystalColor]);
setCrystalStat(droppedItem, "elemdamage", "2", "2");
} else {
for (int i=0; i<customizationAttributes.size();i++){
int intValue = customizationValues.get(i);
@@ -1286,7 +1332,7 @@ public class LootService implements INetworkDispatch {
}
}
private void handleStats(TangibleObject droppedItem, Vector<String> itemStats) {
private void handleStats(TangibleObject droppedItem, Vector<String> itemStats, LootRollSession lootRollSession) {
if (droppedItem.getTemplate().contains("object/weapon")){
WeaponObject weaponObject = (WeaponObject) droppedItem;
@@ -1303,8 +1349,10 @@ public class LootService implements INetworkDispatch {
String statName = itemStats.get(3*i);
String minValue = itemStats.get(3*i+1);
String maxValue = itemStats.get(3*i+2);
setArmorStat(droppedItem, statName, minValue, maxValue);
setArmorStat(droppedItem, statName, minValue, maxValue);
}
if (lootRollSession != null)
setRandomAttributes(droppedItem,lootRollSession);
}
String lootDescriptor = (String)droppedItem.getAttachment("lootDescriptor");
@@ -1316,6 +1364,7 @@ public class LootService implements INetworkDispatch {
String minValue = itemStats.get(3*i+1);
String maxValue = itemStats.get(3*i+2);
setCrystalStat(droppedItem, statName, minValue, maxValue);
return;
}
}
@@ -1325,11 +1374,89 @@ public class LootService implements INetworkDispatch {
String minValue = itemStats.get(3*i+1);
String maxValue = itemStats.get(3*i+2);
setBuffItemStat(droppedItem, statName, minValue, maxValue);
return;
}
}
}
}
private void setRandomAttributes(TangibleObject droppedItem, LootRollSession lootRollSession){
//determine number of stats #20 yt
int statNumber = 1;
int levelOfDrop = lootRollSession.getLootedObjectLevel();
int difficultyLevel = lootRollSession.getLootedObjectDifficulty(); // better for calculation
int statRoll = new Random().nextInt(100);
int difficultyBonus = 0;
// // stage 1
// if (difficultyLevel==1)
// difficultyBonus = 60;
// if (difficultyLevel>=2)
// difficultyBonus = 75;
//
// if (statRoll<20+difficultyBonus) // diff 3 95% diff 2 70 diff1 20
// statNumber++;
//
// // stage 2
// difficultyBonus = 0;
// if (difficultyLevel==1)
// difficultyBonus = 20;
// if (difficultyLevel>=2)
// difficultyBonus = 60;
//
// if (statRoll<10+difficultyBonus) // diff 3 70% diff 2 30 diff1 10
// statNumber++;
//
// // stage 3
// difficultyBonus = 0;
// if (difficultyLevel==1)
// difficultyBonus = 3;
// if (difficultyLevel>=2)
// difficultyBonus = 5;
//
// if (statRoll<1+difficultyBonus)
// statNumber++;
if (levelOfDrop>60 && levelOfDrop<=90 && difficultyLevel<1){
statNumber=2;
}
if (levelOfDrop>84 && difficultyLevel>=1){
statNumber=3;
}
int primaryAttribute = new Random().nextInt(7); // 0-6
int maxValue = (int) (levelOfDrop*25/90);
int minValue = (int) (0.75*maxValue);
minValue = Math.max(1, minValue);
maxValue = Math.max(2, maxValue);
droppedItem.setIntAttribute(getAttributeSTF(primaryAttribute), getStatValue(minValue,maxValue));
//maxValue -= 2; //secondary attributes must have less maxValue
minValue = (int) (0.75*maxValue);
minValue = Math.max(1, minValue);
maxValue = Math.max(2, maxValue);
String prefix = getJewelryPrefix(droppedItem);
String suffix = getJewelrySuffix(primaryAttribute, statNumber);
String itemName = prefix + suffix;
Vector<Integer> alreadyUsedStats = new Vector<Integer>();
alreadyUsedStats.add(primaryAttribute);
int attribute = primaryAttribute;
List<Integer> statList = new ArrayList<Integer>();
for (int i=0;i<7;i++)
statList.add(i);
statList.remove(primaryAttribute);
for (int i=0;i<statNumber-1;i++){
int attributeIndex = new Random().nextInt(statList.size());
droppedItem.setIntAttribute(getAttributeSTF(statList.get(attributeIndex)), getStatValue(minValue,maxValue));
statList.remove(attributeIndex);
}
}
private void handleSkillMods(TangibleObject droppedItem, Vector<String> skillMods) {
for (int i=0;i<skillMods.size()/2;i++){
String skillMod = skillMods.get(2*i);
@@ -1511,7 +1638,7 @@ public class LootService implements INetworkDispatch {
int finalMinDmg = 0;
int finalMaxDmg = 0;
@SuppressWarnings("unused") String tunableObjectName = "";
String tunableObjectName = "";
if (objectType.contains("powercrystal")){
tunableObjectName = "Power Crystal";
@@ -1635,14 +1762,20 @@ public class LootService implements INetworkDispatch {
if (statName.equals("mindamage")){
int minimalValue = (int) Integer.parseInt(minValue);
int maximalValue = (int) Integer.parseInt(maxValue);
int randomValue = minimalValue + new Random().nextInt(maximalValue-minimalValue);
int extra = 0;
if (maximalValue>minimalValue)
extra = new Random().nextInt(maximalValue-minimalValue);
int randomValue = minimalValue + extra;
weapon.setMinDamage(randomValue);
}
if (statName.equals("maxdamage")){
int minimalValue = (int) Integer.parseInt(minValue);
int maximalValue = (int) Integer.parseInt(maxValue);
int randomValue = minimalValue + new Random().nextInt(maximalValue-minimalValue);
int extra = 0;
if (maximalValue>minimalValue)
extra = new Random().nextInt(maximalValue-minimalValue);
int randomValue = minimalValue + extra;
weapon.setMaxDamage(randomValue);
}
@@ -1870,7 +2003,7 @@ public class LootService implements INetworkDispatch {
public void setLooted(CreatureObject requester,TangibleObject lootedObject){
lootedObject.setLooted(true);
StopClientEffectObjectByLabel stopmsg = new StopClientEffectObjectByLabel(lootedObject.getObjectID(),"lootMe");
StopClientEffectObjectByLabel stopmsg = new StopClientEffectObjectByLabel(lootedObject.getObjectID(),"lootMe", (byte) 0);
requester.getClient().getSession().write(stopmsg.serialize());
}
@@ -2374,7 +2507,7 @@ public class LootService implements INetworkDispatch {
System.err.println(errorMessage);
return;
}
handleStats(droppedItem, itemStats);
handleStats(droppedItem, itemStats, lootRollSession);
}
if (itemSkillMods!=null){
@@ -2493,7 +2626,6 @@ public class LootService implements INetworkDispatch {
// util method
@SuppressWarnings("unused")
private void printArrayElements(TangibleObject[] array){
System.out.print("Array [");
for (int i=0;i<array.length;i++){
@@ -2553,6 +2685,8 @@ public class LootService implements INetworkDispatch {
TangibleObject item11 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_armor_repair_device_generic.iff", player.getPlanet());
item11.setCustomName("Armor Repair Device");
playerInventory.add(item11);
}
+1 -1
View File
@@ -573,7 +573,7 @@ public class PlayerService implements INetworkDispatch {
return;
}
if (profession == null || profession.equals("")) {
if (profession == null || !Professions.isProfession(profession)) {
return;
}
+68
View File
@@ -350,11 +350,21 @@ public class SimulationService implements INetworkDispatch {
Point3D newPos;
Point3D oldPos;
synchronized(object.getMutex()) {
newPos = new Point3D(dataTransform.getXPosition(), dataTransform.getYPosition(), dataTransform.getZPosition());
if(Float.isNaN(newPos.x) || Float.isNaN(newPos.y) || Float.isNaN(newPos.z))
return;
oldPos = object.getPosition();
}
if (object instanceof CreatureObject && object.getOption(Options.MOUNT)) {
if (!checkLineOfSight(object, newPos)) {
newPos = oldPos;
}
}
synchronized(object.getMutex()) {
//Collection<Client> oldObservers = object.getObservers();
//Collection<Client> newObservers = new HashSet<Client>();
if(object.getContainer() == null)
@@ -1153,6 +1163,64 @@ public class SimulationService implements INetworkDispatch {
}
/* Check world line of sight between an object and coordinates, instead of between two objects
* Needed for vehicles.
*/
public boolean checkLineOfSight(SWGObject object, Point3D position2) {
long startTime = System.nanoTime();
float heightOrigin = 1.f;
float heightDirection = 1.f;
if (object instanceof CreatureObject) {
heightOrigin = getHeightOrigin((CreatureObject) object);
}
Point3D position1 = object.getWorldPosition();
Point3D origin = new Point3D(position1.x, position1.y + heightOrigin, position1.z);
Point3D end = new Point3D(position2.x, position2.y + heightDirection, position2.z);
float distance = position1.getDistance2D(position2);
List<SWGObject> inRangeObjects = get(object.getPlanet(), position1.x, position1.z, (int) distance);
for (SWGObject inRangeObject : inRangeObjects) {
if (inRangeObject == object) {
continue;
}
if (object.getTemplateData() != null && object.getTemplateData().getAttribute("collisionActionBlockFlags") != null) {
int bit = (Integer) object.getTemplateData().getAttribute("collisionActionBlockFlags") & 255;
if (bit == (Integer) object.getTemplateData().getAttribute("collisionActionBlockFlags")) {
continue;
}
}
Ray ray = convertRayToModelSpace(origin, end, object);
MeshVisitor visitor = object.getMeshVisitor();
if (visitor == null) {
continue;
}
List<Mesh3DTriangle> tris = visitor.getTriangles();
if (tris.isEmpty()) {
continue;
}
for (Mesh3DTriangle tri : tris) {
if (ray.intersectsTriangle(tri, distance) != null) {
return false;
}
}
}
return true;
}
public boolean checkLineOfSight(SWGObject obj1, SWGObject obj2) {
long startTime = System.nanoTime();
if(obj1.getPlanet() != obj2.getPlanet())
+21 -13
View File
@@ -243,6 +243,12 @@ public class AIActor {
}
public void faceObject(SWGObject object) {
// Null checks due to a null error at: float direction =
if (object == null) System.out.println("object is null");
if (creature == null) System.out.println("creature is null");
if (object.getWorldPosition() == null) System.out.println("object's position is null");
if (creature.getWorldPosition() == null) System.out.println("creature's position is null");
float direction = (float) Math.atan2(object.getWorldPosition().x - creature.getWorldPosition().x, object.getWorldPosition().z - creature.getWorldPosition().z);
if(direction < 0)
direction = (float) (2 * Math.PI + direction);
@@ -290,27 +296,29 @@ public class AIActor {
}
public void scheduleDespawn()
{
public void scheduleDespawn() {
// Sometimes these tasks are null?
try
{
aggroCheckTask.cancel(true);
regenTask.cancel(true);
}
catch(Exception ex ) { }
scheduler.schedule(new Runnable()
{
try {
aggroCheckTask.cancel(true);
} catch(Exception e) {
}
try {
regenTask.cancel(true);
} catch(Exception e) {
}
scheduler.schedule(new Runnable() {
@Override
public void run()
{
public void run() {
damageMap.clear();
followObject = null;
creature.setAttachment("AI", null);
NGECore.getInstance().objectService.destroyObject(creature);
}
}, 2, TimeUnit.MINUTES);
}
+4
View File
@@ -66,6 +66,10 @@ public abstract class AIState {
Vector<Point3D> movementPoints = actor.getMovementPoints();
CellObject cell = null;
//while(!finished && movementPoints.size() != 0) {
if (movementPoints.size() == 0) {
return false;
}
targetPosition = movementPoints.firstElement();
Vector<Point3D> path = core.aiService.findPath(creature.getPlanetId(), currentPosition, targetPosition);
@@ -164,8 +164,6 @@ public class EquipmentService implements INetworkDispatch {
PyObject func = core.scriptService.getMethod("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", ""), serverTemplate.split("shared_" , 2)[1], "equip");
if(func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item));
// TODO: bio-link (assign it by objectID with setAttachment and then just display the customName for that objectID).
if(!actor.getEquipmentList().contains(item.getObjectId()))
{
actor.addObjectToEquipList(item);
+1 -1
View File
@@ -366,7 +366,7 @@ public class FactionService implements INetworkDispatch {
try {
for (int i = 0; i < pvpFactions.getRowCount(); i++) {
if (pvpFactions.getObject(i, 0) != null) {
if (((String) pvpFactions.getObject(i, 0)).equals(faction)) {
if (((String) pvpFactions.getObject(i, 1)).equals(faction)) {
return true;
}
}
+16 -5
View File
@@ -51,6 +51,7 @@ import resources.common.OutOfBand;
import resources.common.collidables.CollidableCircle;
import resources.datatables.DisplayType;
import resources.datatables.FactionStatus;
import resources.datatables.GcwRank;
import resources.datatables.GcwType;
import resources.gcw.CurrentServerGCWZoneHistory;
import resources.gcw.CurrentServerGCWZonePercent;
@@ -354,7 +355,7 @@ public class GCWService implements INetworkDispatch {
player.setHighestImperialRank(player.getCurrentRank());
}
player.setNextUpdateTime(nextUpdateTime - player.getBornDate());
player.setNextUpdateTime(nextUpdateTime);
}
}
@@ -461,6 +462,10 @@ public class GCWService implements INetworkDispatch {
PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost");
int gcwBonus = actor.getSkillModBase("flush_with_success");
gcwPoints += ((gcwPoints * gcwBonus) / 100);
String planet = actor.getPlanet().getName();
String prefix = ((planet.startsWith("space")) ? (planet + "_space") : planet);
@@ -539,14 +544,14 @@ public class GCWService implements INetworkDispatch {
newranktotal = oldranktotal + newprogress;
if (oldrank == 7 && newprogress < 0 && newranktotal < 30000) {
if (oldrank == GcwRank.LIEUTENANT && newprogress < 0 && newranktotal < 30000) {
newranktotal = 29999;
}
newrank = (int) (Math.floor(newranktotal / 5000) + 1);
if (newrank > 12) {
newrank = 12;
if (newrank > GcwRank.GENERAL) {
newrank = GcwRank.GENERAL;
newranktotal = 12 * 5000 - 1;
}
@@ -555,6 +560,12 @@ public class GCWService implements INetworkDispatch {
player.setCurrentRank(newrank);
player.setRankProgress((float) Math.floor(newprogress));
if (newrank > oldrank) {
core.scriptService.callScript("scripts/gcw/", "gcwrank_" + actor.getFaction(), "handleRankUp", core, actor, newrank);
} else {
core.scriptService.callScript("scripts/gcw/", "gcwrank_" + actor.getFaction(), "handleRankDown", actor, newrank);
}
}
public List<SWGObject> getSFPlayers() {
@@ -654,7 +665,7 @@ public class GCWService implements INetworkDispatch {
PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost");
player.setNextUpdateTime(player.getBornDate() + calculateNextUpdateTime());
player.setNextUpdateTime(calculateNextUpdateTime());
}
cursor.close();
+20 -16
View File
@@ -679,17 +679,21 @@ public class ObjectService implements INetworkDispatch {
return;
}
// Bio-Linking
String template = ((object.getAttachment("customServerTemplate") == null) ? object.getTemplate() : (object.getTemplate().split("shared_")[0] + "shared_" + ((String) object.getAttachment("customServerTemplate")) + ".iff"));
String bl = object.getStringAttribute("bio_link");
if (bl!=null){
if (! object.getContainer().getTemplate().contains("shared_character_inventory")){
creature.sendSystemMessage("@base_player:must_biolink_to_use_from_inventory", (byte)1);
return;
}
if (! bl.contains("@obj_attr_n:bio_link_pending") && ! bl.contains(creature.getCustomName())){
creature.sendSystemMessage("@base_player:not_linked_to_holder", (byte)1);
if (bl != null) {
if (!object.getContainer().getTemplate().contains("shared_character_inventory")){
creature.sendSystemMessage("@base_player:must_biolink_to_use_from_inventory", DisplayType.Screen);
return;
}
if (!bl.contains("@obj_attr_n:bio_link_pending") && ! bl.contains(creature.getCustomName())){
creature.sendSystemMessage("@base_player:not_linked_to_holder", DisplayType.Screen);
return;
}
if (bl.contains("@obj_attr_n:bio_link_pending")){
creature.setAttachment("BioLinkItemCandidate", object.getObjectID());
SUIWindow window = core.suiService.createSUIWindow("Script.messageBox", creature, creature, 0);
@@ -705,7 +709,7 @@ public class ObjectService implements INetworkDispatch {
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
@Override
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
((CreatureObject)owner).sendSystemMessage("@base_player:item_bio_linked", (byte)1);
((CreatureObject)owner).sendSystemMessage("@base_player:item_bio_linked", (byte) 1);
object.setStringAttribute("bio_link", owner.getCustomName());
object.setAttachment("bio_link_PlayerID", owner.getObjectID());
return;
@@ -769,11 +773,11 @@ public class ObjectService implements INetworkDispatch {
}
if (!foundTemplate && reuse_time > 0) {
if (creature.hasCooldown(object.getTemplate())) {
if (creature.hasCooldown(template)) {
return;
}
creature.addCooldown(object.getTemplate(), reuse_time);
creature.addCooldown(template, reuse_time);
}
} catch (Exception e) {
e.printStackTrace();
@@ -796,14 +800,14 @@ public class ObjectService implements INetworkDispatch {
core.buffService.addBuffToCreature(creature, object.getStringAttribute("proc_name").replace("@ui_buff:", ""), creature);
}
String filePath = "scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", "") + object.getTemplate().split("shared_" , 2)[1].replace(".iff", "") + ".py";
String filePath = "scripts/" + template.split("shared_" , 2)[0].replace("shared_", "") + template.split("shared_" , 2)[1].replace(".iff", "") + ".py";
if (FileUtilities.doesFileExist(filePath)) {
filePath = "scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", "");
String fileName = object.getTemplate().split("shared_" , 2)[1].replace(".iff", "");
filePath = "scripts/" + template.split("shared_" , 2)[0].replace("shared_", "");
String fileName = template.split("shared_" , 2)[1].replace(".iff", "");
PyObject method1 = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "use");
PyObject method2 = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "useObject");
PyObject method1 = core.scriptService.getMethod("scripts/" + template.split("shared_" , 2)[0].replace("shared_", ""), template.split("shared_" , 2)[1].replace(".iff", ""), "use");
PyObject method2 = core.scriptService.getMethod("scripts/" + template.split("shared_" , 2)[0].replace("shared_", ""), template.split("shared_" , 2)[1].replace(".iff", ""), "useObject");
if (method1 != null && method1.isCallable()) {
method1.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(object));
+3 -2
View File
@@ -674,8 +674,9 @@ public class MountService implements INetworkDispatch {
}
if (isMounted(owner, mount)) {
storer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:must_dismount"), DisplayType.Broadcast);
return;
//storer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:must_dismount"), DisplayType.Broadcast);
//return;
dismount(storer, mount);
}
if (owner.getTefTime() > 0) {
-46
View File
@@ -42,16 +42,10 @@ public class MobileTemplate implements Cloneable {
private short maxLevel;
private Vector<String> attacks;
private String defaultAttack;
private int minDamage = 0;
private int maxDamage = 0;
private float attackSpeed = 0;
private int weaponType = 0;
private int difficulty = 0;
private int health, action;
private String creatureName;
private float scale = 1;
// this is a custom attack Range setting to use for large mobs like krayts
private int attackRange;
private Vector<String> weaponTemplates = new Vector<String>();
private Vector<WeaponTemplate> weaponTemplateVector = new Vector<WeaponTemplate>();
private int minSpawnDistance = 0;
@@ -122,22 +116,6 @@ public class MobileTemplate implements Cloneable {
this.attacks = attacks;
}
public int getMinDamage() {
return minDamage;
}
public void setMinDamage(int minDamage) {
this.minDamage = minDamage;
}
public int getMaxDamage() {
return maxDamage;
}
public void setMaxDamage(int maxDamage) {
this.maxDamage = maxDamage;
}
public int getDifficulty() {
return difficulty;
}
@@ -185,14 +163,6 @@ public class MobileTemplate implements Cloneable {
public void setScale(float scale) {
this.scale = scale;
}
public int getAttackRange() {
return attackRange;
}
public void setAttackRange(int attackRange) {
this.attackRange = attackRange;
}
public Vector<String> getWeaponTemplates() {
return weaponTemplates;
@@ -202,22 +172,6 @@ public class MobileTemplate implements Cloneable {
this.weaponTemplates = weaponTemplates;
}
public float getAttackSpeed() {
return attackSpeed;
}
public void setAttackSpeed(float attackSpeed) {
this.attackSpeed = attackSpeed;
}
public int getWeaponType() {
return weaponType;
}
public void setWeaponType(int weaponType) {
this.weaponType = weaponType;
}
public Vector<WeaponTemplate> getWeaponTemplateVector() {
return weaponTemplateVector;
}
+18 -23
View File
@@ -41,6 +41,7 @@ import java.util.concurrent.ScheduledExecutorService;
import resources.common.collidables.CollidableCircle;
import resources.datatables.Options;
import resources.datatables.PvpStatus;
import resources.datatables.WeaponType;
import resources.objects.cell.CellObject;
import resources.objects.creature.CreatureObject;
import resources.objects.tangible.TangibleObject;
@@ -129,42 +130,36 @@ public class SpawnService {
creature.setLevel(level);
}
//WeaponObject defaultWeapon = (mobileTemplate.getWeaponTemplates().size() > 0) ? (WeaponObject) core.objectService.createObject(mobileTemplate.getWeaponTemplates().get(new Random().nextInt(mobileTemplate.getWeaponTemplates().size())), creature.getPlanet()) : (WeaponObject) core.objectService.createObject("object/weapon/creature/shared_creature_default_weapon.iff", creature.getPlanet());
WeaponObject defaultWeapon = null;
Vector<WeaponTemplate> weaponTemplates = mobileTemplate.getWeaponTemplateVector();
if (weaponTemplates.size()==0){
int rnd = 0;
if (weaponTemplates.size() > 0 )
rnd = new Random().nextInt(weaponTemplates.size());
if (weaponTemplates.size() == 0){
defaultWeapon = (WeaponObject) core.objectService.createObject("object/weapon/creature/shared_creature_default_weapon.iff", creature.getPlanet());
defaultWeapon.setAttackSpeed(1.0F);
defaultWeapon.setWeaponType(6);
defaultWeapon.setWeaponType(WeaponType.UNARMED);
defaultWeapon.setDamageType("kinetic");
defaultWeapon.setMaxRange(5);
} else {
int rnd = new Random().nextInt(weaponTemplates.size());
defaultWeapon = (WeaponObject) core.objectService.createObject(weaponTemplates.get(rnd).getTemplate(), creature.getPlanet());
defaultWeapon = (WeaponObject) core.objectService.createObject(weaponTemplates.get(rnd).getTemplate(), creature.getPlanet());
defaultWeapon.setAttackSpeed(weaponTemplates.get(rnd).getAttackSpeed());
defaultWeapon.setWeaponType(weaponTemplates.get(rnd).getWeaponType());
defaultWeapon.setMaxRange(weaponTemplates.get(rnd).getMaxRange());
defaultWeapon.setDamageType(weaponTemplates.get(rnd).getDamageType());
}
// QA
if (mobileTemplate.getAttackSpeed()==0)
System.err.println("Error in mobile spawn template for " + mobileTemplate.getCreatureName() + ". Missing attackspeed parameter");
if (mobileTemplate.getAttackRange()==0)
System.err.println("Error in mobile spawn template for " + mobileTemplate.getCreatureName() + ". Missing attackrange parameter");
defaultWeapon.setAttackSpeed(mobileTemplate.getAttackSpeed());
defaultWeapon.setWeaponType(mobileTemplate.getWeaponType());
defaultWeapon.setDamageType("@obj_attr_n:armor_eff_kinetic");
defaultWeapon.setStringAttribute("cat_wpn_damage.damage", "0-0");
if(mobileTemplate.getAttackRange() > 0)
defaultWeapon.setMaxRange(mobileTemplate.getAttackRange());
if(mobileTemplate.getMaxDamage() != 0) {
defaultWeapon.setMaxDamage(mobileTemplate.getMaxDamage());
defaultWeapon.setMinDamage(mobileTemplate.getMinDamage());
if (weaponTemplates.get(rnd).getMinDamage() != 0 && weaponTemplates.get(rnd).getMaxDamage() != 0) {
defaultWeapon.setMaxDamage(weaponTemplates.get(rnd).getMinDamage());
defaultWeapon.setMinDamage(weaponTemplates.get(rnd).getMaxDamage());
} else {
defaultWeapon.setMaxDamage(creature.getLevel() * 24);
defaultWeapon.setMinDamage(creature.getLevel() * 22);
}
creature.addObjectToEquipList(defaultWeapon);
creature.add(defaultWeapon);
creature.setWeaponId(defaultWeapon.getObjectID());
+52 -4
View File
@@ -2,18 +2,34 @@ package services.spawn;
public class WeaponTemplate {
private String template="";
private float attackSpeed=0;
private int weaponType=0;
private String template = "";
private int weaponType = 0;
private float attackSpeed = 0;
private int minDamage = 0;
private int maxDamage = 0;
private float maxRange = 0;
private String damageType = "";
public WeaponTemplate(){
}
public WeaponTemplate(String template, int weaponType, float attackSpeed){
public WeaponTemplate(String template, int weaponType, float attackSpeed, float maxRange, int minDamage, int maxDamage, String damageType){
this.template = template;
this.weaponType = weaponType;
this.attackSpeed = attackSpeed;
this.maxRange = maxRange;
this.minDamage = minDamage;
this.maxDamage = maxDamage;
this.damageType = damageType;
}
public WeaponTemplate(String template, int weaponType, float attackSpeed, float maxRange, String damageType){
this.template = template;
this.weaponType = weaponType;
this.attackSpeed = attackSpeed;
this.maxRange = maxRange;
this.damageType = damageType;
}
public String getTemplate() {
@@ -39,4 +55,36 @@ public class WeaponTemplate {
public void setWeaponType(int weaponType) {
this.weaponType = weaponType;
}
public float getMaxRange() {
return maxRange;
}
public void setMaxRange(float maxRange) {
this.maxRange = maxRange;
}
public int getMinDamage() {
return minDamage;
}
public void setMinDamage(int minDamage) {
this.minDamage = minDamage;
}
public int getMaxDamage() {
return maxDamage;
}
public void setMaxDamage(int maxDamage) {
this.maxDamage = maxDamage;
}
public String getDamageType() {
return damageType;
}
public void setDamageType(String damageType) {
this.damageType = damageType;
}
}