mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
474 lines
19 KiB
Java
Executable File
474 lines
19 KiB
Java
Executable File
package script.conversation;
|
|
|
|
import script.library.ai_lib;
|
|
import script.library.chat;
|
|
import script.library.groundquests;
|
|
import script.library.utils;
|
|
import script.*;
|
|
|
|
public class porcellus extends script.base_script
|
|
{
|
|
public porcellus()
|
|
{
|
|
}
|
|
public static String c_stringFile = "conversation/porcellus";
|
|
public boolean porcellus_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
return true;
|
|
}
|
|
public boolean porcellus_condition_completedPorcellus(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.hasCompletedQuest(player, "quest/jabba_porcellus"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_completedEphantMon(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.hasCompletedQuest(player, "quest/jabba_ephant_mon"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_gettingAppetizer(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "appetizer"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_gettingSoup(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "soup"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_gettingSalad(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "salad"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_gettingEntree(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "entree"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_gettingDessert(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "dessert"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_gettingWine(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "wine"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public boolean porcellus_condition_returningIngredients(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
if (groundquests.isTaskActive(player, "quest/jabba_porcellus", "delivery"))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public void porcellus_action_sendFinishSignal(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
faceTo(npc, player);
|
|
groundquests.sendSignal(player, "completedPorcellus");
|
|
}
|
|
public void porcellus_action_grantPorcellusQuest(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
groundquests.grantQuest(player, "quest/jabba_porcellus");
|
|
}
|
|
public void porcellus_action_pointToBarada(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
groundquests.grantQuest(player, "pointer_barada");
|
|
}
|
|
public void porcellus_action_clearPointer(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
faceTo(npc, player);
|
|
groundquests.sendSignal(player, "found_porcellus");
|
|
}
|
|
public void porcellus_action_facePlayer(obj_id player, obj_id npc) throws InterruptedException
|
|
{
|
|
faceTo(npc, player);
|
|
}
|
|
public int porcellus_handleBranch2(obj_id player, obj_id npc, string_id response) throws InterruptedException
|
|
{
|
|
if (response.equals("s_23"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
porcellus_action_pointToBarada(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_24");
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
public int porcellus_handleBranch10(obj_id player, obj_id npc, string_id response) throws InterruptedException
|
|
{
|
|
if (response.equals("s_26"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_28");
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
if (response.equals("s_30"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
porcellus_action_grantPorcellusQuest(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_32");
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
if (response.equals("s_34"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_36");
|
|
int numberOfResponses = 0;
|
|
boolean hasResponse = false;
|
|
boolean hasResponse0 = false;
|
|
if (porcellus_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_38");
|
|
}
|
|
utils.setScriptVar(player, "conversation.porcellus.branchId", 13);
|
|
npcSpeak(player, message);
|
|
npcSetConversationResponses(player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
public int porcellus_handleBranch13(obj_id player, obj_id npc, string_id response) throws InterruptedException
|
|
{
|
|
if (response.equals("s_38"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_40");
|
|
int numberOfResponses = 0;
|
|
boolean hasResponse = false;
|
|
boolean hasResponse0 = false;
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
boolean hasResponse1 = false;
|
|
if (porcellus_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_42");
|
|
}
|
|
if (hasResponse1)
|
|
{
|
|
responses[responseIndex++] = new string_id(c_stringFile, "s_44");
|
|
}
|
|
utils.setScriptVar(player, "conversation.porcellus.branchId", 14);
|
|
npcSpeak(player, message);
|
|
npcSetConversationResponses(player, responses);
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
public int porcellus_handleBranch14(obj_id player, obj_id npc, string_id response) throws InterruptedException
|
|
{
|
|
if (response.equals("s_42"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
porcellus_action_grantPorcellusQuest(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_32");
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
if (response.equals("s_44"))
|
|
{
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
string_id message = new string_id(c_stringFile, "s_28");
|
|
utils.removeScriptVar(player, "conversation.porcellus.branchId");
|
|
npcEndConversationWithMessage(player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_DEFAULT;
|
|
}
|
|
public int OnInitialize(obj_id self) throws InterruptedException
|
|
{
|
|
if ((!isMob(self)) || (isPlayer(self)))
|
|
{
|
|
detachScript(self, "conversation.porcellus");
|
|
}
|
|
setCondition(self, CONDITION_CONVERSABLE);
|
|
setCondition(self, CONDITION_INTERESTING);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnAttach(obj_id self) throws InterruptedException
|
|
{
|
|
setCondition(self, CONDITION_CONVERSABLE);
|
|
setCondition(self, CONDITION_INTERESTING);
|
|
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, "conversation.porcellus");
|
|
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
|
|
{
|
|
obj_id npc = self;
|
|
if (ai_lib.isInCombat(npc) || ai_lib.isInCombat(player))
|
|
{
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
if (porcellus_condition_completedPorcellus(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_4");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_returningIngredients(player, npc))
|
|
{
|
|
porcellus_action_sendFinishSignal(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_6");
|
|
int numberOfResponses = 0;
|
|
boolean hasResponse = false;
|
|
boolean hasResponse0 = false;
|
|
if (porcellus_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_23");
|
|
}
|
|
utils.setScriptVar(player, "conversation.porcellus.branchId", 2);
|
|
npcStartConversation(player, npc, "porcellus", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat(npc, player, message);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_gettingWine(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_10");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_gettingDessert(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_12");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_gettingEntree(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_14");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_gettingSalad(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_16");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_gettingSoup(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_18");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_gettingAppetizer(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_20");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition_completedEphantMon(player, npc))
|
|
{
|
|
porcellus_action_clearPointer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_22");
|
|
int numberOfResponses = 0;
|
|
boolean hasResponse = false;
|
|
boolean hasResponse0 = false;
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse0 = true;
|
|
}
|
|
boolean hasResponse1 = false;
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
++numberOfResponses;
|
|
hasResponse = true;
|
|
hasResponse1 = true;
|
|
}
|
|
boolean hasResponse2 = false;
|
|
if (porcellus_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_26");
|
|
}
|
|
if (hasResponse1)
|
|
{
|
|
responses[responseIndex++] = new string_id(c_stringFile, "s_30");
|
|
}
|
|
if (hasResponse2)
|
|
{
|
|
responses[responseIndex++] = new string_id(c_stringFile, "s_34");
|
|
}
|
|
utils.setScriptVar(player, "conversation.porcellus.branchId", 10);
|
|
npcStartConversation(player, npc, "porcellus", message, responses);
|
|
}
|
|
else
|
|
{
|
|
chat.chat(npc, player, message);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (porcellus_condition__defaultCondition(player, npc))
|
|
{
|
|
porcellus_action_facePlayer(player, npc);
|
|
string_id message = new string_id(c_stringFile, "s_46");
|
|
chat.chat(npc, player, message);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
chat.chat(npc, "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("porcellus"))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
obj_id npc = self;
|
|
int branchId = utils.getIntScriptVar(player, "conversation.porcellus.branchId");
|
|
if (branchId == 2 && porcellus_handleBranch2(player, npc, response) == SCRIPT_CONTINUE)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 10 && porcellus_handleBranch10(player, npc, response) == SCRIPT_CONTINUE)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 13 && porcellus_handleBranch13(player, npc, response) == SCRIPT_CONTINUE)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (branchId == 14 && porcellus_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.porcellus.branchId");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|