コード例 #1
0
ファイル: Game.cs プロジェクト: sakseichek/homm
        public void DequeueBattleCommand(int playerId, out BattleCommand cmd)
        {
            cmd = null;

            if (GameSetting._attackPlayer != null && playerId == GameSetting._attackPlayer._id)
            {
                // attacker get defender commands
                if (GameSetting._defendCommands.Count > 0)
                {
                    lock (frmGame._lockToken)
                    {
                        cmd = (BattleCommand)GameSetting._defendCommands.Dequeue();
                    }
                }
            }
            else if (GameSetting._defendPlayer != null && playerId == GameSetting._defendPlayer._id)
            {
                // defender get attacker commands
                if (GameSetting._attackCommands.Count > 0)
                {
                    lock (frmGame._lockToken)
                    {
                        cmd = (BattleCommand)GameSetting._attackCommands.Dequeue();
                    }
                }
            }
        }
コード例 #2
0
ファイル: BattleScene.cs プロジェクト: umb16/AoH_emulation
 void setAnim(BattleCommand command)
 {
     int alterIndex = Mathf.Abs (currentIndex - 1);
     if (command == BattleCommand.block) {
         anim [currentIndex].SetInteger ("animIndex", 1);
         anim [alterIndex].SetInteger ("animIndex", 3);
     } else if (command == BattleCommand.bit) {
         anim [currentIndex].SetInteger ("animIndex", 1);
         anim [alterIndex].SetInteger ("animIndex", 2);
     } else if (command == BattleCommand.die) {
         anim [currentIndex].SetInteger ("animIndex", 1);
         anim [alterIndex].SetInteger ("animIndex", 4);
     }
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: sakseichek/homm
 public void EnqueueBattleCommand(int playerId, BattleCommand cmd)
 {
     if (GameSetting._attackPlayer != null && playerId == GameSetting._attackPlayer._id)
     {
         lock (frmGame._lockToken)
         {
             GameSetting._attackCommands.Enqueue(cmd);
         }
     }
     else if (GameSetting._defendPlayer != null && playerId == GameSetting._defendPlayer._id)
     {
         lock (frmGame._lockToken)
         {
             GameSetting._defendCommands.Enqueue(cmd);
         }
     }
 }
コード例 #4
0
ファイル: BattleScene.cs プロジェクト: umb16/AoH_emulation
 public void setCommand(BattleCommand command1, BattleCommand command2)
 {
     currentIndex = 0;
     suicide = false;
     if (command1 == command2 && command2 == BattleCommand.die) {
         anim [0].SetInteger ("animIndex", 1);
         anim [1].SetInteger ("animIndex", 1);
         suicide = true;
     } else if (command1 == BattleCommand.die) {
         currentIndex = 1;
         setAnim (command2);
         currentIndex = 0;
         secondCommand = command1;
         Invoke("secondPhase",2);
     } else {
         setAnim (command1);
         currentIndex = 1;
         secondCommand = command2;
         Invoke("secondPhase",2);
     }
 }
コード例 #5
0
ファイル: btl_abil.cs プロジェクト: ArtReeX/memoria
        public static void CheckAutoItemAbility(BattleTarget defender, BattleCommand command)
        {
            const Byte potion1Id      = 236;
            const Byte potion2Id      = 237;
            const Byte potionScriptId = 069;

            if (!defender.HasSupportAbility(SupportAbility2.AutoPotion))
            {
                return;
            }

            if (defender.IsUnderStatus(BattleStatus.NoReaction) || command.Id > BattleCommandId.EnemyAtk)
            {
                return;
            }

            Int32 overhealLimit = Configuration.Battle.AutoPotionOverhealLimit;

            // Vanila
            if (overhealLimit < 0)
            {
                foreach (Byte potionId in new[] { potion1Id, potion2Id })
                {
                    if (ff9item.FF9Item_GetCount(potionId) != 0)
                    {
                        UIManager.Battle.ItemRequest(potionId);
                        btl_cmd.SetCounter(defender.Data, BattleCommandId.AutoPotion, potionId, defender.Id);
                        break;
                    }
                }
            }
            // Better auto-potions
            else
            {
                Byte betterPotionId = 0;

                foreach (Byte potionId in new[] { potion1Id, potion2Id })
                {
                    if (ff9item.FF9Item_GetCount(potionId) < 1)
                    {
                        continue;
                    }

                    CMD_DATA testCommand = new CMD_DATA
                    {
                        cmd_no = BattleCommandId.AutoPotion,
                        sub_no = potionId,
                        aa     = FF9StateSystem.Battle.FF9Battle.aa_data[0],
                        tar_id = defender.Id,
                        info   = new CMD_DATA.SELECT_INFO()
                    };

                    BattleCalculator    v       = new BattleCalculator(defender.Data, defender.Data, new BattleCommand(testCommand));
                    BattleScriptFactory factory = SBattleCalculator.FindScriptFactory(potionScriptId);
                    if (factory != null)
                    {
                        IBattleScript script = factory(v);
                        script.Perform();
                    }

                    Int16 heal = v.Target.HpDamage;
                    Int32 harm = v.Target.MaximumHp - v.Target.CurrentHp;

                    if (heal - harm > heal * overhealLimit / 100)
                    {
                        break;
                    }

                    betterPotionId = potionId;
                }

                if (betterPotionId != 0)
                {
                    UIManager.Battle.ItemRequest(betterPotionId);
                    btl_cmd.SetCounter(defender.Data, BattleCommandId.AutoPotion, betterPotionId, defender.Id);
                }
            }
        }
コード例 #6
0
ファイル: BattleScene.cs プロジェクト: umb16/AoH_emulation
 void secondPhase()
 {
     setAnim (secondCommand);
     secondCommand = BattleCommand.zero;
 }
コード例 #7
0
ファイル: CommandHolder.cs プロジェクト: raptor420/ExKreed
 public void init(BattleCommand command, Battler user, Tile target)
 {
     this.command = command;
     this.user    = user;
     this.target  = target;
 }
コード例 #8
0
    void Awake()
    {
        characterSpeedManager.playerList = playerList;
        characterSpeedManager.enemyList = enemyList;

        commands = new BattleCommand[commandObjects.Length];
        commandPositions = new Vector3[commandObjects.Length];
        for(int i=0; i<commands.Length;i++)
        {
            commands[i] = new BattleCommand();
            commands[i].position = commandObjects[i].transform.position;
            commands[i].positionIndex = i;
            commandPositions[i] = commandObjects[i].transform.position;
        }
    }
コード例 #9
0
 public virtual bool CanUseAbility(Character target, BattleCommand ability)
 {
     return(false);
 }
コード例 #10
0
ファイル: Kernel_bin.cs プロジェクト: stantoxt/OpenVIII
        /// <summary>
        /// Read binary data from into structures and arrays
        /// </summary>
        /// <see cref="http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain/wiki/Kernel.bin"/>
        public KernelBin()
        {
            Memory.Log.WriteLine($"{nameof(KernelBin)} :: new ");
            ArchiveBase aw = ArchiveWorker.Load(ArchiveString);

            byte[]     buffer       = aw.GetBinaryFile(Memory.Strings[Strings.FileID.KERNEL].GetFilenames()[0]);
            List <Loc> subPositions = Memory.Strings[Strings.FileID.KERNEL].GetFiles().subPositions;

            MemoryStream ms;

            if (buffer == null)
            {
                return;
            }
            using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
            {
                ms.Seek(subPositions[BattleCommand.ID], SeekOrigin.Begin);
                BattleCommands = BattleCommand.Read(br);
                ms.Seek(subPositions[Magic_Data.id], SeekOrigin.Begin);
                MagicData = Magic_Data.Read(br);
                ms.Seek(subPositions[Junctionable_GFs_Data.id], SeekOrigin.Begin);
                JunctionableGFsData = Junctionable_GFs_Data.Read(br);
                ms.Seek(subPositions[Enemy_Attacks_Data.id], SeekOrigin.Begin);
                EnemyAttacksData = Enemy_Attacks_Data.Read(br);
                ms.Seek(subPositions[Weapons_Data.id], SeekOrigin.Begin);
                WeaponsData = Weapons_Data.Read(br);
                ms.Seek(subPositions[Renzokuken_Finishers_Data.id], SeekOrigin.Begin);
                RenzokukenFinishersData = Renzokuken_Finishers_Data.Read(br);
                ms.Seek(subPositions[Character_Stats.id], SeekOrigin.Begin);
                CharacterStats = Character_Stats.Read(br);
                ms.Seek(subPositions[BattleItemData.ID], SeekOrigin.Begin);
                BattleItemsData    = BattleItemData.Read(br);
                NonBattleItemsData = Non_battle_Items_Data.Read();
                ms.Seek(subPositions[Non_Junctionable_GFs_Attacks_Data.id], SeekOrigin.Begin);
                NonJunctionableGFsAttacksData = Non_Junctionable_GFs_Attacks_Data.Read(br);
                ms.Seek(subPositions[Command_ability_data.id], SeekOrigin.Begin);
                CommandAbilityData = Command_ability_data.Read(br);
                ms.Seek(subPositions[Kernel.JunctionAbilities.ID], SeekOrigin.Begin);
                JunctionAbilities = Kernel.JunctionAbilities.Read(br);
                ms.Seek(subPositions[Kernel.CommandAbilities.ID], SeekOrigin.Begin);
                CommandAbilities = Kernel.CommandAbilities.Read(br);
                ms.Seek(subPositions[StatPercentageAbilities.ID], SeekOrigin.Begin);
                StatPercentAbilities = StatPercentageAbilities.Read(br);
                ms.Seek(subPositions[Kernel.CharacterAbilities.ID], SeekOrigin.Begin);
                CharacterAbilities = Kernel.CharacterAbilities.Read(br);
                ms.Seek(subPositions[Kernel.PartyAbilities.ID], SeekOrigin.Begin);
                PartyAbilities = Kernel.PartyAbilities.Read(br);
                ms.Seek(subPositions[Kernel.GFAbilities.ID], SeekOrigin.Begin);
                GFAbilities = Kernel.GFAbilities.Read(br);
                ms.Seek(subPositions[Kernel.MenuAbilities.ID], SeekOrigin.Begin);
                MenuAbilities = Kernel.MenuAbilities.Read(br);
                ms.Seek(subPositions[Temporary_character_limit_breaks.id], SeekOrigin.Begin);
                TemporaryCharacterLimitBreaks = Temporary_character_limit_breaks.Read(br);
                ms.Seek(subPositions[Blue_Magic_Quistis_limit_break.id], SeekOrigin.Begin);
                BlueMagicQuistisLimitBreak = Blue_Magic_Quistis_limit_break.Read(br);
                //ms.Seek(subPositions[Quistis_limit_break_parameters.BattleID], SeekOrigin.Begin);
                //QuistisLimitBreakParameters = Quistis_limit_break_parameters.Read(br);
                ms.Seek(subPositions[Shot_Irvine_limit_break.id], SeekOrigin.Begin);
                ShotIrvineLimitBreak = Shot_Irvine_limit_break.Read(br);
                ms.Seek(subPositions[Duel_Zell_limit_break.id], SeekOrigin.Begin);
                DuelZellLimitBreak = Duel_Zell_limit_break.Read(br);
                ms.Seek(subPositions[Zell_limit_break_parameters.id], SeekOrigin.Begin);
                ZellLimitBreakParameters = Zell_limit_break_parameters.Read(br);
                ms.Seek(subPositions[Rinoa_limit_breaks_part_1.id], SeekOrigin.Begin);
                RinoaLimitBreaksPart1 = Rinoa_limit_breaks_part_1.Read(br);
                ms.Seek(subPositions[Rinoa_limit_breaks_part_2.id], SeekOrigin.Begin);
                RinoaLimitBreaksPart2 = Rinoa_limit_breaks_part_2.Read(br);
                ms.Seek(subPositions[Slot_array.id], SeekOrigin.Begin);
                SlotArray = Slot_array.Read(br);
                ms.Seek(subPositions[Selphie_limit_break_sets.id], SeekOrigin.Begin);
                SelphieLimitBreakSets = Selphie_limit_break_sets.Read(br);
                ms.Seek(subPositions[Kernel.Devour.id], SeekOrigin.Begin);
                List <Devour> tmp = Kernel.Devour.Read(br);
                tmp.Add(new Devour {
                    Description = Memory.Strings.Read(Strings.FileID.KERNEL, 30, 112)
                });
                Devour = tmp;
                ms.Seek(subPositions[Misc_section.id], SeekOrigin.Begin);
                MiscSection      = Misc_section.Read(br);
                MiscTextPointers = Misc_text_pointers.Read();

                Dictionary <Abilities, Ability> allAbilities = new Dictionary <Abilities, Ability>(Kernel.MenuAbilities.Count + Kernel.JunctionAbilities.Count + Kernel.CommandAbilities.Count + StatPercentageAbilities.Count + Kernel.CharacterAbilities.Count + Kernel.PartyAbilities.Count + Kernel.GFAbilities.Count);
                foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                {
                    combine(MenuAbilities);
                    combine(StatPercentAbilities);
                    combine(JunctionAbilities);
                    combine(CommandAbilities);
                    combine(CharacterAbilities);
                    combine(PartyAbilities);
                    combine(GFAbilities);
                    void combine <T>(IReadOnlyDictionary <Abilities, T> dict)
                        where T : Ability
                    {
                        if (!dict.TryGetValue(ability, out T a))
                        {
                            return;
                        }
                        allAbilities.Add(ability, a);
                    }
                }

                AllAbilities = allAbilities;
                Dictionary <Abilities, EquippableAbility> equippableAbilities = new Dictionary <Abilities, EquippableAbility>(
                    StatPercentageAbilities.Count +
                    Kernel.CharacterAbilities.Count +
                    Kernel.PartyAbilities.Count +
                    Kernel.GFAbilities.Count);
                foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                {
                    if (StatPercentAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = StatPercentAbilities[ability];
                    }
                    else if (CharacterAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = CharacterAbilities[ability];
                    }
                    else if (PartyAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = PartyAbilities[ability];
                    }
                    else if (CharacterAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = CharacterAbilities[ability];
                    }
                }
                EquippableAbilities = equippableAbilities;
            }
        }
コード例 #11
0
    public void Execute()
    {
        List <BattleCommandRuner.PutedSkillInfo> removeList      = new List <BattleCommandRuner.PutedSkillInfo>();
        List <BattleCommandRuner.PutedSkillInfo> putedSkillInfos = BattleCommandRuner.Instance.GetPutedSkillInfos();
        Contexts contexts = EntityMgr.Instance.GetContexts();

        for (int i = 0; i < putedSkillInfos.Count; i++)
        {
            SkillSetting skillSetting = SkillSetting.SkillSettingDict[putedSkillInfos[i].SkillId];
            if (putedSkillInfos[i].PutSkillTime + skillSetting.SkillAttackTime <= Time.time)
            {
                HashSet <GameEntity> gameEntities = null;
                GameEntity           entity       = EntityMgr.Instance.GetGameEntity(putedSkillInfos[i].EntityId);
                if (entity.entityInfoComp.EntityType == EntityType.MainPlayer)
                {
                    gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.Monster);
                }
                else
                {
                    gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.MainPlayer);
                }
                foreach (var item in gameEntities)
                {
                    Vector3 forward           = entity.moveComp.Forward;
                    Vector3 entityPos         = item.moveComp.CurPos;
                    Vector3 skillPutEntityPos = entity.moveComp.CurPos;

                    //Debug.LogError(" 释放者 " + skillPutEntityPos.x + " " + skillPutEntityPos.z);
                    //Debug.LogError(" 被攻击者 " + entityPos.x + " " + entityPos.z);
                    //Debug.LogError(" forward " + forward.x + " " + forward.z);

                    bool isAttacked = false;

                    if (skillSetting.IsAttackForward == true)
                    {
                        if (Mathf.Abs(entityPos.x - skillPutEntityPos.x) <= skillSetting.AttackInfoCo.x &&
                            Mathf.Abs(entityPos.z - skillPutEntityPos.z) <= skillSetting.AttackInfoCo.y)
                        {
                            Vector3 vec1 = new Vector3(entityPos.x - skillPutEntityPos.x, entityPos.y - skillPutEntityPos.y, entityPos.z - skillPutEntityPos.z);
                            vec1    = Vector3.Normalize(vec1);
                            forward = Vector3.Normalize(forward);

                            float cos = Vector3.Dot(vec1, forward);

                            isAttacked = true;
                        }
                    }
                    else
                    {
                        Vector3 diff = entityPos - skillPutEntityPos;
                        if (diff.sqrMagnitude <= skillSetting.AttackInfoCo.r)
                        {
                            isAttacked = true;
                        }
                    }

                    if (isAttacked == true)
                    {
                        BattleCommand command1 = new BattleCommand();
                        command1.CommandType         = BattleCommandType.PlayAni;
                        command1.EntityId            = item.entityInfoComp.Id;
                        command1.PlayAniInfo         = new BattleCommand.CommandPlayAniInfo();
                        command1.PlayAniInfo.AniName = "attacked";
                        BattleLoop.Instance.AddCommand(command1);
                    }
                }
                removeList.Insert(0, putedSkillInfos[i]);
            }
        }

        for (int i = 0; i < removeList.Count; i++)
        {
            BattleCommandRuner.Instance.RemovePutedSkillInfo(removeList[i]);
        }
    }
