Attempts to fix loot bugs

This commit is contained in:
CharonInferar
2014-05-04 01:31:00 +02:00
parent 5e4062ae38
commit 43d1bd5ea4
7 changed files with 84 additions and 22 deletions
View File
+1 -1
View File
@@ -8,7 +8,7 @@ def addTemplate(core):
mobileTemplate.setCreatureName('stormtrooper')
mobileTemplate.setLevel(90)
mobileTemplate.setDifficulty(0)
mobileTemplate.setDifficulty(2)
mobileTemplate.setAttackRange(24)
mobileTemplate.setAttackSpeed(1.0)
mobileTemplate.setWeaponType(0)
+10
View File
@@ -47,6 +47,7 @@ public class LootRollSession {
private boolean allowRareLoot;
private boolean increasedRLSChance;
private int lootedObjectLevel=0;
private int lootedObjectDifficulty=0;
public LootRollSession(){
}
@@ -65,6 +66,7 @@ public class LootRollSession {
if (lootedObject instanceof CreatureObject){
CreatureObject lootedCreature = (CreatureObject)lootedObject;
lootedObjectLevel = lootedCreature.getLevel();
lootedObjectDifficulty = lootedCreature.getDifficulty();
// Exclude rare loot depending on creature level
// For groups maybe average CL?
if (requester.getLevel()-lootedCreature.getLevel()<=6){
@@ -171,4 +173,12 @@ public class LootRollSession {
public void setLootedObjectLevel(int lootedObjectLevel) {
this.lootedObjectLevel = lootedObjectLevel;
}
public int getLootedObjectDifficulty() {
return lootedObjectDifficulty;
}
public void setLootedObjectDifficulty(int lootedObjectDifficulty) {
this.lootedObjectDifficulty = lootedObjectDifficulty;
}
}
+57 -17
View File
@@ -87,6 +87,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());
@@ -898,32 +900,70 @@ public class LootService implements INetworkDispatch {
//determine number of stats #20 yt
int statNumber = 1;
int levelOfDrop = lootRollSession.getLootedObjectLevel();
int difficultyLevel = 1;
int difficultyLevel = lootRollSession.getLootedObjectDifficulty(); // better for calculation
//difficultyLevel++; // better for calculation
if (levelOfDrop>70 && levelOfDrop<90 && difficultyLevel==1)
statNumber = 2;
// if (levelOfDrop>70 && levelOfDrop<90 && difficultyLevel==1)
// statNumber = 2;
//
// if (levelOfDrop>=90 && difficultyLevel==1)
// statNumber = 2;
// int statRoll = new Random().nextInt(100);
// if (statRoll<30)
// statNumber = 3;
//
// if (levelOfDrop>=90 && difficultyLevel>=2){
// statNumber = 2;
// statRoll = new Random().nextInt(100);
// if (statRoll<8)
// statNumber = 4;
// else if (statRoll<50)
// statNumber = 3;
// }
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>=90 && difficultyLevel==1)
statNumber = 2;
int statRoll = new Random().nextInt(100);
if (statRoll<30)
statNumber = 3;
if (levelOfDrop>=90 && difficultyLevel>=2){
statNumber = 2;
statRoll = new Random().nextInt(100);
if (statRoll<8)
statNumber = 4;
else if (statRoll<50)
statNumber = 3;
}
int primaryAttribute = new Random().nextInt(6); // 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;
+12 -2
View File
@@ -916,9 +916,15 @@ 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))
requester.getClient().getSession().write(opm.serialize());
}
else
System.out.println("NOT SENT");
} else {System.out.println("NO VIEW PERMISSION");}
}
@@ -983,6 +989,10 @@ public class SimulationService implements INetworkDispatch {
float heightOrigin = 1.f;
float heightDirection = 1.f;
if (obj2.getTemplate().equals("object/tangible/inventory/shared_character_inventory.iff")){
obj2 = obj2.getContainer(); // LOS message fix on corpse
}
if(obj1 instanceof CreatureObject)
heightOrigin = getHeightOrigin((CreatureObject) obj1);
@@ -1196,7 +1206,7 @@ public class SimulationService implements INetworkDispatch {
float height = (float) (creature.getHeight()/* - 0.3*/);
if(creature.getPosture() == 2 || creature.getPosture() == 13 || creature.getPosture() == 14)
height = 0.3f;
height = 0.45f;
else if(creature.getPosture() == 1)
height /= 2.f;
+2 -1
View File
@@ -229,7 +229,8 @@ 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:
+2 -1
View File
@@ -32,7 +32,8 @@ public class DeathState extends AIState {
public byte onEnter(AIActor actor) {
NGECore.getInstance().aiService.awardExperience(actor);
actor.getCreature().setAttachment("radial_filename", "npc/corpse");
NGECore.getInstance().lootService.DropLoot((CreatureObject)(actor.getCreature().getKiller()),(TangibleObject)(actor.getCreature()));
System.out.println("DEATH STATE!!!!");
NGECore.getInstance().lootService.DropLoot((CreatureObject)(actor.getCreature().getKiller()),(TangibleObject)(actor.getCreature()));
actor.scheduleDespawn();
return 0;
}