include library.cts; include library.utils; const boolean BLOGGING_ON = true; const string BLOG_CATEGORY = "CharacterTransfer"; const string STF_FILE = "veteran_new"; const string_id SID_TRANSFER_TO_SPONSOR = new string_id(STF_FILE,"transfer_to_sponsor"); //RESTRICTED SPONSOR GIFT SCRIPT. /* This script is attached to the gift object received by the CTS player when it is claimed via the vet reward system. The player cannot drop the object in their house or otherwise move it to another container they own (like a pack). The player must trade this gift box to another player other than him/her self. */ //OnInitialize() is for clean up only. Hopefully the work //will be done in OnTransferred() trigger OnInitialize() { //for clean up only. Hopefully the work //will be done in OnTransferred() if(!utils.isNestedWithinAPlayer(self)) return SCRIPT_CONTINUE; if(!hasObjVar(self, cts.CURRENT_PLAYER_OID)) cts.initializeCtsObject(self); return SCRIPT_CONTINUE; } //When a valid transfer happens we want the sponsors gift box to //be stamped trigger OnTransferred(obj_id sourceContainer, obj_id destContainer, obj_id transferer) { //if the destination is not a player we dont care if(!isPlayer(getContainedBy(destContainer))) return SCRIPT_CONTINUE; //if it is somehow transferred within the same player //we dont care if(destContainer == sourceContainer) return SCRIPT_CONTINUE; obj_id containingPlayer = utils.getContainingPlayer(self); if(!isValidId(containingPlayer) || !exists(containingPlayer)) return SCRIPT_CONTINUE; //The box is created for first time in CTS Player Inventory if(!hasObjVar(self, cts.CURRENT_PLAYER_OID)) { cts.initializeCtsObject(self); } //The box is traded from CTS player to Sponsor else if(hasObjVar(self, cts.CURRENT_PLAYER_OID) && !hasObjVar(self, cts.SPONSOR_PLAYER_OID)) { //@TODO //verify that gift box is in the proper container if(!utils.isNestedWithinAPlayer(self)) return SCRIPT_CONTINUE; obj_id originalOwner = getObjIdObjVar(self, cts.CURRENT_PLAYER_OID); if(!isValidId(originalOwner)) return SCRIPT_CONTINUE; if(containingPlayer == originalOwner) return SCRIPT_CONTINUE; if(!hasObjVar(self, cts.PREVIOUS_PLAYER_CLUSTER)) return SCRIPT_CONTINUE; if(hasObjVar(self, cts.SPONSOR_PLAYER_OID)) return SCRIPT_CONTINUE; setObjVar(self, cts.SPONSOR_PLAYER_OID, containingPlayer); setObjVar(self, cts.SPONSOR_PLAYER_FULL_NAME, getPlayerFullName(containingPlayer)); setObjVar(self, cts.SPONSOR_PLAYER_CLUSTER_NAME, getClusterName()); setObjVar(self, cts.SPONSOR_PLAYER_TIME, getCalendarTime()); CustomerServiceLog("CharacterTransfer", "Successful stamping of sponsor data onto RESTRICTED CTS Gift Box: "+ self + " " + getName(self) + " to player: " +containingPlayer+" " +getName(containingPlayer)+" from CTS Player and original owner: " + getObjIdObjVar(self, cts.CURRENT_PLAYER_OID) + " " + getName(getObjIdObjVar(self, cts.CURRENT_PLAYER_OID))); } //The box is in the Sponsor's inventory and has been stampted. This section will create //a new UNRESTRICTED Gift Box, stamp all the objvars onto the new box, then destroy itself. if(hasObjVar(self, cts.CURRENT_PLAYER_OID) && hasObjVar(self, cts.SPONSOR_PLAYER_OID)) { if(!utils.isNestedWithinAPlayer(self)) return SCRIPT_CONTINUE; obj_id sponsorOid = getObjIdObjVar(self, cts.SPONSOR_PLAYER_OID); if(!isValidId(sponsorOid)) return SCRIPT_CONTINUE; //if we are missing CTS player objvars or the painting objvar, bail out if(!hasObjVar(self, cts.CTS_PAINTING_OBJVAR) || !hasObjVar(self, cts.CTS_UNRESTRICTED_GIFT_BOX_OBJVAR) || !hasObjVar(self, cts.DATETIME_GIFT_TRANSFER) || !hasObjVar(self, cts.CURRENT_PLAYER_NAME) || !hasObjVar(self, cts.DATETIME_GIFT_TRANSFER) || !hasObjVar(self, cts.PREVIOUS_PLAYER_CLUSTER) || !hasObjVar(self, cts.PREVIOUS_PLAYER_NAME) || !hasObjVar(self, cts.CURRENT_PLAYER_CLUSTER) ) return SCRIPT_CONTINUE; //if we are missing Sponsor objvars, bail out if(!hasObjVar(self, cts.SPONSOR_PLAYER_FULL_NAME) || !hasObjVar(self, cts.SPONSOR_PLAYER_CLUSTER_NAME) || !hasObjVar(self, cts.SPONSOR_PLAYER_TIME)) return SCRIPT_CONTINUE; //Get the unrestricted gift box string unrestrictedTemplate = getStringObjVar(self, cts.CTS_UNRESTRICTED_GIFT_BOX_OBJVAR); if(unrestrictedTemplate == null || unrestrictedTemplate.equals("")) return SCRIPT_CONTINUE; //Get the painting string paintingTemplate = getStringObjVar(self, cts.CTS_PAINTING_OBJVAR); if(paintingTemplate == null || paintingTemplate.equals("")) return SCRIPT_CONTINUE; //Get The CTS Player Data obj_id originalCtsPlayer = getObjIdObjVar(self, cts.CURRENT_PLAYER_OID); if(!isValidId(originalCtsPlayer)) return SCRIPT_CONTINUE; int refugeeTimeTransfer = getIntObjVar(self, cts.DATETIME_GIFT_TRANSFER); if(refugeeTimeTransfer <= 0) return SCRIPT_CONTINUE; string refugeePrevGalaxy = getStringObjVar(self, cts.PREVIOUS_PLAYER_CLUSTER); if(refugeePrevGalaxy == null || refugeePrevGalaxy.equals("")) return SCRIPT_CONTINUE; string refugeePrevName = getStringObjVar(self, cts.PREVIOUS_PLAYER_NAME); if(refugeePrevName == null || refugeePrevName.equals("")) return SCRIPT_CONTINUE; string refugeeCurrentGalaxy = getStringObjVar(self, cts.CURRENT_PLAYER_CLUSTER); if(refugeeCurrentGalaxy == null || refugeeCurrentGalaxy.equals("")) return SCRIPT_CONTINUE; string refugeeName = getStringObjVar(self, cts.CURRENT_PLAYER_NAME); if(refugeeName == null || refugeeName.equals("")) return SCRIPT_CONTINUE; //Get the Sponsor data string playerFullName = getStringObjVar(self, cts.SPONSOR_PLAYER_FULL_NAME); if(playerFullName == null || playerFullName.equals("")) return SCRIPT_CONTINUE; string sponsorClusterName = getStringObjVar(self, cts.SPONSOR_PLAYER_CLUSTER_NAME); if(sponsorClusterName == null || sponsorClusterName.equals("")) return SCRIPT_CONTINUE; int giftTime = getIntObjVar(self, cts.SPONSOR_PLAYER_TIME); if(refugeeTimeTransfer <= 0) return SCRIPT_CONTINUE; obj_id unrestrictedGiftBox = createObjectInInventoryAllowOverload(unrestrictedTemplate, sponsorOid); if(!isValidId(unrestrictedGiftBox) || !exists(unrestrictedGiftBox)) return SCRIPT_CONTINUE; //set all vars on unrestrictedGiftBox //Pinting setObjVar(unrestrictedGiftBox, cts.CTS_PAINTING_OBJVAR, paintingTemplate); //Original owner data setObjVar(unrestrictedGiftBox, cts.CURRENT_PLAYER_OID, originalCtsPlayer); setObjVar(unrestrictedGiftBox, cts.DATETIME_GIFT_TRANSFER, refugeeTimeTransfer); setObjVar(unrestrictedGiftBox, cts.PREVIOUS_PLAYER_CLUSTER, refugeePrevGalaxy); setObjVar(unrestrictedGiftBox, cts.PREVIOUS_PLAYER_NAME, refugeePrevName); setObjVar(unrestrictedGiftBox, cts.CURRENT_PLAYER_CLUSTER, refugeeCurrentGalaxy); setObjVar(unrestrictedGiftBox, cts.CURRENT_PLAYER_NAME, refugeeName); //Sponsor data setObjVar(unrestrictedGiftBox, cts.SPONSOR_PLAYER_OID, sponsorOid); setObjVar(unrestrictedGiftBox, cts.SPONSOR_PLAYER_FULL_NAME, playerFullName); setObjVar(unrestrictedGiftBox, cts.SPONSOR_PLAYER_CLUSTER_NAME, sponsorClusterName); setObjVar(unrestrictedGiftBox, cts.SPONSOR_PLAYER_TIME, giftTime); CustomerServiceLog("CharacterTransfer", "Successful creation and transfer of sponsor data from RESTRICTED to UNRESTRICTED" + " Gift Box: "+ unrestrictedGiftBox + " " + getName(unrestrictedGiftBox) + " to player: " +sponsorOid+" " +getName(sponsorOid)+" from CTS Player and original owner: " + originalCtsPlayer + " " + getName(originalCtsPlayer)); //destroy restricted box destroyObject(self); } return SCRIPT_CONTINUE; } //Only specific transfers are valid. If the sponsor gift box //has not been stamped it can not be placed anywhere and must reside //in the player's inventory. trigger OnAboutToBeTransferred(obj_id destContainer, obj_id transferer) { //the original CTS player should never be able to place //the gift box in a structure or any location other than if(!isPlayer(getContainedBy(destContainer))) { blog("OnAboutToBeTransferred destination container not a player"); sendSystemMessage(transferer, SID_TRANSFER_TO_SPONSOR); return SCRIPT_OVERRIDE; } obj_id destPlayer = utils.getContainingPlayer(destContainer); obj_id destPlayerInv = utils.getInventoryContainer(destPlayer); if(destContainer != destPlayerInv) { blog("OnAboutToBeTransferred destination container not a player's top level inventory"); sendSystemMessage(transferer, SID_TRANSFER_TO_SPONSOR); return SCRIPT_OVERRIDE; } blog("OnAboutToBeTransferred transfer success"); return SCRIPT_CONTINUE; } trigger OnGetAttributes(obj_id player, string[] names, string[] attribs) { int idx = utils.getValidAttributeIndex(names); if(idx == -1) return SCRIPT_CONTINUE; if(!isValidId(self) || !exists(self)) return SCRIPT_CONTINUE; string inscriptionString = cts.getCtsInscription(self); if(inscriptionString != null && !inscriptionString.equals("")) { names[idx] = "inscription"; attribs[idx] = inscriptionString; idx++; } return SCRIPT_CONTINUE; } boolean blog(string msg) { if(BLOGGING_ON) LOG(BLOG_CATEGORY, msg); return true; }