コード例 #12
0
ファイル: Client.cs プロジェクト: umb16/AoH_emulation
    void CalculateTurn(Turn[] turn)
    {
        BattleCommand[] command = new BattleCommand[2];

        /*bool crit=false;
        bool flee=false;*/
        string name1;
        string name2;
        int dif=0;
        float dmgFactor=1f;
        int alterIndex;/*
        string block = "";
        string partOfBody = "";*/
        string log = "";
        int dmg = 1;
        for (int j = 0; j < turn.Length; j++) {
            alterIndex = Mathf.Abs (j - 1);
            name1 = "Player" + (j + 1);
            log = "";
            name2 = "Player" + (alterIndex + 1);
            //crit = (Random.Range(0,100) < Mathf.Floor( turn [j].player.critChance*100)) ? true : false;
            //flee = (Random.Range(0,100) < Mathf.Floor( turn [alterIndex].player.fleeChance*100)) ? true : false;
            log += name1 + string.Format(" бъет в {0}",BodyPart(turn[j].att));
            turn[j].player.SP-=3;
            dif= (int)Mathf.Abs(turn[j].att-turn[alterIndex].def);
            if(dif>numberOfZones/2)
            dif=numberOfZones-dif;
            print("difbefore="+dif);
            //dif-= fleeCalc(turn[alterIndex].player.Agility,turn[j].player.Agility);

            print("difafter="+dif);
            /*if(turn[j].att>=1&&turn[j].att<=2)
            {
                dif-=2;
                dmgFactor = calculateDmgFactor(dif);
                dmgFactor*=2f;
            }
            else
            {
            if(turn[j].att>=3&&turn[j].att<=6||turn[j].att>=23&&turn[j].att<=26||turn[j].att>=11&&turn[j].att<=18)
            {
                dif-=1;

            }*/
                dmgFactor = calculateDmgFactor(dif,fleeCalc(turn[alterIndex].player.Agility,turn[j].player.Agility));
            //}
            if (dmgFactor==0) {
                log += ", "+name2+ " ловко избегает повреждений.";
                command [j] = BattleCommand.block;
            } else {
                if (dmgFactor<.6f) {
                    log += " и, едва цепляя "+name2+",";
                }
                else
                if (dmgFactor<1.6f) {
                    log += " и";
                }
                else{
                    log += " и, попадая в уязвимое место,";
                }
                dmg=(int)(((float)turn [j].player.weaponDmg)*dmgFactor);
                log += string.Format(" наносит {0} урона",dmg);
                turn [alterIndex].player.HP -= dmg;
                command [j] = BattleCommand.bit;

            }
            /*if (!flee) {
                for (int i = 0; i < turn[j].att.Length; i++) {
                    if (turn [j].att [i] == true) {
                        if (i == 0)
                            partOfBody = "голову ";
                        else if (i == 1) {
                            partOfBody = "грудь ";
                        } else if (i == 2) {
                            partOfBody = "пах ";
                        } else {
                            partOfBody = "ноги ";
                        }
                        if (turn [alterIndex].def [i] == false) {
                            block = "";
                            command [j] = BattleCommand.bit;
                            if (i == 0) {
                                dmg *= (int)((turn [j].player.totalDmg + turn [j].player.totalDmg * Random.value * .1f) * turn [alterIndex].player.helmetDefMultiplier);
                            } else {
                                dmg *= (int)((turn [j].player.totalDmg + turn [j].player.totalDmg * Random.value * .1f) * turn [alterIndex].player.armorDefMultiplier);
                            }
                        } else {
                            command [j] = BattleCommand.block;
                            block = ", попадает в блок, ";
                            if (i == 0) {
                                dmg *= (int)((turn [j].player.totalDmg + turn [j].player.totalDmg * Random.value * .1f) * turn [alterIndex].player.helmetDefMultiplier * turn [alterIndex].player.shieldDefMultiplier);
                            } else {
                                dmg *= (int)((turn [j].player.totalDmg + turn [j].player.totalDmg * Random.value * .1f) * turn [alterIndex].player.armorDefMultiplier * turn [alterIndex].player.shieldDefMultiplier);
                            }
                        }
                    }
                }
                turn [alterIndex].player.HP -= dmg;
            }*/
            turn[j].player.SP+=1;
            Debug.Log (log);
            if (turn [alterIndex].player.HP < 1) {
                command [j] = BattleCommand.die;
                Debug.Log (name2 + " умерает");
            }
        }
        battleScene.setCommand (command [0], command [1]);
    }
