Files
dsrc/sku.0/sys.server/compiled/game/script/conversation/barn_ranchhand.script
T
2013-09-10 23:17:15 -07:00

580 lines
16 KiB
Plaintext

// ======================================================================
//
// barn_ranchhand.script
// Copyright 2004, Sony Online Entertainment
// All Rights Reserved.
//
// Created with SwgConversationEditor 1.37 - DO NOT EDIT THIS AUTO-GENERATED FILE!
//
// ======================================================================
// ======================================================================
// Library Includes
// ======================================================================
include library.ai_lib;
include library.beast_lib;
include library.callable;
include library.chat;
include library.conversation;
include library.player_structure;
include library.tcg;
include library.utils;
// ======================================================================
// Script Constants
// ======================================================================
string c_stringFile = "conversation/barn_ranchhand";
// ======================================================================
// Script Conditions
// ======================================================================
boolean barn_ranchhand_condition__defaultCondition (obj_id player, obj_id npc)
{
return true;
}
// ----------------------------------------------------------------------
boolean barn_ranchhand_condition_isBuildingOwner (obj_id player, obj_id npc)
{
obj_id building = getTopMostContainer(npc);
if ( isIdValid(building) )
{
obj_id owner = getOwner(building);
if ( isIdValid(owner) && owner == player )
{
return true;
}
}
return false;
}
// ----------------------------------------------------------------------
boolean barn_ranchhand_condition_playerHasBeasts (obj_id player, obj_id npc)
{
// if ( beast_lib.isBeastMaster(player) )
// {
if ( beast_lib.getTotalBeastControlDevices(player) > 0 )
{
return true;
}
// }
return false;
}
// ----------------------------------------------------------------------
boolean barn_ranchhand_condition_ranchhandHasBeasts (obj_id player, obj_id npc)
{
// if ( beast_lib.isBeastMaster(player) )
// {
if ( tcg.getTotalBarnStoredBeastsFromRanchhand(npc) > 0 )
{
return true;
}
// }
return false;
}
// ----------------------------------------------------------------------
boolean barn_ranchhand_condition_noBeasts (obj_id player, obj_id npc)
{
//if ( beast_lib.isBeastMaster(player) )
// {
if ( beast_lib.getTotalBeastControlDevices(player) > 0 || tcg.getTotalBarnStoredBeastsFromRanchhand(npc) > 0 )
{
return false;
}
// }
return true;
}
// ----------------------------------------------------------------------
boolean barn_ranchhand_condition_barnIsFull (obj_id player, obj_id npc)
{
return tcg.getTotalBarnStoredBeastsFromRanchhand(npc) >= tcg.MAX_NUM_BARN_PETS;
}
// ----------------------------------------------------------------------
boolean barn_ranchhand_condition_playerIsFull (obj_id player, obj_id npc)
{
return callable.hasMaxStoredCombatPets(player);
}
// ======================================================================
// Script Actions
// ======================================================================
void barn_ranchhand_action_storeBeast (obj_id player, obj_id npc)
{
tcg.barnStoreBeastPrompt(player, npc);
return;
}
// ----------------------------------------------------------------------
void barn_ranchhand_action_reclaimBeast (obj_id player, obj_id npc)
{
obj_id barn = getTopMostContainer(npc);
if( isIdValid(barn) )
{
tcg.barnReclaimBeastPrompt(player, barn, npc);
}
return;
}
// ----------------------------------------------------------------------
void barn_ranchhand_action_displayBeast (obj_id player, obj_id npc)
{
obj_id barn = getTopMostContainer(npc);
if( isIdValid(barn) )
{
tcg.barnDisplayBeastPrompt(player, barn, npc);
}
return;
}
// ======================================================================
// Script %TO Tokens
// ======================================================================
string barn_ranchhand_tokenTO_barnOwnerNamePossessive (obj_id player, obj_id npc)
{
string name = "the";
obj_id building = getTopMostContainer(npc);
if ( isIdValid(building) )
{
string buildingOwnerName = getStringObjVar(building, player_structure.VAR_OWNER);
if ( buildingOwnerName != null && buildingOwnerName.length() > 0 )
{
name = "" + toUpper(buildingOwnerName, 0) + "'s";
}
}
return name;
}
// ----------------------------------------------------------------------
string barn_ranchhand_tokenTO_barnOwnerName (obj_id player, obj_id npc)
{
string name = "Sir";
if ( getGender(player) == GENDER_FEMALE )
{
name = "Ma'am";
}
obj_id building = getTopMostContainer(npc);
if ( isIdValid(building) )
{
string buildingOwnerName = getStringObjVar(building, player_structure.VAR_OWNER);
if ( buildingOwnerName != null && buildingOwnerName.length() > 0 )
{
name = toUpper(buildingOwnerName, 0);
}
}
return name;
}
// ======================================================================
// Script %DI Tokens
// ======================================================================
// ======================================================================
// Script %DF Tokens
// ======================================================================
// ======================================================================
// handleBranch<n> Functions
// ======================================================================
int barn_ranchhand_handleBranch1 (obj_id player, obj_id npc, string_id response)
{
//-- [BRANCH NOTE]
//-- NPC: Greetings and salutations, %TO! Always a pleasure when you visit us here at your barn.
//-- [RESPONSE NOTE]
//-- PLAYER: I would like to store one of my beasts.
if (response == "s_6")
{
//-- [NOTE]
if (barn_ranchhand_condition_barnIsFull (player, npc))
{
//-- NPC: I'm afraid we've no more room in the barn. It's quite crowded in here as it is and would only get worse with even more creatures.
string_id message = new string_id (c_stringFile, "s_27");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
//-- [NOTE]
if (barn_ranchhand_condition__defaultCondition (player, npc))
{
barn_ranchhand_action_storeBeast (player, npc);
//-- NPC: Oh sure, sure. That's what this here barn is for.
string_id message = new string_id (c_stringFile, "s_9");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
//-- [RESPONSE NOTE]
//-- PLAYER: I would like to reclaim one of my beasts.
if (response == "s_11")
{
//-- [NOTE]
if (barn_ranchhand_condition_playerIsFull (player, npc))
{
//-- NPC: Begging your pardon, but you don't seem to have room for another beast at the moment.
string_id message = new string_id (c_stringFile, "s_28");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
//-- [NOTE]
if (barn_ranchhand_condition__defaultCondition (player, npc))
{
barn_ranchhand_action_reclaimBeast (player, npc);
//-- NPC: As you want it. Just let me know which one.
string_id message = new string_id (c_stringFile, "s_14");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
//-- [RESPONSE NOTE]
//-- PLAYER: Perhaps some of my beasts could wander around in the barn.
if (response == "s_19")
{
//-- [NOTE]
if (barn_ranchhand_condition__defaultCondition (player, npc))
{
barn_ranchhand_action_displayBeast (player, npc);
//-- NPC: As you wish it. And don't worry...I'll clean up any messes these critters make. Which did you have in mind?
string_id message = new string_id (c_stringFile, "s_20");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
//-- [RESPONSE NOTE]
//-- PLAYER: Thank you. And...um...keep up the good work.
if (response == "s_23")
{
//-- [NOTE]
if (barn_ranchhand_condition__defaultCondition (player, npc))
{
//-- NPC: Oh, I'll not let you down. No chance.
string_id message = new string_id (c_stringFile, "s_24");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
// ----------------------------------------------------------------------
int barn_ranchhand_handleBranch8 (obj_id player, obj_id npc, string_id response)
{
//-- [BRANCH NOTE]
//-- NPC: Welcome to %TO barn! Mind you don't step in anything.
//-- [RESPONSE NOTE]
//-- PLAYER: Thank you.
if (response == "s_26")
{
//-- [NOTE]
if (barn_ranchhand_condition__defaultCondition (player, npc))
{
//-- NPC: You're welcome.
string_id message = new string_id (c_stringFile, "s_30");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
npcEndConversationWithMessage (player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
// ----------------------------------------------------------------------
// ======================================================================
// User Script Triggers
// ======================================================================
trigger OnInitialize ()
{
if ((!isTangible (self)) || (isPlayer (self)))
detachScript(self, "conversation.barn_ranchhand");
setCondition (self, CONDITION_CONVERSABLE);
if ( !hasScript(self, tcg.BARN_RANCHHAND_SCRIPT) )
{
attachScript(self, tcg.BARN_RANCHHAND_SCRIPT);
}
return SCRIPT_CONTINUE;
}
trigger OnAttach ()
{
setCondition (self, CONDITION_CONVERSABLE);
if ( !hasScript(self, tcg.BARN_RANCHHAND_SCRIPT) )
{
attachScript(self, tcg.BARN_RANCHHAND_SCRIPT);
}
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);
faceTo(self, player);
return SCRIPT_CONTINUE;
}
trigger OnIncapacitated (obj_id killer)
{
clearCondition (self, CONDITION_CONVERSABLE);
detachScript (self, "conversation.barn_ranchhand");
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 (barn_ranchhand_condition_isBuildingOwner (player, npc))
{
//-- NPC: Greetings and salutations, %TO! Always a pleasure when you visit us here at your barn.
string_id message = new string_id (c_stringFile, "s_4");
int numberOfResponses = 0;
boolean hasResponse = false;
//-- PLAYER: I would like to store one of my beasts.
boolean hasResponse0 = false;
if (barn_ranchhand_condition_playerHasBeasts (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
//-- PLAYER: I would like to reclaim one of my beasts.
boolean hasResponse1 = false;
if (barn_ranchhand_condition_ranchhandHasBeasts (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse1 = true;
}
//-- PLAYER: Perhaps some of my beasts could wander around in the barn.
boolean hasResponse2 = false;
if (barn_ranchhand_condition_ranchhandHasBeasts (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse2 = true;
}
//-- PLAYER: Thank you. And...um...keep up the good work.
boolean hasResponse3 = false;
if (barn_ranchhand_condition_noBeasts (player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse3 = true;
}
if (hasResponse)
{
int responseIndex = 0;
string_id responses [] = new string_id [numberOfResponses];
if (hasResponse0)
responses [responseIndex++] = new string_id (c_stringFile, "s_6");
if (hasResponse1)
responses [responseIndex++] = new string_id (c_stringFile, "s_11");
if (hasResponse2)
responses [responseIndex++] = new string_id (c_stringFile, "s_19");
if (hasResponse3)
responses [responseIndex++] = new string_id (c_stringFile, "s_23");
utils.setScriptVar (player, "conversation.barn_ranchhand.branchId", 1);
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
pp.other.set (barn_ranchhand_tokenTO_barnOwnerName (player, npc));
npcStartConversation (player, npc, "barn_ranchhand", null, pp, responses);
}
else
{
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
pp.other.set (barn_ranchhand_tokenTO_barnOwnerName (player, npc));
chat.chat (npc, player, null, null, pp);
}
return SCRIPT_CONTINUE;
}
//-- [NOTE]
if (barn_ranchhand_condition__defaultCondition (player, npc))
{
//-- NPC: Welcome to %TO barn! Mind you don't step in anything.
string_id message = new string_id (c_stringFile, "s_22");
int numberOfResponses = 0;
boolean hasResponse = false;
//-- PLAYER: Thank you.
boolean hasResponse0 = false;
if (barn_ranchhand_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_26");
utils.setScriptVar (player, "conversation.barn_ranchhand.branchId", 8);
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
pp.other.set (barn_ranchhand_tokenTO_barnOwnerNamePossessive (player, npc));
npcStartConversation (player, npc, "barn_ranchhand", null, pp, responses);
}
else
{
prose_package pp = new prose_package ();
pp.stringId = message;
pp.actor.set (player);
pp.target.set (npc);
pp.other.set (barn_ranchhand_tokenTO_barnOwnerNamePossessive (player, 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 != "barn_ranchhand")
return SCRIPT_CONTINUE;
obj_id npc = self;
int branchId = utils.getIntScriptVar (player, "conversation.barn_ranchhand.branchId");
if (branchId == 1 && barn_ranchhand_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE)
return SCRIPT_CONTINUE;
if (branchId == 8 && barn_ranchhand_handleBranch8 (player, npc, response) == SCRIPT_CONTINUE)
return SCRIPT_CONTINUE;
chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse.");
utils.removeScriptVar (player, "conversation.barn_ranchhand.branchId");
return SCRIPT_CONTINUE;
}
// ======================================================================