Ejemplo n.º 1
0
 public void GambleDefence()
 {
     if (_context.DefensePower != 0 && HasSupportAbility(SupportAbility1.GambleDefence))
     {
         _context.DefensePower = (Int16)(Comn.random16() % (_context.DefensePower << 1));
     }
 }
Ejemplo n.º 2
0
 public void TryAlterMagicStatuses()
 {
     if (_command.HitRate > Comn.random16() % 100)
     {
         _target.TryAlterStatuses(_command.AbilityStatus, false);
     }
 }
Ejemplo n.º 3
0
        public Boolean TryPhysicalHit()
        {
            Caster.PenaltyPhysicalHitRate();
            Caster.BonusPhysicalEvade();
            Target.PenaltyDistractHitRate();
            Target.PenaltyPhysicalEvade();
            Target.PenaltyDefenceHitRate();
            Target.PenaltyBanishHitRate();

            if (Context.HitRate <= Comn.random16() % 100)
            {
                Context.Flags |= BattleCalcFlags.Miss;
                return(false);
            }

            if (Target.Data == Caster.Data || Context.Evade <= Comn.random16() % 100)
            {
                return(true);
            }

            Context.Flags |= BattleCalcFlags.Miss;
            if (!Target.IsCovered)
            {
                Context.Flags |= BattleCalcFlags.Dodge;
            }

            return(false);
        }
Ejemplo n.º 4
0
        public void WeaponPhisicalParams(CalcAttackBonus bonus)
        {
            Int32 baseDamage = Comn.random16() % (1 + (Caster.Level + Caster.Strength >> 3));

            Context.AttackPower = Caster.WeaponPower;
            Target.SetPhisicalDefense();
            switch (bonus)
            {
            case CalcAttackBonus.Simple:
                Context.Attack = (Int16)(Caster.Strength + baseDamage);
                break;

            case CalcAttackBonus.WillPower:
                Context.Attack = (Int16)((Caster.Strength + Caster.Will >> 1) + baseDamage);
                break;

            case CalcAttackBonus.Dexterity:
                Context.Attack = (Int16)((Caster.Strength + Caster.Data.elem.dex >> 1) + baseDamage);
                break;

            case CalcAttackBonus.Magic:
                Context.Attack = (Int16)((Caster.Strength + Caster.Data.elem.mgc >> 1) + baseDamage);
                break;

            case CalcAttackBonus.Random:
                Context.Attack = (Int16)(Comn.random16() % Caster.Strength + baseDamage);
                break;

            case CalcAttackBonus.Level:
                Context.AttackPower += Caster.Data.level;
                Context.Attack       = (Int16)(Caster.Strength + baseDamage);
                break;
            }
        }
Ejemplo n.º 5
0
        public void TryCriticalHit()
        {
            Int32 quarterWill = Caster.Data.elem.wpr >> 2;

            if (quarterWill != 0 && Comn.random16() % quarterWill > Comn.random16() % 100)
            {
                Context.Attack *= 2;
                Target.Flags   |= CalcFlag.Critical;
            }
        }
Ejemplo n.º 6
0
        public void TryEscape()
        {
            CMD_DATA curCmdPtr = btl_util.getCurCmdPtr();

            if (curCmdPtr != null && curCmdPtr.regist.bi.player == 0)
            {
                return;
            }

            SByte playerCount  = 0;
            SByte enemyCount   = 0;
            Int16 playerLevels = 0;
            Int16 enemyLevels  = 0;

            for (BTL_DATA next = FF9StateSystem.Battle.FF9Battle.btl_list.next; next != null; next = next.next)
            {
                BattleUnit unit = new BattleUnit(next);
                if (unit.IsPlayer)
                {
                    ++playerCount;
                    playerLevels += next.level;
                }
                else
                {
                    ++enemyCount;
                    enemyLevels += next.level;
                }
            }

            if (enemyCount == 0)
            {
                enemyCount = 1;
            }
            if (playerCount == 0)
            {
                playerCount = 1;
            }
            if (enemyLevels == 0)
            {
                enemyLevels = 1;
            }
            if (playerLevels == 0)
            {
                playerLevels = 1;
            }

            const UInt32 fleeIterationScript = 0056;

            Int16 rate = (Int16)(200 / (enemyLevels / enemyCount) * (playerLevels / playerCount) / 16);

            if (rate > Comn.random16() % 100)
            {
                btl_cmd.SetCommand(FF9StateSystem.Battle.FF9Battle.cmd_escape, fleeIterationScript, 1U, 15, 1U);
            }
        }