コード例 #13
0
 private static CommandAbility CreateInstance(BinaryReader br, int i, BattleCommand battleCommand)
 => new CommandAbility(br, i, battleCommand);
コード例 #14
0
 public void ClearInfo()
 {
     command = BattleCommand.None;
 }
コード例 #15
0
 public void ClearCommand()
 {
     LogHelper.DebugLog("clear command");
     CurrentCommand = BattleCommand.None;
     Time           = 0;
 }
コード例 #16
0
 public void SetCommand(BattleCommand command)
 {
     LogHelper.DebugLog("set command:" + command);
     CurrentCommand = command;
     Time           = 0;
 }
コード例 #17
0
 // 发送
 public void Send(BattleCommand battlecmd)
 {
     byte[] bytes = ProtoTransfer.Serialize(battlecmd);
     Send(bytes);
 }
コード例 #18
0
 //Try and apply a status effect
 public void TryStatus(Character caster, Character target, BattleCommand skill, CommandResultContainer results, bool isAdditional = true)
 {
     BattleUtils.TryStatus(caster, target, skill, this, results, isAdditional);
 }
コード例 #19
0
 public virtual bool CanCast(Character target, BattleCommand spell)
 {
     return(false);
 }
コード例 #20
0
        //Damage calculations
        //Calculate damage of action
        //We could probably just do this when determining the action's hit type
        public static void CalculatePhysicalDamageTaken(Character attacker, Character defender, BattleCommand skill, CommandResult action)
        {
            short dlvl = (short)(defender.GetLevel() - attacker.GetLevel());

            // todo: physical resistances

            //dlvl, Defense, and Vitality all effect how much damage is taken after hittype takes effect
            //player attacks cannot do more than 9999 damage.
            //VIT is turned into Defense at a 3:2 ratio in calculatestats, so don't need to do that here
            double damageTakenPercent = 1 - (defender.GetMod(Modifier.DamageTakenDown) / 100.0);

            action.amount = (ushort)(action.amount - CalculateDlvlModifier(dlvl) * (defender.GetMod((uint)Modifier.Defense))).Clamp(0, 9999);
            action.amount = (ushort)(action.amount * damageTakenPercent).Clamp(0, 9999);
        }
