Example #1
0
 public override void AddStatus(Constants.StatusTypes type, int statusPower, int duration = 2)
 {
     if (Effects == null)
     {
         Effects = new List <Effect>();
     }
     RemoveStatus();
     Effects.Add(new Effect(Constants.EffectType.Status, Constants.BuffTypes.None, type, statusPower, duration));
     if (type == Constants.StatusTypes.Berserk || type == Constants.StatusTypes.Confuse)
     {
         if (type == Constants.StatusTypes.Berserk)
         {
             Stats.AttackDefense /= Constants.BERSERK_MODIFIER;
             Stats.AttackPower   /= Constants.BERSERK_MODIFIER;
             Stats.MagicDefense  /= Constants.BERSERK_MODIFIER;
             unitManager.log.Add(NameStr + " Berserks");
         }
         else
         {
             Stats.Accuracy /= Constants.CONFUSE_MODIFIER;
             Stats.Evasion  /= Constants.CONFUSE_MODIFIER;
             unitManager.log.Add(NameStr + " is Confused");
         }
     }
     ColorChange();
 }
Example #2
0
 public void RemoveStatus()
 {
     if (Effects == null)
     {
         Effects = new List <Effect>();
     }
     Constants.StatusTypes type = GetStatus();
     if (type == Constants.StatusTypes.Berserk || type == Constants.StatusTypes.Confuse)
     {
         if (type == Constants.StatusTypes.Berserk)
         {
             Stats.AttackDefense *= Constants.BERSERK_MODIFIER;
             Stats.AttackPower   *= Constants.BERSERK_MODIFIER;
             Stats.MagicDefense  *= Constants.BERSERK_MODIFIER;
             unitManager.log.Add("Berserk wears off " + NameStr);
         }
         else
         {
             Stats.Accuracy *= Constants.CONFUSE_MODIFIER;
             Stats.Evasion  *= Constants.CONFUSE_MODIFIER;
             unitManager.log.Add("Confuse wears off " + NameStr);
         }
     }
     Effects.RemoveAll(x => x.Type == Constants.EffectType.Status);
     if (Stats == null)
     {
         return;
     }
     Stats.Status = Constants.StatusTypes.None;
 }
Example #3
0
 public Effect(Constants.EffectType type, Constants.BuffTypes buffType = Constants.BuffTypes.None,
               Constants.StatusTypes statusType = Constants.StatusTypes.None, float power = 0, int duration = 2)
 {
     Type       = type;
     BuffType   = buffType;
     StatusType = statusType;
     Power      = power;
     Duration   = duration;
 }
Example #4
0
 public DamagePacket(bool hit, int power = 0, int statusPower = 0, bool isWeak = false, bool isTechnical = false, bool removeStatus = false, Constants.StatusTypes status = Constants.StatusTypes.None, Constants.StatusTypes returnStatus = Constants.StatusTypes.None, bool isCrit = false, int statusDuration = 2) : this()
 {
     this.hit            = hit;
     damage              = power;
     this.statusPower    = statusPower;
     this.isWeak         = isWeak;
     this.isTechnical    = isTechnical;
     this.removeStatus   = removeStatus;
     this.status         = status;
     this.returnStatus   = returnStatus;
     this.isCrit         = isCrit;
     this.statusDuration = statusDuration;
 }
