Reorganizes Project (#41)

This commit is contained in:
Kamron Batman 2019-08-02 18:13:40 -07:00 • committed by GitHub
parent 08bf44af9a
commit 3614a66aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3499 changed files with 79 additions and 55 deletions

View file

@ -0,0 +1,183 @@
namespace Server.Engines.Quests.Matriarch
{
public class DontOfferConversation : QuestConversation
{
private bool m_Friend;
public DontOfferConversation(bool friend)
{
m_Friend = friend;
}
public DontOfferConversation()
{
}
public override object Message
{
get
{
if (m_Friend) return 1054081;
/* <I>The Solen Matriarch smiles as she eats the seed you offered.</I><BR><BR>
*
* Thank you for that seed. It was quite delicious. <BR><BR>
*
* I would offer to make you a friend of my colony, but you seem to be busy with
* another task at the moment. Perhaps you should finish whatever is occupying
* your attention at the moment and return to me once you're done.
*/
return 1054079;
}
}
public override bool Logged => false;
public override void ChildDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
m_Friend = reader.ReadBool();
}
public override void ChildSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write(m_Friend);
}
}
public class AcceptConversation : QuestConversation
{
public override object Message => 1054084;
public override void OnRead()
{
System.AddObjective(new KillInfiltratorsObjective());
}
}
public class DuringKillInfiltratorsConversation : QuestConversation
{
public override object Message => 1054089;
public override bool Logged => false;
}
public class GatherWaterConversation : QuestConversation
{
public override object Message => 1054091;
public override void OnRead()
{
System.AddObjective(new GatherWaterObjective());
}
}
public class DuringWaterGatheringConversation : QuestConversation
{
public override object Message => 1054094;
public override bool Logged => false;
}
public class ProcessFungiConversation : QuestConversation
{
private bool m_Friend;
public ProcessFungiConversation(bool friend)
{
m_Friend = friend;
}
public ProcessFungiConversation()
{
}
public override object Message
{
get
{
if (m_Friend) return 1054097;
/* <I>The Solen Matriarch listens as you report the completion of your
* tasks to her.</I><BR><BR>
*
* I give you my thanks for your help, and I will gladly make you a friend of my
* solen colony. My warriors, workers, and queens will not longer look at you
* as an intruder and attack you when you enter our lair.<BR><BR>
*
* I will also process some zoogi fungus into powder of translocation for you.
* Two of the zoogi fungi are required for each measure of the powder. I will
* process up to 200 zoogi fungi into 100 measures of powder of translocation.<BR><BR>
*
* I will also give you some gold for assisting me and my colony, but first let's
* take care of your zoogi fungus.
*/
return 1054096;
}
}
public override void OnRead()
{
System.AddObjective(new ProcessFungiObjective());
}
public override void ChildDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
m_Friend = reader.ReadBool();
}
public override void ChildSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write(m_Friend);
}
}
public class DuringFungiProcessConversation : QuestConversation
{
public override object Message => 1054099;
public override bool Logged => false;
}
public class FullBackpackConversation : QuestConversation
{
private bool m_Logged;
public FullBackpackConversation(bool logged)
{
m_Logged = logged;
}
public FullBackpackConversation()
{
m_Logged = true;
}
public override object Message => 1054102;
public override bool Logged => m_Logged;
public override void OnRead()
{
if (m_Logged)
System.AddObjective(new GetRewardObjective());
}
}
public class EndConversation : QuestConversation
{
public override object Message => 1054101;
public override void OnRead()
{
System.Complete();
}
}
}

View file

