Files
dsrc/sku.0/sys.server/compiled/game/script/faction_perk/hq/terminal.script
T

1377 lines
45 KiB
Plaintext

/***** INCLUDES ********************************************************/
include java.util.Calendar;
include library.hq;
include library.sui;
include library.utils;
include library.prose;
include library.money;
include library.factions;
include library.player_structure;
include library.stealth;
/***** INHERITS ********************************************************/
inherits terminal.base.base_terminal;
/***** CONSTANTS *******************************************************/
const string_id MNU_DONATE = new string_id("hq", "mnu_donate");
const string_id MNU_DONATE_MONEY = new string_id("hq", "mnu_donate_money");
const string_id MNU_DONATE_RESOURCE = new string_id("hq", "mnu_donate_resource");
const string_id MNU_DONATE_DEED = new string_id("hq", "mnu_donate_deed");
const string_id UNDER_ATTACK = new string_id("hq", "under_attack");
const string_id MNU_OVERLOAD = new string_id("hq", "mnu_overload");
const string_id MNU_OVERLOAD_GOD = new string_id("hq", "mnu_overload_god_intentional_code_string");
const string_id MNU_SHUTDOWN = new string_id("hq", "mnu_shutdown");
const string_id MNU_DEFENSE_STATUS = new string_id("hq", "mnu_defense_status");
const string_id MNU_RESET_VULNERABILITY = new string_id("hq", "mnu_reset_vulnerability");
const string[] ACCEPTED_DEED_TYPES =
{
"turret",
"mine",
};
const string SCRIPTVAR_COUNTDOWN = "countdownInProgress";
const string_id SID_TERMINAL_MANAGEMENT = new string_id("player_structure", "management");
const string_id SID_TERMINAL_MANAGEMENT_STATUS = new string_id("player_structure", "management_status");
const string_id SID_TERMINAL_MANAGEMENT_PAY = new string_id("player_structure", "management_pay");
const string_id SID_TERMINAL_MANAGEMENT_DESTROY = new string_id("player_structure", "permission_destroy");
const string_id SID_VULNERABILITY_RESET = new string_id("hq", "vulnerability_reset");
const string_id SID_VULNERABILITY_RESET_BLACKOUT_PERIOD = new string_id("hq", "vulnerability_reset_blackout_period");
const string_id SID_VULNERABILITY_RESET_WRONG_CELL = new string_id("hq", "vulnerability_reset_wrong_cell");
const string_id SID_VULNERABILITY_RESET_NO_LONGER_IN_STRUCTURE = new string_id("hq", "vulnerability_reset_no_longer_in_structure");
const string_id SID_VULNERABILITY_RESET_REQUEST_RECEIVED = new string_id("hq", "vulnerability_reset_request_received");
const string_id SID_VULNERABILITY_RESET_NOT_ALIVE = new string_id("hq", "vulnerability_reset_not_alive");
const string STRING_FILE_LOC = "faction/faction_hq/faction_hq_response";
const string_id SID_NO_STEALTH = new string_id("hq", "no_stealth");
/***** TRIGGERS ********************************************************/
trigger OnInitialize()
{
if ( hasScript(self, hq.SCRIPT_TERMINAL_DISABLE) )
detachScript(self, hq.SCRIPT_TERMINAL_DISABLE);
return super.OnInitialize(self);
}
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return super.OnObjectMenuRequest(self, player, mi);
}
if(isGod(player) && getGodLevel(player) >= 15)
{
mi.addRootMenu(menu_info_types.SERVER_MENU12, MNU_OVERLOAD_GOD);
}
int intState = getState(player, STATE_FEIGN_DEATH);
if (isDead(player) || isIncapacitated(player) || intState > 0)
return super.OnObjectMenuRequest(self, player, mi);
obj_id structure = player_structure.getStructure(player);
if ( !isIdValid(structure) )
return super.OnObjectMenuRequest(self, player, mi);
string buildingTemplate = getTemplateName(structure);
//LOG("hq", "faction_perk.hq.terminal:OnObjectMenuRequest: ********* got template of structure. It came in as: "+buildingTemplate);
if ( pvpGetAlignedFaction(player) != pvpGetAlignedFaction(structure) )
{
if ( pvpGetType(player) == PVPTYPE_NEUTRAL )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response01")); // Only declared factional personnel may access this terminal!
return super.OnObjectMenuRequest(self, player, mi);
}
if ( hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) )
{
obj_id[] objectives = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_ID);
if ( objectives == null || objectives.length == 0 )
return super.OnObjectMenuRequest(self, player, mi);
obj_id[] disabled = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_DISABLED);
if ( disabled == null || disabled.length != objectives.length )
{
prose_package ppDisableOther = prose.getPackage(hq.PROSE_DISABLE_OTHER, objectives[objectives.length - 1], self);
sendSystemMessageProse(player, ppDisableOther);
return super.OnObjectMenuRequest(self, player, mi);
}
int mnuCountdown = mi.addRootMenu(menu_info_types.ITEM_USE, MNU_OVERLOAD);
}
return super.OnObjectMenuRequest(self, player, mi);
}
int management_root = mi.addRootMenu (menu_info_types.ITEM_USE, SID_TERMINAL_MANAGEMENT);
if ( management_root > -1 )
{
mi.addSubMenu(management_root, menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS, SID_TERMINAL_MANAGEMENT_STATUS);
if ( player_structure.isAdmin(structure, player) )
{
if ( !player_structure.isFactionPerkBase(buildingTemplate))
mi.addSubMenu(management_root, menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY, SID_TERMINAL_MANAGEMENT_PAY);
if ( hasObjVar(structure,"isPvpBase" ))
{
int stamp = getIntObjVar(structure, "lastReset");
int now = getGameTime();
if ( now > stamp + 1209600 || !hasObjVar(structure, "lastReset"))
mi.addSubMenu(management_root, menu_info_types.SERVER_MENU6, MNU_RESET_VULNERABILITY);
}
mi.addSubMenu(management_root, menu_info_types.SERVER_MENU5, MNU_DEFENSE_STATUS);
mi.addSubMenu(management_root, menu_info_types.SERVER_TERMINAL_MANAGEMENT_DESTROY, SID_TERMINAL_MANAGEMENT_DESTROY);
}
}
int mnuDonate = -1;
if(!player_structure.isFactionPerkBase(buildingTemplate))
{
mnuDonate = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_DONATE);
int mnuDonateMoney = mi.addSubMenu(mnuDonate, menu_info_types.SERVER_MENU2, MNU_DONATE_MONEY);
}
if(hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) || isGod(player))
{
if(mnuDonate <= -1)
{
mnuDonate = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_DONATE);
}
int mnuDonateDeed = mi.addSubMenu(mnuDonate, menu_info_types.SERVER_MENU4, MNU_DONATE_DEED);
}
if ( utils.hasScriptVar(self, SCRIPTVAR_COUNTDOWN) && pvpGetType(player) != PVPTYPE_NEUTRAL)
{
if ( hasObjVar(structure,"isPvpBase" ))
{
int mnuShutdown = mi.addRootMenu(menu_info_types.SERVER_MENU9, MNU_SHUTDOWN);
}
}
return super.OnObjectMenuRequest(self, player, mi);
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
if(isGod(player) && item == menu_info_types.SERVER_MENU12 && getGodLevel(player) >= 15)
{
startCountdown(self, player);
}
int intState = getState(player, STATE_FEIGN_DEATH);
if (isDead(player) || isIncapacitated(player) || intState > 0)
return SCRIPT_CONTINUE;
obj_id structure = player_structure.getStructure(player);
if (!isIdValid(structure) )
return SCRIPT_CONTINUE;
string buildingTemplate = getTemplateName(structure);
if ( pvpGetAlignedFaction(player) != pvpGetAlignedFaction(structure) )
{
if ( pvpGetType(player) == PVPTYPE_NEUTRAL)
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response01")); // Only declared factional personnel may access this terminal!
return SCRIPT_CONTINUE;
}
if ( item == menu_info_types.ITEM_USE )
{
if ( hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) )
{
if ( utils.hasScriptVar(self, SCRIPTVAR_COUNTDOWN) )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response02")); // A countdown is already in progress...
return SCRIPT_CONTINUE;
}
obj_id[] objectives = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_ID);
if ( objectives == null || objectives.length == 0 )
return SCRIPT_CONTINUE;
obj_id[] disabled = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_DISABLED);
if ( disabled == null || disabled.length != objectives.length )
{
prose_package ppDisableOther = prose.getPackage(hq.PROSE_DISABLE_OTHER, objectives[objectives.length - 1], self);
sendSystemMessageProse(player, ppDisableOther);
return SCRIPT_CONTINUE;
}
if ( !hasSkill(player, "class_officer_phase1_novice") )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response03")); // Only an experienced squad leader could expect to coordinate a reactor overload!
return SCRIPT_CONTINUE;
}
startCountdown(self, player);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_OVERRIDE;
}
//basic player structure functionality
if ((item == menu_info_types.SERVER_TERMINAL_MANAGEMENT)||(item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_STATUS)||
(item == menu_info_types.ITEM_USE))
{
queueCommand(player, ##"structureStatus", null, "", COMMAND_PRIORITY_DEFAULT);
}
else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_PAY)
{
if ( !player_structure.isFactionPerkBase(buildingTemplate))
queueCommand(player, ##"payMaintenance", null, "", COMMAND_PRIORITY_DEFAULT);
}
else if (item == menu_info_types.SERVER_TERMINAL_MANAGEMENT_DESTROY)
{
queueCommand(player, ##"destroyStructure", null, "", COMMAND_PRIORITY_DEFAULT);
}
//default menu functionality
if ( item == menu_info_types.ITEM_USE ) //generic use
{
//open holocron page!
return SCRIPT_CONTINUE;
}
//hq specific functionality
if ( item == menu_info_types.SERVER_MENU1 ) //donate - generic
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response04")); // You must first select a sub-menu of 'Donate' to proceed.
return SCRIPT_CONTINUE;
}
else if ( item == menu_info_types.SERVER_MENU2 ) //donate money
{
if ( !player_structure.isFactionPerkBase(buildingTemplate))
{
int total = getTotalMoney(player);
if ( total < 1 )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response05")); // You do not possess any credits to donate.
return SCRIPT_CONTINUE;
}
else
{
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response18")); // Donate money
string prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response17")); // How much of your total money would you like to donate to this facility?
sui.transfer(self, player, prompt, title, "@faction/faction_hq/faction_hq_response:terminal_response30", total, "@faction/faction_hq/faction_hq_response:terminal_response31", 0, "handleRequestDonation");
}
}
}
else if ( item == menu_info_types.SERVER_MENU4 ) //donate deed
{
if (hasObjVar(structure, "donateTerminalOff"))
{
int terminalOff_time = utils.getIntObjVar(structure, "donateTerminalOff");
int termOff_remaining = 3600 - (getGameTime() - terminalOff_time);
string timeOff_remaining = player_structure.assembleTimeRemaining(player_structure.convertSecondsTime(termOff_remaining));
//sendSystemMessage(player, UNDER_ATTACK + timeOff_remaining, null);
prose_package ppTimeRemaining = prose.getPackage(UNDER_ATTACK, timeOff_remaining);
sendSystemMessageProse(player, ppTimeRemaining);
return SCRIPT_CONTINUE;
}
else
{
if(hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) || isGod(player))
{
if(isGod(player))
sendSystemMessage(player, "Warning: You are using donation function while in Godmode.", null);
showDeedDonationUI(self, player);
}
}
}
else if ( item == menu_info_types.SERVER_MENU5 ) //show defense status
{
if ( player_structure.isAdmin(structure, player) )
showDefenseStatusUI(self, player);
}
else if ( item == menu_info_types.SERVER_MENU6 ) //reset vulnerability!
{
if ( player_structure.isAdmin(structure, player) )
{
if ( hasObjVar(structure,"isPvpBase" ))
{
int hqBlackoutPeriodStart = utils.getIntConfigSetting("ScriptFlags", "hqBlackoutPeriodStart");
if ( hqBlackoutPeriodStart == 0 )
hqBlackoutPeriodStart = 2;
int hqBlackoutPeriodEnd = utils.getIntConfigSetting("ScriptFlags", "hqBlackoutPeriodEnd");
if ( hqBlackoutPeriodEnd == 0 )
hqBlackoutPeriodEnd = 6;
Calendar currentCalendar = Calendar.getInstance();
int currentHourOfDay = currentCalendar.get(Calendar.HOUR_OF_DAY);
if ( (currentHourOfDay >= hqBlackoutPeriodStart) && (currentHourOfDay <= hqBlackoutPeriodEnd) )
{
prose_package pp1a = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response32"), hqBlackoutPeriodStart);
prose_package pp2a = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response37"), hqBlackoutPeriodEnd);
string oob1 = packOutOfBandProsePackage(null, pp1a);
oob1 = packOutOfBandProsePackage(oob1, pp2a);
sendSystemMessageOob(player, oob1);
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response38"), currentHourOfDay));
//sendSystemMessage(player, SID_VULNERABILITY_RESET_BLACKOUT_PERIOD);
}
else
{
long now = System.currentTimeMillis();
long curTime = ((now / 1000) - 1072224000);
int currentTime = (int) curTime;
setObjVar(structure, hq.VAR_OBJECTIVE_STAMP, currentTime);
setObjVar(structure, "lastReset", getGameTime());
sendSystemMessage(player, SID_VULNERABILITY_RESET);
}
}
}
}
else if ( item == menu_info_types.SERVER_MENU9 ) //shutdown facility
{
if ( hasObjVar(structure,"isPvpBase" ))
{
if (pvpGetType(player) != PVPTYPE_NEUTRAL)
{
if (factions.isNewlyDeclared(player))
{
int declared_time = utils.getIntScriptVar(player, factions.VAR_NEWLY_DECLARED);
int time_remaining = factions.NEWLY_DECLARED_INTERVAL - (getGameTime() - declared_time);
LOG("LOG_CHANNEL", "declared_time ->" + declared_time + " time_remaining ->" + time_remaining);
if (time_remaining > 0)
{
string time_str = player_structure.assembleTimeRemaining(player_structure.convertSecondsTime(time_remaining));
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response41"), time_str));
}
else
{
utils.removeScriptVar(player, factions.VAR_NEWLY_DECLARED);
facilityShutdownDelay(self, player);
}
}
else
{
// Added new timer for delay before triggering a shutdown, per ELI solution to TT# 39933
facilityShutdownDelay(self, player);
//shutdownFacility(self);
}
}
else
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response06")); // You cannot do that while covert.
}
}
return SCRIPT_CONTINUE;
}
void shutdownFacility(obj_id self)
{
attachScript(self, hq.SCRIPT_TERMINAL_DISABLE);
obj_id structure = player_structure.getStructure(self);
if ( isIdValid(structure) )
{
hq.disableHqTerminals(structure);
}
abortCountdown(self);
hq.activateHackAlarms(structure, false);
messageTo(self, "handleFacilityReboot", null, 30f, false);
}
void startCountdown(obj_id self, obj_id player)
{
//start countdown
int meleemod = getSkillStatMod(player, "group_melee_defense");
int rangemod = getSkillStatMod(player, "group_range_defense");
float mod = (100f - (float)(meleemod + rangemod))/100f;
if ( mod < 0f )
mod = 0f;
float delay = 300f + 300f * mod;
int minutes = Math.round(delay/60f);
if(isGod(player) && getGodLevel(player) >= 15)
delay = 60;
obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(self));
if ( players != null && players.length > 0 )
{
for ( int i = 0; i < players.length; i++ )
sendSystemMessageProse(players[i], prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response40"), minutes));
}
int stamp = getGameTime() + Math.round(delay);
utils.setScriptVar(self, SCRIPTVAR_COUNTDOWN, stamp);
dictionary d = new dictionary();
d.put("player", player);
d.put("cnt", minutes);
messageTo(self, "handleCountdown", d, 10f, false);
}
void abortCountdown(obj_id self)
{
obj_id structure = getTopMostContainer(self);
hq.activateDestructAlarms(structure, false);
utils.removeScriptVar(self, SCRIPTVAR_COUNTDOWN);
obj_id[] players = player_structure.getPlayersInBuilding(structure);
if ( players != null && players.length > 0 )
{
for ( int i = 0; i < players.length; i++ )
sendSystemMessage(players[i], new string_id(STRING_FILE_LOC, "terminal_response07")); // COUNTDOWN ABORTED: FACILITY SHUTTING DOWN!!
}
}
/***** MESSAGEHANDLERS *************************************************/
messageHandler handleFacilityReboot()
{
detachScript(self, hq.SCRIPT_TERMINAL_DISABLE);
obj_id structure = player_structure.getStructure(self);
if ( isIdValid(structure) )
{
hq.enableHqTerminals(structure);
}
obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(self));
if ( players != null && players.length > 0 )
{
for ( int i = 0; i < players.length; i++ )
sendSystemMessage(players[i], new string_id(STRING_FILE_LOC, "terminal_response08")); // FACILITY RESTART: RELOADING PRIMARY FACILITY SYSTEMS");
}
return SCRIPT_CONTINUE;
}
messageHandler handleCountdown()
{
if ( !utils.hasScriptVar(self, SCRIPTVAR_COUNTDOWN) )
return SCRIPT_CONTINUE;
obj_id player = params.getObjId("player");
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
if ( !isIdValid(player) )
{
abortCountdown(self);
return SCRIPT_CONTINUE;
}
int cnt = params.getInt("cnt");
int stamp = utils.getIntScriptVar(self, SCRIPTVAR_COUNTDOWN);
LOG("hqObjective","stamp = " + stamp);
int now = getGameTime();
LOG("hqObjective","now = " + now);
int timeLeft = stamp - now;
int minutes = Math.round(timeLeft/60f);
obj_id structure = player_structure.getStructure(self);
if ( !isIdValid(structure) )
{
abortCountdown(self);
return SCRIPT_CONTINUE;
}
LOG("hqObjective","timeLeft = " + timeLeft);
if ( timeLeft < 1 ) //time to detonate!
{
utils.setScriptVar(structure, "faction_hq.detonator", player);
hq.detonateHq(structure);
string hqName = getName(structure);
CustomerServiceLog("faction_hq", "Initiating destroy for Faction HQ " + hqName + " (" + structure + "), by normal terminal overload.");
return SCRIPT_CONTINUE;
}
prose_package msg = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response39"), minutes);
if ( minutes < 1 )
{
msg = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response39"), timeLeft);
}
else if ( minutes < cnt )
{
obj_id[] players = player_structure.getPlayersInBuilding(structure);
if ( players != null && players.length > 0 )
{
for ( int i = 0; i < players.length; i++ )
sendSystemMessageProse(players[i], msg);
}
params.put("cnt", minutes);
}
hq.activateDestructAlarms(structure, true);
messageTo(self, "handleCountdown", params, 10f, false);
return SCRIPT_CONTINUE;
}
messageHandler handleDonateDeed()
{
obj_id player = sui.getPlayerId(params);
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
string scriptvar_sui = player + ".deed.sui";
string scriptvar_opt = player + ".deed.opt";
obj_id[] deeds = utils.getObjIdBatchScriptVar(self, scriptvar_opt);
utils.removeScriptVar(self, scriptvar_sui);
utils.removeBatchScriptVar(self, scriptvar_opt);
if ( deeds == null || deeds.length == 0 )
return SCRIPT_CONTINUE;
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
int idx = sui.getListboxSelectedRow(params);
if ( idx == -1 || idx > deeds.length-1 )
return SCRIPT_CONTINUE;
obj_id deed = deeds[idx];
if ( !isIdValid(deed) )
return SCRIPT_CONTINUE;
if ( !utils.isNestedWithin(deed, player) )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response09")); // The selected deed is no longer in your inventory. Cancelling donation...
return SCRIPT_CONTINUE;
}
string deedType = getStringObjVar(deed, "perkDeedType");
if ( deedType != null && !deedType.equals("") )
{
if ( utils.getElementPositionInArray(ACCEPTED_DEED_TYPES, deedType) == -1 )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response10")); // This facility only accepts selected deed types. Cancelling donation...
return SCRIPT_CONTINUE;
}
else
{
// We do not want to allow turret deeds to be donated to special forces facilities
if(deedType.equals("turret"))
{
obj_id objBuilding = getTopMostContainer(self);
if(isIdValid(objBuilding))
{
if (hasObjVar(objBuilding, "isPvpBase"))
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response_special_forces_no_turrets")); // You can't donate turrets to special forces base
return SCRIPT_CONTINUE;
}
}
else
{
debugServerConsoleMsg(player, "Trying to donate turrets to a Factional HQ terminal without a topmost container");
return SCRIPT_CONTINUE;
}
}
}
}
string displayType = utils.packStringId(new string_id("faction_perk", deedType));
string template = "";
int mineType = -1;
obj_id structure = player_structure.getStructure(player);
if ( !isIdValid(structure) )
return SCRIPT_CONTINUE;
if(deedType.equals("mine"))
{
int numMines = hq.getTotalMines(structure);
if(numMines >= hq.getMaxMines(structure))
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "max_number_mines"));
return SCRIPT_CONTINUE;
}
if(hasObjVar(deed, "mineType"))
mineType = getIntObjVar(deed, "mineType");
}
else
{
obj_id[] defensesOfType = getObjIdArrayObjVar(structure, hq.VAR_DEFENSE_BASE + "." + deedType);
if ( defensesOfType == null || defensesOfType.length == 0 )
{
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response43"), displayType));
return SCRIPT_CONTINUE;
}
int pos = utils.getFirstNonValidIdIndex(defensesOfType);
if ( pos < 0 || pos > defensesOfType.length - 1 )
{
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response44"), displayType));
return SCRIPT_CONTINUE;
}
template = player_structure.getDeedTemplate(deed);
if ( template == null || template.equals("") )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response11")); // The selected deed is improperly formatted. Cancelling donation...
return SCRIPT_CONTINUE;
}
}
string sFacName = factions.getFaction(structure);
if ( sFacName == null || sFacName.equals("") )
{
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response45"), displayType));
CustomerServiceLog("faction_hq", "%TU donates a " + displayType + " deed to Factional HQ " + structure, player, null);
} // BLEH
else
{
prose_package pp1b = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response46"), displayType);
prose_package pp2b = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response47"), sFacName);
string oob2 = packOutOfBandProsePackage(null, pp1b);
oob2 = packOutOfBandProsePackage(oob2, pp2b);
CustomerServiceLog("faction_hq", "%TU donates a " + displayType + " deed to Factional HQ " + structure, player, null);
sendSystemMessageOob(player, oob2);
}
destroyObject(deed);
dictionary d = new dictionary();
d.put("template", template);
d.put("type", deedType);
d.put("mineType", mineType);
messageTo(structure, "handleAddDefense", d, 1, true);
return SCRIPT_CONTINUE;
}
/***** RESOURCE DONATIONS *************************************************/
messageHandler handleDonateResourceType()
{
obj_id player = sui.getPlayerId(params);
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
string scriptvar_sui = player + ".resource.sui";
string scriptvar_opt = player + ".resource.opt";
obj_id[] crates = utils.getObjIdBatchScriptVar(self, scriptvar_opt);
utils.removeScriptVar(self, scriptvar_sui);
utils.removeBatchScriptVar(self, scriptvar_opt);
if ( crates == null || crates.length == 0 )
return SCRIPT_CONTINUE;
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
int idx = sui.getListboxSelectedRow(params);
if ( idx == -1 || idx > crates.length-1 )
return SCRIPT_CONTINUE;
obj_id crate = crates[idx];
if ( !isIdValid(crate) )
return SCRIPT_CONTINUE;
if ( !utils.isNestedWithin(crate, player) )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response12")); // The selected resource container is no longer in your inventory. Cancelling donation...
return SCRIPT_CONTINUE;
}
int amt = getResourceContainerQuantity(crate);
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response20")); // Donate Resource
string prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response19")); // How much of this resource would you like to donate?
int pid = sui.transfer(self, player, prompt, title, "@faction/faction_hq/faction_hq_response:terminal_response36", amt, "@faction/faction_hq/faction_hq_response:terminal_response31", 0, "handleDonateResourceAmt");
if ( pid > -1 )
{
utils.setScriptVar(self, scriptvar_sui, pid);
utils.setScriptVar(self, scriptvar_opt, crate);
}
return SCRIPT_CONTINUE;
}
messageHandler handleDonateResourceAmt()
{
obj_id player = sui.getPlayerId(params);
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
string scriptvar_sui = player + ".resource.sui";
string scriptvar_opt = player + ".resource.opt";
obj_id crate = utils.getObjIdScriptVar(self, scriptvar_opt);
utils.removeScriptVar(self, scriptvar_sui);
utils.removeScriptVar(self, scriptvar_opt);
if ( !isIdValid(crate) )
return SCRIPT_CONTINUE;
if ( !utils.isNestedWithin(crate, player) )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response12")); // The selected resource container is no longer in your inventory. Cancelling donation...
return SCRIPT_CONTINUE;
}
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
int amt = sui.getTransferInputTo(params);
if ( amt == 0 )
return SCRIPT_CONTINUE;
obj_id rtype = getResourceContainerResourceType(crate);
if ( !isIdValid(rtype) )
return SCRIPT_CONTINUE;
string res_name = getResourceName(rtype);
if ( removeResourceFromContainer(crate, rtype, amt) )
{
obj_id structure = player_structure.getStructure(player);
string sFacName = factions.getFaction(structure);
if ( sFacName == null || sFacName.equals("") )
{
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response48"), amt));
CustomerServiceLog("faction_hq", "%TU donates " + amt + " units of " + res_name + " to Factional HQ " + structure, player, null);
}
else
{
prose_package pp1c = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response49"), amt);
prose_package pp2c = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response50"), sFacName);
string oob3 = packOutOfBandProsePackage(null, pp1c);
oob3 = packOutOfBandProsePackage(oob3, pp2c);
CustomerServiceLog("faction_hq", "%TU donates " + amt + " units of " + res_name + " to Factional HQ " + structure, player, null);
sendSystemMessageOob(player, oob3);
}
if ( !isIdValid(structure) )
return SCRIPT_CONTINUE;
int total = getIntObjVar(structure, hq.VAR_HQ_RESOURCE_CNT);
total += amt;
setObjVar(structure, hq.VAR_HQ_RESOURCE_CNT, total);
}
return SCRIPT_CONTINUE;
}
/***** MONEY DONATIONS *************************************************/
messageHandler handleRequestDonation()
{
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
obj_id player = sui.getPlayerId(params);
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
int amt = sui.getTransferInputTo(params);
if ( amt == 0 )
return SCRIPT_CONTINUE;
money.requestPayment(player, self, amt, "handleCreditDonation", null, true);
return SCRIPT_CONTINUE;
}
messageHandler handleCreditDonation()
{
if ( params == null || params.isEmpty() )
return SCRIPT_CONTINUE;
int ret = params.getInt(money.DICT_CODE);
if ( ret == money.RET_FAIL )
return SCRIPT_CONTINUE;
obj_id player = params.getObjId(money.DICT_PLAYER_ID);
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
obj_id structure = player_structure.getStructure(player);
int amt = params.getInt(money.DICT_TOTAL);
string sFacName = factions.getFaction(structure);
if ( sFacName == null || sFacName.equals("") )
{
sendSystemMessageProse(player, prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response51"), amt));
CustomerServiceLog("faction_hq", "%TU donated " + amt + " credits to Faction HQ " + structure, player, null);
}
else
{
prose_package pp1d = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response52"), amt);
prose_package pp2d = prose.getPackage(new string_id (STRING_FILE_LOC, "terminal_response53"), sFacName);
string oob4 = packOutOfBandProsePackage(null, pp1d);
oob4 = packOutOfBandProsePackage(oob4, pp2d);
sendSystemMessageOob(player, oob4);
CustomerServiceLog("faction_hq", "%TU donated " + amt + " credits to Faction HQ " + structure, player, null);
}
if ( isIdValid(structure) )
money.bankTo(self, structure, amt);
return SCRIPT_CONTINUE;
}
/***** DEFENSE STATUS/REMOVAL *************************************************/
messageHandler handleDefenseSelection()
{
obj_id player = sui.getPlayerId(params);
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
string scriptvar_sui = player + ".defense.sui";
string scriptvar_opt = player + ".defense.opt";
obj_id[] opt = utils.getObjIdBatchScriptVar(self, scriptvar_opt);
utils.removeScriptVar(self, scriptvar_sui);
utils.removeBatchScriptVar(self, scriptvar_opt);
if ( opt == null || opt.length == 0 )
return SCRIPT_CONTINUE;
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
int idx = sui.getListboxSelectedRow(params);
if ( idx == -1 || idx > opt.length-1 )
return SCRIPT_CONTINUE;
obj_id defense = opt[idx];
if ( !isIdValid(defense) )
return SCRIPT_CONTINUE;
if ( !exists(defense) || !defense.isLoaded() )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response13")); // The selected defense is not available. Cancelling...
return SCRIPT_CONTINUE;
}
int max_hp = getMaxHitpoints(defense);
int cur_hp = getHitpoints(defense);
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response24")); // Confirm Defense Removal?
string prompt = getString(new string_id(STRING_FILE_LOC, "terminal_response25")); // Are you sure that you want to destroy the selected defense?
prompt += "/n/n" + getString(new string_id(STRING_FILE_LOC, "selected_defense")) + utils.getStringName(defense) + " ["+cur_hp+"/"+max_hp+"]";
if(hasScript(defense, "faction_perk.minefield.advanced_minefield"))
prompt = getString(new string_id(STRING_FILE_LOC, "terminal_response25a")); // Are you sure that you want to clear the minefield?
int pid = sui.msgbox(self, player, prompt, sui.YES_NO, title, "handleDefenseRemoveConfirm");
if ( pid > -1 )
{
utils.setScriptVar(self, scriptvar_sui, pid);
utils.setScriptVar(self, scriptvar_opt, defense);
}
return SCRIPT_CONTINUE;
}
messageHandler handleDefenseRemoveConfirm()
{
obj_id player = sui.getPlayerId(params);
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
string scriptvar_sui = player + ".defense.sui";
string scriptvar_opt = player + ".defense.opt";
obj_id defense = utils.getObjIdScriptVar(self, scriptvar_opt);
utils.removeScriptVar(self, scriptvar_sui);
utils.removeScriptVar(self, scriptvar_opt);
if ( !isIdValid(defense) || !exists(defense) || !defense.isLoaded() )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response13")); // The selected defense is not available. Cancelling...
return SCRIPT_CONTINUE;
}
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response58")); // Processing HQ defense removal...
utils.setScriptVar(defense, "hq.defense.remover", player);
if(hasScript(defense, "faction_perk.minefield.advanced_minefield"))
hq.clearMinefield(player_structure.getStructure(player));
else
destroyObject(defense);
return SCRIPT_CONTINUE;
}
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *************************************************/
void showResourceDonationUI(obj_id terminal, obj_id player)
{
if ( !isIdValid(terminal) || !isIdValid(player) )
return;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return ;
}
string scriptvar_sui = player + ".resource.sui";
string scriptvar_opt = player + ".resource.opt";
if ( utils.hasScriptVar(terminal, scriptvar_sui) )
{
sui.closeSUI(player, utils.getIntScriptVar(terminal, scriptvar_sui));
utils.removeScriptVar(terminal, scriptvar_sui);
utils.removeBatchScriptVar(terminal, scriptvar_opt);
}
obj_id[] crates = utils.getContainedGOTObjects(player, GOT_resource_container, true, true);
if ( crates == null || crates.length == 0 )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response14")); // You do not possess any resource to donate.");
return;
}
resizeable string[] entries = new string[0];
for ( int i = 0; i < crates.length; i++ )
{
obj_id crate = crates[i];
if ( isIdValid(crate) )
{
int inCrate = getResourceContainerQuantity(crate);
string name = getString(getNameStringId(crate));
entries = utils.addElement(entries, name + " [" + inCrate + "]");
}
}
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response20")); // Donate Resource
string prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response29")); // Which resource would you like to donate?
int pid = sui.listbox(terminal, player, prompt, sui.OK_CANCEL, title, entries, "handleDonateResourceType");
if ( pid > -1 )
{
utils.setScriptVar(terminal, scriptvar_sui, pid);
utils.setBatchScriptVar(terminal, scriptvar_opt, crates);
}
}
void showDeedDonationUI(obj_id terminal, obj_id player)
{
if ( !isIdValid(terminal) || !isIdValid(player) )
return;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return ;
}
LOG("hq"," //***// showDeedDonationUI entered... passed in terminal:"+terminal+" and player:"+player); //*************************************************************************************************************************
string scriptvar_sui = player + ".deed.sui";
string scriptvar_opt = player + ".deed.opt";
LOG("hq"," //***// showDeedDonationUI ... string scriptvar_sui ="+scriptvar_sui+" and string scriptvar_opt ="+scriptvar_opt); //*************************************************************************************************************************
if ( utils.hasScriptVar(terminal, scriptvar_sui) )
{
LOG("hq"," //***// showDeedDonationUI ... utils.hasScriptVar(terminal, scriptvar_sui) is AFFIRM"); //*************************************************************************************************************************
sui.closeSUI(player, utils.getIntScriptVar(terminal, scriptvar_sui));
utils.removeScriptVar(terminal, scriptvar_sui);
utils.removeScriptVar(terminal, scriptvar_opt);
}
obj_id[] deeds = utils.getContainedObjectsWithObjVar(player, "perkDeedType", true);
if ( deeds == null || deeds.length == 0 )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response15")); // You do not possess any deeds to donate.");
return;
}
resizeable string[] entries = new string[0];
resizeable obj_id[] opt = new obj_id[0];
for ( int i = 0; i < deeds.length; i++ )
{
LOG("hq"," //***// showDeedDonationUI ... counting through GOT_deed objects in player inventory. Currently on item# "+i); //*************************************************************************************************************************
obj_id deed = deeds[i];
if ( isIdValid(deed) )
{
string deedType = getStringObjVar(deed, "perkDeedType");
if ( deedType != null && !deedType.equals("") )
{
LOG("hq"," //***// showDeedDonationUI ... deed item# "+i+" has 'perkDeedType' objvar of: "+deedType); //*************************************************************************************************************************
if ( utils.getElementPositionInArray(ACCEPTED_DEED_TYPES, deedType) > -1 )
{
opt = utils.addElement(opt, deed);
entries = utils.addElement(entries, getEncodedName(deed));
}
}
}
}
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response26")); // Donate Deed
string prompt = utils.packStringId (new string_id(STRING_FILE_LOC, "terminal_response23")); // Which deed would you like to donate?
//string title = getString(new string_id(STRING_FILE_LOC, "terminal_response26")); // Donate Deed
//string prompt = getString(new string_id(STRING_FILE_LOC, "terminal_response23")); // Which deed would you like to donate?
LOG("hq"," //***// showDeedDonationUI ... title= "+title+" and prompt = "+prompt+" size of 'entries' array is:"+entries.length); //*************************************************************************************************************************
int pid = sui.listbox(terminal, player, prompt, sui.OK_CANCEL, title, entries, "handleDonateDeed");
if ( pid > -1 )
{
utils.setScriptVar(terminal, scriptvar_sui, pid);
utils.setBatchScriptVar(terminal, scriptvar_opt, opt);
}
}
void showDefenseStatusUI(obj_id terminal, obj_id player)
{
if ( !isIdValid(terminal) || !isIdValid(player) )
return;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return ;
}
string scriptvar_sui = player + ".defense.sui";
string scriptvar_opt = player + ".defense.opt";
if ( utils.hasScriptVar(terminal, scriptvar_sui) )
{
sui.closeSUI(player, utils.getIntScriptVar(terminal, scriptvar_sui));
utils.removeScriptVar(terminal, scriptvar_sui);
utils.removeScriptVar(terminal, scriptvar_opt);
}
obj_id structure = player_structure.getStructure(player);
if ( !isIdValid(structure) )
return;
resizeable string[] entries = new string[0];
resizeable obj_id[] opt = new obj_id[0];
obj_var_list ovl = getObjVarList(structure, hq.VAR_DEFENSE_BASE);
if ( ovl == null )
{
sendSystemMessage(player, new string_id(STRING_FILE_LOC, "terminal_response14")); // There are currently no active defenses for this headquarters.");
return;
}
int numTypes = ovl.getNumItems();
for ( int i = 0; i < numTypes; i++ )
{
obj_var ov = ovl.getObjVar(i);
string ovName = ov.getName();
entries = utils.addElement(entries, toUpper(ovName));
opt = utils.addElement(opt, obj_id.NULL_ID);
obj_id[] data = ov.getObjIdArrayData();
if ( data != null && data.length > 0 )
{
int validCount = 0;
for ( int n = 0; n < data.length; n++ )
{
if ( isIdValid(data[n]) )
{
string sName = utils.getStringName(data[n]);
int max_hp = getMaxHitpoints(data[n]);
int cur_hp = getHitpoints(data[n]);
if(hasScript(data[n], "faction_perk.minefield.advanced_minefield"))
entries = utils.addElement(entries, "- " + hq.getTotalMines(structure) + "/" + hq.getMaxMines(structure) + " mines");
else
entries = utils.addElement(entries, "- " + sName + " ["+cur_hp+"/"+max_hp+"]");
opt = utils.addElement(opt, data[n]);
validCount++;
}
}
if ( validCount == 0 )
{
entries = utils.addElement(entries, "- none");
opt = utils.addElement(opt, obj_id.NULL_ID);
}
/*
if ( i < numTypes-1)
{
entries = utils.addElement(entries, " ");
opt = utils.addElement(opt, obj_id.NULL_ID);
}
*/
}
}
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response23")); // HQ Defense Status
string prompt = utils.packStringId (new string_id(STRING_FILE_LOC, "terminal_response22")); // If you would like to remove a defense, select the defense and click 'Remove'.
//string title = getString(new string_id(STRING_FILE_LOC, "terminal_response23")); // HQ Defense Status
//string prompt = getString(new string_id(STRING_FILE_LOC, "terminal_response22")); // If you would like to remove a defense, select the defense and click 'Remove'.
int pid = sui.listbox(terminal, player, prompt, sui.REMOVE_CANCEL, title, entries, "handleDefenseSelection");
if ( pid > -1 )
{
utils.setScriptVar(terminal, scriptvar_sui, pid);
utils.setBatchScriptVar(terminal, scriptvar_opt, opt);
}
}
void facilityShutdownDelay(obj_id terminal, obj_id player)
{
if ( !isIdValid(terminal) || !isIdValid(player))
return;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return ;
}
string currentCell = null;
location locTest = getLocation(player);
if(isIdValid(locTest.cell))
currentCell = getCellName(locTest.cell);
sendSystemMessage(player, SID_VULNERABILITY_RESET_REQUEST_RECEIVED);
//start the delay (60 seconds)
dictionary params = new dictionary();
params.put("player", player);
if ( !currentCell.equals("null") )
params.put("cellName", currentCell);
messageTo(terminal, "handleShutdownCountdownComplete", params, 60f, false);
return;
}
messageHandler handleShutdownCountdownComplete()
{
obj_id player = params.getObjId("player");
string triggeringCell = params.getString("cellName");
if ( !isIdValid(player) || !isIdValid(self))
return SCRIPT_CONTINUE;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
obj_id structure = player_structure.getStructure(self);
if ( !isIdValid(structure) )
return SCRIPT_CONTINUE;
if (hasObjVar(structure, hq.VAR_TERMINAL_DISABLE))
{
boolean structureState = getBooleanObjVar(structure, hq.VAR_TERMINAL_DISABLE);
if (structureState == true)
return SCRIPT_CONTINUE;
}
//if still within the correct cell
string currentCell = null;
location locTest = getLocation(player);
if(isIdValid(locTest.cell))
currentCell = getCellName(locTest.cell);
if ( (!isIdValid(locTest.cell)) || (!currentCell.equals(triggeringCell)) )
{
sendSystemMessage(player, SID_VULNERABILITY_RESET_WRONG_CELL);
return SCRIPT_CONTINUE;
}
//If the person wanting to shutdown the base and save it is dead, disallow that cheatin' person! 2/14/2k+5
if ( isIncapacitated(player) || isDead(player) )
{
sendSystemMessage(player, SID_VULNERABILITY_RESET_NOT_ALIVE);
return SCRIPT_CONTINUE;
}
//TRIGGER y/n question - 'ready to shutdown facility?'
string title = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response27")); // Confirm Facility Shutdown
string prompt = utils.packStringId(new string_id(STRING_FILE_LOC, "terminal_response28")); // Are you sure that you want to shut down the facility?
//************************************ALERT ALERT ALERT ALERT. ARTIFICALLY REVERSING THE PROMPT AND TITLE BECAUSE THEY ARE BACKWARDS IN DISPLAY FOR WHO KNOWS WHAT REASON. THIS IS TOTAL BS.
//************************************ALERT ALERT ALERT ALERT. ARTIFICALLY REVERSING THE PROMPT AND TITLE BECAUSE THEY ARE BACKWARDS IN DISPLAY FOR WHO KNOWS WHAT REASON. THIS IS TOTAL BS.
int pid = sui.msgbox(self, player, title, sui.YES_NO, prompt, "handleShutdownConfirm");
//if ( pid > -1 )
// shutdownFacility(self);
return SCRIPT_CONTINUE;
}
messageHandler handleShutdownConfirm()
{
obj_id player = sui.getPlayerId(params);
if ( !isIdValid(player) )
return SCRIPT_CONTINUE;
if (stealth.hasInvisibleBuff(player))
{
sendSystemMessage(player, SID_NO_STEALTH);
return SCRIPT_CONTINUE;
}
int bp = sui.getIntButtonPressed(params);
if ( bp == sui.BP_CANCEL )
return SCRIPT_CONTINUE;
obj_id structure = player_structure.getStructure(self);
if (hasObjVar(structure, hq.VAR_TERMINAL_DISABLE))
{
boolean structureState = getBooleanObjVar(structure, hq.VAR_TERMINAL_DISABLE);
if (structureState == true)
return SCRIPT_CONTINUE;
}
obj_id currentStructure = player_structure.getStructure(player);
if ( currentStructure != structure )
{
sendSystemMessage(player, SID_VULNERABILITY_RESET_NO_LONGER_IN_STRUCTURE);
return SCRIPT_CONTINUE;
}
//trigger the shutdown
shutdownFacility(self);
return SCRIPT_CONTINUE;
}
messageHandler handleAlarmMute()
{
obj_id structure = player_structure.getStructure(self);
if ( isIdValid(structure) )
hq.activateHackAlarms(structure, false);
return SCRIPT_CONTINUE;
}