Fixed several AI bugs, added log system

- Fixes 0000031: Incap is not working correctly
- NPC AI now considers deathblow values correctly
- AI state transition further debugged
- Pet now follows owner after killing attacker
- Added debug log system
- Cleaned up system console from system.out messages
This commit is contained in:
CharonInferar
2014-07-06 23:47:56 +02:00
parent 7eca666dbe
commit 81a811a425
21 changed files with 612 additions and 118 deletions
+21 -22
View File
@@ -62,6 +62,7 @@ import services.sui.SUIService.MessageBoxType;
import services.sui.SUIWindow;
import services.sui.SUIWindow.SUICallback;
import services.sui.SUIWindow.Trigger;
import tools.DevLog;
import main.NGECore;
import engine.resources.container.CreatureContainerPermissions;
import engine.resources.container.Traverser;
@@ -104,8 +105,8 @@ public class LootService implements INetworkDispatch {
// security check
if (hasAccess(requester,lootedObject) && ! lootedObject.isLooted()){
LootRollSession lootRollSession = (LootRollSession )lootedObject.getAttachment("LootSession");
if (lootRollSession.getDroppedItems().size()==0){
System.err.println("lootRollSession.getDroppedItems().size()==0");
if (lootRollSession.getDroppedItems().size()==0){
DevLog.debugout("Charon", "Loot Service", "handleLootRequest lootRollSession.getDroppedItems().size()==0");
return;
}
SWGObject lootedObjectInventory = lootedObject.getSlottedObject("inventory");
@@ -117,7 +118,7 @@ public class LootService implements INetworkDispatch {
private boolean hasAccess(CreatureObject requester, TangibleObject lootedObject){
LootRollSession lootRollSession = (LootRollSession )lootedObject.getAttachment("LootSession");
if (lootRollSession==null)
System.err.println("LootSession null: " + lootRollSession);
DevLog.debugout("Charon", "Loot Service", "hasAccess LootSession null: " + lootRollSession);
if (lootRollSession!=null){
if (lootRollSession.getRequester()==requester){
return true;
@@ -169,7 +170,6 @@ public class LootService implements INetworkDispatch {
if (projectionCoefficientMatrixModulo!=0)
lootGroupRoll=groupChance+1;
if (lootGroupRoll <= groupChance){
//System.out.println("this lootGroup will drop something");
handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare}
}
}
@@ -502,11 +502,11 @@ public class LootService implements INetworkDispatch {
double[] lootPoolChances = lootGroup.getLootPoolChances();
String[] lootPoolNames = lootGroup.getLootPoolNames();
if (lootPoolChances==null || lootPoolNames==null){
System.err.println("Lootpools are null!");
DevLog.debugout("Charon", "Loot Service", "handleLootGroup Lootpools are null!");
return;
}
if (lootPoolChances.length==0 || lootPoolNames.length==0){
System.err.println("No Lootpools in Lootgroup!");
DevLog.debugout("Charon", "Loot Service", "handleLootGroup No Lootpools in Lootgroup!");
return;
}
@@ -529,7 +529,7 @@ public class LootService implements INetworkDispatch {
}
}
if (!test)
System.err.println("SOMETHING WENT WRONG!");
DevLog.debugout("Charon", "Loot Service", "handleLootGroup SOMETHING WENT WRONG!");
}
private void handleLootPool(String poolName,LootRollSession lootRollSession){
@@ -991,11 +991,11 @@ public class LootService implements INetworkDispatch {
double[] lootPoolChances = lootGroup.getLootPoolChances();
String[] lootPoolNames = lootGroup.getLootPoolNames();
if (lootPoolChances==null || lootPoolNames==null){
System.err.println("Lootpools are null!");
DevLog.debugout("Charon", "Loot Service", "fillChest2 Lootpools are null!");
return;
}
if (lootPoolChances.length==0 || lootPoolNames.length==0){
System.err.println("No Lootpools in Lootgroup!");
DevLog.debugout("Charon", "Loot Service", "fillChest2 No Lootpools in Lootgroup!");
return;
}
@@ -1018,7 +1018,7 @@ public class LootService implements INetworkDispatch {
}
}
if (!test)
System.err.println("SOMETHING WENT WRONG!");
DevLog.debugout("Charon", "Loot Service", "fillChest2 SOMETHING WENT WRONG!");
}
private void fillChest3(String poolName, CreatureObject owner, TangibleObject chest){
@@ -1289,7 +1289,7 @@ public class LootService implements INetworkDispatch {
// Example color crystal
if (itemName.contains("colorcrystal")) {
System.out.println("colorcrystal");
DevLog.debugout("Charon", "Loot Service", "setCustomization colorcrystal");
if (customizationAttributes==null){
int crystalColor = new Random().nextInt(11);
@@ -1316,7 +1316,7 @@ public class LootService implements INetworkDispatch {
// Example power crystal
if (itemName.contains("powercrystal")) {
System.out.println("powercrystal");
DevLog.debugout("Charon", "Loot Service", "setCustomization powercrystal");
droppedItem.setCustomizationVariable("/private/index_color_1", (byte) 0x21); // 0x1F
}
@@ -1324,7 +1324,7 @@ public class LootService implements INetworkDispatch {
if (lootDescriptor==null)
lootDescriptor="";
if (lootDescriptor.contains("rarecolorcrystal")) {
System.out.println("rarecolorcrystal");
DevLog.debugout("Charon", "Loot Service", "setCustomization rarecrystal");
int saberColor = (Integer)droppedItem.getAttachment("customColor1");
if (saberColor==31) // Cunning of Tyranus, which is not in @jedi_spam
@@ -2316,8 +2316,8 @@ public class LootService implements INetworkDispatch {
lootRollSession.setLootedObjectDifficulty(0);
if (containerObject==null)
System.out.println("containerObject is NULL " );
DevLog.debugout("Charon", "Loot Service", "handleContainer containerObject is NULL");
handleContainerDrops(containerObject, lootRollSession);
}
@@ -2343,11 +2343,11 @@ public class LootService implements INetworkDispatch {
double[] lootPoolChances = lootGroup.getLootPoolChances();
String[] lootPoolNames = lootGroup.getLootPoolNames();
if (lootPoolChances==null || lootPoolNames==null){
System.err.println("Lootpools are null!");
DevLog.debugout("Charon", "Loot Service", "handleContainerLootGroup Lootpools are null!");
return;
}
if (lootPoolChances.length==0 || lootPoolNames.length==0){
System.err.println("No Lootpools in Lootgroup!");
DevLog.debugout("Charon", "Loot Service", "handleContainerLootGroup No Lootpools in Lootgroup!");
return;
}
@@ -2370,11 +2370,11 @@ public class LootService implements INetworkDispatch {
}
}
if (!test)
System.err.println("SOMETHING WENT WRONG!");
DevLog.debugout("Charon", "Loot Service", "handleContainerLootGroup SOMETHING WENT WRONG!");
}
private void handleContainerLootPool(String poolName,LootRollSession lootRollSession , TangibleObject containerObject){
System.err.println("poolName.toLowerCase() " + poolName.toLowerCase());
DevLog.debugout("Charon", "Loot Service", "handleContainerLootPool poolName.toLowerCase() " + poolName.toLowerCase());
// Fetch the loot pool data from the poolName.py script
String path = "scripts/loot/lootPools/"+poolName.toLowerCase();
Vector<String> itemNames = (Vector<String>)core.scriptService.fetchStringVector(path,"itemNames");
@@ -2502,7 +2502,7 @@ public class LootService implements INetworkDispatch {
junkType = (byte)core.scriptService.fetchInteger(itemPath,"junkType");
System.out.println("itemTemplate " + itemTemplate);
DevLog.debugout("Charon", "Loot Service", "handleContainerLootPoolItems itemTemplate " + itemTemplate);
TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet());
@@ -2567,7 +2567,7 @@ public class LootService implements INetworkDispatch {
//SWGObject containerObjectInventory = containerObject.getSlottedObject("inventory"); //placable_loot_crate_trashpile
containerObject.add(droppedItem);
//containerObjectInventory.add(droppedItem);
System.out.println("Added to container " + containerObject.getTemplate());
DevLog.debugout("Charon", "Loot Service", "handleContainerLootPoolItems Added to container " + containerObject.getTemplate());
}
@@ -2947,7 +2947,6 @@ public class LootService implements INetworkDispatch {
sword1.setOptions(Options.USABLE, true);
sword1.setWeaponType(WeaponType.ONEHANDEDMELEE);
playerInventory.add(sword1);
System.err.println("MIX " + sword1.getObjectID());
String powerUpLabel = "item_reverse_engineering_powerup_weapon_02_01";