mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-02 02:15:48 -04:00
568 lines
16 KiB
Plaintext
568 lines
16 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// loveday_ewok_cupid.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.badge;
|
|
include library.chat;
|
|
include library.conversation;
|
|
include library.groundquests;
|
|
include library.utils;
|
|
|
|
// ======================================================================
|
|
// Script Constants
|
|
// ======================================================================
|
|
|
|
string c_stringFile = "conversation/loveday_ewok_cupid";
|
|
|
|
// ======================================================================
|
|
// Script Conditions
|
|
// ======================================================================
|
|
|
|
boolean loveday_ewok_cupid_condition__defaultCondition (obj_id player, obj_id npc)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean loveday_ewok_cupid_condition_alreadyHasBadge (obj_id player, obj_id npc)
|
|
{
|
|
return badge.hasBadge(player, "loveday_cupid_badge_10");
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean loveday_ewok_cupid_condition_hasCardBundle (obj_id player, obj_id npc)
|
|
{
|
|
obj_id lovedayCardBundle = utils.getStaticItemInInventory(player, "item_event_loveday_card_stack");
|
|
if ( isIdValid(lovedayCardBundle) )
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean loveday_ewok_cupid_condition_hasChakHearts (obj_id player, obj_id npc)
|
|
{
|
|
obj_id lovedayCardBundle = utils.getStaticItemInInventory(player, "item_event_loveday_chak_heart");
|
|
if ( isIdValid(lovedayCardBundle) && getCount(lovedayCardBundle) >= 2 )
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean loveday_ewok_cupid_condition_preparingToLeave (obj_id player, obj_id npc)
|
|
{
|
|
return hasObjVar(npc, "preparingForDespawn");
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean loveday_ewok_cupid_condition_preparingToLeave_hasBadge (obj_id player, obj_id npc)
|
|
{
|
|
return hasObjVar(npc, "preparingForDespawn") && badge.hasBadge(player, "loveday_cupid_badge_10");
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script Actions
|
|
// ======================================================================
|
|
|
|
void loveday_ewok_cupid_action_hearts_grantCupidBadge (obj_id player, obj_id npc)
|
|
{
|
|
obj_id lovedayChakHearts = utils.getStaticItemInInventory(player, "item_event_loveday_chak_heart");
|
|
if ( isIdValid(lovedayChakHearts) && getCount(lovedayChakHearts) >= 2 )
|
|
{
|
|
boolean success = incrementCount(lovedayChakHearts, -2);
|
|
if (success && getCount(lovedayChakHearts) <= 0)
|
|
{
|
|
destroyObject(lovedayChakHearts);
|
|
}
|
|
|
|
badge.grantBadge(player, "loveday_cupid_badge_10");
|
|
|
|
if ( !hasCompletedCollectionSlot(player, "loveday_2010_found_kyoopid") )
|
|
{
|
|
modifyCollectionSlotValue(player, "loveday_2010_found_kyoopid", 1);
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
void loveday_ewok_cupid_action_cards_grantCupidBadge (obj_id player, obj_id npc)
|
|
{
|
|
obj_id lovedayCardBundle = utils.getStaticItemInInventory(player, "item_event_loveday_card_stack");
|
|
if ( isIdValid(lovedayCardBundle) )
|
|
{
|
|
destroyObject(lovedayCardBundle);
|
|
badge.grantBadge(player, "loveday_cupid_badge_10");
|
|
|
|
if ( !hasCompletedCollectionSlot(player, "loveday_2010_found_kyoopid") )
|
|
{
|
|
modifyCollectionSlotValue(player, "loveday_2010_found_kyoopid", 1);
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
void loveday_ewok_cupid_action_grant_collectionSlot (obj_id player, obj_id npc)
|
|
{
|
|
if ( !hasCompletedCollectionSlot(player, "loveday_2010_found_kyoopid") )
|
|
{
|
|
modifyCollectionSlotValue(player, "loveday_2010_found_kyoopid", 1);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script %TO Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Script %DI Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Script %DF Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// handleBranch<n> Functions
|
|
// ======================================================================
|
|
|
|
int loveday_ewok_cupid_handleBranch4 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Do you wish to honor the spirit of the Festival of Love?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: I do.
|
|
if (response == "s_12")
|
|
{
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
doAnimationAction (npc, "nod_head_once");
|
|
|
|
//-- NPC: I am pleased. You may honor the Festival with either two Chak Hearts or with a bundle of Festival Cards. Which would you choose?
|
|
string_id message = new string_id (c_stringFile, "s_14");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Chak Hearts.
|
|
boolean hasResponse0 = false;
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: A bundle of Festival Cards.
|
|
boolean hasResponse1 = false;
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse1 = true;
|
|
}
|
|
|
|
//-- PLAYER: Neither.
|
|
boolean hasResponse2 = false;
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse2 = true;
|
|
}
|
|
|
|
if (hasResponse)
|
|
{
|
|
int responseIndex = 0;
|
|
string_id responses [] = new string_id [numberOfResponses];
|
|
|
|
if (hasResponse0)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_19");
|
|
|
|
if (hasResponse1)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_20");
|
|
|
|
if (hasResponse2)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_27");
|
|
|
|
utils.setScriptVar (player, "conversation.loveday_ewok_cupid.branchId", 5);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Um, no.
|
|
if (response == "s_30")
|
|
{
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: I see. May you eventually find some harmony and fill your life with joy.
|
|
string_id message = new string_id (c_stringFile, "s_34");
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int loveday_ewok_cupid_handleBranch5 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: I am pleased. You may honor the Festival with either two Chak Hearts or with a bundle of Festival Cards. Which would you choose?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Chak Hearts.
|
|
if (response == "s_19")
|
|
{
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition_hasChakHearts (player, npc))
|
|
{
|
|
doAnimationAction (npc, "celebrate");
|
|
|
|
loveday_ewok_cupid_action_hearts_grantCupidBadge (player, npc);
|
|
|
|
//-- NPC: You have honored the Festival of Love. May your days overflow with its spirit!
|
|
string_id message = new string_id (c_stringFile, "s_21");
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (!loveday_ewok_cupid_condition_hasChakHearts (player, npc))
|
|
{
|
|
doAnimationAction (npc, "explain");
|
|
|
|
//-- NPC: You do not have enough Chak Hearts. I appreciate your enthusiasm, but perhaps you should learn more about the Festival of Love.
|
|
string_id message = new string_id (c_stringFile, "s_23");
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: A bundle of Festival Cards.
|
|
if (response == "s_20")
|
|
{
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition_hasCardBundle (player, npc))
|
|
{
|
|
doAnimationAction (npc, "celebrate1");
|
|
|
|
loveday_ewok_cupid_action_cards_grantCupidBadge (player, npc);
|
|
|
|
//-- NPC: You show honor to the Festival of Love. Long may its spirit guide your path!
|
|
string_id message = new string_id (c_stringFile, "s_22");
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (!loveday_ewok_cupid_condition_hasCardBundle (player, npc))
|
|
{
|
|
doAnimationAction (npc, "explain");
|
|
|
|
//-- NPC: You do not have a bundle of Festival of Love cards. I enjoy your eagerness to honor the Festival, but perhaps you should first seek to participate in it a bit.
|
|
string_id message = new string_id (c_stringFile, "s_24");
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Neither.
|
|
if (response == "s_27")
|
|
{
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Ah, so you choose not to honor the Festival. Interesting.
|
|
string_id message = new string_id (c_stringFile, "s_28");
|
|
utils.removeScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
npcEndConversationWithMessage (player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// ======================================================================
|
|
// User Script Triggers
|
|
// ======================================================================
|
|
|
|
trigger OnInitialize ()
|
|
{
|
|
if ((!isTangible (self)) || (isPlayer (self)))
|
|
detachScript(self, "conversation.loveday_ewok_cupid");
|
|
|
|
setCondition(self, CONDITION_CONVERSABLE);
|
|
setCondition(self, CONDITION_HOLIDAY_INTERESTING);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAttach ()
|
|
{
|
|
setCondition (self, CONDITION_CONVERSABLE);
|
|
setCondition(self, CONDITION_HOLIDAY_INTERESTING);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler prepareForDespawn()
|
|
{
|
|
setObjVar(self, "preparingForDespawn", true);
|
|
messageTo(self, "handleMyDespawn", null, 180, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleMyDespawn()
|
|
{
|
|
location here = getLocation(self);
|
|
playClientEffectLoc(getPlayerCreaturesInRange(here, 100.0f), "appearance/pt_efol_hearts_large_noloop.prt", here, 1.0f);
|
|
messageTo(self, "handleDestroySelf", null, 0.25f, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleDestroySelf()
|
|
{
|
|
LOG("idiot", "Loveday Cupid Conversation: handleDestroySelf called... ");
|
|
obj_id[] players = getPlayerCreaturesInRange(getLocation(self), 20f);
|
|
if ( players != null && players.length > 0 )
|
|
{
|
|
for ( int i = 0; i < players.length; i++ )
|
|
{
|
|
npcEndConversation(players[i]);
|
|
}
|
|
}
|
|
|
|
destroyObject(self);
|
|
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);
|
|
clearCondition (self, CONDITION_SPACE_INTERESTING);
|
|
detachScript (self, "conversation.loveday_ewok_cupid");
|
|
|
|
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 (loveday_ewok_cupid_condition_preparingToLeave_hasBadge (player, npc))
|
|
{
|
|
loveday_ewok_cupid_action_grant_collectionSlot (player, npc);
|
|
|
|
//-- NPC: Joyous and happy Festival of Love to you!
|
|
string_id message = new string_id (c_stringFile, "s_33");
|
|
chat.chat (npc, player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition_preparingToLeave (player, npc))
|
|
{
|
|
//-- NPC: I must take my leave of you in a few short minutes. Farewell and celebrate your love!
|
|
string_id message = new string_id (c_stringFile, "s_31");
|
|
chat.chat (npc, player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition_alreadyHasBadge (player, npc))
|
|
{
|
|
loveday_ewok_cupid_action_grant_collectionSlot (player, npc);
|
|
|
|
//-- NPC: Happy and joyous Festival of Love to you!
|
|
string_id message = new string_id (c_stringFile, "s_6");
|
|
chat.chat (npc, player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Do you wish to honor the spirit of the Festival of Love?
|
|
string_id message = new string_id (c_stringFile, "s_10");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: I do.
|
|
boolean hasResponse0 = false;
|
|
if (loveday_ewok_cupid_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: Um, no.
|
|
boolean hasResponse1 = false;
|
|
if (loveday_ewok_cupid_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.loveday_ewok_cupid.branchId", 4);
|
|
|
|
npcStartConversation (player, npc, "loveday_ewok_cupid", 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 != "loveday_ewok_cupid")
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id npc = self;
|
|
|
|
int branchId = utils.getIntScriptVar (player, "conversation.loveday_ewok_cupid.branchId");
|
|
|
|
if (branchId == 4 && loveday_ewok_cupid_handleBranch4 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 5 && loveday_ewok_cupid_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.loveday_ewok_cupid.branchId");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// ======================================================================
|
|
|