Example #5
0
        private void DoStatus(int pos, Unit unit)
        {
            Constants.StatusTypes status = unit.GetStatus();
            switch (status)
            {
            default:
                if (!unit.IsPlayer)
                {
                    MonsterCast((int)Turn - 1);
                }
                break;

            case Constants.StatusTypes.Blast:
                if (!unit.IsPlayer)
                {
                    StartCoroutine(DisplayText(pos, "Detonating"));
                    MonsterCast((int)Turn - 1);
                }
                break;

            case Constants.StatusTypes.Shock:
                StartCoroutine(DisplayText(pos, "Shocked"));
                if (unit.IsPlayer)
                {
                    log.Add("You are shocked");
                }
                else
                {
                    log.Add(unit.NameStr + " is shocked");
                }
                AdvanceTurn();
                break;

            case Constants.StatusTypes.Freeze:
                StartCoroutine(DisplayText(pos, "Frozen"));
                if (unit.IsPlayer)
                {
                    log.Add("You are frozen");
                }
                else
                {
                    log.Add(unit.NameStr + " is frozen");
                }
                AdvanceTurn();
                break;

            case Constants.StatusTypes.Burn:
                StartCoroutine(DisplayText(pos, "Burning\nTaking damage"));
                unit.ApplyBurn();
                if (unit.IsPlayer)
                {
                    log.Add("You are burning");
                    UpdateGlobes();
                }
                else
                {
                    log.Add(unit.NameStr + " is burning");
                    monsterDisplay[pos].UpdateFill(monsters[pos]);
                    MonsterCast((int)Turn - 1);
                }
                break;

            case Constants.StatusTypes.Curse:
                StartCoroutine(DisplayText(pos, "Cursed\nLosing health"));
                unit.ApplyCurse(-1);
                if (unit.IsPlayer)
                {
                    log.Add("You are cursed");
                    UpdateGlobes();
                }
                else
                {
                    log.Add(unit.NameStr + " is cursed");
                    monsterDisplay[pos].UpdateFill(monsters[pos]);
                    MonsterCast((int)Turn - 1);
                }
                break;

            case Constants.StatusTypes.Sleep:
                StartCoroutine(DisplayText(pos, "Sleeping\nGaining health"));
                unit.ApplyCurse(1);
                if (unit.IsPlayer)
                {
                    log.Add("You are sleeping");
                    UpdateGlobes();
                }
                else
                {
                    log.Add(unit.NameStr + " is sleeping");
                    monsterDisplay[pos].UpdateFill(monsters[pos]);
                }
                AdvanceTurn();
                break;

            case Constants.StatusTypes.Brainwash:
                StartCoroutine(DisplayText(pos, "Brainwashed"));
                if (unit.IsPlayer)
                {
                    log.Add("You are brainwashed");
                }
                else
                {
                    log.Add(unit.NameStr + " is brainwashed");
                }
                AdvanceTurn();
                break;

            case Constants.StatusTypes.Fear:
                StartCoroutine(DisplayText(pos, "Terrified\nLosing willpower"));
                if (unit.IsPlayer)
                {
                    log.Add("You are terrified");
                    unit.ApplyCost(100, Constants.CostTypes.Spell);
                    UpdateGlobes();
                }
                else
                {
                    log.Add(unit.NameStr + " is terrfied");
                }
                AdvanceTurn();
                break;
            }
        }