コード例 #21
0
        private Hougeki <BattleAtackKinds_Day> getHougekiData(BattleCommand command, int atk_idx, Mem_ship attacker)
        {
            if (!attacker.IsFight())
            {
                return(null);
            }
            BattleBaseData f_Data = F_Data;
            Dictionary <int, BattleShipSubInfo> f_SubInfo = F_SubInfo;
            BattleBaseData e_Data = E_Data;
            Dictionary <int, BattleShipSubInfo> e_SubInfo = E_SubInfo;

            if (!isAttackerFromTargetKind(f_SubInfo[attacker.Rid]))
            {
                return(null);
            }
            Dictionary <int, Mst_stype> mst_stypes = Mst_DataManager.Instance.Mst_stype;
            Dictionary <int, Mst_ship>  mst_ships  = Mst_DataManager.Instance.Mst_ship;
            List <Mem_ship>             shipData   = e_Data.ShipData;
            bool submarine_flag = false;
            BattleAtackKinds_Day    battleAtackKinds_Day = BattleAtackKinds_Day.Normal;
            List <int>              slot_List            = null;
            KeyValuePair <int, int> submarine_keisu      = new KeyValuePair <int, int>(0, 0);
            bool flag = IsAirAttackGroup(attacker, f_Data.SlotData[atk_idx], command);

            if (flag && !CanAirAtack_DamageState(attacker))
            {
                return(null);
            }
            int num = 0;

            if (command != BattleCommand.Taisen)
            {
                shipData = (from x in shipData
                            where !mst_stypes[x.Stype].IsSubmarine()
                            select x).ToList();
                if (flag)
                {
                    if (command != BattleCommand.Kouku)
                    {
                        return(null);
                    }
                    if (!CanAirAttack(attacker, f_Data.SlotData[atk_idx]))
                    {
                        return(null);
                    }
                    battleAtackKinds_Day = BattleAtackKinds_Day.AirAttack;
                    List <int> list = new List <int>();
                    list.Add(0);
                    slot_List = list;
                    if (!isValidAirAtack_To_LandFaccillity(attacker, f_Data.SlotData[atk_idx]))
                    {
                        shipData = (from x in shipData
                                    where (!mst_stypes[x.Stype].IsLandFacillity(mst_ships[x.Ship_id].Soku)) ? true : false
                                    select x).ToList();
                    }
                }
                else if (!isValidHougeki(attacker))
                {
                    return(null);
                }
                if (!flag && command == BattleCommand.Kouku)
                {
                    if (airAttackEndRid.Contains(attacker.Rid))
                    {
                        return(null);
                    }
                    airAttackEndRid.Add(attacker.Rid);
                    num = 2;
                    int        hougSlotData = getHougSlotData(f_Data.SlotData[atk_idx]);
                    List <int> list         = new List <int>();
                    list.Add(hougSlotData);
                    slot_List = list;
                }
            }
            else
            {
                shipData = (from x in shipData
                            where mst_stypes[x.Stype].IsSubmarine()
                            select x).ToList();
                submarine_keisu = getSubMarineAtackKeisu(shipData, attacker, f_Data.SlotData[atk_idx], midnight: false);
                if (submarine_keisu.Key == 0)
                {
                    shipData = (from x in e_Data.ShipData
                                where !mst_stypes[x.Stype].IsSubmarine()
                                select x).ToList();
                    submarine_flag = false;
                    num            = 1;
                    if (flag)
                    {
                        if (!CanAirAttack(attacker, f_Data.SlotData[atk_idx]))
                        {
                            return(null);
                        }
                        battleAtackKinds_Day = BattleAtackKinds_Day.AirAttack;
                        List <int> list = new List <int>();
                        list.Add(0);
                        slot_List = list;
                        if (!isValidAirAtack_To_LandFaccillity(attacker, f_Data.SlotData[atk_idx]))
                        {
                            shipData = (from x in shipData
                                        where (!mst_stypes[x.Stype].IsLandFacillity(mst_ships[x.Ship_id].Soku)) ? true : false
                                        select x).ToList();
                        }
                    }
                    else if (!isValidHougeki(attacker))
                    {
                        return(null);
                    }
                    if (!flag)
                    {
                        int        hougSlotData2 = getHougSlotData(f_Data.SlotData[atk_idx]);
                        List <int> list          = new List <int>();
                        list.Add(hougSlotData2);
                        slot_List = list;
                    }
                }
                else
                {
                    battleAtackKinds_Day = ((submarine_keisu.Key == 1) ? BattleAtackKinds_Day.Bakurai : BattleAtackKinds_Day.AirAttack);
                    List <int> list = new List <int>();
                    list.Add(0);
                    slot_List      = list;
                    submarine_flag = true;
                }
            }
            if (shipData.Count == 0)
            {
                return(null);
            }
            if (command != BattleCommand.Taisen && num == 0)
            {
                KeyValuePair <BattleAtackKinds_Day, List <int> > spAttackKind = getSpAttackKind(attacker, f_Data.SlotData[atk_idx]);
                if (battleAtackKinds_Day != BattleAtackKinds_Day.AirAttack || spAttackKind.Key != 0)
                {
                    battleAtackKinds_Day = spAttackKind.Key;
                    slot_List            = spAttackKind.Value;
                }
            }
            Hougeki <BattleAtackKinds_Day> attackData = getAttackData(attacker, f_Data.SlotData[atk_idx], f_Data.SlotLevel[atk_idx], battleAtackKinds_Day, submarine_flag, submarine_keisu, shipData, e_Data.LostFlag, e_SubInfo, num);

            if (attackData != null)
            {
                attackData.Slot_List = slot_List;
            }
            return(attackData);
        }
