10 public static Quest Create(
string _id,
string _idPerson =
null,
Chara c =
null)
12 Quest quest = ClassCache.Create<
Quest>(
EClass.sources.quests.map[_id].type.IsEmpty(
"Quest"),
"Elin");
14 quest.person =
new Person(_idPerson,
null);
16 if (questDestZone !=
null && questDestZone.IsDeliver)
19 questDestZone.SetDest(zone, zone.dictCitizen.Keys.RandomItem<
int>());
23 quest.SetClient(c,
true);
30 public static List<Zone> ListDeliver()
32 List<Zone> list =
new List<Zone>();
33 foreach (
Zone zone
in EClass.game.spatials.Zones)
35 if (zone !=
EClass._zone && zone.IsTown && !zone.IsClosed && !zone.IsPCFaction && zone.dictCitizen.Count > 0 && zone.CanBeDeliverDestination)
45 public Zone ClientZone
50 if (this.chara ==
null || !this.chara.IsGlobal ||
this.chara.currentZone ==
null)
52 if ((result =
RefZone.Get(
this.uidClientZone)) ==
null)
54 if (this.source.idZone.IsEmpty())
56 return EClass.game.StartZone;
58 return EClass.game.spatials.Find(this.source.idZone);
63 result = this.chara.currentZone;
75 return this.person.chara;
85 return EClass.sources.quests.map[this.idSource];
101 public bool IsExpired
105 return (this.deadline > 0 && this.Hours < 0) || this.isComplete;
115 if (this.deadline != 0)
117 return EClass.world.date.GetRemainingHours(this.deadline);
125 public string TextDeadline
129 if (this.deadline != 0)
131 return Date.GetText((this.Hours < 0) ? 0 : this.Hours);
133 return "dateDayVoid".lang();
139 public virtual bool HasDLC
149 public virtual string idSource
159 public virtual string RewardSuffix
169 public virtual bool FameContent
179 public virtual string TextExtra
183 if (!this.FameContent)
187 return "dangerLv".lang(this.DangerLv.ToString() ??
"",
null,
null,
null,
null);
193 public virtual int DangerLv
197 return this.dangerLv;
203 public virtual int AffinityGain
213 public virtual int BaseMoney
217 return this.source.money;
223 public virtual int KarmaOnFail
233 public virtual bool CanAbandon
237 return this.IsRandomQuest;
243 public virtual int FameOnComplete
253 public virtual int RangeDeadLine
263 public virtual bool UseInstanceZone
273 public virtual bool ForbidTeleport
283 public virtual bool RequireClientInSameZone
293 public virtual Quest.DifficultyType difficultyType
297 return Quest.DifficultyType.Default;
302 public virtual Thing GetDestThing()
308 public virtual int GetExtraMoney()
314 public virtual int GetRewardPlat(
int money)
316 return 1 +
EClass.rnd(2) +
EClass.rndHalf((
int)Mathf.Sqrt((
float)(money / 200)));
321 public virtual Chara DestChara
331 public virtual string RefDrama1
335 if (this.task ==
null)
339 return this.task.RefDrama1;
345 public virtual string RefDrama2
349 if (this.task ==
null)
353 return this.task.RefDrama2;
359 public virtual string RefDrama3
363 if (this.task ==
null)
367 return this.task.RefDrama3;
373 public virtual string RefDrama4
383 public virtual string TitlePrefix
392 public override bool Equals(
object obj)
396 int? num2 = (quest !=
null) ?
new int?(quest.uid) :
null;
397 return num == num2.GetValueOrDefault() & num2 !=
null;
401 public virtual bool IsVisibleOnQuestBoard()
403 return (!this.RequireClientInSameZone || (this.chara !=
null && this.chara.IsAliveInCurrentZone)) &&
EClass.world.date.GetRaw(0) >= this.startDate && this.CanStartQuest() && ((!this.chara.IsPCFaction &&
this is
QuestRandom) ||
EClass._zone.IsPCFaction) && (this.chara ==
null || !(this.chara.trait is
TraitLoytel) ||
this.chara.currentZone ==
null ||
this.chara.currentZone.IsPCFaction);
407 public virtual bool CanStartQuest()
413 public virtual bool CanUpdateOnTalk(
Chara c)
420 public virtual bool CanAutoAdvance
430 public virtual bool IsRandomQuest
439 public virtual Zone CreateInstanceZone(
Chara c)
445 public virtual bool UpdateOnTalk()
455 if (this.RangeDeadLine != 0)
457 this.deadline =
EClass.world.date.GetRaw(0) + (36 +
EClass.rnd(12)) * 60 +
EClass.rnd(this.RangeDeadLine) * 1440;
459 this.uid =
EClass.game.quests.uid;
463 switch (this.difficultyType)
465 case Quest.DifficultyType.Deliver:
466 case Quest.DifficultyType.Supply:
467 case Quest.DifficultyType.Escort:
468 this.difficulty = Mathf.Clamp(6 - this.Hours / 48, 1, 6);
470 case Quest.DifficultyType.Bulk:
471 this.difficulty = Mathf.Clamp(
EClass.rnd(
EClass.rnd(((
EClass._zone.branch !=
null) ?
EClass._zone.branch.lv : 1) + 3)) + 1, 1, 6);
473 case Quest.DifficultyType.Farm:
474 this.difficulty = 1 +
EClass.rnd(3 +
EClass.pc.Evalue(250) / 10);
476 case Quest.DifficultyType.Music:
477 this.difficulty = 1 +
EClass.rnd(3 +
EClass.pc.Evalue(241) / 10);
482 this.difficulty = Mathf.Clamp(this.difficulty, 1, 7);
484 if (this.task !=
null)
488 int fameLv =
EClass.pc.FameLv;
489 this.dangerLv = Mathf.Max(fameLv +
EClass.rnd(fameLv / 10 + 5) -
EClass.rnd(fameLv / 10 + 5), 1);
490 this.rewardMoney = (this.BaseMoney +
EClass.rnd(this.BaseMoney / 4) + this.GetExtraMoney()) * (55 + this.difficulty * 15) / 100;
494 public virtual void OnInit()
499 public Quest SetClient(
Chara c,
bool assignQuest =
true)
503 this.person =
new Person();
510 if (c.currentZone !=
null)
512 this.uidClientZone = c.currentZone.uid;
514 this.person =
new Person(c);
522 this.task.SetOwner(
this);
529 if (this.task !=
null)
536 public virtual void OnStart()
541 public virtual void OnEnterZone()
546 public virtual void OnClickQuest()
548 if (!this.source.drama.IsEmpty())
550 LayerDrama.currentQuest =
this;
551 SoundManager.ForceBGM();
552 this.chara.ShowDialog(this.source.drama[0], (
this.source.drama.Length > 1) ?
this.source.drama[1] : (
"quest_" +
this.source.id),
"");
555 LayerDrama.currentQuest =
this;
556 LayerDrama.forceJump =
"_quest";
557 this.chara.ShowDialog();
563 EClass.Sound.Play(
"questFail");
564 EClass.player.ModFame(-10 - (
int)((
float)
EClass.player.fame * 0.05f));
565 EClass.player.ModKarma(this.KarmaOnFail);
566 EClass.game.quests.Remove(
this);
567 if (this.chara !=
null && this.chara.quest !=
null &&
this.chara.quest.uid ==
this.uid)
569 this.chara.quest =
null;
571 if (this.ClientZone !=
null)
573 this.ClientZone.completedQuests.Add(this.uid);
579 public virtual void OnFail()
584 public virtual void ShowCompleteText()
586 EClass.Sound.Play(
"questComplete");
587 Msg.Say(
"completeQuest", this.GetTitle(),
null,
null,
null);
591 public void Complete()
593 this.OnBeforeComplete();
594 EClass.game.quests.Remove(
this);
595 EClass.game.quests.completedIDs.Add(this.
id);
596 EClass.game.quests.completedTypes.Add(base.GetType().ToString());
597 this.ShowCompleteText();
601 EClass.Sound.Play(
"confetti");
604 if (this.chara !=
null && this.chara.quest !=
null &&
this.chara.quest.uid ==
this.uid)
606 this.chara.quest =
null;
608 if (this.DestChara !=
null && this.DestChara.IsAliveInCurrentZone &&
this.AffinityGain != 0)
610 this.DestChara.ModAffinity(
EClass.pc,
this.AffinityGain,
true);
612 if (this.ClientZone !=
null)
614 this.ClientZone.completedQuests.Add(this.uid);
617 EClass.player.ModKarma(1);
618 this.isComplete =
true;
622 public virtual void OnBeforeComplete()
627 public virtual void OnDropReward()
632 public Thing DropReward(
string id)
634 return this.DropReward(
ThingGen.Create(
id, -1, -1));
640 return EClass.player.DropReward(t,
false);
644 public virtual void OnComplete()
649 public void CompleteTask()
651 this.OnCompleteTask();
656 public virtual void OnCompleteTask()
658 EClass.game.quests.Complete(
this);
662 public virtual void OnGiveItem(
Chara c,
Thing t)
664 if (this.task !=
null)
666 this.task.OnGiveItem(c, t);
667 if (this.task.IsComplete())
675 public virtual void OnKillChara(
Chara c)
677 if (this.task !=
null)
679 this.task.OnKillChara(c);
680 if (this.task.IsComplete())
688 public virtual void OnModKarma(
int a)
690 if (this.task !=
null)
692 this.task.OnModKarma(a);
693 if (this.task.IsComplete())
701 public void NextPhase()
703 this.ChangePhase(this.phase + 1);
707 public void ChangePhase(
int a)
710 this.UpdateJournal();
711 this.OnChangePhase(a);
715 public virtual void OnChangePhase(
int a)
720 public string Parse(
string s)
726 GameLang.refDrama1 = this.RefDrama1.TagColor(FontColor.QuestObjective,
null);
727 GameLang.refDrama2 = this.RefDrama2.TagColor(FontColor.QuestObjective,
null);
728 GameLang.refDrama3 = this.RefDrama3.TagColor(FontColor.QuestObjective,
null);
729 GameLang.refDrama4 = this.RefDrama4.TagColor(FontColor.QuestObjective,
null);
730 Rand.UseSeed(this.uid, delegate
732 s =
GameLang.ConvertDrama(s, this.chara);
733 if (this.chara !=
null)
735 s = this.chara.ApplyTone(s,
false);
738 s =
Card.ApplyTone(this.chara, ref s, this.person.tones,
this.person.gender,
false);
744 public virtual string GetTitle()
747 Rand.UseSeed(this.uid, delegate
749 s = this.source.GetText(
"name",
false).Split(Environment.NewLine.ToCharArray()).RandomItem<
string>();
755 public virtual string GetTrackerText()
757 string text = this.GetTextProgress();
758 if (text.IsEmpty() && !
this.IsRandomQuest)
760 text = this.GetDetail(
true);
766 public virtual string GetDetail(
bool onJournal =
false)
768 string text = this.Parse(this.GetDetailText(onJournal));
771 string textProgress = this.GetTextProgress();
772 if (!textProgress.IsEmpty())
774 text = text +
"\n\n" + textProgress;
777 if (this.task !=
null)
779 this.task.OnGetDetail(ref text, onJournal);
786 public virtual string GetDetailText(
bool onJournal =
false)
789 Rand.UseSeed(this.uid, delegate
791 s = this.source.GetText(
"detail",
false).Split(Environment.NewLine.ToCharArray()).RandomItem<
string>();
793 return s.ToTitleCase(
false);
797 public virtual string GetTextProgress()
799 if (this.task !=
null)
801 return this.task.GetTextProgress();
807 public string GetRewardText()
812 result = (
"qReward" + this.RewardSuffix).lang(this.rewardMoney.ToString() ??
"",
null,
null,
null,
null);
818 public virtual string GetTalkProgress()
820 return this.Parse(this.source.GetText(
"talkProgress",
true));
824 public virtual string GetTalkComplete()
826 return this.Parse(this.source.GetText(
"talkComplete",
true));
830 public void UpdateJournal()
833 Msg.Say(
"journalUpdate2", this.GetTitle(),
null,
null,
null);
837 public virtual bool IsDeliverTarget(
Chara c)
843 public virtual bool CanDeliverToClient(
Chara c)
849 public virtual bool CanDeliverToBox(
Thing t)
855 public virtual bool Deliver(
Chara c,
Thing t =
null)
862 public virtual string NameDeliver
871 public const int PhaseComplete = 999;
883 public int uidClientZone;
899 public int difficulty;
903 public int rewardMoney;
907 public int bonusMoney;
911 public int startDate;
923 public bool isComplete;
941 public enum DifficultyType
962 public enum SubReward