/** * * Title: mediator.script * Description: mediator object script: POI = heromark */ //------------------------ // Includes //------------------------ include library.npc; include library.ai_lib; include library.scenario; include library.badge; include library.poi; include library.utils; include ai.ai_combat; //----------------------- // Inherits //----------------------- inherits poi.base.scenario_actor; //------------------------ // Constants //------------------------ const string SCRIPT_CONVERSE = "npc.converse.npc_converse_menu"; const string LOG_NAME = "poiHeroMark Mediator"; // Conversation states. const int CONV_GREET = 0; // Player hasn't spoken to anyone and needs a greeting. const int CONV_SPOKE = 1; // Player spoke to the mediator. //------------------------ // Methods //------------------------ //------------------------ // OnAttach //------------------------ trigger OnAttach() { attachScript( self, SCRIPT_CONVERSE ); return SCRIPT_CONTINUE; } //------------------------ // OnInitialize //------------------------ trigger OnInitialize() { attachScript( self, SCRIPT_CONVERSE ); return SCRIPT_CONTINUE; } //------------------------ // OnStartNpcConversation //------------------------ trigger OnStartNpcConversation( obj_id speaker ) { // Ignore conversation in combat. if ( ai_lib.isInCombat(self) ) return SCRIPT_CONTINUE; // Get conversation. string convo = scenario.getConvo(); if ( convo.equals("") ) { npcEndConversation( speaker ); return SCRIPT_CONTINUE; } // Get progress. int progress = scenario.getPlayerProgress( speaker ); // Msg/response vars. string_id msg = new string_id( convo, "a_greet" ); resizeable string_id[] responses = new string_id[0]; if ( badge.hasBadge( speaker, "poi_heromark" ) ) { // A hero has returned. poi.quickSay( self, "m_heroreturned" ); // Cut off the convo (no responses). npcEndConversation( speaker ); } else if ( progress == CONV_SPOKE ) { int idx = rand( 1, 4 ); poi.quickSay( self, "m_chatter_" + idx ); // Cut off the convo (no responses). npcEndConversation( speaker ); } else { // Does this player have the badges? if ( badge.hasBadge( speaker, "poi_prisonbreak" ) && badge.hasBadge( speaker, "poi_factoryliberation" ) && badge.hasBadge( speaker, "poi_rabidbeast" ) && badge.hasBadge( speaker, "poi_twoliars" ) ) { // Greet this player. msg = new string_id( convo, "m_youareahero" ); responses = utils.addElement( responses, new string_id(convo, "r_m_relatestory") ); npcStartConversation( speaker, self, convo, msg, responses ); } else { // Greet this player. msg = new string_id( convo, "m_greet" ); responses = utils.addElement( responses, new string_id(convo, "r_m_greet") ); npcStartConversation( speaker, self, convo, msg, responses ); } } return SCRIPT_CONTINUE; } //------------------------------------------------ // OnNpcConversationResponse //------------------------------------------------ trigger OnNpcConversationResponse( string convoName, obj_id speaker, string_id response ) { // Ignore conversation in combat. if ( ai_lib.isInCombat(self) ) return SCRIPT_CONTINUE; // Get reference to conversation. string convo = scenario.getConvo(); if ( convo.equals("") ) { npcEndConversation( speaker ); return SCRIPT_CONTINUE; } // Validate our conversation. if ( !convoName.equals(convo) ) return SCRIPT_CONTINUE; // Respond to the player's comment. string aId = response.getAsciiId(); resizeable string_id[] responses = new string_id[0]; // Zero out responses. npcSetConversationResponses( speaker, responses ); if ( ( aId.equals("r_m_greet") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk1" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk1") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk1") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk2" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk2") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk2") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk3" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk3") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk3") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk4" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_empirebad") ); responses = utils.addElement( responses, new string_id(convo, "r_m_empiregood") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_empiregood") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk5" ) ); // Set progress. scenario.setPlayerProgress( speaker, CONV_SPOKE ); } else if ( ( aId.equals("r_m_empirebad") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk6" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk6") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk6") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk7" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk7") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk7") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk8" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk8") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk8") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk9" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk9") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk9") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk10" ) ); // Set player responses. responses = utils.addElement( responses, new string_id(convo, "r_m_herotalk10") ); npcSetConversationResponses( speaker, responses ); } else if ( ( aId.equals("r_m_herotalk10") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_herotalk11" ) ); // Set progress. scenario.setPlayerProgress( speaker, CONV_SPOKE ); } else if ( ( aId.equals("r_m_relatestory") ) ) { // Tell our story. npcSpeak( speaker, new string_id( convo, "m_youareahero2" ) ); // Set progress. scenario.setPlayerProgress( speaker, CONV_SPOKE ); // Give this person the mark. badge.grantBadge( speaker, "poi_heromark" ); scenario.complete(); } return SCRIPT_CONTINUE; }