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,53 @@
namespace Server.Engines.Quests.Naturalist
{
public class DontOfferConversation : QuestConversation
{
public override object Message => 1054052;
public override bool Logged => false;
}
public class AcceptConversation : QuestConversation
{
public override object Message => 1054043;
public override void OnRead()
{
System.AddObjective(new StudyNestsObjective());
}
}
public class NaturalistDuringStudyConversation : QuestConversation
{
public override object Message => 1054049;
public override bool Logged => false;
}
public class EndConversation : QuestConversation
{
public override object Message => 1054050;
public override void OnRead()
{
System.Complete();
}
}
public class SpecialEndConversation : QuestConversation
{
public override object Message => 1054051;
public override void OnRead()
{
System.Complete();
}
}
public class FullBackpackConversation : QuestConversation
{
public override object Message => 1054053;
public override bool Logged => false;
}
}

View file

@ -0,0 +1,191 @@
using Server.Engines.Plants;
using Server.Items;
using Server.Mobiles;
namespace Server.Engines.Quests.Naturalist
{
public class Naturalist : BaseQuester
{
[Constructible]
public Naturalist() : base("the Naturalist")
{
}
public Naturalist(Serial serial) : base(serial)
{
}
public override void InitBody()
{
InitStats(100, 100, 25);
Hue = Race.Human.RandomSkinHue();
Female = false;
Body = 0x190;
Name = NameList.RandomName("male");
}
public override void InitOutfit()
{
AddItem(new Tunic(0x598));
AddItem(new LongPants(0x59B));
AddItem(new Boots());
Utility.AssignRandomHair(this);
Utility.AssignRandomFacialHair(this, HairHue);
}
public override void OnTalk(PlayerMobile player, bool contextMenu)
{
if (player.Quest is StudyOfSolenQuest qs && qs.Naturalist == this)
{
StudyNestsObjective study = qs.FindObjective<StudyNestsObjective>();
if (study == null)
return;
if (!study.Completed)
{
PlaySound(0x41F);
qs.AddConversation(new NaturalistDuringStudyConversation());
return;
}
QuestObjective obj = qs.FindObjective<ReturnToNaturalistObjective>();
if (obj?.Completed == false)
{
Seed reward;
PlantType type;
switch (Utility.Random(17))
{
case 0:
type = PlantType.CampionFlowers;
break;
case 1:
type = PlantType.Poppies;
break;
case 2:
type = PlantType.Snowdrops;
break;
case 3:
type = PlantType.Bulrushes;
break;
case 4:
type = PlantType.Lilies;
break;
case 5:
type = PlantType.PampasGrass;
break;
case 6:
type = PlantType.Rushes;
break;
case 7:
type = PlantType.ElephantEarPlant;
break;
case 8:
type = PlantType.Fern;
break;
case 9:
type = PlantType.PonytailPalm;
break;
case 10:
type = PlantType.SmallPalm;
break;
case 11:
type = PlantType.CenturyPlant;
break;
case 12:
type = PlantType.WaterPlant;
break;
case 13:
type = PlantType.SnakePlant;
break;
case 14:
type = PlantType.PricklyPearCactus;
break;
case 15:
type = PlantType.BarrelCactus;
break;
default:
type = PlantType.TribarrelCactus;
break;
}
if (study.StudiedSpecialNest)
{
reward = new Seed(type, PlantHue.FireRed);
}
else
{
PlantHue hue;
switch (Utility.Random(3))
{
case 0:
hue = PlantHue.Pink;
break;
case 1:
hue = PlantHue.Magenta;
break;
default:
hue = PlantHue.Aqua;
break;
}
reward = new Seed(type, hue);
}
if (player.PlaceInBackpack(reward))
{
obj.Complete();
PlaySound(0x449);
PlaySound(0x41B);
if (study.StudiedSpecialNest)
qs.AddConversation(new SpecialEndConversation());
else
qs.AddConversation(new EndConversation());
}
else
{
reward.Delete();
qs.AddConversation(new FullBackpackConversation());
}
}
}
else
{
QuestSystem newQuest = new StudyOfSolenQuest(player, this);
if (player.Quest == null && QuestSystem.CanOfferQuest(player, typeof(StudyOfSolenQuest)))
{
PlaySound(0x42F);
newQuest.SendOffer();
}
else
{
PlaySound(0x448);
newQuest.AddConversation(new DontOfferConversation());
}
}
}
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,64 @@
using System.Linq;
namespace Server.Engines.Quests.Naturalist
{
public class NestArea
{
private static readonly NestArea[] m_Areas =
{
new NestArea(false, new Rectangle2D(5861, 1787, 26, 25)),
new NestArea(false, new Rectangle2D(5734, 1788, 14, 50),
new Rectangle2D(5748, 1800, 3, 34),
new Rectangle2D(5751, 1808, 2, 20)),
new NestArea(false, new Rectangle2D(5907, 1908, 19, 43)),
new NestArea(false, new Rectangle2D(5721, 1926, 24, 29),
new Rectangle2D(5745, 1935, 7, 22)),
new NestArea(true, new Rectangle2D(5651, 1853, 21, 32),
new Rectangle2D(5672, 1857, 6, 20))
};
private Rectangle2D[] m_Rects;
private NestArea(bool special, params Rectangle2D[] rects)
{
Special = special;
m_Rects = rects;
}
public static int NonSpecialCount => m_Areas.Count(area => !area.Special);
public bool Special{ get; }
public int ID
{
get
{
for (int i = 0; i < m_Areas.Length; i++)
if (m_Areas[i] == this)
return i;
return 0;
}
}
public static NestArea Find(IPoint2D p)
{
return m_Areas.FirstOrDefault(area => area.Contains(p));
}
public static NestArea GetByID(int id)
{
if (id >= 0 && id < m_Areas.Length)
return m_Areas[id];
return null;
}
public bool Contains(IPoint2D p)
{
return m_Rects.Any(rect => rect.Contains(p));
}
}
}

View file

@ -0,0 +1,180 @@
using System;
using System.Collections.Generic;
using Server.Mobiles;
namespace Server.Engines.Quests.Naturalist
{
public class StudyNestsObjective : QuestObjective
{
private NestArea m_CurrentNest;
private List<NestArea> m_StudiedNests = new List<NestArea>();
private DateTime m_StudyBegin;
private StudyState m_StudyState;
public override object Message => 1054044;
public override int MaxProgress => NestArea.NonSpecialCount;
public bool StudiedSpecialNest{ get; private set; }
public override bool GetTimerEvent()
{
return true;
}
public override void CheckProgress()
{
PlayerMobile from = System.From;
if (m_CurrentNest != null)
{
NestArea nest = m_CurrentNest;
if ((from.Map == Map.Trammel || from.Map == Map.Felucca) && nest.Contains(from))
{
if (m_StudyState != StudyState.Inactive)
{
TimeSpan time = DateTime.UtcNow - m_StudyBegin;
if (time > TimeSpan.FromSeconds(30.0))
{
m_StudiedNests.Add(nest);
m_StudyState = StudyState.Inactive;
if (m_CurrentNest.Special)
{
from.SendLocalizedMessage(
1054057); // You complete your examination of this bizarre Egg Nest. The Naturalist will undoubtedly be quite interested in these notes!
StudiedSpecialNest = true;
}
else
{
from.SendLocalizedMessage(
1054054); // You have completed your study of this Solen Egg Nest. You put your notes away.
CurProgress++;
}
}
else if (m_StudyState == StudyState.FirstStep && time > TimeSpan.FromSeconds(15.0))
{
if (!nest.Special)
from.SendLocalizedMessage(
1054058); // You begin recording your completed notes on a bit of parchment.
m_StudyState = StudyState.SecondStep;
}
}
}
else
{
if (m_StudyState != StudyState.Inactive)
from.SendLocalizedMessage(
1054046); // You abandon your study of the Solen Egg Nest without gathering the needed information.
m_CurrentNest = null;
}
}
else if (from.Map == Map.Trammel || from.Map == Map.Felucca)
{
NestArea nest = NestArea.Find(from);
if (nest != null)
{
m_CurrentNest = nest;
m_StudyBegin = DateTime.UtcNow;
if (m_StudiedNests.Contains(nest))
{
m_StudyState = StudyState.Inactive;
from.SendLocalizedMessage(
1054047); // You glance at the Egg Nest, realizing you've already studied this one.
}
else
{
m_StudyState = StudyState.FirstStep;
if (nest.Special)
from.SendLocalizedMessage(
1054056); // You notice something very odd about this Solen Egg Nest. You begin taking notes.
else
from.SendLocalizedMessage(
1054045); // You begin studying the Solen Egg Nest to gather information.
if (from.Female)
from.PlaySound(0x30B);
else
from.PlaySound(0x419);
}
}
}
}
public override void RenderProgress(BaseQuestGump gump)
{
if (!Completed)
{
gump.AddHtmlLocalized(70, 260, 270, 100, 1054055, BaseQuestGump.Blue); // Solen Nests Studied :
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 void OnComplete()
{
System.AddObjective(new ReturnToNaturalistObjective());
}
public override void ChildDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
int count = reader.ReadEncodedInt();
for (int i = 0; i < count; i++)
{
NestArea nest = NestArea.GetByID(reader.ReadEncodedInt());
m_StudiedNests.Add(nest);
}
StudiedSpecialNest = reader.ReadBool();
}
public override void ChildSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.WriteEncodedInt(m_StudiedNests.Count);
foreach (NestArea nest in m_StudiedNests)
writer.WriteEncodedInt(nest.ID);
writer.Write(StudiedSpecialNest);
}
private enum StudyState
{
Inactive,
FirstStep,
SecondStep
}
}
public class ReturnToNaturalistObjective : QuestObjective
{
public override object Message => 1054048;
public override void RenderProgress(BaseQuestGump gump)
{
string count = NestArea.NonSpecialCount.ToString();
gump.AddHtmlLocalized(70, 260, 270, 100, 1054055, BaseQuestGump.Blue); // Solen Nests Studied :
gump.AddLabel(70, 280, 0x64, count);
gump.AddLabel(100, 280, 0x64, "/");
gump.AddLabel(130, 280, 0x64, count);
}
}
}

View file

@ -0,0 +1,66 @@
using System;
using Server.Mobiles;
namespace Server.Engines.Quests.Naturalist
{
public class StudyOfSolenQuest : QuestSystem
{
private static Type[] m_TypeReferenceTable =
{
typeof(StudyNestsObjective),
typeof(ReturnToNaturalistObjective),
typeof(DontOfferConversation),
typeof(AcceptConversation),
typeof(NaturalistDuringStudyConversation),
typeof(EndConversation),
typeof(SpecialEndConversation),
typeof(FullBackpackConversation)
};
public StudyOfSolenQuest(PlayerMobile from, Naturalist naturalist) : base(from)
{
Naturalist = naturalist;
}
// Serialization
public StudyOfSolenQuest()
{
}
public override Type[] TypeReferenceTable => m_TypeReferenceTable;
public override object Name => 1054041;
public override object OfferMessage => 1054042;
public override TimeSpan RestartDelay => TimeSpan.Zero;
public override bool IsTutorial => false;
public override int Picture => 0x15C7;
public Naturalist Naturalist{ get; private set; }
public override void ChildDeserialize(GenericReader reader)
{
int version = reader.ReadEncodedInt();
Naturalist = (Naturalist)reader.ReadMobile();
}
public override void ChildSerialize(GenericWriter writer)
{
writer.WriteEncodedInt(0); // version
writer.Write(Naturalist);
}
public override void Accept()
{
base.Accept();
Naturalist?.PlaySound(0x431);
AddConversation(new AcceptConversation());
}
}
}