コード例 #22
0
 public void SetInfo(BattleCommand iCommand)
 {
     command = iCommand;
 }
コード例 #23
0
        public static void CalculateSpellDamageTaken(Character attacker, Character defender, BattleCommand skill, CommandResult action)
        {
            short dlvl = (short)(defender.GetLevel() - attacker.GetLevel());

            // todo: elemental resistances
            //Patch 1.19:
            //Magic Defense has been abolished and no longer appears in equipment attributes.
            //The effect of elemental attributes has been changed to that of reducing damage from element-based attacks.

            //http://kanican.livejournal.com/55370.html:
            //elemental resistance stats are not actually related to resists (except for status effects), instead they impact damage taken


            //dlvl, Defense, and Vitality all effect how much damage is taken after hittype takes effect
            //player attacks cannot do more than 9999 damage.
            double damageTakenPercent = 1 - (defender.GetMod(Modifier.DamageTakenDown) / 100.0);

            action.amount = (ushort)(action.amount - CalculateDlvlModifier(dlvl) * (defender.GetMod((uint)Modifier.Defense) + 0.67 * defender.GetMod((uint)Modifier.Vitality))).Clamp(0, 9999);
            action.amount = (ushort)(action.amount * damageTakenPercent).Clamp(0, 9999);
        }
