mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
273 lines
7.4 KiB
Plaintext
273 lines
7.4 KiB
Plaintext
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include library.hq;
|
|
include library.sui;
|
|
include library.utils;
|
|
include library.prose;
|
|
include library.money;
|
|
include library.factions;
|
|
include library.player_structure;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string_id MNU_OVERLOAD = new string_id("hq", "mnu_overload");
|
|
const string_id MNU_SHUTDOWN = new string_id("hq", "mnu_shutdown");
|
|
const string_id MNU_DONATE = new string_id("hq", "mnu_donate");
|
|
const string SCRIPTVAR_COUNTDOWN = "countdownInProgress";
|
|
trigger OnInitialize()
|
|
{
|
|
setObjVar(self, "type", "terminal");
|
|
setObjVar(self, "intTerminal", 1);
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
obj_id structure = getObjIdObjVar(self, "objParent");
|
|
if ( !isIdValid(structure) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int sFac = pvpGetAlignedFaction(structure);
|
|
int pFac = pvpGetAlignedFaction(player);
|
|
if ( pvpAreFactionsOpposed(sFac, pFac) )
|
|
{
|
|
if ( pvpGetType(player) != PVPTYPE_DECLARED )
|
|
{
|
|
sendSystemMessageTestingOnly(player, "Only declared factional personnel may access this terminal!");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( utils.hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) )
|
|
{
|
|
LOG("gcw", "HASOBJVAR");
|
|
|
|
obj_id[] objectives = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_ID);
|
|
if ( objectives == null || objectives.length == 0 )
|
|
{
|
|
LOG("gcw", "returning continue");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id[] disabled = getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_DISABLED);
|
|
if ( disabled == null || disabled.length != objectives.length )
|
|
{
|
|
LOG("gcw", "Disabled thing");
|
|
prose_package ppDisableOther = prose.getPackage(hq.PROSE_DISABLE_OTHER, objectives[objectives.length - 1], self);
|
|
sendSystemMessageProse(player, ppDisableOther);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int mnuCountdown = mi.addRootMenu(menu_info_types.SERVER_MENU10, MNU_OVERLOAD);
|
|
LOG("gcw", "Added overload");
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
else
|
|
{
|
|
LOG("gcw", "NO OBJVAR");
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(player, "You are not an enemy of this structure. Why would you want to tamper?");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/*
|
|
if ( utils.hasObjVar(structure, hq.VAR_OBJECTIVE_TRACKING) )
|
|
{
|
|
obj_id[] disabled = utils.getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_DISABLED);
|
|
obj_id[] objTerminals = utils.getObjIdArrayObjVar(structure, hq.VAR_OBJECTIVE_TRACKING);
|
|
if(disabled.length==objTerminals.length)
|
|
{
|
|
int mnuShutdown = mi.addRootMenu( menu_info_types.SERVER_MENU9, MNU_SHUTDOWN);
|
|
}
|
|
}*/
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
LOG("gcw", "OnObject menu selected");
|
|
obj_id structure = getObjIdObjVar(self, "objParent");
|
|
if ( !isIdValid(structure) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int sFac = pvpGetAlignedFaction(structure);
|
|
int pFac = pvpGetAlignedFaction(player);
|
|
if ( pvpAreFactionsOpposed(sFac, pFac) )
|
|
{
|
|
if ( pvpGetType(player) != PVPTYPE_DECLARED )
|
|
{
|
|
sendSystemMessageTestingOnly(player, "Only declared factional personnel may access this terminal!");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU10 )
|
|
{
|
|
LOG("gcw", "10");
|
|
if(!hasObjVar(self, "intCompleted"))
|
|
{
|
|
|
|
setObjVar(self, "intCompleted", 1);
|
|
string strText = "Facility has succesfully been taken over.";
|
|
sendSystemMessageTestingOnly(player, strText);
|
|
messageTo(structure, "objectiveCompleted", null, 0, true);
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU1 ) //donate - generic
|
|
{
|
|
LOG("gcw", "1");
|
|
sendSystemMessageTestingOnly(player, "You must first select a sub-menu of 'Donate' to proceed.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU9 ) //shutdown facility
|
|
{
|
|
LOG("gcw", "SHUTDOWN");
|
|
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void shutdownFacility(obj_id self)
|
|
{
|
|
attachScript(self, hq.SCRIPT_TERMINAL_DISABLE);
|
|
|
|
obj_id structure = getObjIdObjVar(self, "objParent");
|
|
if ( isIdValid(structure) )
|
|
{
|
|
hq.disableHqTerminals(structure);
|
|
}
|
|
|
|
abortCountdown(self);
|
|
|
|
messageTo(self, "handleFacilityReboot", null, 300f, 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 delay = 300f + 300f * (100f - (meleemod + rangemod))/100f;
|
|
|
|
int minutes = Math.round(delay/60f);
|
|
|
|
obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(self));
|
|
if ( players != null && players.length > 0 )
|
|
{
|
|
for ( int i = 0; i < players.length; i++ )
|
|
sendSystemMessageTestingOnly(players[i], "COUNTDOWN INITIATED: estimated time to detonation: " + minutes + " minutes.");
|
|
}
|
|
|
|
utils.setScriptVar(self, SCRIPTVAR_COUNTDOWN, getGameTime() + delay);
|
|
|
|
dictionary d = new dictionary();
|
|
d.put("player", player);
|
|
d.put("cnt", minutes);
|
|
|
|
messageTo(self, "handleCountdown", d, 10f, false);
|
|
}
|
|
|
|
void abortCountdown(obj_id self)
|
|
{
|
|
utils.removeScriptVar(self, SCRIPTVAR_COUNTDOWN);
|
|
|
|
obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(self));
|
|
if ( players != null && players.length > 0 )
|
|
{
|
|
for ( int i = 0; i < players.length; i++ )
|
|
sendSystemMessageTestingOnly(players[i], "COUNTDOWN ABORTED: FACILITY SHUTTING DOWN!!");
|
|
}
|
|
}
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
|
|
messageHandler handleFacilityReboot()
|
|
{
|
|
detachScript(self, hq.SCRIPT_TERMINAL_DISABLE);
|
|
|
|
obj_id structure = getObjIdObjVar(self, "objParent");
|
|
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++ )
|
|
sendSystemMessageTestingOnly(players[i], "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 ( !isIdValid(player) )
|
|
{
|
|
abortCountdown(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int cnt = params.getInt("cnt");
|
|
|
|
int stamp = utils.getIntScriptVar(self, SCRIPTVAR_COUNTDOWN);
|
|
int now = getGameTime();
|
|
|
|
int timeLeft = stamp - now;
|
|
int minutes = timeLeft/60;
|
|
|
|
obj_id structure = getObjIdObjVar(self, "objParent");
|
|
if ( !isIdValid(structure) )
|
|
{
|
|
abortCountdown(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
string msg = "COUNTDOWN: estimated time to detonation: " + minutes + " minutes.";
|
|
if ( minutes < 1 )
|
|
{
|
|
msg = "COUNTDOWN: estimated time to detonation: " + timeLeft + " seconds.";
|
|
}
|
|
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++ )
|
|
sendSystemMessageTestingOnly(players[i], msg);
|
|
}
|
|
|
|
params.put("cnt", minutes);
|
|
}
|
|
|
|
messageTo(self, "handleCountdown", params, 10f, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|