/// <summary> /// Fixing this properly means rewriting the attack array gen as something marginally sane, so this is here until that happens. /// </summary> void ShittyGen_HackySanityCheckForStaves(ref BattlerAction checkingAtk) { if (attacks[0] == BattlerAction.IceBullet || attacks[0] == BattlerAction.FrostSpear || attacks[0] == BattlerAction.CometStrike) { if (checkingAtk == BattlerAction.IceBullet) { checkingAtk = BattlerAction.HealingWind; } else if (checkingAtk == BattlerAction.FrostSpear) { checkingAtk = BattlerAction.BreathOfLife; } else if (checkingAtk == BattlerAction.CometStrike) { checkingAtk = BattlerAction.Renewal; } } else if (attacks[0] == BattlerAction.HealingWind || attacks[0] == BattlerAction.BreathOfLife || attacks[0] == BattlerAction.Renewal) { if (checkingAtk == BattlerAction.HealingWind) { checkingAtk = BattlerAction.IceBullet; } else if (checkingAtk == BattlerAction.BreathOfLife) { checkingAtk = BattlerAction.FrostSpear; } else if (checkingAtk == BattlerAction.Renewal) { checkingAtk = BattlerAction.CometStrike; } } }
bool SubTurnStep_Interrupt_AllyHit(Battler bat, Battler[] bats) { BattlerAction action = BattlerAction.None; bool tryToCutIn = false; for (int i = 0; i < bats.Length; i++) { if (bats[i].isValidTarget && bats[i].incomingHit && bats[i] != bat) { tryToCutIn = true; break; } } if (tryToCutIn) { action = bat.GetInterruptAction(BattlerActionInterruptType.OnAllyHit); if (action != BattlerAction.None) { currentActingBattler = bat; if (bat.isEnemy) { bat.AttackWith(validPlayerTargets, validEnemyTargets, action); } else { bat.AttackWith(validEnemyTargets, validPlayerTargets, action); } } } return(action != BattlerAction.None); }
public GameDataManager_DataStore() { lastScene = SceneIDType.OverworldScene; yourTownName = "Citysburg"; fakeTownNames = new string[] { "Town A", "Town No. 2", "Tertiary Town" }; pendingUpgrade_Docks = false; pendingUpgrade_Mason = false; pendingUpgrade_Sawmill = false; pendingUpgrade_Smith = false; unlock_sovSpe_CalledShots = false; unlock_sovSpe_HammerSmash = false; unlock_sovSpe_Protect = false; adventureLevel = 0; buildingLv_Docks = 0; buildingLv_Mason = 0; buildingLv_Sawmill = 0; buildingLv_Smith = 0; buildingLv_WizardsTower = 1; nextRandomAdventureAnte = 2; resBricks = 0; resBricks_max = 999; // we actually recalc these immediately, lol resBricks_maxUpgrades = 0; resMetal = 0; resMetal_max = 999; resMetal_maxUpgrades = 0; resPlanks = 0; resPlanks_max = 999; resPlanks_maxUpgrades = 0; resMana = 0; resMana_max = manaCap; pendingUpgradeTimer_Docks = 0; pendingUpgradeTimer_Mason = 0; pendingUpgradeTimer_Sawmill = 0; pendingUpgradeTimer_Smith = 0; lastInspectedAdventurerIndex = 0; partyAdventurer0Index = 0; partyAdventurer1Index = 1; partyAdventurer2Index = 2; sovereignFirstName = "Dude"; sovereignLastName = "Huge"; housingLevel = 0; housingUnitUpgrades = new bool[housingLevelCap]; houseAdventurers = new Adventurer[housingLevelCap]; for (int i = 0; i < houseAdventurers.Length; i++) { houseAdventurers[i] = new Adventurer(); } sovereignAdventurer = new Adventurer(); sovereignTactic = BattlerAction.GetBehindMe; sovereignSkill = AdventurerSpecial.None; sovereignMugshot = AdventurerMugshot.Sovereign0; progressionFlags = 0; buyable0 = null; buyable1 = null; unlockedMysticPromotes = MysticPromotes.None; unlockedWarriorPromotes = WarriorPromotes.None; peddlerIsPresent = false; peddlerPrice = 25; }
public static string GetAttackDescription(BattlerAction attack) { string desc = "None"; TextAsset a = Resources.Load <TextAsset>(attackDescsResourcePath + attack.ToString()); if (a != null) { desc = a.text; } return(desc); }
void SubTurnStep_StandardAction_Fetch(Battler bat) { standardPriorityActingBattler = bat; if (bat.isEnemy) { nextAction = bat.GetStandardAction(turn, validEnemyTargets, validPlayerTargets); bat.ReadyAttack(validPlayerTargets, validEnemyTargets, nextAction); } else { nextAction = bat.GetStandardAction(turn, validPlayerTargets, validEnemyTargets); bat.ReadyAttack(validEnemyTargets, validPlayerTargets, nextAction); } }
//Define the actions in battle Ed will use public static IList<BattlerAction> GetEdActions() { IList<BattlerAction> list = new List<BattlerAction>(); BattlerAction action = new BattlerAction( "Standard Attack", 0, 1, ActionTarget.Enemy, BattlerMethods.EdStandardAttack); list.Add(action); return list; }
// Update is called once per frame void Update() { if (cachedSovereignName != GameDataManager.Instance.dataStore.sovereignName) { cachedSovereignName = GameDataManager.Instance.dataStore.sovereignName; sovereignNameLabel.text = strings[0] + GameDataManager.Instance.dataStore.sovereignName; } if (cachedSovereignMugshot != GameDataManager.Instance.dataStore.sovereignMugshot) { cachedSovereignMugshot = GameDataManager.Instance.dataStore.sovereignMugshot; sovereignMugshot.sprite = GameDataManager.Instance.dataStore.sovereignAdventurer.GetMugshotGraphic(); } if (cachedSovereignTactic != GameDataManager.Instance.dataStore.sovereignTactic) { cachedSovereignTactic = GameDataManager.Instance.dataStore.sovereignTactic; sovereignTacticDesc.text = Adventurer.GetAttackDescription(GameDataManager.Instance.dataStore.sovereignTactic); } if (cachedSovereignSpecial != GameDataManager.Instance.dataStore.sovereignSkill) { cachedSovereignSpecial = GameDataManager.Instance.dataStore.sovereignSkill; sovereignSpecialDesc.text = Adventurer.GetSpecialDescription(GameDataManager.Instance.dataStore.sovereignSkill); } if (cachedSovereignTitle != GameDataManager.Instance.dataStore.sovereignAdventurer.fullTitle) { cachedSovereignTitle = GameDataManager.Instance.dataStore.sovereignAdventurer.fullTitle; sovereignTitleArea.text = cachedSovereignTitle; } if (cachedSovereignWpn != GameDataManager.Instance.dataStore.sovWpn_Set) { UpdateTextFieldWithWpnInfo(GameDataManager.Instance.dataStore.sovWpn_Set, ref cachedSovereignWpn, ref strings, ref sovereignWpnArea); } if (rowPlacementButton != null && rowPlacementButton.interactable != (GameDataManager.Instance.dataStore.sovereignEquippedWeaponType == WpnType.Knives)) { rowPlacementButton.interactable = (GameDataManager.Instance.dataStore.sovereignEquippedWeaponType == WpnType.Knives); } if (cachedSovereignRowState != GameDataManager.Instance.dataStore.sovereignOnBackRow) { cachedSovereignRowState = GameDataManager.Instance.dataStore.sovereignOnBackRow; if (cachedSovereignRowState) { rowPlacementArea.text = strings[35]; } else { rowPlacementArea.text = strings[34]; } } }
private BattlerActionData(int index, string line) { actionID = (BattlerAction)index; string[] terms = line.Split(','); name = terms[0]; cooldownTurns = int.Parse(terms[1]); effectPower = int.Parse(terms[2]); interruptType = ParseInterruptType(terms[3]); anim = ParseAnim(terms[4]); target = ParseTarget(terms[5]); baseDamage = int.Parse(terms[6]); numberOfSubtargets = int.Parse(terms[7]); flags = ParseListOfFlags(terms); if ((flags & BattlerActionEffectFlags.Healing) == BattlerActionEffectFlags.Healing) { baseDamage = baseDamage * -1; } }
private void ExecuteAction(BattlerAction action) { ActionPreOutcome outcome = ResolveAction(action); actors[action.actorIndex].actionPoints -= outcome.cost; if (random.Next(1, 7) <= outcome.toHitChance) // skill hit { // Debug.Log(" - " + actors[action.actorIndex].character.name + " hit " + actors[action.targetIndex].character.name + " for " + outcome.damage + " hitpoints."); actors[action.targetIndex].character.Hitpoints -= outcome.damage; if (actors[action.targetIndex].character.Hitpoints < 0) { actors[action.targetIndex].character.Hitpoints = 0; } } else { // Debug.Log(" - " + actors[action.actorIndex].character.name + "'s attack on " + actors[action.targetIndex].character.name + " missed."); } }
BattlerAction GetSpecial0(int lv) { BattlerAction a = BattlerAction.None; switch (wpnType) { case WpnType.Mace: if (lv > 1) { a = BattlerAction.BloodOfSteel; } else if (lv > 0) { a = BattlerAction.Fortify; } break; case WpnType.Knives: if (lv > 1) { a = BattlerAction.BladeOfCrimson; } else if (lv > 0) { a = BattlerAction.BloodRites; } break; case WpnType.Staff: if (lv > 1) { a = BattlerAction.SpeakNoEvil; } else if (lv > 0) { a = BattlerAction.ZoneOfSilence; } break; } return(a); }
BattlerAction GetSpecial1(int lv) { BattlerAction a = BattlerAction.None; switch (wpnType) { case WpnType.Mace: if (lv > 1) { a = BattlerAction.CataclysmicImpact; } else if (lv > 0) { a = BattlerAction.WideSwing; } break; case WpnType.Knives: if (lv > 1) { a = BattlerAction.FlashStep; } else if (lv > 0) { a = BattlerAction.FleetFeet; } break; case WpnType.Staff: if (lv > 1) { a = BattlerAction.CovetNot; } else if (lv > 0) { a = BattlerAction.AntiDrain; } break; } return(a); }
public bool Update() { if (CheckWinner() != TEAMS.NONE) { // Debug.Log("WINNER: " + (CheckWinner() == TEAMS.TEAM1 ? "Team 1" : "Team2") + "!"); return(true); } Battler nextActor = NextActor(); if (nextActor == null) { Tick(); } else { BattlerAction action = nextActor.Act(); ExecuteAction(action); } return(false); }
bool SubTurnStep_Interrupt_SelfHit(Battler bat) { BattlerAction action = BattlerAction.None; if (bat.incomingHit) { action = bat.GetInterruptAction(BattlerActionInterruptType.OnHit); if (action != BattlerAction.None) { currentActingBattler = bat; if (bat.isEnemy) { bat.AttackWith(validPlayerTargets, validEnemyTargets, action); } else { bat.AttackWith(validEnemyTargets, validPlayerTargets, action); } } } return(action != BattlerAction.None); }
private void EndTurn() { if (outOfBattleBattler != null && outOfBattleBattler._wantsToReenterBattle) { outOfBattleBattler.ReenterBattle(); _forceAllBattlersRegen = true; } turn++; encoreWaitingForEnemies = false; encoreWaitingForPlayer = false; nextAction = BattlerAction.None; currentActingBattler = default(Battler); currentTurnTarget = default(Battler); if (currentBattleResolved) { EndBattle(); } else { Timing.RunCoroutine(RunTurn(), _owned); } }
private void ExecuteAction(BattlerAction p_attack) { currentAction = p_attack; //currentActionFrames = p_attack.frameData; action = p_attack.fullFrames; currentFrame = 0; if (thisAnimation) { if (currentAction.animationName != null) { thisAnimation.Play(currentAction.animationName, -1, 0); } else { thisAnimation.Play("attackBasic", -1, 0); } //thisAnimation.speed = actionSpeed; } currentState = Action.ACTING; execution = 0; }
public BattlerAction Act() { // Debug.Log(character.character.name + " choosing action."); Skill skill = character.skills[0].skill; List <Battler> possibleTargets = new List <Battler>(); int targetIndex; if (skill.targetType == Skill.TargetType.ALLIES) { foreach (Battler b in battle.actors) { if (b.team == this.team) { possibleTargets.Add(b); } } } else // ENEMIES { foreach (Battler b in battle.actors) { if (b.team != this.team) { possibleTargets.Add(b); } } } float bestEfficiency = 0; BattlerAction bestAction = null; foreach (Battler b in possibleTargets) { targetIndex = b.index; BattlerAction action = new BattlerAction(skill, index, targetIndex); if (bestAction == null && false) { bestAction = action; //TODO: find better place for code } Battle.ActionPreOutcome outcome = battle.ResolveAction(action); //Debug.Log("Expected damage: " + outcome.damage); float efficiency = (float)outcome.damage / (float)battle.actors[targetIndex].character.Hitpoints; if (efficiency >= 1) { efficiency = 1; efficiency *= 2; // addition to efficiency for killing blows. TODO: should take into account some threat level of the target } //Debug.Log("Efficiency: " + efficiency); efficiency *= outcome.toHitChance >= 6 ? 1 : (float)outcome.toHitChance / 6; //Debug.Log("Efficiency: " + efficiency); if (skill.targetType == Skill.TargetType.ALLIES) { //TODO: code healing and status effects } //Debug.Log("Cost/ActionPoints: " + outcome.cost + "/" + actionPoints); if (outcome.cost > actionPoints) { //Debug.Log("Not enough action points."); efficiency = 0; // TODO: refactor with code above } //Debug.Log("Efficiency: " + efficiency + " / Best efficiency: " + bestEfficiency); // Found better move? if (efficiency > bestEfficiency) { bestEfficiency = efficiency; bestAction = action; //Debug.Log("Current best action: " + bestAction); } } return(bestAction); }
BattlerAction GetSpecial2(int lv) { BattlerAction a = BattlerAction.None; switch (wpnType) { case WpnType.Mace: if (lv > 1) { a = BattlerAction.DreamlessSleep; } else if (lv > 0) { a = BattlerAction.Concuss; } break; case WpnType.Knives: if (lv > 1) { a = BattlerAction.WithTheWind; } else if (lv > 0) { a = BattlerAction.SecondSight; } break; case WpnType.Staff: if (wpnLevel == 0) { if (UnityEngine.Random.Range(0, 2) == 0) { a = GetSpecial1(lv); } else { a = GetSpecial0(lv); } } else if (attacks[0] == BattlerAction.IceBullet || attacks[0] == BattlerAction.FrostSpear || attacks[0] == BattlerAction.CometStrike) { if (lv > 1) { a = BattlerAction.BreathOfLife; } else if (lv > 0) { a = BattlerAction.HealingWind; } } else { if (lv > 1) { a = BattlerAction.FrostSpear; } else if (lv > 0) { a = BattlerAction.IceBullet; } } break; } return(a); }
public static string GetAttackName(BattlerAction attack) { return(BattlerActionData.get(attack).name); }
public ActionPreOutcome ResolveAction(BattlerAction action) { ActionPreOutcome outcome; CharacterSO actor = actors[action.actorIndex].character; CharacterSO target = actors[action.targetIndex].character; List <Battler> tempActors = new List <Battler>(); foreach (Battler b in tempActors) { tempActors.Add(new Battler(b.character, b.team, b.index, this, b.position)); } // Damage & Cost int cost = 2; cost += action.skill.extraCost; // cost += distance, if melee cost += Mathf.Min(Distance(action.actorIndex, action.targetIndex) - actor.weapon.weapon.range, 0); // TODO: consider path blocking int damage = 0; damage += action.skill.extraDamage; switch (action.skill.baseDamage) { case Skill.BaseDamage.STRENGTH: damage += actor.character.attributes.strength; damage += actor.weapon.weapon.value; damage -= target.Armor; // .armor.armor.value; cost += actor.weapon.weapon.weight; break; case Skill.BaseDamage.FREE_ENCUMBRANCE: damage += actor.character.attributes.strength - actor.Encumbrance; damage += actor.weapon.weapon.value; damage -= target.Armor; // .armor.armor.value; cost += actor.weapon.weapon.weight; break; case Skill.BaseDamage.INTELLIGENCE: damage += actor.character.attributes.inteligence; damage -= target.character.attributes.inteligence; cost += 3 - Mathf.FloorToInt(actor.FreeEncumbrance / 2); break; } // To Hit Chance int toHitChance = 6; int targetEvasion = target.character.attributes.dexterity + Mathf.FloorToInt(target.FreeEncumbrance / 2); //targetEvasion += target.shield.shield.value * (actors[action.targetIndex].defending ? 2 : 1); //FIXME: characterSO must handle null values for equipment switch (action.skill.type) { case Skill.Type.MELEE: toHitChance += actor.character.attributes.dexterity + Mathf.FloorToInt(actor.FreeEncumbrance / 2); toHitChance -= targetEvasion; break; case Skill.Type.PROJECTILE: toHitChance += actor.character.attributes.dexterity + Mathf.FloorToInt(actor.FreeEncumbrance / 2); toHitChance -= targetEvasion; break; case Skill.Type.DIRECT: break; } if (toHitChance < 1) { toHitChance = 1; } outcome.cost = cost; outcome.toHitChance = toHitChance; outcome.damage = damage; return(outcome); }
/// <summary> /// Calls into BattlerActionData, gets a BattlerActionData entry from the dataset if it exists, makes it first if it doesn't. /// </summary> public static BattlerActionData get(BattlerAction a) { return(_get[(int)a]); }
public void Step(BattleMessageType message = BattleMessageType.StandardTurnMessage, Battler actor = default(Battler), BattlerAction action = BattlerAction.None) { _clear = false; messageQueue.Enqueue(message); actorQueue.Enqueue(actor); actionQueue.Enqueue(action); }
private void NextMessage() { timer = 0; BattleMessageType message = messageQueue.Dequeue(); Battler actor = actorQueue.Dequeue(); BattlerAction action = actionQueue.Dequeue(); bool drawToLine1 = true; if (line0 == "") { drawToLine1 = false; } else if (line1 != "") { line0 = line1; } string baseLine; string nextLine = ""; switch (message) { case BattleMessageType.StandardTurnMessage: if (actor == null) { throw new System.Exception("Can't do standard turn message with null battler!"); } if (overseer.standardActionPriorityBracket) { baseLine = mainStrings[0]; } else { baseLine = mainStrings[1]; } if (overseer.currentActingBattler.isEnemy) { nextLine = actor.adventurer.title + baseLine + actionNameStrings[(int)action]; } else { nextLine = actor.adventurer.fullName + baseLine + actionNameStrings[(int)action]; } break; case BattleMessageType.Silence: nextLine = mainStrings[3]; break; case BattleMessageType.ShieldWall: nextLine = mainStrings[4]; break; case BattleMessageType.ShieldBlock: nextLine = mainStrings[5]; break; case BattleMessageType.Heal: nextLine = mainStrings[6]; break; case BattleMessageType.Haste: nextLine = mainStrings[7]; break; case BattleMessageType.Barrier: nextLine = mainStrings[8]; break; case BattleMessageType.MultiHeal: nextLine = mainStrings[9]; break; case BattleMessageType.Encore: nextLine = mainStrings[10]; break; case BattleMessageType.Feedback: nextLine = mainStrings[11]; break; case BattleMessageType.Revenge: nextLine = mainStrings[12]; break; case BattleMessageType.Critical: nextLine = mainStrings[13]; break; case BattleMessageType.SavedAlly: nextLine = mainStrings[14]; break; case BattleMessageType.Flanking: nextLine = mainStrings[15]; break; case BattleMessageType.SomebodyDead: Battler bat = corpseQueue.Dequeue(); if (bat.isEnemy) { nextLine = bat.adventurer.title + mainStrings[2]; } else { nextLine = bat.adventurer.fullName + mainStrings[2]; } break; case BattleMessageType.Win: nextLine = mainStrings[16]; break; case BattleMessageType.Loss: nextLine = mainStrings[17]; break; case BattleMessageType.Retreat: nextLine = mainStrings[18]; break; case BattleMessageType.FailedCast: if (overseer.currentActingBattler.isEnemy) { nextLine = actor.adventurer.title + mainStrings[19]; } else { nextLine = actor.adventurer.fullName + mainStrings[19]; } break; case BattleMessageType.PulledOutOfBattle: nextLine = actor.adventurer.fullName + mainStrings[20]; break; case BattleMessageType.ReenteredBattle: nextLine = actor.adventurer.fullName + mainStrings[21]; break; case BattleMessageType.StunBuff: nextLine = mainStrings[22]; break; case BattleMessageType.StunBuffFaded: nextLine = mainStrings[23]; break; case BattleMessageType.Stun: nextLine = mainStrings[24]; break; case BattleMessageType.PumpedUp: nextLine = mainStrings[25]; break; case BattleMessageType.MovesBetweenLines: nextLine = mainStrings[26]; break; case BattleMessageType.SwiftlyMovesBetweenLines: nextLine = mainStrings[27]; break; case BattleMessageType.AttunedBuff: nextLine = mainStrings[28]; break; case BattleMessageType.AttunedBuffFaded: nextLine = mainStrings[29]; break; case BattleMessageType.Dodged: nextLine = mainStrings[30]; break; case BattleMessageType.DrainKill: nextLine = mainStrings[31]; break; case BattleMessageType.FailedToDrain: nextLine = mainStrings[32]; break; case BattleMessageType.MagBoost: nextLine = mainStrings[33]; break; case BattleMessageType.StatBoostsLost: nextLine = mainStrings[34]; break; case BattleMessageType.SacrificeLost: nextLine = mainStrings[35]; break; case BattleMessageType.Sacrifice: nextLine = mainStrings[36]; break; case BattleMessageType.StunnedNoMove: if (overseer.currentActingBattler.isEnemy) { nextLine = actor.adventurer.title + mainStrings[37]; } else { nextLine = actor.adventurer.fullName + mainStrings[37]; } break; } if (drawToLine1) { line1 = nextLine; } else { line0 = nextLine; } uiText.text = line0 + System.Environment.NewLine + line1; }
public void SetSovereignTactic(BattlerAction attack) { dataStore.sovereignTactic = attack; dataStore.sovereignAdventurer.attacks[1] = attack; }