mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-17 07:02:53 -04:00
Armor loot fix, stat loot fix
fixed numeric errors Loot client command response coded
This commit is contained in:
@@ -25,9 +25,14 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.DirectoryStream.Filter;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.FileVisitor;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -36,6 +41,8 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import protocol.swg.PlayClientEffectObjectTransformMessage;
|
||||
import resources.loot.LootGroup;
|
||||
import resources.loot.LootRollSession;
|
||||
@@ -87,12 +94,8 @@ public class LootService implements INetworkDispatch {
|
||||
}
|
||||
SWGObject lootedObjectInventory = lootedObject.getSlottedObject("inventory");
|
||||
core.simulationService.openContainer(requester, lootedObjectInventory);
|
||||
System.err.println("core.simulationService.openContainer " + lootedObject.getTemplate() );
|
||||
System.err.println("core.simulationService.openContainer " + lootedObjectInventory.getTemplate());
|
||||
setLooted(requester,lootedObject);
|
||||
}
|
||||
System.err.println("NO ACCESS lootedObject.isLooted(): " + lootedObject.isLooted());
|
||||
System.err.println("NO ACCESS hasAccess(requester,lootedObject): " + hasAccess(requester,lootedObject));
|
||||
}
|
||||
|
||||
private boolean hasAccess(CreatureObject requester, TangibleObject lootedObject){
|
||||
@@ -101,7 +104,6 @@ public class LootService implements INetworkDispatch {
|
||||
System.err.println("LootSession null: " + lootRollSession);
|
||||
if (lootRollSession!=null){
|
||||
if (lootRollSession.getRequester()==requester){
|
||||
System.err.println("lootRollSession.getRequester()==requester: " + (lootRollSession.getRequester()==requester));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +153,9 @@ public class LootService implements INetworkDispatch {
|
||||
System.out.println("this lootGroup will drop something");
|
||||
handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare}
|
||||
}
|
||||
System.out.println("While Loop Stuck check");
|
||||
}
|
||||
System.out.println("Past while ");
|
||||
|
||||
// Rare Loot System Stage (Is in place for all looted creatures)
|
||||
//if (lootRollSession.isAllowRareLoot()){
|
||||
@@ -256,9 +260,9 @@ public class LootService implements INetworkDispatch {
|
||||
Vector<Double> itemChances = (Vector<Double>)core.scriptService.fetchDoubleVector(path,"itemChances");
|
||||
|
||||
double randomItemFromPool = new Random().nextDouble()*100;
|
||||
int remainder = 0; // [10,20,30,34,5,1]
|
||||
double span = 100/itemNames.size();
|
||||
|
||||
double remainder = 0.0; // [10,20,30,34,5,1]
|
||||
double span = 100.0/(double)itemNames.size();
|
||||
|
||||
for (int i=0;i<itemNames.size();i++){
|
||||
if (itemChances.get(0)!=-1.0)
|
||||
remainder += itemChances.get(i);
|
||||
@@ -267,8 +271,9 @@ 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);
|
||||
break;
|
||||
handleLootPoolItems(itemNames.get(i), lootRollSession);
|
||||
//break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,34 +287,34 @@ public class LootService implements INetworkDispatch {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){
|
||||
|
||||
List<String> subfolders = new ArrayList<String>(); // Consider all sub-folders
|
||||
try (DirectoryStream<Path> ds = Files.newDirectoryStream(FileSystems.getDefault().getPath("scripts/loot/lootItems/"), new DirectoriesFilter())) {
|
||||
for (Path p : ds) {
|
||||
subfolders.add(p.getFileName().toString());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
lootRollSession.addErrorMessage("File system check caused an error. Please contact Charon about this issue.");
|
||||
return;
|
||||
}
|
||||
|
||||
String itemPath = "scripts/loot/lootItems/"+itemName.toLowerCase()+".py";
|
||||
File file = new File(itemPath);
|
||||
if (!file.isFile()){
|
||||
for (String subfolderName : subfolders){
|
||||
itemPath = "scripts/loot/lootItems/"+ subfolderName +"/"+itemName.toLowerCase()+".py";
|
||||
File subfile = new File(itemPath);
|
||||
if (subfile.isFile())
|
||||
break;
|
||||
}
|
||||
|
||||
final Vector<String> foundPath = new Vector<String>();
|
||||
Path p = Paths.get("scripts/loot/lootItems/");
|
||||
FileVisitor<Path> fv = new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String actualFileName = file.getFileName().toString();
|
||||
actualFileName = actualFileName.substring(0, actualFileName.length()-3);
|
||||
if (actualFileName.equals(itemName.toLowerCase())){
|
||||
foundPath.add(file.toString());
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
try {
|
||||
Files.walkFileTree(p, fv);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
File checkfile = new File(itemPath);
|
||||
if (!checkfile.isFile()){
|
||||
|
||||
|
||||
if (foundPath.size()==0){
|
||||
String errorMessage = "Loot item '" + itemName + "' not found in file system. Please contact Charon about this issue.";
|
||||
lootRollSession.addErrorMessage(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
String itemPath = foundPath.get(0);
|
||||
|
||||
itemPath = itemPath.substring(0, itemPath.length()-3); // remove the file type
|
||||
|
||||
@@ -358,7 +363,7 @@ public class LootService implements INetworkDispatch {
|
||||
if(core.scriptService.getMethod(itemPath,"","itemStats")!=null)
|
||||
itemStats = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"itemStats");
|
||||
|
||||
if(core.scriptService.getMethod(itemPath,"","itemStats")!=null)
|
||||
if(core.scriptService.getMethod(itemPath,"","itemSkillMods")!=null)
|
||||
itemSkillMods = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"itemSkillMods");
|
||||
|
||||
if(core.scriptService.getMethod(itemPath,"","biolink")!=null)
|
||||
@@ -448,7 +453,7 @@ public class LootService implements INetworkDispatch {
|
||||
|
||||
|
||||
lootRollSession.addDroppedItem(droppedItem);
|
||||
System.err.println("END REACHED");
|
||||
System.out.println("END REACHED");
|
||||
}
|
||||
|
||||
private void handleCustomDropName(TangibleObject droppedItem,String customName) {
|
||||
@@ -954,7 +959,7 @@ public class LootService implements INetworkDispatch {
|
||||
statNumber++;
|
||||
|
||||
|
||||
int primaryAttribute = new Random().nextInt(6); // 0-6
|
||||
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);
|
||||
@@ -972,15 +977,27 @@ public class LootService implements INetworkDispatch {
|
||||
int attribute = primaryAttribute;
|
||||
|
||||
|
||||
// for (int i=0;i<statNumber-1;i++){
|
||||
// while (alreadyUsedStats.contains(attribute)) {
|
||||
// attribute = new Random().nextInt(6);
|
||||
// if (! alreadyUsedStats.contains(attribute)){
|
||||
// droppedItem.setIntAttribute(getAttributeSTF(attribute), getStatValue(minValue,maxValue));
|
||||
// alreadyUsedStats.add(attribute);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
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++){
|
||||
while (alreadyUsedStats.contains(attribute)) {
|
||||
attribute = new Random().nextInt(6);
|
||||
if (! alreadyUsedStats.contains(attribute)){
|
||||
droppedItem.setIntAttribute(getAttributeSTF(attribute), getStatValue(minValue,maxValue));
|
||||
alreadyUsedStats.add(attribute);
|
||||
}
|
||||
}
|
||||
int attributeIndex = new Random().nextInt(statList.size());
|
||||
droppedItem.setIntAttribute(getAttributeSTF(statList.get(attributeIndex)), getStatValue(minValue,maxValue));
|
||||
statList.remove(attributeIndex);
|
||||
}
|
||||
|
||||
return itemName;
|
||||
}
|
||||
|
||||
|
||||
@@ -923,16 +923,10 @@ public class SimulationService implements INetworkDispatch {
|
||||
|
||||
if(container.getPermissions().canView(requester, container)) {
|
||||
OpenedContainerMessage opm = new OpenedContainerMessage(container.getObjectID());
|
||||
if (!(container instanceof CreatureObject))
|
||||
System.out.println("(!(container instanceof CreatureObject)");
|
||||
|
||||
|
||||
if(requester.getClient() != null && requester.getClient().getSession() != null && !(container instanceof CreatureObject))
|
||||
if(requester.getClient() != null && requester.getClient().getSession() != null && !(container instanceof CreatureObject)){
|
||||
requester.getClient().getSession().write(opm.serialize());
|
||||
else
|
||||
System.out.println("NOT SENT");
|
||||
} else {System.out.println("NO VIEW PERMISSION");}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void transform(TangibleObject obj, Point3D position)
|
||||
|
||||
@@ -264,8 +264,7 @@ public class AIActor {
|
||||
}
|
||||
|
||||
public void doStateAction(byte result) {
|
||||
CreatureObject creature = this.getCreature();
|
||||
System.out.println("AI creature.getPosture() " + creature.getPosture() + " result " + result + " getCurrentState " + getCurrentState().getClass().getName());
|
||||
|
||||
switch(result) {
|
||||
|
||||
case StateResult.DEAD:
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
******************************************************************************/
|
||||
package services.ai.states;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
import resources.common.RadialOptions;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import services.ai.AIActor;
|
||||
@@ -32,8 +35,8 @@ public class DeathState extends AIState {
|
||||
public byte onEnter(AIActor actor) {
|
||||
NGECore.getInstance().aiService.awardExperience(actor);
|
||||
actor.getCreature().setAttachment("radial_filename", "npc/corpse");
|
||||
System.out.println("DEATH STATE!!!!");
|
||||
NGECore.getInstance().lootService.DropLoot((CreatureObject)(actor.getCreature().getKiller()),(TangibleObject)(actor.getCreature()));
|
||||
//NGECore.getInstance().scriptService.callScript("scripts/radial/npc/corpse", "", "createRadial", NGECore.getInstance(), actor.getCreature().getKiller(), actor.getCreature(), new Vector<RadialOptions>());
|
||||
NGECore.getInstance().lootService.DropLoot((CreatureObject)(actor.getCreature().getKiller()),(TangibleObject)(actor.getCreature()));
|
||||
actor.scheduleDespawn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SUIService implements INetworkDispatch {
|
||||
|
||||
ObjectMenuRequest request = new ObjectMenuRequest();
|
||||
request.deserialize(data);
|
||||
|
||||
|
||||
SWGObject target = core.objectService.getObject(request.getTargetId());
|
||||
SWGObject owner = core.objectService.getObject(request.getCharacterId());
|
||||
|
||||
@@ -107,6 +107,7 @@ public class SUIService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
if (target instanceof CreatureObject){
|
||||
//System.out.println("SUI target is creatureobject");
|
||||
CreatureObject creature = (CreatureObject) target;
|
||||
if (!creature.isPlayer() && creature.isLootLock()){
|
||||
LootRollSession lootRollSession = (LootRollSession )creature.getAttachment("LootSession");
|
||||
@@ -114,12 +115,22 @@ public class SUIService implements INetworkDispatch {
|
||||
if (lootRollSession.getRequester()!=owner){
|
||||
|
||||
// ToDo: RADIALS MUST BE DISABLED HERE FOR THE CORPSE, BUT HOW?
|
||||
core.scriptService.callScript("scripts/radial/", "npc/noloot", "createRadial", core, owner, target, request.getRadialOptions());
|
||||
target.setAttachment("radial_filename", "npc/noloot");
|
||||
core.scriptService.callScript("scripts/radial/npc/noloot", "", "createRadial", core, owner, target, request.getRadialOptions());
|
||||
sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount());
|
||||
return;
|
||||
} else {
|
||||
// Note: Bugged NPC corpses never make it through here, they are not sent from client at all it seems
|
||||
target.setAttachment("radial_filename", "npc/corpse");
|
||||
core.scriptService.callScript("scripts/radial/npc/corpse", "", "createRadial", core, owner, target, request.getRadialOptions());
|
||||
sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount());
|
||||
//((CreatureObject)owner).sendSystemMessage("Radial set from suiservice", (byte)0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//System.out.println("SUI target is NOT creatureobject " + target.getTemplate());
|
||||
}
|
||||
|
||||
if(target.getGrandparent() != null && target.getGrandparent().getAttachment("structureAdmins") != null)
|
||||
|
||||
Reference in New Issue
Block a user