mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-13 03:13:26 -04:00
Merge pull request #996 from CharonInferar/NPCUpdate
Fixes #61 Houses can't be deleted
This commit is contained in:
@@ -111,6 +111,7 @@ import services.spawn.SpawnService;
|
||||
import services.sui.SUIService;
|
||||
import services.trade.TradeService;
|
||||
import services.travel.TravelService;
|
||||
import tools.CharonPacketLogger;
|
||||
import tools.DevLogQueuer;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.CrcStringTableVisitor;
|
||||
@@ -538,6 +539,10 @@ public class NGECore {
|
||||
|
||||
|
||||
DevLogQueuer devLogQueuer = new DevLogQueuer();
|
||||
|
||||
CharonPacketLogger packetLogger;
|
||||
if (PACKET_DEBUG)
|
||||
packetLogger = new CharonPacketLogger();
|
||||
|
||||
didServerCrash = false;
|
||||
System.out.println("Started Server.");
|
||||
|
||||
@@ -37,6 +37,8 @@ import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import services.ai.AIActor;
|
||||
import services.ai.states.FollowState;
|
||||
import tools.DevLog;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
@@ -468,12 +470,31 @@ public class Forager {
|
||||
treasureContainer.setAttachment("radial_filename", "object/treasureContainer");
|
||||
treasureContainer.setAttachment("TreasureExtractorID", owner.getObjectID());
|
||||
treasureContainer.setAttachment("TreasureGuards",guardList);
|
||||
treasureContainer.setAttachment("ChestLevel",new Integer(spawnLevel));
|
||||
// treasureContainer.setAttachment("ChestLevel",new Integer(spawnLevel));
|
||||
configureTreasureLoot(treasureContainer,owner,spawnLevel);
|
||||
NGECore.getInstance().lootService.DropLoot(owner, treasureContainer);
|
||||
|
||||
owner.sendSystemMessage("@treasure_map/treasure_map:sys_time_limit",(byte)0);
|
||||
|
||||
Thread guardsThread = new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
while (countAliveGuards(treasureContainer)>0){
|
||||
Thread.sleep(1000);
|
||||
if (owner.getPosture()==14)
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
treasureContainer.setAttachment("radial_filename", "object/treasureContainer");
|
||||
owner.sendSystemMessage("@treasure_map/treasure_map:unlock_chest",(byte)0);
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
} catch(InterruptedException va) {
|
||||
System.out.println(va);
|
||||
Thread.currentThread().interrupt(); // very important
|
||||
}
|
||||
}
|
||||
};
|
||||
guardsThread.start();
|
||||
|
||||
// all down: owner.sendSystemMessage("@treasure_map/treasure_map:unlock_chest",(byte)0);
|
||||
}
|
||||
|
||||
@@ -342,6 +342,7 @@ public class SWGList<E> implements List<E>, Serializable {
|
||||
|
||||
updateCounter += list.size();
|
||||
//StringUtilities.printBytes(newListData);
|
||||
//tools.CharonPacketUtils.printAnalysis(buffer,"SWGList set");
|
||||
queue(newListData);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -113,6 +113,7 @@ public class CreatureMessageBuilder extends TangibleMessageBuilder {
|
||||
buffer.putInt(creature.getFactionStatus());
|
||||
|
||||
byte[] customizationData = creature.getCustomization();
|
||||
//byte[] customizationData = new byte[]{(byte)0x03,(byte)0xBF,(byte)0xC3,(byte)0x33,(byte)0x02,(byte)0x01,(byte)0x02};
|
||||
|
||||
if(customizationData == null || customizationData.length <= 0) // Shuttles have no customization data
|
||||
buffer.putShort((short) 0);
|
||||
@@ -148,6 +149,9 @@ public class CreatureMessageBuilder extends TangibleMessageBuilder {
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("CREO", (byte) 3, buffer, size);
|
||||
|
||||
tools.CharonPacketUtils.printAnalysis(buffer, "CREO 3");
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import resources.common.Console;
|
||||
import resources.common.FileUtilities;
|
||||
import resources.common.Forager;
|
||||
import resources.common.Opcodes;
|
||||
import resources.common.SpawnPoint;
|
||||
import resources.datatables.Posture;
|
||||
@@ -51,6 +52,9 @@ import main.NGECore;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.container.CreatureContainerPermissions;
|
||||
import engine.resources.container.CreaturePermissions;
|
||||
import engine.resources.container.NullPermissions;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -76,6 +80,8 @@ public class DevService implements INetworkDispatch {
|
||||
suiOptions.put((long) 1, "Character");
|
||||
suiOptions.put((long) 2, "Items");
|
||||
suiOptions.put((long) 3, "Locations");
|
||||
if (System.getProperty("user.name").equals("Charon"))
|
||||
suiOptions.put((long) 4, "Treasure chest test");
|
||||
break;
|
||||
case 1: // Character
|
||||
suiOptions.put((long) 10, "Set combat level to 90");
|
||||
@@ -188,6 +194,26 @@ public class DevService implements INetworkDispatch {
|
||||
case 3: // Locations
|
||||
sendCharacterBuilderSUI(player, 11);
|
||||
return;
|
||||
|
||||
case 4: // Test
|
||||
TangibleObject treasureContainer = (TangibleObject) NGECore.getInstance().staticService.spawnObject("object/tangible/container/drum/shared_treasure_drum.iff",
|
||||
owner.getPlanet().getName(), 0L, owner.getWorldPosition().x, owner.getWorldPosition().y, owner.getWorldPosition().z, 0.70F, 0.71F);
|
||||
treasureContainer.setAttachment("radial_filename", "object/treasureContainer");
|
||||
|
||||
//treasureContainer.setContainerPermissions(CreatureContainerPermissions.CREATURE_CONTAINER_PERMISSIONS);
|
||||
treasureContainer.setAttachment("TreasureExtractorID", owner.getObjectID());
|
||||
treasureContainer.add(core.objectService.createObject("object/tangible/inventory/shared_character_inventory.iff", treasureContainer.getPlanet()));
|
||||
String template = "object/tangible/wearables/bracelet/shared_bracelet_s02_r.iff";
|
||||
TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, planet);
|
||||
// SWGObject lootedObjectInventory = treasureContainer.getSlottedObject("inventory");
|
||||
// lootedObjectInventory.add(droppedItem);
|
||||
//
|
||||
Forager forager = new Forager();
|
||||
forager.configureTreasureLoot(treasureContainer,(CreatureObject)owner,(short)90);
|
||||
NGECore.getInstance().lootService.DropLoot((CreatureObject)owner, treasureContainer);
|
||||
|
||||
//treasureContainer.add(droppedItem);
|
||||
return;
|
||||
|
||||
// Character
|
||||
case 10: // Set combat level to 90
|
||||
|
||||
@@ -230,12 +230,13 @@ public class LootService implements INetworkDispatch {
|
||||
// For autoloot
|
||||
//SWGObject requesterInventory = requester.getSlottedObject("inventory");
|
||||
//System.out.println("lootRollSession.getDroppedItems() " + (lootRollSession.getDroppedItems()));
|
||||
DevLog.debugout("Charon", "Loot Service", "lootRollSession.getDroppedItems().size() " + lootRollSession.getDroppedItems().size());
|
||||
for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){
|
||||
|
||||
DevLog.debugout("Charon", "Loot Service", "droppedItem " + droppedItem.getCustomName());
|
||||
//droppedItem.setAttachment("radial_filename", "lootitem");
|
||||
//if (! droppedItem.getTemplate().contains("shared_rare_loot_chest"))
|
||||
lootedObjectInventory.add(droppedItem);
|
||||
|
||||
|
||||
|
||||
// RLS chest effect
|
||||
if (droppedItem.getAttachment("LootItemName").toString().contains("Loot Chest")){
|
||||
@@ -586,7 +587,7 @@ public class LootService implements INetworkDispatch {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String actualFileName = file.getFileName().toString();
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3);
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3).toLowerCase();
|
||||
if (actualFileName.equals(itemName.toLowerCase())){
|
||||
foundPath.add(file.toString());
|
||||
}
|
||||
@@ -1065,7 +1066,7 @@ public class LootService implements INetworkDispatch {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String actualFileName = file.getFileName().toString();
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3);
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3).toLowerCase();
|
||||
if (actualFileName.equals(itemName.toLowerCase())){
|
||||
foundPath.add(file.toString());
|
||||
}
|
||||
@@ -1491,9 +1492,16 @@ public class LootService implements INetworkDispatch {
|
||||
|
||||
public void handleCreditDrop(CreatureObject requester,TangibleObject lootedObject,LootRollSession lootRollSession){
|
||||
int lootedCredits = 0;
|
||||
AIActor ai = (AIActor) lootedObject.getAttachment("AI");
|
||||
String resType = ai.getMobileTemplate().getMeatType();
|
||||
if (lootedObject.isCreditRelieved() || resType!=null)
|
||||
if (lootedObject.getAttachment("AI")!=null){
|
||||
AIActor ai = (AIActor) lootedObject.getAttachment("AI");
|
||||
String resType = ai.getMobileTemplate().getMeatType();
|
||||
if (resType!=null)
|
||||
return;
|
||||
}
|
||||
|
||||
if (lootedObject.isCreditRelieved())
|
||||
return;
|
||||
if (lootedObject.getTemplate().contains("shared_treasure_drum"))
|
||||
return;
|
||||
|
||||
// Credit drop is depending on the CL of the looted CreatureObject
|
||||
@@ -2408,7 +2416,7 @@ public class LootService implements INetworkDispatch {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String actualFileName = file.getFileName().toString();
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3);
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3).toLowerCase();
|
||||
if (actualFileName.equals(itemName.toLowerCase())){
|
||||
foundPath.add(file.toString());
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package services.ai.states;
|
||||
|
||||
import engine.resources.container.CreatureContainerPermissions;
|
||||
import main.NGECore;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
@@ -38,6 +39,7 @@ public class DeathState extends AIState {
|
||||
CreatureObject killer = (CreatureObject)actor.getCreature().getKiller();
|
||||
if (killer==null)
|
||||
killer = actor.getHighestDamageDealer();
|
||||
actor.getCreature().setContainerPermissions(CreatureContainerPermissions.CREATURE_CONTAINER_PERMISSIONS);
|
||||
NGECore.getInstance().lootService.DropLoot(killer,(TangibleObject)(actor.getCreature()));
|
||||
|
||||
actor.destroyActor(); // to prevent standing up right after death
|
||||
|
||||
@@ -46,6 +46,7 @@ import resources.common.OutOfBand;
|
||||
import resources.datatables.Citizenship;
|
||||
import resources.datatables.DisplayType;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
import resources.objects.installation.InstallationObject;
|
||||
@@ -325,7 +326,7 @@ public class HousingService implements INetworkDispatch {
|
||||
} else {
|
||||
window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#32CD32 @player_structure:can_redeed_yes_suffix \\#FFFFFF ",1 );
|
||||
}
|
||||
if (building.getConditionDamage()<20){
|
||||
if (building.getConditionDamage()>20){
|
||||
window.addListBoxMenuItem("@player_structure:redeed_condition \\#BB0000 " + building.getConditionDamage() + " \\#FFFFFF ",1 );
|
||||
noRedeed.add(-1);
|
||||
} else {
|
||||
@@ -421,7 +422,6 @@ public class HousingService implements INetworkDispatch {
|
||||
houseOwner.sendSystemMessage("@player_structure:processing_destruction",(byte)1);
|
||||
houseOwner.sendSystemMessage("@player_structure:deed_reclaimed",(byte)1);
|
||||
|
||||
|
||||
} else {
|
||||
houseOwner.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,11 @@ public class PetService implements INetworkDispatch {
|
||||
activeAbilities.add("toggleBeastPassive");
|
||||
player.getActivePetAbilities().set(activeAbilities);
|
||||
|
||||
// 02 01 02 33 C3 BF 03
|
||||
//byte[] customization = new byte[]{(byte)0x03,(byte)0xBF,(byte)0xC3,(byte)0x33,(byte)0x02,(byte)0x01,(byte)0x02};
|
||||
byte[] customization = new byte[]{(byte)0x02,(byte)0x01,(byte)0x02,(byte)0x33,(byte)0xC3,(byte)0xBF,(byte)0x03};
|
||||
pet.setCustomization(customization);
|
||||
|
||||
pet.setFaction(actor.getFaction());
|
||||
pet.setFactionStatus(actor.getFactionStatus());
|
||||
pet.setOwnerId(actor.getObjectID());
|
||||
@@ -1004,8 +1009,11 @@ public class PetService implements INetworkDispatch {
|
||||
actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:too_hard"), DisplayType.Broadcast);
|
||||
}
|
||||
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
} catch(InterruptedException v) {
|
||||
System.out.println(v);
|
||||
Thread.currentThread().interrupt(); // very important
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,6 +85,9 @@ public class SUIService implements INetworkDispatch {
|
||||
if(target == null || owner == null)
|
||||
return;
|
||||
|
||||
// if (getRadialFilename(target).equals("noradialoptions"))
|
||||
// return;
|
||||
|
||||
if (target instanceof HarvesterObject){
|
||||
HarvesterObject harvester = (HarvesterObject) target;
|
||||
Vector<String> admins = harvester.getAdminList();
|
||||
@@ -206,7 +209,7 @@ public class SUIService implements INetworkDispatch {
|
||||
});
|
||||
|
||||
swgOpcodes.put(Opcodes.SuiEventNotification, new INetworkRemoteEvent() {
|
||||
|
||||
|
||||
@Override
|
||||
public void handlePacket(IoSession session, IoBuffer data) throws Exception {
|
||||
|
||||
@@ -232,7 +235,7 @@ public class SUIService implements INetworkDispatch {
|
||||
return;
|
||||
|
||||
PyObject func = window.getFunctionByEventId(suiEvent.getEventType());
|
||||
|
||||
|
||||
if(func != null)
|
||||
func.__call__(Py.java2py(owner), Py.java2py(window), Py.java2py(suiEvent.getEventType()), Py.java2py(suiEvent.getReturnList()));
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.concurrent.BlockingQueue;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class CharonPacketLogger extends Thread {
|
||||
private static final CharonPacketLogger instance = new CharonPacketLogger();
|
||||
private static CharonPacketLogger instance;
|
||||
|
||||
private BlockingQueue<String> itemsToLog =
|
||||
new ArrayBlockingQueue<String>(100);
|
||||
@@ -16,8 +16,11 @@ public class CharonPacketLogger extends Thread {
|
||||
public static CharonPacketLogger getLogger() {
|
||||
return instance;
|
||||
}
|
||||
private CharonPacketLogger() {
|
||||
start();
|
||||
public CharonPacketLogger() {
|
||||
if (instance!=null)
|
||||
return; // Singleton
|
||||
instance = this;
|
||||
start();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
@@ -9,6 +9,9 @@ import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
@@ -20,21 +23,30 @@ import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
public class CharonPacketUtils {
|
||||
|
||||
static Path newFile = Paths.get("M:/PSWG/LOGS/PSWG_PacketLog.txt");
|
||||
private static int loggingSessionID=0;
|
||||
static Path newFile = Paths.get("src", "PSWG_DEVLOG.log");
|
||||
private static boolean writeToFile = false;
|
||||
private CharonPacketLogger logger;
|
||||
|
||||
|
||||
public static void createLog(){
|
||||
|
||||
try {
|
||||
Files.deleteIfExists(newFile);
|
||||
newFile = Files.createFile(newFile);
|
||||
try {
|
||||
writeToFile = true;
|
||||
Date date = new Date();
|
||||
Calendar cal1 = Calendar.getInstance();
|
||||
cal1.setTimeInMillis(System.currentTimeMillis());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-hh-mm-ss");
|
||||
String sDate=dateFormat.format(cal1.getTime());
|
||||
|
||||
String fileName = "PSWG_PACKETLOG_"+sDate+".log";
|
||||
newFile = Paths.get("debuglogs", fileName);
|
||||
Files.deleteIfExists(newFile);
|
||||
newFile = Files.createFile(newFile);
|
||||
createHeader(newFile);
|
||||
} catch (IOException ex) {
|
||||
System.out.println("Error creating file");
|
||||
}
|
||||
System.out.println(Files.exists(newFile));
|
||||
writeToFile=true;
|
||||
System.out.println("Error creating file");
|
||||
}
|
||||
}
|
||||
|
||||
public static void appendToLog(String content, Path newFile){
|
||||
@@ -58,6 +70,16 @@ public class CharonPacketUtils {
|
||||
if (!NGECore.PACKET_DEBUG)
|
||||
return;
|
||||
|
||||
if (pack==null)
|
||||
return;
|
||||
|
||||
if (loggingSessionID>0){
|
||||
} else {
|
||||
createLog();
|
||||
loggingSessionID++;
|
||||
}
|
||||
|
||||
|
||||
//appendToLog(packetName+" :");
|
||||
int hexLineNumber = 0;
|
||||
byte[] packArray = pack.array();
|
||||
@@ -138,4 +160,25 @@ public class CharonPacketUtils {
|
||||
//if (writeToFile)
|
||||
// appendToLog("");
|
||||
}
|
||||
|
||||
public static void createHeader(Path newFile){
|
||||
//Writing to file
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(
|
||||
newFile, Charset.defaultCharset(),new OpenOption[] {StandardOpenOption.APPEND})){
|
||||
Date date = new Date();
|
||||
Calendar cal1 = Calendar.getInstance();
|
||||
cal1.setTimeInMillis(System.currentTimeMillis());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-hh:mm:ss");
|
||||
String sDate=dateFormat.format(cal1.getTime());
|
||||
String developer = System.getProperty("user.name");
|
||||
writer.append("*********************************************\n");
|
||||
writer.append("**** PROJECTSWG PACKET LOG " + sDate + " ***\n");
|
||||
writer.append("*********************************************\n");
|
||||
writer.append("DEV: "+developer + "\n");
|
||||
writer.append("\n");
|
||||
writer.flush();
|
||||
}catch(IOException exception){
|
||||
System.out.println("Error writing to file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user