@ -0,0 +1,299 @@
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Engines.Plants;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
namespace Server.Engines.Quests.Matriarch
{
public abstract class BaseSolenMatriarch : BaseQuester
{
public BaseSolenMatriarch()
{
Body = 0x328;
if (!RedSolen)
Hue = 0x44E;
SpeechHue = 0;
}
public BaseSolenMatriarch(Serial serial) : base(serial)
{
}
public abstract bool RedSolen{ get; }
public override string DefaultName => "the solen matriarch";
public override bool DisallowAllMoves => false;
public override int GetIdleSound()
{
return 0x10D;
}
public override bool CanTalkTo(PlayerMobile to)
{
if (SolenMatriarchQuest.IsFriend(to, RedSolen))
return true;
return to.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen;
}
public override void OnTalk(PlayerMobile player, bool contextMenu)
{
Direction = GetDirectionTo(player);
if (player.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen)
{
if (qs.IsObjectiveInProgress(typeof(KillInfiltratorsObjective)))
{
qs.AddConversation(new DuringKillInfiltratorsConversation());
}
else
{
QuestObjective obj = qs.FindObjective<ReturnAfterKillsObjective>();
if (obj?.Completed == false)
{
obj.Complete();
}
else if (qs.IsObjectiveInProgress(typeof(GatherWaterObjective)))
{
qs.AddConversation(new DuringWaterGatheringConversation());
}
else
{
obj = qs.FindObjective<ReturnAfterWaterObjective>();
if (obj?.Completed == false)
{
obj.Complete();
}
else if (qs.IsObjectiveInProgress(typeof(ProcessFungiObjective)))
{
qs.AddConversation(new DuringFungiProcessConversation());
}
else
{
obj = qs.FindObjective<GetRewardObjective>();
if (obj?.Completed == false)
{
if (SolenMatriarchQuest.GiveRewardTo(player))
obj.Complete();
else
qs.AddConversation(new FullBackpackConversation(false));
}
}
}
}
}
else if (SolenMatriarchQuest.IsFriend(player, RedSolen))
{
QuestSystem newQuest = new SolenMatriarchQuest(player, RedSolen);
if (player.Quest == null && QuestSystem.CanOfferQuest(player, typeof(SolenMatriarchQuest)))
newQuest.SendOffer();
else
newQuest.AddConversation(new DontOfferConversation(true));
}
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
if (from is PlayerMobile player)
{
if (dropped is Seed)
{
if (player.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen)
{
SayTo(player, 1054080); // Thank you for that plant seed. Those have such wonderful flavor.
}
else
{
QuestSystem newQuest = new SolenMatriarchQuest(player, RedSolen);
if (player.Quest == null && QuestSystem.CanOfferQuest(player, typeof(SolenMatriarchQuest)))
newQuest.SendOffer();
else
newQuest.AddConversation(
new DontOfferConversation(SolenMatriarchQuest.IsFriend(player, RedSolen)));
}
dropped.Delete();
return true;
}
if (dropped is ZoogiFungus fungus)
{
OnGivenFungi(player, fungus);
return fungus.Deleted;
}
}
return base.OnDragDrop(from, dropped);
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
if (from.Alive)
if (from is PlayerMobile pm)
if (pm.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen)
if (qs.IsObjectiveInProgress(typeof(ProcessFungiObjective)))
list.Add(new ProcessZoogiFungusEntry(this, pm));
}
public void OnGivenFungi(PlayerMobile player, ZoogiFungus fungi)
{
Direction = GetDirectionTo(player);
if (player.Quest is SolenMatriarchQuest qs && qs.RedSolen == RedSolen)
{
QuestObjective obj = qs.FindObjective<ProcessFungiObjective>();
if (obj?.Completed == false)
{
int amount = fungi.Amount / 2;
if (amount > 100)
amount = 100;
if (amount > 0)
{
if (amount * 2 >= fungi.Amount)
fungi.Delete();
else
fungi.Amount -= amount * 2;
PowderOfTranslocation powder = new PowderOfTranslocation(amount);
player.AddToBackpack(powder);
player.SendLocalizedMessage(1054100); // You receive some powder of translocation.
obj.Complete();
}
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
private class ProcessZoogiFungusEntry : ContextMenuEntry
{
private PlayerMobile m_From;
private BaseSolenMatriarch m_Matriarch;
public ProcessZoogiFungusEntry(BaseSolenMatriarch matriarch, PlayerMobile from) : base(6184)
{
m_Matriarch = matriarch;
m_From = from;
}
public override void OnClick()
{
if (m_From.Alive)
m_From.Target = new ProcessFungiTarget(m_Matriarch, m_From);
}
}
private class ProcessFungiTarget : Target
{
private PlayerMobile m_From;
private BaseSolenMatriarch m_Matriarch;
public ProcessFungiTarget(BaseSolenMatriarch matriarch, PlayerMobile from) : base(-1, false, TargetFlags.None)
{
m_Matriarch = matriarch;
m_From = from;
}
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
from.SendLocalizedMessage(1042021, "", 0x59); // Cancelled.
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is ZoogiFungus fungus)
{
if (fungus.IsChildOf(m_From.Backpack))
m_Matriarch.OnGivenFungi(m_From, fungus);
else
m_From.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
}
}
public class RedSolenMatriarch : BaseSolenMatriarch
{
[Constructible]
public RedSolenMatriarch()
{
}
public RedSolenMatriarch(Serial serial) : base(serial)
{
}
public override bool RedSolen => true;
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
public class BlackSolenMatriarch : BaseSolenMatriarch
{
[Constructible]
public BlackSolenMatriarch()
{
}
public BlackSolenMatriarch(Serial serial) : base(serial)
{
}
public override bool RedSolen => false;
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
}

View file

@ -0,0 +1,142 @@
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.Quests.Matriarch
{
public class KillInfiltratorsObjective : QuestObjective
{
public override object Message => ((SolenMatriarchQuest)System).RedSolen ? 1054086 : 1054085;
public override int MaxProgress => 7;
public override void RenderProgress(BaseQuestGump gump)
{
if (!Completed)
{
// Black/Red Solen Infiltrators killed:
gump.AddHtmlLocalized(70, 260, 270, 100, ((SolenMatriarchQuest)System).RedSolen ? 1054088 : 1054087,
BaseQuestGump.Blue);
gump.AddLabel(70, 280, 0x64, CurProgress.ToString());
gump.AddLabel(100, 280, 0x64, "/");
gump.AddLabel(130, 280, 0x64, MaxProgress.ToString());
}
else
{
base.RenderProgress(gump);
}
}
public override bool IgnoreYoungProtection(Mobile from)
{
if (Completed)
return false;
bool redSolen = ((SolenMatriarchQuest)System).RedSolen;
if (redSolen)
return from is BlackSolenInfiltratorWarrior || from is BlackSolenInfiltratorQueen;
return from is RedSolenInfiltratorWarrior || from is RedSolenInfiltratorQueen;
}
public override void OnKill(BaseCreature creature, Container corpse)
{
bool redSolen = ((SolenMatriarchQuest)System).RedSolen;
if (redSolen)
{
if (creature is BlackSolenInfiltratorWarrior || creature is BlackSolenInfiltratorQueen)
CurProgress++;
}
else
{
if (creature is RedSolenInfiltratorWarrior || creature is RedSolenInfiltratorQueen)
CurProgress++;
}
}
public override void OnComplete()
{
System.AddObjective(new ReturnAfterKillsObjective());
}
}
public class ReturnAfterKillsObjective : QuestObjective
{
public override object Message => 1054090;
public override void OnComplete()
{
System.AddConversation(new GatherWaterConversation());
}
}
public class GatherWaterObjective : QuestObjective
{
public override object Message => 1054092;
public override int MaxProgress => 40;
public override void RenderProgress(BaseQuestGump gump)
{
if (!Completed)
{
gump.AddHtmlLocalized(70, 260, 270, 100, 1054093, BaseQuestGump.Blue); // Gallons of Water gathered:
gump.AddLabel(70, 280, 0x64, (CurProgress / 5).ToString());
gump.AddLabel(100, 280, 0x64, "/");
gump.AddLabel(130, 280, 0x64, (MaxProgress / 5).ToString());
}
else
{
base.RenderProgress(gump);
}
}
public override void OnComplete()
{
System.AddObjective(new ReturnAfterWaterObjective());
}
}
public class ReturnAfterWaterObjective : QuestObjective
{
public override object Message => 1054095;
public override void OnComplete()
{
PlayerMobile player = System.From;
bool redSolen = ((SolenMatriarchQuest)System).RedSolen;
bool friend = SolenMatriarchQuest.IsFriend(player, redSolen);
System.AddConversation(new ProcessFungiConversation(friend));
if (redSolen)
player.SolenFriendship = SolenFriendship.Red;
else
player.SolenFriendship = SolenFriendship.Black;
}
}
public class ProcessFungiObjective : QuestObjective
{
public override object Message => 1054098;
public override void OnComplete()
{
if (SolenMatriarchQuest.GiveRewardTo(System.From))
System.Complete();
else
System.AddConversation(new FullBackpackConversation(true));
}
}
public class GetRewardObjective : QuestObjective
{
public override object Message => 1054149;
public override void OnComplete()
{
System.AddConversation(new EndConversation());
}
}
}

View file

@ -0,0 +1,124 @@
using System;
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.Quests.Matriarch
{
public class SolenMatriarchQuest : QuestSystem
{
private static Type[] m_TypeReferenceTable =
{
typeof(DontOfferConversation),
typeof(AcceptConversation),
typeof(DuringKillInfiltratorsConversation),
typeof(GatherWaterConversation),
typeof(DuringWaterGatheringConversation),
typeof(ProcessFungiConversation),
typeof(DuringFungiProcessConversation),
typeof(FullBackpackConversation),
typeof(EndConversation),
typeof(KillInfiltratorsObjective),
typeof(ReturnAfterKillsObjective),
typeof(GatherWaterObjective),
typeof(ReturnAfterWaterObjective),
typeof(ProcessFungiObjective),
typeof(GetRewardObjective)
};
public SolenMatriarchQuest(PlayerMobile from, bool redSolen) : base(from)
{
RedSolen = redSolen;
}
// Serialization
public SolenMatriarchQuest()
{
}
public override Type[] TypeReferenceTable => m_TypeReferenceTable;
public override object Name => 1054147;
public override object OfferMessage
{
get
{
if (IsFriend(From, RedSolen)) return 1054083;
/* <I>The Solen Matriarch smiles happily as she eats the seed you offered.</I><BR><BR>
*
* I think you for that seed. I was quite delicious. So full of flavor.<BR><BR>
*
* Hmm... if you would like, I could make you a friend of my colony. This would stop
* the warriors, workers, and queens of my colony from thinking you are an intruder,
* thus they would not attack you. In addition, as a friend of my colony I will process
* zoogi fungus into powder of translocation for you.<BR><BR>
*
* To become a friend of my colony, I ask that you complete a couple tasks for me. These
* are the same tasks I will ask of you when you wish me to process zoogi fungus,
* by the way.<BR><BR>
*
* First, I would like for you to eliminate some infiltrators from the other solen colony.
* They are spying on my colony, and I fear for the safety of my people. They must
* be slain.<BR><BR>
*
* After that, I must ask that you gather some water for me. Our water supplies are
* inadequate, so we must try to supplement our reserve using water vats here in our
* lair.<BR><BR>
*
* Will you accept my offer?
*/
return 1054082;
}
}
public override TimeSpan RestartDelay => TimeSpan.Zero;
public override bool IsTutorial => false;
public override int Picture => 0x15C9;
public bool RedSolen{ get; private set; }
public override void ChildDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
RedSolen = reader.ReadBool();
}
public override void ChildSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write(RedSolen);
}
public override void Accept()
{
base.Accept();
AddConversation(new AcceptConversation());
}
public static bool IsFriend(PlayerMobile player, bool redSolen)
{
if (redSolen)
return player.SolenFriendship == SolenFriendship.Red;
return player.SolenFriendship == SolenFriendship.Black;
}
public static bool GiveRewardTo(PlayerMobile player)
{
Gold gold = new Gold(Utility.RandomMinMax(250, 350));
if (player.PlaceInBackpack(gold))
{
player.SendLocalizedMessage(1054076); // You have been given some gold.
return true;
}
gold.Delete();
return false;
}
}
}