mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-29 23:15:55 -04:00
313 lines
13 KiB
Plaintext
313 lines
13 KiB
Plaintext
include library.utils;
|
|
|
|
const boolean BLOGGING_ON = true;
|
|
const string BLOG_CATEGORY = "CharacterTransfer";
|
|
|
|
const string CTS_GIFT_TEMPLATE = "object/tangible/furniture/house_cleanup/cts_";
|
|
const string CTS_GIFT_BOX = "box.iff";
|
|
|
|
const string REFUGEE_OBJVAR_PREFIX = "cts_reward";
|
|
const string PREVIOUS_PLAYER_NAME = REFUGEE_OBJVAR_PREFIX + ".player_previous_name";
|
|
const string PREVIOUS_PLAYER_CLUSTER = REFUGEE_OBJVAR_PREFIX + ".player_previous_cluster";
|
|
const string DATETIME_GIFT_TRANSFER = REFUGEE_OBJVAR_PREFIX + ".player_date_time_claimed";
|
|
const string CURRENT_PLAYER_NAME = REFUGEE_OBJVAR_PREFIX + ".player_current_name";
|
|
const string CURRENT_PLAYER_CLUSTER = REFUGEE_OBJVAR_PREFIX + ".player_current_cluster";
|
|
const string CURRENT_PLAYER_OID = REFUGEE_OBJVAR_PREFIX + ".player_current_oid";
|
|
|
|
const string SPONSOR_PLAYER_OID = REFUGEE_OBJVAR_PREFIX + ".sponsor_current_oid";
|
|
const string SPONSOR_PLAYER_FULL_NAME = REFUGEE_OBJVAR_PREFIX + ".sponsor_current_name";
|
|
const string SPONSOR_PLAYER_CLUSTER_NAME = REFUGEE_OBJVAR_PREFIX + ".sponsor_current_cluster";
|
|
const string SPONSOR_PLAYER_TIME = REFUGEE_OBJVAR_PREFIX + ".sponsor_current_time";
|
|
//this objvar is on the sponsor's gift box
|
|
const string CTS_PAINTING_OBJVAR = "cts.greeter.painting";
|
|
const string CTS_UNRESTRICTED_GIFT_BOX_OBJVAR = "cts.greeter.unrestricted_box";
|
|
|
|
const string SCRIPTVAR_CTS_ITEM_ID = "ctsItemId";
|
|
|
|
//Unpacks a CTS Painting for the sponsor.
|
|
boolean grantPackagedPainting(obj_id sponsorGiftBox, obj_id anyPlayer)
|
|
{
|
|
blog("grantPackagedPainting init");
|
|
|
|
if(!isValidId(sponsorGiftBox) || !exists(sponsorGiftBox))
|
|
return false;
|
|
if(!isValidId(anyPlayer) || !exists(anyPlayer))
|
|
return false;
|
|
/*
|
|
Validate that all the necessary data is here
|
|
and then create the painting
|
|
*/
|
|
|
|
blog("grantPackagedPainting initial validation complete");
|
|
|
|
if(!hasObjVar(sponsorGiftBox, CTS_PAINTING_OBJVAR))
|
|
{
|
|
CustomerServiceLog("CharacterTransfer", "No Painting ObjVar on Gift - CTS Sponsor Gift unpacked failed for player: "+ anyPlayer + " " + getName(anyPlayer)+". Offending object: "+sponsorGiftBox+" failed to spawn painting because no painting template found.");
|
|
return false;
|
|
}
|
|
|
|
string paintingTemplate = getStringObjVar(sponsorGiftBox, CTS_PAINTING_OBJVAR);
|
|
if(paintingTemplate == null || paintingTemplate.equals(""))
|
|
{
|
|
CustomerServiceLog("CharacterTransfer", "Painting ObjVar Null - CTS Sponsor Gift unpacked failed for player: "+ anyPlayer + " " + getName(anyPlayer)+". Offending object: "+sponsorGiftBox+" failed to spawn retrive painting string: "+paintingTemplate);
|
|
return false;
|
|
}
|
|
|
|
if(!hasObjVar(sponsorGiftBox, cts.CURRENT_PLAYER_OID))
|
|
{
|
|
CustomerServiceLog("CharacterTransfer", "Original CTS Player OID not found - CTS Sponsor Gift unpacked failed for player: "+ anyPlayer + " " + getName(anyPlayer)+". Offending object: "+sponsorGiftBox+". Did not have original owner refugee OID on box object");
|
|
return false;
|
|
}
|
|
|
|
if(!hasObjVar(sponsorGiftBox, cts.SPONSOR_PLAYER_OID))
|
|
{
|
|
CustomerServiceLog("CharacterTransfer", "Sponsor's OID not found - CTS Sponsor Gift unpacked failed for player: "+ anyPlayer + " " + getName(anyPlayer)+". Offending object: "+sponsorGiftBox+". Did not have sponsor OID on box object");
|
|
return false;
|
|
}
|
|
|
|
blog("grantPackagedPainting has painting, CTS player OID and Sponsor OID.");
|
|
|
|
//Original owner data
|
|
int refugeeTimeTransfer = getIntObjVar(sponsorGiftBox, cts.DATETIME_GIFT_TRANSFER);
|
|
if(refugeeTimeTransfer <= 0)
|
|
return false;
|
|
|
|
blog("grantPackagedPainting has refugeeTimeTransfer");
|
|
|
|
string refugeePrevGalaxy = getStringObjVar(sponsorGiftBox, cts.PREVIOUS_PLAYER_CLUSTER);
|
|
if(refugeePrevGalaxy == null || refugeePrevGalaxy.equals(""))
|
|
return false;
|
|
|
|
blog("grantPackagedPainting has refugeePrevGalaxy");
|
|
|
|
string refugeePrevName = getStringObjVar(sponsorGiftBox, cts.PREVIOUS_PLAYER_NAME);
|
|
if(refugeePrevName == null || refugeePrevName.equals(""))
|
|
return false;
|
|
|
|
blog("grantPackagedPainting has refugeePrevName");
|
|
|
|
string refugeeCurrentGalaxy = getStringObjVar(sponsorGiftBox, cts.CURRENT_PLAYER_CLUSTER);
|
|
if(refugeeCurrentGalaxy == null || refugeeCurrentGalaxy.equals(""))
|
|
return false;
|
|
|
|
blog("grantPackagedPainting has refugeeCurrentGalaxy");
|
|
|
|
string refugeeName = getStringObjVar(sponsorGiftBox, cts.CURRENT_PLAYER_NAME);
|
|
if(refugeeName == null || refugeeName.equals(""))
|
|
return false;
|
|
|
|
blog("grantPackagedPainting has refugeeName");
|
|
|
|
//Sponsor data
|
|
|
|
obj_id sponsorOid = getObjIdObjVar(sponsorGiftBox, cts.SPONSOR_PLAYER_OID);
|
|
if(!isValidId(sponsorOid))
|
|
return false;
|
|
|
|
blog("grantPackagedPainting has sponsorOid");
|
|
|
|
string playerFullName = getStringObjVar(sponsorGiftBox, cts.SPONSOR_PLAYER_FULL_NAME);
|
|
if(playerFullName == null || playerFullName.equals(""))
|
|
return false;
|
|
|
|
string sponsorClusterName = getStringObjVar(sponsorGiftBox, cts.SPONSOR_PLAYER_CLUSTER_NAME);
|
|
if(sponsorClusterName == null || sponsorClusterName.equals(""))
|
|
return false;
|
|
|
|
int giftTime = getIntObjVar(sponsorGiftBox, cts.SPONSOR_PLAYER_TIME);
|
|
if(refugeeTimeTransfer <= 0)
|
|
return false;
|
|
|
|
blog("grantPackagedPainting paintingTemplate: "+paintingTemplate);
|
|
|
|
//Create the painting in the player inventory, not the sponsor's inventory. The sponsor and player
|
|
//could be 2 different people!!
|
|
obj_id sponsorGiftPainting = createObjectInInventoryAllowOverload(paintingTemplate, anyPlayer);
|
|
if(!isValidId(sponsorGiftPainting) || !exists(sponsorGiftPainting))
|
|
{
|
|
CustomerServiceLog("CharacterTransfer", "CTS Sponsor Gift unpacked failed for player: "+ anyPlayer + " " + getName(anyPlayer)+". Offending object: "+sponsorGiftPainting+" failed to spawn painting: "+paintingTemplate);
|
|
return false;
|
|
}
|
|
|
|
//set all vars on sponsorGiftPainting
|
|
|
|
//Original owner data
|
|
setObjVar(sponsorGiftPainting, cts.DATETIME_GIFT_TRANSFER, refugeeTimeTransfer);
|
|
setObjVar(sponsorGiftPainting, cts.PREVIOUS_PLAYER_CLUSTER, refugeePrevGalaxy);
|
|
setObjVar(sponsorGiftPainting, cts.PREVIOUS_PLAYER_NAME, refugeePrevName);
|
|
setObjVar(sponsorGiftPainting, cts.CURRENT_PLAYER_CLUSTER, refugeeCurrentGalaxy);
|
|
setObjVar(sponsorGiftPainting, cts.CURRENT_PLAYER_NAME, refugeeName);
|
|
|
|
//Sponsor data
|
|
setObjVar(sponsorGiftPainting, cts.SPONSOR_PLAYER_OID, sponsorOid);
|
|
setObjVar(sponsorGiftPainting, cts.SPONSOR_PLAYER_FULL_NAME, playerFullName);
|
|
setObjVar(sponsorGiftPainting, cts.SPONSOR_PLAYER_CLUSTER_NAME, sponsorClusterName);
|
|
setObjVar(sponsorGiftPainting, cts.SPONSOR_PLAYER_TIME, giftTime);
|
|
|
|
CustomerServiceLog("CharacterTransfer", "Packed item: "+ sponsorGiftBox + " " + getName(sponsorGiftBox) + " unpacked: " +sponsorGiftPainting+" "+getName(sponsorGiftPainting)+" for player: "+ anyPlayer + " " + getName(anyPlayer)+".");
|
|
return true;
|
|
}
|
|
|
|
//Dynamically builds inscription string for the CTS Player Gift Painting,
|
|
//Sponsor Gift Box and Sponsor Gift Painting
|
|
string getCtsInscription(obj_id object)
|
|
{
|
|
if(!isValidId(object) || !exists(object))
|
|
return null;
|
|
|
|
if(!hasObjVar(object, cts.CURRENT_PLAYER_OID))
|
|
return null;
|
|
|
|
string refugeeTimeTransfer = getCalendarTimeStringLocal(getIntObjVar(object, cts.DATETIME_GIFT_TRANSFER));
|
|
if(refugeeTimeTransfer == null || refugeeTimeTransfer.equals(""))
|
|
return null;
|
|
|
|
string refugeePrevGalaxy = getStringObjVar(object, cts.PREVIOUS_PLAYER_CLUSTER);
|
|
if(refugeePrevGalaxy == null || refugeePrevGalaxy.equals(""))
|
|
return null;
|
|
|
|
string refugeePrevName = getStringObjVar(object, cts.PREVIOUS_PLAYER_NAME);
|
|
if(refugeePrevName == null || refugeePrevName.equals(""))
|
|
return null;
|
|
|
|
string refugeeCurrentGalaxy = getStringObjVar(object, cts.CURRENT_PLAYER_CLUSTER);
|
|
if(refugeeCurrentGalaxy == null || refugeeCurrentGalaxy.equals(""))
|
|
return null;
|
|
|
|
string refugeeName = getStringObjVar(object, cts.CURRENT_PLAYER_NAME);
|
|
if(refugeeName == null || refugeeName.equals(""))
|
|
return null;
|
|
|
|
string inscriptionString = "";
|
|
|
|
if(!hasObjVar(object, cts.SPONSOR_PLAYER_OID))
|
|
{
|
|
//Inscription should read 'Given to Bobby Drake, Bria upon transfer from Bill Jones, Kauri on Thu Sep 25 00:00:00 2008 PDT'
|
|
inscriptionString += "Given to " + refugeeName + ", " + refugeeCurrentGalaxy + " upon transfer from " + refugeePrevName;
|
|
inscriptionString += ", " + refugeePrevGalaxy + " on " + refugeeTimeTransfer;
|
|
}
|
|
else
|
|
{
|
|
obj_id sponsorOid = getObjIdObjVar(object, cts.SPONSOR_PLAYER_OID);
|
|
if(!isValidId(sponsorOid))
|
|
return null;
|
|
|
|
string playerFullName = getStringObjVar(object, cts.SPONSOR_PLAYER_FULL_NAME);
|
|
if(playerFullName == null || playerFullName.equals(""))
|
|
return null;
|
|
|
|
string sponsorClusterName = getStringObjVar(object, cts.SPONSOR_PLAYER_CLUSTER_NAME);
|
|
if(sponsorClusterName == null || sponsorClusterName.equals(""))
|
|
return null;
|
|
|
|
string giftTime = getCalendarTimeStringLocal(getIntObjVar(object, cts.SPONSOR_PLAYER_TIME));
|
|
if(giftTime == null || giftTime.equals(""))
|
|
return null;
|
|
|
|
//"Given to Carla Fib, Bria on Fri Sep 26 00:00:00 2008 PDT from Bobby Drake, Bria, who received it upon transfer from Bill Jones, Kauri on Thu Sep 25 00:00:00 2008 PDT"
|
|
inscriptionString += "Given to " + playerFullName + ", " + sponsorClusterName + " on " + giftTime + " from " + refugeeName + ", ";
|
|
inscriptionString += refugeeCurrentGalaxy + ", who received it upon transfer from " + refugeePrevName + ", " + refugeePrevGalaxy;
|
|
inscriptionString += " on " + refugeeTimeTransfer;
|
|
}
|
|
|
|
if(inscriptionString == null || inscriptionString.equals(""))
|
|
CustomerServiceLog("CharacterTransfer", "Unable to build inscription for CTS reward: "+object+ " " +getName(object));
|
|
|
|
return inscriptionString;
|
|
}
|
|
|
|
//Dynamically initializes the CTS objects by stamping
|
|
//data onto each object at specific stages
|
|
boolean initializeCtsObject(obj_id object)
|
|
{
|
|
blog("initializeCtsPainting init");
|
|
|
|
//no need to re-init stuff if the data has been collected
|
|
if(hasObjVar(object, cts.CURRENT_PLAYER_OID))
|
|
return true;
|
|
|
|
//placing it in house
|
|
if(!utils.isNestedWithinAPlayer(object))
|
|
return false;
|
|
|
|
obj_id containingPlayer = utils.getContainingPlayer(object);
|
|
if(!isValidId(containingPlayer) || !exists(containingPlayer))
|
|
return false;
|
|
|
|
//sets the OID of the original owner
|
|
if(!hasObjVar(object, CURRENT_PLAYER_OID))
|
|
setObjVar(object, CURRENT_PLAYER_OID, containingPlayer);
|
|
|
|
//------------------
|
|
//get dictionary from base script hook here
|
|
//------------------
|
|
dictionary playerCTSData = getCharacterCtsHistory(containingPlayer);
|
|
if(playerCTSData == null || playerCTSData.isEmpty())
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS REWARD - " + object + " created but could not get the player "+containingPlayer+" CTS Data. Location: "+getLocation(object));
|
|
return false;
|
|
}
|
|
|
|
string[] playerPreviousName = playerCTSData.getStringArray("character_name");
|
|
if(playerPreviousName == null || playerPreviousName.length <= 0)
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS REWARD - " + object + " created but could not get containing player OID. Location: "+getLocation(object));
|
|
return false;
|
|
}
|
|
|
|
string[] playerPreviousGalaxy = playerCTSData.getStringArray("cluster_name");
|
|
if(playerPreviousGalaxy == null || playerPreviousGalaxy.length <= 0)
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS REWARD - " + object + " created but could not get containing player OID. Location: "+getLocation(object));
|
|
return false;
|
|
}
|
|
|
|
int[] timeDate = playerCTSData.getIntArray("transfer_time");
|
|
if(timeDate == null || timeDate.length <= 0)
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS REWARD - " + object + " created but could not get the current Cal Time for this message. Location: "+getLocation(object));
|
|
return false;
|
|
}
|
|
|
|
//validation for length of all player data arrays
|
|
if(playerPreviousName.length != playerPreviousGalaxy.length || playerPreviousName.length != timeDate.length)
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS REWARD - " + object + " created but player CTS Data not consistent. Player: "+getName(containingPlayer) + " " + containingPlayer);
|
|
return false;
|
|
}
|
|
//set all objvars on object
|
|
setObjVar(object, CURRENT_PLAYER_NAME, getPlayerFullName(containingPlayer));
|
|
setObjVar(object, CURRENT_PLAYER_CLUSTER, getClusterName());
|
|
setObjVar(object, DATETIME_GIFT_TRANSFER, timeDate[timeDate.length-1]);
|
|
setObjVar(object, PREVIOUS_PLAYER_NAME, playerPreviousName[playerPreviousName.length-1]);
|
|
setObjVar(object, PREVIOUS_PLAYER_CLUSTER, playerPreviousGalaxy[playerPreviousGalaxy.length-1]);
|
|
|
|
if(hasObjVar(object, CTS_PAINTING_OBJVAR))
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS SPONSOR'S GIFT BOX stamped with data from Player: "+containingPlayer+" "+getName(containingPlayer) + " claimed the Galaxy Painting CTS Reward: " +object+ " " + getName(object) + " at " + getCalendarTimeStringLocal(timeDate[timeDate.length-1]) + " showing a previous galaxy of: " + playerPreviousGalaxy[playerPreviousGalaxy.length-1] + " where the player's name was: "+playerPreviousName[playerPreviousName.length-1]);
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("veteran", "- CTS REFUGEE PAINTING stamped with data from Player: "+containingPlayer+" "+getName(containingPlayer) + " claimed the Galaxy Painting CTS Reward: " +object+ " " + getName(object) + " at " + getCalendarTimeStringLocal(timeDate[timeDate.length-1]) + " showing a previous galaxy of: " + playerPreviousGalaxy[playerPreviousGalaxy.length-1] + " where the player's name was: "+playerPreviousName[playerPreviousName.length-1]);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean blog(string msg)
|
|
{
|
|
if(BLOGGING_ON)
|
|
LOG(BLOG_CATEGORY, msg);
|
|
return true;
|
|
}
|
|
|
|
void initiateCtsFromItem(obj_id player, obj_id item)
|
|
{
|
|
if (!isValidId(player) || !isValidId(item))
|
|
return;
|
|
|
|
dictionary d = new dictionary();
|
|
d.put("item", item);
|
|
messageTo(player, "initiateCtsFromItem", d, 0.0f, false);
|
|
}
|