// Updates the ai, broad spectrum public virtual void updateAI(Unit unit, BattleMap map) { if(updatingAI) return; if(unit.hasStatEffect("Enrage")) updateAIEnrage(unit, map); else updateAINormal(unit, map); /* // Variables int[] target; int[] spotToMoveTo; AttackInfo info; int heuristic; bool isUncontrollable= unit.hasStatEffect("Enrage"); updatingAI= true; ai_getTarget(unit, map, isUncontrollable, out target, out spotToMoveTo, out info); map.destroyPaths(); if(target== null || target[0]== -1) { map.endUnitTurn(map.getFullUnitID(unit.mapPos)); return; } heuristic= map.getHeuristic(unit.mapPos, map.getUnitXY(target)); if(!unit.isAttackingDone && heuristic>= info.range[0] && heuristic<= info.range[1]) { ai_attackUnit(unit, map, info, isUncontrollable); map.destroyPaths(); map.endUnitAttacking(map.getFullUnitID(unit.mapPos)); if(unit.isTurnEnded) { return; } } if(!unit.isWalkingDone) { if(!movesByProximity() || map.isEnemyWithinProximity(unit.mapPos[0], unit.mapPos[1], unit.move, map.getTeamID(unit.mapPos), target)) ai_moveUnit(unit, map, spotToMoveTo, isUncontrollable); map.destroyPaths(); map.endUnitWalking(map.getFullUnitID(unit.mapPos)); if(unit.isTurnEnded) { return; } } heuristic= map.getHeuristic(unit.mapPos, map.getUnitXY(target)); if(!unit.isAttackingDone && heuristic>= info.range[0] && heuristic<= info.range[1]) { ai_attackUnit(unit, map, info, isUncontrollable); map.destroyPaths(); map.endUnitAttacking(map.getFullUnitID(unit.mapPos)); if(unit.isTurnEnded) { return; } } map.destroyPaths(); map.endUnitTurn(map.getFullUnitID(unit.mapPos));*/ }
// Called when the unit's attack has missed public override void onMissedAttack(Profession prof, ref Unit unit, int amount, ref Unit victim, ref BattleMap map) { if(!unit.hasStatEffect("Enraged")) return; if(Start.rng.Next(0, 10)< 3) victim.addStatEffect(StatEffect.create(StatusEffect.Enraged, 3), ref map); }
// --- Inherited Methods --- // Called when the unit has taken damage public override int onTakeDamage(Profession prof, ref Unit unit, int oldHealth, int newHealth, int amount, ref Unit instigator, ref BattleMap map) { if(!unit.hasStatEffect("Enraged")) return amount; if(Start.rng.Next(0, 10)< 3) instigator.addStatEffect(StatEffect.create(StatusEffect.Enraged, 3), ref map); return amount; }
// Called when the unit is about to deal damage public override int onDealtDamage(Profession prof, ref Unit unit, int victimHP, int amount, ref Unit victim, ref BattleMap map) { if(!unit.hasStatEffect("Enraged")) return amount; if(Start.rng.Next(0, 10)< 3) victim.addStatEffect(StatEffect.create(StatusEffect.Enraged, 3), ref map); return amount; }