Esempio n. 1
0
 /// <summary>
 /// Condition for troop are met
 /// </summary>
 /// <param Name="page_index">troop event's page index</param>
 /// <param Name="condition">analysed condition</param>
 /// <returns>true if conditions are met</returns>
 public bool IsTroopConditionsMet(int page_index, Troop.Page.Condition condition)
 {
     // Return False if no conditions appointed
     if (!(condition.TurnValid || condition.NpcValid || condition.ActorValid || condition.SwitchValid))
     {
         return(false);
     }
     // Return False if page already completed
     if ((bool)InGame.Temp.BattleEventFlags[page_index])
     {
         return(false);
     }
     // Confirm turn conditions
     if (condition.TurnValid)
     {
         int n = InGame.Temp.BattleTurn;
         int a = condition.TurnA;
         int b = condition.TurnB;
         if ((b == 0 && n != a) || (b > 0 && (n < 1 || n < a || n % b != a % b)))
         {
             return(false);
         }
     }
     // Confirm enemy conditions
     if (condition.NpcValid)
     {
         GameNpc enemy = InGame.Troops.Npcs[condition.NpcIndex];
         if (enemy == null || enemy.Hp * 100.0 / enemy.MaxHp > condition.NpcHp)
         {
             return(false);
         }
     }
     // Confirm actor conditions
     if (condition.ActorValid)
     {
         GameActor actor = InGame.Actors[condition.ActorId - 1];
         if (actor == null || actor.Hp * 100.0 / actor.MaxHp > condition.ActorHp)
         {
             return(false);
         }
     }
     // Confirm switch conditions
     if (condition.SwitchValid)
     {
         if (InGame.Switches.Arr[condition.SwitchId])
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     // Return True
     return(true);
 }
Esempio n. 2
0
        /// <summary>Smooth Selection of a Target npc</summary>
        /// <param Name="npc_index">The relative position in the monster group of the npc to check. </param>
        /// <returns>GameNpc : seleted npc</returns>
        public GameNpc SmoothTargetNpc(int npcIndex)
        {
            GameNpc _npc = null;

            // If an npc exists
            if (Npcs[npcIndex] != null && Npcs[npcIndex].IsExist)
            {
                _npc = Npcs[npcIndex];
            }
            else
            {
                // Loop
                for (int i = 0; i < Npcs.Count; i++)
                {
                    // If an npc exists
                    if (Npcs[i].IsExist)
                    {
                        _npc = Npcs[i];
                    }
                }
            }
            return(_npc);
        }