Example #6
0
        public void ApplyDuration()
        {
            if (Effects == null)
            {
                return;
            }
            foreach (Effect effect in Effects)
            {
                effect.Duration--;
            }
            Constants.StatusTypes type = GetStatus();
            if (type == Constants.StatusTypes.Berserk || type == Constants.StatusTypes.Confuse)
            {
                if (type == Constants.StatusTypes.Berserk)
                {
                    Stats.AttackDefense *= Constants.BERSERK_MODIFIER;
                    Stats.AttackPower   *= Constants.BERSERK_MODIFIER;
                    Stats.MagicDefense  *= Constants.BERSERK_MODIFIER;
                    unitManager.log.Add("Berserk wears off " + NameStr);
                }
                else
                {
                    Stats.Accuracy *= Constants.CONFUSE_MODIFIER;
                    Stats.Evasion  *= Constants.CONFUSE_MODIFIER;
                    unitManager.log.Add("Confuse wears off " + NameStr);
                }
            }
            List <Effect> buffs = GetBuffs();

            if (buffs != null)
            {
                if (buffs.Count != 0)
                {
                    foreach (Effect buff in buffs)
                    {
                        if (buff.Duration <= 0)
                        {
                            switch (buff.BuffType)
                            {
                            case Constants.BuffTypes.Damage:
                                Stats.AttackPower /= (Constants.BUFF_MULTIPLIER * buff.Power);
                                Stats.MagicPower  /= (Constants.BUFF_MULTIPLIER * buff.Power);
                                unitManager.log.Add("Damage buff wears off " + NameStr);
                                break;

                            case Constants.BuffTypes.Defense:
                                Stats.AttackDefense /= (Constants.BUFF_MULTIPLIER * buff.Power);
                                Stats.MagicDefense  /= (Constants.BUFF_MULTIPLIER * buff.Power);
                                unitManager.log.Add("Defense buff wears off " + NameStr);
                                break;

                            case Constants.BuffTypes.Evasion:
                                Stats.Accuracy /= (Constants.BUFF_MULTIPLIER * buff.Power);
                                Stats.Evasion  /= (Constants.BUFF_MULTIPLIER * buff.Power);
                                unitManager.log.Add("Evasion buff wears off " + NameStr);
                                break;

                            case Constants.BuffTypes.Speed:
                                Stats.Speed = (int)(Stats.Speed / (Constants.BUFF_MULTIPLIER * buff.Power));
                                unitManager.log.Add("Speed buff wears off " + NameStr);
                                break;

                            case Constants.BuffTypes.Guard:
                                Stats.AttackDefense /= Constants.GUARD_MODIFIER;
                                Stats.MagicDefense  /= Constants.GUARD_MODIFIER;
                                unitManager.log.Add("Guard buff wears off " + NameStr);
                                break;
                            }
                        }
                    }
                }
            }
            Effects.RemoveAll(x => x.Duration <= 0);
            Constants.StatusTypes status = GetStatus();
            Stats.Status = status;
            UpdateColor();
        }
