public void OnQuestComplete(FishQuestObjective obj) { foreach (KeyValuePair <Type, int[]> kvp in obj.Line) { Type type = kvp.Key; int index = FishQuestHelper.GetIndexForType(type); if (m_HaveFished.ContainsKey(index)) { if (m_HaveFished[index] >= 20) { m_HaveFished[index] = 10; } else { m_HaveFished[index] += 5; } } else { m_HaveFished.Add(index, 15); } if (!m_TimesFished.ContainsKey(index)) { m_TimesFished[index] = 0; } m_TimesFished[index]++; } }
public double GetPointsAwarded(FishQuestObjective obj) { double toAward = 0.0; foreach (KeyValuePair <Type, int[]> kvp in obj.Line) { Type type = kvp.Key; int value = kvp.Value[1]; if (FishQuestHelper.IsShallowWaterFish(type)) { toAward += value; } else if (FishQuestHelper.IsCrustacean(type) || FishQuestHelper.IsDeepWaterFish(type)) { toAward += value * 2; } else if (FishQuestHelper.IsDungeonFish(type)) { toAward += value * 3; } m_Reputation += toAward; } return(toAward); }
public void OnQuestResign(Type type) { int index = FishQuestHelper.GetIndexForType(type); if (index < 0) { return; } m_Reputation -= 20; if (m_HaveFished.ContainsKey(index)) { if (m_HaveFished[index] > 10) { m_HaveFished[index] -= 5; } else { m_HaveFished[index] = 5; } } else { m_HaveFished.Add(index, 10); } }
public int CalculateLines() { int eligibleIndex = FishQuestHelper.GetIndexForSkillLevel(m_Player); double line2 = 0.0; double line3 = 0.0; double line4 = 0.0; double line5 = 0.0; double line6 = 0.0; for (int i = 0; i < eligibleIndex; i++) { if (!m_TimesFished.ContainsKey(i)) { continue; } int timesDone = Math.Min(6, m_TimesFished[i]); int toAdd = 100 / eligibleIndex; switch (timesDone) { case 6: goto case 5; case 5: line6 += toAdd; goto case 4; case 4: line5 += toAdd; goto case 3; case 3: line4 += toAdd; goto case 2; case 2: line3 += toAdd; goto case 1; case 1: line2 += toAdd; goto case 0; case 0: default: break; } } if (Math.Min(85, line6) >= Utility.Random(100)) { return(6); } if (Math.Min(85, line5) >= Utility.Random(100)) { return(5); } if (Math.Min(85, line4) >= Utility.Random(100)) { return(4); } if (Math.Min(85, line3) >= Utility.Random(100)) { return(3); } if (Math.Min(85, line2) >= Utility.Random(100)) { return(2); } return(1); }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); writer.Write(Line.Count); foreach (KeyValuePair <Type, int[]> kvp in Line) { writer.Write(FishQuestHelper.GetIndexForType(kvp.Key)); writer.Write(kvp.Value[0]); writer.Write(kvp.Value[1]); } }
public ProfessionalFisherQuest(Mobile from, FishMonger monger, FishMonger quester, BaseBoat boat) { PlayerFishingEntry entry = PlayerFishingEntry.GetEntry(from, true); int lines; if (boat.IsClassicBoat) { lines = 1; } else { lines = entry.CalculateLines(); } m_TurnIn = monger; m_Boat = boat; int index = 0; int amount = 10; Type type = null; List <int> hasChosen = new List <int>(); Dictionary <Type, int> types = new Dictionary <Type, int>(); for (int i = 0; i < lines; i++) { entry.GetRandomFish(ref index, ref amount, hasChosen); hasChosen.Add(index); type = FishQuestHelper.GetTypeFromIndex(index); if (amount < 5) { amount = 5; } if (amount > 20) { amount = 20; } types[type] = amount; } AddObjective(new FishQuestObjective(types)); AddReward(new BaseReward(1116510)); //A rare reward from the Order of the Dragonfish. hasChosen.Clear(); m_Title = GetTitle(quester); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); int count = reader.ReadInt(); Line = new Dictionary <Type, int[]>(); for (int i = 0; i < count; i++) { Type type = FishQuestHelper.GetTypeFromIndex(reader.ReadInt()); int[] line = new int[] { reader.ReadInt(), reader.ReadInt() }; if (type != null) { Line[type] = line; } } }
public void GetRandomFish(ref int index, ref int amount, List <int> chosen) { int eligibleIndex = FishQuestHelper.GetIndexForSkillLevel(m_Player); while (true) { index = Utility.Random(eligibleIndex); if (!chosen.Contains(index)) { break; } } if (m_HaveFished.ContainsKey(index)) { amount = m_HaveFished[index]; } else { amount = 10; } }
public override void GiveRewards() { if (Owner != null) { PlayerFishingEntry entry = PlayerFishingEntry.GetEntry(Owner); if (entry != null) { double pointsAwarded = 0; FishQuestObjective obj = GetObjective(); if (obj != null) { pointsAwarded += entry.GetPointsAwarded(obj); entry.OnQuestComplete(obj); } FishQuestHelper.GiveRewards(Owner, entry, pointsAwarded); } } DeleteQuestItems(); base.GiveRewards(); }