コード例 #24
0
        //The order of messages that appears after using a command is:

        //1. Cast start messages. (ie "You begin casting... ")
        //2. Messages from buffs that activate before the command actually starts, like Power Surge or Presence of Mind. (This may be wrong and these could be the same as 4.)
        //3. If the command is a multi-hit command, this is where the "You use [command] on [target]" message goes

        //Then, for each hit:
        //4. Buffs that activate before a command hits, like Blindside
        //5. The hit itself. For single hit commands this message is "Your [command] hits [target] for x damage" for multi hits it's "[Target] takes x points of damage"
        //6. Stoneskin falling off
        //6. Buffs that activate after a command hits, like Aegis Boon and Divine Veil

        //After all hits
        //7. If it's a multi-hit command there's a "{numhits]fold attack..." message or if all hits miss an "All attacks missed" message
        //8. Buffs that fall off after the skill ends, like Excruciate

        //For every target defeated:
        //8. Defeat message
        //9. EXP message
        //10. EXP chain message


        //folder is probably temporary until move to cached scripts is complete
        public void DoBattleCommand(BattleCommand command, string folder)
        {
            //List<BattleAction> actions = new List<BattleAction>();
            CommandResultContainer actions = new CommandResultContainer();

            var  targets   = command.targetFind.GetTargets();
            bool hitTarget = false;

            if (targets.Count > 0)
            {
                statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnCommandStart, "onCommandStart", this, command, actions);

                foreach (var chara in targets)
                {
                    ushort hitCount    = 0;
                    ushort totalDamage = 0;
                    for (int hitNum = 1; hitNum <= command.numHits; hitNum++)
                    {
                        var action = new CommandResult(chara.actorId, command, (byte)GetHitDirection(chara), (byte)hitNum);

                        //uncached script
                        lua.LuaEngine.CallLuaBattleCommandFunction(this, command, folder, "onSkillFinish", this, chara, command, action, actions);
                        //cached script
                        //skill.CallLuaFunction(owner, "onSkillFinish", this, chara, command, action, actions);
                        if (action.hitType > HitType.Evade && action.hitType != HitType.Resist)
                        {
                            hitTarget = true;
                            hitCount++;
                            totalDamage += action.amount;
                        }
                    }

                    if (command.numHits > 1)
                    {
                        //30442: [hitCount]fold Attack! [chara] takes a total of totalDamage points of damage.
                        //30450: All attacks miss!
                        ushort textId = (ushort)(hitTarget ? 30442 : 30450);
                        actions.AddAction(new CommandResult(chara.actorId, textId, 0, totalDamage, (byte)hitCount));
                    }
                }

                statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnCommandFinish, "onCommandFinish", this, command, actions);
            }
            else
            {
                actions.AddAction(new CommandResult(actorId, 30202, 0));
            }

            //Now that we know if we hit the target we can check if the combo continues
            if (this is Player)
            {
                if (command.isCombo && hitTarget)
                {
                    ((Player)this).SetCombos(command.comboNextCommandId);
                }
                else
                {
                    ((Player)this).SetCombos();
                }
            }

            CommandResult error = new CommandResult(actorId, 0, 0);

            DelMP(command.CalculateMpCost(this));
            DelTP(command.CalculateTpCost(this));
            actions.CombineLists();
            DoBattleAction(command.id, command.battleAnimation, actions.GetList());
        }
コード例 #25
0
        public static void CalculateBlockDamage(Character attacker, Character defender, BattleCommand skill, CommandResult action)
        {
            double percentBlocked;

            //Aegis boon forces a full block
            if (defender.statusEffects.HasStatusEffect(StatusEffectId.AegisBoon))
            {
                percentBlocked = 1.0;
            }
            else
            {
                //Is this a case where VIT gives Block?
                percentBlocked  = defender.GetMod((uint)Modifier.Block) * 0.002;    //Every point of Block adds .2% to how much is blocked
                percentBlocked += defender.GetMod((uint)Modifier.Vitality) * 0.001; //Every point of vitality adds .1% to how much is blocked
            }

            action.amountMitigated = (ushort)(action.amount * percentBlocked);
            action.amount          = (ushort)(action.amount * (1.0 - percentBlocked));
        }
コード例 #26
0
 public virtual bool CanWeaponSkill(Character target, BattleCommand skill)
 {
     return(false);
 }
コード例 #27
0
        //don't know exact crit bonus formula
        public static void CalculateCritDamage(Character attacker, Character defender, BattleCommand skill, CommandResult action)
        {
            short  dlvl  = (short)(defender.GetLevel() - attacker.GetLevel());
            double bonus = (.04 * (dlvl * dlvl)) - 2 * dlvl;

            bonus += 1.20;
            double potencyModifier = (-.075 * dlvl) + 1.73;

            // + potency bonus
            //bonus += attacker.GetMod((uint) Modifier.CriticalPotency) * potencyModifier;
            // - Crit resilience
            //bonus -= attacker.GetMod((uint)Modifier.CriticalResilience) * potencyModifier;

            //need to add something for bonus potency as a part of skill (ie thundara, which breaks the cap)
            action.amount = (ushort)(action.amount * bonus.Clamp(1.15, 1.75));//min bonus of 115, max bonus of 175
        }
コード例 #28
0
ファイル: PlayerBattler.cs プロジェクト: raptor420/ExKreed
 public void chooseTurn(BattleCommand command)
 {
     chosenCommand.init(command, this, null);
     Debug.Log(chosenCommand.command.title + "selected by " + chosenCommand.user.title);
 }
