mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
804 lines
21 KiB
Plaintext
804 lines
21 KiB
Plaintext
/**
|
|
* Copyright (c)2000-2004 Sony Online Entertainment Inc.
|
|
* All Rights Reserved
|
|
*
|
|
* Title: fs_kickoff.scriptlib
|
|
* Description: scriptlib for force sensitive kickoff functions
|
|
* @author $Author:$
|
|
* @version $Revision:$
|
|
*/
|
|
|
|
include library.utils;
|
|
include library.pclib;
|
|
include library.fs_dyn_village;
|
|
include library.locations;
|
|
include library.ai_lib;
|
|
include library.quests;
|
|
include library.factions;
|
|
|
|
const string DATATABLE_SKILL_BRANCH = "datatables/quest/force_sensitive/skill_branch.iff";
|
|
|
|
const string VAR_BRANCHES_UNLOCKED = "fs_quest.branches_unlocked";
|
|
const string VAR_FREE_UNLOCK_USED = "fs_quest.free_unlock_used";
|
|
const string VAR_VILLAGE_ELIGIBLE = "fs_quest.village_eligible";
|
|
const string VAR_VILLAGE_COMPLETE = "fs_quest.village_complete";
|
|
const string VAR_QUEST_ACCEPTED = "fs_quest.quest_accepted";
|
|
const string VAR_QUEST_COMPLETED = "fs_quest.quest_completed";
|
|
|
|
const string SCRIPT_VAR_BRANCH_SELECT_SUI = "fs_quest.branch_select_sui";
|
|
const string SCRIPT_VAR_BRANCH_SELECT_LIST = "fs_quest.branch_select_list";
|
|
const string SCRIPT_VAR_REMOVE_TASK_SUI = "fs_quest.remove_task_sui";
|
|
const string SCRIPT_VAR_REMOVE_TASK_LIST = "fs_quest.remove_task_list";
|
|
const string SCRIPT_VAR_REMOVE_TASK_PLAYER = "fs_quest.remove_task_player";
|
|
const string SCRIPT_VAR_UNLOCK_BRANCH_SUI = "fs_quest.unlock_branch_sui";
|
|
const string SCRIPT_VAR_UNLOCK_BRANCH_PLAYER = "fs_quest.unlock_branch_player";
|
|
|
|
void badgeLeadin (obj_id player)
|
|
{
|
|
int randomNumber = rand (1,250);
|
|
if (randomNumber == 250)
|
|
{
|
|
// TODO: Send system message telling them to get more exploration badges
|
|
// TODO: Build in some way for player to shut this message off
|
|
}
|
|
return;
|
|
}
|
|
|
|
void setDelay (obj_id player, int stage)
|
|
{
|
|
setObjVar(player, "fs_timestamp", getGameTime());
|
|
int randomTimeDelay = 0;
|
|
int visits = 0;
|
|
|
|
|
|
switch(stage)
|
|
{
|
|
case 0: // Old man Delay [1 to 2 days by default but overridden by the server config]
|
|
{
|
|
fs_quests.advanceStage(player);
|
|
string config = getConfigSetting("GameServer", "forceSensitiveIntroDelayFloor");
|
|
int delayFloor = utils.stringToInt(config);
|
|
if (delayFloor <= 0)
|
|
{
|
|
delayFloor = 86400; // Use the default of 1 day
|
|
}
|
|
config = getConfigSetting("GameServer", "forceSensitiveIntroDelayCeiling");
|
|
int delayCeiling = utils.stringToInt(config);
|
|
if (delayCeiling <= 0)
|
|
{
|
|
delayCeiling = 172800; // Use the default of 2 days
|
|
}
|
|
|
|
randomTimeDelay = rand (delayFloor, delayCeiling); // Set a delay between 1 day and 2 days for the next stage to start
|
|
|
|
// Make it so the old man comes back less and less often
|
|
if (!hasObjVar(player, "fs_oldman_visits"))
|
|
{
|
|
setObjVar(player, "fs_oldman_visits", 1);
|
|
}
|
|
|
|
visits = getIntObjVar(player, "fs_oldman_visits");
|
|
|
|
if (visits == 2)
|
|
{
|
|
randomTimeDelay = randomTimeDelay + 172800; // 2 visits + 2 days
|
|
}
|
|
|
|
if (visits == 3)
|
|
{
|
|
randomTimeDelay = randomTimeDelay + 604800; // 3 visits + 7 days
|
|
}
|
|
|
|
if (visits == 4)
|
|
{
|
|
randomTimeDelay = randomTimeDelay + 1209600; // 4 visits + 14 days
|
|
}
|
|
|
|
if (visits == 5)
|
|
{
|
|
randomTimeDelay = randomTimeDelay + 2419200; // 5 visits + month
|
|
}
|
|
|
|
if (visits >= 6)
|
|
{
|
|
randomTimeDelay = randomTimeDelay + 4838400; // 2 months
|
|
}
|
|
|
|
visits = visits +1;
|
|
|
|
setObjVar(player, "fs_oldman_visits", visits);
|
|
|
|
break;
|
|
}
|
|
case 3: // Two military enemies Delay [1 hour - 1 day]
|
|
{
|
|
string config = getConfigSetting("GameServer", "forceSensitiveIntroDelayFloor");
|
|
int delayFloor = utils.stringToInt(config);
|
|
if (delayFloor <= 0)
|
|
{
|
|
delayFloor = 3600;
|
|
}
|
|
config = getConfigSetting("GameServer", "forceSensitiveIntroDelayCeiling");
|
|
int delayCeiling = utils.stringToInt(config);
|
|
if (delayCeiling <= 0)
|
|
{
|
|
delayCeiling = 86400;
|
|
}
|
|
randomTimeDelay = rand (delayFloor, delayCeiling);
|
|
break;
|
|
}
|
|
case 13: // Old Man exit delay
|
|
randomTimeDelay = rand (15600, 86400); // Set a delay between 6 hours and 1 day for the next stage to start
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
setObjVar(player, "fs_delay", randomTimeDelay);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
boolean checkDelay(obj_id player)
|
|
{
|
|
int currentTime = getGameTime();
|
|
int startTime = getIntObjVar(player, "fs_timestamp");
|
|
int delayTime = getIntObjVar(player, "fs_delay");
|
|
if (currentTime > (startTime + delayTime))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// Checks to see if the player is eligible to do quests from the village.
|
|
boolean isVillageEligible(obj_id player)
|
|
{
|
|
/* DISABLED FOR NPE
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.isVillageEligible -- player is invalid.");
|
|
return false;
|
|
}
|
|
|
|
// Jedis always qualify for the village.
|
|
if (isJedi(player))
|
|
{
|
|
factions.setFactionStanding(player, "sith_shadow", factions.FACTION_RATING_MIN);
|
|
return true;
|
|
}
|
|
|
|
if (hasObjVar(player, VAR_VILLAGE_ELIGIBLE))
|
|
return true;
|
|
else
|
|
*/
|
|
return false;
|
|
}
|
|
|
|
// Sets the player as eligible to do quests for the village.
|
|
boolean makeVillageEligible(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.makeVillageEligible -- player is invalid.");
|
|
return false;
|
|
}
|
|
|
|
factions.setFactionStanding(player, "sith_shadow", factions.FACTION_RATING_MIN);
|
|
setObjVar(player, VAR_VILLAGE_ELIGIBLE, 1);
|
|
|
|
return true;
|
|
}
|
|
|
|
// Check to see if the player has completed the village quest and is now eligible for the end quest.
|
|
boolean isEndQuestEligible(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.isEndQuestEligible -- player is invalid.");
|
|
return false;
|
|
}
|
|
|
|
return hasObjVar(player, VAR_VILLAGE_COMPLETE);
|
|
}
|
|
|
|
// Returns the number of fs branches that the player has learned.
|
|
int getBranchesLearned(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchesLearned -- player is invalid.");
|
|
return -1;
|
|
}
|
|
|
|
int learned_branches = 0;
|
|
for (int i = 0; i < 16; i++)
|
|
{
|
|
string branch = getBranchFromId(i);
|
|
if (branch != null)
|
|
{
|
|
if (hasSkill(player, branch + "_04"))
|
|
learned_branches++;
|
|
}
|
|
}
|
|
|
|
return learned_branches;
|
|
}
|
|
|
|
// Returns the id of the specified force sensitive skill branch
|
|
int getBranchId(string branch)
|
|
{
|
|
if (branch == null)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchId -- branch is null.");
|
|
return -1;
|
|
}
|
|
int index = dataTableSearchColumnForString(branch, "branch", DATATABLE_SKILL_BRANCH);
|
|
if (index == -1)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchId -- can't find branch " + branch);
|
|
return -1;
|
|
}
|
|
|
|
return dataTableGetInt(DATATABLE_SKILL_BRANCH, index, "id");
|
|
}
|
|
|
|
// Returns the skill branch name from its id.
|
|
string getBranchFromId(int id)
|
|
{
|
|
if (id < 0)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchFromId -- id is not valid.");
|
|
return null;
|
|
}
|
|
|
|
int index = dataTableSearchColumnForInt(id, "id", DATATABLE_SKILL_BRANCH);
|
|
if (index == -1)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchFromId -- can't find id " + id);
|
|
return null;
|
|
}
|
|
|
|
return dataTableGetString(DATATABLE_SKILL_BRANCH, index, "branch");
|
|
}
|
|
|
|
string getBranchFromSkill(string skill)
|
|
{
|
|
if (skill == null)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchFromSkill -- skill is null.");
|
|
return null;
|
|
}
|
|
int index = dataTableSearchColumnForString(skill, "skill", DATATABLE_SKILL_BRANCH);
|
|
if (index == -1)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getBranchFromSkill -- can't find skill " + skill);
|
|
return null;
|
|
}
|
|
|
|
return dataTableGetString(DATATABLE_SKILL_BRANCH, index, "branch");
|
|
}
|
|
|
|
// Checks to see if the player has unlocked the specified branch
|
|
boolean hasUnlockedBranch(obj_id player, string branch)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.hasUnlockedBranch -- player is invalid");
|
|
return false;
|
|
}
|
|
if (branch == null)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.hasUnlockedBranch -- branch is null");
|
|
return false;
|
|
}
|
|
|
|
// Novice and master branches don't need to be unlocked
|
|
if (branch.equals("master") || branch.equals("novice"))
|
|
return true;
|
|
|
|
int branches_unlocked = 0;
|
|
if (hasObjVar(player, VAR_BRANCHES_UNLOCKED))
|
|
branches_unlocked = getIntObjVar(player, VAR_BRANCHES_UNLOCKED);
|
|
else
|
|
return false;
|
|
|
|
int pos = getBranchId(branch);
|
|
if (pos < 0)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.hasUnlockedBranch -- can't find id for " + branch);
|
|
return false;
|
|
}
|
|
|
|
return utils.checkBit(branches_unlocked, pos);
|
|
}
|
|
|
|
boolean hasUnlockedBranch(obj_id player, int id)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.hasUnlockedBranch -- player is invalid");
|
|
return false;
|
|
}
|
|
int branches_unlocked = 0;
|
|
if (hasObjVar(player, VAR_BRANCHES_UNLOCKED))
|
|
branches_unlocked = getIntObjVar(player, VAR_BRANCHES_UNLOCKED);
|
|
else
|
|
return false;
|
|
|
|
return utils.checkBit(branches_unlocked, id);
|
|
}
|
|
|
|
boolean unlockBranch(obj_id player, string branch)
|
|
{
|
|
int branches_unlocked = 0;
|
|
if (hasObjVar(player, VAR_BRANCHES_UNLOCKED))
|
|
branches_unlocked = getIntObjVar(player, VAR_BRANCHES_UNLOCKED);
|
|
|
|
int index = dataTableSearchColumnForString(branch, "branch", DATATABLE_SKILL_BRANCH);
|
|
if (index == -1)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.unlockBranch -- can't find branch " + branch);
|
|
return false;
|
|
}
|
|
|
|
int pos = getBranchId(branch);
|
|
if (pos < 0)
|
|
{
|
|
LOG("force_sensitive", "fs_quests.unlockBranch -- can't find id for " + branch);
|
|
return false;
|
|
}
|
|
|
|
branches_unlocked = utils.setBit(branches_unlocked, pos);
|
|
setObjVar(player, VAR_BRANCHES_UNLOCKED, branches_unlocked);
|
|
|
|
string_id branch_sid = utils.unpackString("@quest/force_sensitive/utils:" + branch);
|
|
string branch_str = localize(branch_sid);
|
|
prose_package pp = prose.getPackage(new string_id("quest/force_sensitive/utils", "branch_selected_unlock"), branch_str);
|
|
sendSystemMessageProse(player, pp);
|
|
|
|
return true;
|
|
}
|
|
|
|
// Marks the player has having taken a quest for the current phase.
|
|
boolean setQuestAccepted(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.setQuestAccepted -- player is invalid");
|
|
return false;
|
|
}
|
|
|
|
if (hasScript(player, "systems.fs_quest.fs_quest_player"))
|
|
return false;
|
|
else
|
|
attachScript(player, "systems.fs_quest.fs_quest_player");
|
|
|
|
fs_dyn_village.getRegisteredIntegerFromClusterWideData(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID, "msgSetQuestPhaseId", player);
|
|
CustomerServiceLog("fs_quests", "%TU has accepted an FS quest.", player, null);
|
|
|
|
sendSystemMessage(player, new string_id("quest/force_sensitive/utils", "quest_accepted"));
|
|
|
|
return true;
|
|
}
|
|
|
|
// Marks the player as having completed a quest for the current phase.
|
|
boolean setQuestCompleted(obj_id player, string questName)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.setQuestCompleted-- player is invalid");
|
|
return false;
|
|
}
|
|
|
|
if (!hasScript(player, "systems.fs_quest.fs_quest_player"))
|
|
attachScript(player, "systems.fs_quest.fs_quest_player");
|
|
|
|
int phase = 0;
|
|
if(!hasObjVar(player, VAR_QUEST_ACCEPTED))
|
|
{
|
|
setQuestAccepted(player);
|
|
}
|
|
else
|
|
{
|
|
phase = getIntObjVar(player, VAR_QUEST_ACCEPTED);
|
|
}
|
|
|
|
CustomerServiceLog("fs_quests", "Marking %TU as having completed a quest (" + questName + ") for phase " + phase + ".", player, null);
|
|
setObjVar(player, VAR_QUEST_COMPLETED, questName);
|
|
|
|
return true;
|
|
}
|
|
|
|
// Checks to see if the player has completed a quest for the current phase
|
|
boolean hasQuestCompleted(obj_id player)
|
|
{
|
|
if(!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.hasQuestCompleted -- player is invalid");
|
|
return false;
|
|
}
|
|
|
|
return hasObjVar(player, VAR_QUEST_COMPLETED);
|
|
}
|
|
|
|
// Checks to see if the player has accepted a quest for the current phase
|
|
boolean hasQuestAccepted(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.hasQuestAccepted -- player is invalid");
|
|
return false;
|
|
}
|
|
|
|
return hasObjVar(player, fs_quests.VAR_QUEST_ACCEPTED);
|
|
}
|
|
|
|
// Checks to see if the player is eligible to convert old Jedi advancement into unlocked skill branches.
|
|
boolean hasFreeUnlockBranches(obj_id player)
|
|
{
|
|
// A player with a Jedi slot isn't eligible for a jumpstart on his second character.
|
|
if (hasJediSlot(player))
|
|
return false;
|
|
|
|
int free_unlock = getFreeUnlockBranches(player);
|
|
if (free_unlock > 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
|
|
// Returns the number of free branch unlocks that the player has remaining.
|
|
int getFreeUnlockBranches(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.getFreeUnlockBranches -- player is invalid");
|
|
return -1;
|
|
}
|
|
|
|
int skills_remaining = 0;
|
|
if (hasObjVar(player, pclib.OBJVAR_JEDI_SKILL_REQUIREMENTS))
|
|
skills_remaining = getStringArrayObjVar(player, pclib.OBJVAR_JEDI_SKILL_REQUIREMENTS).length;
|
|
else if (!hasObjVar(player, "jedi.postponeGrant"))
|
|
skills_remaining = 8;
|
|
|
|
int max_free_unlock = 0;
|
|
switch (skills_remaining)
|
|
{
|
|
case 0:
|
|
max_free_unlock = 6;
|
|
break;
|
|
case 1:
|
|
max_free_unlock = 5;
|
|
break;
|
|
case 2:
|
|
max_free_unlock = 4;
|
|
break;
|
|
case 3:
|
|
max_free_unlock = 3;
|
|
break;
|
|
case 4:
|
|
max_free_unlock = 2;
|
|
break;
|
|
case 5:
|
|
max_free_unlock = 1;
|
|
break;
|
|
}
|
|
|
|
int unlock_used = 0;
|
|
if (hasObjVar(player, VAR_FREE_UNLOCK_USED))
|
|
unlock_used = getIntObjVar(player, VAR_FREE_UNLOCK_USED);
|
|
|
|
int unlock_remaining = max_free_unlock - unlock_used;
|
|
|
|
CustomerServiceLog("fs_quests", "%TU has " + unlock_remaining + " unlocked free unlocks remaining.", player, null);
|
|
|
|
return unlock_remaining;
|
|
}
|
|
|
|
boolean showBranchUnlockSUI(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.showBranchUnlockSUI -- player is invalid");
|
|
return false;
|
|
}
|
|
|
|
int free_branches = getFreeUnlockBranches(player);
|
|
if (free_branches < 1)
|
|
{
|
|
sendSystemMessage(player, new string_id("quests/force_sensitive/utils", "no_free_branches"));
|
|
return false;
|
|
}
|
|
|
|
int branches_unlocked = 0;
|
|
if (hasObjVar(player, VAR_BRANCHES_UNLOCKED))
|
|
branches_unlocked = getIntObjVar(player, VAR_BRANCHES_UNLOCKED);
|
|
|
|
resizeable string[] branches_available = new string[0];
|
|
resizeable string[] dsrc = new string[0];
|
|
for (int i = 0; i < 16; i++)
|
|
{
|
|
if (!hasUnlockedBranch(player, i))
|
|
{
|
|
string branch = getBranchFromId(i);
|
|
if (branch != null)
|
|
{
|
|
branches_available.add(branch);
|
|
dsrc.add("@quest/force_sensitive/utils:" + branch);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (branches_available.size() > 0)
|
|
{
|
|
string prompt = "Select the branch that you wish to unlock.\n Free branch unlocks remaining: " + free_branches;
|
|
int pid = sui.listbox(player, player, prompt, sui.OK_CANCEL, "@quest/force_sensitive/utils:branch_select_title", dsrc, "msgBranchSelected");
|
|
utils.setScriptVar(player, SCRIPT_VAR_BRANCH_SELECT_SUI, pid);
|
|
utils.setScriptVar(player, SCRIPT_VAR_BRANCH_SELECT_LIST, branches_available);
|
|
|
|
if (!hasScript(player, "quest.force_sensitive.fs_xp_convert"))
|
|
attachScript(player, "quest.force_sensitive.fs_xp_convert");
|
|
}
|
|
else
|
|
sendSystemMessage(player, new string_id("quests/force_sensitive/utils", "no_available_branches"));
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean isValidLocationForEncounter(location loc)
|
|
{
|
|
string area = toLower(loc.area);
|
|
if(area.equals("dathomir") || area.startsWith("kashyyyk") || area.startsWith("space_"))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
boolean canBeginEncounter(obj_id player)
|
|
{
|
|
location here = getLocation(player);
|
|
|
|
if(!isValidLocationForEncounter(here))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (locations.isInCity(here))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Cannot be inside a building
|
|
obj_id building = getTopMostContainer(player);
|
|
if (building != player )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Cannot be mounted or in a vehical
|
|
if ( isIdValid (getMountId(player)))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void advanceStage(obj_id player)
|
|
{
|
|
int stage = getIntObjVar(player, "fs_kickoff_stage");
|
|
int nextStage = stage + 1;
|
|
setObjVar(player, "fs_kickoff_stage", nextStage);
|
|
return;
|
|
}
|
|
|
|
void decreaseStage(obj_id player)
|
|
{
|
|
int stage = getIntObjVar(player, "fs_kickoff_stage");
|
|
int nextStage = stage - 1;
|
|
setObjVar(player, "fs_kickoff_stage", nextStage);
|
|
return;
|
|
}
|
|
|
|
void setStage(obj_id player, int stage)
|
|
{
|
|
setObjVar(player, "fs_kickoff_stage", stage);
|
|
return;
|
|
}
|
|
|
|
void oldManDepart(obj_id player, obj_id npc, int flag)
|
|
{
|
|
if ( (isIdValid(player)) && (exists(player)) )
|
|
|
|
if ( (isIdValid(npc)) && (exists(npc)) )
|
|
{
|
|
ai_lib.aiStopFollowing(npc);
|
|
}
|
|
|
|
if ( (isIdValid(player)) && (exists(player)) )
|
|
{
|
|
if ( (isIdValid(npc)) && (exists(npc)) )
|
|
{
|
|
ai_lib.pathAwayFrom(npc, player);
|
|
}
|
|
}
|
|
|
|
int dataRow = 0;
|
|
|
|
if (flag == 0)
|
|
{
|
|
messageTo( npc, "cleanUp", null, 8, false );
|
|
return;
|
|
}
|
|
|
|
if (flag == 1)
|
|
{
|
|
quests.deactivate("old_man_initial", player);
|
|
dataRow = quests.getQuestId("old_man_initial");
|
|
|
|
}
|
|
|
|
if (flag == 2)
|
|
{
|
|
quests.deactivate("old_man_exit", player);
|
|
dataRow = quests.getQuestId("old_man_exit");
|
|
|
|
}
|
|
|
|
clearCompletedQuest(player, dataRow);
|
|
messageTo( npc, "cleanUp", null, 8, false );
|
|
return;
|
|
}
|
|
|
|
// Removes all FS data from the player. -- CS Tool
|
|
boolean clearFSData(obj_id player)
|
|
{
|
|
if (!isIdValid(player))
|
|
return false;
|
|
|
|
String datatable = "datatables/player/quests.iff";
|
|
int numRows = dataTableGetNumRows(datatable);
|
|
int iter = 0;
|
|
for(iter = 0; iter < numRows; ++iter)
|
|
{
|
|
clearCompletedQuest(player, iter);
|
|
if (isQuestActive(player, iter))
|
|
{
|
|
string questName = quests.getDataEntry(iter, "NAME");
|
|
//deactivateQuest(player, iter);
|
|
quests.deactivate(questName, player);
|
|
}
|
|
}
|
|
if (hasObjVar(player, "fs_quest"))
|
|
removeObjVar(player, "fs_quest");
|
|
|
|
if (hasObjVar(player, "fs_kickoff_stage"))
|
|
removeObjVar(player, "fs_kickoff_stage");
|
|
|
|
if (hasObjVar(player, "conversation"))
|
|
removeObjVar(player, "conversation");
|
|
|
|
if (hasObjVar(player, "quest"))
|
|
removeObjVar(player, "quest");
|
|
|
|
if (hasScript(player, "systems.fs_quest.fs_quest_player"))
|
|
detachScript(player, "systems.fs_quest.fs_quest_player");
|
|
|
|
if (hasScript(player, "quest.force_sensitive.fs_kickoff"))
|
|
detachScript(player, "quest.force_sensitive.fs_kickoff");
|
|
|
|
if (hasTheaterAssigned(player))
|
|
unassignTheaterFromPlayer(player);
|
|
|
|
setJediState(player, JEDI_STATE_NONE);
|
|
|
|
return true;
|
|
}
|
|
|
|
// Resets the data for a given task. -- CS Tool
|
|
boolean resetFSTask(obj_id player, obj_id owner)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.resetFSTask -- player is invalid");
|
|
return false;
|
|
}
|
|
if (!isIdValid(owner))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.resetFSTask -- owner is invalid");
|
|
return false;
|
|
}
|
|
|
|
string datatable = "datatables/player/quests.iff";
|
|
int rows = dataTableGetNumRows(datatable);
|
|
resizeable string[] dsrc = new string[0];
|
|
resizeable int[] tasks = new int[0];
|
|
for (int i = 0; i < rows; i++)
|
|
{
|
|
string quest_name = quests.getDataEntry(i, "NAME");
|
|
if (isQuestActive(player, i))
|
|
{
|
|
dsrc.add(quest_name + " *");
|
|
tasks.add(new Integer(i));
|
|
}
|
|
else if (isQuestComplete(player, i))
|
|
{
|
|
dsrc.add(quest_name);
|
|
tasks.add(new Integer(i));
|
|
}
|
|
}
|
|
|
|
if (dsrc.length > 0)
|
|
{
|
|
if (utils.hasScriptVar(owner, SCRIPT_VAR_REMOVE_TASK_SUI))
|
|
forceCloseSUIPage(utils.getIntScriptVar(owner, SCRIPT_VAR_REMOVE_TASK_SUI));
|
|
|
|
string prompt = "Select the task you wish to reset. * denotes an active task.";
|
|
int pid = sui.listbox(owner, owner, prompt, sui.OK_CANCEL, "Reset FS Task", dsrc, "msgResetFSTask", true, false);
|
|
utils.setScriptVar(owner, SCRIPT_VAR_REMOVE_TASK_SUI, pid);
|
|
utils.setScriptVar(owner, SCRIPT_VAR_REMOVE_TASK_PLAYER, player);
|
|
utils.setBatchScriptVar(owner, SCRIPT_VAR_REMOVE_TASK_LIST, tasks);
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
|
|
}
|
|
|
|
// Unlocks branches for a player -- CS Tool
|
|
boolean unlockBranchSUI(obj_id player, obj_id owner)
|
|
{
|
|
if (!isIdValid(player))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.unlockBranchSUI -- player is invalid");
|
|
return false;
|
|
}
|
|
if (!isIdValid(owner))
|
|
{
|
|
LOG("force_sensitive", "fs_quests.unlockBranchSUI -- owner is invalid");
|
|
return false;
|
|
}
|
|
|
|
string[] branches = {"force_sensitive_combat_prowess_ranged_accuracy",
|
|
"force_sensitive_combat_prowess_ranged_speed",
|
|
"force_sensitive_combat_prowess_melee_accuracy",
|
|
"force_sensitive_combat_prowess_melee_speed",
|
|
"force_sensitive_enhanced_reflexes_ranged_defense",
|
|
"force_sensitive_enhanced_reflexes_melee_defense",
|
|
"force_sensitive_enhanced_reflexes_vehicle_control",
|
|
"force_sensitive_enhanced_reflexes_survival",
|
|
"force_sensitive_crafting_mastery_experimentation",
|
|
"force_sensitive_crafting_mastery_assembly",
|
|
"force_sensitive_crafting_mastery_repair",
|
|
"force_sensitive_crafting_mastery_technique",
|
|
"force_sensitive_heightened_senses_healing",
|
|
"force_sensitive_heightened_senses_surveying",
|
|
"force_sensitive_heightened_senses_persuasion",
|
|
"force_sensitive_heightened_senses_luck"
|
|
};
|
|
|
|
string[] dsrc = new string[branches.length];
|
|
for (int i = 0; i < branches.length; i++)
|
|
{
|
|
dsrc[i] = localize(new string_id("quest/force_sensitive/utils", branches[i]));
|
|
if (hasUnlockedBranch(player, i))
|
|
{
|
|
if (dsrc[i] != null)
|
|
dsrc[i] += " *";
|
|
}
|
|
}
|
|
|
|
string prompt = "Select the branch you wish to unlock. * denotes that the target already has the branch.";
|
|
int pid = sui.listbox(owner, owner, prompt, sui.OK_CANCEL, "Branch Unlock", dsrc, "msgCSUnlockBranch");
|
|
utils.setScriptVar(owner, SCRIPT_VAR_UNLOCK_BRANCH_SUI, pid);
|
|
utils.setScriptVar(owner, SCRIPT_VAR_UNLOCK_BRANCH_PLAYER, player);
|
|
|
|
return true;
|
|
}
|