/// <summary> /// All not Done quests from this NPC /// </summary> private BaseQuest[] GetUnDoneQuestsFor( Character c ) { ArrayList result = new ArrayList(); for ( int i=0; i<Quests.Length; i++ ) { BaseQuest q = Quests[i]; if ( q != null && !c.QuestDone( q ) ) result.Add( q ); } return (BaseQuest[])result.ToArray( typeof(BaseQuest)); }
/// <summary> /// private internal Events on quest selections /// changed: 02.10.05 /// </summary> private void DoQuestEvents( Character c, BaseQuest bq ) { if ( c.QuestDone( bq ) ) return; if ( !c.QuestCompleted( bq ) ) { if ( !c.HaveQuest( bq ) ) { if ( bq.HaveDeliveryObj && !HaveFreeSlot( c ) ) // quest need free slot { c.QuestFailed( qFailedReason.InventoryFull ); } else if ( AmountActiveQuests( c ) >= 20 ) // questLog is full { c.QuestLogIsFull(); } else // can get quest {//need add questEmotion[] on get quest c.ResponseQuestDetails( this, bq.Id, bq.Name, bq.Desc, bq.Details, getEmoteOnStart( bq ) ); //c.ResponseQuestDetails( this, bq.Id, bq.Name, bq.Desc, bq.Details, new qEmote[] { new qEmote( Emote.ONESHOT_TALK, 500 ) } ); } } else { //c.QuestInvalid( qInvalidReason.ReadyHaveThatQuest ); c.SendGossip( this, OnlyQuests ? (int)NPCMenuId.Quests : (int)NPCMenuId.MainMenu, null, null ); //c.ResponseMessage( this, OnlyQuests ? (int)NPCMenuId.Quests : (int)NPCMenuId.MainMenu, bq.ProgressDialog ); } } else if ( c.QuestCompleted( bq ) ) {//need add questEmotion[] on complete quest c.OfferReward( this, bq.Id, bq.FinishTitle, bq.FinishDialog, getEmoteOnEnd( bq ) ); //c.OfferReward( this, bq.Id, bq.FinishTitle, bq.FinishDialog, new qEmote[] { new qEmote( Emote.ONESHOT_TALK, 500 ) } ); } }
/// <summary> /// All Available quests for character (Sort by level) /// </summary> private BaseQuest[] GetQuestsFor( Character c ) { ArrayList result = new ArrayList(); for ( int i=0; i<Quests.Length; i++ ) { BaseQuest q = Quests[i]; if ( q != null && AllowedTo( q, c ) && !c.QuestDone( q ) ) { if ( q.PreviousQuest > 0 ) { BaseQuest bq = World.CreateQuestById( q.PreviousQuest ); if ( bq!=null && c.QuestDone( bq ) ) result.Add( q ); } else result.Add( q ); } } return ( BaseQuest[] )result.ToArray( typeof( BaseQuest ) ); }
/// <summary> /// Static function for using in all quests (for smaller code) /// changed: 01.10.05, need mod /// </summary> public static DialogStatus QDS( Mobile questOwner, Character c, BaseQuest bq ) { DialogStatus result = DialogStatus.ChatUnAvailable; if ( questOwner.Reputation( c ) > bq.MinReputation ) { if ( !c.QuestDone( bq ) ) // этот квест уже пройден { if ( !c.HaveQuest( bq ) ) // у чара нету этого квеста { if ( AllowedTo( bq, c ) ) // разрешено выдать, подходит ( расса, класс, скилл ) { if ( bq.PreviousQuest > 0 ) // этот квест из серии, необходимо закончить предыдущий { BaseQuest q = World.CreateQuestById( bq.PreviousQuest ); if ( q != null && c.QuestDone( q ) ) { result = DialogStatus.SingleQuestAvailable; //предыдущий закончен, этот можно получить } } else // квест одиночный или начальный для серии { result = DialogStatus.SingleQuestAvailable; } } } else // Character have this quest already { ActiveQuest aq = c.FindPlayerQuest( bq ); if ( aq.Completed ) // закончен квест, нужно наградить { result = aq.Repeatable ? DialogStatus.RepeatQuestCompleate : DialogStatus.SingleQuestCompleate; } else if ( !QuestForNPC( bq, (BaseNPC)questOwner ) ) // квест не для этого нпс? { result = DialogStatus.QuestUnCompleate; } } } } return result; }