mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
627 lines
17 KiB
Plaintext
627 lines
17 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// nexus_travel.script
|
|
//
|
|
//
|
|
//
|
|
// 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";
|
|
|
|
// ======================================================================
|
|
// Script Conditions
|
|
// ======================================================================
|
|
|
|
boolean nexus_travel_condition__defaultCondition (obj_id player, obj_id npc)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nexus_travel_condition_isEligible (obj_id player, obj_id npc)
|
|
{
|
|
return township.isTownshipEligible(player);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nexus_travel_condition_hasMet (obj_id player, obj_id npc)
|
|
{
|
|
if(hasObjVar(player, "towship.metTravel") && nexus_travel_condition_isEligible(player, npc))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nexus_travel_condition_hasFoundAurillia (obj_id player, obj_id npc)
|
|
{
|
|
return groundquests.hasCompletedQuest(player, "travel_found");
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nexus_travel_condition_canAffordPay (obj_id player, obj_id npc)
|
|
{
|
|
return money.hasFunds(player, money.MT_TOTAL, township.TRAVEL_COST);
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script Actions
|
|
// ======================================================================
|
|
|
|
void nexus_travel_action_travelAurillia (obj_id player, obj_id npc)
|
|
{
|
|
string prompt = utils.packStringId(new string_id("nexus", "shuttle_to_aurillia_prompt"));
|
|
string title = utils.packStringId(new string_id("nexus", "shuttle_to_aurillia_title"));
|
|
location npcLoc = getLocation(npc);
|
|
utils.setScriptVar(player, "nexus.travel.npc_loc", npcLoc);
|
|
utils.setScriptVar(player, "nexus.travel.pid", true);
|
|
|
|
int pid = sui.msgbox(npc, player, prompt, sui.OK_CANCEL, title, 0, "nexusTravelAurillia");
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
void nexus_travel_action_setMet (obj_id player, obj_id npc)
|
|
{
|
|
setObjVar(player, "towship.metTravel", true);
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script %TO Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Script %DI Tokens
|
|
// ======================================================================
|
|
|
|
int nexus_travel_tokenDI_travelCost (obj_id player, obj_id npc)
|
|
{
|
|
return township.TRAVEL_COST;
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script %DF Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// handleBranch<n> Functions
|
|
// ======================================================================
|
|
|
|
int nexus_travel_handleBranch1 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: I am sorry, we cannot do business just yet. You must speak with my counterpart in Aurilia first.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Where do I find them?
|
|
if (response == "s_27")
|
|
{
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Search the wilds of Dathomir. If you are strong enough, traverse the fog.
|
|
string_id message = new string_id (c_stringFile, "s_28");
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int nexus_travel_handleBranch3 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Welcome %TU. Would you like another ride back to Aurilia? It will still cost you 2500 credits.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Fine, I accept. Please take me there.
|
|
if (response == "s_9")
|
|
{
|
|
//-- [NOTE]
|
|
if (!nexus_travel_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_24");
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
nexus_travel_action_travelAurillia (player, npc);
|
|
|
|
//-- NPC: Let's be off then.
|
|
string_id message = new string_id (c_stringFile, "s_12");
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int nexus_travel_handleBranch6 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: I hear you may be interested in getting a charter flight to Aurilia. I can do this for you for a small fee.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: How much, and how do you know I would like to go there.
|
|
if (response == "s_16")
|
|
{
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
nexus_travel_action_setMet (player, npc);
|
|
|
|
//-- NPC: %DI credits.
|
|
string_id message = new string_id (c_stringFile, "s_18");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Fine, I accept. Please take me there.
|
|
boolean hasResponse0 = false;
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: That is outrageous! I don't know who you are, please leave me be.
|
|
boolean hasResponse1 = false;
|
|
if (nexus_travel_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_23");
|
|
|
|
utils.setScriptVar (player, "conversation.nexus_travel.branchId", 7);
|
|
|
|
prose_package pp = new prose_package ();
|
|
pp.stringId = message;
|
|
pp.actor.set (player);
|
|
pp.target.set (npc);
|
|
pp.digitInteger = nexus_travel_tokenDI_travelCost (player, npc);
|
|
|
|
npcSpeak (player, pp);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
prose_package pp = new prose_package ();
|
|
pp.stringId = message;
|
|
pp.actor.set (player);
|
|
pp.target.set (npc);
|
|
pp.digitInteger = nexus_travel_tokenDI_travelCost (player, npc);
|
|
|
|
npcEndConversationWithMessage (player, pp);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int nexus_travel_handleBranch7 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: %DI credits.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Fine, I accept. Please take me there.
|
|
if (response == "s_22")
|
|
{
|
|
//-- [NOTE]
|
|
if (!nexus_travel_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_24");
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
nexus_travel_action_travelAurillia (player, npc);
|
|
|
|
//-- NPC: Let's be off then.
|
|
string_id message = new string_id (c_stringFile, "s_12");
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: That is outrageous! I don't know who you are, please leave me be.
|
|
if (response == "s_23")
|
|
{
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Bah! come back when you are ready then.
|
|
string_id message = new string_id (c_stringFile, "s_26");
|
|
utils.removeScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// ======================================================================
|
|
// User Script Triggers
|
|
// ======================================================================
|
|
|
|
messageHandler nexusTravelAurillia()
|
|
{
|
|
|
|
int btn = sui.getIntButtonPressed(params);
|
|
obj_id player = sui.getPlayerId(params);
|
|
location npcLoc = utils.getLocationScriptVar(player, "nexus.travel.npc_loc");
|
|
location playerLoc = getLocation(player);
|
|
|
|
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");
|
|
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, "aurillia_township", "initialRequiredFlag"))
|
|
{
|
|
if(money.requestPayment(player, "aurillia_travel", township.TRAVEL_COST, "handleTransaction", d, true))
|
|
{
|
|
transition.zonePlayerNoGate("aurillia_township", player, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
transition.notifyPlayerOfInvalidPermission(player, "aurillia_township");
|
|
}
|
|
}
|
|
else
|
|
sendSystemMessage(self, new string_id("nexus", "travel_too_far"));
|
|
|
|
utils.removeScriptVarTree(player, "nexus.travel");
|
|
}
|
|
if(btn == sui.BP_CANCEL)
|
|
utils.removeScriptVarTree(player, "nexus.travel");
|
|
|
|
utils.removeScriptVarTree(player, "nexus.travel");
|
|
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");
|
|
|
|
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");
|
|
|
|
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_condition_hasFoundAurillia (player, npc))
|
|
{
|
|
//-- NPC: I am sorry, we cannot do business just yet. You must speak with my counterpart in Aurilia first.
|
|
string_id message = new string_id (c_stringFile, "s_19");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Where do I find them?
|
|
boolean hasResponse0 = false;
|
|
if (nexus_travel_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_27");
|
|
|
|
utils.setScriptVar (player, "conversation.nexus_travel.branchId", 1);
|
|
|
|
npcStartConversation (player, npc, "nexus_travel", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat (npc, player, message);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition_hasMet (player, npc))
|
|
{
|
|
//-- NPC: Welcome %TU. Would you like another ride back to Aurilia? It will still cost you 2500 credits.
|
|
string_id message = new string_id (c_stringFile, "s_7");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Fine, I accept. Please take me there.
|
|
boolean hasResponse0 = false;
|
|
if (nexus_travel_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_9");
|
|
|
|
utils.setScriptVar (player, "conversation.nexus_travel.branchId", 3);
|
|
|
|
prose_package pp = new prose_package ();
|
|
pp.stringId = message;
|
|
pp.actor.set (player);
|
|
pp.target.set (npc);
|
|
|
|
npcStartConversation (player, npc, "nexus_travel", 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;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition_isEligible (player, npc))
|
|
{
|
|
//-- NPC: I hear you may be interested in getting a charter flight to Aurilia. I can do this for you for a small fee.
|
|
string_id message = new string_id (c_stringFile, "s_14");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: How much, and how do you know I would like to go there.
|
|
boolean hasResponse0 = false;
|
|
if (nexus_travel_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_16");
|
|
|
|
utils.setScriptVar (player, "conversation.nexus_travel.branchId", 6);
|
|
|
|
npcStartConversation (player, npc, "nexus_travel", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat (npc, player, message);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nexus_travel_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: You are not quite ready for our purposes.
|
|
string_id message = new string_id (c_stringFile, "s_30");
|
|
chat.chat (npc, player, message);
|
|
|
|
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")
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id npc = self;
|
|
|
|
int branchId = utils.getIntScriptVar (player, "conversation.nexus_travel.branchId");
|
|
|
|
if (branchId == 1 && nexus_travel_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 3 && nexus_travel_handleBranch3 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 6 && nexus_travel_handleBranch6 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 7 && nexus_travel_handleBranch7 (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.branchId");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// ======================================================================
|
|
|