// ====================================================================== // // sheeli.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.chat; include library.conversation; include library.create; include library.groundquests; include library.utils; // ====================================================================== // Script Constants // ====================================================================== string c_stringFile = "conversation/sheeli"; // ====================================================================== // Script Conditions // ====================================================================== boolean sheeli_condition__defaultCondition (obj_id player, obj_id npc) { return true; } // ---------------------------------------------------------------------- boolean sheeli_condition_isRescuer (obj_id player, obj_id npc) { return groundquests.isTaskActive(player, "u16_nym_themepark_rescue_sheeli", "rescueSheeli"); } // ---------------------------------------------------------------------- boolean sheeli_condition_hasArrived (obj_id player, obj_id npc) { return groundquests.isTaskActive(player, "u16_nym_themepark_rescue_sheeli", "waitingForShuttle"); } // ---------------------------------------------------------------------- boolean sheeli_condition_isTraveling (obj_id player, obj_id npc) { faceTo(npc, player); return hasObjVar(npc, "traveling") && getIntObjVar(npc, "traveling") == 1 && groundquests.isTaskActive(player, "u16_nym_themepark_rescue_sheeli", "getToPickUp"); } // ====================================================================== // Script Actions // ====================================================================== void sheeli_action_startEscort (obj_id player, obj_id npc) { groundquests.sendSignal(player, "hasRescuedSheeli"); ai_lib.aiFollow(npc, player, 1.0f, 3.0f); setMovementRun(npc); setBaseRunSpeed(npc, (getBaseRunSpeed(npc)-8)); setObjVar(npc, "traveling", 1); setObjVar(npc, "playerOwner", player); setInvulnerable(npc, false); setMaster(npc, player); messageTo(npc, "checkArrivalLoopHandler", null, 5, false); } // ---------------------------------------------------------------------- void sheeli_action_walkFaster (obj_id player, obj_id npc) { setMovementRun(npc); setBaseRunSpeed(npc, (getBaseRunSpeed(npc)-8)); ai_lib.aiFollow(npc, player, 1.0f, 3.0f); } // ====================================================================== // Script %TO Tokens // ====================================================================== // ====================================================================== // Script %DI Tokens // ====================================================================== // ====================================================================== // Script %DF Tokens // ====================================================================== // ====================================================================== // handleBranch Functions // ====================================================================== int sheeli_handleBranch3 (obj_id player, obj_id npc, string_id response) { //-- [BRANCH NOTE] //-- NPC: Who are you? You aren't a Sulfur Lake Pirate! //-- [RESPONSE NOTE] //-- PLAYER: No, I'm here to rescue you. if (response == "s_8") { //-- [NOTE] if (sheeli_condition__defaultCondition (player, npc)) { doAnimationAction (npc, "thank"); sheeli_action_startEscort (player, npc); //-- NPC: Oh thank you. I thought for sure they were going to kill me. I'll follow you! string_id message = new string_id (c_stringFile, "s_10"); utils.removeScriptVar (player, "conversation.sheeli.branchId"); npcEndConversationWithMessage (player, message); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } // ---------------------------------------------------------------------- // ====================================================================== // User Script Triggers // ====================================================================== trigger OnInitialize () { if ((!isTangible (self)) || (isPlayer (self))) detachScript(self, "conversation.sheeli"); setCondition (self, CONDITION_CONVERSABLE); return SCRIPT_CONTINUE; } trigger OnAttach () { setCondition (self, CONDITION_CONVERSABLE); CustomerServiceLog("nyms_themepark","OnAttach - init."); messageTo(self, "startFollowingOwner", null, 3, false); return SCRIPT_CONTINUE; } trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo) { if(!hasObjVar(self, "quest.owner")) { CustomerServiceLog("nyms_themepark","OnObjectMenuRequest - quest.owner not valid."); messageTo(self, "handleDestroySelf", null, 0, false); return SCRIPT_OVERRIDE; } if(player != getObjIdObjVar(self, "quest.owner")) { CustomerServiceLog("nyms_themepark","OnObjectMenuRequest - quest.owner var found but not valid."); return SCRIPT_OVERRIDE; } 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.sheeli"); return SCRIPT_CONTINUE; } messageHandler handleDestroySelf() { destroyObject(self); return SCRIPT_CONTINUE; } messageHandler startFollowingOwner() { if(!hasObjVar(self, "quest.owner")) { CustomerServiceLog("nyms_themepark","startFollowingOwner - quest.owner not valid."); messageTo(self, "handleDestroySelf", null, 0, false); return SCRIPT_CONTINUE; } obj_id owner = getObjIdObjVar(self, "quest.owner"); if(!isValidId(owner) || !exists(owner)) { messageTo(self, "handleDestroySelf", null, 0, false); return SCRIPT_CONTINUE; } setInvulnerable(self, true); ai_lib.aiFollow(self, owner, 1.0f, 3.0f); setMovementRun(self); setBaseRunSpeed(self, (getBaseRunSpeed(self)-8)); setObjVar(self, "traveling", 1); setInvulnerable(self, false); setMaster(self, owner); messageTo(self, "checkArrivalLoopHandler", null, 5, false); //messageTo(self, "loopForSpeakingTask", null, 0, false); return SCRIPT_CONTINUE; } messageHandler checkArrivalLoopHandler() { CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - Setting move to run."); setMovementRun(self); setBaseRunSpeed(self, (getBaseRunSpeed(self)-8)); CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - init."); obj_id player = getObjIdObjVar(self, "quest.owner"); if(!isValidId(player)) { CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - could not get valid player OID."); messageTo(self, "handleDestroySelf", null, 1, false); return SCRIPT_CONTINUE; } if(isDead(player)) { CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - Player Died."); failRescueQuest(self); return SCRIPT_CONTINUE; } CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - player: "+ player); //The player has failed the quest if(!groundquests.isQuestActive(player, "u16_nym_themepark_rescue_sheeli")) { CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - player no longer had required quest active!"); failRescueQuest(self); return SCRIPT_CONTINUE; } else if(groundquests.isTaskActive(player, "u16_nym_themepark_rescue_sheeli", "waitingForShuttle")) { CustomerServiceLog("nyms_themepark","checkArrivalLoopHandler - Calling SHuttle!"); callShuttle(self, player); return SCRIPT_CONTINUE; } ai_lib.aiFollow(self, player, 1.0f, 3.0f); messageTo(self, "checkArrivalLoopHandler", null, 1, false); return SCRIPT_CONTINUE; } messageHandler handleUpdatePrisonerRescueQuest() { //NPC could be destroyed or on the way to being destroyed if(!isValidId(self)) { CustomerServiceLog("nyms_themepark","handleUpdatePrisonerRescueQuest - NPC is not a valid OID."); return SCRIPT_CONTINUE; } obj_id player = getObjIdObjVar(self, "quest.owner"); if(!isValidId(player)) { messageTo(self, "handleDestroySelf", null, 1, false); CustomerServiceLog("nyms_themepark","handleUpdatePrisonerRescueQuest - could not get valid player OID."); return SCRIPT_CONTINUE; } groundquests.sendSignal(player, "shuttleHasArrived"); return SCRIPT_CONTINUE; } boolean callShuttle(obj_id self, obj_id player) { CustomerServiceLog("nyms_themepark","callShuttle - Shuttle Called"); if(!isValidId(player)) return false; if(!isValidId(self)) return false; ai_lib.aiStopFollowing(self); removeObjVar(self, "traveling"); location[] prisonerPath = new location[1]; prisonerPath[0] = new location(-42, 11, 2741, "lok", null); setYaw(self, 27.0f); setMovementRun(self); setBaseRunSpeed(self, (getBaseRunSpeed(self)-8)); utils.setScriptVar(self, ai_lib.SCRIPTVAR_CACHED_PATROL_NAMED_PATH, prisonerPath); utils.setScriptVar(self, ai_lib.SCRIPTVAR_CACHED_PATROL_TYPE, 0); patrolOnce(self, prisonerPath, 0); location landLocation = new location(-28, 11, 2759, "lok", null); obj_id shuttle = create.object("object/creature/npc/theme_park/player_shuttle.iff", landLocation); if(!isIdValid(shuttle)) return false; //THIS WILL CHANGE THE SHUTTLE TRAJECTORY!!!! setYaw(shuttle, -140); detachScript(shuttle, "ai.ai"); detachScript(shuttle, "ai.creature_combat"); detachScript(shuttle, "skeleton.humanoid"); detachScript(shuttle, "systems.combat.combat_actions"); detachScript(shuttle, "systems.combat.combat_actions_creature"); detachScript(shuttle, "systems.combat.credit_for_kills"); stop(shuttle); utils.setScriptVar(shuttle, "prisoner", self); utils.setScriptVar(shuttle, "playerOwner", player); setPosture(shuttle, POSTURE_PRONE); attachScript(shuttle, "systems.spawning.dropship.player_shuttle"); //Land Shuttle messageTo(shuttle, "landShuttle", null, 0, false); messageTo(shuttle, "takeOff", null, 37, false); messageTo(self, "handleUpdatePrisonerRescueQuest", null, 30, false); messageTo(self, "handleDestroySelf", null, 32, false); return true; } boolean failRescueQuest(obj_id self) { obj_id player = getObjIdObjVar(self, "quest.owne"); if(!isValidId(player)) { messageTo(self, "handleDestroySelf", null, 1, false); return false; } groundquests.sendSignal(player, "hasFailedQuest"); messageTo(self, "handleDestroySelf", null, 1, false); return true; } // ====================================================================== // 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 (sheeli_condition_hasArrived (player, npc)) { doAnimationAction (npc, "scream"); //-- NPC: They are sending a shuttle? Hope it gets here soon. string_id message = new string_id (c_stringFile, "s_11"); chat.chat (npc, player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (sheeli_condition_isTraveling (player, npc)) { sheeli_action_walkFaster (player, npc); //-- NPC: I'm coming, sorry! string_id message = new string_id (c_stringFile, "s_13"); chat.chat (npc, player, message); return SCRIPT_CONTINUE; } //-- [NOTE] if (sheeli_condition_isRescuer (player, npc)) { doAnimationAction (npc, "nervous"); //-- NPC: Who are you? You aren't a Sulfur Lake Pirate! string_id message = new string_id (c_stringFile, "s_6"); int numberOfResponses = 0; boolean hasResponse = false; //-- PLAYER: No, I'm here to rescue you. boolean hasResponse0 = false; if (sheeli_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_8"); utils.setScriptVar (player, "conversation.sheeli.branchId", 3); npcStartConversation (player, npc, "sheeli", message, responses); } else { chat.chat (npc, player, message); } return SCRIPT_CONTINUE; } //-- [NOTE] if (sheeli_condition__defaultCondition (player, npc)) { //-- NPC: I'm sorry. I'm busy at the moment. string_id message = new string_id (c_stringFile, "s_14"); 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 != "sheeli") return SCRIPT_CONTINUE; obj_id npc = self; int branchId = utils.getIntScriptVar (player, "conversation.sheeli.branchId"); if (branchId == 3 && sheeli_handleBranch3 (player, npc, response) == SCRIPT_CONTINUE) return SCRIPT_CONTINUE; chat.chat (npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar (player, "conversation.sheeli.branchId"); return SCRIPT_CONTINUE; } // ======================================================================