Ejemplo n.º 7
0
        public Boolean TryMagicHit()
        {
            if (_context.HitRate <= Comn.random16() % 100)
            {
                _context.Flags |= BattleCalcFlags.Miss;
                return(false);
            }

            if (_context.Evade > Comn.random16() % 100)
            {
                _context.Flags |= BattleCalcFlags.Miss;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        private static void CheckDamageReaction(BattleCalculator v, Boolean counterAtk)
        {
            if (v.Target.Data.bi.player == 0 || v.Caster.Data.bi.player != 0)
            {
                return;
            }
            if (!counterAtk)
            {
                btl_abil.CheckAutoItemAbility(v.Target, v.Command);
            }
            btl_abil.CheckReactionAbility(v.Target.Data, v.Command.Data.aa);
            if (v.Target.Data.bi.t_gauge == 0 || v.Target.Data.cur.hp <= 0 || Status.checkCurStat(v.Target.Data, BattleStatus.CannotTrance))
            {
                return;
            }


            Byte num1 = v.Target.HasSupportAbility(SupportAbility2.HighTide)
                ? v.Target.Data.elem.wpr
                : (Byte)((UInt32)Comn.random16() % v.Target.Data.elem.wpr);

            if (v.Target.Data.trance + num1 < Byte.MaxValue)
            {
                v.Target.Data.trance += num1;
            }
            else
            {
                v.Target.Data.trance = Byte.MaxValue;

                if (FF9StateSystem.Battle.isDebug)
                {
                    return;
                }

                if (Configuration.Battle.NoAutoTrance)
                {
                    return;
                }

                v.Target.AlterStatus(BattleStatus.Trance);
            }
        }
Ejemplo n.º 9
0
 public static void OrganizeEnemyData(FF9StateBattleSystem btlsys)
 {
     for (Int32 i = 0; i < BTL_SCENE.GetMonCount(); i++)
     {
         ENEMY_TYPE et       = btlsys.enemy[i].et;
         BTL_DATA   btl_DATA = btlsys.btl_data[4 + i];
         btl_DATA.level  = et.level;
         btl_DATA.max.at = (Int16)((60 - btl_DATA.elem.dex) * 40 << 2);
         btl_para.InitATB(btl_DATA);
         btl_DATA.cur.at = (Int16)(Comn.random16() % (Int32)btl_DATA.max.at);
         btl_DATA.weapon = (ItemAttack)null;
         btl_stat.InitCountDownStatus(btl_DATA);
         btl_mot.HideMesh(btl_DATA, btl_DATA.mesh_current, false);
         if (btl_DATA.bi.slave != 0)
         {
             btl_DATA.cur.at      = 0;
             btl_DATA.cur.at_coef = 0;
             btl_DATA.gameObject.transform.localRotation = btl_DATA.rot;
             btl_DATA.gameObject.transform.localPosition = btl_DATA.evt.posBattle;
             btl_DATA.currentAnimationName = btl_DATA.mot[(Int32)btl_DATA.bi.def_idle];
             btl_mot.setMotion(btl_DATA, btl_DATA.currentAnimationName);
             btl_mot.setSlavePos(btl_DATA, ref btl_DATA.base_pos);
             UnityEngine.Object.Destroy(btl_DATA.gameObject);
             UnityEngine.Object.Destroy(btl_DATA.getShadow());
             btl_DATA.gameObject = btl_util.GetMasterEnemyBtlPtr().Data.gameObject;
         }
         else
         {
             btl_DATA.base_pos[0]          = btl_DATA.evt.posBattle[0];
             btl_DATA.base_pos[1]          = btl_DATA.evt.posBattle[1];
             btl_DATA.base_pos[2]          = btl_DATA.evt.posBattle[2];
             btl_DATA.currentAnimationName = btl_DATA.mot[(Int32)btl_DATA.bi.def_idle];
             btl_DATA.evt.animFrame        = (Byte)(Comn.random8() % (Int32)GeoAnim.geoAnimGetNumFrames(btl_DATA));
         }
     }
 }
Ejemplo n.º 10
0
 public void SetLowPhisicalAttack()
 {
     _context.Attack = (Int16)(Strength + Comn.random16() % (1 + (Level + Strength >> 3)));
 }
Ejemplo n.º 11
0
 public void SetMagicAttack()
 {
     _context.Attack = (Int16)(Magic + Comn.random16() % (1 + (Level + Magic >> 3)));
 }
Ejemplo n.º 12
0
 private static void FldCalcSub_137(Context v)
 {
     v.AttackNumber = (Int16)(v.Caster.elem.mgc + Comn.random16() % (1 + (v.Caster.level + v.Caster.elem.mgc >> 3)));
     v.AttackPower  = v.Tbl.Ref.Power;
     v.DefencePower = v.Target.defence.MagicalDefence;
 }
Ejemplo n.º 13
0
    public static void OrganizePlayerData(PLAYER p, BTL_DATA btl, UInt16 cnt, UInt16 btl_no)
    {
        btl.btl_id = (UInt16)(1 << (Int32)btl_no);
        BONUS btl_bonus = battle.btl_bonus;

        btl_bonus.member_flag = (Byte)(btl_bonus.member_flag | (Byte)(1 << (Int32)cnt));
        btl.bi.player         = 1;
        btl.bi.slot_no        = p.info.slot_no;
        btl.bi.target         = 1;
        btl.bi.line_no        = (Byte)cnt;
        btl.bi.slave          = 0;
        if (battle.TRANCE_GAUGE_FLAG == 0 || (p.category & 16) != 0 || (btl.bi.slot_no == 2 && battle.GARNET_DEPRESS_FLAG != 0))
        {
            btl.bi.t_gauge = 0;
            btl.trance     = 0;
        }
        else
        {
            btl.bi.t_gauge = 1;
            btl.trance     = p.trance;
        }
        btl.tar_bone = 0;
        btl.sa       = p.sa;
        btl.elem.dex = p.elem.dex;
        btl.elem.str = p.elem.str;
        btl.elem.mgc = p.elem.mgc;
        btl.elem.wpr = p.elem.wpr;
        btl.level    = p.level;
        btl.max      = p.max;
        btl_init.CopyPoints(btl.cur, p.cur);
        Byte    serial_no = p.info.serial_no;
        FF9Char ff9Char   = new FF9Char();

        ff9Char.btl = btl;
        ff9Char.evt = btl.evt;
        FF9StateSystem.Common.FF9.charArray.Add((Int32)p.info.slot_no, ff9Char);
        btl_init.InitBattleData(btl, ff9Char);
        btl.mesh_banish = UInt16.MaxValue;
        btl_stat.InitCountDownStatus(btl);
        btl.max.at = (Int16)((60 - btl.elem.dex) * 40 << 2);
        btl_para.InitATB(btl);
        if (FF9StateSystem.Battle.FF9Battle.btl_scene.Info.StartType == 0)
        {
            btl.cur.at = 0;
        }
        else if (FF9StateSystem.Battle.FF9Battle.btl_scene.Info.StartType == 1)
        {
            btl.cur.at = (Int16)(btl.max.at - 1);
        }
        else
        {
            btl.cur.at = (Int16)(Comn.random16() % (Int32)btl.max.at);
        }
        btl_mot.SetPlayerDefMotion(btl, (UInt32)p.info.serial_no, (UInt32)btl_no);
        BattlePlayerCharacter.InitAnimation(btl);
        btl_eqp.InitWeapon(p, btl);
        btl.defence.PhisicalDefence = p.defence.PhisicalDefence;
        btl.defence.PhisicalEvade   = p.defence.PhisicalEvade;
        btl.defence.MagicalDefence  = p.defence.MagicalDefence;
        btl.defence.MagicalEvade    = p.defence.MagicalEvade;
        btl_eqp.InitEquipPrivilegeAttrib(p, btl);
        btl_util.GeoSetColor2Source(btl.weapon_geo, 0, 0, 0);
        if (btl.cur.hp * 6 < btl.max.hp)
        {
            btl.stat.cur |= 512u;
        }
        btl_stat.AlterStatuses(btl, (UInt32)p.status & 4294967294u);
        if ((p.status & 1) != 0)
        {
            btl_stat.AlterStatus(btl, 1u);
        }
        btl_abil.CheckStatusAbility(btl);
        btl.base_pos = btl.evt.posBattle;
        Int16 geoID = btl.dms_geo_id;

        btl.height = 0;
        btl.radius = 0;

        FF9BattleDBHeightAndRadius.TryFindHeightAndRadius(geoID, ref btl.height, ref btl.radius);

        if (btl.cur.hp == 0 && btl_stat.AlterStatus(btl, 256u) == 2u)
        {
            btl.die_seq = 5;
            btl_mot.DecidePlayerDieSequence(btl);
            return;
        }
        btl.bi.def_idle = Convert.ToByte(btl_stat.CheckStatus(btl, 197122u));
        btl_mot.setMotion(btl, btl.bi.def_idle);
        btl.evt.animFrame = 0;
    }
Ejemplo n.º 14
0
    public static void OrganizePlayerData(PLAYER p, BTL_DATA btl, UInt16 cnt, UInt16 btl_no)
    {
        btl.btl_id = (UInt16)(1 << btl_no);
        BONUS btl_bonus = battle.btl_bonus;

        btl_bonus.member_flag = (Byte)(btl_bonus.member_flag | (Byte)(1 << cnt));
        btl.bi.player         = 1;
        btl.bi.slot_no        = p.info.slot_no;
        btl.bi.target         = 1;
        btl.bi.line_no        = (Byte)cnt;
        btl.bi.slave          = 0;
        if (battle.TRANCE_GAUGE_FLAG == 0 || (p.category & 16) != 0 || (btl.bi.slot_no == 2 && battle.GARNET_DEPRESS_FLAG != 0))
        {
            btl.bi.t_gauge = 0;
            btl.trance     = 0;
        }
        else
        {
            btl.bi.t_gauge = 1;
            btl.trance     = p.trance;
        }
        btl.tar_bone = 0;
        btl.sa       = p.sa;
        btl.elem.dex = p.elem.dex;
        btl.elem.str = p.elem.str;
        btl.elem.mgc = p.elem.mgc;
        btl.elem.wpr = p.elem.wpr;
        btl.level    = p.level;
        btl.max      = p.max;
        btl_init.CopyPoints(btl.cur, p.cur);
        Byte    serial_no = p.info.serial_no;
        FF9Char ff9Char   = new FF9Char();

        ff9Char.btl = btl;
        ff9Char.evt = btl.evt;
        FF9StateSystem.Common.FF9.charArray.Add(p.info.slot_no, ff9Char);
        btl_init.InitBattleData(btl, ff9Char);
        btl.mesh_banish = UInt16.MaxValue;
        btl_stat.InitCountDownStatus(btl);
        btl.max.at = (Int16)((60 - btl.elem.dex) * 40 << 2);
        btl_para.InitATB(btl);
        if (FF9StateSystem.Battle.FF9Battle.btl_scene.Info.StartType == 0)
        {
            btl.cur.at = 0;
        }
        else if (FF9StateSystem.Battle.FF9Battle.btl_scene.Info.StartType == 1)
        {
            btl.cur.at = (Int16)(btl.max.at - 1);
        }
        else
        {
            btl.cur.at = (Int16)(Comn.random16() % btl.max.at);
        }
        btl_mot.SetPlayerDefMotion(btl, p.info.serial_no, btl_no);
        BattlePlayerCharacter.InitAnimation(btl);
        btl_eqp.InitWeapon(p, btl);
        btl.defence.PhisicalDefence = p.defence.PhisicalDefence;
        btl.defence.PhisicalEvade   = p.defence.PhisicalEvade;
        btl.defence.MagicalDefence  = p.defence.MagicalDefence;
        btl.defence.MagicalEvade    = p.defence.MagicalEvade;
        btl_eqp.InitEquipPrivilegeAttrib(p, btl);
        btl_util.GeoSetColor2Source(btl.weapon_geo, 0, 0, 0);
        if (btl.cur.hp * 6 < btl.max.hp)
        {
            btl.stat.cur |= BattleStatus.LowHP;
        }

        btl_stat.AlterStatuses(btl, (BattleStatus)p.status & (BattleStatus.Venom | BattleStatus.Virus | BattleStatus.Silence | BattleStatus.Blind | BattleStatus.Trouble | BattleStatus.Zombie | BattleStatus.EasyKill | BattleStatus.Death | BattleStatus.LowHP | BattleStatus.Confuse | BattleStatus.Berserk | BattleStatus.Stop | BattleStatus.AutoLife | BattleStatus.Trance | BattleStatus.Defend | BattleStatus.Poison | BattleStatus.Sleep | BattleStatus.Regen | BattleStatus.Haste | BattleStatus.Slow | BattleStatus.Float | BattleStatus.Shell | BattleStatus.Protect | BattleStatus.Heat | BattleStatus.Freeze | BattleStatus.Vanish | BattleStatus.Doom | BattleStatus.Mini | BattleStatus.Reflect | BattleStatus.Jump | BattleStatus.GradualPetrify));
        if ((p.status & 1) != 0)
        {
            btl_stat.AlterStatus(btl, BattleStatus.Petrify);
        }
        btl_abil.CheckStatusAbility(new BattleUnit(btl));
        btl.base_pos = btl.evt.posBattle;
        Int16 geoID = btl.dms_geo_id;

        btl.height = 0;
        btl.radius = 0;

        FF9BattleDBHeightAndRadius.TryFindHeightAndRadius(geoID, ref btl.height, ref btl.radius);

        if (btl.cur.hp == 0 && btl_stat.AlterStatus(btl, BattleStatus.Death) == 2u)
        {
            btl.die_seq = 5;
            btl_mot.DecidePlayerDieSequence(btl);
            return;
        }
        btl.bi.def_idle = Convert.ToByte(btl_stat.CheckStatus(btl, BattleStatus.IdleDying));
        btl_mot.setMotion(btl, btl.bi.def_idle);
        btl.evt.animFrame = 0;
    }