mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
You can now rename your beast as much as you would like. Police officers will no longer harass corpses. Static NPC's conversing will now successfully converse with one another. When a player dies, the pet will go invulnerable and be immediately packed up. When respecing professions, your weapon will now be unequiped. Fixed the chat system for some NPC's. You can now only mount your vehicle from less than 5 meters. Quest items that can be clicked on cannot be used from less than 5 meters. Added a message to the QaSetup script, notifying the QA that they have received their items.
1549 lines
58 KiB
Plaintext
1549 lines
58 KiB
Plaintext
/**********************************************************************
|
|
|
|
*
|
|
* Title: terminal_travel.script
|
|
* Description: script that attaches to the travel terminal
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
include library.buff;
|
|
include library.callable;
|
|
include library.city;
|
|
include library.combat;
|
|
include library.create;
|
|
include library.factions;
|
|
include library.locations;
|
|
include library.money;
|
|
include library.prose;
|
|
include library.regions;
|
|
include library.space_dungeon;
|
|
include library.space_dungeon_data;
|
|
include library.structure;
|
|
include library.sui;
|
|
include library.travel;
|
|
include library.utils;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const string_id SID_CANT_BOARD = new string_id("city/city","city_cant_board");
|
|
const string_id SID_CANT_BUY_TICKET = new string_id("city/city","city_cant_purchase_ticket");
|
|
const string_id SID_CITY_TICKET = new string_id("city/city","city_ticket_pay");
|
|
const string_id SID_NO_COLLECTOR = new string_id("dungeon/space_dungeon", "no_collector");
|
|
|
|
const string_id SID_BANNED_FROM_THAT_CITY= new string_id("city/city","banned_from_that_city");
|
|
|
|
const string_id SID_INSTANT_GO_MOUNT_NO = new string_id("travel/travel", "on_pet_or_vehicle_instant_go");
|
|
const string_id SID_INSTANT_MOUNT_NO = new string_id("travel/travel", "on_pet_or_vehicle_instant");
|
|
const string_id SID_SUI_SELECT_DESTINATION_TITLE = new string_id("travel/travel","sui_select_destination_title");
|
|
const string_id SID_SUI_SELECT_DESTINATION_HEADER = new string_id("travel/travel","sui_select_destination_header");
|
|
const string_id SID_SUI_SELECT_DESTINATION_LOC = new string_id("travel/travel","sui_select_destination_loc");
|
|
|
|
const string_id SID_CALLING_FOR_PICKUP = new string_id("travel", "calling_for_pickup");
|
|
const string_id SID_LOCATION_NOGOOD_FOR_PICKUP = new string_id("travel", "no_pickup_location");
|
|
const string_id SID_LOCATION_INDOORS = new string_id("travel", "no_pickup_indoors");
|
|
const string_id SID_ALREADY_OUT = new string_id("travel", "pickup_craft_already_out");
|
|
const string_id SID_NO_PICKUP_IN_TOWN = new string_id("travel", "no_pickup_in_town");
|
|
const string_id SID_INVALID_PICKUP_LOC = new string_id("travel", "invalid_pickup_loc");
|
|
const string_id SID_IN_COMBAT = new string_id("travel", "in_combat");
|
|
const string_id SID_NO_PICKUP_IN_PVP = new string_id("travel", "no_pickup_in_pvp");
|
|
const string_id SID_PICKUP_CANCEL = new string_id("travel", "pickup_cancel");
|
|
|
|
const boolean CONST_FLAG_DO_LOGGING = false;
|
|
|
|
const string ITV_PICKUP_BUFF = "call_for_pickup";
|
|
const string STF_FILE = "travel";
|
|
|
|
const string SCRIPTVAR_ACCEPT_GCW_SURCHARGE_ACCEPTED = "travel.accept_gcw_surcharge_accepted";
|
|
const string SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED = "travel.accept_gcw_skip_shuttle_wait_surcharge_accepted";
|
|
const string SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID = "travel.accept_gcw_surcharge_sui_id";
|
|
const string SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID = "travel.accept_gcw_surcharge_ticket_id";
|
|
const string SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID = "travel.accept_gcw_surcharge_shuttle_id";
|
|
|
|
const int SHIP_TYPE_INSTANT_XWING_TIE = 1;
|
|
const int SHIP_TYPE_INSTANT_PRIVATEER = 2;
|
|
const int SHIP_TYPE_INSTANT_ROYAL_SHIP = 3;
|
|
const int SHIP_TYPE_INSTANT_JALOPY = 4;
|
|
const int SHIP_TYPE_TCG_HOME_SHIP = 5;
|
|
const int SHIP_TYPE_TCG_LOCATION_SHIP = 6;
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
trigger OnInitialize()
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel.OnInitialize");
|
|
if (hasObjVar(self, travel.VAR_TRAVEL))
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnPurchaseTicket(obj_id player, String departPlanetName, String departTravelPointName, String arrivePlanetName, String arriveTravelPointName, boolean roundTrip)
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::OnPurchaseTicket");
|
|
|
|
obj_id terminal = utils.getObjIdScriptVar(player, travel.SCRIPT_VAR_TERMINAL);
|
|
if (isIdValid(terminal))
|
|
{
|
|
float distance = getDistance(self, terminal);
|
|
LOG("LOG_CHANNEL", "distance ->" + distance);
|
|
if (distance > travel.MAXIMUM_TERMINAL_DISTANCE)
|
|
{
|
|
sendSystemMessage(self, new string_id(STF_FILE, "too_far")); // You are too far from the terminal to purchase a ticket.
|
|
//utils.removeScriptVar(player, travel.SCRIPT_VAR_TERMINAL);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
obj_id starport = travel.getStarportFromTerminal( terminal );
|
|
|
|
if(arriveTravelPointName.indexOf("gcwstaticbase") > -1)
|
|
{
|
|
if((arriveTravelPointName.indexOf("rebel") > -1) && !factions.isRebel(self))
|
|
{
|
|
sendSystemMessage(self, new string_id("gcw", "static_base_shuttle_beacon_cant_not_rebel"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if((arriveTravelPointName.indexOf("imperial") > -1) && !factions.isImperial(self))
|
|
{
|
|
sendSystemMessage(self, new string_id("gcw", "static_base_shuttle_beacon_cant_not_imperial"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Can't board if we are city banned.
|
|
int city_id = getCityAtLocation( getLocation(starport), 0 );
|
|
if ( city.isCityBanned( self, city_id ) )
|
|
{
|
|
sendSystemMessage( self, SID_CANT_BUY_TICKET );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Check to see if there is restriction on using starport for interplanetary travel
|
|
if (!departPlanetName.equals(arrivePlanetName))
|
|
{
|
|
const string departPlanetAvailableStarport = travel.getGcwTravelRestrictionsAvailableStarport(self, departPlanetName);
|
|
if ((departPlanetAvailableStarport != null) && (departPlanetAvailableStarport.length() > 0) && (!departPlanetAvailableStarport.equals(departTravelPointName)))
|
|
{
|
|
sendSystemMessage(self, "Because you are a GCW officer and the opposing faction currently controls the departure planet, the only starport currently available for interplanetary travel on the departure planet is " + departPlanetAvailableStarport + ".", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
const string arrivePlanetAvailableStarport = travel.getGcwTravelRestrictionsAvailableStarport(self, arrivePlanetName);
|
|
if ((arrivePlanetAvailableStarport != null) && (arrivePlanetAvailableStarport.length() > 0) && (!arrivePlanetAvailableStarport.equals(arriveTravelPointName)))
|
|
{
|
|
sendSystemMessage(self, "Because you are a GCW officer and the opposing faction currently controls the arrival planet, the only starport currently available for interplanetary travel on the arrival planet is " + arrivePlanetAvailableStarport + ".", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
travel.purchaseTicket( self, departPlanetName, departTravelPointName, arrivePlanetName, arriveTravelPointName, roundTrip, starport );
|
|
|
|
//if (utils.hasScriptVar(player, travel.SCRIPT_VAR_TERMINAL))
|
|
// utils.removeScriptVar(player, travel.SCRIPT_VAR_TERMINAL);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
trigger OnPurchaseTicketInstantTravel(obj_id player, String departPlanetName, String departTravelPointName, String arrivePlanetName, String arriveTravelPointName, boolean roundTrip)
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::OnPurchaseTicketInstantTravel");
|
|
|
|
if (!utils.hasScriptVar(player, "instantTravel") )
|
|
return SCRIPT_CONTINUE;
|
|
else
|
|
utils.removeScriptVar(player, "instantTravel");
|
|
|
|
obj_id terminal = utils.getObjIdScriptVar(player, travel.SCRIPT_VAR_TERMINAL);
|
|
if (isIdValid(terminal))
|
|
{
|
|
float distance = getDistance(self, terminal);
|
|
LOG("LOG_CHANNEL", "distance ->" + distance);
|
|
if (distance > travel.MAXIMUM_TERMINAL_DISTANCE || !exists(terminal))
|
|
{
|
|
sendSystemMessage(self, new string_id(STF_FILE, "too_far")); // You are too far from the terminal to purchase a ticket.
|
|
//utils.removeScriptVar(player, travel.SCRIPT_VAR_TERMINAL);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Can't call for pickup when mounted.
|
|
obj_id playerCurrentMount = getMountId (player);
|
|
if ( isIdValid(playerCurrentMount))
|
|
{
|
|
sendSystemMessage(player, SID_INSTANT_GO_MOUNT_NO);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
obj_id starport = travel.getStarportFromTerminal( terminal );
|
|
|
|
// Can't board if we are city banned.
|
|
int city_id = getCityAtLocation( getLocation(starport), 0 );
|
|
if ( city.isCityBanned( self, city_id ) )
|
|
{
|
|
sendSystemMessage( self, SID_CANT_BUY_TICKET );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
travel.instantTravel( self, departPlanetName, departTravelPointName, arrivePlanetName, arriveTravelPointName, roundTrip, starport );
|
|
|
|
//clean up the ITV if exists
|
|
if(buff.hasBuff(self, ITV_PICKUP_BUFF))
|
|
{
|
|
sendSystemMessage(self, SID_PICKUP_CANCEL);
|
|
buff.removeBuff(self, ITV_PICKUP_BUFF);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
trigger OnAboutToTravelToGroupPickupPoint()
|
|
{
|
|
if(callable.hasAnyCallable(self))
|
|
{
|
|
sendSystemMessage(self, new string_id("beast", "beast_cant_travel"));
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
trigger OnTravelToGroupPickupPoint(string planetName, string travelPointName)
|
|
{
|
|
travel.movePlayerToDestination(self, planetName, travelPointName, true);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
|
|
messageHandler msgTicketPaymentFail()
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->You do not have enough money to complete the ticket purchase.");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "short_funds")); // You do not have enough money to complete the ticket purchase.
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgUseTravelCouponSui()
|
|
{
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( utils.hasScriptVar(self, "travel_voucher.travelVoucherSui") )
|
|
{
|
|
utils.removeScriptVar(self, "travel_voucher.travelVoucherSui");
|
|
}
|
|
|
|
// this dictionary has all the data needed to purchase the ticket (from travel.purchaseTicket)
|
|
dictionary webster = utils.getDictionaryScriptVar(self, "travelTicketDict");
|
|
obj_id starport = webster.getObjId("starport");
|
|
int total_cost = webster.getInt("amount");
|
|
int city_fee = webster.getInt("city_fee");
|
|
obj_id travel_coupon = webster.getObjId("travel_coupon");
|
|
boolean hasEnoughMoney = webster.getBoolean("hasEnoughMoney");
|
|
|
|
obj_id terminal = utils.getObjIdScriptVar(self, travel.SCRIPT_VAR_TERMINAL);
|
|
if (isIdValid(terminal))
|
|
{
|
|
float distance = getDistance(self, terminal);
|
|
if (distance > travel.MAXIMUM_TERMINAL_DISTANCE)
|
|
{
|
|
sendSystemMessage(self, new string_id(STF_FILE, "too_far")); // You are too far from the terminal to purchase a ticket.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Determine which button was pressed.
|
|
int bp = sui.getIntButtonPressed( params );
|
|
switch ( bp )
|
|
{
|
|
case sui.BP_OK: // Use My Travel Coupon
|
|
if ( isIdValid(travel_coupon) )
|
|
{
|
|
destroyObject(travel_coupon);
|
|
|
|
// Set the players purchase pending scriptvar
|
|
utils.setScriptVar(self, travel.VAR_PURCHASING_TICKET, 1);
|
|
|
|
string custLogMsg = "New Player Rewards: %TU sucessfully used a travel voucher.";
|
|
CustomerServiceLog("NEW_PLAYER_QUESTS", custLogMsg, self);
|
|
|
|
messageTo(self, "msgTicketPaymentComplete", webster, 1, false);
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(self, new string_id ("new_player", "travel_coupon_invaild"));
|
|
}
|
|
break;
|
|
case sui.BP_CANCEL: // Pay for the ticket
|
|
if ( hasEnoughMoney )
|
|
{
|
|
if ( money.pay(self, money.ACCT_TRAVEL, total_cost, "msgTicketPaymentComplete", webster, true) )
|
|
{
|
|
params.put("amount", city_fee);
|
|
if ( (city_fee > 0) && !money.pay( self, city.getCityHall(starport), city_fee, "msgCityTicketPaymentComplete", webster, true ) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
LOG("LOG_CHANNEL", "Deducting " + total_cost);
|
|
|
|
// Set the players purchase pending scriptvar
|
|
utils.setScriptVar(self, travel.VAR_PURCHASING_TICKET, 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(self, new string_id ("new_player", "travel_coupon_cancelled"));
|
|
}
|
|
break;
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgTicketPaymentComplete()
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgTicketPaymentComplete");
|
|
|
|
// Clear the purchase pending scriptvar.
|
|
if (utils.hasScriptVar(self, travel.VAR_PURCHASING_TICKET))
|
|
utils.removeScriptVar(self, travel.VAR_PURCHASING_TICKET);
|
|
|
|
string planet1 = params.getString("planet1");
|
|
string point1 = params.getString("point1");
|
|
string planet2 = params.getString("planet2");
|
|
string point2 = params.getString("point2");
|
|
boolean roundtrip = params.getBoolean("roundtrip");
|
|
|
|
obj_id[] tickets = travel.createTicket(self, planet1, point1, planet2, point2, roundtrip);
|
|
|
|
LOG("LOG_CHANNEL", self + " ->Ticket purchase complete.");
|
|
sui.msgbox(self, new string_id(STF_FILE, "ticket_purchase_complete"));
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgTravelComplete()
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgTravelComplete");
|
|
|
|
string departure_planet;
|
|
string arrival_planet;
|
|
string departure_point;
|
|
string arrival_point;
|
|
|
|
if (utils.hasScriptVar(self, travel.VAR_DEPARTURE_PLANET))
|
|
{
|
|
departure_planet = utils.getStringScriptVar(self, travel.VAR_DEPARTURE_PLANET);
|
|
utils.removeScriptVar(self, travel.VAR_DEPARTURE_PLANET);
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("travel", getFirstName(self) + " has an invalid departure planet. Unable to check for travel success.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (utils.hasScriptVar(self, travel.VAR_DEPARTURE_POINT))
|
|
{
|
|
departure_point = utils.getStringScriptVar(self, travel.VAR_DEPARTURE_POINT);
|
|
utils.removeScriptVar(self, travel.VAR_DEPARTURE_POINT);
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("travel", getFirstName(self) + " has an invalid departure point. Unable to check for travel success.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (utils.hasScriptVar(self, travel.VAR_ARRIVAL_PLANET))
|
|
{
|
|
arrival_planet = utils.getStringScriptVar(self, travel.VAR_ARRIVAL_PLANET);
|
|
utils.removeScriptVar(self, travel.VAR_ARRIVAL_PLANET);
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("travel", getFirstName(self) + " has an invalid arrival planet. Unable to check for travel success.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (utils.hasScriptVar(self, travel.VAR_ARRIVAL_POINT))
|
|
{
|
|
arrival_point = utils.getStringScriptVar(self, travel.VAR_ARRIVAL_POINT);
|
|
utils.removeScriptVar(self, travel.VAR_ARRIVAL_POINT);
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("travel", getFirstName(self) + " has an invalid arrival point. Unable to check for travel success.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
location loc = getPlanetTravelPointLocation(arrival_planet, arrival_point);
|
|
if (loc != null)
|
|
{
|
|
// Check to see if the player ended up where he should have.
|
|
location player_loc = getLocation(self);
|
|
if (loc.area.equals(player_loc.area))
|
|
{
|
|
if (player_loc.distance(loc) < 100)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Player isn't where he should be. Recreate the deed.
|
|
if (travel.createTicket(self, departure_planet, departure_point, arrival_planet, arrival_point, false) == null)
|
|
CustomerServiceLog("travel", getFirstName(self) + " arrived at the incorrect travel location. Unable to recreate ticket.");
|
|
}
|
|
else
|
|
CustomerServiceLog("travel", "Unable to find travel location for " + getFirstName(self) + ". Unable to check for travel success.");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgBoardShuttle()
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- " + params);
|
|
|
|
if ( isIdValid (getMountId(self)))
|
|
{
|
|
LOG("LOG_CHANNEL", self + " -> PLAYER_TRAVEL - msghndler msgBoardShuttle - You cannot board the shuttle when mounted on a pet/vehicle?");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "no_pets")); // You cannot board the shuttle when you are riding on a pet or in a vehicle.
|
|
if(utils.hasScriptVar( self, "travel.hasTicketList"))
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string button = params.getString("buttonPressed");
|
|
if (button.equals("Cancel") || button.equals("No"))
|
|
{
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int row_selected = sui.getListboxSelectedRow(params);
|
|
if (row_selected != -1)
|
|
{
|
|
// Get the valid ticket from those stored on the player
|
|
if (hasObjVar(self, travel.VAR_VALID_TICKETS))
|
|
{
|
|
obj_id[] valid_tickets = getObjIdArrayObjVar(self, travel.VAR_VALID_TICKETS);
|
|
const obj_id shuttle = getObjIdObjVar(self, travel.VAR_BOARDING_SHUTTLE);
|
|
|
|
if (row_selected >= valid_tickets.length)
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- Row selected exceeded ticket length.");
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id ticket = valid_tickets[row_selected];
|
|
|
|
if (!ticket.isLoaded())
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- " + ticket + " can't be loaded.");
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (!shuttle.isLoaded())
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- " + shuttle + " can't be loaded.");
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Get rid of the objvar once we've used it.
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
|
|
// Make sure the player hasn't moved too far from the shuttle
|
|
if (!travel.isInShuttleBoardingRange(self, shuttle))
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- " + self + " is too far from shuttle " + shuttle);
|
|
sendSystemMessage(self, new string_id(STF_FILE, "boarding_too_far")); // You are too far from the shuttle to board.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
const obj_id starport = travel.getStarportFromTerminal(shuttle);
|
|
if (starport == null)
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- Unable to find starport.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Make sure the shuttle is available
|
|
boolean qualifiesForGcwTravelPerks = false;
|
|
if (!travel.isShuttleAvailable(starport))
|
|
{
|
|
// see if the player qualifies to bypass the shuttle timer
|
|
qualifiesForGcwTravelPerks = travel.qualifiesForGcwTravelPerks(self);
|
|
|
|
if (!qualifiesForGcwTravelPerks)
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->The shuttle is not available at this time.");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "shuttle_not_available")); // The shuttle is not available at this time.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Get the origination point
|
|
string depart_planet = getCurrentSceneName();
|
|
string depart_point = travel.getTravelPointName(starport);
|
|
|
|
// Make sure that the ticket is still valid
|
|
if (!travel.isTravelTicketValid(ticket, depart_planet, depart_point))
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- " + ticket + " is no longer valid.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Get the arrival location from the ticket
|
|
string arrival_planet = travel.getTicketArrivalPlanet(ticket);
|
|
string arrival_point = travel.getTicketArrivalPoint(ticket);
|
|
|
|
// See if we are banned from the target city.
|
|
int city_id = findCityByName( arrival_point );
|
|
if ( (city_id != 0) && cityExists( city_id ) && city.isCityBanned( self, city_id ) )
|
|
{
|
|
sendSystemMessage( self, SID_BANNED_FROM_THAT_CITY );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
LOG("LOG_CHANNEL", "arrival_planet ->" + arrival_planet + " arrival_point ->" + arrival_point);
|
|
|
|
// Check to see that the route is still valid
|
|
if (!travel.isValidRoute(depart_planet, depart_point, arrival_planet, arrival_point))
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- The route is no longer valid for " + ticket);
|
|
sendSystemMessage(self, new string_id(STF_FILE, "route_not_available")); // This ticket's route is no longer available."
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(callable.hasAnyCallable(self))
|
|
{
|
|
sendSystemMessage(self, new string_id("beast", "beast_cant_travel"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Check to see if there is restriction on using starport for interplanetary travel
|
|
if (!depart_planet.equals(arrival_planet))
|
|
{
|
|
const string departPlanetAvailableStarport = travel.getGcwTravelRestrictionsAvailableStarport(self, depart_planet);
|
|
if ((departPlanetAvailableStarport != null) && (departPlanetAvailableStarport.length() > 0) && (!departPlanetAvailableStarport.equals(depart_point)))
|
|
{
|
|
sendSystemMessage(self, "Because you are a GCW officer and the opposing faction currently controls the departure planet, the only starport currently available for interplanetary travel on the departure planet is " + departPlanetAvailableStarport + ".", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
const string arrivePlanetAvailableStarport = travel.getGcwTravelRestrictionsAvailableStarport(self, arrival_planet);
|
|
if ((arrivePlanetAvailableStarport != null) && (arrivePlanetAvailableStarport.length() > 0) && (!arrivePlanetAvailableStarport.equals(arrival_point)))
|
|
{
|
|
sendSystemMessage(self, "Because you are a GCW officer and the opposing faction currently controls the arrival planet, the only starport currently available for interplanetary travel on the arrival planet is " + arrivePlanetAvailableStarport + ".", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Display message letting player know that he has the GCW travel perk
|
|
if (qualifiesForGcwTravelPerks)
|
|
{
|
|
sendSystemMessage(self, "Bypassing the shuttle timer because you are a GCW officer and your faction currently controls the planet.", "");
|
|
}
|
|
|
|
// check for GCW travel restriction
|
|
if (travel.restrictedByGcwTravelRestrictions(self) && utils.hasScriptVar(starport, travel.SCRIPTVAR_SHUTTLE_AVAILABLE_COUNT))
|
|
{
|
|
int shuttleAvailableCount = utils.getIntScriptVar(starport, travel.SCRIPTVAR_SHUTTLE_AVAILABLE_COUNT);
|
|
|
|
// can only board every other shuttle
|
|
if ((shuttleAvailableCount % 2) == 1)
|
|
{
|
|
// display window giving player the option to either wait
|
|
// for the next shuttle or pay 50000 surcharge to skip
|
|
// the wait and board the current shuttle
|
|
if (utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID))
|
|
{
|
|
const int pid = utils.getIntScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
|
|
forceCloseSUIPage(pid);
|
|
}
|
|
|
|
// get how much time until the current shuttle departs
|
|
const int timeUntilCurrentShuttleDeparts = timeUntilMessageTo(shuttle, "msgShuttleTakeOff");
|
|
string announcement = "You must wait for the next shuttle because you are a GCW officer and the opposing faction currently controls the planet.\n\nOr you can pay a surcharge of 50000 credits to avoid the wait.\n\nWhat do you want to do?";
|
|
if (timeUntilCurrentShuttleDeparts >= 0)
|
|
announcement += "\n\n(The current shuttle will depart in " + (timeUntilCurrentShuttleDeparts / 60) + "m:" + (timeUntilCurrentShuttleDeparts % 60) + "s.)";
|
|
|
|
const int pid = sui.msgbox(self, self, announcement, sui.OK_CANCEL, "GCW Travel Restriction", sui.MSG_QUESTION, "handleConfirmGcwTravelRestrictionSkipShuttleWait");
|
|
sui.setSUIProperty(pid, sui.MSGBOX_BTN_CANCEL, sui.PROP_TEXT, "Wait");
|
|
sui.setSUIProperty(pid, sui.MSGBOX_BTN_OK, sui.PROP_TEXT, "Pay");
|
|
showSUIPage(pid);
|
|
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID, pid);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID, ticket);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID, shuttle);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Check to see if the player must pay a GCW travel restrictions surcharge
|
|
const int gcwTravelRestrictionsSurcharge = travel.getGcwTravelRestrictionsSurcharge(self, travel.getTicketDeparturePlanet(ticket), arrival_planet);
|
|
if (gcwTravelRestrictionsSurcharge > 0)
|
|
{
|
|
// display acceptance window
|
|
if (utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID))
|
|
{
|
|
const int pid = utils.getIntScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
|
|
forceCloseSUIPage(pid);
|
|
}
|
|
|
|
const int pid = sui.msgbox(self, self, "You must pay a surcharge of " + gcwTravelRestrictionsSurcharge + " credits because you are a GCW officer and the opposing faction currently controls either the departure or the arrival planet.\n\nDo you accept the surcharge?", sui.YES_NO, "GCW Travel Surcharge", sui.MSG_QUESTION, "handleConfirmGcwTravelSurcharge");
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID, pid);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID, ticket);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID, shuttle);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Store ticket data on player.
|
|
utils.setScriptVar(self, travel.VAR_DEPARTURE_PLANET, travel.getTicketDeparturePlanet(ticket));
|
|
utils.setScriptVar(self, travel.VAR_DEPARTURE_POINT, travel.getTicketDeparturePoint(ticket));
|
|
utils.setScriptVar(self, travel.VAR_ARRIVAL_PLANET, arrival_planet);
|
|
utils.setScriptVar(self, travel.VAR_ARRIVAL_POINT, arrival_point);
|
|
|
|
// Destroy the ticket and move the player to the destination
|
|
destroyObject(ticket);
|
|
travel.movePlayerToDestination(self, arrival_planet, arrival_point);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (hasObjVar(self, travel.VAR_TRAVEL))
|
|
removeObjVar(self, travel.VAR_TRAVEL);
|
|
|
|
if (utils.hasScriptVar(self, "travel.hasTicketList"))
|
|
utils.removeScriptVar(self, "travel.hasTicketList");
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgTravelToStarport()
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgTravelToStarport -- " + self + " " + params);
|
|
location loc = params.getLocation("location");
|
|
|
|
warpPlayer(self, loc.area, loc.x, loc.y, loc.z, null, 0.0f, 0.0f, 0.0f);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgSelectDungeonTicket()
|
|
{
|
|
string button = params.getString("buttonPressed");
|
|
if (button.equals("Cancel") || button.equals("No"))
|
|
{
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_VALID_TICKETS);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int row_selected = sui.getListboxSelectedRow(params);
|
|
if (row_selected != -1)
|
|
{
|
|
obj_id[] valid_tickets = utils.getObjIdArrayScriptVar(self, space_dungeon.SCRIPT_VAR_VALID_TICKETS);
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_VALID_TICKETS);
|
|
if (row_selected > valid_tickets.length)
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgSelectDungeonTicket -- row_selected was greater than the length of valid_tickets.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
obj_id ticket = valid_tickets[row_selected];
|
|
obj_id ticket_collector = space_dungeon.getDungeonTicketCollector(self, space_dungeon.getTicketPointName(ticket));
|
|
if (!isIdValid(ticket_collector))
|
|
{
|
|
sendSystemMessage(self, SID_NO_COLLECTOR);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
space_dungeon.activateDungeonTicket(self, ticket, ticket_collector);
|
|
}
|
|
else
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_VALID_TICKETS);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgDungeonTravelComplete()
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonTravelComplete -- " + self + " :" + space_dungeon.getDungeonSessionId(self));
|
|
// Get the player's ticket.
|
|
obj_id ticket = getObjIdObjVar(self, space_dungeon.VAR_TICKET_USED);
|
|
if (!isIdValid(ticket))
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonTravelComplete -- the ticket for " + self + " is invalid.");
|
|
CustomerServiceLog("travel", "Unable to claim dungeon ticket for " + getFirstName(self) + "(" + self + ").");
|
|
}
|
|
|
|
// Check to make sure the player is at the destination.
|
|
obj_id dungeon = space_dungeon.getDungeonIdForPlayer(self);
|
|
LOG("space_dungeon", "player_travel.msgDungeonTravelComplete -- dungeon ->" + dungeon + " (" + getTemplateName(dungeon) + ")");
|
|
if (!isIdValid(dungeon))
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonTravelComplete -- dungeon is invalid, player not in a dungeon.");
|
|
space_dungeon.cleanupPlayerTicketObjvars(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
string dungeon_name = space_dungeon.getDungeonName(dungeon);
|
|
if (dungeon_name == null || dungeon_name.length() < 1)
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonTravelComplete -- dungeon " + dungeon + " has no name. This may not be a dungeon.");
|
|
space_dungeon.cleanupPlayerTicketObjvars(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// check to see if there should be any scripts to be attached to the player.
|
|
string player_script = space_dungeon_data.getDungeonPlayerScript(dungeon_name);
|
|
LOG("space_dungeon", "player_travel.msgDungeonTravelComplete -- player_script :" + player_script);
|
|
if (player_script != null)
|
|
attachScript(self, player_script);
|
|
|
|
if (null != ticket)
|
|
{
|
|
string ticket_dungeon_name = space_dungeon.getTicketDungeonName(ticket);
|
|
|
|
// If the ticket and dungeon names match, we'll assume that the player got to the dungeon.
|
|
//LOG("LOG_CHANNEL", "ticket ->" + ticket + " dungeon_name ->" + dungeon_name + " ticket_dungeon_name ->" + ticket_dungeon_name);
|
|
if (dungeon_name.equals(ticket_dungeon_name))
|
|
{
|
|
//-- player can be used as his own ticket
|
|
if (!ticket.equals(self))
|
|
{
|
|
LOG("space_dungeon", self + " has reached dungeon " + dungeon + "(" + dungeon_name + "). Deleting ticket " + ticket);
|
|
destroyObject(ticket);
|
|
}
|
|
}
|
|
}
|
|
|
|
space_dungeon.cleanupPlayerTicketObjvars(self);
|
|
|
|
CustomerServiceLog("travel", getFirstName(self) + " (" + self + ") has traveled to dungeon " + dungeon_name);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgDungeonTravelConfirmed()
|
|
{
|
|
if (!utils.hasScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_PENDING) || !utils.hasScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_ID_PENDING))
|
|
{
|
|
if (hasObjVar(self, space_dungeon.VAR_SESSION_ID))
|
|
removeObjVar(self, space_dungeon.VAR_SESSION_ID);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string dungeon_name = utils.getStringScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_PENDING);
|
|
obj_id dungeon = utils.getObjIdScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_ID_PENDING);
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_PENDING);
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_ID_PENDING);
|
|
|
|
string button = params.getString("buttonPressed");
|
|
if (button.equals("Cancel"))
|
|
{
|
|
if (hasObjVar(self, space_dungeon.VAR_SESSION_ID))
|
|
removeObjVar(self, space_dungeon.VAR_SESSION_ID);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
location dungeon_position = new location();
|
|
if (utils.hasScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_POSITION))
|
|
{
|
|
dungeon_position = utils.getLocationScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_POSITION);
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_POSITION);
|
|
}
|
|
|
|
CustomerServiceLog("travel", getFirstName(self) + " (" + self + ") has initiated travel to dungeon " + dungeon_name);
|
|
space_dungeon.moveSinglePlayerIntoDungeon(self, dungeon, dungeon_name, dungeon_position);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgDungeonGroupTravelComplete()
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonGroupTravelComplete -- " + self + " :" + space_dungeon.getDungeonSessionId(self));
|
|
|
|
// Check to make sure the player is at the destination.
|
|
obj_id dungeon = space_dungeon.getDungeonIdForPlayer(self);
|
|
if (!isIdValid(dungeon))
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonGroupTravelComplete -- top most container is invalid, player not in a dungeon.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
string dungeon_name = space_dungeon.getDungeonName(dungeon);
|
|
if (dungeon_name == null || dungeon_name.length() < 1)
|
|
{
|
|
LOG("space_dungeon", "player_travel.msgDungeonGroupTravelComplete -- dungeon " + dungeon + " has no name. This may not be a dungeon.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// check to see if there should be any scripts to be attached to the player.
|
|
string player_script = space_dungeon_data.getDungeonPlayerScript(dungeon_name);
|
|
LOG("space_dungeon", "player_travel.msgDungeonGroupTravelComplete -- player_script :" + player_script);
|
|
if (player_script != null)
|
|
attachScript(self, player_script);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler msgCloseDungeonTravel()
|
|
{
|
|
if (utils.hasScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_PENDING) || utils.hasScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_ID_PENDING))
|
|
{
|
|
int pid = params.getInt("pid");
|
|
if (pid > -1)
|
|
sui.closeSUI(self, pid);
|
|
|
|
removeObjVar(self, space_dungeon.VAR_SESSION_ID);
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_PENDING);
|
|
utils.removeScriptVar(self, space_dungeon.SCRIPT_VAR_DUNGEON_ID_PENDING);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleConfirmGcwTravelSurcharge()
|
|
{
|
|
if (!utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const int pid = utils.getIntScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
|
|
const boolean acceptGcwSkipShuttleWaitSurcharge = utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED);
|
|
|
|
if (!utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const obj_id ticket = utils.getObjIdScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID);
|
|
|
|
if (!utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const obj_id shuttle = utils.getObjIdScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID);
|
|
|
|
if (!isIdValid(ticket) || !exists(ticket) || (utils.getContainingPlayer(ticket) != self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (!isIdValid(shuttle) || !exists(shuttle))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (pid != params.getInt("pageId"))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const int bp = sui.getIntButtonPressed(params);
|
|
if (bp == sui.BP_OK)
|
|
{
|
|
if (acceptGcwSkipShuttleWaitSurcharge)
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED, 1);
|
|
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_ACCEPTED, 1);
|
|
queueCommand(self, ##"boardShuttle", shuttle, ticket.toString(), COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleConfirmGcwTravelRestrictionSkipShuttleWait()
|
|
{
|
|
if (!utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const int pid = utils.getIntScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
|
|
if (!utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const obj_id ticket = utils.getObjIdScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID);
|
|
|
|
if (!utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const obj_id shuttle = utils.getObjIdScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID);
|
|
|
|
if (!isIdValid(ticket) || !exists(ticket) || (utils.getContainingPlayer(ticket) != self))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (!isIdValid(shuttle) || !exists(shuttle))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (pid != params.getInt("pageId"))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
const int bp = sui.getIntButtonPressed(params);
|
|
if (bp == sui.BP_OK)
|
|
{
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED, 1);
|
|
queueCommand(self, ##"boardShuttle", shuttle, ticket.toString(), COMMAND_PRIORITY_DEFAULT);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** COMMANDHANDLERS *************************************************/
|
|
commandHandler boardShuttle()
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::boardShuttle");
|
|
|
|
// see if the player has confirmed that he accepts the GCW surcharge
|
|
const boolean acceptGcwSkipShuttleWaitSurcharge = utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED);
|
|
|
|
const boolean acceptGcwSurcharge = utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_ACCEPTED);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_ACCEPTED);
|
|
|
|
if ( isIdValid (getMountId(self)))
|
|
{
|
|
LOG("LOG_CHANNEL", self + " -> PLAYER_TRAVEL - cmdHndlr boardShuttle - You cannot board the shuttle when mounted on a pet/vehicle?");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "no_pets")); // You cannot board the shuttle when you are riding on a pet or in a vehicle.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (travel.isTravelBlocked(self, false))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
// Target must be the shuttle or the pilot
|
|
if (target == null || target == obj_id.NULL_ID)
|
|
{
|
|
target = getLookAtTarget(self);
|
|
|
|
if (target == null)
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->What shuttle do you wish to board?");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "boarding_what_shuttle")); // What shuttle do you wish to board?
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if (travel.isTravelShuttlePilot(target))
|
|
{
|
|
// Find the shuttle
|
|
obj_id starport = travel.getStarportFromTerminal(target);
|
|
obj_id shuttle = travel.getShuttleFromStarport(starport);
|
|
if (shuttle == null || shuttle == obj_id.NULL_ID)
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->The shuttle is not available at this time.");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "shuttle_not_available")); // The shuttle is not available at this time.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
target = shuttle;
|
|
}
|
|
}
|
|
else if (!travel.isTravelShuttle(target))
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->What shuttle do you wish to board?");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "boarding_what_shuttle")); // What shuttle do you wish to board?
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (!travel.isInShuttleBoardingRange(self, target))
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::msgBoardShuttle -- " + self + " is too far from shuttle " + target);
|
|
sendSystemMessage(self, new string_id(STF_FILE, "boarding_too_far")); // You are too far from the shuttle to board.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Can't board if we are city banned.
|
|
int city_id = getCityAtLocation( getLocation(target), 0 );
|
|
if ( city.isCityBanned( self, city_id ) )
|
|
{
|
|
sendSystemMessage( self, SID_CANT_BOARD );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Check for a ticket
|
|
obj_id ticket = obj_id.NULL_ID;
|
|
if (params.length() > 0)
|
|
ticket = utils.stringToObjId(params);
|
|
|
|
string planet = getCurrentSceneName();
|
|
const obj_id starport = travel.getStarportFromTerminal(target);
|
|
|
|
// Make sure the shuttle is available
|
|
boolean qualifiesForGcwTravelPerks = false;
|
|
if (!travel.isShuttleAvailable(starport))
|
|
{
|
|
// see if the player qualifies to bypass the shuttle timer
|
|
qualifiesForGcwTravelPerks = travel.qualifiesForGcwTravelPerks(self);
|
|
|
|
if (!qualifiesForGcwTravelPerks)
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->The shuttle is not available at this time.");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "shuttle_not_available")); // The shuttle is not available at this time.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if (starport == null)
|
|
{
|
|
LOG("LOG_CHANNEL", "player.player_travel::OnBoardShuttle -- Unable to find the starport for " + target);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string depart_point = travel.getTravelPointName(starport);
|
|
|
|
if (ticket == null || ticket == obj_id.NULL_ID)
|
|
{
|
|
// Look through the player's inventory for valid tickets
|
|
resizeable string[] dsrc = new string[0];
|
|
resizeable obj_id[] valid_tickets = new obj_id[0];
|
|
obj_id inventory = getObjectInSlot(self, "inventory");
|
|
obj_id[] inv_contents = utils.getContents(inventory, false);
|
|
for (int i = 0; i < inv_contents.length; i++)
|
|
{
|
|
if (travel.isTravelTicketValid(inv_contents[i], planet, depart_point))
|
|
{
|
|
string ticket_planet = travel.getTicketArrivalPlanet(inv_contents[i]);
|
|
string ticket_point = travel.getTicketArrivalPoint(inv_contents[i]);
|
|
|
|
//if planet is kashyyyk_main switch to kashyyyk
|
|
if (ticket_planet == "kashyyyk_main")
|
|
{
|
|
ticket_planet = "kashyyyk";
|
|
}
|
|
// Make first letter of planet name upper case.
|
|
ticket_planet = ticket_planet.substring(0,1).toUpperCase() + ticket_planet.substring(1).toLowerCase();
|
|
|
|
prose_package ppLoc = prose.getPackage(SID_SUI_SELECT_DESTINATION_LOC);
|
|
prose.setTT(ppLoc, ticket_planet);
|
|
prose.setTO(ppLoc, ticket_point);
|
|
string loc = " \0" + packOutOfBandProsePackage(null, ppLoc);
|
|
dsrc = utils.addElement(dsrc, loc);
|
|
valid_tickets = utils.addElement(valid_tickets, inv_contents[i]);
|
|
}
|
|
}
|
|
if (dsrc.length < 1)
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->You do not have a ticket to board this shuttle.");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "no_ticket")); // You do not have a ticket to board this shuttle.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
// Don't display if the player already has a ticket select box.
|
|
if (!utils.hasScriptVar(self, "travel.hasTicketList"))
|
|
{
|
|
// Store list of valid tickets on player for the duration of the listbox.
|
|
setObjVar(self, travel.VAR_VALID_TICKETS, valid_tickets);
|
|
// Keep track of the shuttle
|
|
setObjVar(self, travel.VAR_BOARDING_SHUTTLE, target);
|
|
|
|
utils.setScriptVar(self, "travel.hasTicketList", 1);
|
|
|
|
// Display message letting player know that he has the GCW travel perk
|
|
if (qualifiesForGcwTravelPerks)
|
|
{
|
|
sendSystemMessage(self, "Bypassing the shuttle timer because you are a GCW officer and your faction currently controls the planet.", "");
|
|
}
|
|
|
|
// Display valid tickets in a listbox
|
|
sui.listbox(self, self, utils.packStringId(SID_SUI_SELECT_DESTINATION_TITLE), sui.OK_CANCEL, utils.packStringId(SID_SUI_SELECT_DESTINATION_HEADER), dsrc, "msgBoardShuttle");
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(self, new string_id(STF_FILE, "boarding_ticket_selection")); // You must select a ticket to use before boarding.
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!travel.isTravelTicketValid(ticket, planet, depart_point))
|
|
{
|
|
LOG("LOG_CHANNEL", self + " ->This ticket is not valid for the given shuttle.");
|
|
sendSystemMessage(self, new string_id(STF_FILE, "wrong_shuttle")); // You must select a ticket to use before boarding.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Get the arrival location from the ticket
|
|
string arrival_planet = travel.getTicketArrivalPlanet(ticket);
|
|
string arrival_point = travel.getTicketArrivalPoint(ticket);
|
|
|
|
// See if we are banned from the target city.
|
|
city_id = findCityByName( arrival_point );
|
|
if ( (city_id != 0) && cityExists( city_id ) && city.isCityBanned( self, city_id ) )
|
|
{
|
|
sendSystemMessage( self, SID_BANNED_FROM_THAT_CITY );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Check to see that the route is still valid
|
|
if (!travel.isValidRoute(planet, depart_point, arrival_planet, arrival_point))
|
|
{
|
|
LOG("LOG_CHANNEL", "player_travel::OnBoardShuttle -- The route is no longer valid for " + ticket);
|
|
sendSystemMessage(self, new string_id(STF_FILE, "route_not_available")); // This ticket's route is no longer available."
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(callable.hasAnyCallable(self))
|
|
{
|
|
sendSystemMessage(self, new string_id("beast", "beast_cant_travel"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Check to see if there is restriction on using starport for interplanetary travel
|
|
if (!planet.equals(arrival_planet))
|
|
{
|
|
const string departPlanetAvailableStarport = travel.getGcwTravelRestrictionsAvailableStarport(self, planet);
|
|
if ((departPlanetAvailableStarport != null) && (departPlanetAvailableStarport.length() > 0) && (!departPlanetAvailableStarport.equals(depart_point)))
|
|
{
|
|
sendSystemMessage(self, "Because you are a GCW officer and the opposing faction currently controls the departure planet, the only starport currently available for interplanetary travel on the departure planet is " + departPlanetAvailableStarport + ".", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
const string arrivePlanetAvailableStarport = travel.getGcwTravelRestrictionsAvailableStarport(self, arrival_planet);
|
|
if ((arrivePlanetAvailableStarport != null) && (arrivePlanetAvailableStarport.length() > 0) && (!arrivePlanetAvailableStarport.equals(arrival_point)))
|
|
{
|
|
sendSystemMessage(self, "Because you are a GCW officer and the opposing faction currently controls the arrival planet, the only starport currently available for interplanetary travel on the arrival planet is " + arrivePlanetAvailableStarport + ".", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// Display message letting player know that he has the GCW travel perk
|
|
if (qualifiesForGcwTravelPerks)
|
|
{
|
|
sendSystemMessage(self, "Bypassing the shuttle timer because you are a GCW officer and your faction currently controls the planet.", "");
|
|
}
|
|
|
|
// check for GCW travel restriction
|
|
int gcwTravelRestrictionsSkipWaitSurcharge = 0;
|
|
if (travel.restrictedByGcwTravelRestrictions(self) && utils.hasScriptVar(starport, travel.SCRIPTVAR_SHUTTLE_AVAILABLE_COUNT))
|
|
{
|
|
int shuttleAvailableCount = utils.getIntScriptVar(starport, travel.SCRIPTVAR_SHUTTLE_AVAILABLE_COUNT);
|
|
|
|
// can only board every other shuttle
|
|
if ((shuttleAvailableCount % 2) == 1)
|
|
{
|
|
// if the player hasn't already accepted the 50000 surcharge, display acceptance window
|
|
if (!acceptGcwSkipShuttleWaitSurcharge)
|
|
{
|
|
// display window giving player the option to either wait
|
|
// for the next shuttle or pay 50000 surcharge to skip
|
|
// the wait and board the current shuttle
|
|
if (utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID))
|
|
{
|
|
const int pid = utils.getIntScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
|
|
forceCloseSUIPage(pid);
|
|
}
|
|
|
|
// get how much time until the current shuttle departs
|
|
const int timeUntilCurrentShuttleDeparts = timeUntilMessageTo(target, "msgShuttleTakeOff");
|
|
string announcement = "You must wait for the next shuttle because you are a GCW officer and the opposing faction currently controls the planet.\n\nOr you can pay a surcharge of 50000 credits to avoid the wait.\n\nWhat do you want to do?";
|
|
if (timeUntilCurrentShuttleDeparts >= 0)
|
|
announcement += "\n\n(The current shuttle will depart in " + (timeUntilCurrentShuttleDeparts / 60) + "m:" + (timeUntilCurrentShuttleDeparts % 60) + "s.)";
|
|
|
|
const int pid = sui.msgbox(self, self, announcement, sui.OK_CANCEL, "GCW Travel Restriction", sui.MSG_QUESTION, "handleConfirmGcwTravelRestrictionSkipShuttleWait");
|
|
sui.setSUIProperty(pid, sui.MSGBOX_BTN_CANCEL, sui.PROP_TEXT, "Wait");
|
|
sui.setSUIProperty(pid, sui.MSGBOX_BTN_OK, sui.PROP_TEXT, "Pay");
|
|
showSUIPage(pid);
|
|
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID, pid);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID, ticket);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID, target);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
gcwTravelRestrictionsSkipWaitSurcharge = 50000;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Check to see if the player must pay a GCW travel restrictions surcharge
|
|
const int gcwTravelRestrictionsSurcharge = travel.getGcwTravelRestrictionsSurcharge(self, travel.getTicketDeparturePlanet(ticket), arrival_planet);
|
|
if (gcwTravelRestrictionsSurcharge > 0)
|
|
{
|
|
// If the player hasn't confirmed that he wants to accept the charge, display acceptance window
|
|
if (!acceptGcwSurcharge)
|
|
{
|
|
if (utils.hasScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID))
|
|
{
|
|
const int pid = utils.getIntScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
utils.removeScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID);
|
|
|
|
forceCloseSUIPage(pid);
|
|
}
|
|
|
|
if (gcwTravelRestrictionsSkipWaitSurcharge > 0)
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SKIP_SHUTTLE_WAIT_SURCHARGE_ACCEPTED, 1);
|
|
|
|
const int pid = sui.msgbox(self, self, "You must pay a surcharge of " + gcwTravelRestrictionsSurcharge + " credits because you are a GCW officer and the opposing faction currently controls either the departure or the arrival planet.\n\nDo you accept the surcharge?", sui.YES_NO, "GCW Travel Surcharge", sui.MSG_QUESTION, "handleConfirmGcwTravelSurcharge");
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SUI_ID, pid);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_TICKET_ID, ticket);
|
|
utils.setScriptVar(self, SCRIPTVAR_ACCEPT_GCW_SURCHARGE_SHUTTLE_ID, target);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
const int totalSurcharge = gcwTravelRestrictionsSkipWaitSurcharge + gcwTravelRestrictionsSurcharge;
|
|
if (totalSurcharge > 0)
|
|
{
|
|
// check to see if the player has the required credits
|
|
if (getTotalMoney(self) < totalSurcharge)
|
|
{
|
|
sendSystemMessage(self, "You do not have enough credits to pay the " + totalSurcharge + " credits GCW travel surcharge.", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
// if player doesn't have enough money in bank, transfer from cash into back to make up the difference
|
|
const int bankBalance = getBankBalance(self);
|
|
if (bankBalance < totalSurcharge)
|
|
{
|
|
depositCashToBank(self, (totalSurcharge - bankBalance), null, null, null);
|
|
if (getBankBalance(self) != totalSurcharge)
|
|
{
|
|
sendSystemMessage(self, "Could not transfer enough cash balance to bank balance to pay the " + totalSurcharge + " credits GCW travel surcharge.", "");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
// do the transfer
|
|
transferBankCreditsToNamedAccount(self, "GcwTravelSurcharge", totalSurcharge, null, null, null);
|
|
|
|
sendSystemMessage(self, "You have paid " + totalSurcharge + " credits GCW travel surcharge to the Galactic Travel Commission.", "");
|
|
}
|
|
}
|
|
|
|
// Store ticket data on player.
|
|
utils.setScriptVar(self, travel.VAR_DEPARTURE_PLANET, travel.getTicketDeparturePlanet(ticket));
|
|
utils.setScriptVar(self, travel.VAR_DEPARTURE_POINT, travel.getTicketDeparturePoint(ticket));
|
|
utils.setScriptVar(self, travel.VAR_ARRIVAL_PLANET, arrival_planet);
|
|
utils.setScriptVar(self, travel.VAR_ARRIVAL_POINT, arrival_point);
|
|
|
|
// Destroy the ticket and move the player.
|
|
destroyObject(ticket);
|
|
travel.movePlayerToDestination(self, arrival_planet, arrival_point);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** FUNCTIONS *******************************************************/
|
|
|
|
void debugLogging(string section, string message)
|
|
{
|
|
if (CONST_FLAG_DO_LOGGING)
|
|
LOG("debug/player_travel/"+section, message);
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
//----------------------------------------------------------------------
|
|
//----------------------------------------------------------------------
|
|
|
|
commandHandler callForPickup()
|
|
{
|
|
if (travel.isTravelBlocked(self, false))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( canCallForPickup(self))
|
|
{
|
|
debugLogging("//***// commandHandler : callForPickup", "////>>>> player CAN call for pickup. Executing shuttle spawn sequence.");
|
|
sendSystemMessage( self, SID_CALLING_FOR_PICKUP ); // calling in the pickup vehicle (spawning the instant travel terminal).
|
|
spawnPickupCraft(self, SHIP_TYPE_INSTANT_XWING_TIE);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
commandHandler callForPrivateerPickup()
|
|
{
|
|
debugLogging("//***// commandHandler : callForPickup", "////>>>> ENTERED");
|
|
|
|
if (travel.isTravelBlocked(self, false))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( canCallForPickup(self))
|
|
{
|
|
debugLogging("//***// commandHandler : callForPickup", "////>>>> player CAN call for pickup. Executing shuttle spawn sequence.");
|
|
sendSystemMessage( self, SID_CALLING_FOR_PICKUP ); // calling in the pickup vehicle (spawning the instant travel terminal).
|
|
spawnPickupCraft(self, SHIP_TYPE_INSTANT_PRIVATEER);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
commandHandler callForRattleTrapPickup()
|
|
{
|
|
debugLogging("//***// commandHandler : callForJunkPickup", "////>>>> ENTERED");
|
|
|
|
if (travel.isTravelBlocked(self, false))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( canCallForPickup(self))
|
|
{
|
|
debugLogging("//***// commandHandler : callForJunkPickup", "////>>>> player CAN call for pickup. Executing shuttle spawn sequence.");
|
|
sendSystemMessage( self, SID_CALLING_FOR_PICKUP ); // calling in the pickup vehicle (spawning the instant travel terminal).
|
|
spawnPickupCraft(self, SHIP_TYPE_INSTANT_JALOPY);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
commandHandler callForRoyalPickup()
|
|
{
|
|
debugLogging("//***// commandHandler : callForPickup", "////>>>> ENTERED");
|
|
|
|
if (travel.isTravelBlocked(self, false))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( canCallForPickup(self))
|
|
{
|
|
sendSystemMessage( self, SID_CALLING_FOR_PICKUP ); // calling in the pickup vehicle (spawning the instant travel terminal).
|
|
spawnPickupCraft(self, SHIP_TYPE_INSTANT_ROYAL_SHIP);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
commandHandler callForTcgHomePickup()
|
|
{
|
|
debugLogging("//***// commandHandler : callForPickup", "////>>>> ENTERED");
|
|
|
|
if (travel.isTravelBlocked(self, false))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if ( canCallForPickup(self))
|
|
{
|
|
sendSystemMessage( self, SID_CALLING_FOR_PICKUP ); // calling in the pickup vehicle (spawning the instant travel terminal).
|
|
spawnPickupCraft(self, SHIP_TYPE_TCG_HOME_SHIP);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
commandHandler callForTcgLocationPickup()
|
|
{
|
|
debugLogging("//***// commandHandler : callForPickup", "////>>>> ENTERED");
|
|
|
|
if (travel.isTravelBlocked(self, false))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( canCallForPickup(self))
|
|
{
|
|
sendSystemMessage( self, SID_CALLING_FOR_PICKUP ); // calling in the pickup vehicle (spawning the instant travel terminal).
|
|
spawnPickupCraft(self, SHIP_TYPE_TCG_LOCATION_SHIP);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
boolean canCallForPickup(obj_id player)
|
|
{
|
|
debugLogging("//***// canCallForPickup", "////>>>> ENTERED");
|
|
// Can't call for pickup when mounted.
|
|
obj_id playerCurrentMount = getMountId (player);
|
|
if ( isIdValid(playerCurrentMount))
|
|
{
|
|
sendSystemMessage(player, SID_INSTANT_MOUNT_NO);
|
|
return false;
|
|
}
|
|
|
|
if(isIdValid(structure.getContainingBuilding(player)))
|
|
{
|
|
sendSystemMessage( player, SID_LOCATION_INDOORS );
|
|
return false;
|
|
}
|
|
|
|
if (isSpaceScene())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (space_dungeon.verifyPlayerSession(player))
|
|
{
|
|
sendSystemMessage( player, SID_INVALID_PICKUP_LOC );
|
|
return false;
|
|
}
|
|
if(buff.hasBuff(player, ITV_PICKUP_BUFF))
|
|
{
|
|
sendSystemMessage(player, SID_PICKUP_CANCEL);
|
|
buff.removeBuff(player, ITV_PICKUP_BUFF);
|
|
return false;
|
|
}
|
|
|
|
location here = getLocation(player);
|
|
if (locations.isInCity(here))
|
|
{
|
|
sendSystemMessage( player, SID_NO_PICKUP_IN_TOWN );
|
|
return false;
|
|
}
|
|
|
|
// 10/02/13 Blocking in any region of geo type "city"
|
|
// This will take care of Aurilia as well as some other military outposts that have been bugged.
|
|
region geoCities[] = getRegionsWithGeographicalAtPoint(here, regions.GEO_CITY);
|
|
if(geoCities != null && geoCities.length > 0)
|
|
{
|
|
sendSystemMessage(player, SID_INVALID_PICKUP_LOC);
|
|
return false;
|
|
}
|
|
|
|
region[] regionList = getRegionsWithPvPAtPoint(here, regions.PVP_REGION_TYPE_ADVANCED);
|
|
|
|
if(regionList != null && regionList.length > 0)
|
|
{
|
|
sendSystemMessage(player, SID_NO_PICKUP_IN_PVP);
|
|
return false;
|
|
}
|
|
|
|
string planet = getCurrentSceneName();
|
|
if (planet.startsWith("kashyyyk") || planet.equals("adventure1"))
|
|
{
|
|
sendSystemMessage( player, SID_INVALID_PICKUP_LOC );
|
|
return false;
|
|
}
|
|
|
|
if(combat.isInCombat(player))
|
|
{
|
|
sendSystemMessage( player, SID_IN_COMBAT );
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
boolean spawnPickupCraft(obj_id player, int type)
|
|
{
|
|
if(!isIdValid(player))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
location here = getLocation(player);
|
|
location spawnLoc = locations.getGoodLocationAroundLocation(here, 1f, 1f, 4f, 4f);
|
|
if(spawnLoc == null)
|
|
{
|
|
sendSystemMessage( player, SID_LOCATION_NOGOOD_FOR_PICKUP ); // this location is no good for a pickup
|
|
return false;
|
|
}
|
|
|
|
string pickupCraftType = "object/tangible/terminal/terminal_travel_instant_xwing.iff"; //default is xwing
|
|
|
|
if(type == SHIP_TYPE_INSTANT_XWING_TIE)
|
|
{
|
|
// FIGURE OUT THE PLAYER'S FACTION AFFILIATION
|
|
int playerFactionID = pvpGetAlignedFaction(player);
|
|
|
|
// BASED UPON FACTIONAL AFFILIATION, SELECT WHAT KINDA SHIP TO SPAWN
|
|
|
|
// In the case the travel vehical is a vet reward we use the privateer ship
|
|
if(playerFactionID == ##"imperial")
|
|
{
|
|
pickupCraftType = "object/tangible/terminal/terminal_travel_instant_tie.iff"; // imperials get the tie
|
|
spawnLoc.y+= 5f; // TIE needs to float a bit because object origin is at middle of ship, and it would be 1/2 submerged in terrain if we don't elevate it at spawntime.
|
|
}
|
|
}
|
|
else if(type == SHIP_TYPE_INSTANT_PRIVATEER)
|
|
{
|
|
pickupCraftType = "object/tangible/terminal/terminal_travel_instant_privateer.iff";
|
|
}
|
|
else if(type == SHIP_TYPE_INSTANT_ROYAL_SHIP)
|
|
{
|
|
pickupCraftType = "object/tangible/terminal/terminal_travel_instant_royal_ship.iff";
|
|
}
|
|
|
|
if(type == SHIP_TYPE_INSTANT_JALOPY)
|
|
{
|
|
pickupCraftType = "object/tangible/terminal/terminal_travel_instant_jalopy.iff";
|
|
}
|
|
|
|
//TCG Item - Allows Player to Set Locations
|
|
if(type == SHIP_TYPE_TCG_LOCATION_SHIP)
|
|
{
|
|
pickupCraftType = "object/tangible/terminal/terminal_travel_instant_tcg_location.iff";
|
|
//play client effect:
|
|
playClientEffectObj(player, "sound/g9_rigger_01.snd", player, "");
|
|
}
|
|
//TCG Item - Takes the player to his Residence
|
|
if(type == SHIP_TYPE_TCG_HOME_SHIP)
|
|
{
|
|
pickupCraftType = "object/tangible/terminal/terminal_travel_instant_tcg_home.iff";
|
|
//play client effect:
|
|
playClientEffectObj(player, "sound/solar_sailer_01.snd", player, "");
|
|
}
|
|
|
|
obj_id pickupCraft = create.object(pickupCraftType, spawnLoc);
|
|
if(!isIdValid(pickupCraft))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
utils.setScriptVar(player,"instantTravelShip.pickupCraft",pickupCraft);
|
|
utils.setScriptVar(pickupCraft,"playerOwner",player);
|
|
|
|
messageTo(pickupCraft, "initializeInstaTravelShip", null, 1, false);
|
|
|
|
buff.applyBuff(player, ITV_PICKUP_BUFF);
|
|
return true;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
//----------------------------------------------------------------------
|
|
|
|
messageHandler groupMemberLocationRequestHandler()
|
|
{
|
|
obj_id terminal = params.getObjId("terminal");
|
|
obj_id requester = params.getObjId("requester");
|
|
if ( isIdValid(terminal) && isIdValid(requester) )
|
|
{
|
|
location groupieLoc = getLocation(self);
|
|
string groupieName = getName(self);
|
|
|
|
dictionary webster = new dictionary();
|
|
webster.put("requester", requester);
|
|
webster.put("groupieLoc", groupieLoc);
|
|
webster.put("groupieName", groupieName);
|
|
|
|
region[] regionsHere = getRegionsAtPoint(groupieLoc);
|
|
if ( regionsHere != null && regionsHere.length > 0 )
|
|
{
|
|
string[] groupieRegions = new string[regionsHere.length ];
|
|
for ( int i = 0; i < regionsHere.length; i++ )
|
|
{
|
|
region currentRegion = regionsHere[i];
|
|
groupieRegions[i] = currentRegion.getName();
|
|
}
|
|
webster.put("groupieRegions", groupieRegions);
|
|
}
|
|
|
|
messageTo(terminal, "groupMemberLocationResponseHandler", webster, 0, false);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
//----------------------------------------------------------------------
|