Files
dsrc/sku.0/sys.server/compiled/game/script/conversation/lifeday_vendor.java
T
2018-06-07 00:32:29 +01:00

734 lines
30 KiB
Java
Executable File

package script.conversation;
import script.*;
import script.library.ai_lib;
import script.library.chat;
import script.library.groundquests;
import script.library.utils;
public class lifeday_vendor extends script.base_script
{
public lifeday_vendor()
{
}
public static String c_stringFile = "conversation/lifeday_vendor";
public boolean lifeday_vendor_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException
{
return true;
}
public boolean lifeday_vendor_condition_questNotCompleted(obj_id player, obj_id npc) throws InterruptedException
{
if (groundquests.hasCompletedQuest(player, "lifeday_stap_1"))
{
return false;
}
if (groundquests.isQuestActive(player, "lifeday_stap_1"))
{
return false;
}
return true;
}
public boolean lifeday_vendor_condition_questReturned(obj_id player, obj_id npc) throws InterruptedException
{
if (groundquests.isTaskActive(player, "lifeday_stap_1", "talkSaun_needsStap"))
{
return true;
}
if (groundquests.isTaskActive(player, "lifeday_stap_1", "talkSaun_hasStap"))
{
return true;
}
return false;
}
public boolean lifeday_vendor_condition_questCompleted(obj_id player, obj_id npc) throws InterruptedException
{
if (groundquests.hasCompletedQuest(player, "lifeday_stap_1"))
{
return true;
}
return false;
}
public void lifeday_vendor_action_showTokenVendorUI(obj_id player, obj_id npc) throws InterruptedException
{
dictionary d = new dictionary();
d.put("player", player);
messageTo(npc, "showInventorySUI", d, 0, false);
return;
}
public void lifeday_vendor_action_giveQuest(obj_id player, obj_id npc) throws InterruptedException
{
if (groundquests.hasCompletedQuest(player, "lifeday_stap_1"))
{
groundquests.clearQuest(player, "lifeday_stap_1");
}
groundquests.grantQuest(player, "lifeday_stap_1");
}
public void lifeday_vendor_action_finishQuest(obj_id player, obj_id npc) throws InterruptedException
{
groundquests.sendSignal(player, "talkedSaun");
}
public int lifeday_vendor_handleBranch1(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_15"))
{
doAnimationAction(player, "slump_head");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(npc, "shake_head_disgust");
string_id message = new string_id(c_stringFile, "s_17");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
boolean hasResponse1 = false;
if (lifeday_vendor_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_18");
}
if (hasResponse1)
{
responses[responseIndex++] = new string_id(c_stringFile, "s_19");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 2);
npcSpeak(player, message);
npcSetConversationResponses(player, responses);
}
else
{
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
}
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch2(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_18"))
{
doAnimationAction(player, "shake_head_no");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
lifeday_vendor_action_finishQuest(player, npc);
string_id message = new string_id(c_stringFile, "s_20");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
if (response.equals("s_19"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(player, "pound_fist_palm");
string_id message = new string_id(c_stringFile, "s_21");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_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_22");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 4);
npcSpeak(player, message);
npcSetConversationResponses(player, responses);
}
else
{
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
}
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch4(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_22"))
{
doAnimationAction(player, "nod");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
lifeday_vendor_action_finishQuest(player, npc);
string_id message = new string_id(c_stringFile, "s_23");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch6(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_42"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
string_id message = new string_id(c_stringFile, "s_44");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_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_46");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 7);
npcSpeak(player, message);
npcSetConversationResponses(player, responses);
}
else
{
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
}
return SCRIPT_CONTINUE;
}
}
if (response.equals("s_43"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
lifeday_vendor_action_showTokenVendorUI(player, npc);
string_id message = new string_id(c_stringFile, "s_45");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch7(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_46"))
{
doAnimationAction(player, "shake_head_disgust");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(npc, "rub_chin_thoughtful");
string_id message = new string_id(c_stringFile, "s_47");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
boolean hasResponse1 = false;
if (lifeday_vendor_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_48");
}
if (hasResponse1)
{
responses[responseIndex++] = new string_id(c_stringFile, "s_49");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 8);
npcSpeak(player, message);
npcSetConversationResponses(player, responses);
}
else
{
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
}
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch8(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_48"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
string_id message = new string_id(c_stringFile, "s_50");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
boolean hasResponse1 = false;
if (lifeday_vendor_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_52");
}
if (hasResponse1)
{
responses[responseIndex++] = new string_id(c_stringFile, "s_53");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 9);
npcSpeak(player, message);
npcSetConversationResponses(player, responses);
}
else
{
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
}
return SCRIPT_CONTINUE;
}
}
if (response.equals("s_49"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(npc, "clap_rousing");
lifeday_vendor_action_giveQuest(player, npc);
string_id message = new string_id(c_stringFile, "s_56");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch9(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_52"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(npc, "clap_rousing");
lifeday_vendor_action_giveQuest(player, npc);
string_id message = new string_id(c_stringFile, "s_56");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
if (response.equals("s_53"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
string_id message = new string_id(c_stringFile, "s_54");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch12(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_37"))
{
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
string_id message = new string_id(c_stringFile, "s_39");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
boolean hasResponse1 = false;
if (lifeday_vendor_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_51");
}
if (hasResponse1)
{
responses[responseIndex++] = new string_id(c_stringFile, "s_58");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 13);
npcSpeak(player, message);
npcSetConversationResponses(player, responses);
}
else
{
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
}
return SCRIPT_CONTINUE;
}
}
if (response.equals("s_62"))
{
doAnimationAction(player, "shake_head_no");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
lifeday_vendor_action_showTokenVendorUI(player, npc);
string_id message = new string_id(c_stringFile, "s_64");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
npcEndConversationWithMessage(player, message);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int lifeday_vendor_handleBranch13(obj_id player, obj_id npc, string_id response) throws InterruptedException
{
if (response.equals("s_51"))
{
doAnimationAction(player, "nod");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(npc, "clap_rousing");
lifeday_vendor_action_giveQuest(player, npc);
string_id message = new string_id(c_stringFile, "s_56");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
if (response.equals("s_58"))
{
doAnimationAction(player, "shake_head_no");
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
string_id message = new string_id(c_stringFile, "s_60");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcEndConversationWithMessage(player, pp);
return SCRIPT_CONTINUE;
}
}
return SCRIPT_DEFAULT;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
if ((!isTangible(self)) || (isPlayer(self)))
{
detachScript(self, "conversation.lifeday_vendor");
}
setCondition(self, CONDITION_CONVERSABLE);
setCondition(self, CONDITION_SPACE_INTERESTING);
return SCRIPT_CONTINUE;
}
public int OnAttach(obj_id self) throws InterruptedException
{
setCondition(self, CONDITION_CONVERSABLE);
setCondition(self, CONDITION_SPACE_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.lifeday_vendor");
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 (lifeday_vendor_condition_questReturned(player, npc))
{
doAnimationAction(npc, "greet");
doAnimationAction(player, "greet");
string_id message = new string_id(c_stringFile, "s_14");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_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_15");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 1);
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcStartConversation(player, npc, "lifeday_vendor", null, pp, responses);
}
else
{
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
chat.chat(npc, player, null, null, pp);
}
return SCRIPT_CONTINUE;
}
if (lifeday_vendor_condition_questCompleted(player, npc))
{
doAnimationAction(npc, "greet");
doAnimationAction(player, "greet");
string_id message = new string_id(c_stringFile, "s_41");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
boolean hasResponse1 = false;
if (lifeday_vendor_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_43");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 6);
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcStartConversation(player, npc, "lifeday_vendor", null, pp, responses);
}
else
{
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
chat.chat(npc, player, null, null, pp);
}
return SCRIPT_CONTINUE;
}
if (lifeday_vendor_condition_questNotCompleted(player, npc))
{
doAnimationAction(npc, "greet");
doAnimationAction(player, "greet");
string_id message = new string_id(c_stringFile, "s_35");
int numberOfResponses = 0;
boolean hasResponse = false;
boolean hasResponse0 = false;
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
++numberOfResponses;
hasResponse = true;
hasResponse0 = true;
}
boolean hasResponse1 = false;
if (lifeday_vendor_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_62");
}
utils.setScriptVar(player, "conversation.lifeday_vendor.branchId", 12);
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
npcStartConversation(player, npc, "lifeday_vendor", null, pp, responses);
}
else
{
prose_package pp = new prose_package();
pp.stringId = message;
pp.actor.set(player);
pp.target.set(npc);
chat.chat(npc, player, null, null, pp);
}
return SCRIPT_CONTINUE;
}
if (lifeday_vendor_condition__defaultCondition(player, npc))
{
doAnimationAction(player, "greet");
lifeday_vendor_action_showTokenVendorUI(player, npc);
string_id message = new string_id(c_stringFile, "s_66");
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("lifeday_vendor"))
{
return SCRIPT_CONTINUE;
}
obj_id npc = self;
int branchId = utils.getIntScriptVar(player, "conversation.lifeday_vendor.branchId");
if (branchId == 1 && lifeday_vendor_handleBranch1(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 2 && lifeday_vendor_handleBranch2(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 4 && lifeday_vendor_handleBranch4(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 6 && lifeday_vendor_handleBranch6(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 7 && lifeday_vendor_handleBranch7(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 8 && lifeday_vendor_handleBranch8(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 9 && lifeday_vendor_handleBranch9(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 12 && lifeday_vendor_handleBranch12(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
if (branchId == 13 && lifeday_vendor_handleBranch13(player, npc, response) == SCRIPT_CONTINUE)
{
return SCRIPT_CONTINUE;
}
chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse.");
utils.removeScriptVar(player, "conversation.lifeday_vendor.branchId");
return SCRIPT_CONTINUE;
}
}