mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-09 00:12:57 -04:00
412 lines
12 KiB
Plaintext
412 lines
12 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// nym_anniversary_dispenser.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.static_item;
|
|
include library.utils;
|
|
|
|
// ======================================================================
|
|
// Script Constants
|
|
// ======================================================================
|
|
|
|
string c_stringFile = "conversation/nym_anniversary_dispenser";
|
|
|
|
// ======================================================================
|
|
// Script Conditions
|
|
// ======================================================================
|
|
|
|
boolean nym_anniversary_dispenser_condition__defaultCondition (obj_id player, obj_id npc)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nym_anniversary_dispenser_condition_notEligable (obj_id player, obj_id npc)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nym_anniversary_dispenser_condition_newRewardEligable (obj_id player, obj_id npc)
|
|
{
|
|
if(hasObjVar(player, "event.last_timed_reward"))
|
|
{
|
|
float lastRewardTime = getFloatObjVar(player, "event.last_timed_reward");
|
|
float rightNow = getGameTime();
|
|
|
|
if(rightNow - lastRewardTime > 3600)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean nym_anniversary_dispenser_condition_firstRewardEligable (obj_id player, obj_id npc)
|
|
{
|
|
if(!hasObjVar(player, "event.last_timed_reward"))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script Actions
|
|
// ======================================================================
|
|
|
|
void nym_anniversary_dispenser_action_randomReward (obj_id player, obj_id npc)
|
|
{
|
|
string[] itemList = { "item_event_dance_party_device_03_01",
|
|
"item_event_firework_show_04_01",
|
|
"item_event_air_cake_01_02",
|
|
"item_event_energy_drink_01_02"
|
|
};
|
|
|
|
string itemName = itemList[rand(0, itemList.length)];
|
|
obj_id reward = null;
|
|
obj_id playerInventory = utils.getInventoryContainer(player);
|
|
|
|
if(rand(1, 15) != 15)
|
|
{
|
|
reward = static_item.createNewItemFunction(itemName, playerInventory);
|
|
}
|
|
else
|
|
{
|
|
reward = createObject("object/tangible/furniture/decorative/30th_anniversary_painting_01.iff", playerInventory, "");
|
|
}
|
|
|
|
if(exists(reward) && isIdValid(reward))
|
|
{
|
|
float rightNow = getGameTime();
|
|
setObjVar(player, "event.last_timed_reward", rightNow);
|
|
}
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script %TO Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Script %DI Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Script %DF Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// handleBranch<n> Functions
|
|
// ======================================================================
|
|
|
|
int nym_anniversary_dispenser_handleBranch1 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Hey hey! Coming to the celebration? Well either way, Nym wants to make sure everyone has a good time! I've got a bunch of party favors to give out to keep everyone in the spirit.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Hey, that sounds great!
|
|
if (response == "s_6")
|
|
{
|
|
//-- [NOTE]
|
|
if (nym_anniversary_dispenser_condition__defaultCondition (player, npc))
|
|
{
|
|
nym_anniversary_dispenser_action_randomReward (player, npc);
|
|
|
|
//-- NPC: Here ya go!
|
|
string_id message = new string_id (c_stringFile, "s_9");
|
|
utils.removeScriptVar (player, "conversation.nym_anniversary_dispenser.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int nym_anniversary_dispenser_handleBranch3 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Back again I see. Hope you're having a good time! I have plenty of gifts left if you want another one.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Sure, what else do you have for me?
|
|
if (response == "s_12")
|
|
{
|
|
//-- [NOTE]
|
|
if (nym_anniversary_dispenser_condition__defaultCondition (player, npc))
|
|
{
|
|
nym_anniversary_dispenser_action_randomReward (player, npc);
|
|
|
|
//-- NPC: Here ya go, try one of these.
|
|
string_id message = new string_id (c_stringFile, "s_14");
|
|
utils.removeScriptVar (player, "conversation.nym_anniversary_dispenser.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int nym_anniversary_dispenser_handleBranch5 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Woah now! I need to make these last, we've got a lot of people coming through here. Nym'd be upset if I ran out of gifts ya know. Check back in an hour or so and I'll set you up with another gift, ok?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: I'll check back later.
|
|
if (response == "s_18")
|
|
{
|
|
//-- [NOTE]
|
|
if (nym_anniversary_dispenser_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Sorry, you know how it is. I'd hate for newcomers to have to go without.
|
|
string_id message = new string_id (c_stringFile, "s_20");
|
|
utils.removeScriptVar (player, "conversation.nym_anniversary_dispenser.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// ======================================================================
|
|
// User Script Triggers
|
|
// ======================================================================
|
|
|
|
trigger OnInitialize ()
|
|
{
|
|
if ((!isTangible (self)) || (isPlayer (self)))
|
|
detachScript(self, "conversation.nym_anniversary_dispenser");
|
|
|
|
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.nym_anniversary_dispenser");
|
|
|
|
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 (nym_anniversary_dispenser_condition_firstRewardEligable (player, npc))
|
|
{
|
|
//-- NPC: Hey hey! Coming to the celebration? Well either way, Nym wants to make sure everyone has a good time! I've got a bunch of party favors to give out to keep everyone in the spirit.
|
|
string_id message = new string_id (c_stringFile, "s_4");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Hey, that sounds great!
|
|
boolean hasResponse0 = false;
|
|
if (nym_anniversary_dispenser_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_6");
|
|
|
|
utils.setScriptVar (player, "conversation.nym_anniversary_dispenser.branchId", 1);
|
|
|
|
npcStartConversation (player, npc, "nym_anniversary_dispenser", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat (npc, player, message);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nym_anniversary_dispenser_condition_newRewardEligable (player, npc))
|
|
{
|
|
//-- NPC: Back again I see. Hope you're having a good time! I have plenty of gifts left if you want another one.
|
|
string_id message = new string_id (c_stringFile, "s_10");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Sure, what else do you have for me?
|
|
boolean hasResponse0 = false;
|
|
if (nym_anniversary_dispenser_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_12");
|
|
|
|
utils.setScriptVar (player, "conversation.nym_anniversary_dispenser.branchId", 3);
|
|
|
|
npcStartConversation (player, npc, "nym_anniversary_dispenser", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat (npc, player, message);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (nym_anniversary_dispenser_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Woah now! I need to make these last, we've got a lot of people coming through here. Nym'd be upset if I ran out of gifts ya know. Check back in an hour or so and I'll set you up with another gift, ok?
|
|
string_id message = new string_id (c_stringFile, "s_16");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: I'll check back later.
|
|
boolean hasResponse0 = false;
|
|
if (nym_anniversary_dispenser_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_18");
|
|
|
|
utils.setScriptVar (player, "conversation.nym_anniversary_dispenser.branchId", 5);
|
|
|
|
npcStartConversation (player, npc, "nym_anniversary_dispenser", message, responses);
|
|
}
|
|
else
|
|
{
|
|
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 != "nym_anniversary_dispenser")
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id npc = self;
|
|
|
|
int branchId = utils.getIntScriptVar (player, "conversation.nym_anniversary_dispenser.branchId");
|
|
|
|
if (branchId == 1 && nym_anniversary_dispenser_handleBranch1 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 3 && nym_anniversary_dispenser_handleBranch3 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 5 && nym_anniversary_dispenser_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.nym_anniversary_dispenser.branchId");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// ======================================================================
|
|
|