mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
503 lines
16 KiB
Plaintext
503 lines
16 KiB
Plaintext
/**
|
|
* Copyright (c)2008 Sony Online Entertainment Inc.
|
|
* All Rights Reserved
|
|
*
|
|
* Title: house_pet.scriptlib
|
|
* Description:
|
|
* @author $Author:jhaskell$
|
|
* @version $Revision:$
|
|
*/
|
|
|
|
//Library to be used for any mob that resides inside a player
|
|
//structure such as the TCG Greeter, Target Creature, Target Dummy,
|
|
//CTS Sarlaac, etc.
|
|
|
|
include java.util.Vector;
|
|
include library.create;
|
|
include library.player_structure;
|
|
include library.static_item;
|
|
include library.utils;
|
|
|
|
//------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------
|
|
//LOGGING
|
|
const boolean LOGGING_ON = true;
|
|
const string LOGGING_CATEGORY = "massiff_pet";
|
|
|
|
const string SARLACC_LOOT_TABLE = "datatables/loot/sarlacc_cts_housepet_loot.iff";
|
|
const string SARLACC_CTS_CRC_TABLE = "datatables/minigame/sarlacc_cts_crc.iff";
|
|
|
|
const string HOUSE_PET_TEMPLATE_OBJVAR = "house_pet";
|
|
|
|
const string CONTROLLER_PREFIX = "controller";
|
|
const string STATIC_ITEM_DEED_NAME = CONTROLLER_PREFIX + ".static_item_deed_name";
|
|
const string CHILD_OBJ_ID = CONTROLLER_PREFIX + ".child_id";
|
|
const string PET_HAS_BEEN_CALLED = CONTROLLER_PREFIX + ".pet_called";
|
|
const string PET_HUE_INDEX1 = CONTROLLER_PREFIX + ".pet_hue_index1";
|
|
|
|
const string HOUSEPET_PREFIX = "house_pet";
|
|
const string PARENT_OBJ_ID = HOUSEPET_PREFIX + ".parent_id";
|
|
const string SARLACC_BASE_LOCATION = HOUSEPET_PREFIX + ".last_location";
|
|
const string PET_NAME = HOUSEPET_PREFIX + ".name";
|
|
const string PET_MOVING = HOUSEPET_PREFIX + ".is_moving";
|
|
const string BEING_FED = HOUSEPET_PREFIX + ".being_fed";
|
|
|
|
const string MASSIFF_CURRENT_PHASE = HOUSEPET_PREFIX + ".current_phase";
|
|
const string MASSIFF_LAST_FED = HOUSEPET_PREFIX + ".last_fed";
|
|
const string MASSIFF_FOOD_OBJ = HOUSEPET_PREFIX + ".food_object";
|
|
const string MASSIFF_EGG_COUNT = HOUSEPET_PREFIX + ".egg_count";
|
|
|
|
//Scurrier Mini-Game Constants
|
|
const int SCURRIER_SNACK_DELAY = 259200;
|
|
const string SCURRIER_ITEM_01 = "item_tcg_scurrier_trash_item_02_01";
|
|
const string SCURRIER_ITEM_02 = "item_tcg_scurrier_trash_item_02_02";
|
|
const string SCURRIER_ITEM_03 = "item_tcg_scurrier_trash_item_02_03";
|
|
const string SCURRIER_ITEM_04 = "item_tcg_scurrier_trash_item_02_04";
|
|
const string SCURRIER_SNACK_LAST_FED = "scurrier_last_snack";
|
|
const string PET_SNACK_OID = CONTROLLER_PREFIX + ".pet_snack_oid";
|
|
const string SCURRIER_SNACK_OBJ = HOUSEPET_PREFIX + ".snack_object";
|
|
|
|
//SARLACC MINI GAME PHASES
|
|
const int SARLACC_FED = 0;
|
|
const int SARLACC_HUNGRY = 1;
|
|
const int SARLACC_STARVING = 2;
|
|
const int SARLACC_DEATH = 3;
|
|
|
|
const string[] SARLACC_PHASES =
|
|
{
|
|
"phase_fed",
|
|
"phase_hungry",
|
|
"phase_starving",
|
|
"phase_death"
|
|
};
|
|
|
|
const string[] MASSIFF_PHASES =
|
|
{
|
|
"phase_fed",
|
|
"phase_hungry",
|
|
"dirt_nap"
|
|
};
|
|
|
|
//OTHER SARLACC SPECIFIC CONST
|
|
const string SARLACC_PREFIX = "sarlacc_minigame";
|
|
const string SARLACC_BORN = SARLACC_PREFIX + ".born_time";
|
|
const string EDIBLES_PREFIX = SARLACC_PREFIX + ".edibles";
|
|
const string EDIBLES_SUI = EDIBLES_PREFIX + ".sui";
|
|
const string EDIBLES_IDS = EDIBLES_PREFIX + ".ids";
|
|
|
|
const string SARLACC_CRC = SARLACC_PREFIX + ".sarlacc_stomach";
|
|
const string SARLACC_FEED_ARRAY = SARLACC_PREFIX + ".feed_array";
|
|
const string SARLACC_CURRENT_PHASE = SARLACC_PREFIX + ".current_phase";
|
|
const string SARLACC_LAST_FED = SARLACC_PREFIX + ".last_fed";
|
|
const string SARLACC_FEEDING_ITERATION = SARLACC_PREFIX + ".feeding_iteration";
|
|
const string SARLACC_PHASE_START = SARLACC_PREFIX + ".phase_start";
|
|
const string SARLACC_PHASE_WEEK = SARLACC_PREFIX + ".phase_week";
|
|
const string SARLACC_OWNER_AFFECTION = SARLACC_PREFIX + ".last_affection";
|
|
const string SARLACC_REWARD_AVAILABLE = SARLACC_PREFIX + ".reward_radial";
|
|
const string SARLACC_REWARD_COLUMN = SARLACC_PREFIX + ".reward_column";
|
|
const string SARLACC_PENALTY_VAR = SARLACC_PREFIX + ".penalty_delivered";
|
|
const string SARLACC_AVOID_REPEATED_UPDATES = SARLACC_PREFIX + ".no_updated_duplicates";
|
|
|
|
|
|
const string SARLACC_FAST_UPDATE_RATE = SARLACC_PREFIX + ".god_hax";
|
|
const string SARLACC_DAILY_UPDATE_RATE = SARLACC_PREFIX + ".god_hax_daily";
|
|
const string MASSIFF_FIVE_MIN_UPDATE_RATE = SARLACC_PREFIX + ".god_hax_five_min";
|
|
|
|
const int SARLACC_UPDATE_WEEK = 604800; // ONE WEEK FROM BIRTH
|
|
const int SARLACC_UPDATE_DAY = 86400; // ONE WEEK FROM BIRTH
|
|
const int SARLACC_PHASE_WEEKS = 4; // Total Weeks before reward
|
|
const int SARLACC_DAYS_IN_WEEK = 7; //
|
|
const int SARLACC_REWARD_WEEK = SARLACC_PHASE_WEEKS + 1; // Reward window
|
|
const int SARLACC_UPDATED_SECONDS = 300; // Minimum time player can see new status on sarlacc
|
|
|
|
const int SARLACC_GOD_WEEK = 35; //week lasts 35 seconds
|
|
const int SARLACC_GOD_DAY = 5; //day lasts 5 seconds
|
|
|
|
const int SARLACC_GOD_DAILY_WEEK = 86400; //week lasts 1 24 hour day
|
|
const int SARLACC_GOD_DAILY_DAY = 12342; //day lasts 3.4 hours
|
|
|
|
const int MASSIFF_GOD_DAILY_WEEK = 300;
|
|
const int MASSIFF_GOD_DAILY_DAY = 30;
|
|
|
|
const string SOUND_SILENCE = "sound/music_silence.snd";
|
|
const string MUSIC_RANGE = "music_range";
|
|
const string PET_TRIG_VOLUME = "petTriggerVol";
|
|
const string PET_SOUND_LABEL = "petSoundLabel";
|
|
const string HOUSE_PET_MENU_PID = HOUSEPET_PREFIX + "housePetMenuPID";
|
|
|
|
const string MASSIFF_SCRIPT = "systems.tcg.tcg_massif_creature";
|
|
|
|
const string[] ALL_MASSIF_ANIMATIONS =
|
|
{
|
|
"alert",
|
|
"ashamed",
|
|
"confused",
|
|
"drink",
|
|
"eat",
|
|
"fidget",
|
|
"happy",
|
|
"look",
|
|
"look_left",
|
|
"look_right",
|
|
"nervous",
|
|
"scratch",
|
|
"sniff",
|
|
"stretch",
|
|
"threaten",
|
|
"trick_1",
|
|
"trick_2",
|
|
"vocalize"
|
|
};
|
|
|
|
const string MASSIF_ANIMATION_ALERT = "alert";
|
|
const string MASSIF_ANIMATION_ASHAMED = "ashamed";
|
|
const string MASSIF_ANIMATION_CONFUSED = "confused";
|
|
const string MASSIF_ANIMATION_DRINK = "drink";
|
|
const string MASSIF_ANIMATION_EAT = "eat";
|
|
const string MASSIF_ANIMATION_FIDGET = "fidget";
|
|
const string MASSIF_ANIMATION_HAPPY = "happy";
|
|
const string MASSIF_ANIMATION_LOOK = "look";
|
|
const string MASSIF_ANIMATION_LOOK_LEFT = "look_left";
|
|
const string MASSIF_ANIMATION_LOOK_RIGHT = "look_right";
|
|
const string MASSIF_ANIMATION_NERVOUS = "nervous";
|
|
const string MASSIF_ANIMATION_SCRATCH = "scratch";
|
|
const string MASSIF_ANIMATION_SNIFF = "sniff";
|
|
const string MASSIF_ANIMATION_STRETCH = "stretch";
|
|
const string MASSIF_ANIMATION_THREATEN = "threaten";
|
|
const string MASSIF_ANIMATION_TRICK1 = "trick_1";
|
|
const string MASSIF_ANIMATION_TRICK2 = "trick_2";
|
|
const string MASSIF_ANIMATION_VOCALIZE = "vocalize";
|
|
|
|
const string[] ALL_MASSIF_STATES =
|
|
{
|
|
"none",
|
|
"sleeping",
|
|
"lying",
|
|
"sitting_ground",
|
|
"test"
|
|
};
|
|
|
|
const int SARLACC_VERSION = 2;
|
|
const string SARLACC_VERSION_VAR = SARLACC_PREFIX + ".sarlacc_version";
|
|
const string SARLACC_FREE_CHANCE = SARLACC_PREFIX + ".used_free_chance";
|
|
const string NO_SARLACC_SOUND = SARLACC_PREFIX + ".no_sound";
|
|
|
|
|
|
const string MASSIF_STATE_COMBAT = "combat";
|
|
const string MASSIF_STATE_SLEEPING = "sleeping";
|
|
const string MASSIF_STATE_LYING = "lying";
|
|
const string MASSIF_STATE_SITTING = "sitting_ground";
|
|
|
|
//MORE MASSIF CONST
|
|
const string SIT = "sit";
|
|
const string TRICK = "trick";
|
|
const string EAT = "eat";
|
|
const string DRINK = "drink";
|
|
const string BAD = "bad";
|
|
const string COME = "come";
|
|
const string GOOD = "good";
|
|
const string HEEL = "heel";
|
|
const string UP = "up";
|
|
const string DOWN = "down";
|
|
const string SLEEP = "sleep";
|
|
const string TAKE = "take";
|
|
const string BED = "bed";
|
|
const string QUIET = "quiet";
|
|
const string STAY = "stay";
|
|
const string HERE = "here";
|
|
const string BACK = "back";
|
|
const string POTTY = "potty";
|
|
const string BREAK = "break";
|
|
const string POODOO = "poodoo";
|
|
const string POOP = "poop";
|
|
const string FETCH = "fetch";
|
|
const string SPEAK = "speak";
|
|
const string BARK = "bark";
|
|
const string DEAD = "dead";
|
|
const string PLAYDEAD = "playdead";
|
|
const string DIE = "die";
|
|
const string CONFUSED = "confused";
|
|
const string BEG = "beg";
|
|
|
|
//MASSIFF SOUNDS
|
|
const string SOUND_GROWL_RANDOM_MASSIFF = "sound/cr_massiff_random_growl.snd";
|
|
const string SOUND_WHINE_RANDOM_MASSIFF = "sound/cr_massiff_random_whine.snd";
|
|
const string SOUND_GROWL_RANDOM_NUNA = "sound/cr_nuna_random_growl.snd";
|
|
const string SOUND_WHINE_RANDOM_NUNA = "sound/cr_nuna_vocalize.snd";
|
|
const string SOUND_GROWL_RANDOM_SCURRIER = "sound/cr_blistmok_emote.snd";
|
|
const string SOUND_WHINE_RANDOM_SCURRIER = "sound/cr_blistmok_attack_light.snd";
|
|
|
|
const string HOUSE_PET_OBJVAR = "house_pet_creature";
|
|
const string HOUSE_PET_SCRIPT = "house_pet_script";
|
|
const string MASSIFF_CREATURE = "tcg_massiff_pet";
|
|
const string PET_FEEDABLE = "pet_feedable";
|
|
const string PET_FOOD_OID = CONTROLLER_PREFIX + ".pet_food_oid";
|
|
|
|
const int MASSIFF_FED = 0;
|
|
const int MASSIFF_HUNGRY = 1;
|
|
const int MASSIFF_DEAD = 2;
|
|
const string PET_KNOCKED_OUT = CONTROLLER_PREFIX + ".pet_knocked_out";
|
|
const string MASSIFF_HUNGRY_EMOTE = "appearance/pt_massiff_hungry_emote.prt";
|
|
const string NUNA_HUNGRY_EMOTE = "appearance/pt_nuna_hungry_emote.prt";
|
|
const string SCURRIER_HUNGRY_EMOTE = "appearance/pt_scurrier_hungry_emote.prt";
|
|
const string MASSIFF_POO_STATIC_ITEM = "item_tcg_nuna_rotten_egg_02_01";
|
|
|
|
//set the owner upon receiving the controller object
|
|
boolean setObjectOwner(obj_id controller)
|
|
{
|
|
if(!isValidId(controller) || !exists(controller))
|
|
return false;
|
|
|
|
if(!utils.isNestedWithinAPlayer(controller))
|
|
return false;
|
|
|
|
obj_id owner = utils.getContainingPlayer(controller);
|
|
if(!isValidId(owner) && !exists(owner))
|
|
return false;
|
|
|
|
setOwner(controller, owner);
|
|
return true;
|
|
}
|
|
|
|
//used by the greeter/non-vendor deed to get the owner of the deed/controller object
|
|
obj_id getObjectOwner(obj_id controller)
|
|
{
|
|
if(!isValidId(controller) || !exists(controller))
|
|
return null;
|
|
|
|
obj_id owner = getOwner(controller);
|
|
if(!isValidId(owner))
|
|
{
|
|
if(!setObjectOwner(controller))
|
|
return null;
|
|
}
|
|
return owner;
|
|
}
|
|
|
|
|
|
obj_id recreateSarlaccObjectAtLocationFromObjVar(obj_id controller)
|
|
{
|
|
if(!isValidId(controller) || !exists(controller))
|
|
return null;
|
|
|
|
location where = getLocation(controller);
|
|
if(where == null)
|
|
return null;
|
|
|
|
if(!hasObjVar(controller, HOUSE_PET_TEMPLATE_OBJVAR))
|
|
return null;
|
|
string mobileTemplate = getStringObjVar(controller, HOUSE_PET_TEMPLATE_OBJVAR);
|
|
if(mobileTemplate == null || mobileTemplate.equals(""))
|
|
return null;
|
|
|
|
obj_id housePetObj = create.staticObject(mobileTemplate, where);
|
|
if(!isValidId(housePetObj) || !exists(housePetObj))
|
|
return null;
|
|
//give the controller the greeter oid
|
|
setObjVar(controller, CHILD_OBJ_ID, housePetObj);
|
|
//give the greeter the controller oid
|
|
setObjVar(housePetObj, PARENT_OBJ_ID, controller);
|
|
// Set flags.
|
|
setInvulnerable(housePetObj, true);
|
|
|
|
if(mobileTemplate.indexOf("s02.iff") > -1)
|
|
attachScript(housePetObj, "event.housepackup.sarlacc_mini_game");
|
|
|
|
return housePetObj;
|
|
}
|
|
|
|
|
|
boolean recreateObjectFromObjVar(obj_id controller)
|
|
{
|
|
if(!isValidId(controller) || !exists(controller))
|
|
return false;
|
|
|
|
location where = getLocation(controller);
|
|
if(where == null)
|
|
return false;
|
|
|
|
string npcType = "";
|
|
if(!hasObjVar(controller, HOUSE_PET_TEMPLATE_OBJVAR))
|
|
return false;
|
|
string mobileTemplate = getStringObjVar(controller, HOUSE_PET_TEMPLATE_OBJVAR);
|
|
if(mobileTemplate == null || mobileTemplate.equals(""))
|
|
return false;
|
|
|
|
return buildHousePetInPlayerStructure(controller, mobileTemplate, where);
|
|
}
|
|
|
|
boolean buildHousePetInPlayerStructure(obj_id controller, string mobileTemplate, location spawnLoc)
|
|
{
|
|
if(!isValidId(controller) || !exists(controller))
|
|
return false;
|
|
if(mobileTemplate == null || mobileTemplate.equals(""))
|
|
return false;
|
|
if(spawnLoc == null)
|
|
return false;
|
|
if(!validateNpcPlacementInStructure(controller))
|
|
return false;
|
|
|
|
obj_id housePetObj = create.staticObject(mobileTemplate, spawnLoc);
|
|
if(!isValidId(housePetObj) || !exists(housePetObj))
|
|
return false;
|
|
//give the controller the greeter oid
|
|
setObjVar(controller, CHILD_OBJ_ID, housePetObj);
|
|
//give the greeter the controller oid
|
|
setObjVar(housePetObj, PARENT_OBJ_ID, controller);
|
|
// Set flags.
|
|
setInvulnerable(housePetObj, true);
|
|
|
|
if(mobileTemplate.indexOf("s02.iff") > -1)
|
|
attachScript(housePetObj, "event.housepackup.sarlacc_mini_game");
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean validateNpcPlacementInStructure(obj_id object)
|
|
{
|
|
return validateNpcPlacementInStructure(object, obj_id.NULL_ID);
|
|
}
|
|
|
|
boolean validateNpcPlacementInStructure(obj_id object, obj_id operator)
|
|
{
|
|
if(!isValidId(object) || !exists(object))
|
|
return false;
|
|
|
|
obj_id structure = getTopMostContainer(object);
|
|
if(!isValidId(structure) || !exists(structure))
|
|
return false;
|
|
|
|
if(!player_structure.isPlayerStructure(structure) || player_structure.isCivic(structure))
|
|
return false;
|
|
|
|
if(isIdNull(operator))
|
|
return true;
|
|
|
|
//If there is an operator, go ahead and
|
|
//validate the following
|
|
if(player_structure.isOwner(structure, operator))
|
|
return true;
|
|
|
|
if(player_structure.isAdmin(structure, operator))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
boolean cleanUpHousePet(obj_id housePet)
|
|
{
|
|
return cleanUpHousePet(obj_id.NULL_ID, housePet);
|
|
}
|
|
|
|
boolean cleanUpHousePet(obj_id controller, obj_id housePet)
|
|
{
|
|
if(!isValidId(housePet) || !exists(housePet))
|
|
return false;
|
|
|
|
if(hasTriggerVolume(housePet, PET_TRIG_VOLUME))
|
|
removeTriggerVolume(PET_TRIG_VOLUME);
|
|
|
|
stopPlayingMusic(housePet);
|
|
destroyObject(housePet);
|
|
|
|
if(isValidId(controller) && exists(controller))
|
|
removeObjVar(controller, house_pet.CHILD_OBJ_ID);
|
|
|
|
return true;
|
|
}
|
|
|
|
int getUpdateWeekly(obj_id controller)
|
|
{
|
|
|
|
if(hasObjVar(controller, house_pet.SARLACC_FAST_UPDATE_RATE))
|
|
return house_pet.SARLACC_GOD_WEEK;
|
|
else if(hasObjVar(controller, house_pet.SARLACC_DAILY_UPDATE_RATE))
|
|
return house_pet.SARLACC_GOD_DAILY_WEEK;
|
|
else if(hasObjVar(controller, house_pet.MASSIFF_FIVE_MIN_UPDATE_RATE))
|
|
return house_pet.MASSIFF_GOD_DAILY_WEEK;
|
|
else
|
|
return house_pet.SARLACC_UPDATE_WEEK;
|
|
}
|
|
|
|
int getUpdateDaily(obj_id controller)
|
|
{
|
|
|
|
if(hasObjVar(controller, house_pet.SARLACC_FAST_UPDATE_RATE))
|
|
return house_pet.SARLACC_GOD_DAY;
|
|
else if(hasObjVar(controller, house_pet.SARLACC_DAILY_UPDATE_RATE))
|
|
return house_pet.SARLACC_GOD_DAILY_DAY;
|
|
else if(hasObjVar(controller, house_pet.MASSIFF_FIVE_MIN_UPDATE_RATE))
|
|
return house_pet.MASSIFF_GOD_DAILY_DAY;
|
|
else
|
|
return house_pet.SARLACC_UPDATE_DAY;
|
|
}
|
|
|
|
boolean stopPlayingMusic(obj_id self)
|
|
{
|
|
//must have MUSIC_RANGE objvar
|
|
if(!hasObjVar(self, MUSIC_RANGE))
|
|
return false;
|
|
|
|
location here = getLocation(self);
|
|
if(here == null)
|
|
return false;
|
|
|
|
float range = getFloatObjVar(self, MUSIC_RANGE) + 10;
|
|
if(range <= 0)
|
|
return false;
|
|
|
|
obj_id[] playersList = getPlayerCreaturesInRange(here, range);
|
|
if(playersList == null || playersList.length <= 0)
|
|
return false;
|
|
|
|
for(int i = 0; i < playersList.length; i++)
|
|
{
|
|
obj_id player = playersList[i];
|
|
if (!isIdValid(player))
|
|
continue;
|
|
|
|
stopClientEffectObjByLabel(player, self, PET_SOUND_LABEL);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//House or POB ship check.
|
|
boolean isInAPlayerHouse(obj_id device)
|
|
{
|
|
if(!isValidId(device) || !exists(device))
|
|
return false;
|
|
|
|
if(utils.isNestedWithinAPlayer(device))
|
|
return false;
|
|
|
|
obj_id selfContainer = getContainedBy(device);
|
|
obj_id ship = space_transition.getContainingShip(selfContainer);
|
|
|
|
if(isIdValid(ship))
|
|
{
|
|
string templateName = getTemplateName(ship);
|
|
if(space_utils.isPobType(templateName))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
obj_id house = getTopMostContainer(device);
|
|
if(isIdValid(house) && !player_structure.isBuilding(house))
|
|
return false;
|
|
if(player_structure.isPackedUp(house))
|
|
return false;
|
|
if(utils.isInHouseCellSpace(device))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
boolean blog(string msg)
|
|
{
|
|
if(LOGGING_ON && msg != null && !msg.equals(""))
|
|
LOG(LOGGING_CATEGORY, msg);
|
|
return true;
|
|
}
|