コード例 #29
0
        //There are 3 or 4 tiers of resist that are flat 25% decreases in damage.
        //It's possible we could just calculate the damage at the same time as we determine the hit type (the same goes for the rest of the hit types)
        //Or we could have HitTypes for DoubleResist, TripleResist, and FullResist that get used here.
        public static void CalculateResistDamage(Character attacker, Character defender, BattleCommand skill, CommandResult action)
        {
            double percentResist = 0.5;

            action.amountMitigated = (ushort)(action.amount * (1 - percentResist));
            action.amount          = (ushort)(action.amount * percentResist);
        }
コード例 #30
0
ファイル: CommandHolder.cs プロジェクト: raptor420/ExKreed
 public CommandHolder(BattleCommand command, Battler user, Tile target)
 {
     init(command, user, target);
 }
コード例 #31
0
        //Determine the hit type, set the hit effect, modify damage based on stoneskin and hit type, hit target
        public static void FinishActionPhysical(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null)
        {
            //Figure out the hit type and change damage depending on hit type
            if (!TryMiss(attacker, defender, skill, action))
            {
                //Handle Stoneskin here because it seems like stoneskin mitigates damage done before taking into consideration crit/block/parry damage reductions.
                //This is based on the fact that a 0 damage attack due to stoneskin will heal for 0 with Aegis Boon, meaning Aegis Boon didn't mitigate any damage
                HandleStoneskin(defender, action);

                //Crits can't be blocked (is this true for Aegis Boon and Divine Veil?) or parried so they are checked first.
                if (!TryCrit(attacker, defender, skill, action))
                {
                    //Block and parry order don't really matter because if you can block you can't parry and vice versa
                    if (!TryBlock(attacker, defender, skill, action))
                    {
                        if (!TryParry(attacker, defender, skill, action))
                        {
                            //Finally if it's none of these, the attack was a hit
                            action.hitType = HitType.Hit;
                        }
                    }
                }
            }

            //Actions have different text ids depending on whether they're a part of a multi-hit ws or not.
            Dictionary <HitType, ushort> textIds = SingleHitTypeTextIds;

            //If this is the first hit of a multi hit command, add the "You use [command] on [target]" action
            //Needs to be done here because certain buff messages appear before it.
            if (skill != null && skill.numHits > 1)
            {
                if (action.hitNum == 1)
                {
                    actionContainer?.AddAction(new CommandResult(attacker.actorId, 30441, 0));
                }

                textIds = MultiHitTypeTextIds;
            }

            //Set the correct textId
            action.worldMasterTextId = textIds[action.hitType];

            //Set the hit effect
            SetHitEffectPhysical(attacker, defender, skill, action, actionContainer);

            //Modify damage based on defender's stats
            CalculatePhysicalDamageTaken(attacker, defender, skill, action);

            actionContainer.AddAction(action);
            action.enmity = (ushort)(action.enmity * (skill != null ? skill.enmityModifier : 1));
            //Damage the target
            DamageTarget(attacker, defender, action, actionContainer);
        }
コード例 #32
0
        public static UICommandLabelButton Instantiate(UICommandLabelButton prefab, Transform parent, Vector3 pos, int nIndex, BattleCommand iCommand, Func <bool> onSetCommand)
        {
            UICommandLabelButton uICommandLabelButton = UnityEngine.Object.Instantiate(prefab);

            uICommandLabelButton.transform.parent = parent;
            uICommandLabelButton.transform.localScaleOne();
            uICommandLabelButton.transform.localPosition = pos;
            uICommandLabelButton.Init(nIndex, isValid: true, iCommand, onSetCommand);
            return(uICommandLabelButton);
        }
コード例 #33
0
        public static void FinishActionStatus(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null)
        {
            //Set the hit effect
            SetHitEffectStatus(attacker, defender, skill, action);

            TryStatus(attacker, defender, skill, action, actionContainer, false);

            actionContainer.AddAction(action);
        }
コード例 #34
0
ファイル: btl_abil.cs プロジェクト: ArtReeX/memoria
        public static Boolean CheckCounterAbility(BattleTarget defender, BattleCaster attacker, BattleCommand command)
        {
            if (defender.IsUnderStatus(BattleStatus.NoReaction) || command.Id > BattleCommandId.EnemyAtk)
            {
                return(false);
            }

            if (defender.HasSupportAbility(SupportAbility2.Counter) && (command.Data.aa.Category & 8) != 0) // Physical
            {
                Int32 chance = defender.Will;
                if (defender.HasSupportAbility(SupportAbility2.Eye4Eye))
                {
                    chance *= 2;
                }

                if (chance > Comn.random16() % 100)
                {
                    btl_cmd.SetCounter(defender.Data, BattleCommandId.Counter, 176, attacker.Id);
                    return(true);
                }
            }

            if (defender.HasSupportAbility(SupportAbility2.ReturnMagic) && (command.Data.aa.Category & 128) != 0)     // Magic
            {
                btl_cmd.SetCounter(defender.Data, BattleCommandId.MagicCounter, command.Data.sub_no, attacker.Id);
                return(true);
            }

            return(false);
        }
コード例 #35
0
        public static void SetHitEffectPhysical(Character attacker, Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer)
        {
            var     hitEffect = HitEffect.HitEffectType;
            HitType hitType   = action.hitType;

            //Don't know what recoil is actually based on, just guessing
            //Crit is 2 and 3 together
            if (hitType == HitType.Crit)
            {
                hitEffect |= HitEffect.CriticalHit;
            }
            else
            {
                //It's not clear what recoil level is based on for physical attacks
                double percentDealt = (100.0 * (action.amount / defender.GetMaxHP()));
                if (percentDealt > 5.0)
                {
                    hitEffect |= HitEffect.RecoilLv2;
                }
                else if (percentDealt > 10)
                {
                    hitEffect |= HitEffect.RecoilLv3;
                }
            }

            hitEffect |= HitTypeEffects[hitType];

            //For combos that land, add the combo effect
            if (skill != null && skill.isCombo && hitType > HitType.Evade && hitType != HitType.Evade && !skill.comboEffectAdded)
            {
                hitEffect |= (HitEffect)(skill.comboStep << 15);
                skill.comboEffectAdded = true;
            }

            //if attack hit the target, take into account protective status effects
            if (hitType >= HitType.Parry)
            {
                //Protect / Shell only show on physical/ magical attacks respectively.
                if (defender.statusEffects.HasStatusEffect(StatusEffectId.Protect))
                {
                    if (action != null)
                    {
                        hitEffect |= HitEffect.Protect;
                    }
                }

                if (defender.statusEffects.HasStatusEffect(StatusEffectId.Stoneskin))
                {
                    if (action != null)
                    {
                        hitEffect |= HitEffect.Stoneskin;
                    }
                }
            }

            action.effectId = (uint)hitEffect;
        }
