mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
95 lines
3.2 KiB
Plaintext
95 lines
3.2 KiB
Plaintext
/**********************************************************************
|
|
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
|
|
* All Rights Reserved
|
|
*
|
|
* Title: barracks
|
|
* Description: script that goes on battlefield installations that
|
|
* create battlefield pets.
|
|
*
|
|
* @author $Author:$
|
|
* @version $Revision:$
|
|
**********************************************************************/
|
|
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
include library.battlefield;
|
|
include library.player_structure;
|
|
include library.sui;
|
|
include library.utils;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
const string_id SID_BUILD_REINFORCEMENT = new string_id("battlefield", "build_reinforcement");
|
|
const string_id SID_BUILD_REINFORCEMENT_STATUS = new string_id("battlefield", "build_reinforcement_status");
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if (battlefield.isSameBattlefieldFaction(player, self))
|
|
{
|
|
if (battlefield.canBuildReinforcement(self))
|
|
{
|
|
int battlefield_root = mi.addRootMenu (menu_info_types.SERVER_MENU2, SID_BUILD_REINFORCEMENT);
|
|
}
|
|
|
|
int status_root = mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_BUILD_REINFORCEMENT_STATUS);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if (item == menu_info_types.SERVER_MENU2)
|
|
{
|
|
LOG("LOG_CHANNEL", "battlefield_barracks::OnPurchaseReinforcement");
|
|
|
|
queueCommand(player, ##"purchaseReinforcement", null, "", COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
|
|
if (item == menu_info_types.SERVER_MENU1)
|
|
{
|
|
string reinforce_name = getStringObjVar(self, battlefield.VAR_REINFORCEMENT_NAME);
|
|
//int build_time = getIntObjVar(self, battlefield.VAR_BUILD_RATE);
|
|
float cost = getFloatObjVar(self, battlefield.VAR_REINFORCEMENT_COST);
|
|
|
|
resizeable string[] dsrc = new string[0];
|
|
dsrc = utils.addElement(dsrc, "Reinforcement Produced: " + reinforce_name);
|
|
dsrc = utils.addElement(dsrc, "Faction Point Cost: " + cost);
|
|
dsrc = utils.addElement(dsrc, "");
|
|
|
|
if (!battlefield.canBuildReinforcement(self))
|
|
{
|
|
// Determine time until more reinforcements can be built.
|
|
int time = getGameTime();
|
|
int build_rate = getIntObjVar(self, battlefield.VAR_BUILD_RATE);
|
|
int last_build = 0;
|
|
if (hasObjVar(self, battlefield.VAR_LAST_BUILD))
|
|
last_build = getIntObjVar(self, battlefield.VAR_LAST_BUILD);
|
|
|
|
// Determine time remaining.
|
|
int time_remaining = last_build + build_rate - time;
|
|
if (time_remaining > 0)
|
|
{
|
|
int[] conv_time = player_structure.convertSecondsTime(time_remaining);
|
|
string time_str = player_structure.assembleTimeRemaining(conv_time);
|
|
|
|
dsrc = utils.addElement(dsrc, "Time until next reinforcement: " + time_str);
|
|
}
|
|
}
|
|
else
|
|
dsrc = utils.addElement(dsrc, "Ready to issue more reinforcements.");
|
|
|
|
sui.listbox(player, "Reinforcement Status", "Reinforcement Status", dsrc);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
|
|
|
|
/***** COMMANDHANDLERS *************************************************/
|
|
|
|
|
|
/***** FUNCTIONS *******************************************************/
|