public void addSubTask(QuestChallenge newTask, bool immediate) { List <QuestChallenge> list = obstacles.ToList <QuestChallenge>(); list.Insert(questStep + (immediate?0:1), newTask); _obstacles = list.ToArray(); }
public void onFailedQuest(Quest theQuest) { QuestChallenge goal = QuestManager.getGoal(theQuest); if (theQuest.miscData != null) { if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.EQUIP_ARMY) { //sideBstrength += 1; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.COMBAT) { object sideObj; theQuest.miscData.TryGetValue("WarSide", out sideObj); string sideStr = (string)sideObj; if (sideStr.Equals("A")) { //side A quest was a failure, so are defending //however, odds are narrower doCombat(ref sideBstrength, ref sideAstrength, theQuest, false); } else { //side B quest was a failure, so are defending //however, odds are narrower doCombat(ref sideAstrength, ref sideBstrength, theQuest, false); } } checkVictory(); } }
public void onSuccessfulQuest(Quest theQuest) { QuestChallenge goal = QuestManager.getGoal(theQuest); if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.HUNT_SPIRITS) { numSpirits--; if (numSpirits <= 0) { numGuildmastersAtEnd = StatisticsTracker.guildmastersElected.value; } } }
public void onFailedQuest(Quest theQuest) { QuestChallenge goal = QuestManager.getGoal(theQuest); if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.HUNT_SPIRITS) { if (theQuest.testLuck(2) == 0) { numSpirits++; } else { spiritPower++; } } }
public void onSuccessfulQuest(Quest theQuest) { QuestChallenge goal = QuestManager.getGoal(theQuest); if (theQuest.miscData != null) { if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.EQUIP_ARMY) { object sideObj; theQuest.miscData.TryGetValue("WarSide", out sideObj); string sideStr = (string)sideObj; if (sideStr.Equals("A")) { sideAstrength += 1; } else { sideBstrength += 1; } } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.COMBAT) { object sideObj; theQuest.miscData.TryGetValue("WarSide", out sideObj); string sideStr = (string)sideObj; if (sideStr.Equals("A")) { //side A quest was a success, so are attacking //odds are wider doCombat(ref sideAstrength, ref sideBstrength, theQuest, true); } else { //side B quest was a success, so are attacking //odds are wider doCombat(ref sideBstrength, ref sideAstrength, theQuest, true); } } checkVictory(); //else } if (goal.type == ChallengeTypes.Goals.OBSERVE_ENEMY) { hasInfo = true; } }
public void onSuccessfulQuest(Quest theQuest) { foreach (Industry ind in Main.instance.player.builtItems) { if (ind.industryType == Industries.IndustryTypesEnum.GOLD) { ind.addTimeRaw(50); } } QuestChallenge goal = QuestManager.getGoal(theQuest); if (goal.type == ChallengeTypes.Goals.DRAGON) { numDragons--; if (numDragons <= 0) { numGuildmastersAtEnd = StatisticsTracker.guildmastersElected.value; } } }
public void onSuccessfulQuest(Quest theQuest) { Rescued = false; QuestChallenge goal = QuestManager.getGoal(theQuest); if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.SOW_CHAOS) { return; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.HEART_TREE) { HeartTrees--; if (HeartTrees <= 0) { numGuildmastersAtEnd = StatisticsTracker.guildmastersElected.value; } } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.BURN_FOREST) { ForestSize -= 1; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.RESCUE_TAKEN) { Rescued = true; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.CLEANS_CORRUPTION) { Corruption -= 1; } else { return; //not one of ours } if (theQuest.miscData == null) { UnityEngine.Debug.Log("No misc data: " + goal.type.name); return; } }
public void finalizeQuest(ref Quest theQuest) { QuestChallenge goal = QuestManager.getGoal(theQuest); theQuest.miscData = new Dictionary <string, object>(); if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.SOW_CHAOS) { theQuest.miscData.Add("forest_corruption", 10); } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.HEART_TREE || goal.type == ChallengeTypes.Goals.DeepGoalSpecial.BURN_FOREST || goal.type == ChallengeTypes.Goals.DeepGoalSpecial.RESCUE_TAKEN || goal.type == ChallengeTypes.Goals.DeepGoalSpecial.CLEANS_CORRUPTION) { theQuest.miscData.Add("forest_corruption", 1); } else { return; } UnityEngine.Debug.Log("Finalizing quest: " + theQuest.miscData == null); }
public static Quest GenerateNewQuest(ObstacleType withGoal, string heroName) { //Debug.Log("Creating new quest with goal" + withGoal); if (withGoal == null) { throw new Exception("Error creating quest wtih null goal!"); } //TODO: moar detail List <QuestChallenge> arr = new List <QuestChallenge>(); QuestChallenge goal = new QuestChallenge(withGoal, 0); int total = ((IQuestGoal)goal.type).getNumTotalEncounters(); if (total < 7) { total = 7; } arr.Add(new QuestChallenge(ChallengeTypes.Initial.getRandom(rand), 0)); //begin for (int n = 0; n < total; n++) { if (n % 2 == 1) { if (n % 4 == 3) { arr.Add(new QuestChallenge(ChallengeTypes.Loot.getRandom(rand), 0)); } else { arr.Add(new QuestChallenge(ChallengeTypes.Unexpected.getRandom(rand), 0)); } } else { if (n % 4 == 2) { arr.Add(new QuestChallenge(ChallengeTypes.Travel.getRandom(rand), 0)); } else { arr.Add(new QuestChallenge(ChallengeTypes.General.getRandom(rand), 0)); } } } //end arr.Add(goal); QuestChallenge[] list = arr.ToArray(); long v; if (!Main.instance.player.questTypeCompletion.TryGetValue(list[list.Length - 1].type.name, out v)) { v = 0; } Quest q = new Quest(v, rand.Next(), list); int min = 0 + (StatisticsTracker.minQuestDifficulty.value / 3); int max = 4 + (StatisticsTracker.minQuestDifficulty.value / 3); Item i = Items.getRandom(rand, min, max); q.rewards[0] = new ItemStack(i, rand.Next(i.maxStackSize - i.minStackSize) + i.minStackSize); i = Items.getRandom(rand, 4, 7); q.rewards[1] = new ItemStack(i, rand.Next(i.maxStackSize - i.minStackSize) + i.minStackSize); q.heroName = heroName; //Name debugging //string debugName = names[0].FirstName + " " + names[0].LastName + " " + names[0].Postfix; //Debug.Log(debugName); q.timeUntilQuestExpires = 18000; //5 hours return(q); }
public void addSubTask(QuestChallenge newTask) { addSubTask(newTask, false); }
private EnumResult _doQuestStep(float t) { if (questComplete) { timeAftercomplete += t; return(EnumResult.CONTINUE); } questTotalTime -= (1.5f * t); if (questTimer > 0) { questTimer -= t; return(EnumResult.CONTINUE); } int initQuestStep = questStep; //if(questStep >= obstacles.Length || questStep < 0) { //Debug.Log(this.heroName); //foreach(QuestChallenge o in obstacles) { //Debug.Log(" " + o.type.name); //} //} QuestChallenge ob = obstacles[questStep]; List <ItemStack> used = new List <ItemStack>(); while (questTotalTime <= 0 && doesHeroHave(RequirementType.MANA)) { if (doesHeroHave(AidType.MANA_LARGE, ref used)) { questTotalTime += 360; } else if (doesHeroHave(AidType.MANA_MEDIUM, ref used)) { questTotalTime += 270; } else if (doesHeroHave(AidType.MANA_SMALL, ref used)) { questTotalTime += 180; } else if (doesHeroHave(AidType.MANA_TINY, ref used)) { questTotalTime += 90; } else { break; } } int healing = 0; foreach (ItemStack st in used) { healing += (st.doesStackHave(AidType.HEALING_TINY) ? 5 : 0); healing += (st.doesStackHave(AidType.HEALING_SMALL) ? 7 : 0); healing += (st.doesStackHave(AidType.HEALING_MEDIUM) ? 15 : 0); healing += (st.doesStackHave(AidType.HEALING_LARGE) ? 25 : 0); } heal(healing); if (questTotalTime <= 0 || heroCurHealth <= 0) { //hero dies //Debug.Log("FAIL " + heroName + ": " + ob.type.name + " | " + questTotalTime + ", " + heroCurHealth); object corwrap; int cor = 0; if (miscData != null && miscData.TryGetValue("cursed_corruption", out corwrap)) { cor = (int)corwrap; //Debug.Log("Corrupted: " + doesHeroHave(RequirementType.SPELL_RESIST) + ", " + cor); } Main.instance.player.getActiveDeepGoal().onFailedQuest(this); //Debug.Log(" " + obstacles[questStep-1].type.name); return(EnumResult.FAIL); } //Debug.Log("Hero is " + ob.type.desc); int fails = 0; int partials = 0; RequirementType lastType = 0; ItemStack lastStack = null; ItemStack altStack = null; //RequirementType statPot = RequirementType.AGILITY | RequirementType.STRENGTH | RequirementType.CHARISMA | RequirementType.INTELLIGENCE; foreach (RequireWrapper rw in ob.type.requirements) { bool foundAlt = false; bool altIsConsumed = true; foreach (ItemStack stack in inventory) { //forces requiring two *different* stacks for same-type requirements if not consumable if (lastType == rw.req && (stack == lastStack /*&& stack.item.isConsumable*/)) { continue; } lastStack = stack; if (stack.item.hasReqType(rw.req) && stack.stackSize > 0) { if (stack.item.isConsumable) { stack.stackSize--; } stack.onUsedDuringQuest(this); goto ObsList; } if (stack.item.hasReqType(rw.alt) && stack.stackSize > 0) { foundAlt = true; //alt items are ok, but we'd rather find the required one altStack = stack; altIsConsumed = rw.req != 0; } } //this looks so janky //if the loop is exited normally, inc failure or partials if (!foundAlt) { fails++; } else { //decrement used alt-type stack, as it was used if (altStack.item.isConsumable && altIsConsumed) { altStack.stackSize--; } altStack.onUsedDuringQuest(this); partials++; } //go here if success ObsList: //then check next requirement ; lastType = rw.req; } EnumResult result = ob.MakeAttempt(this, fails, partials); if (result == EnumResult.CRIT_FAIL && this.doesHeroHave(AidType.RETRY_FAILURE)) { result = ob.MakeAttempt(this, fails, partials); } ob.OnAttempt(result, this); questTimer += 60; questStep++; if (questStep > initQuestStep) { heal(5); } inventory.RemoveAll(x => x.stackSize <= 0); if (questStep >= obstacles.Length) { if (result < EnumResult.MIXED && ob.type is IQuestGoal) { //rare ending //Debug.Log("QUEST FAILURE " + ob.type.name + "|" + questTotalTime + "," + heroCurHealth); Main.instance.player.getActiveDeepGoal().onFailedQuest(this); return(EnumResult.FAIL); } //Debug.Log("SUCCESS " + ob.type.name + "|" + questTotalTime + "," + heroCurHealth); Main.instance.player.getActiveDeepGoal().onSuccessfulQuest(this); return(EnumResult.SUCCESS); } return(EnumResult.CONTINUE); }
public ChallengeLoadWrapper(QuestChallenge chal) { challenge = chal; }
public Quest(SerializationInfo info, StreamingContext context) { questRand = new System.Random(); heroMaxHealth = info.GetInt32("heroMaxHealth"); heroCurHealth = info.GetInt32("heroCurHealth"); heroName = info.GetString("heroName"); STR = info.GetInt32("STR"); AGL = info.GetInt32("AGL"); CHA = info.GetInt32("CHA"); INT = info.GetInt32("INT"); questTimer = (float)info.GetDouble("questTimer"); questTotalTime = (float)info.GetDouble("questTotalTime"); questStep = info.GetInt32("questStep"); int num = info.GetInt32("numObstacles"); questComplete = questStep >= num; _obstacles = new QuestChallenge[num]; for (int o = 0; o < num; o++) { QuestChallenge temp = (QuestChallenge)info.GetValue("obs_" + o, typeof(QuestChallenge)); //_obstacles[o] = (QuestChallenge)info.GetValue("obs_" + o, typeof(QuestChallenge)); fromDisk.Add(new ChallengeLoadWrapper(temp)); } originalGoal = GameRegistry.GetObstacleByID(info.GetString("originalGoal")); num = info.GetInt32("inventorySize"); inventory = new List <ItemStack>(); for (int o = 0; o < num; o++) { inventory.Add((ItemStack)info.GetValue("inven_" + o, typeof(ItemStack))); } timeUntilQuestExpires = (float)info.GetDouble("timeUntilQuestExpires"); numQuestsBefore = info.GetInt64("numQuestsBefore"); rewards = new ItemStack[2]; rewards[0] = (ItemStack)info.GetValue("reward_0", typeof(ItemStack)); rewards[1] = (ItemStack)info.GetValue("reward_1", typeof(ItemStack)); if (Main.saveVersionFromDisk >= 9) { if (info.GetBoolean("hasMiscData")) { miscData = (Dictionary <string, object>)info.GetValue("miscData", typeof(Dictionary <string, object>)); } } if (Main.saveVersionFromDisk >= 16) { finalResult = (EnumResult)info.GetInt32("finalResult"); } if (Main.saveVersionFromDisk >= 24) { num = info.GetInt32("numKnownRequirements"); knownRequirements = new long[num]; for (int o = 0; o < num; o++) { long temp = (long)info.GetValue("knReq_" + o, typeof(long)); knownRequirements[o] = temp; } } else { } }
public void onFailedQuest(Quest theQuest) { QuestChallenge goal = QuestManager.getGoal(theQuest); if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.SOW_CHAOS) { bool haveEnoughCorruption = HeartTrees == Corruption; bool haveEnoughForest = Corruption * 2 == ForestSize; if (haveEnoughCorruption && haveEnoughForest) { HeartTrees++; } else if (haveEnoughCorruption && !haveEnoughForest) { ForestSize++; } else { Corruption++; } return; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.HEART_TREE) { Corruption += 1; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.BURN_FOREST) { if (Corruption * 2 < ForestSize) { Corruption += 1; } } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.RESCUE_TAKEN) { HeartTrees++; } else if (goal.type == ChallengeTypes.Goals.DeepGoalSpecial.CLEANS_CORRUPTION) { ForestSize += 1; } else { return; //not one of ours } if (theQuest.miscData == null) { UnityEngine.Debug.Log("No misc data: " + goal.type.name); return; } object corwrap; int cor = 0; if (theQuest.miscData.TryGetValue("forest_corruption", out corwrap)) { cor = (int)corwrap; theQuest.miscData.Remove("forest_corruption"); } if (cor >= 6) { Agents++; } }