コード例 #36
0
 public void AddCommand(BattleCommand command)
 {
     mCacheCommandList.Insert(0, command);
 }
コード例 #37
0
 public void setProperty(XElement element)
 {
     this.Rid            = int.Parse(element.Element("Rid").get_Value());
     this.GetNo          = int.Parse(element.Element("GetNo").get_Value());
     this.Ship_id        = int.Parse(element.Element("Ship_id").get_Value());
     this.Level          = int.Parse(element.Element("Level").get_Value());
     this.Exp            = int.Parse(element.Element("Exp").get_Value());
     this.Nowhp          = int.Parse(element.Element("Nowhp").get_Value());
     this.C_houg         = int.Parse(element.Element("C_houg").get_Value());
     this.C_raig         = int.Parse(element.Element("C_raig").get_Value());
     this.C_tyku         = int.Parse(element.Element("C_tyku").get_Value());
     this.C_souk         = int.Parse(element.Element("C_souk").get_Value());
     this.C_taik         = int.Parse(element.Element("C_taik").get_Value());
     this.C_taik_powerup = int.Parse(element.Element("C_taik_powerup").get_Value());
     this.C_luck         = int.Parse(element.Element("C_luck").get_Value());
     this.C_taisen       = int.Parse(element.Element("C_taisen").get_Value());
     this.C_kaihi        = int.Parse(element.Element("C_kaihi").get_Value());
     this.Fuel           = int.Parse(element.Element("Fuel").get_Value());
     this.Bull           = int.Parse(element.Element("Bull").get_Value());
     this.Cond           = int.Parse(element.Element("Cond").get_Value());
     this.Locked         = int.Parse(element.Element("Locked").get_Value());
     this.Escape_sts     = bool.Parse(element.Element("Escape_sts").get_Value());
     this.BlingType      = (Mem_ship.BlingKind)((int)Enum.Parse(typeof(Mem_ship.BlingKind), element.Element("BlingType").get_Value()));
     this.BlingWaitDeck  = int.Parse(element.Element("BlingWaitDeck").get_Value());
     this.BlingWaitArea  = int.Parse(element.Element("BlingWaitArea").get_Value());
     this.Bling_start    = int.Parse(element.Element("Bling_start").get_Value());
     this.Bling_end      = int.Parse(element.Element("Bling_end").get_Value());
     using (IEnumerator <XElement> enumerator = element.Element("Slot").Elements().GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             XElement current = enumerator.get_Current();
             this.Slot.Add(int.Parse(current.get_Value()));
         }
     }
     using (var enumerator2 = Enumerable.Select(element.Element("Onslot").Elements(), (XElement obj, int idx) => new
     {
         obj,
         idx
     }).GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             var current2 = enumerator2.get_Current();
             this.Onslot.Add(int.Parse(current2.obj.get_Value()));
         }
     }
     if (element.Element("Exslot") != null)
     {
         this.Exslot = int.Parse(element.Element("Exslot").get_Value());
     }
     else
     {
         this.Exslot = -2;
     }
     if (element.Element("BattleCommand").get_Value() != string.Empty)
     {
         this.BattleCommand = new List <BattleCommand>();
         using (IEnumerator <XElement> enumerator3 = element.Element("BattleCommand").Elements().GetEnumerator())
         {
             while (enumerator3.MoveNext())
             {
                 XElement      current3      = enumerator3.get_Current();
                 BattleCommand battleCommand = (BattleCommand)((int)Enum.Parse(typeof(BattleCommand), current3.get_Value()));
                 this.BattleCommand.Add(battleCommand);
             }
         }
     }
     this.Lov = int.Parse(element.Element("Lov").get_Value());
     using (IEnumerator <XElement> enumerator4 = element.Element("Lov_back_processed").Elements().GetEnumerator())
     {
         while (enumerator4.MoveNext())
         {
             XElement current4  = enumerator4.get_Current();
             XNode    firstNode = current4.get_FirstNode();
             XNode    nextNode  = firstNode.get_NextNode();
             byte     b         = byte.Parse(((XElement)firstNode).get_Value());
             byte     b2        = byte.Parse(((XElement)nextNode).get_Value());
             this.Lov_back_processed.Add(b, b2);
         }
     }
     using (IEnumerator <XElement> enumerator5 = element.Element("Lov_back_value").Elements().GetEnumerator())
     {
         while (enumerator5.MoveNext())
         {
             XElement current5 = enumerator5.get_Current();
             int      num      = int.Parse(current5.get_Value());
             this.Lov_back_value.Add(num);
         }
     }
     using (IEnumerator <XElement> enumerator6 = element.Element("Lov_front_processed").Elements().GetEnumerator())
     {
         while (enumerator6.MoveNext())
         {
             XElement current6   = enumerator6.get_Current();
             XNode    firstNode2 = current6.get_FirstNode();
             XNode    nextNode2  = firstNode2.get_NextNode();
             byte     b3         = byte.Parse(((XElement)firstNode2).get_Value());
             byte     b4         = byte.Parse(((XElement)nextNode2).get_Value());
             this.Lov_front_processed.Add(b3, b4);
         }
     }
     using (IEnumerator <XElement> enumerator7 = element.Element("Lov_front_value").Elements().GetEnumerator())
     {
         while (enumerator7.MoveNext())
         {
             XElement current7 = enumerator7.get_Current();
             int      num2     = int.Parse(current7.get_Value());
             this.Lov_front_value.Add(num2);
         }
     }
 }