Files
dsrc/sku.0/sys.server/compiled/game/script/conversation/nexus_travel_away.script
T

694 lines
19 KiB
Plaintext

// ======================================================================
//
// nexus_travel_away.script
// Copyright 2004, Sony Online Entertainment
// All Rights Reserved.
//
// Created with SwgConversationEditor 1.36 - DO NOT EDIT THIS AUTO-GENERATED FILE!
//
// ======================================================================
// ======================================================================
// Library Includes
// ======================================================================
include library.ai_lib;
include library.chat;
include library.groundquests;
include library.money;
include library.sui;
include library.township;
include library.transition;
include library.utils;
// ======================================================================
// Script Constants
// ======================================================================
string c_stringFile = "conversation/nexus_travel_away";
// ======================================================================
// Script Conditions
// ======================================================================
boolean nexus_travel_away_condition__defaultCondition (obj_id player, obj_id npc)
{
return true;
}
// ----------------------------------------------------------------------
boolean nexus_travel_away_condition_hasFoundAurilia (obj_id player, obj_id npc)
{
return groundquests.hasCompletedQuest(player, "travel_found");
}
// ----------------------------------------------------------------------
boolean nexus_travel_away_condition_canAffordPay (obj_id player, obj_id npc)
{
return money.hasFunds(player, money.MT_TOTAL, township.TRAVEL_COST);
}
// ======================================================================
// Script Actions
// ======================================================================
void nexus_travel_away_action_travelFromAurilia (obj_id player, obj_id npc)
{
township.giveTravelListFromAurilia(player, npc);
}
// ----------------------------------------------------------------------
void nexus_travel_away_action_grantFoundAurilia (obj_id player, obj_id npc)
{
groundquests.grantQuest(player, "travel_found");
}
// ======================================================================
// Script %TO Tokens
// ======================================================================
// ======================================================================
// Script %DI Tokens
// ======================================================================
int nexus_travel_away_tokenDI_travelCost (obj_id player, obj_id npc)
{
return township.TRAVEL_COST;
}
// ======================================================================
// Script %DF Tokens
// ======================================================================
// ======================================================================
// handleBranch<n> Functions
// ======================================================================
int nexus_travel_away_handleBranch1 (obj_id player, obj_id npc, string_id response)
{
//-- [BRANCH NOTE]
//-- NPC: Hello, and welcome to Aurilia. I am the travel Liason for the township. I will notify all my counterparts across the galaxy so that you may now travel here via our charter system.
//-- [RESPONSE NOTE]
//-- PLAYER: How does that work?
if (response == "s_17")
{
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
//-- NPC: We have Aurilian contacts scattered around the galaxy. If you find one, they will be happy to shuttle you back here for a small fee.
string_id message = new string_id (c_stringFile, "s_18");
int numberOfResponses = 0;
boolean hasResponse = false;
//-- PLAYER: And what do you do?
boolean hasResponse0 = false;
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
if (hasResponse)
{
int responseIndex = 0;
string_id responses [] = new string_id [numberOfResponses];
if (hasResponse0)
responses [responseIndex++] = new string_id (c_stringFile, "s_20");
utils.setScriptVar (player, "conversation.nexus_travel_away.branchId", 2);
npcSpeak (player, message);
npcSetConversationResponses (player, responses);
}
else
{
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
npcEndConversationWithMessage (player, message);
}
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
// ----------------------------------------------------------------------
int nexus_travel_away_handleBranch2 (obj_id player, obj_id npc, string_id response)
{
//-- [BRANCH NOTE]
//-- NPC: We have Aurilian contacts scattered around the galaxy. If you find one, they will be happy to shuttle you back here for a small fee.
//-- [RESPONSE NOTE]
//-- PLAYER: And what do you do?
if (response == "s_20")
{
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
//-- NPC: You just come talk to me anytime you need transport from here.
string_id message = new string_id (c_stringFile, "s_26");
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
// ----------------------------------------------------------------------
int nexus_travel_away_handleBranch4 (obj_id player, obj_id npc, string_id response)
{
//-- [BRANCH NOTE]
//-- NPC: Ahh %TU, is there a place you would like me to take you?
//-- [RESPONSE NOTE]
//-- PLAYER: How much?
if (response == "s_12")
{
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
//-- NPC: Standard fee of %DI credits.
string_id message = new string_id (c_stringFile, "s_14");
int numberOfResponses = 0;
boolean hasResponse = false;
//-- PLAYER: Fine, I accept. Please tell me all the places I can go.
boolean hasResponse0 = false;
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
//-- PLAYER: On second thought, I will go there on my own.
boolean hasResponse1 = false;
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse1 = true;
}
if (hasResponse)
{
int responseIndex = 0;
string_id responses [] = new string_id [numberOfResponses];
if (hasResponse0)
responses [responseIndex++] = new string_id (c_stringFile, "s_22");
if (hasResponse1)
responses [responseIndex++] = new string_id (c_stringFile, "s_25");
utils.setScriptVar (player, "conversation.nexus_travel_away.branchId", 5);
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
pp.digitInteger = nexus_travel_away_tokenDI_travelCost (player, npc);
npcSpeak (player, pp);
npcSetConversationResponses (player, responses);
}
else
{
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
pp.digitInteger = nexus_travel_away_tokenDI_travelCost (player, npc);
npcEndConversationWithMessage (player, pp);
}
return SCRIPT_CONTINUE;
}
}
//-- [RESPONSE NOTE]
//-- PLAYER: No, not right now.
if (response == "s_30")
{
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
//-- NPC: As you wish.
string_id message = new string_id (c_stringFile, "s_32");
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
// ----------------------------------------------------------------------
int nexus_travel_away_handleBranch5 (obj_id player, obj_id npc, string_id response)
{
//-- [BRANCH NOTE]
//-- NPC: Standard fee of %DI credits.
//-- [RESPONSE NOTE]
//-- PLAYER: Fine, I accept. Please tell me all the places I can go.
if (response == "s_22")
{
//-- [NOTE]
if (!nexus_travel_away_condition_canAffordPay (player, npc))
{
//-- NPC: Well you need to come back when you have the money first.
string_id message = new string_id (c_stringFile, "s_19");
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
nexus_travel_away_action_travelFromAurilia (player, npc);
//-- NPC: Please choose where you would like to go.
string_id message = new string_id (c_stringFile, "s_24");
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
//-- [RESPONSE NOTE]
//-- PLAYER: On second thought, I will go there on my own.
if (response == "s_25")
{
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
//-- NPC: Come back if you ever need my services.
string_id message = new string_id (c_stringFile, "s_28");
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
// ----------------------------------------------------------------------
// ======================================================================
// User Script Triggers
// ======================================================================
messageHandler nexusTravelFromAurilliaSub()
{
if(params == null || params.isEmpty())
return SCRIPT_CONTINUE;
obj_id player = sui.getPlayerId(params);
int pageId = params.getInt("pageId");
if(!sui.hasPid(player, township.PID_VAR))
{
utils.removeScriptVarTree(player, "nexus.travel");
forceCloseSUIPage(pageId);
return SCRIPT_CONTINUE;
}
int pid = sui.getPid(player, township.PID_VAR);
if(pageId != pid)
{
forceCloseSUIPage(pageId);
forceCloseSUIPage(pid);
sui.removePid(player, township.PID_VAR);
utils.removeScriptVarTree(player, "nexus.travel");
return SCRIPT_CONTINUE;
}
int btn = sui.getIntButtonPressed(params);
int idx = sui.getListboxSelectedRow(params);
if(btn == sui.BP_CANCEL || idx < 0)
{
sui.removePid(player, township.PID_VAR);
utils.removeScriptVarTree(player, "nexus.travel");
return SCRIPT_CONTINUE;
}
string[] subGroups = utils.getStringArrayScriptVar(player, township.GROUPS_SCRIPT_VAR);
if(btn == sui.BP_OK)
{
sui.removePid(player, township.PID_VAR);
township.displayTravelListBySub(player, self, subGroups[idx]);
}
return SCRIPT_CONTINUE;
}
messageHandler nexusTravelFromAurillia()
{
if(params == null || params.isEmpty())
{
return SCRIPT_CONTINUE;
}
int btn = sui.getIntButtonPressed(params);
int idx = sui.getListboxSelectedRow(params);
int pageId = params.getInt("pageId");
obj_id player = sui.getPlayerId(params);
if(!sui.hasPid(player, township.PID_VAR))
{
utils.removeScriptVarTree(player, "nexus.travel");
forceCloseSUIPage(pageId);
return SCRIPT_CONTINUE;
}
int pid = sui.getPid(player, township.PID_VAR);
if(pageId != pid)
{
forceCloseSUIPage(pageId);
forceCloseSUIPage(pid);
sui.removePid(player, township.PID_VAR);
utils.removeScriptVarTree(player, "nexus.travel");
return SCRIPT_CONTINUE;
}
if(btn == sui.BP_CANCEL)
{
sui.removePid(player, township.PID_VAR);
utils.removeScriptVarTree(player, "nexus.travel");
return SCRIPT_CONTINUE;
}
if ( btn == sui.BP_REVERT )
{
township.giveTravelListFromAurilia(player, self);
return SCRIPT_CONTINUE;
}
if( idx < 0)
{
sui.removePid(player, township.PID_VAR);
utils.removeScriptVarTree(player, "nexus.travel");
return SCRIPT_CONTINUE;
}
location npcLoc = utils.getLocationScriptVar(player, "nexus.travel.npc_loc");
location playerLoc = getLocation(player);
string[] instances = utils.getStringArrayScriptVar(player, "nexus.travel.instances");
if(btn == sui.BP_OK)
{
if(!npcLoc.area.equals(playerLoc.area))
{
sendSystemMessage(self, new string_id("nexus", "travel_too_far"));
utils.removeScriptVarTree(player, "nexus.travel");
sui.removePid(player, township.PID_VAR);
return SCRIPT_CONTINUE;
}
if(getDistance(npcLoc, playerLoc) < 10)
{
dictionary d = new dictionary();
d.put("price", township.TRAVEL_COST);
d.put("player", player);
d.put("npc", self);
if(transition.hasPermissionForZone(player, instances[idx], "initialRequiredFlag"))
{
if(money.requestPayment(player, "aurillia_travel", township.TRAVEL_COST, "handleTransaction", d, true))
{
transition.zonePlayerNoGate(instances[idx], player, true);
}
}
else
{
transition.notifyPlayerOfInvalidPermission(player, instances[idx]);
}
}
else
sendSystemMessage(self, new string_id("nexus", "travel_too_far"));
utils.removeScriptVarTree(player, "nexus.travel");
}
utils.removeScriptVarTree(player, "nexus.travel");
sui.removePid(player, township.PID_VAR);
return SCRIPT_CONTINUE;
}
messageHandler handleTransaction()
{
if ( params == null || params.isEmpty() )
{
return SCRIPT_CONTINUE;
}
obj_id player = params.getObjId("player");
int price = params.getInt("price");
if ( !isIdValid(player) || price < 1 )
{
return SCRIPT_CONTINUE;
}
if ( params.getInt(money.DICT_CODE) == money.RET_FAIL )
{
chat.chat(self, player, new string_id("spam","no_money"));
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
trigger OnInitialize ()
{
if ((!isTangible (self)) || (isPlayer (self)))
detachScript(self, "conversation.nexus_travel_away");
setCondition (self, CONDITION_CONVERSABLE);
return SCRIPT_CONTINUE;
}
trigger OnAttach ()
{
setCondition (self, CONDITION_CONVERSABLE);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo)
{
int menu = menuInfo.addRootMenu (menu_info_types.CONVERSE_START, null);
menu_info_data menuInfoData = menuInfo.getMenuItemById (menu);
menuInfoData.setServerNotify (false);
setCondition (self, CONDITION_CONVERSABLE);
return SCRIPT_CONTINUE;
}
trigger OnIncapacitated (obj_id killer)
{
clearCondition (self, CONDITION_CONVERSABLE);
detachScript (self, "conversation.nexus_travel_away");
return SCRIPT_CONTINUE;
}
// ======================================================================
// Script Triggers
// ======================================================================
//-- This function should move to base_class.java
boolean npcStartConversation(obj_id player, obj_id npc, string convoName, string_id greetingId, prose_package greetingProse, string_id[] responses)
{
Object[] objects = new Object[responses.length];
System.arraycopy(responses, 0, objects, 0, responses.length);
return npcStartConversation(player, npc, convoName, greetingId, greetingProse, objects);
}
// ----------------------------------------------------------------------
trigger OnStartNpcConversation (obj_id player)
{
obj_id npc = self;
if (ai_lib.isInCombat (npc) || ai_lib.isInCombat (player))
return SCRIPT_OVERRIDE;
//-- [NOTE]
if (!nexus_travel_away_condition_hasFoundAurilia (player, npc))
{
nexus_travel_away_action_grantFoundAurilia (player, npc);
//-- NPC: Hello, and welcome to Aurilia. I am the travel Liason for the township. I will notify all my counterparts across the galaxy so that you may now travel here via our charter system.
string_id message = new string_id (c_stringFile, "s_15");
int numberOfResponses = 0;
boolean hasResponse = false;
//-- PLAYER: How does that work?
boolean hasResponse0 = false;
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
if (hasResponse)
{
int responseIndex = 0;
string_id responses [] = new string_id [numberOfResponses];
if (hasResponse0)
responses [responseIndex++] = new string_id (c_stringFile, "s_17");
utils.setScriptVar (player, "conversation.nexus_travel_away.branchId", 1);
npcStartConversation (player, npc, "nexus_travel_away", message, responses);
}
else
{
chat.chat (npc, player, message);
}
return SCRIPT_CONTINUE;
}
//-- [NOTE]
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
//-- NPC: Ahh %TU, is there a place you would like me to take you?
string_id message = new string_id (c_stringFile, "s_10");
int numberOfResponses = 0;
boolean hasResponse = false;
//-- PLAYER: How much?
boolean hasResponse0 = false;
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
//-- PLAYER: No, not right now.
boolean hasResponse1 = false;
if (nexus_travel_away_condition__defaultCondition (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse1 = true;
}
if (hasResponse)
{
int responseIndex = 0;
string_id responses [] = new string_id [numberOfResponses];
if (hasResponse0)
responses [responseIndex++] = new string_id (c_stringFile, "s_12");
if (hasResponse1)
responses [responseIndex++] = new string_id (c_stringFile, "s_30");
utils.setScriptVar (player, "conversation.nexus_travel_away.branchId", 4);
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
npcStartConversation (player, npc, "nexus_travel_away", null, pp, responses);
}
else
{
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
chat.chat (npc, player, null, null, pp);
}
return SCRIPT_CONTINUE;
}
chat.chat (npc, "Error: All conditions for OnStartNpcConversation were false.");
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
trigger OnNpcConversationResponse (string conversationId, obj_id player, string_id response)
{
if (conversationId != "nexus_travel_away")
return SCRIPT_CONTINUE;
obj_id npc = self;
int branchId = utils.getIntScriptVar (player, "conversation.nexus_travel_away.branchId");
if (branchId == 1 && nexus_travel_away_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE)
return SCRIPT_CONTINUE;
if (branchId == 2 && nexus_travel_away_handleBranch2 (player, npc, response) == SCRIPT_CONTINUE)
return SCRIPT_CONTINUE;
if (branchId == 4 && nexus_travel_away_handleBranch4 (player, npc, response) == SCRIPT_CONTINUE)
return SCRIPT_CONTINUE;
if (branchId == 5 && nexus_travel_away_handleBranch5 (player, npc, response) == SCRIPT_CONTINUE)
return SCRIPT_CONTINUE;
chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse.");
utils.removeScriptVar (player, "conversation.nexus_travel_away.branchId");
return SCRIPT_CONTINUE;
}
// ======================================================================