From d820b3f90efc05e30dca0fa62609a2b28a10990d Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Wed, 16 Apr 2014 19:25:07 +0200 Subject: [PATCH 1/6] Measures to stabilize Surveyservice Transformed apparent non-entity-connected object-relational dependencies into looser coupled ID-keyed relations to ensure referential integrity Added null pointer checks Removal of null elements out of survey tool collection --- ...lOdbFolders_ONLY_EXECUTE_IN_ODB_FOLDER.bat | 19 +++++++ src/resources/objects/tool/SurveyTool.java | 57 ++++++++++--------- src/services/SurveyService.java | 28 +++++---- 3 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 odb/WipeAllOdbFolders_ONLY_EXECUTE_IN_ODB_FOLDER.bat diff --git a/odb/WipeAllOdbFolders_ONLY_EXECUTE_IN_ODB_FOLDER.bat b/odb/WipeAllOdbFolders_ONLY_EXECUTE_IN_ODB_FOLDER.bat new file mode 100644 index 00000000..ebbd9e09 --- /dev/null +++ b/odb/WipeAllOdbFolders_ONLY_EXECUTE_IN_ODB_FOLDER.bat @@ -0,0 +1,19 @@ +:: Odb file wiper by Charon +:: Use at your own risk! +:: Do NOT execute outside the odb folder +:: because it deletes files in subfolders! + +@echo off +cls +setlocal EnableDelayedExpansion + +set /a count=0 + +for /d %%d in (*) do ( + set /a count+=1 + @echo !count!. %%d + del "%%d\*.*" /s/q + echo. 2>%%d\placeholder.txt +) +setlocal DisableDelayedExpansion + diff --git a/src/resources/objects/tool/SurveyTool.java b/src/resources/objects/tool/SurveyTool.java index a695a078..90dfbc18 100644 --- a/src/resources/objects/tool/SurveyTool.java +++ b/src/resources/objects/tool/SurveyTool.java @@ -23,6 +23,8 @@ package resources.objects.tool; import java.util.Vector; +import main.NGECore; + import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; @@ -41,32 +43,32 @@ import resources.objects.tangible.TangibleObject; @Persistent(version=0) public class SurveyTool extends TangibleObject{ - private byte toolType; - private GalacticResource surveyResource; - private CreatureObject user; - private Long tanoID; - private byte SurveyRangeSetting; + private byte toolType=0; + private long surveyResourceID; + private long userID=0; + private Long tanoID=0L; + private byte SurveyRangeSetting=0; @NotPersistent - private String surveyEffectString; + private String surveyEffectString=""; @NotPersistent - private String sampleEffectString; + private String sampleEffectString=""; @NotPersistent - private boolean currentlySurveying; + private boolean currentlySurveying=false; @NotPersistent - private boolean currentlySampling; + private boolean currentlySampling=false; @NotPersistent - private boolean currentlyCoolingDown; + private boolean currentlyCoolingDown=false; @NotPersistent - private boolean exceptionalState; + private boolean exceptionalState=false; @NotPersistent - private boolean recoveryMode; + private boolean recoveryMode=false; @NotPersistent - private Long lastSurveyTime; + private Long lastSurveyTime=0L; @NotPersistent - private Long lastSampleTime; + private Long lastSampleTime=0L; @NotPersistent - private Long recoveryTime; + private Long recoveryTime=10L; public static byte MineralSurveyDevice = 1; public static byte ChemicalSurveyDevice = 2; @@ -234,12 +236,12 @@ public class SurveyTool extends TangibleObject{ return this.lastSampleTime; } - public void setSurveyResource(GalacticResource surveyResource){ - this.surveyResource = surveyResource; + public void setSurveyResourceID(long surveyResourceID){ + this.surveyResourceID = surveyResourceID; } - public GalacticResource getSurveyResource(){ - return this.surveyResource; + public long getSurveyResourceID(){ + return this.surveyResourceID; } public boolean getCurrentlyCoolingDown() { @@ -258,12 +260,12 @@ public class SurveyTool extends TangibleObject{ this.recoveryTime = recoveryTime; } - public CreatureObject getUser() { - return user; + public long getUserID() { + return userID; } - public void setUser(CreatureObject user) { - this.user = user; + public void setUserID(long userID) { + this.userID = userID; } public Long getTanoID() { @@ -324,9 +326,12 @@ public class SurveyTool extends TangibleObject{ } float differential = surveyRadius / (float) divisor; - GalacticResource resourceToSurvey = this.getSurveyResource(); - Vector concentrationMap = resourceToSurvey.buildConcentrationsCollection(this.getUser().getPosition(),resourceToSurvey, surveyRadius, differential, this.getUser().getPlanetId()); - this.getSurveyResource().constructSurveyMapMessage(this.getUser(), concentrationMap, surveyRadius); + GalacticResource resourceToSurvey = (GalacticResource) NGECore.getInstance().objectService.getObject(this.getSurveyResourceID()); + CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(this.getUserID()); + if (resourceToSurvey==null || user==null) + return; + Vector concentrationMap = resourceToSurvey.buildConcentrationsCollection(user.getPosition(),resourceToSurvey, surveyRadius, differential, user.getPlanetId()); + resourceToSurvey.constructSurveyMapMessage(user, concentrationMap, surveyRadius); //this.getUser().sendSystemMessage("Distance to nearest Deposit : " + this.getSurveyResource().getHelperMinDist(), (byte) 0); } } \ No newline at end of file diff --git a/src/services/SurveyService.java b/src/services/SurveyService.java index db662c14..39b75519 100644 --- a/src/services/SurveyService.java +++ b/src/services/SurveyService.java @@ -21,6 +21,7 @@ ******************************************************************************/ package services; +import java.util.Collections; import java.util.Map; import java.util.Random; import java.util.Vector; @@ -81,6 +82,9 @@ public class SurveyService implements INetworkDispatch { // All tools sampling SurveyTool removeTool=null; for (SurveyTool surveyTool : activeSurveyTools){ + if (surveyTool==null) + continue; + CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID()); if (surveyTool.getCurrentlySurveying()){ // Check if survey process has finished if (System.currentTimeMillis()>surveyTool.getLastSurveyTime()+3000){ @@ -104,19 +108,21 @@ public class SurveyService implements INetworkDispatch { surveyTool.setCurrentlyCoolingDown(false); continueSampling(surveyTool); } - if (surveyTool.getUser().getPosture()!=1){ + if (user.getPosture()!=1){ surveyTool.setExceptionalState(false); surveyTool.setCurrentlySampling(false); removeTool = surveyTool; - if (surveyTool.getUser().getPosture()==0) - surveyTool.getUser().sendSystemMessage("You stand up", (byte) 0); + if (user.getPosture()==0) + user.sendSystemMessage("You stand up", (byte) 0); - surveyTool.getUser().sendSystemMessage("@survey:sample_cancel", (byte) 0); + user.sendSystemMessage("@survey:sample_cancel", (byte) 0); } } } if (removeTool!=null) activeSurveyTools.remove(removeTool); // remove after notification + + activeSurveyTools.removeAll(Collections.singleton(null)); } } @@ -124,9 +130,9 @@ public class SurveyService implements INetworkDispatch { if (surveyTool.isExceptionalState()) return; - CreatureObject crafter = surveyTool.getUser(); + CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID()); PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); - GalacticResource sampleResource = surveyTool.getSurveyResource(); + GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID()); int stackCount = 0; boolean gamblingwon = false; //ResourceContainerObject container = player.getRecentContainer(); @@ -267,7 +273,7 @@ public class SurveyService implements INetworkDispatch { if (surveyTool.getToolType()==-1) return; // Survey tool type was not recognized - surveyTool.setUser(crafter); + surveyTool.setUserID(crafter.getObjectID()); surveyTool.setRecoveryTime(10000L); PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); player.setLastUsedSurveyTool(surveyTool); @@ -302,7 +308,7 @@ public class SurveyService implements INetworkDispatch { surveyTool.setCurrentlySurveying(true); surveyTool.setLastSurveyTime(System.currentTimeMillis()); - surveyTool.setSurveyResource(resource); + surveyTool.setSurveyResourceID(resource.getObjectID()); String effectFile = surveyTool.getSurveyEffectString(); PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition()); @@ -343,7 +349,7 @@ public class SurveyService implements INetworkDispatch { } surveyTool.setCurrentlyCoolingDown(false); - GalacticResource sampleResource = surveyTool.getSurveyResource(); + GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID()); if(surveyTool==null || sampleResource==null) { // QA crafter.sendSystemMessage("You must survey for a resource before you can sample it.", (byte) 0); surveyTool.setExceptionalState(false); @@ -415,7 +421,7 @@ public class SurveyService implements INetworkDispatch { public void continueSampling(SurveyTool surveyTool){ surveyTool.setCurrentlyCoolingDown(false); - CreatureObject crafter = surveyTool.getUser(); + CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID()); PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); if (crafter.getPosture()!=1){ crafter.sendSystemMessage("@survey:sample_cancel", (byte) 0); @@ -432,7 +438,7 @@ public class SurveyService implements INetworkDispatch { return; } - GalacticResource sampleResource = surveyTool.getSurveyResource(); + GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID()); float localConcentration = sampleResource.deliverConcentrationForSurvey(crafter.getPlanetId(), crafter.getPosition().x, crafter.getPosition().z); //float localConcentration = 1.0F; if (localConcentration > 0.1) { From c4be8f160af2fd1439c2a48ad905506f93d89c14 Mon Sep 17 00:00:00 2001 From: Seefo Date: Wed, 16 Apr 2014 13:35:00 -0400 Subject: [PATCH 2/6] Fixed an error in the setgodmode command --- scripts/commands/meditate.py | 4 ++-- scripts/commands/setgodmode.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/commands/meditate.py b/scripts/commands/meditate.py index 9c02f74f..8e0ed60f 100644 --- a/scripts/commands/meditate.py +++ b/scripts/commands/meditate.py @@ -6,8 +6,8 @@ def setup(): def run(core, actor, target, commandString): ##To do make it reset moodanimations when meditation is cancled. - if core.collectionService.isComplete(actor, 'inv_holocron_collection_02') is False: - return + # if core.collectionService.isComplete(actor, 'inv_holocron_collection_02') is False: + # return if actor.getPosture() != 0x08: actor.sendSystemMessage('You need to sit',0) diff --git a/scripts/commands/setgodmode.py b/scripts/commands/setgodmode.py index 84f981c7..e66d7982 100644 --- a/scripts/commands/setgodmode.py +++ b/scripts/commands/setgodmode.py @@ -57,14 +57,13 @@ def run(core, actor, target, commandString): position = Point3D(float(arg3), float(arg4), float(arg5)) core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName(arg2), position, player.getOrientation(), None) - elif command == 'credits' and arg1: actor.setCashCredits(actor.getCashCredits() + int(arg1)) actor.sendSystemMessage('The Galactic Empire has transferred ' + arg1 + ' credits to you for your service.', 0) elif command == 'addability' and arg1: actor.addAbility(str(arg1)) - actor.sendSystemMessage('You have learned ' + arg1 + '') + actor.sendSystemMessage('You have learned ' + arg1 + '.', 0) elif command == 'anim' and arg1: actor.doSkillAnimation(arg1) @@ -110,8 +109,10 @@ def run(core, actor, target, commandString): playerObject.setHoloEmote('holoemote_' + arg1) playerObject.setHoloEmoteUses(20) actor.sendSystemMessage('Holo-Emote Generator set to ' + 'holoemote_' + arg1, 0) + elif command == 'off': if playerObject.getGodLevel > 0: actor.removeAbility("admin") playerObject.setGodLevel(0) + return From e911eebdceb8eb3adbaf59f2902678118ddaded2 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Thu, 17 Apr 2014 04:10:58 +0200 Subject: [PATCH 3/6] Junk Dealer Conversation menu added --- options.cfg | 4 +- scripts/conversation/junk_dealer.py | 122 ++++++++++++++++++++++++++++ scripts/staticNPCs/junk_dealer.py | 6 ++ scripts/static_spawns/tatooine.py | 7 +- 4 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 scripts/conversation/junk_dealer.py create mode 100644 scripts/staticNPCs/junk_dealer.py diff --git a/options.cfg b/options.cfg index 5a3a7f8e..cb743c88 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=1 -LOAD.BUILDOUT_OBJECTS=1 +LOAD.SNAPSHOT_OBJECTS=0 +LOAD.BUILDOUT_OBJECTS=0 LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/conversation/junk_dealer.py b/scripts/conversation/junk_dealer.py new file mode 100644 index 00000000..8259d519 --- /dev/null +++ b/scripts/conversation/junk_dealer.py @@ -0,0 +1,122 @@ +from resources.common import ConversationOption +from resources.common import OutOfBand +from resources.common import ProsePackage +from resources.common import RadialOptions +from services.sui import SUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def startConversation(core, actor, npc): + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_bef51e38') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_54fab04f') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + prose3 = ProsePackage('conversation/junk_dealer_generic', 's_48') + outOfBand3 = OutOfBand() + outOfBand3.addProsePackage(prose3) + prose4 = ProsePackage('conversation/junk_dealer_generic', 's_3aa18b2d') + outOfBand4 = OutOfBand() + outOfBand4.addProsePackage(prose4) + option1 = ConversationOption(outOfBand2, 0) + option2 = ConversationOption(outOfBand3, 1) + option3 = ConversationOption(outOfBand4, 1) + options = Vector() + options.add(option1) + options.add(option2) + options.add(option3) + convSvc.sendConversationOptions(actor, npc, options, handleFirstScreen) + return + +def handleFirstScreen(core, actor, npc, selection): + + if selection == 0: + # sell items + + window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0); + window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:sell_title'); + window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:sell_prompt'); + + for item in actor.getinventoryitems(): + window.addListBoxMenuItem(item.getCustomName(), 0); + + window.setProperty('btnOther:visible', 'True') + window.setProperty('btnCancel:visible', 'True') + window.setProperty('btnOk:visible', 'True') + window.setProperty('btnOther:Text', 'Examine Item') + window.setProperty('btnCancel:Text', '@cancel') + window.setProperty('btnOk:Text', '@loot_dealer:btn_sell') + returnList = Vector() + returnList.add('List.lstList:SelectedRow') + + window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, sellWindowCallBack) + window.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnList, sellWindowCallBack) + window.addHandler(2, '', Trigger.TRIGGER_UPDATE, returnList, sellWindowCallBack) + core.suiService.openSUIWindow(window); + + return + + if selection == 1: + # expertise reset + # TODO: check for prices + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_35') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_71') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + prose3 = ProsePackage('conversation/junk_dealer_generic', 's_72') + outOfBand3 = OutOfBand() + outOfBand3.addProsePackage(prose3) + option1 = ConversationOption(outOfBand2, 0) + option2 = ConversationOption(outOfBand3, 1) + options = Vector() + options.add(option1) + options.add(option2) + convSvc.sendConversationOptions(actor, npc, options, handleResetScreen) + + + return + +def handleRespecScreen(core, actor, npc, selection): + + if selection == 0: + core.skillService.sendRespecWindow(actor) + + core.conversationService.handleEndConversation(actor, npc) + + return + + +def handleResetScreen(core, actor, npc, selection): + + if selection == 0: + core.skillService.resetExpertise(actor) + + core.conversationService.handleEndConversation(actor, npc) + + return + +def endConversation(core, actor, npc): + core.conversationService.sendStopConversation(actor, npc, 'conversation/junk_dealer_generic', 's_38') + return + + +def sellWindowCallBack(owner, window, eventType, returnList): + + if eventType == 0 and len(returnList) == 2: + cashCredits = int(returnList.get(0)) + bankCredits = int(returnList.get(1)) + + if bankCredits + cashCredits == owner.getCashCredits() + owner.getBankCredits(): + owner.setCashCredits(cashCredits) + owner.setBankCredits(bankCredits) + owner.sendSystemMessage('@base_player:bank_success', 0) + return + \ No newline at end of file diff --git a/scripts/staticNPCs/junk_dealer.py b/scripts/staticNPCs/junk_dealer.py new file mode 100644 index 00000000..d2965171 --- /dev/null +++ b/scripts/staticNPCs/junk_dealer.py @@ -0,0 +1,6 @@ + + + + +object = stcSvc.spawnObject('object/mobile/shared_respec_seller_f_1.iff', 'tatooine', long(0), float(3533.14), float(5), float(-4788.86), float(-0.3327), float(0.9288)) +object.setOptionsBitmask(264) \ No newline at end of file diff --git a/scripts/static_spawns/tatooine.py b/scripts/static_spawns/tatooine.py index 7944d2f3..1d52548e 100644 --- a/scripts/static_spawns/tatooine.py +++ b/scripts/static_spawns/tatooine.py @@ -11,7 +11,12 @@ def addPlanetSpawns(core, planet): stcSvc.spawnObject('object/tangible/terminal/shared_terminal_character_builder.iff', 'tatooine', long(0), float(3525), float(4), float(-4801), float(0.70), float(0.71)) #object = stcSvc.spawnObject('object/mobile/shared_respec_seller_f_1.iff', 'tatooine', long(0), float(3533.14), float(5), float(-4788.86), float(-0.3327), float(0.9288)) #object.setOptionsBitmask(264) - + + junkdealer = stcSvc.spawnObject('object/mobile/shared_junk_dealer_m_01.iff', 'tatooine', long(0), float(3525), float(4), float(-4804), float(0.70), float(0.71)) + junkdealer.setOptionsBitmask(264) + junkdealer.setCustomName('Junk Dealer') + junkdealer.setAttachment('radial_filename', 'conversation'); + junkdealer.setAttachment('conversationFile','junk_dealer') return From 2b4527e16592776fc500dce36d3acf6b8110ab58 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Fri, 18 Apr 2014 04:45:12 +0200 Subject: [PATCH 4/6] Conversation menu improvements SUI window functionality storage of items in collections --- scripts/conversation/junk_dealer.py | 275 +++++++++++++++--- .../objects/tangible/TangibleObject.java | 31 +- src/services/LootService.java | 188 ++++++++++++ 3 files changed, 456 insertions(+), 38 deletions(-) diff --git a/scripts/conversation/junk_dealer.py b/scripts/conversation/junk_dealer.py index 8259d519..ba6782b4 100644 --- a/scripts/conversation/junk_dealer.py +++ b/scripts/conversation/junk_dealer.py @@ -7,7 +7,19 @@ from services.sui.SUIWindow import Trigger from java.util import Vector import sys +sellItemListRef = 0 +buyItemListRef = 0 +coreRef = 0 +junkDealerRef = 0 + def startConversation(core, actor, npc): + core.lootService.prepInv(actor) + global coreRef + global junkDealerRef + global sellItemListRef + sellItemListRef = core.lootService.getSellableInventoryItems(actor) + coreRef = core + junkDealerRef = npc convSvc = core.conversationService prose = ProsePackage('conversation/junk_dealer_generic', 's_bef51e38') outOfBand = OutOfBand() @@ -25,10 +37,19 @@ def startConversation(core, actor, npc): option1 = ConversationOption(outOfBand2, 0) option2 = ConversationOption(outOfBand3, 1) option3 = ConversationOption(outOfBand4, 1) + options = Vector() options.add(option1) options.add(option2) options.add(option3) + + if core.lootService.getBuyHistory(actor,npc)!=None: + prose5 = ProsePackage('conversation/junk_dealer_generic', 's_43') + outOfBand5 = OutOfBand() + outOfBand5.addProsePackage(prose5) + option4 = ConversationOption(outOfBand5, 1) + options.add(option4) + convSvc.sendConversationOptions(actor, npc, options, handleFirstScreen) return @@ -36,18 +57,28 @@ def handleFirstScreen(core, actor, npc, selection): if selection == 0: # sell items - - window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0); - window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:sell_title'); - window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:sell_prompt'); - - for item in actor.getinventoryitems(): + + sellItemListRef = core.lootService.getSellableInventoryItems(actor) + + if len(sellItemListRef) == 0: + actor.sendSystemMessage('@loot_dealer:no_items', 1) + startConversation(coreRef,actor,junkDealerRef) + return # no point + + window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0) + window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:sell_title') + window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:sell_prompt') + + + + for item in sellItemListRef: window.addListBoxMenuItem(item.getCustomName(), 0); + actor.sendSystemMessage('ddf ' + item.getCustomName(), 1) window.setProperty('btnOther:visible', 'True') window.setProperty('btnCancel:visible', 'True') window.setProperty('btnOk:visible', 'True') - window.setProperty('btnOther:Text', 'Examine Item') + window.setProperty('btnOther:Text', '@loot_dealer:examine') window.setProperty('btnCancel:Text', '@cancel') window.setProperty('btnOk:Text', '@loot_dealer:btn_sell') returnList = Vector() @@ -61,28 +92,70 @@ def handleFirstScreen(core, actor, npc, selection): return if selection == 1: - # expertise reset - # TODO: check for prices - convSvc = core.conversationService - prose = ProsePackage('conversation/junk_dealer_generic', 's_35') - outOfBand = OutOfBand() - outOfBand.addProsePackage(prose) - convSvc.sendConversationMessage(actor, npc, outOfBand) - prose2 = ProsePackage('conversation/junk_dealer_generic', 's_71') - outOfBand2 = OutOfBand() - outOfBand2.addProsePackage(prose2) - prose3 = ProsePackage('conversation/junk_dealer_generic', 's_72') - outOfBand3 = OutOfBand() - outOfBand3.addProsePackage(prose3) - option1 = ConversationOption(outOfBand2, 0) - option2 = ConversationOption(outOfBand3, 1) - options = Vector() - options.add(option1) - options.add(option2) - convSvc.sendConversationOptions(actor, npc, options, handleResetScreen) + # mark items + window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0) + window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:junk_no_sell_title') + window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:junk_no_sell_desc') + + sellItemListRef = core.lootService.getSellableInventoryItems(actor) + + for item in sellItemListRef: + nameString = item.getCustomName() + nameString = 'TestJunkItem' + if item.isNoSell(): + nameString = '[*No Sell*]' + item.getCustomName() + window.addListBoxMenuItem(nameString, 0) + else: + nameString = '[*Sell*]' + item.getCustomName() + window.addListBoxMenuItem(nameString, 0) + + window.setProperty('btnOther:visible', 'True') + window.setProperty('btnCancel:visible', 'True') + window.setProperty('btnOk:visible', 'True') + window.setProperty('btnOther:Text', '@loot_dealer:examine') + window.setProperty('btnCancel:Text', '@cancel') + window.setProperty('btnOk:Text', '@loot_dealer:junk_no_sell_button') + returnList = Vector() + returnList.add('List.lstList:SelectedRow') + + #window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, noSellWindowCallBack) + #window.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnList, noSellWindowCallBack) + window.addHandler(0, '',9, returnList, noSellWindowCallBack) + window.addHandler(1, '',10, returnList, noSellWindowCallBack) + window.addHandler(2, '',11, returnList, noSellWindowCallBack) + core.suiService.openSUIWindow(window); + return + + if selection == 3: + # buy back - - return + window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0) + window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:buy_back_title') + window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:buy_back_prompt') + + buyHistory = core.lootService.getBuyHistory(actor,junkDealerRef) + if buyHistory==None: + return + + for item in buyHistory: + nameString = '[%s' % 100 + ']' + item.getCustomName() #%item.getJunkDealerPrice() + window.addListBoxMenuItem(nameString, 0) + + window.setProperty('btnOther:visible', 'True') + window.setProperty('btnCancel:visible', 'True') + window.setProperty('btnOk:visible', 'True') + window.setProperty('btnOther:Text', '@loot_dealer:examine') + window.setProperty('btnCancel:Text', '@cancel') + window.setProperty('btnOk:Text', '@loot_dealer:btn_buy_back') + returnList = Vector() + returnList.add('List.lstList:SelectedRow') + + window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, buyBackWindowCallBack) + window.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnList, buyBackWindowCallBack) + window.addHandler(2, '', Trigger.TRIGGER_UPDATE, returnList, buyBackWindowCallBack) + core.suiService.openSUIWindow(window); + + return def handleRespecScreen(core, actor, npc, selection): @@ -109,14 +182,142 @@ def endConversation(core, actor, npc): def sellWindowCallBack(owner, window, eventType, returnList): - - if eventType == 0 and len(returnList) == 2: - cashCredits = int(returnList.get(0)) - bankCredits = int(returnList.get(1)) - - if bankCredits + cashCredits == owner.getCashCredits() + owner.getBankCredits(): - owner.setCashCredits(cashCredits) - owner.setBankCredits(bankCredits) - owner.sendSystemMessage('@base_player:bank_success', 0) + + if returnList.get(0) == 0: + owner.sendSystemMessage("huh?", 1) + #startConversation(coreRef,owner,junkDealerRef) + return + + #sell + if eventType == 0: + + sellItem = sellItemListRef.get(int(returnList.get(0))) + + #if len(sellItemListRef): + #owner.sendSystemMessage('@junk_dealer:no_items', 1) + #return + + if sellItem == None: + owner.sendSystemMessage('@junk_dealer:no_items', 1) + return + + inventory = owner.getSlottedObject('inventory') + + + junkPrice = 20 + owner.setCashCredits(owner.getCashCredits()+junkPrice); + + # add item to 10-item junk dealer history + coreRef.lootService.addToBuyHistory(owner,junkDealerRef,sellItem) + + #You sell %TT for %DI credits. + owner.sendSystemMessage("sold "+sellItem.getCustomName(), 1) + #owner.sendSystemMessage(ProsePackage("@junk_dealer:prose_sold_junk", "TT", sellItem.getCustomName()), 0) + + inventory.remove(sellItem) + + coreRef.suiService.closeSUIWindow(owner,window.getWindowId()); + handleFirstScreen(coreRef, owner, junkDealerRef, 0) + return + + #cancel + if eventType == 1: + owner.sendSystemMessage("cancel ", 1) + #coreRef.suiService.closeSUIWindow(window,window.getWindowId()); + #startConversation(coreRef,owner,junkDealerRef) + return + + #examine + if eventType == 2: + owner.sendSystemMessage("examine ", 1) + #coreRef.suiService.closeSUIWindow(window,window.getWindowId()); + #startConversation(coreRef,owner,junkDealerRef) + #owner.sendSystemMessage('Examine', 0) + return + return + +def noSellWindowCallBack(owner, window, eventType, returnList): + + if returnList.get(0) == 0: + startConversation(coreRef,owner,junkDealerRef) + return + + #toggle + if eventType == 0: + owner.sendSystemMessage('Toggle', 0) + toggleItem = sellItemListRef.get(int(returnList.get(0))) + if toggleItem.isNoSell(): + toggleItem.setNoSell(0) + else: + toggleItem.setNoSell(1) + + #core.suiService.closeSUIWindow(window); + handleFirstScreen(coreRef, owner, junkDealerRef, 1) + return + + #cancel + if eventType == 1: + owner.sendSystemMessage('Cancle', 0) + sellItem = returnList.get(0) + startConversation(coreRef,owner,junkDealerRef) + return + + #examine + if eventType == 2: + owner.sendSystemMessage('Ex', 0) + sellItem = returnList.get(0) + startConversation(coreRef,owner,junkDealerRef) + owner.sendSystemMessage('Examine', 0) + return + +def buyBackWindowCallBack(owner, window, eventType, returnList): + + if returnList.get(0) == 0: + startConversation(coreRef,owner,junkDealerRef) + return + + #buy + if eventType == 0: + index = int(returnList.get(0)) + buyHistory = coreRef.lootService.getBuyHistory(owner,junkDealerRef) + if len(buyHistory) == 0: + owner.sendSystemMessage('@loot_dealer:no_buy_back_items_found', 1) + + buyBackItem = buyHistory.get(index) + + if buyBackItem == None: + owner.sendSystemMessage('@loot_dealer:no_buy_back_items_found', 0) + startConversation(coreRef,owner,junkDealerRef) + return + + junkPrice = 20 + if owner.getCashCredits()>=junkPrice and owner.getInventoryItemCount() < 80: + owner.setCashCredits(owner.getCashCredits()-junkPrice) + inventory = owner.getSlottedObject('inventory') + inventory.add(buyBackItem) + # remove from junk dealer history + coreRef.lootService.removeBoughtBackItemFromHistory(owner,junkDealerRef,buyBackItem) + else: + owner.sendSystemMessage('@loot_dealer:prose_no_buy_back', 0) + + coreRef.suiService.closeSUIWindow(owner,window.getWindowId()); + handleFirstScreen(coreRef, owner, junkDealerRef, 3) + return + + #cancel + if eventType == 1: + owner.sendSystemMessage('Cancle', 0) + sellItem = returnList.get(0) + startConversation(coreRef,owner,junkDealerRef) + return + + #examine + if eventType == 2: + owner.sendSystemMessage('Ex', 0) + sellItem = returnList.get(0) + startConversation(coreRef,owner,junkDealerRef) + owner.sendSystemMessage('Examine', 0) + return + \ No newline at end of file diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 80240884..04f72677 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -53,7 +53,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=9) +@Persistent(version=10) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -89,6 +89,11 @@ public class TangibleObject extends SWGObject { @NotPersistent private boolean lootItem = false; + private boolean noSell = false; + private byte junkType = -1; + private int junkDealerPrice = 0; + + private String serialNumber; @NotPersistent @@ -499,6 +504,30 @@ public class TangibleObject extends SWGObject { this.lootItem = lootItem; } + public boolean isNoSell() { + return noSell; + } + + public void setNoSell(boolean noSell) { + this.noSell = noSell; + } + + public byte getJunkType() { + return junkType; + } + + public void setJunkType(byte junkType) { + this.junkType = junkType; + } + + public int getJunkDealerPrice() { + return junkDealerPrice; + } + + public void setJunkDealerPrice(int junkDealerPrice) { + this.junkDealerPrice = junkDealerPrice; + } + public boolean isCreditRelieved() { return creditRelieved; } diff --git a/src/services/LootService.java b/src/services/LootService.java index ca40b77f..e8788c1d 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -29,8 +29,10 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Random; @@ -42,12 +44,14 @@ import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.loot.LootGroup; import resources.objects.loot.LootRollSession; +import resources.objects.resource.ResourceContainerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; import main.NGECore; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.CrcStringTableVisitor; import engine.resources.common.CRC; +import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; @@ -62,6 +66,7 @@ import engine.resources.service.INetworkRemoteEvent; public class LootService implements INetworkDispatch { private NGECore core; + private static int prepInvCnt = 0; public LootService(NGECore core) { this.core = core; @@ -784,6 +789,189 @@ public class LootService implements INetworkDispatch { } + // ********* Junk-dealer related ********* + + public Vector getSellableInventoryItems(CreatureObject actor){ + TangibleObject playerInventory = (TangibleObject) actor.getSlottedObject("inventory"); + final Vector sellableItems = new Vector(); + playerInventory.viewChildren(actor, false, false, new Traverser() { + @Override + public void process(SWGObject obj) { + String itemTemplate = obj.getTemplate(); + if (itemTemplate.contains("loot/")){ + sellableItems.add(obj); + } + } + }); + System.err.println("sellableItems " + sellableItems.size()); + return sellableItems; + } + + public void addToSoldHistory(CreatureObject actor, TangibleObject item){ + + } + + public boolean haveBusinessHistory(CreatureObject actor, CreatureObject dealer){ + return true; + } + + @SuppressWarnings("unchecked") + public Vector getBuyHistory(CreatureObject actor, CreatureObject dealer){ + LinkedHashMap businessHistory = (LinkedHashMap )dealer.getAttachment("BusinessHistory"); + if (businessHistory==null){ + businessHistory = new LinkedHashMap(); + dealer.setAttachment("BusinessHistory",businessHistory); + } + + TangibleObject[] actorsBuyHistory = businessHistory.get(actor.getObjectID()); + if (actorsBuyHistory==null) + return new Vector(); + + Vector actorHistory = new Vector(); + for (TangibleObject item : actorsBuyHistory){ + if (item!=null) + actorHistory.add(item); + } + return actorHistory; + } + + @SuppressWarnings("unchecked") + public boolean addToBuyHistory(CreatureObject actor, CreatureObject dealer, TangibleObject item){ + LinkedHashMap businessHistory = (LinkedHashMap )dealer.getAttachment("BusinessHistory"); + if (businessHistory==null){ + System.out.println("businessHistory==null"); + businessHistory = new LinkedHashMap(); + dealer.setAttachment("BusinessHistory",businessHistory); + } + System.out.println("abusinessHistory.size " + businessHistory.size()); + TangibleObject[] actorsBuyHistory = businessHistory.get(actor.getObjectID()); + if (actorsBuyHistory==null){ + System.out.println("actorsBuyHistory==null"); + actorsBuyHistory = new TangibleObject[10]; + actorsBuyHistory[0] = item; + } else { + // Check Array for zeros + int lastObject=0; + for (int i=0;i>shift right and add + for (int i = 8; i >= 0; i--) { + actorsBuyHistory[i+1] = actorsBuyHistory[i]; + } + actorsBuyHistory[0] = item; + } else { + actorsBuyHistory[lastObject+1] = item; + } + } + businessHistory.put(actor.getObjectID(),actorsBuyHistory); + dealer.setAttachment("BusinessHistory",businessHistory); + printArrayElements(actorsBuyHistory); + return true; + } + + public boolean removeBoughtBackItemFromHistory(CreatureObject actor, CreatureObject dealer, TangibleObject item){ + if (item==null) + return false; // Player has hit the button without selecting an item + LinkedHashMap businessHistory = (LinkedHashMap )dealer.getAttachment("BusinessHistory"); + if (businessHistory==null){ + return false; // something went seriously wrong. At this point the dealer should have a history + } + TangibleObject[] actorsBuyHistory = businessHistory.get(actor.getObjectID()); + if (actorsBuyHistory==null) + return false; // Player has no history entry + // Find the element index + int index = -1; + for (int i=0;i<10;i++){ + if (actorsBuyHistory[i]!=null){ + if (item.getObjectID()==actorsBuyHistory[i].getObjectID()){ + index = i; + } + } + } + + if (index==-1) + return false; + + // SHift everything to the right of the found index to the left + for (int i = index; i < 9; i++) { + actorsBuyHistory[i] = actorsBuyHistory[i+1]; // 0 1 2 3 4 5 6 7 8 9 + } + if (index!=-1) + actorsBuyHistory[9]=null; + + businessHistory.put(actor.getObjectID(),actorsBuyHistory); + dealer.setAttachment("BusinessHistory",businessHistory); + printArrayElements(actorsBuyHistory); + return true; + } + + + // util method + private void printArrayElements(TangibleObject[] array){ + System.out.print("Array ["); + for (int i=0;i0) + return; + prepInvCnt++; + SWGObject playerInventory = player.getSlottedObject("inventory"); + TangibleObject item1 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_impulse_detector_01_generic.iff", player.getPlanet()); + item1.setCustomName("Impulse Detector"); + playerInventory.add(item1); + + TangibleObject item2 = (TangibleObject)core.objectService.createObject("object/tangible/loot/misc/shared_damaged_datapad.iff", player.getPlanet()); + item2.setCustomName("Damaged Datapad"); + playerInventory.add(item2); + + TangibleObject item3 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_software_module_generic.iff", player.getPlanet()); + item3.setCustomName("Software Module"); + playerInventory.add(item3); + + TangibleObject item4 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_survival_equipment_generic.iff", player.getPlanet()); + item4.setCustomName("Survival Gear"); + playerInventory.add(item4); + + TangibleObject item5 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_shield_module_generic.iff", player.getPlanet()); + item5.setCustomName("Shield Module"); + playerInventory.add(item5); + + TangibleObject item6 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_firework_generic.iff", player.getPlanet()); + item6.setCustomName("Explosive Dud"); + playerInventory.add(item6); + + TangibleObject item7 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_launcher_tube_generic.iff", player.getPlanet()); + item7.setCustomName("Launcher Tube"); + playerInventory.add(item7); + + TangibleObject item8 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_red_wiring_generic.iff", player.getPlanet()); + item8.setCustomName("Red Wiring"); + playerInventory.add(item8); + + TangibleObject item9 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_laser_trap_generic.iff", player.getPlanet()); + item9.setCustomName("Laser Trap"); + playerInventory.add(item9); + + TangibleObject item10 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_comlink_civilian_generic.iff", player.getPlanet()); + item10.setCustomName("Comlink"); + playerInventory.add(item10); + + TangibleObject item11 = (TangibleObject)core.objectService.createObject("object/tangible/loot/npc_loot/shared_armor_repair_device_generic.iff", player.getPlanet()); + item11.setCustomName("Armor Repair Device"); + playerInventory.add(item11); + } + + /* 1377 wpn_category_0 Rifle 1378 wpn_category_1 Carbine From 4f60260e5313129934c136f9a64f88cc5de93a3a Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Fri, 18 Apr 2014 20:57:56 +0200 Subject: [PATCH 5/6] Menu functionality improved Lootkit implemented Loot price and further stats considered --- scripts/conversation/junk_dealer.py | 311 ++++++++++++++++-- .../armor/composite_armor_bicep_left.py | 2 +- .../armor/composite_armor_bicep_right.py | 2 +- .../lootItems/armor/composite_armor_boots.py | 2 +- .../armor/composite_armor_bracer_left.py | 2 +- .../armor/composite_armor_bracer_right.py | 2 +- .../armor/composite_armor_chestplate.py | 2 +- .../lootItems/armor/composite_armor_gloves.py | 2 +- .../lootItems/armor/composite_armor_helmet.py | 2 +- .../armor/composite_armor_leggings.py | 2 +- .../clothes/tusken_raider_bandolier.py | 2 +- .../lootItems/clothes/tusken_raider_boots.py | 2 +- .../lootItems/clothes/tusken_raider_dress.py | 2 +- .../lootItems/clothes/tusken_raider_gloves.py | 2 +- .../lootItems/clothes/tusken_raider_helmet.py | 2 +- .../{junk => creatureloot}/antenna.py | 4 + .../lootItems/{junk => creatureloot}/brain.py | 0 .../lootItems/{junk => creatureloot}/eye.py | 4 + .../lootItems/{junk => creatureloot}/gland.py | 0 .../lootItems/{junk => creatureloot}/heart.py | 4 + .../{junk => creatureloot}/stomach.py | 4 + .../lootItems/junk/armor_repair_device.py | 17 + .../loot/lootItems/junk/chassis_blueprint.py | 14 +- scripts/loot/lootItems/junk/comlink.py | 14 +- .../loot/lootItems/junk/damaged_datapad.py | 12 + scripts/loot/lootItems/junk/ear_jewel.py | 4 + scripts/loot/lootItems/junk/explosive_dud.py | 16 + .../loot/lootItems/junk/hyperdrive_unit.py | 16 + scripts/loot/lootItems/junk/id_chip.py | 12 + .../loot/lootItems/junk/impulse_detector.py | 16 + scripts/loot/lootItems/junk/laser_trap.py | 16 + scripts/loot/lootItems/junk/launcher_tube.py | 14 +- scripts/loot/lootItems/junk/ledger.py | 16 + .../loot/lootItems/junk/magseal_detector.py | 16 + .../loot/lootItems/junk/medical_console.py | 16 + scripts/loot/lootItems/junk/medical_device.py | 16 + scripts/loot/lootItems/junk/motor.py | 16 + .../lootItems/junk/power_output_analyzer.py | 16 + scripts/loot/lootItems/junk/red_wiring.py | 16 + scripts/loot/lootItems/junk/shield_module.py | 16 + .../loot/lootItems/junk/software_module.py | 16 + scripts/loot/lootItems/junk/survival_gear.py | 16 + .../lootItems/junk/underpowered_survey_pad.py | 16 + .../lootItems/junk/unidentified_serum_vial.py | 16 + scripts/loot/lootItems/junk/used_notebook.py | 16 + .../loot/lootItems/junk/weak_droid_battery.py | 16 + .../loot/lootItems/junk/worklight_generic.py | 16 + .../loot/lootItems/weapons/gaderiffi_baton.py | 2 +- scripts/static_spawns/tatooine.py | 2 +- .../objects/tangible/TangibleObject.java | 20 +- src/services/LootService.java | 67 ++-- 51 files changed, 764 insertions(+), 73 deletions(-) rename scripts/loot/lootItems/{junk => creatureloot}/antenna.py (70%) rename scripts/loot/lootItems/{junk => creatureloot}/brain.py (100%) rename scripts/loot/lootItems/{junk => creatureloot}/eye.py (71%) rename scripts/loot/lootItems/{junk => creatureloot}/gland.py (100%) rename scripts/loot/lootItems/{junk => creatureloot}/heart.py (71%) rename scripts/loot/lootItems/{junk => creatureloot}/stomach.py (70%) diff --git a/scripts/conversation/junk_dealer.py b/scripts/conversation/junk_dealer.py index ba6782b4..7c146b0f 100644 --- a/scripts/conversation/junk_dealer.py +++ b/scripts/conversation/junk_dealer.py @@ -13,7 +13,7 @@ coreRef = 0 junkDealerRef = 0 def startConversation(core, actor, npc): - core.lootService.prepInv(actor) + #core.lootService.prepInv(actor) global coreRef global junkDealerRef global sellItemListRef @@ -43,7 +43,7 @@ def startConversation(core, actor, npc): options.add(option2) options.add(option3) - if core.lootService.getBuyHistory(actor,npc)!=None: + if len(core.lootService.getBuyHistory(actor,npc))!= 0: prose5 = ProsePackage('conversation/junk_dealer_generic', 's_43') outOfBand5 = OutOfBand() outOfBand5.addProsePackage(prose5) @@ -54,10 +54,17 @@ def startConversation(core, actor, npc): return def handleFirstScreen(core, actor, npc, selection): - + + convSvc = core.conversationService + if selection == 0: # sell items + prose = ProsePackage('conversation/junk_dealer_generic', 's_84a67771') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + sellItemListRef = core.lootService.getSellableInventoryItems(actor) if len(sellItemListRef) == 0: @@ -68,12 +75,9 @@ def handleFirstScreen(core, actor, npc, selection): window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0) window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:sell_title') window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:sell_prompt') - - - + for item in sellItemListRef: window.addListBoxMenuItem(item.getCustomName(), 0); - actor.sendSystemMessage('ddf ' + item.getCustomName(), 1) window.setProperty('btnOther:visible', 'True') window.setProperty('btnCancel:visible', 'True') @@ -106,7 +110,7 @@ def handleFirstScreen(core, actor, npc, selection): nameString = '[*No Sell*]' + item.getCustomName() window.addListBoxMenuItem(nameString, 0) else: - nameString = '[*Sell*]' + item.getCustomName() + nameString = '[Sellable]' + item.getCustomName() window.addListBoxMenuItem(nameString, 0) window.setProperty('btnOther:visible', 'True') @@ -125,10 +129,25 @@ def handleFirstScreen(core, actor, npc, selection): window.addHandler(2, '',11, returnList, noSellWindowCallBack) core.suiService.openSUIWindow(window); return - + + if selection == 2: + lootKitScreen1(core, actor, npc) + + if selection == 3: # buy back - + + buyHistory = coreRef.lootService.getBuyHistory(actor,npc) + if len(buyHistory) == 0: + actor.sendSystemMessage('@loot_dealer:no_buy_back_items_found', 1) + startConversation(coreRef,actor,npc) + return + + prose = ProsePackage('conversation/junk_dealer_generic', 's_44') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + window = core.suiService.createSUIWindow('Script.listBox', actor, npc, 0) window.setProperty('bg.caption.lblTitle:Text', '@loot_dealer:buy_back_title') window.setProperty('Prompt.lblPrompt:Text', '@loot_dealer:buy_back_prompt') @@ -137,8 +156,13 @@ def handleFirstScreen(core, actor, npc, selection): if buyHistory==None: return + + for item in buyHistory: - nameString = '[%s' % 100 + ']' + item.getCustomName() #%item.getJunkDealerPrice() + junkDealerPrice = item.getJunkDealerPrice() + if junkDealerPrice == 0: + junkDealerPrice = 20 + nameString = '[%s' % junkDealerPrice + ']' + item.getCustomName() #% window.addListBoxMenuItem(nameString, 0) window.setProperty('btnOther:visible', 'True') @@ -177,16 +201,13 @@ def handleResetScreen(core, actor, npc, selection): return def endConversation(core, actor, npc): - core.conversationService.sendStopConversation(actor, npc, 'conversation/junk_dealer_generic', 's_38') + core.conversationService.sendStopConversation(actor, npc, 'conversation/junk_dealer_generic', 's_4bd9d15e') return def sellWindowCallBack(owner, window, eventType, returnList): - if returnList.get(0) == 0: - owner.sendSystemMessage("huh?", 1) - #startConversation(coreRef,owner,junkDealerRef) - return + sellItemListRef = coreRef.lootService.getSellableInventoryItems(owner) #sell if eventType == 0: @@ -204,33 +225,33 @@ def sellWindowCallBack(owner, window, eventType, returnList): inventory = owner.getSlottedObject('inventory') - junkPrice = 20 - owner.setCashCredits(owner.getCashCredits()+junkPrice); + junkDealerPrice = sellItem.getJunkDealerPrice() + if junkDealerPrice == 0: + junkDealerPrice = 20 + owner.setCashCredits(owner.getCashCredits()+junkDealerPrice) # add item to 10-item junk dealer history coreRef.lootService.addToBuyHistory(owner,junkDealerRef,sellItem) - #You sell %TT for %DI credits. - owner.sendSystemMessage("sold "+sellItem.getCustomName(), 1) - #owner.sendSystemMessage(ProsePackage("@junk_dealer:prose_sold_junk", "TT", sellItem.getCustomName()), 0) + owner.sendSystemMessage(OutOfBand.ProsePackage("@junk_dealer:prose_sold_junk", "TT", sellItem.getCustomName(),junkDealerPrice), 0) inventory.remove(sellItem) - coreRef.suiService.closeSUIWindow(owner,window.getWindowId()); + coreRef.suiService.closeSUIWindow(owner,window.getWindowId()) handleFirstScreen(coreRef, owner, junkDealerRef, 0) return #cancel if eventType == 1: owner.sendSystemMessage("cancel ", 1) - #coreRef.suiService.closeSUIWindow(window,window.getWindowId()); - #startConversation(coreRef,owner,junkDealerRef) + coreRef.suiService.closeSUIWindow(owner,window.getWindowId()) + startConversation(coreRef,owner,junkDealerRef) return #examine if eventType == 2: owner.sendSystemMessage("examine ", 1) - #coreRef.suiService.closeSUIWindow(window,window.getWindowId()); + #coreRef.suiService.closeSUIWindow(window,window.getWindowId()) #startConversation(coreRef,owner,junkDealerRef) #owner.sendSystemMessage('Examine', 0) return @@ -252,7 +273,7 @@ def noSellWindowCallBack(owner, window, eventType, returnList): else: toggleItem.setNoSell(1) - #core.suiService.closeSUIWindow(window); + #core.suiService.closeSUIWindow(window) handleFirstScreen(coreRef, owner, junkDealerRef, 1) return @@ -273,6 +294,8 @@ def noSellWindowCallBack(owner, window, eventType, returnList): def buyBackWindowCallBack(owner, window, eventType, returnList): + convSvc = coreRef.conversationService + if returnList.get(0) == 0: startConversation(coreRef,owner,junkDealerRef) return @@ -283,6 +306,8 @@ def buyBackWindowCallBack(owner, window, eventType, returnList): buyHistory = coreRef.lootService.getBuyHistory(owner,junkDealerRef) if len(buyHistory) == 0: owner.sendSystemMessage('@loot_dealer:no_buy_back_items_found', 1) + startConversation(coreRef,owner,junkDealerRef) + return buyBackItem = buyHistory.get(index) @@ -290,12 +315,24 @@ def buyBackWindowCallBack(owner, window, eventType, returnList): owner.sendSystemMessage('@loot_dealer:no_buy_back_items_found', 0) startConversation(coreRef,owner,junkDealerRef) return + + if owner.getInventoryItemCount() >= 80: + prose = ProsePackage('conversation/junk_dealer_generic', 's_47') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(owner, junkDealerRef, outOfBand) + return - junkPrice = 20 - if owner.getCashCredits()>=junkPrice and owner.getInventoryItemCount() < 80: - owner.setCashCredits(owner.getCashCredits()-junkPrice) + junkDealerPrice = buyBackItem.getJunkDealerPrice() + if junkDealerPrice == 0: + junkDealerPrice = 20 + owner.setCashCredits(owner.getCashCredits()+junkDealerPrice) + + if owner.getCashCredits()>=junkDealerPrice: + owner.setCashCredits(owner.getCashCredits()-junkDealerPrice) inventory = owner.getSlottedObject('inventory') inventory.add(buyBackItem) + owner.sendSystemMessage('You buy back ' + buyBackItem.getCustomName() + ' for %s' % junkDealerPrice + ' credits.', 0) # remove from junk dealer history coreRef.lootService.removeBoughtBackItemFromHistory(owner,junkDealerRef,buyBackItem) else: @@ -307,7 +344,7 @@ def buyBackWindowCallBack(owner, window, eventType, returnList): #cancel if eventType == 1: - owner.sendSystemMessage('Cancle', 0) + owner.sendSystemMessage('Cancel', 0) sellItem = returnList.get(0) startConversation(coreRef,owner,junkDealerRef) return @@ -319,5 +356,217 @@ def buyBackWindowCallBack(owner, window, eventType, returnList): startConversation(coreRef,owner,junkDealerRef) owner.sendSystemMessage('Examine', 0) return + +def handleLootScreenSelection1(core, actor, npc, selection): + + convSvc = core.conversationService + if selection == 0: + lootKitScreen1(core, actor, npc) + + return + +def handleLootScreenSelection2(core, actor, npc, selection): + + convSvc = core.conversationService + if selection == 0: + lootKitScreen2(core, actor, npc) + + return + +def handleLootScreenSelection3(core, actor, npc, selection): + + convSvc = core.conversationService + if selection == 0: + lootKitScreen3(core, actor, npc) + + return + +def handleLootScreenSelection4(core, actor, npc, selection): + + convSvc = core.conversationService + if selection == 0: + lootKitScreen4(core, actor, npc) + + return + +def handleLootScreenSelection5(core, actor, npc, selection): + + convSvc = core.conversationService + if selection == 0: + lootKitScreen5a(core, actor, npc) - \ No newline at end of file + if selection == 1: + lootKitScreen5b(core, actor, npc) + + return + +def handleLootScreenSelection6(core, actor, npc, selection): + + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_14efaaa2') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + if selection == 0: + template = 'object/tangible/loot/collectible/kits/shared_orange_rug_kit.iff' + addLootKit(core, actor, npc,template) + + if selection == 1: + template = 'object/tangible/loot/collectible/kits/shared_blue_rug_kit.iff' + addLootKit(core, actor, npc,template) + + if selection == 2: + template = 'object/tangible/loot/collectible/kits/shared_gong_kit.iff' + addLootKit(core, actor, npc,template) + + if selection == 3: + template = 'object/tangible/loot/collectible/kits/shared_light_table_kit.iff' + addLootKit(core, actor, npc,template) + + if selection == 4: + template = 'object/tangible/loot/collectible/kits/shared_sculpture_kit.iff' + addLootKit(core, actor, npc,template) + + return + +def addLootKit(core, actor, npc,template): + + kit = core.objectService.createObject(template, actor.getPlanet()) + inventory = actor.getSlottedObject('inventory') + inventory.add(kit) + return + +def lootKitScreen1(core, actor, npc): + + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_d9e6b751') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_6d53d062') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + + option1 = ConversationOption(outOfBand2, 0) + + options = Vector() + options.add(option1) + + convSvc.sendConversationOptions(actor, npc, options, handleLootScreenSelection2) + + return + +def lootKitScreen2(core, actor, npc): + + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_e29f48dc') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_324b9b0f') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + + option1 = ConversationOption(outOfBand2, 0) + + options = Vector() + options.add(option1) + + convSvc.sendConversationOptions(actor, npc, options, handleLootScreenSelection3) + + return + +def lootKitScreen3(core, actor, npc): + + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_12fe83a6') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_e1a103e5') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + + option1 = ConversationOption(outOfBand2, 0) + + options = Vector() + options.add(option1) + + convSvc.sendConversationOptions(actor, npc, options, handleLootScreenSelection4) + + return + +def lootKitScreen4(core, actor, npc): + + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_4d65752') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_d347bee3') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + prose3 = ProsePackage('conversation/junk_dealer_generic', 's_b60b73f8') + outOfBand3 = OutOfBand() + outOfBand3.addProsePackage(prose3) + + option1 = ConversationOption(outOfBand2, 0) + option2 = ConversationOption(outOfBand3, 0) + + options = Vector() + options.add(option1) + options.add(option2) + + convSvc.sendConversationOptions(actor, npc, options, handleLootScreenSelection5) + + return + +def lootKitScreen5a(core, actor, npc): + + convSvc = core.conversationService + prose = ProsePackage('conversation/junk_dealer_generic', 's_3fc7eb45') + outOfBand = OutOfBand() + outOfBand.addProsePackage(prose) + convSvc.sendConversationMessage(actor, npc, outOfBand) + + prose2 = ProsePackage('conversation/junk_dealer_generic', 's_ee977dee') + outOfBand2 = OutOfBand() + outOfBand2.addProsePackage(prose2) + prose3 = ProsePackage('conversation/junk_dealer_generic', 's_8f39769') + outOfBand3 = OutOfBand() + outOfBand3.addProsePackage(prose3) + prose4 = ProsePackage('conversation/junk_dealer_generic', 's_fe657cdd') + outOfBand4 = OutOfBand() + outOfBand4.addProsePackage(prose4) + prose5 = ProsePackage('conversation/junk_dealer_generic', 's_9ede4b84') + outOfBand5 = OutOfBand() + outOfBand5.addProsePackage(prose5) + prose6 = ProsePackage('conversation/junk_dealer_generic', 's_87c5851b') + outOfBand6 = OutOfBand() + outOfBand6.addProsePackage(prose6) + + option1 = ConversationOption(outOfBand2, 0) + option2 = ConversationOption(outOfBand3, 0) + option3 = ConversationOption(outOfBand4, 0) + option4 = ConversationOption(outOfBand5, 0) + option5 = ConversationOption(outOfBand6, 0) + + options = Vector() + options.add(option1) + options.add(option2) + options.add(option3) + options.add(option4) + options.add(option5) + + convSvc.sendConversationOptions(actor, npc, options, handleLootScreenSelection6) + + return + +def lootKitScreen5b(core, actor, npc): + + startConversation(core,actor,npc) + return \ No newline at end of file diff --git a/scripts/loot/lootItems/armor/composite_armor_bicep_left.py b/scripts/loot/lootItems/armor/composite_armor_bicep_left.py index 01dae7ed..d5089e38 100644 --- a/scripts/loot/lootItems/armor/composite_armor_bicep_left.py +++ b/scripts/loot/lootItems/armor/composite_armor_bicep_left.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Left Bicep' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_bicep_right.py b/scripts/loot/lootItems/armor/composite_armor_bicep_right.py index d0520ca7..5e04243e 100644 --- a/scripts/loot/lootItems/armor/composite_armor_bicep_right.py +++ b/scripts/loot/lootItems/armor/composite_armor_bicep_right.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Right Bicep' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_boots.py b/scripts/loot/lootItems/armor/composite_armor_boots.py index f82eba8c..f996bfa7 100644 --- a/scripts/loot/lootItems/armor/composite_armor_boots.py +++ b/scripts/loot/lootItems/armor/composite_armor_boots.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Boots' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_bracer_left.py b/scripts/loot/lootItems/armor/composite_armor_bracer_left.py index 9c5bfb48..7d805114 100644 --- a/scripts/loot/lootItems/armor/composite_armor_bracer_left.py +++ b/scripts/loot/lootItems/armor/composite_armor_bracer_left.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Bracer Left' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_bracer_right.py b/scripts/loot/lootItems/armor/composite_armor_bracer_right.py index 2c177745..deb22a6c 100644 --- a/scripts/loot/lootItems/armor/composite_armor_bracer_right.py +++ b/scripts/loot/lootItems/armor/composite_armor_bracer_right.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Bracer Right' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_chestplate.py b/scripts/loot/lootItems/armor/composite_armor_chestplate.py index 9d5687b1..b569da42 100644 --- a/scripts/loot/lootItems/armor/composite_armor_chestplate.py +++ b/scripts/loot/lootItems/armor/composite_armor_chestplate.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Chestplate' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_gloves.py b/scripts/loot/lootItems/armor/composite_armor_gloves.py index c99e4081..acd4a1cf 100644 --- a/scripts/loot/lootItems/armor/composite_armor_gloves.py +++ b/scripts/loot/lootItems/armor/composite_armor_gloves.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Gloves' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_helmet.py b/scripts/loot/lootItems/armor/composite_armor_helmet.py index e29f9e11..d5fe36de 100644 --- a/scripts/loot/lootItems/armor/composite_armor_helmet.py +++ b/scripts/loot/lootItems/armor/composite_armor_helmet.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Helmet' def customItemStackCount(): diff --git a/scripts/loot/lootItems/armor/composite_armor_leggings.py b/scripts/loot/lootItems/armor/composite_armor_leggings.py index 9111c640..a48864a4 100644 --- a/scripts/loot/lootItems/armor/composite_armor_leggings.py +++ b/scripts/loot/lootItems/armor/composite_armor_leggings.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Composite Armor Leggings' def customItemStackCount(): diff --git a/scripts/loot/lootItems/clothes/tusken_raider_bandolier.py b/scripts/loot/lootItems/clothes/tusken_raider_bandolier.py index 41e4b5b6..163a87ea 100644 --- a/scripts/loot/lootItems/clothes/tusken_raider_bandolier.py +++ b/scripts/loot/lootItems/clothes/tusken_raider_bandolier.py @@ -5,4 +5,4 @@ def itemTemplate(): def customItemName(): - return '' + return 'Tusken Raider Bandolier' diff --git a/scripts/loot/lootItems/clothes/tusken_raider_boots.py b/scripts/loot/lootItems/clothes/tusken_raider_boots.py index c6eaa937..81cb35af 100644 --- a/scripts/loot/lootItems/clothes/tusken_raider_boots.py +++ b/scripts/loot/lootItems/clothes/tusken_raider_boots.py @@ -5,4 +5,4 @@ def itemTemplate(): def customItemName(): - return '' + return 'Tusken Raider Boots' diff --git a/scripts/loot/lootItems/clothes/tusken_raider_dress.py b/scripts/loot/lootItems/clothes/tusken_raider_dress.py index 35cec848..c697642b 100644 --- a/scripts/loot/lootItems/clothes/tusken_raider_dress.py +++ b/scripts/loot/lootItems/clothes/tusken_raider_dress.py @@ -5,4 +5,4 @@ def itemTemplate(): def customItemName(): - return '' + return 'Tusken Raider Dress' diff --git a/scripts/loot/lootItems/clothes/tusken_raider_gloves.py b/scripts/loot/lootItems/clothes/tusken_raider_gloves.py index 690f9471..a942a1d3 100644 --- a/scripts/loot/lootItems/clothes/tusken_raider_gloves.py +++ b/scripts/loot/lootItems/clothes/tusken_raider_gloves.py @@ -5,4 +5,4 @@ def itemTemplate(): def customItemName(): - return '' + return 'Tusken Raider Gloves' diff --git a/scripts/loot/lootItems/clothes/tusken_raider_helmet.py b/scripts/loot/lootItems/clothes/tusken_raider_helmet.py index 5187c38b..d4e539d4 100644 --- a/scripts/loot/lootItems/clothes/tusken_raider_helmet.py +++ b/scripts/loot/lootItems/clothes/tusken_raider_helmet.py @@ -5,4 +5,4 @@ def itemTemplate(): def customItemName(): - return '' + return 'Tusken Raider Helmet' diff --git a/scripts/loot/lootItems/junk/antenna.py b/scripts/loot/lootItems/creatureloot/antenna.py similarity index 70% rename from scripts/loot/lootItems/junk/antenna.py rename to scripts/loot/lootItems/creatureloot/antenna.py index 64a11ec4..62113b2d 100644 --- a/scripts/loot/lootItems/junk/antenna.py +++ b/scripts/loot/lootItems/creatureloot/antenna.py @@ -2,3 +2,7 @@ def itemTemplate(): return ['object/tangible/loot/creature_loot/generic/shared_generic_antennae.iff'] + +def customItemName(): + + return 'Antenna' diff --git a/scripts/loot/lootItems/junk/brain.py b/scripts/loot/lootItems/creatureloot/brain.py similarity index 100% rename from scripts/loot/lootItems/junk/brain.py rename to scripts/loot/lootItems/creatureloot/brain.py diff --git a/scripts/loot/lootItems/junk/eye.py b/scripts/loot/lootItems/creatureloot/eye.py similarity index 71% rename from scripts/loot/lootItems/junk/eye.py rename to scripts/loot/lootItems/creatureloot/eye.py index 45a5a41e..076ce324 100644 --- a/scripts/loot/lootItems/junk/eye.py +++ b/scripts/loot/lootItems/creatureloot/eye.py @@ -2,3 +2,7 @@ def itemTemplate(): return ['object/tangible/loot/creature_loot/generic/shared_generic_eye.iff'] + +def customItemName(): + + return 'Eye' diff --git a/scripts/loot/lootItems/junk/gland.py b/scripts/loot/lootItems/creatureloot/gland.py similarity index 100% rename from scripts/loot/lootItems/junk/gland.py rename to scripts/loot/lootItems/creatureloot/gland.py diff --git a/scripts/loot/lootItems/junk/heart.py b/scripts/loot/lootItems/creatureloot/heart.py similarity index 71% rename from scripts/loot/lootItems/junk/heart.py rename to scripts/loot/lootItems/creatureloot/heart.py index 15268f40..8232f7a7 100644 --- a/scripts/loot/lootItems/junk/heart.py +++ b/scripts/loot/lootItems/creatureloot/heart.py @@ -2,3 +2,7 @@ def itemTemplate(): return ['object/tangible/loot/creature_loot/generic/shared_generic_heart.iff'] + +def customItemName(): + + return 'Heart' diff --git a/scripts/loot/lootItems/junk/stomach.py b/scripts/loot/lootItems/creatureloot/stomach.py similarity index 70% rename from scripts/loot/lootItems/junk/stomach.py rename to scripts/loot/lootItems/creatureloot/stomach.py index e4ead448..47042a7d 100644 --- a/scripts/loot/lootItems/junk/stomach.py +++ b/scripts/loot/lootItems/creatureloot/stomach.py @@ -2,3 +2,7 @@ def itemTemplate(): return ['object/tangible/loot/creature_loot/generic/shared_generic_stomach.iff'] + +def customItemName(): + + return 'Stomach' diff --git a/scripts/loot/lootItems/junk/armor_repair_device.py b/scripts/loot/lootItems/junk/armor_repair_device.py index 65252c39..079cd72a 100644 --- a/scripts/loot/lootItems/junk/armor_repair_device.py +++ b/scripts/loot/lootItems/junk/armor_repair_device.py @@ -2,3 +2,20 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_armor_repair_device_generic.iff'] + +def customItemName(): + + return 'Armor Repair Device' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 28 + +def junkType(): + + return 0 + diff --git a/scripts/loot/lootItems/junk/chassis_blueprint.py b/scripts/loot/lootItems/junk/chassis_blueprint.py index 98b2e26f..2848f501 100644 --- a/scripts/loot/lootItems/junk/chassis_blueprint.py +++ b/scripts/loot/lootItems/junk/chassis_blueprint.py @@ -5,4 +5,16 @@ def itemTemplate(): def customItemName(): - return 'Chassis Blueprint' \ No newline at end of file + return 'Chassis Blueprint' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 21 + +def junkType(): + + return 0 \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/comlink.py b/scripts/loot/lootItems/junk/comlink.py index ac3ff538..afc926dd 100644 --- a/scripts/loot/lootItems/junk/comlink.py +++ b/scripts/loot/lootItems/junk/comlink.py @@ -5,4 +5,16 @@ def itemTemplate(): def customItemName(): - return 'Comlink' \ No newline at end of file + return 'Comlink' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 15 + +def junkType(): + + return 0 \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/damaged_datapad.py b/scripts/loot/lootItems/junk/damaged_datapad.py index d1773502..8bb43fba 100644 --- a/scripts/loot/lootItems/junk/damaged_datapad.py +++ b/scripts/loot/lootItems/junk/damaged_datapad.py @@ -6,4 +6,16 @@ def itemTemplate(): def customItemName(): return 'Damaged Datapad' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 8 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/ear_jewel.py b/scripts/loot/lootItems/junk/ear_jewel.py index 02a39e85..6093adae 100644 --- a/scripts/loot/lootItems/junk/ear_jewel.py +++ b/scripts/loot/lootItems/junk/ear_jewel.py @@ -2,3 +2,7 @@ def itemTemplate(): return ['/object/tangible/loot/npc_loot/shared_jewelry_ear_s02.iff'] + +def customItemName(): + + return 'Ear jewel' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/explosive_dud.py b/scripts/loot/lootItems/junk/explosive_dud.py index d2983ddc..2d0291da 100644 --- a/scripts/loot/lootItems/junk/explosive_dud.py +++ b/scripts/loot/lootItems/junk/explosive_dud.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_firework_dud_s1.iff'] + +def customItemName(): + + return 'Explosive Dud' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 10 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/hyperdrive_unit.py b/scripts/loot/lootItems/junk/hyperdrive_unit.py index 099c821a..8ce2372d 100644 --- a/scripts/loot/lootItems/junk/hyperdrive_unit.py +++ b/scripts/loot/lootItems/junk/hyperdrive_unit.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/misc/shared_hyperdrive_part_s01.iff'] + +def customItemName(): + + return 'Hyperdrive Unit' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 34 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/id_chip.py b/scripts/loot/lootItems/junk/id_chip.py index b8d8ee89..38cb1161 100644 --- a/scripts/loot/lootItems/junk/id_chip.py +++ b/scripts/loot/lootItems/junk/id_chip.py @@ -6,3 +6,15 @@ def itemTemplate(): def customItemName(): return 'ID Chip' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 14 + +def junkType(): + + return 0 \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/impulse_detector.py b/scripts/loot/lootItems/junk/impulse_detector.py index f100ded7..6da7301b 100644 --- a/scripts/loot/lootItems/junk/impulse_detector.py +++ b/scripts/loot/lootItems/junk/impulse_detector.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_impulse_detector_01_generic.iff'] + +def customItemName(): + + return 'Impulse Detector' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 17 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/laser_trap.py b/scripts/loot/lootItems/junk/laser_trap.py index 0ea4640f..fd8840b9 100644 --- a/scripts/loot/lootItems/junk/laser_trap.py +++ b/scripts/loot/lootItems/junk/laser_trap.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_laser_trap_generic.iff'] + +def customItemName(): + + return 'Laser Trap' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 22 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/launcher_tube.py b/scripts/loot/lootItems/junk/launcher_tube.py index d3535342..8f6d60a2 100644 --- a/scripts/loot/lootItems/junk/launcher_tube.py +++ b/scripts/loot/lootItems/junk/launcher_tube.py @@ -5,4 +5,16 @@ def itemTemplate(): def customItemName(): - return 'Launcher Tube' \ No newline at end of file + return 'Launcher Tube' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 16 + +def junkType(): + + return 0 \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/ledger.py b/scripts/loot/lootItems/junk/ledger.py index 84481094..ba93e09b 100644 --- a/scripts/loot/lootItems/junk/ledger.py +++ b/scripts/loot/lootItems/junk/ledger.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_ledger_generic.iff'] + +def customItemName(): + + return 'Ledger' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 13 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/magseal_detector.py b/scripts/loot/lootItems/junk/magseal_detector.py index 30890aa6..e98ebf36 100644 --- a/scripts/loot/lootItems/junk/magseal_detector.py +++ b/scripts/loot/lootItems/junk/magseal_detector.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_magseal_detector_generic.iff'] + +def customItemName(): + + return 'MagSeal Detector' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 15 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/medical_console.py b/scripts/loot/lootItems/junk/medical_console.py index aba84602..d393fe32 100644 --- a/scripts/loot/lootItems/junk/medical_console.py +++ b/scripts/loot/lootItems/junk/medical_console.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_medical_console_generic.iff'] + +def customItemName(): + + return 'Medical Console' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 24 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/medical_device.py b/scripts/loot/lootItems/junk/medical_device.py index 4f198f3a..8511594b 100644 --- a/scripts/loot/lootItems/junk/medical_device.py +++ b/scripts/loot/lootItems/junk/medical_device.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_medical_device_generic.iff'] + +def customItemName(): + + return 'Medical Device' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 17 + +def junkType(): + + return 0 \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/motor.py b/scripts/loot/lootItems/junk/motor.py index 0fde31c1..0e72d464 100644 --- a/scripts/loot/lootItems/junk/motor.py +++ b/scripts/loot/lootItems/junk/motor.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_small_motor_generic.iff'] + +def customItemName(): + + return 'Motor' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 13 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/power_output_analyzer.py b/scripts/loot/lootItems/junk/power_output_analyzer.py index 39af3121..16114969 100644 --- a/scripts/loot/lootItems/junk/power_output_analyzer.py +++ b/scripts/loot/lootItems/junk/power_output_analyzer.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_power_output_analyzer_generic.iff'] + +def customItemName(): + + return 'Power Output Analyzer' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 21 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/red_wiring.py b/scripts/loot/lootItems/junk/red_wiring.py index b4682a7b..fbefb228 100644 --- a/scripts/loot/lootItems/junk/red_wiring.py +++ b/scripts/loot/lootItems/junk/red_wiring.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_red_wiring_generic.iff'] + +def customItemName(): + + return 'Red Wiring' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 12 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/shield_module.py b/scripts/loot/lootItems/junk/shield_module.py index 4ba2a8cf..db0fb690 100644 --- a/scripts/loot/lootItems/junk/shield_module.py +++ b/scripts/loot/lootItems/junk/shield_module.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_shield_module_generic.iff'] + +def customItemName(): + + return 'Shield Module' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 20 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/software_module.py b/scripts/loot/lootItems/junk/software_module.py index 98b0759d..58cc91ef 100644 --- a/scripts/loot/lootItems/junk/software_module.py +++ b/scripts/loot/lootItems/junk/software_module.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_software_module_generic.iff'] + +def customItemName(): + + return 'Software Module' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 12 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/survival_gear.py b/scripts/loot/lootItems/junk/survival_gear.py index e4cfba46..efdaebfb 100644 --- a/scripts/loot/lootItems/junk/survival_gear.py +++ b/scripts/loot/lootItems/junk/survival_gear.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_survival_equipment_generic.iff'] + +def customItemName(): + + return 'Survival Gear' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 11 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/underpowered_survey_pad.py b/scripts/loot/lootItems/junk/underpowered_survey_pad.py index 9caf9857..27fac34c 100644 --- a/scripts/loot/lootItems/junk/underpowered_survey_pad.py +++ b/scripts/loot/lootItems/junk/underpowered_survey_pad.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_survey_pad_adv_generic.iff'] + +def customItemName(): + + return 'Underpowered Survey Pad' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 13 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/unidentified_serum_vial.py b/scripts/loot/lootItems/junk/unidentified_serum_vial.py index 06a69fac..d9b5590e 100644 --- a/scripts/loot/lootItems/junk/unidentified_serum_vial.py +++ b/scripts/loot/lootItems/junk/unidentified_serum_vial.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_serum_vial_generic.iff'] + +def customItemName(): + + return 'Unidentified Serum Vial' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 14 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/used_notebook.py b/scripts/loot/lootItems/junk/used_notebook.py index bb42f7fd..6d117330 100644 --- a/scripts/loot/lootItems/junk/used_notebook.py +++ b/scripts/loot/lootItems/junk/used_notebook.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_notebook_generic.iff'] + +def customItemName(): + + return 'Used Notebook' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 12 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/weak_droid_battery.py b/scripts/loot/lootItems/junk/weak_droid_battery.py index 426a9373..8647f305 100644 --- a/scripts/loot/lootItems/junk/weak_droid_battery.py +++ b/scripts/loot/lootItems/junk/weak_droid_battery.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/generic/shared_battery_useable_generic.iff'] + +def customItemName(): + + return 'Weak Droid Battery' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 9 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/junk/worklight_generic.py b/scripts/loot/lootItems/junk/worklight_generic.py index 395beead..3b3bed9a 100644 --- a/scripts/loot/lootItems/junk/worklight_generic.py +++ b/scripts/loot/lootItems/junk/worklight_generic.py @@ -2,3 +2,19 @@ def itemTemplate(): return ['object/tangible/loot/npc_loot/shared_worklight_generic.iff'] + +def customItemName(): + + return 'Generic Worklight' + +def stackable(): + + return 1 + +def junkDealerPrice(): + + return 10 + +def junkType(): + + return 0 diff --git a/scripts/loot/lootItems/weapons/gaderiffi_baton.py b/scripts/loot/lootItems/weapons/gaderiffi_baton.py index 0977f314..f0aa09e9 100644 --- a/scripts/loot/lootItems/weapons/gaderiffi_baton.py +++ b/scripts/loot/lootItems/weapons/gaderiffi_baton.py @@ -5,7 +5,7 @@ def itemTemplate(): def customItemName(): - return '' + return 'Gaderiffi Baton' def customItemStackCount(): diff --git a/scripts/static_spawns/tatooine.py b/scripts/static_spawns/tatooine.py index 1d52548e..c059c589 100644 --- a/scripts/static_spawns/tatooine.py +++ b/scripts/static_spawns/tatooine.py @@ -14,7 +14,7 @@ def addPlanetSpawns(core, planet): junkdealer = stcSvc.spawnObject('object/mobile/shared_junk_dealer_m_01.iff', 'tatooine', long(0), float(3525), float(4), float(-4804), float(0.70), float(0.71)) junkdealer.setOptionsBitmask(264) - junkdealer.setCustomName('Junk Dealer') + junkdealer.setCustomName('a Junk Dealer') junkdealer.setAttachment('radial_filename', 'conversation'); junkdealer.setAttachment('conversationFile','junk_dealer') diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 04f72677..2710a33a 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -53,7 +53,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=10) +@Persistent(version=11) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -89,6 +89,8 @@ public class TangibleObject extends SWGObject { @NotPersistent private boolean lootItem = false; + private boolean stackable = false; + private int stackCount = 1; private boolean noSell = false; private byte junkType = -1; private int junkDealerPrice = 0; @@ -504,6 +506,22 @@ public class TangibleObject extends SWGObject { this.lootItem = lootItem; } + public boolean isStackable() { + return stackable; + } + + public void setStackable(boolean stackable) { + this.stackable = stackable; + } + + public int getStackCount() { + return stackCount; + } + + public void setStackCount(int stackCount) { + this.stackCount = stackCount; + } + public boolean isNoSell() { return noSell; } diff --git a/src/services/LootService.java b/src/services/LootService.java index e8788c1d..c9157d18 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -29,28 +29,20 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Vector; - -import protocol.swg.PlayClientEffectObjectMessage; import protocol.swg.PlayClientEffectObjectTransformMessage; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.loot.LootGroup; import resources.objects.loot.LootRollSession; -import resources.objects.resource.ResourceContainerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; import main.NGECore; -import engine.clientdata.ClientFileManager; -import engine.clientdata.visitors.CrcStringTableVisitor; -import engine.resources.common.CRC; import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; @@ -92,7 +84,7 @@ public class LootService implements INetworkDispatch { return; SWGObject lootedObjectInventory = lootedObject.getSlottedObject("inventory"); core.simulationService.openContainer(requester, lootedObjectInventory); - setLooted(lootedObject); + setLooted(requester,lootedObject); } } @@ -250,6 +242,7 @@ public class LootService implements INetworkDispatch { } } + @SuppressWarnings("unused") private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){ List subfolders = new ArrayList(); // Consider all sub-folders @@ -288,6 +281,9 @@ public class LootService implements INetworkDispatch { int stackCount = 1; int biolink = 0; int requiredCL = 1; + int stackable = -1; + int junkDealerPrice = 0; + byte junkType = -1; String requiredProfession = ""; String requiredFaction = ""; Vector customizationAttributes = null; @@ -335,7 +331,15 @@ public class LootService implements INetworkDispatch { if(core.scriptService.getMethod(itemPath,"","requiredFaction")!=null) requiredFaction = (String)core.scriptService.fetchString(itemPath,"requiredFaction"); - + if(core.scriptService.getMethod(itemPath,"","stackable")!=null) + stackable = (Integer)core.scriptService.fetchInteger(itemPath,"stackable"); + + if(core.scriptService.getMethod(itemPath,"","junkDealerPrice")!=null) + junkDealerPrice = (Integer)core.scriptService.fetchInteger(itemPath,"junkDealerPrice"); + + if(core.scriptService.getMethod(itemPath,"","junkType")!=null) + junkType = (byte)core.scriptService.fetchInteger(itemPath,"junkType"); + System.out.println("itemTemplate " + itemTemplate); TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); @@ -345,6 +349,21 @@ public class LootService implements INetworkDispatch { if (customName!=null) handleCustomDropName(droppedItem, customName); + + if (stackable!=-1){ + if(stackable==1) + droppedItem.setStackable(true); + else + droppedItem.setStackable(false); + } + + if (junkDealerPrice!=0){ + droppedItem.setJunkDealerPrice(junkDealerPrice); + } + + if (junkType!=-1){ + droppedItem.setJunkType(junkType); + } if (itemStats!=null){ if (itemStats.size()%3!=0){ @@ -373,6 +392,7 @@ public class LootService implements INetworkDispatch { droppedItem.setStringAttribute("required_faction", requiredFaction); } + lootRollSession.addDroppedItem(droppedItem); } @@ -779,13 +799,14 @@ public class LootService implements INetworkDispatch { return 42%42; } - public void setLooted(TangibleObject lootedObject){ + public void setLooted(TangibleObject lootedObject,TangibleObject requester){ lootedObject.setLooted(true); float y = -5.0F; float qz= 1.06535322E9F; Point3D effectorPosition = new Point3D(0,y,0); Quaternion effectorOrientation = new Quaternion(0,0,0,qz); PlayClientEffectObjectTransformMessage lmsg = new PlayClientEffectObjectTransformMessage("",lootedObject.getObjectID(),"",effectorPosition,effectorOrientation); + //((CreatureObject) requester).getClient().getSession().write(lmsg.serialize()); } @@ -798,12 +819,14 @@ public class LootService implements INetworkDispatch { @Override public void process(SWGObject obj) { String itemTemplate = obj.getTemplate(); - if (itemTemplate.contains("loot/")){ - sellableItems.add(obj); - } - } + TangibleObject tano = (TangibleObject) obj; + if (tano.getCustomName()!=null){ + if (itemTemplate.contains("loot/")){ + sellableItems.add(obj); + } + } + } }); - System.err.println("sellableItems " + sellableItems.size()); return sellableItems; } @@ -839,14 +862,12 @@ public class LootService implements INetworkDispatch { public boolean addToBuyHistory(CreatureObject actor, CreatureObject dealer, TangibleObject item){ LinkedHashMap businessHistory = (LinkedHashMap )dealer.getAttachment("BusinessHistory"); if (businessHistory==null){ - System.out.println("businessHistory==null"); businessHistory = new LinkedHashMap(); dealer.setAttachment("BusinessHistory",businessHistory); } - System.out.println("abusinessHistory.size " + businessHistory.size()); + TangibleObject[] actorsBuyHistory = businessHistory.get(actor.getObjectID()); if (actorsBuyHistory==null){ - System.out.println("actorsBuyHistory==null"); actorsBuyHistory = new TangibleObject[10]; actorsBuyHistory[0] = item; } else { @@ -868,10 +889,11 @@ public class LootService implements INetworkDispatch { } businessHistory.put(actor.getObjectID(),actorsBuyHistory); dealer.setAttachment("BusinessHistory",businessHistory); - printArrayElements(actorsBuyHistory); + //printArrayElements(actorsBuyHistory); return true; } + @SuppressWarnings("unchecked") public boolean removeBoughtBackItemFromHistory(CreatureObject actor, CreatureObject dealer, TangibleObject item){ if (item==null) return false; // Player has hit the button without selecting an item @@ -895,7 +917,7 @@ public class LootService implements INetworkDispatch { if (index==-1) return false; - // SHift everything to the right of the found index to the left + // Shift everything to the right of the found index to the left for (int i = index; i < 9; i++) { actorsBuyHistory[i] = actorsBuyHistory[i+1]; // 0 1 2 3 4 5 6 7 8 9 } @@ -904,12 +926,13 @@ public class LootService implements INetworkDispatch { businessHistory.put(actor.getObjectID(),actorsBuyHistory); dealer.setAttachment("BusinessHistory",businessHistory); - printArrayElements(actorsBuyHistory); + //printArrayElements(actorsBuyHistory); return true; } // util method + @SuppressWarnings("unused") private void printArrayElements(TangibleObject[] array){ System.out.print("Array ["); for (int i=0;i Date: Fri, 18 Apr 2014 21:16:56 +0200 Subject: [PATCH 6/6] options.cfg set to default values --- options.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options.cfg b/options.cfg index cb743c88..5a3a7f8e 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=0 -LOAD.BUILDOUT_OBJECTS=0 +LOAD.SNAPSHOT_OBJECTS=1 +LOAD.BUILDOUT_OBJECTS=1 LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file