mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
352 lines
11 KiB
Plaintext
352 lines
11 KiB
Plaintext
/* Title: camp_controlpanel.script
|
|
* Description: camp control panel object script
|
|
*/
|
|
|
|
//----------------------------------------------------------------------
|
|
// Includes
|
|
//----------------------------------------------------------------------
|
|
|
|
include library.camping;
|
|
include library.factions;
|
|
include library.faction_perk;
|
|
include library.prose;
|
|
include library.utils;
|
|
include library.sui;
|
|
include library.player_structure;
|
|
include library.structure;
|
|
include library.group;
|
|
|
|
//----------------------------------------------------------------------
|
|
// Constants
|
|
//----------------------------------------------------------------------
|
|
|
|
const float FIELD_COST_MULTIPLER = 1.15f;
|
|
|
|
const string_id SID_MNU_DISBAND = new string_id("camp","mnu_disband");
|
|
const string_id SID_MNU_STATUS = new string_id("camp","mnu_status");
|
|
const string_id SID_MNU_WAYPOINT = new string_id("camp","mnu_waypoint");
|
|
const string_id SID_MNU_ASSUME_OWNERSHIP = new string_id("camp","mnu_assume_ownership");
|
|
const string_id SID_NO_GROUP = new string_id("camp","waypoint_no_group");
|
|
const string_id SID_CAMP_UP = new string_id("camp","waypoint_camp_up");
|
|
const string_id SID_WAYPOINT_SENT = new string_id("camp","waypoint_sent");
|
|
const string_id SID_SELECT_SUB_MENU = new string_id("camp","select_sub_menu");
|
|
|
|
const string_id SID_MNU_REQUISITION = new string_id("camp","mnu_requisition");
|
|
const string_id SID_MNU_REQUISITION_WPN = new string_id("camp","mnu_requisition_wpn");
|
|
const string_id SID_MNU_REQUISITION_INSTALLATION = new string_id("camp","mnu_requisition_installation");
|
|
|
|
const string_id SID_SUI_FIELD_REQ_TITLE = new string_id("camp","sui_field_req_title");
|
|
const string_id SID_SUI_FIELD_REQ_PROMPT = new string_id("camp","sui_field_req_prompt");
|
|
|
|
const string_id SID_SUI_CAMP_STATUS_TITLE = new string_id("camp","sui_camp_status_title");
|
|
const string_id SID_SUI_CAMP_STATUS_PROMPT = new string_id("camp","sui_camp_status_prompt");
|
|
const string_id SID_SUI_CAMP_STATUS_OWNER = new string_id("camp","sui_camp_status_owner");
|
|
const string_id SID_SUI_CAMP_STATUS_UPTIME = new string_id("camp","sui_camp_status_uptime");
|
|
const string_id SID_SUI_CAMP_STATUS_TOT_VIS = new string_id("camp","sui_camp_status_tot_vis");
|
|
const string_id SID_SUI_CAMP_STATUS_CUR_VIS = new string_id("camp","sui_camp_status_cur_vis");
|
|
const string_id SID_SUI_CAMP_STATUS_HEAL = new string_id("camp","sui_camp_status_heal");
|
|
|
|
//----------------------------------------------------------------------
|
|
// handleCampPrep
|
|
//----------------------------------------------------------------------
|
|
|
|
messageHandler handleCampPrep()
|
|
{
|
|
// Get master ref.
|
|
if ( params == null )
|
|
return SCRIPT_CONTINUE;
|
|
obj_id master = params.getObjId( "master" );
|
|
setObjVar( self, "master", master );
|
|
|
|
// Set our name.
|
|
setName( self, getEncodedName( master ) );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// OnObjectMenuRequest
|
|
//----------------------------------------------------------------------
|
|
|
|
trigger OnObjectMenuRequest( obj_id player, menu_info mi )
|
|
{
|
|
obj_id master = getObjIdObjVar( self, "master" );
|
|
if ( !isIdValid(master) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id owner = getObjIdObjVar(master, camping.VAR_OWNER);
|
|
if ( owner == null )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if ( owner == obj_id.NULL_ID )
|
|
{
|
|
/*
|
|
int mod = getSkillStatMod(player, camping.MOD_CAMP);
|
|
if ( mod > 0 )
|
|
{
|
|
mi.addRootMenu(menu_info_types.SERVER_CAMP_ASSUME_OWNERSHIP, SID_MNU_ASSUME_OWNERSHIP);
|
|
}
|
|
*/
|
|
}
|
|
else
|
|
{
|
|
if ( owner == player )
|
|
mi.addRootMenu( menu_info_types.SERVER_CAMP_DISBAND, SID_MNU_DISBAND );
|
|
mi.addRootMenu( menu_info_types.SERVER_MENU1, SID_MNU_STATUS );
|
|
// mi.addRootMenu( menu_info_types.SERVER_MENU2, SID_MNU_WAYPOINT );
|
|
|
|
int mFac = pvpGetAlignedFaction(master);
|
|
if ( mFac != 0 )
|
|
{
|
|
int pFac = pvpGetAlignedFaction(player);
|
|
if ( pFac == mFac && factions.isDeclared(player) )
|
|
{
|
|
int mnuReq = mi.addRootMenu( menu_info_types.SERVER_MENU3, SID_MNU_REQUISITION );
|
|
if ( mnuReq > -1 )
|
|
{
|
|
mi.addSubMenu( mnuReq, menu_info_types.SERVER_MENU4, SID_MNU_REQUISITION_WPN );
|
|
mi.addSubMenu( mnuReq, menu_info_types.SERVER_MENU5, SID_MNU_REQUISITION_INSTALLATION );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// OnObjectMenuSelect
|
|
//----------------------------------------------------------------------
|
|
|
|
trigger OnObjectMenuSelect( obj_id player, int item )
|
|
{
|
|
obj_id master = getObjIdObjVar( self, "master" );
|
|
if ( !isIdValid(master) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id owner = getObjIdObjVar( master, camping.VAR_OWNER );
|
|
if ( item == menu_info_types.SERVER_CAMP_DISBAND )
|
|
{
|
|
if ( (owner == null) || (owner == obj_id.NULL_ID) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
if ( owner == player )
|
|
{
|
|
camping.nukeCamp( master );
|
|
// destroyObject( master );
|
|
}
|
|
}
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU1 )
|
|
{
|
|
// Show status window.
|
|
showStatus( self, player );
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU2 )
|
|
{
|
|
// Transmit waypoint.
|
|
// sendWaypoint( self, player );
|
|
}
|
|
else if ( item == menu_info_types.SERVER_CAMP_ASSUME_OWNERSHIP )
|
|
{
|
|
/*
|
|
if ( owner == obj_id.NULL_ID )
|
|
{
|
|
queueCommand(player, ##"camp", null, "", COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
*/
|
|
}
|
|
else
|
|
{
|
|
int mFac = pvpGetAlignedFaction(master);
|
|
if ( mFac != 0 )
|
|
{
|
|
int pFac = pvpGetAlignedFaction(player);
|
|
if ( pFac == mFac && factions.isDeclared(player) )
|
|
{
|
|
if ( item == menu_info_types.SERVER_MENU3 )
|
|
{
|
|
//showPerkOptionsMenu(self, player);
|
|
sendSystemMessage(player, SID_SELECT_SUB_MENU);
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU4 )
|
|
{
|
|
faction_perk.displayItemPurchaseSUI(player, pvpGetCurrentGcwRank(player), factions.getFaction(player), FIELD_COST_MULTIPLER);
|
|
}
|
|
else if ( item == menu_info_types.SERVER_MENU5 )
|
|
{
|
|
faction_perk.displayItemPurchaseSUI(player, pvpGetCurrentGcwRank(player), factions.getFaction(player), FIELD_COST_MULTIPLER);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgFactionItemPurchaseSelected()
|
|
{
|
|
faction_perk.factionItemPurchased(params, FIELD_COST_MULTIPLER);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/*
|
|
void showPerkOptionsMenu(obj_id self, obj_id player)
|
|
{
|
|
if ( !isIdValid(self) || !isIdValid(player) )
|
|
return;
|
|
|
|
resizeable string[] entries = new string[0];
|
|
for ( int i = 0; i < faction_perk.FACTION_PERK_GROUPS.length; i++ )
|
|
entries = utils.addElement(entries, utils.packStringId(faction_perk.FACTION_PERK_GROUPS[i]));
|
|
|
|
if ( entries != null && entries.length > 0 )
|
|
{
|
|
float fieldMod = 1.15f;
|
|
|
|
string title = utils.packStringId(SID_SUI_FIELD_REQ_TITLE);
|
|
prose_package ppFieldReq = prose.getPackage(SID_SUI_FIELD_REQ_PROMPT);
|
|
prose.setDI(ppFieldReq, fieldMod * 100);
|
|
string prompt = " \0" + packOutOfBandProsePackage(null, ppFieldReq);
|
|
|
|
sui.listbox(self, player, prompt, sui.OK_CANCEL, title, entries, "handleRequisitionCategory");
|
|
}
|
|
}
|
|
|
|
messageHandler handleRequisitionCategory()
|
|
{
|
|
if ( params == null || params.isEmpty() )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int bp = sui.getIntButtonPressed(params);
|
|
if ( bp == sui.BP_CANCEL )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( !isIdValid(player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
if ( idx < 0 )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
*/
|
|
|
|
//----------------------------------------------------------------------
|
|
// showStatus
|
|
//----------------------------------------------------------------------
|
|
|
|
void showStatus( obj_id self, obj_id player )
|
|
{
|
|
obj_id master = getObjIdObjVar( self, "master" );
|
|
obj_id owner = getObjIdObjVar( master, camping.VAR_OWNER );
|
|
|
|
// List owner name.
|
|
resizeable string[] dsrc = new string[0];
|
|
prose_package ppCampOwner = prose.getPackage(SID_SUI_CAMP_STATUS_OWNER);
|
|
prose.setTT(ppCampOwner, owner);
|
|
dsrc = utils.addElement( dsrc, " \0" + packOutOfBandProsePackage(null, ppCampOwner) );
|
|
|
|
// List time.
|
|
int createTime = getIntObjVar( master, "camp.createTime" );
|
|
int curTime = getGameTime();
|
|
string timestring = player_structure.assembleTimeRemaining( player_structure.convertSecondsTime( curTime - createTime ) );
|
|
prose_package ppUptime = prose.getPackage(SID_SUI_CAMP_STATUS_UPTIME);
|
|
prose.setTT(ppUptime, timestring);
|
|
dsrc = utils.addElement( dsrc, " \0" + packOutOfBandProsePackage(null, ppUptime) );
|
|
|
|
// List visitors.
|
|
int count = getIntObjVar( master, "visitor_count" );
|
|
prose_package ppTotVis = prose.getPackage(SID_SUI_CAMP_STATUS_TOT_VIS);
|
|
prose.setDI(ppTotVis, count);
|
|
dsrc = utils.addElement( dsrc, " \0" + packOutOfBandProsePackage(null, ppTotVis) );
|
|
|
|
// List visitors.
|
|
count = getIntObjVar( master, "occ_count" );
|
|
prose_package ppCurVis = prose.getPackage(SID_SUI_CAMP_STATUS_CUR_VIS);
|
|
prose.setDI(ppCurVis, count);
|
|
dsrc = utils.addElement( dsrc, " \0" + packOutOfBandProsePackage(null, ppCurVis) );
|
|
|
|
// List healing rate.
|
|
float healrate = camping.getCampHealModifier( master );
|
|
prose_package ppHealMod = prose.getPackage(SID_SUI_CAMP_STATUS_HEAL);
|
|
prose.setDF(ppHealMod, healrate);
|
|
dsrc = utils.addElement( dsrc, " \0" + packOutOfBandProsePackage(null, ppHealMod) );
|
|
|
|
// Draw the list box with all of the info.
|
|
sui.listbox( player, utils.packStringId(SID_SUI_CAMP_STATUS_PROMPT), utils.packStringId(SID_SUI_CAMP_STATUS_TITLE), sui.OK_CANCEL, dsrc );
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// sendWaypoint
|
|
//----------------------------------------------------------------------
|
|
|
|
void sendWaypoint( obj_id self, obj_id player )
|
|
{
|
|
if ( !group.isGrouped( player ) )
|
|
{
|
|
// Not grouped, no one to send waypoint to.
|
|
sendSystemMessage( player, SID_NO_GROUP );
|
|
return;
|
|
}
|
|
|
|
location point = getLocation( self );
|
|
obj_id group = getGroupObject( player );
|
|
obj_id[] members = getGroupMemberIds( group );
|
|
for ( int i=0; i<members.length; i++ )
|
|
{
|
|
if ( isIdValid( members[i] ) )
|
|
{
|
|
if ( members[i] == player )
|
|
{
|
|
sendSystemMessage( player, SID_WAYPOINT_SENT );
|
|
continue;
|
|
}
|
|
// Give this guy a waypoint.
|
|
obj_id waypoint = getCampWaypoint( members[i] );
|
|
if (!isIdValid(waypoint))
|
|
waypoint = createWaypointInDatapad( members[i], point );
|
|
|
|
if (isIdValid(waypoint))
|
|
{
|
|
// setWaypointVisible( waypoint, true );
|
|
setWaypointActive( waypoint, true );
|
|
setWaypointLocation( waypoint, point );
|
|
setName( waypoint, "Camp Location" );
|
|
setWaypointColor( waypoint, "white" );
|
|
}
|
|
sendSystemMessage( members[i], SID_CAMP_UP );
|
|
}
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// getCampWaypoint
|
|
//----------------------------------------------------------------------
|
|
|
|
obj_id getCampWaypoint( obj_id other )
|
|
{
|
|
// Check to see if any waypoints are already to that location.
|
|
obj_id datapad = getObjectInSlot( other, "datapad" );
|
|
obj_id[] data = getContents( datapad );
|
|
if ( data != null )
|
|
{
|
|
for ( int i=0; i<data.length; i++ )
|
|
{
|
|
string waypointName = getName( data[i] );
|
|
if ( waypointName == "Camp Location" )
|
|
{
|
|
// Matching waypoint.
|
|
return data[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|