Example #7
0
        internal static DamagePacket Hit(SkillStats skill, UnitStats attacker, UnitStats defender)
        {
            bool playerAttacker = false;
            bool playerDefender = false;

            if (attacker.Id == 0)
            {
                playerAttacker = true;
            }
            else if (defender.Id == 0)
            {
                playerDefender = true;
            }
            //Check evasion
            float accuracy = skill.Accuracy * ((float)attacker.Accuracy / 100);

            //Always hit if evasion <= 0
            if (defender.Evasion > 0)
            {
                accuracy /= (float)defender.Evasion / 100;
                int evasionRoll = RandomInt(1, 100);
                if (ExperimentControl.active)
                {
                    if (playerDefender)
                    {
                        int evasionRoll2 = RandomInt(1, 100);
                        if (evasionRoll2 > evasionRoll)
                        {
                            evasionRoll = evasionRoll2;
                        }
                    }
                }
                if (accuracy < evasionRoll)
                {
                    return(new DamagePacket(false));
                }
            }
            //Hit
            //Set Type
            float power          = 0;
            float defense        = 0;
            float resist         = 0;
            int   statusDuration = 2;

            switch (skill.DamageType)
            {
            case Constants.DamageTypes.Physical:
                power   = attacker.AttackPower;
                defense = defender.AttackDefense;
                resist  = defender.ResistPhysical;
                break;

            case Constants.DamageTypes.Projectile:
                power   = attacker.AttackPower;
                defense = defender.AttackDefense;
                resist  = defender.ResistProjectile;
                break;

            case Constants.DamageTypes.Almighty:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                break;

            case Constants.DamageTypes.Electric:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                resist  = defender.ResistElectric;
                break;

            case Constants.DamageTypes.Cold:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                resist  = defender.ResistCold;
                break;

            case Constants.DamageTypes.Fire:
                power          = attacker.MagicPower;
                defense        = defender.MagicDefense;
                resist         = defender.ResistFire;
                statusDuration = 4;
                break;

            case Constants.DamageTypes.Wind:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                resist  = defender.ResistWind;
                break;

            case Constants.DamageTypes.Arcane:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                resist  = defender.ResistArcane;
                break;

            case Constants.DamageTypes.Psychic:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                resist  = defender.ResistPsychic;
                break;

            case Constants.DamageTypes.Light:
                power   = attacker.MagicPower;
                defense = defender.MagicDefense;
                resist  = defender.ResistLight;
                break;

            case Constants.DamageTypes.Dark:
                power          = attacker.MagicPower;
                defense        = defender.MagicDefense;
                resist         = defender.ResistDark;
                statusDuration = 4;
                break;
            }
            //Check Weakness
            bool isWeak = false;

            if (resist <= -50)
            {
                isWeak = true;
            }
            //Check Technical
            bool isTechnical  = false;
            bool removeStatus = false;

            Constants.StatusTypes returnStatus = Constants.StatusTypes.None;
            switch (defender.Status)
            {
            case Constants.StatusTypes.None:
                break;

            case Constants.StatusTypes.Shock:
                if (skill.DamageType == Constants.DamageTypes.Physical)
                {
                    power        = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical  = true;
                    removeStatus = true;
                    returnStatus = Constants.StatusTypes.Shock;
                }
                else if (skill.DamageType == Constants.DamageTypes.Arcane)
                {
                    power        = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical  = true;
                    removeStatus = true;
                }
                break;

            case Constants.StatusTypes.Freeze:
                if (skill.DamageType == Constants.DamageTypes.Physical || skill.DamageType == Constants.DamageTypes.Projectile)
                {
                    power        = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical  = true;
                    removeStatus = true;
                }
                else if (skill.DamageType == Constants.DamageTypes.Arcane)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;

            case Constants.StatusTypes.Burn:
                if (skill.DamageType == Constants.DamageTypes.Arcane)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;

            case Constants.StatusTypes.Sleep:
                power       = (int)(power * Constants.TECHNICAL_MULTI);
                isTechnical = true;
                break;

            case Constants.StatusTypes.Forget:
                if (skill.DamageType == Constants.DamageTypes.Psychic)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;

            case Constants.StatusTypes.Berserk:
                if (skill.DamageType == Constants.DamageTypes.Psychic)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;

            case Constants.StatusTypes.Confuse:
                if (skill.DamageType == Constants.DamageTypes.Psychic)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;

            case Constants.StatusTypes.Brainwash:
                if (skill.DamageType == Constants.DamageTypes.Psychic)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;

            case Constants.StatusTypes.Fear:
                if (skill.DamageType == Constants.DamageTypes.Psychic)
                {
                    power       = (int)(power * Constants.TECHNICAL_MULTI);
                    isTechnical = true;
                }
                break;
            }
            //Check Crit
            bool isCrit = false;

            if (TryChance(skill.CritChance, attacker.CritChance, defender.IncCritChance, playerAttacker))
            {
                isCrit = true;
                float critMulti = attacker.CritMulti * ((float)skill.CritMulti / 100);
                power *= critMulti / 100;
            }
            //Check Status
            float statusChance = skill.StatusChance;

            statusChance *= (100 - resist) / 100;
            Constants.StatusTypes status = Constants.StatusTypes.None;
            if (!isTechnical)
            {
                if (statusChance > 0)
                {
                    if (isCrit)
                    {
                        statusChance *= Constants.CRITICAL_STATUS_MULTI;
                    }
                    bool statusAttempt;
                    if (skill.StatusType >= Constants.StatusTypes.Sleep)
                    {
                        statusAttempt = TryChance(statusChance, attacker.MentalStatusChance, defender.IncMentalStatus, playerAttacker);
                    }
                    else
                    {
                        statusAttempt = TryChance(statusChance, attacker.TypeStatusChance, defender.IncTypeStatus, playerAttacker);
                    }
                    if (statusAttempt)
                    {
                        status = skill.StatusType;
                    }
                }
            }
            //Calculate final power
            power *= (100 - resist) / 100;
            float statusPower = 0;

            if (status != Constants.StatusTypes.None)
            {
                statusPower  = power;
                statusPower *= (float)attacker.StatusPower / 100;
                statusPower *= (float)skill.StatusPower / 100;
            }
            if (defense > 0)
            {
                power /= defense / 100;
            }
            power *= (float)skill.Power / 100;
            DamagePacket packet = new DamagePacket(true, (int)power, (int)statusPower, isWeak, isTechnical, removeStatus, status, returnStatus, isCrit, statusDuration);

            return(packet);
        }