diff --git a/scripts/loot/rarelootchestcontents/exceptionaltable.py b/scripts/loot/rarelootchestcontents/exceptionaltable.py new file mode 100644 index 00000000..b8c4ba4d --- /dev/null +++ b/scripts/loot/rarelootchestcontents/exceptionaltable.py @@ -0,0 +1,12 @@ + +def itemTemplates(): + templates = ['Biological_Focus_Crystal','Synapse_Focus_Crystal','Concentrated_Bacta_Tank','DNA_Storage_Device_Kowakian'] + templates = templates + ['Dug_Costume_Instructions','Dusk_in_Kachirho','Mercenaries_Despair','Mercenaries_Lament','Nightsister_Melee_Armguard'] + templates = templates + ['Rare_Painting','Sunriders_Destiny'] + return templates + +def itemChances(): + chances = [9,9,9,9] + chances = chances+[9,9,9,9,9] + chances = chances+[9,9] #= 100% + return chances \ No newline at end of file diff --git a/scripts/loot/rarelootchestcontents/legendarytable.py b/scripts/loot/rarelootchestcontents/legendarytable.py new file mode 100644 index 00000000..d372b968 --- /dev/null +++ b/scripts/loot/rarelootchestcontents/legendarytable.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['colorCrystal'] + +def itemChances(): + + return [70] \ No newline at end of file diff --git a/scripts/loot/rarelootchestcontents/raretable.py b/scripts/loot/rarelootchestcontents/raretable.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/object/tangible/item/rare_loot_chest_1.py b/scripts/object/tangible/item/rare_loot_chest_1.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_1.py +++ b/scripts/object/tangible/item/rare_loot_chest_1.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/item/rare_loot_chest_2.py b/scripts/object/tangible/item/rare_loot_chest_2.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_2.py +++ b/scripts/object/tangible/item/rare_loot_chest_2.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/item/rare_loot_chest_3.py b/scripts/object/tangible/item/rare_loot_chest_3.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_3.py +++ b/scripts/object/tangible/item/rare_loot_chest_3.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/radial/lootchest.py b/scripts/radial/lootchest.py new file mode 100644 index 00000000..1a0c9889 --- /dev/null +++ b/scripts/radial/lootchest.py @@ -0,0 +1,13 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.add(RadialOptions(0, 21, 1, 'Open')) + radials.add(RadialOptions(0, 7, 1, '')) + return + +def handleSelection(core, owner, target, option): + if option == 21 and target: + owner.sendSystemMessage('RLS chest content system not yet implemented.',1) + return + \ No newline at end of file diff --git a/src/resources/objects/group/GroupObject.java b/src/resources/objects/group/GroupObject.java index 0cac422d..0f5c4622 100644 --- a/src/resources/objects/group/GroupObject.java +++ b/src/resources/objects/group/GroupObject.java @@ -41,6 +41,11 @@ public class GroupObject extends UniverseObject { private GroupMessageBuilder messageBuilder; private int chatRoomId; + public static int FREE_FOR_ALL = 0; + public static int MASTER_LOOTER = 1; + public static int LOTTERY = 2; + + public GroupObject(long objectId) { super(objectId, null, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/group/shared_group_object.iff"); messageBuilder = new GroupMessageBuilder(this); diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java index cb7c93e4..59e06267 100644 --- a/src/resources/objects/loot/LootRollSession.java +++ b/src/resources/objects/loot/LootRollSession.java @@ -37,25 +37,50 @@ import resources.objects.tangible.TangibleObject; public class LootRollSession { private String SessionID; // leaderName-SystemTime + private boolean sessionValid; private GroupObject playerGroup; private List droppedItems; private Planet sessionPlanet; private List errorMessages; + private int sessionLootMode; + private boolean allowRareLoot; + private boolean increasedRLSChance; public LootRollSession(){ } - public LootRollSession(CreatureObject requester){ + public LootRollSession(CreatureObject requester, TangibleObject lootedObject){ long requesterGroupId = requester.getGroupId(); if (requesterGroupId>0){ this.playerGroup = (GroupObject) NGECore.getInstance().objectService.getObject(requesterGroupId); this.SessionID = playerGroup.getGroupLeader().getCustomName()+"-"+System.currentTimeMillis(); + } else { this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis(); } + + if (lootedObject instanceof CreatureObject){ + CreatureObject lootedCreature = (CreatureObject)lootedObject; + // Exclude rare loot depending on creature level + // For groups maybe average CL? + if (requester.getLevel()-lootedCreature.getLevel()<=6){ + this.setAllowRareLoot(true); + } + } + + // Group situation + if (this.getPlayerGroup()!=null){ + if (this.getPlayerGroup().getMemberList().size()>=4) + this.setIncreasedRLSChance(true); + } + + // Possible AFKer check here + + droppedItems = new ArrayList(); errorMessages = new ArrayList(); sessionPlanet = requester.getPlanet(); + allowRareLoot = false; } public List getDroppedItems() { @@ -89,4 +114,40 @@ public class LootRollSession { public void addErrorMessage(String errorMessage) { this.errorMessages.add(errorMessage); } + + public int getSessionLootMode() { + return sessionLootMode; + } + + public void setSessionLootMode(int sessionLootMode) { + this.sessionLootMode = sessionLootMode; + } + + public boolean isAllowRareLoot() { + return allowRareLoot; + } + + public void setAllowRareLoot(boolean allowRareLoot) { + this.allowRareLoot = allowRareLoot; + } + + public GroupObject getPlayerGroup() { + return playerGroup; + } + + public boolean isIncreasedRLSChance() { + return increasedRLSChance; + } + + public void setIncreasedRLSChance(boolean increasedRLSChance) { + this.increasedRLSChance = increasedRLSChance; + } + + public boolean isSessionValid() { + return sessionValid; + } + + public void setSessionValid(boolean sessionValid) { + this.sessionValid = sessionValid; + } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 3001915f..eccd631f 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -60,7 +60,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=4) +@Persistent(version=5) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -87,6 +87,7 @@ public class TangibleObject extends SWGObject { private List lootGroups = new ArrayList(); private boolean looted = false; + private boolean lootLock = false; @NotPersistent private TangibleObject killer = null; @@ -473,6 +474,14 @@ public class TangibleObject extends SWGObject { this.looted = looted; } + public boolean isLootLock() { + return lootLock; + } + + public void setLootLock(boolean lootLock) { + this.lootLock = lootLock; + } + @Override public void sendBaselines(Client destination) { @@ -497,4 +506,5 @@ public class TangibleObject extends SWGObject { } + } diff --git a/src/services/LootService.java b/src/services/LootService.java index 2b38bf74..4084d8fd 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -39,6 +39,7 @@ import java.util.Random; import java.util.Vector; import resources.objects.creature.CreatureObject; +import resources.objects.group.GroupObject; import resources.objects.loot.LootGroup; import resources.objects.loot.LootRollSession; import resources.objects.tangible.TangibleObject; @@ -72,18 +73,23 @@ public class LootService implements INetworkDispatch { public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { - if (lootedObject.isLooted()) + if (lootedObject.isLooted() || lootedObject.isLootLock()) return; + lootedObject.setLootLock(true); + if (requester.getCustomName().contains("Kun")){ requester.setCashCredits(requester.getCashCredits()+1); requester.sendSystemMessage("You looted 1 credit.", (byte)1); + lootedObject.setLooted(true); return; } - LootRollSession lootRollSession = new LootRollSession(requester); + LootRollSession lootRollSession = new LootRollSession(requester,lootedObject); handleCreditDrop(requester,lootedObject); + + lootSituationAssessment(requester,lootedObject,lootRollSession); CreatureObject lootedCreature = (CreatureObject) lootedObject; @@ -96,12 +102,23 @@ public class LootService implements INetworkDispatch { LootGroup lootGroup = iterator.next(); int groupChance = lootGroup.getLootGroupChance(); int lootGroupRoll = new Random().nextInt(100); - if (lootGroupRoll <= groupChance){ + 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} } } + // Rare Loot System Stage (Is in place for all looted creatures) + if (lootRollSession.isAllowRareLoot()){ + int randomRareLoot = new Random().nextInt(100); + int chanceRequirement = 1; + if (lootRollSession.isIncreasedRLSChance()) + chanceRequirement+=3; // RLS chance is at 4% for groupsize >= 4 + if (randomRareLoot <= chanceRequirement){ + handleRareLootChest(lootRollSession); + } + } + // ********** Phase 1 complete, loot items determined ********** // stored in the lootSession @@ -113,6 +130,8 @@ public class LootService implements INetworkDispatch { for (String msg : lootRollSession.getErrorMessages()){ // ToDo: Show this for each group member later! requester.sendSystemMessage(msg,(byte) 1); + lootedObject.setLootLock(false); + return; } } @@ -121,6 +140,9 @@ public class LootService implements INetworkDispatch { for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){ requesterInventory.add(droppedItem); + if (droppedItem.getAttachment("LootItemName").toString().contains("Loot Chest")){ + requester.playEffectObject("clienteffect/level_granted.cef", ""); + } } lootedObject.setLooted(true); @@ -148,7 +170,7 @@ public class LootService implements INetworkDispatch { for(int i=0;i