mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
246 lines
11 KiB
Java
Executable File
246 lines
11 KiB
Java
Executable File
package script.conversation;
|
|
|
|
import script.library.ai_lib;
|
|
import script.library.chat;
|
|
import script.library.utils;
|
|
import script.*;
|
|
|
|
public class village_elder extends script.base_script
|
|
{
|
|
public village_elder()
|
|
{
|
|
}
|
|
public static String c_stringFile = "conversation/village_elder";
|
|
public boolean village_elder_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
return true;
|
|
}
|
|
public boolean village_elder_condition_needCrystal(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (utils.playerHasItemByTemplateInBankOrInventory(player, "object/tangible/loot/quest/force_sensitive/force_crystal.iff"))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public void village_elder_action_giveCrystal(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
createObjectInInventoryAllowOverload("object/tangible/loot/quest/force_sensitive/force_crystal.iff", player);
|
|
return;
|
|
}
|
|
public int OnInitialize(obj_id self) throws InterruptedException
|
|
{
|
|
if ((!isMob(self)) || (isPlayer(self)))
|
|
{
|
|
detachScript(self, "npc.conversation.village_elder");
|
|
}
|
|
setCondition(self, CONDITION_CONVERSABLE);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnAttach(obj_id self) throws InterruptedException
|
|
{
|
|
setCondition(self, CONDITION_CONVERSABLE);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException
|
|
{
|
|
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;
|
|
}
|
|
public int OnIncapacitated(obj_id self, obj_id killer) throws InterruptedException
|
|
{
|
|
clearCondition(self, CONDITION_CONVERSABLE);
|
|
detachScript(self, "npc.conversation.village_elder");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public boolean npcStartConversation(obj_id player, obj_id npc, String convoName, string_id greetingId, prose_package greetingProse, string_id[] responses) throws InterruptedException
|
|
{
|
|
Object[] objects = new Object[responses.length];
|
|
System.arraycopy(responses, 0, objects, 0, responses.length);
|
|
return npcStartConversation(player, npc, convoName, greetingId, greetingProse, objects);
|
|
}
|
|
public int OnStartNpcConversation(obj_id self, obj_id player) throws InterruptedException
|
|
{
|
|
if (ai_lib.isInCombat(self) || ai_lib.isInCombat(player))
|
|
{
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_688b65");
|
|
int numberOfResponses = 0;
|
|
boolean hasResponse = false;
|
|
boolean hasResponse0 = false;
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
boolean hasResponse1 = false;
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
++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_fb95fc83");
|
|
}
|
|
if (hasResponse1)
|
|
{
|
|
responses[responseIndex++] = new string_id(c_stringFile, "s_85e90557");
|
|
}
|
|
setObjVar(player, "conversation.village_elder.branchId", 1);
|
|
npcStartConversation(player, self, "village_elder", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat(self, message);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: All conditions for OnStartNpcConversation were false.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnNpcConversationResponse(obj_id self, String conversationId, obj_id player, string_id response) throws InterruptedException
|
|
{
|
|
if (!conversationId.equals("village_elder"))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int branchId = getIntObjVar(player, "conversation.village_elder.branchId");
|
|
if (branchId == 1 && response.equals("s_fb95fc83"))
|
|
{
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_4dfe3937");
|
|
int numberOfResponses = 0;
|
|
boolean hasResponse = false;
|
|
boolean hasResponse0 = false;
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
boolean hasResponse1 = false;
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse1 = true;
|
|
}
|
|
boolean hasResponse2 = false;
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
++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_a9e1f5c2");
|
|
}
|
|
if (hasResponse1)
|
|
{
|
|
responses[responseIndex++] = new string_id(c_stringFile, "s_d931cb17");
|
|
}
|
|
if (hasResponse2)
|
|
{
|
|
responses[responseIndex++] = new string_id(c_stringFile, "s_efefc64f");
|
|
}
|
|
setObjVar(player, "conversation.village_elder.branchId", 2);
|
|
npcSpeak(player, message);
|
|
npcSetConversationResponses(player, responses);
|
|
}
|
|
else
|
|
{
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
npcSpeak(player, message);
|
|
npcEndConversation(player);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Hello, I am Elgin Seropf, elder of this village. What brings you to our home?' were false.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 1 && response.equals("s_85e90557"))
|
|
{
|
|
if (village_elder_condition_needCrystal(player, self))
|
|
{
|
|
village_elder_action_giveCrystal(player, self);
|
|
string_id message = new string_id(c_stringFile, "s_bdd3bae5");
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
npcSpeak(player, message);
|
|
npcEndConversation(player);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (!village_elder_condition_needCrystal(player, self))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_199fe2af");
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
npcSpeak(player, message);
|
|
npcEndConversation(player);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Hello, I am Elgin Seropf, elder of this village. What brings you to our home?' were false.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 2 && response.equals("s_a9e1f5c2"))
|
|
{
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_7d804cc7");
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
npcSpeak(player, message);
|
|
npcEndConversation(player);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, you might at that. Do you have any skills we might be in need of?' were false.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 2 && response.equals("s_d931cb17"))
|
|
{
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_ba08eb80");
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
npcSpeak(player, message);
|
|
npcEndConversation(player);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, you might at that. Do you have any skills we might be in need of?' were false.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 2 && response.equals("s_efefc64f"))
|
|
{
|
|
if (village_elder_condition__defaultCondition(player, self))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_7f56b89c");
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
npcSpeak(player, message);
|
|
npcEndConversation(player);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: All conditions for OnNpcConversationResponse for branch 'Yes, you might at that. Do you have any skills we might be in need of?' were false.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(self, "Error: Fell through all branches and responses for OnNpcConversationResponse.");
|
|
removeObjVar(player, "conversation.village_elder.branchId");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|