mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-05 05:17:55 -04:00
967 lines
29 KiB
Plaintext
967 lines
29 KiB
Plaintext
// ======================================================================
|
|
//
|
|
// defend_the_village.script
|
|
//
|
|
//
|
|
//
|
|
// Created with SwgConversationEditor 1.34 - DO NOT EDIT THIS AUTO-GENERATED FILE!
|
|
//
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Library Includes
|
|
// ======================================================================
|
|
|
|
include library.ai_lib;
|
|
include library.chat;
|
|
include library.fs_quests;
|
|
include library.quests;
|
|
include library.utils;
|
|
|
|
// ======================================================================
|
|
// Script Constants
|
|
// ======================================================================
|
|
|
|
string c_stringFile = "conversation/defend_the_village";
|
|
|
|
// ======================================================================
|
|
// Script Conditions
|
|
// ======================================================================
|
|
|
|
boolean defend_the_village_condition__defaultCondition (obj_id player, obj_id npc)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_percentComplete50 (obj_id player, obj_id npc)
|
|
{
|
|
boolean result = false;
|
|
|
|
if(defend_the_village_condition_isOnRangedSpeedQuest(player, npc))
|
|
{
|
|
if(getPercentComplete(player, "fs_defend_01") + getPercentComplete(player, "fs_defend_02") >= 0.5f)
|
|
{
|
|
result = true;
|
|
}
|
|
}
|
|
else if(defend_the_village_condition_isOnMeleeDefenseQuest(player, npc))
|
|
{
|
|
if(getPercentComplete(player, "fs_defend_03") + getPercentComplete(player, "fs_defend_04") >= 0.5f)
|
|
{
|
|
result = true;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_canAcceptEitherQuest (obj_id player, obj_id npc)
|
|
{
|
|
return (defend_the_village_condition_canAcceptMeleeDefenseQuest(player, npc) || defend_the_village_condition_canAcceptRangedSpeedQuest(player, npc));
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_isOnRangedSpeedQuest (obj_id player, obj_id npc)
|
|
{
|
|
boolean result = false;
|
|
if(quests.isActive("fs_defend_wait_01", player))
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_isOnEitherQuest (obj_id player, obj_id npc)
|
|
{
|
|
return (defend_the_village_condition_isOnMeleeDefenseQuest(player, npc) || defend_the_village_condition_isOnRangedSpeedQuest(player, npc));
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_isOnMeleeDefenseQuest (obj_id player, obj_id npc)
|
|
{
|
|
boolean result = false;
|
|
if(quests.isActive("fs_defend_wait_02", player))
|
|
{
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_hasCompletedQuest (obj_id player, obj_id npc)
|
|
{
|
|
boolean result = false;
|
|
|
|
// finished both quests
|
|
if ( quests.isComplete("fs_defend_wait_01", player) && quests.isComplete("fs_defend_wait_02", player) )
|
|
{
|
|
result = true;
|
|
}
|
|
|
|
// finished one quest and can't accept another one right now
|
|
if ( (quests.isComplete("fs_defend_wait_01", player) || quests.isComplete("fs_defend_wait_02", player))
|
|
&& !defend_the_village_condition_isOnEitherQuest(player, npc) && !defend_the_village_condition_canAcceptEitherQuest(player, npc) )
|
|
{
|
|
result = true;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_canAcceptMeleeDefenseQuest (obj_id player, obj_id npc)
|
|
{
|
|
boolean result = false;
|
|
if(quests.canActivate("fs_defend_set_faction_02", player) && !fs_quests.hasQuestAccepted(player))
|
|
result = true;
|
|
return result;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
boolean defend_the_village_condition_canAcceptRangedSpeedQuest (obj_id player, obj_id npc)
|
|
{
|
|
boolean result = false;
|
|
if(quests.canActivate("fs_defend_set_faction", player) && !fs_quests.hasQuestAccepted(player))
|
|
result = true;
|
|
return result;
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script Actions
|
|
// ======================================================================
|
|
|
|
void defend_the_village_action_assignDefendTheVillage1 (obj_id player, obj_id npc)
|
|
{
|
|
attachScript(player, "quest.force_sensitive.fs_defend_01_cleanup");
|
|
quests.activate("fs_defend_set_faction", player, npc);
|
|
fs_quests.setQuestAccepted(player);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
void defend_the_village_action_assignDefendTheVillage2 (obj_id player, obj_id npc)
|
|
{
|
|
attachScript(player, "quest.force_sensitive.fs_defend_01_cleanup");
|
|
quests.activate("fs_defend_set_faction_02", player, npc);
|
|
fs_quests.setQuestAccepted(player);
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script %TO Tokens
|
|
// ======================================================================
|
|
|
|
string defend_the_village_tokenTO_delete_me (obj_id player, obj_id npc)
|
|
{
|
|
return new string();
|
|
}
|
|
|
|
// ======================================================================
|
|
// Script %DI Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// Script %DF Tokens
|
|
// ======================================================================
|
|
|
|
// ======================================================================
|
|
// handleBranch<n> Functions
|
|
// ======================================================================
|
|
|
|
int defend_the_village_handleBranch4 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Easy there recruit. I have an assignment for you whenever you're ready. I can give you training after you complete this mission. Would you be more interested in learning how to fire ranged weapons more quickly, or defending yourself in melee combat?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Definitely increasing my ranged speed.
|
|
if (response == "s_6e8bed18")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Here's what I have. Outlaws and pirates are swarming this area like Jawas over a speeder engine. The village's safety is going to rely on reducing the number of hostiles we have in this area. I'm counting on you to do that.
|
|
string_id message = new string_id (c_stringFile, "s_23");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: You want me to take out ALL of them?!?
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_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_25");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 5);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Melee defense. No question.
|
|
if (response == "s_95fe56b2")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Here's what I have. Outlaws and pirates are swarming this area like Jawas over a speeder engine. The village's safety is going to rely on reducing the number of hostiles we have in this area. I'm counting on you to do that.
|
|
string_id message = new string_id (c_stringFile, "s_cb3652f");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: You want me to take out ALL of them?!?
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_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_c382b2d0");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 11);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: I'm not ready to work right now.
|
|
if (response == "s_64cad97c")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Right then. Speak with me when you're ready.
|
|
string_id message = new string_id (c_stringFile, "s_918a48b8");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int defend_the_village_handleBranch5 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Here's what I have. Outlaws and pirates are swarming this area like Jawas over a speeder engine. The village's safety is going to rely on reducing the number of hostiles we have in this area. I'm counting on you to do that.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: You want me to take out ALL of them?!?
|
|
if (response == "s_25")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: No. In fact, I just want you to take out a few. Well, more than a few. Let's say 50 outlaws. I think if you can handle that, the rest of them will get the message that this isn't a safe spot for them to hang around. The pirates, well, there's less of them, so let's say 25 of the pirates. Can you handle that?
|
|
string_id message = new string_id (c_stringFile, "s_27");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Yes sir!
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: Sounds like a lot...
|
|
boolean hasResponse1 = false;
|
|
if (defend_the_village_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_29");
|
|
|
|
if (hasResponse1)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_33");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 6);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int defend_the_village_handleBranch6 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: No. In fact, I just want you to take out a few. Well, more than a few. Let's say 50 outlaws. I think if you can handle that, the rest of them will get the message that this isn't a safe spot for them to hang around. The pirates, well, there's less of them, so let's say 25 of the pirates. Can you handle that?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Yes sir!
|
|
if (response == "s_29")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
defend_the_village_action_assignDefendTheVillage1 (player, npc);
|
|
|
|
//-- NPC: Good. Come back and see me while you're working on this problem and I'll let you know how things are going.
|
|
string_id message = new string_id (c_stringFile, "s_31");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Sounds like a lot...
|
|
if (response == "s_33")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Maybe, but I think you're the right person for the job. Can you do it?
|
|
string_id message = new string_id (c_stringFile, "s_35");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Um...sure.
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: No, I think it's too much for me.
|
|
boolean hasResponse1 = false;
|
|
if (defend_the_village_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_37");
|
|
|
|
if (hasResponse1)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_41");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 8);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int defend_the_village_handleBranch8 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Maybe, but I think you're the right person for the job. Can you do it?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Um...sure.
|
|
if (response == "s_37")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
defend_the_village_action_assignDefendTheVillage1 (player, npc);
|
|
|
|
//-- NPC: Fantastic! I knew I could count on you.
|
|
string_id message = new string_id (c_stringFile, "s_39");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: No, I think it's too much for me.
|
|
if (response == "s_41")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: That's too bad. I was hoping you'd be more helpful. Come back if you ever toughen up.
|
|
string_id message = new string_id (c_stringFile, "s_43");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int defend_the_village_handleBranch11 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Here's what I have. Outlaws and pirates are swarming this area like Jawas over a speeder engine. The village's safety is going to rely on reducing the number of hostiles we have in this area. I'm counting on you to do that.
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: You want me to take out ALL of them?!?
|
|
if (response == "s_c382b2d0")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: No. In fact, I just want you to take out a few. Well, more than a few. Let's say 50 outlaws. I think if you can handle that, the rest of them will get the message that this isn't a safe spot for them to hang around. The pirates, well, there's less of them, so let's say 25 of the pirates. Can you handle that?
|
|
string_id message = new string_id (c_stringFile, "s_ee72ef65");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Yes sir!
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: Sounds like a lot...
|
|
boolean hasResponse1 = false;
|
|
if (defend_the_village_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_a30c1a53");
|
|
|
|
if (hasResponse1)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_ed6ed8a4");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 12);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int defend_the_village_handleBranch12 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: No. In fact, I just want you to take out a few. Well, more than a few. Let's say 50 outlaws. I think if you can handle that, the rest of them will get the message that this isn't a safe spot for them to hang around. The pirates, well, there's less of them, so let's say 25 of the pirates. Can you handle that?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Yes sir!
|
|
if (response == "s_a30c1a53")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
defend_the_village_action_assignDefendTheVillage2 (player, npc);
|
|
|
|
//-- NPC: Good. Come back and see me while you're working on this problem and I'll let you know how things are going.
|
|
string_id message = new string_id (c_stringFile, "s_db99c818");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Sounds like a lot...
|
|
if (response == "s_ed6ed8a4")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: Maybe, but I think you're the right person for the job. Can you do it?
|
|
string_id message = new string_id (c_stringFile, "s_2647addd");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Um...sure.
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: No, I think it's too much for me.
|
|
boolean hasResponse1 = false;
|
|
if (defend_the_village_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_f9a0517");
|
|
|
|
if (hasResponse1)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_2b2d70cd");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 14);
|
|
|
|
npcSpeak (player, message);
|
|
npcSetConversationResponses (player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
int defend_the_village_handleBranch14 (obj_id player, obj_id npc, string_id response)
|
|
{
|
|
//-- [BRANCH NOTE]
|
|
//-- NPC: Maybe, but I think you're the right person for the job. Can you do it?
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: Um...sure.
|
|
if (response == "s_f9a0517")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
defend_the_village_action_assignDefendTheVillage2 (player, npc);
|
|
|
|
//-- NPC: Fantastic! I knew I could count on you.
|
|
string_id message = new string_id (c_stringFile, "s_212d92b3");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
//-- [RESPONSE NOTE]
|
|
//-- PLAYER: No, I think it's too much for me.
|
|
if (response == "s_2b2d70cd")
|
|
{
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: That's too bad. I was hoping you'd be more helpful. Come back if you ever toughen up.
|
|
string_id message = new string_id (c_stringFile, "s_982a066f");
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
chat.chat (npc, player, message);
|
|
npcEndConversation (player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// ======================================================================
|
|
// User Script Triggers
|
|
// ======================================================================
|
|
|
|
float getPercentComplete(obj_id self, String questName)
|
|
{
|
|
float result = 0.0f;
|
|
|
|
// quest.name.parameter tracks kills remaining
|
|
String objvarName = "quest." + questName + ".parameter";
|
|
if(hasObjVar(self, objvarName))
|
|
{
|
|
int killsRemaining = getIntObjVar(self, objvarName);
|
|
if(killsRemaining > 0)
|
|
{
|
|
// datatable contains total kills
|
|
String totalKillsString = quests.getDataEntry(questName, "PARAMETER");
|
|
int totalKills = utils.stringToInt(totalKillsString);
|
|
if(totalKills > 0)
|
|
{
|
|
result = 1 - (float)(killsRemaining / totalKills);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = 1.0f;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
trigger OnInitialize ()
|
|
{
|
|
if ((!isMob (self)) || (isPlayer (self)))
|
|
detachScript(self, "conversation.defend_the_village");
|
|
|
|
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.defend_the_village");
|
|
|
|
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 (defend_the_village_condition_hasCompletedQuest (player, npc))
|
|
{
|
|
doAnimationAction (npc, "salute1");
|
|
|
|
//-- NPC: I'd like to thank you for all the hard work you did. Get some rest. I'm sure at some point in the future we'll need some more help from you, but for now you've earned some R&R.
|
|
string_id message = new string_id (c_stringFile, "s_a2665c7f");
|
|
chat.chat (npc, player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition_percentComplete50 (player, npc))
|
|
{
|
|
doAnimationAction (npc, "thumb_up");
|
|
|
|
//-- NPC: I knew I picked the right person for this. I just knew it. The outlaws and the pirates are cursing your name this very minute. You've almost finished what I asked you to do. All you have to do is get out there and complete this mission. Good luck, soldier!
|
|
string_id message = new string_id (c_stringFile, "s_1a9b1371");
|
|
chat.chat (npc, player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition_isOnEitherQuest (player, npc))
|
|
{
|
|
doAnimationAction (npc, "pound_fist_palm");
|
|
|
|
//-- NPC: I know you've been working on that problem of ours...you know, with the outlaws and the pirates? But I'm going to need you to work a little harder. Now get back out there soldier!
|
|
string_id message = new string_id (c_stringFile, "s_c9be571d");
|
|
chat.chat (npc, player, message);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition_canAcceptEitherQuest (player, npc))
|
|
{
|
|
//-- NPC: Easy there recruit. I have an assignment for you whenever you're ready. I can give you training after you complete this mission. Would you be more interested in learning how to fire ranged weapons more quickly, or defending yourself in melee combat?
|
|
string_id message = new string_id (c_stringFile, "s_d2fe23af");
|
|
int numberOfResponses = 0;
|
|
|
|
boolean hasResponse = false;
|
|
|
|
//-- PLAYER: Definitely increasing my ranged speed.
|
|
boolean hasResponse0 = false;
|
|
if (defend_the_village_condition_canAcceptRangedSpeedQuest (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
|
|
//-- PLAYER: Melee defense. No question.
|
|
boolean hasResponse1 = false;
|
|
if (defend_the_village_condition_canAcceptMeleeDefenseQuest (player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse1 = true;
|
|
}
|
|
|
|
//-- PLAYER: I'm not ready to work right now.
|
|
boolean hasResponse2 = false;
|
|
if (defend_the_village_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_6e8bed18");
|
|
|
|
if (hasResponse1)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_95fe56b2");
|
|
|
|
if (hasResponse2)
|
|
responses [responseIndex++] = new string_id (c_stringFile, "s_64cad97c");
|
|
|
|
utils.setScriptVar (player, "conversation.defend_the_village.branchId", 4);
|
|
|
|
npcStartConversation (player, npc, "defend_the_village", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat (npc, player, message);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//-- [NOTE]
|
|
if (defend_the_village_condition__defaultCondition (player, npc))
|
|
{
|
|
//-- NPC: As I understand it, you already have some assignments from some of the other villagers. Come back when you don't have so much on your plate.
|
|
string_id message = new string_id (c_stringFile, "s_41ea5583");
|
|
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 != "defend_the_village")
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id npc = self;
|
|
|
|
int branchId = utils.getIntScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
if (branchId == 4 && defend_the_village_handleBranch4 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 5 && defend_the_village_handleBranch5 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 6 && defend_the_village_handleBranch6 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 8 && defend_the_village_handleBranch8 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 11 && defend_the_village_handleBranch11 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 12 && defend_the_village_handleBranch12 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (branchId == 14 && defend_the_village_handleBranch14 (player, npc, response) == SCRIPT_CONTINUE)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse.");
|
|
|
|
utils.removeScriptVar (player, "conversation.defend_the_village.branchId");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// ======================================================================
|
|
|