//******************************************************************************************* //******************************************************************************************* // ALL INCLUDES //******************************************************************************************* //******************************************************************************************* include library.utils; include library.player_structure; include library.vendor_lib; include library.static_item; //******************************************************************************************* //******************************************************************************************* // ALL INHERITS //******************************************************************************************* //******************************************************************************************* inherits terminal.base.base_terminal; //******************************************************************************************* //******************************************************************************************* // ALL CONSTANTS //******************************************************************************************* //******************************************************************************************* //-----------------LOGGING const boolean LOGGING_ON = true; const string LOGGING_CATEGORY = "nonvendor"; const string_id SID_FACE_ME = new string_id("player_vendor", "face_me"); const string_id SID_RECOVER = new string_id("player_vendor", "recover_nonvendor"); const string_id SID_MAKE_ROOM = new string_id("player_vendor", "recover_nonvendor_make_room"); const string_id SID_NO_USE_WHILE_DEAD = new string_id("player_structure", "while_dead"); //******************************************************************************************* //******************************************************************************************* // ALL TRIGGERS //******************************************************************************************* //******************************************************************************************* trigger OnInitialize() { if(!isValidId(self)) return SCRIPT_CONTINUE; if(utils.hasScriptVar(self, "messageCompleted")) return SCRIPT_CONTINUE; if(!vendor_lib.validateNonVendorInStructure(self)) { int currentTime = getGameTime(); dictionary msgparams = new dictionary(); msgparams.put("time", currentTime); utils.setScriptVar(self, "messageTime", currentTime); utils.setScriptVar(self, "messageCompleted", true); messageTo(self, "handleDestroyNonVendor", msgparams, 0, false); CustomerServiceLog("tcg", "TCG NonVendor: "+self+" is about to be destroyed and given to the owner. The nonvendor is being destroyed (probably via structure terminal)."); } return SCRIPT_CONTINUE; } //Meant to catch the structure terminal deletion or special case issue. trigger OnDestroy() { if(!isValidId(self)) return SCRIPT_CONTINUE; if(utils.hasScriptVar(self, "messageCompleted")) return SCRIPT_CONTINUE; int currentTime = getGameTime(); dictionary msgparams = new dictionary(); msgparams.put("time", currentTime); utils.setScriptVar(self, "messageTime", currentTime); utils.setScriptVar(self, "messageCompleted", true); messageTo(self, "handleDestroyNonVendor", msgparams, 0, false); CustomerServiceLog("tcg", "TCG NonVendor: "+self+" is about to be destroyed and given to the owner. The nonvendor is being destroyed (probably via structure terminal)."); return SCRIPT_CONTINUE; } trigger OnTransferred(obj_id sourceContainer, obj_id destContainer, obj_id transferer) { obj_id ownerId = getObjIdObjVar(self, vendor_lib.GREETER_OWNER_OBJVAR); if(!isValidId(ownerId)) return SCRIPT_CONTINUE; int currentTime = getGameTime(); dictionary msgparams = new dictionary(); msgparams.put("time", currentTime); utils.setScriptVar(self, "messageTime", currentTime); utils.setScriptVar(self, "messageCompleted", true); messageTo(self, "handleDestroyNonVendor", msgparams, 0, false); CustomerServiceLog("tcg", "TCG NonVendor: "+self+" is about to be destroyed and given to: " + ownerId + ". The nonvendor is being transferred (probably picked up)."); return SCRIPT_CONTINUE; } //------------------------------------------------ // OnObjectMenuRequest //------------------------------------------------ trigger OnObjectMenuRequest( obj_id player, menu_info mi ) { if(!isValidId(player) || !exists(player)) return SCRIPT_CONTINUE; if(isIncapacitated(player) || isDead(player)) return SCRIPT_CONTINUE; blog("terminal.nonvendor.OnObjectMenuRequest init"); obj_id ownerId = getObjIdObjVar(self, vendor_lib.GREETER_OWNER_OBJVAR); if(!isValidId(ownerId) || !exists(ownerId)) return SCRIPT_CONTINUE; if(player != ownerId) return SCRIPT_CONTINUE; return SCRIPT_CONTINUE; } //------------------------------------------------ // OnObjectMenuSelect //------------------------------------------------ trigger OnObjectMenuSelect(obj_id player, int item) { if(!isValidId(player) || !exists(player)) return SCRIPT_CONTINUE; if(isIncapacitated(player) || isDead(player)) return SCRIPT_CONTINUE; blog("terminal.nonvendor.OnObjectMenuSelect init"); obj_id ownerId = getObjIdObjVar(self, vendor_lib.GREETER_OWNER_OBJVAR); if(!isValidId(ownerId) || !exists(ownerId)) return SCRIPT_CONTINUE; else if(player != ownerId) return SCRIPT_CONTINUE; return SCRIPT_CONTINUE; } messageHandler handleDestroyNonVendor() { if(params == null || params.isEmpty()) return SCRIPT_CONTINUE; int time = params.getInt("time"); if(time <= 0) return SCRIPT_CONTINUE; int messageTime = utils.getIntScriptVar(self, "messageTime"); if(messageTime <= 0) return SCRIPT_CONTINUE; if(time != messageTime) return SCRIPT_CONTINUE; obj_id ownerId = getObjIdObjVar(self, vendor_lib.GREETER_OWNER_OBJVAR); if(!isValidId(ownerId)) { utils.removeScriptVar(self, "messageTime"); return SCRIPT_CONTINUE; } CustomerServiceLog("tcg", "TCG NonVendor " +self+ " is about to be destroyed. The owner of this TCG item is: "+ownerId+"."); string staticItem = getStringObjVar(self, vendor_lib.STATIC_ITEM_DEED_NAME); if(staticItem == null || staticItem.equals("")) { utils.removeScriptVar(self, "messageTime"); return SCRIPT_CONTINUE; } dictionary reimburseParams = new dictionary(); reimburseParams.put("reimburseItem", staticItem); blog("terminal.nonvendor.handleDestroyNonVendor OWNER ID: "+ ownerId); //if used for house packup and the owner is not the house owner if(!ownerId.isLoaded()) { blog("terminal.nonvendor.handleDestroyNonVendor OWNER OFFLINE"); CustomerServiceLog("tcg", "TCG NonVendor "+self+" owner " +ownerId+ " is not online. The TCG NonVendor will be reimbursed at next login."); messageTo(ownerId, "reimburseTcgItem", reimburseParams, 0, true); } else { blog("terminal.nonvendor.handleDestroyNonVendor OWNER LOADED"); obj_id pInv = utils.getInventoryContainer(ownerId); if(!isValidId(pInv) || !exists(pInv)) { CustomerServiceLog("tcg", "TCG NonVendor: "+self+" could not be destroyed properly because owner: " + ownerId + " had no player inventory container available. We have sent a message to reimburse the player at another time."); messageTo(ownerId, "reimburseTcgItem", reimburseParams, 0, true); destroyObject(self); return SCRIPT_CONTINUE; } obj_id newItem = static_item.createNewItemFunction(staticItem, pInv); if(!isValidId(newItem) || !exists(newItem)) { CustomerServiceLog("tcg", "TCG NonVendor: "+self+" could not be destroyed for owner: " + ownerId + " because the deed could not be created properly. We have sent a message to reimburse the player at another time."); messageTo(ownerId, "reimburseTcgItem", reimburseParams, 0, true); destroyObject(self); return SCRIPT_CONTINUE; } CustomerServiceLog("tcg", "TCG NonVendor "+self+" will be destroyed because the owner: " + ownerId + " has received a new deed for the nonvendor destruction. The object: "+newItem); } destroyObject(self); return SCRIPT_CONTINUE; } messageHandler OnPack() { CustomerServiceLog("tcg", "TCG NonVendor " +self+ " is being packed up."); location loc = getLocation(self); if(loc != null && isValidId(loc.cell)) { CustomerServiceLog("tcg", "TCG NonVendor " +self+ " is being packed up. Current Location: "+loc); obj_id structure = player_structure.getStructure(self); if(isValidId(structure)) { CustomerServiceLog("tcg", "TCG NonVendor "+self+" currently resides in " +structure); obj_id structureOwner = getOwner(structure); if(isValidId(structureOwner)) { CustomerServiceLog("tcg", "TCG NonVendor "+self+" currently resides in " +structure+ " that is owned by " +structureOwner); obj_id ownerId = getObjIdObjVar(self, vendor_lib.GREETER_OWNER_OBJVAR); if(isValidId(ownerId) && ownerId != structureOwner) { CustomerServiceLog("tcg", "TCG NonVendor "+self+" is being packed up in a house that the NonVendor owner "+ownerId+" doesn't own."); } } } } int currentTime = getGameTime(); dictionary msgparams = new dictionary(); msgparams.put("time", currentTime); utils.setScriptVar(self, "messageTime", currentTime); utils.setScriptVar(self, "messageCompleted", true); messageTo(self, "handleDestroyNonVendor", msgparams, 0, false); return SCRIPT_CONTINUE; } boolean blog(string msg) { if(LOGGING_ON && msg != null && !msg.equals("")) LOG(LOGGING_CATEGORY, msg); return true; }