コード例 #1
0
 private bool TryArm()
 {
     if (Weapon != null)
     {
         if (!character.Inventory.Items.Contains(Weapon) || WeaponComponent == null)
         {
             Weapon = null;
         }
         else if (!WeaponComponent.HasRequiredContainedItems(false))
         {
             // Seek ammunition only if cannot find a new weapon
             if (!Reload(true, () => GetWeapon(out _) == null))
             {
                 if (seekAmmunition != null && subObjectives.Contains(seekAmmunition))
                 {
                     return(false);
                 }
                 else
                 {
                     Weapon = null;
                 }
             }
         }
     }
     if (Weapon == null)
     {
         Weapon = GetWeapon(out _weaponComponent);
     }
     if (Weapon == null)
     {
         Weapon = GetWeapon(out _weaponComponent, ignoreRequiredItems: true);
     }
     Mode = Weapon == null ? CombatMode.Retreat : initialMode;
     return(Weapon != null);
 }
コード例 #2
0
 private bool Equip()
 {
     if (character.LockHands)
     {
         return(false);
     }
     if (!WeaponComponent.HasRequiredContainedItems(character, addMessage: false))
     {
         return(false);
     }
     if (!character.HasEquippedItem(Weapon))
     {
         Weapon.TryInteract(character, forceSelectKey: true);
         var slots = Weapon.AllowedSlots.FindAll(s => s == InvSlotType.LeftHand || s == InvSlotType.RightHand || s == (InvSlotType.LeftHand | InvSlotType.RightHand));
         if (character.Inventory.TryPutItem(Weapon, character, slots))
         {
             aimTimer = Rand.Range(0.5f, 1f);
         }
         else
         {
             Weapon = null;
             Mode   = CombatMode.Retreat;
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
        public AIObjectiveCombat(Character character, Character enemy, CombatMode mode, AIObjectiveManager objectiveManager, float priorityModifier = 1, float coolDown = 10.0f) 
            : base(character, objectiveManager, priorityModifier)
        {
            if (mode == CombatMode.None)
            {
#if DEBUG
                DebugConsole.ThrowError("Combat mode == None");
#endif
                return;
            }
            Enemy = enemy;
            coolDownTimer = coolDown;
            findSafety = objectiveManager.GetObjective<AIObjectiveFindSafety>();
            if (findSafety != null)
            {
                findSafety.Priority = 0;
                HumanAIController.UnreachableHulls.Clear();
            }
            Mode = mode;
            initialMode = Mode;
            if (Enemy == null)
            {
                Mode = CombatMode.Retreat;
            }
        }
コード例 #4
0
 private void Engage()
 {
     retreatTarget = null;
     RemoveSubObjective(ref retreatObjective);
     RemoveSubObjective(ref seekAmmunition);
     if (followTargetObjective != null && followTargetObjective.Target != Enemy)
     {
         followTargetObjective = null;
     }
     TryAddSubObjective(ref followTargetObjective,
                        constructor: () => new AIObjectiveGoTo(Enemy, character, objectiveManager, repeat: true, getDivingGearIfNeeded: true)
     {
         AllowGoingOutside  = true,
         IgnoreIfTargetDead = true
     },
                        onAbandon: () =>
     {
         Mode = CombatMode.Retreat;
         SteeringManager.Reset();
     });
     if (followTargetObjective != null && subObjectives.Contains(followTargetObjective))
     {
         followTargetObjective.CloseEnough =
             WeaponComponent is RangedWeapon ? 300 :
             WeaponComponent is MeleeWeapon mw ? mw.Range :
             WeaponComponent is RepairTool rt ? rt.Range : 50;
     }
 }
コード例 #5
0
ファイル: Main.cs プロジェクト: 2cwldys/fodev-tools
 public GlobalInviteEventArgs(Critter cr, Item car, uint encounter_descriptor, CombatMode combat_mode)
 {
     this.Cr  = cr;
     this.Car = car;
     this.EncounterDescriptor = encounter_descriptor;
     this.CombatMode          = combat_mode;
 }
コード例 #6
0
ファイル: AIObjectiveCombat.cs プロジェクト: S3ler/Barotrauma
 private bool Reload(float deltaTime)
 {
     if (WeaponComponent != null && WeaponComponent.requiredItems.ContainsKey(RelatedItem.RelationType.Contained))
     {
         var containedItems = Weapon.ContainedItems;
         foreach (RelatedItem requiredItem in WeaponComponent.requiredItems[RelatedItem.RelationType.Contained])
         {
             Item containedItem = containedItems.FirstOrDefault(it => it.Condition > 0.0f && requiredItem.MatchesItem(it));
             if (containedItem == null)
             {
                 if (reloadWeaponObjective == null)
                 {
                     reloadWeaponObjective = new AIObjectiveContainItem(character, requiredItem.Identifiers, Weapon.GetComponent <ItemContainer>());
                 }
             }
         }
     }
     if (reloadWeaponObjective != null)
     {
         if (reloadWeaponObjective.IsCompleted())
         {
             reloadWeaponObjective = null;
         }
         else if (!reloadWeaponObjective.CanBeCompleted)
         {
             Mode = CombatMode.Retreat;
         }
         else
         {
             reloadWeaponObjective.TryComplete(deltaTime);
         }
         return(false);
     }
     return(true);
 }
コード例 #7
0
ファイル: Creature.cs プロジェクト: zarlant/ACE
        /// <summary>
        /// This method sets us into peace mode.   It checks our current state to see if we have missle ammo equipped
        /// it will make the call to hid the "ammo" as we switch to peace mode.   It will then send the message switch our stance. Og II
        /// </summary>
        /// <param name="oldCombatMode"></param>
        /// <param name="isAutonomous"></param>
        public void HandleSwitchToPeaceMode(CombatMode oldCombatMode, bool isAutonomous = false)
        {
            HandleUnloadMissileAmmo(oldCombatMode);

            // FIXME: (Og II)<this is a hack for now to be removed.> Placement has an issue we have not figured out.   It has to do with animation frame. Og II
            PositionFlag &= ~UpdatePositionFlag.Placement;
            // End hack
            CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, new GameMessageUpdatePosition(this));
            UniversalMotion mm = new UniversalMotion(MotionStance.Standing);

            mm.MovementData.CurrentStyle = (uint)MotionStance.Standing;
            SetMotionState(this, mm);
            var mEquipedAmmo = EquippedObjects.FirstOrDefault(s => s.Value.CurrentWieldedLocation == EquipMask.MissileAmmo).Value;
            var player       = this as Player;

            if (mEquipedAmmo != null)
            {
                CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectGhostRange, new GameMessagePickupEvent(mEquipedAmmo));
            }
            if (player != null)
            {
                player.stance = MotionStance.Standing;
                player.Session.Network.EnqueueSend(new GameMessagePrivateUpdatePropertyInt(this, PropertyInt.CombatMode, (int)CombatMode.NonCombat));
            }
        }
コード例 #8
0
        public Ai_CombatController(AiController controller)
        {
            _controller = controller;

            combatModeMelee = true;
            combatMode      = CombatMode.Melee;
        }
コード例 #9
0
    public void EndCombat()
    {
        if (combatMode == CombatMode.Fleeing)
        {
            // End flight

            Vector2 avgPos = new Vector2();
            members.ForEach(member => avgPos += (Vector2)member.position);
            avgPos /= members.Count;

            targetPosition = avgPos;
            position       = avgPos;
            hasTarget      = false;
            movementMode   = MovementMode.Stationary;
        }
        else if (combatMode == CombatMode.Pursuing)
        {
            targetPosition = GetPosition();
            movementMode   = MovementMode.Stationary;
        }

        inCombat   = false;
        combatMode = CombatMode.None;

        fleeingFrom   = null;
        attackedSquad = null;
    }
コード例 #10
0
        public void SetCombatMode(CombatMode newCombatMode)
        {
            log.InfoFormat("Changing combat mode for {0} to {1}", Guid, newCombatMode);

            ActionChain combatModeChain = new ActionChain();

            combatModeChain.AddAction(this, () =>
            {
                CombatMode oldCombatMode = CombatMode;
                CombatMode = newCombatMode;
                switch (CombatMode)
                {
                case CombatMode.NonCombat:
                    HandleSwitchToPeaceMode(oldCombatMode);
                    break;

                case CombatMode.Melee:
                    HandleSwitchToMeleeCombatMode(oldCombatMode);
                    break;

                case CombatMode.Magic:
                    HandleSwitchToMagicCombatMode();
                    break;

                case CombatMode.Missile:
                    HandleSwitchToMissileCombatMode(combatModeChain);
                    break;

                default:
                    log.InfoFormat("Changing combat mode for {0} - something has gone wrong", Guid);
                    break;
                }
            });
            combatModeChain.EnqueueChain();
        }
コード例 #11
0
 private void Engage()
 {
     if (character.LockHands || Enemy == null)
     {
         Mode = CombatMode.Retreat;
         SteeringManager.Reset();
         return;
     }
     retreatTarget = null;
     RemoveSubObjective(ref retreatObjective);
     RemoveSubObjective(ref seekAmmunition);
     if (followTargetObjective != null && followTargetObjective.Target != Enemy)
     {
         followTargetObjective = null;
     }
     TryAddSubObjective(ref followTargetObjective,
                        constructor: () => new AIObjectiveGoTo(Enemy, character, objectiveManager, repeat: true, getDivingGearIfNeeded: true)
     {
         IgnoreIfTargetDead = true,
         DialogueIdentifier = "dialogcannotreachtarget",
         TargetName         = Enemy.DisplayName
     },
                        onAbandon: () =>
     {
         Abandon = true;
         SteeringManager.Reset();
     });
     if (followTargetObjective != null)
     {
         followTargetObjective.CloseEnough =
             WeaponComponent is RangedWeapon ? 1000 :
             WeaponComponent is MeleeWeapon mw ? mw.Range :
             WeaponComponent is RepairTool rt ? rt.Range : 50;
     }
 }
コード例 #12
0
        public EngineInitialization(CombatMode mode, PlayerProfile p1, Int32 p1palette, PlayerProfile p2, Int32 p2palette, StageProfile stage, Int32 seed)
        {
            if (mode == CombatMode.None)
            {
                throw new ArgumentOutOfRangeException("mode");
            }
            if (p1 == null)
            {
                throw new ArgumentNullException("p1");
            }
            if (p1palette < 0 || p1palette > 11)
            {
                throw new ArgumentOutOfRangeException("p1palette");
            }
            if (p2 == null)
            {
                throw new ArgumentNullException("p2");
            }
            if (p2palette < 0 || p2palette > 11)
            {
                throw new ArgumentOutOfRangeException("p2palette");
            }
            if (stage == null)
            {
                throw new ArgumentNullException("stage");
            }

            m_mode  = mode;
            m_p1    = new PlayerCreation(p1, p1.GetValidPaletteIndex(p1palette));
            m_p2    = new PlayerCreation(p2, p2.GetValidPaletteIndex(p2palette));
            m_stage = stage;
            m_seed  = seed;
        }
コード例 #13
0
        public Maybe <GameState> CompleteWord(CombatMode mode)
        {
            if (!CharBoard.HasSelectedCharCells)
            {
                return(Maybe.None <GameState>());
            }

            var word = new Word(StartsWith.Value + CharBoard.EndsWith);

            var seed = word.Value.Aggregate(0, (c, a) => (int)c + a);

            var attemptResult = CharBoard.HasWord(word)
                ? AttemptResult.Success(word.Value)
                : AttemptResult.Failure(word.Value);

            var encounter = Encounter;
            var player    = Player;

            var items = LootEscrow;
            var xp    = XPEscrow;

            if (attemptResult is AttemptResult.SuccessResult)
            {
                if (mode == CombatMode.Attack)
                {
                    encounter = Encounter.TakeMitigatedDamage(Player.AttackDamage(Random, word.Value.Length));
                }
                else if (mode == CombatMode.Defense)
                {
                    var enemyAttack = encounter.ActiveEnemy.Select(e => e.AttackDamage(Random, -word.Value.Length)).ValueOr(() => 0);
                    player = Player.TakeMitigatedDamage(enemyAttack);
                }

                items = items.Concat(CharBoard.CollectItems());
                xp   += word.Value.Length;
            }
            else
            {
                if (mode == CombatMode.Defense)
                {
                    var enemyAttack = encounter.ActiveEnemy.Select(e => e.AttackDamage(Random, word.Value.Length)).ValueOr(() => 0);
                    player = Player.TakeMitigatedDamage(enemyAttack);
                }
            }

            var nextStartsWith = Words.GetNextStartsWith(Random, attemptResult is AttemptResult.SuccessResult ? word.ToMaybe() : Maybe.None <Word>());

            return(new GameState(
                       Random,
                       Words,
                       nextStartsWith,
                       CharBoard.New(Random, Words, nextStartsWith),
                       AttemptResults.Prepend(attemptResult),
                       player,
                       encounter,
                       items,
                       xp
                       ).ToMaybe());
        }
コード例 #14
0
        public EngineInitialization(CombatMode mode, TeamMode team1mode, TeamMode team2mode,
                                    PlayerProfile team1p1, int team1p1palette, PlayerMode team1p1mode,
                                    PlayerProfile team1p2, int team1p2palette, PlayerMode team1p2mode,
                                    PlayerProfile team2p1, int team2p1palette, PlayerMode team2p1mode,
                                    PlayerProfile team2p2, int team2p2palette, PlayerMode team2p2mode,
                                    StageProfile stage, int?seed = null)
        {
            seed = seed ?? Environment.TickCount;
            if (mode == CombatMode.None)
            {
                throw new ArgumentOutOfRangeException(nameof(mode));
            }
            if (team1p1 == null)
            {
                throw new ArgumentNullException(nameof(team1p1));
            }
            if (team1p1palette < 0 || team1p1palette > 11)
            {
                throw new ArgumentOutOfRangeException(nameof(team1p1palette));
            }
            if (team1p2palette < 0 || team1p2palette > 11)
            {
                throw new ArgumentOutOfRangeException(nameof(team1p2palette));
            }
            if (team2p1 == null)
            {
                throw new ArgumentNullException(nameof(team2p1));
            }
            if (team2p1palette < 0 || team2p1palette > 11)
            {
                throw new ArgumentOutOfRangeException(nameof(team2p1palette));
            }
            if (team2p2palette < 0 || team2p2palette > 11)
            {
                throw new ArgumentOutOfRangeException(nameof(team2p2palette));
            }
            if (stage == null)
            {
                throw new ArgumentNullException(nameof(stage));
            }

            m_mode    = mode;
            Team1Mode = team1mode;
            Team2Mode = team2mode;
            m_team1p1 = new PlayerCreation(team1p1, team1p1.GetValidPaletteIndex(team1p1palette), team1p1mode);
            if (team1p2 != null)
            {
                m_team1p2 = new PlayerCreation(team1p2, team1p2.GetValidPaletteIndex(team1p2palette), team1p2mode);
            }
            m_team2p1 = new PlayerCreation(team2p1, team2p1.GetValidPaletteIndex(team2p1palette), team2p1mode);
            if (team2p2 != null)
            {
                m_team2p2 = new PlayerCreation(team2p2, team2p2.GetValidPaletteIndex(team2p2palette), team2p2mode);
            }
            m_stage = stage;
            m_seed  = seed.Value;
        }
コード例 #15
0
        public static void SetCombatMode(CombatMode combatMode)
        {
            var result = Me.SendToAll("COMBATMODE", combatMode.ToString());

            foreach (var pluginCommunicationResponse in result)
            {
                Log.Debug("[AutoFollow][" + pluginCommunicationResponse.Plugin.Name + "] Response: " + pluginCommunicationResponse.Result);
            }
        }
コード例 #16
0
 public EngineInitialization(CombatMode mode,
                             PlayerProfile team1p1, int team1p1palette, PlayerMode team1p1mode,
                             PlayerProfile team2p1, int team2p1palette, PlayerMode team2p1mode,
                             StageProfile stage) :
     this(mode, TeamMode.None, TeamMode.None,
          team1p1, team1p1palette, team1p1mode, null, 0, PlayerMode.Human,
          team2p1, team2p1palette, team2p1mode, null, 0, PlayerMode.Human,
          stage)
 {
 }
コード例 #17
0
ファイル: AIObjectiveCombat.cs プロジェクト: S3ler/Barotrauma
 public AIObjectiveCombat(Character character, Character enemy, CombatMode mode) : base(character, "")
 {
     Enemy         = enemy;
     coolDownTimer = CoolDown;
     HumanAIController.ObjectiveManager.GetObjective <AIObjectiveFindSafety>().Priority = 0;
     Mode = mode;
     if (Enemy == null)
     {
         Mode = CombatMode.Retreat;
     }
 }
コード例 #18
0
ファイル: Creature_Combat.cs プロジェクト: justonia/ACE
        /// <summary>
        /// Switches a player or creature to a new combat stance
        /// </summary>
        public float SetCombatMode(CombatMode combatMode, out float queueTime)
        {
            // check if combat stance actually needs switching
            var combatStance = GetCombatStance();

            //Console.WriteLine($"{Name}.SetCombatMode({combatMode}), CombatStance: {combatStance}");

            if (combatMode != CombatMode.NonCombat && CurrentMotionState.Stance == combatStance)
            {
                queueTime = 0.0f;
                return(0.0f);
            }

            if (CombatMode == CombatMode.Missile)
            {
                HideAmmo();
            }

            CombatMode = combatMode;

            var animLength = 0.0f;

            switch (CombatMode)
            {
            case CombatMode.NonCombat:
                animLength = HandleSwitchToPeaceMode();
                break;

            case CombatMode.Melee:
                animLength = HandleSwitchToMeleeCombatMode();
                break;

            case CombatMode.Magic:
                animLength = HandleSwitchToMagicCombatMode();
                break;

            case CombatMode.Missile:
                animLength = HandleSwitchToMissileCombatMode();
                break;

            default:
                log.InfoFormat($"Unknown combat mode {CombatMode} for {Name}");
                break;
            }

            queueTime = HandleStanceQueue(animLength);

            //Console.WriteLine($"SetCombatMode(): queueTime({queueTime}) + animLength({animLength})");
            return(queueTime + animLength);
        }
コード例 #19
0
        public void HandleSwitchToPeaceMode(CombatMode oldCombatMode, bool isAutonomous = false)
        {
            HandleUnloadMissileAmmo(oldCombatMode);

            // FIXME: (Og II)<this is a hack for now to be removed.> Placement has an issue we have not figured out.   It has to do with animation frame. Og II
            PositionFlag &= ~UpdatePositionFlag.Placement;
            // End hack
            CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, new GameMessageUpdatePosition(this));
            UniversalMotion mm = new UniversalMotion(MotionStance.Standing);

            mm.MovementData.CurrentStyle = (ushort)MotionStance.Standing;
            SetMotionState(this, mm);
            CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, new GameMessagePrivateUpdatePropertyInt(Sequences, PropertyInt.CombatMode, (uint)CombatMode.NonCombat));
        }
コード例 #20
0
        /// <summary>
        /// Toggle the mode which the Ai will combat in, Melee (fists or weapon) or Ranged (if has one equipped)
        /// </summary>
        public void ToggleCombatMode()
        {
            if (!_controller.equipment.IsEquipped(EquipmentSlot.EquipmentType.RangedWep))
            {
                Debug.Log("No Ranged Weapon Equipped!");
                return;
            }

            combatModeMelee = !combatModeMelee;

            combatMode = combatModeMelee ? CombatMode.Melee: CombatMode.Ranged;

            EventRelay.OnCombatModeToggled(_controller);
        }
コード例 #21
0
        // constructor
        public UserPlayer(CombatMode mode) : base(mode, Def.MAIN_CHARACTER_ID)
        {
            _name = Manager.Instance.Object.MainCharacter.Name;

            CombatPlayer p = Manager.Instance.DT.CombatPlayer[Id];
            _criticalProbability = p.criticalProbability;

            Nurture.Character c = Manager.Instance.Object.NurtureMode.Character;
            _hp = c.Stamina;
            _mp = c.Intellect;
            _attack = c.Attack;
            _defense = c.Defense;
            _intellect = c.Intellect;
            _tactic = c.Tactic;
        }
コード例 #22
0
		public EngineInitialization(CombatMode mode, PlayerProfile p1, Int32 p1palette, PlayerProfile p2, Int32 p2palette, StageProfile stage, Int32 seed)
		{
			if (mode == CombatMode.None) throw new ArgumentOutOfRangeException("mode");
			if (p1 == null) throw new ArgumentNullException("p1");
			if (p1palette < 0 || p1palette > 11) throw new ArgumentOutOfRangeException("p1palette");
			if (p2 == null) throw new ArgumentNullException("p2");
			if (p2palette < 0 || p2palette > 11) throw new ArgumentOutOfRangeException("p2palette");
			if (stage == null) throw new ArgumentNullException("stage");

			m_mode = mode;
			m_p1 = new PlayerCreation(p1, p1.GetValidPaletteIndex(p1palette));
			m_p2 = new PlayerCreation(p2, p2.GetValidPaletteIndex(p2palette));
			m_stage = stage;
			m_seed = seed;
		}
コード例 #23
0
 /// <summary>
 /// Seeks for more ammunition. Creates a new subobjective.
 /// </summary>
 private void SeekAmmunition(string[] ammunitionIdentifiers)
 {
     retreatTarget = null;
     RemoveSubObjective(ref retreatObjective);
     RemoveSubObjective(ref followTargetObjective);
     TryAddSubObjective(ref seekAmmunition,
                        constructor: () => new AIObjectiveContainItem(character, ammunitionIdentifiers, Weapon.GetComponent <ItemContainer>(), objectiveManager)
     {
         targetItemCount = Weapon.GetComponent <ItemContainer>().Capacity,
         checkInventory  = false
     },
                        onAbandon: () =>
     {
         Weapon = null;
         Mode   = CombatMode.Retreat;
         SteeringManager.Reset();
     });
 }
コード例 #24
0
ファイル: WorldObject.cs プロジェクト: leclaist/ACE
        public void SetCombatMode(CombatMode newCombatMode)
        {
            log.InfoFormat("Changing combat mode for {0} to {1}", this.Guid, newCombatMode);
            // TODO: any sort of validation
            CombatMode = newCombatMode;
            switch (CombatMode)
            {
            case CombatMode.Peace:
                SetMotionState(new UniversalMotion(MotionStance.Standing));
                break;

            case CombatMode.Melee:
                var gm = new UniversalMotion(MotionStance.UANoShieldAttack);
                gm.MovementData.CurrentStyle = (ushort)MotionStance.UANoShieldAttack;
                SetMotionState(gm);
                break;
            }
        }
コード例 #25
0
 public AIObjectiveCombat(Character character, Character enemy, CombatMode mode, AIObjectiveManager objectiveManager, float priorityModifier = 1)
     : base(character, objectiveManager, priorityModifier)
 {
     Enemy         = enemy;
     coolDownTimer = coolDown;
     findSafety    = objectiveManager.GetObjective <AIObjectiveFindSafety>();
     if (findSafety != null)
     {
         findSafety.Priority = 0;
         HumanAIController.UnreachableHulls.Clear();
     }
     Mode        = mode;
     initialMode = Mode;
     if (Enemy == null)
     {
         Mode = CombatMode.Retreat;
     }
 }
コード例 #26
0
ファイル: AIObjectiveCombat.cs プロジェクト: S3ler/Barotrauma
        protected override void Act(float deltaTime)
        {
            coolDownTimer -= deltaTime;
            if (abandon)
            {
                return;
            }
            switch (Mode)
            {
            case CombatMode.Defensive:
                if (Weapon != null && character.Inventory.Items.Contains(_weapon))
                {
                    Weapon = null;
                }
                if (Weapon == null)
                {
                    Weapon = GetWeapon();
                }
                if (Weapon == null)
                {
                    Mode = CombatMode.Retreat;
                }
                else if (Equip(deltaTime))
                {
                    if (Reload(deltaTime))
                    {
                        Attack(deltaTime);
                    }
                }
                // When defensive, try to retreat to safety. TODO: in offsensive mode, engage the target
                Retreat(deltaTime);
                break;

            case CombatMode.Retreat:
                Retreat(deltaTime);
                break;

            case CombatMode.Offensive:
            default:
                throw new System.NotImplementedException();
            }
        }
コード例 #27
0
ファイル: Creature.cs プロジェクト: zarlant/ACE
        /// <summary>
        /// This method is called if we unwield missle ammo.   It will check to see if I have arrows wielded
        /// send the message to "hide" the arrow.
        /// </summary>
        /// <param name="oldCombatMode"></param>
        public void HandleUnloadMissileAmmo(CombatMode oldCombatMode)
        {
            // Before I can switch to any non missile mode, do I have missile ammo I need to remove?
            WorldObject ammo         = null;
            HeldItem    mEquipedAmmo = Children.Find(s => s.EquipMask == EquipMask.MissileAmmo);

            if (mEquipedAmmo != null)
            {
                ammo = GetInventoryItem(new ObjectGuid(mEquipedAmmo.Guid));
            }

            if (oldCombatMode == CombatMode.Missile)
            {
                if (ammo != null)
                {
                    ammo.Location = null;
                    CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, new GameMessagePickupEvent(ammo));
                }
            }
        }
コード例 #28
0
        private void TryMove(Direction dir)
        {
            var targetCell = Cell.GetNeighbour(dir);
            var canPass    = targetCell?.OnCollision(this) ?? false;
            var isActor    = targetCell?.IsActor(this) ?? false;

            if (canPass && !isActor)
            {
                AssignCell(targetCell);
            }

            else if (canPass && isActor)
            {
                if (targetCell.Actor is ItemActor || targetCell.Actor is Treasure)
                {
                    PickUpItem(targetCell);
                    AssignCell(targetCell);
                }
                else if (targetCell.Actor is Door)
                {
                    var colorDoor = targetCell.Actor as Door;
                    if (colorDoor.IsKeyMatch(this, colorDoor.GetDoorType()))
                    {
                        //targetCell.Actor.Cell = null;
                        targetCell.Actor.Destroy();
                        targetCell.Actor = null;
                        targetCell.Type  = TileType.Floor;
                        AssignCell(targetCell);
                    }
                }

                else
                {
                    var enemy      = targetCell.Actor;
                    var CombatMode = new CombatMode(this, enemy);
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// Switches a player or creature to a new combat stance
        /// </summary>
        public float SetCombatMode(CombatMode combatMode)
        {
            //Console.WriteLine($"Changing combat mode for {Name} to {combatMode}");

            if (CombatMode == CombatMode.Missile)
            {
                HideAmmo();
            }

            CombatMode = combatMode;

            var animLength = 0.0f;

            switch (CombatMode)
            {
            case CombatMode.NonCombat:
                animLength = HandleSwitchToPeaceMode();
                break;

            case CombatMode.Melee:
                animLength = HandleSwitchToMeleeCombatMode();
                break;

            case CombatMode.Magic:
                animLength = HandleSwitchToMagicCombatMode();
                break;

            case CombatMode.Missile:
                animLength = HandleSwitchToMissileCombatMode();
                break;

            default:
                log.InfoFormat($"Unknown combat mode {CombatMode} for {Name}");
                break;
            }
            return(animLength);
        }
コード例 #30
0
        private void UpdateCombatModeValue()
        {
            if (config.GetValue <int>("DefaultCombatMode", out int value))
            {
                combatMode = (CombatMode)value;
                radioButtonCombatBoth.Checked      = combatMode == CombatMode.BOTH;
                radioButtonCombatRealTime.Checked  = combatMode == CombatMode.REAL_TIME;
                radioButtonCombatTurnBased.Checked = combatMode == CombatMode.TURN_BASED;
            }
            else if (radioButtonCombatBoth.Checked)
            {
                combatMode = CombatMode.BOTH;
            }
            else if (radioButtonCombatRealTime.Checked)
            {
                combatMode = CombatMode.REAL_TIME;
            }
            else
            {
                combatMode = CombatMode.TURN_BASED;
            }

            SetValue("DefaultCombatMode", (int)combatMode);
        }
コード例 #31
0
ファイル: Main.cs プロジェクト: wladimiiir/vault112
 public GlobalInviteEventArgs(Critter cr, Item car, uint encounter_descriptor, CombatMode combat_mode)
 {
     this.Cr = cr;
     this.Car = car;
     this.EncounterDescriptor = encounter_descriptor;
     this.CombatMode = combat_mode;
 }
コード例 #32
0
		public EngineInitialization(CombatMode mode, PlayerProfile p1, Int32 p1palette, PlayerProfile p2, Int32 p2palette, StageProfile stage):
			this(mode, p1, p1palette, p2, p2palette, stage, Environment.TickCount)
		{
		}
コード例 #33
0
ファイル: Creature.cs プロジェクト: zarlant/ACE
        public void HandleSwitchToMeleeCombatMode(CombatMode olCombatMode)
        {
            // TODO and FIXME: GetInventoryItem doesn't work for this so this function is effectively broke
            bool shieldEquiped      = false;
            bool weaponInShieldSlot = false;

            // Check to see if we were in missile combat and have an arrow hanging around we might need to remove.
            HandleUnloadMissileAmmo(olCombatMode);

            HeldItem mEquipedShieldSlot = Children.Find(s => s.EquipMask == EquipMask.Shield);

            if (mEquipedShieldSlot != null)
            {
                //WorldObject itemInShieldSlot = GetInventoryItem(new ObjectGuid(mEquipedShieldSlot.Guid));
                var itemInShieldSlot = GetEquippedShield();
                if (itemInShieldSlot != null)
                {
                    if (itemInShieldSlot.ItemType == ItemType.Armor)
                    {
                        shieldEquiped = true;
                    }
                    else
                    {
                        weaponInShieldSlot = true;
                    }
                }
            }

            HeldItem     mEquipedMelee     = Children.Find(s => s.EquipMask == EquipMask.MeleeWeapon);
            HeldItem     mEquipedTwoHanded = Children.Find(s => s.EquipMask == EquipMask.TwoHanded);
            MotionStance ms = MotionStance.Invalid;
            CombatStyle  cs = CombatStyle.Undef;

            // are we unarmed?   If so, do we have a shield?
            if (mEquipedMelee == null && mEquipedTwoHanded == null && !weaponInShieldSlot)
            {
                if (!shieldEquiped)
                {
                    ms = MotionStance.UaNoShieldAttack;
                }
                else
                {
                    ms = MotionStance.MeleeShieldAttack;
                }
            }
            else if (weaponInShieldSlot)
            {
                ms = MotionStance.DualWieldAttack;
            }

            if (mEquipedTwoHanded != null)
            {
                WorldObject twoHandedWeapon = GetInventoryItem(new ObjectGuid(mEquipedTwoHanded.Guid));
                if (twoHandedWeapon.DefaultCombatStyle != null)
                {
                    cs = twoHandedWeapon.DefaultCombatStyle.Value;
                    // ms = MotionStance.TwoHandedSwordAttack;
                    // ms = MotionStance.TwoHandedStaffAttack; ?
                    switch (cs)
                    {
                    // case CombatStyle.???
                    // ms = MotionStance.TwoHandedStaffAttack;
                    // break;
                    default:
                        ms = MotionStance.TwoHandedSwordAttack;
                        break;
                    }
                }
            }

            // Let's see if we are melee single handed / two handed with our without shield as appropriate.
            if (mEquipedMelee?.Guid != null && ms != MotionStance.DualWieldAttack)
            {
                //WorldObject meleeWeapon = GetInventoryItem(new ObjectGuid(mEquipedMelee.Guid));
                WorldObject meleeWeapon = GetEquippedWeapon();

                if (meleeWeapon == null)
                {
                    log.InfoFormat("Changing combat mode for {0} - could not locate wielded weapon {1}", Guid, mEquipedMelee.Guid);
                    return;
                }

                if (!shieldEquiped)
                {
                    if (meleeWeapon.DefaultCombatStyle != null)
                    {
                        cs = meleeWeapon.DefaultCombatStyle.Value;
                        switch (cs)
                        {
                        case CombatStyle.Atlatl:
                            ms = MotionStance.AtlatlCombat;
                            break;

                        case CombatStyle.Sling:
                            ms = MotionStance.SlingAttack;
                            break;

                        case CombatStyle.ThrownWeapon:
                            ms = MotionStance.ThrownWeaponAttack;
                            break;

                        default:
                            ms = MotionStance.MeleeNoShieldAttack;
                            break;
                        }
                    }
                }
                else
                {
                    switch (meleeWeapon.DefaultCombatStyle)
                    {
                    case CombatStyle.Unarmed:
                    case CombatStyle.OneHanded:
                    case CombatStyle.OneHandedAndShield:
                    case CombatStyle.TwoHanded:
                    case CombatStyle.DualWield:
                    case CombatStyle.Melee:
                        ms = MotionStance.MeleeShieldAttack;
                        break;

                    case CombatStyle.ThrownWeapon:
                        ms = MotionStance.ThrownShieldCombat;
                        break;

                    ////case CombatStyle.Unarmed:
                    ////    ms = MotionStance.MeleeShieldAttack;
                    ////    break;
                    default:
                        log.InfoFormat(
                            "Changing combat mode for {0} - unable to determine correct combat stance for weapon {1}", Guid, mEquipedMelee.Guid);
                        return;
                    }
                }
            }
            if (ms != MotionStance.Invalid)
            {
                UniversalMotion mm = new UniversalMotion(ms);
                mm.MovementData.CurrentStyle = (ushort)ms;
                SetMotionState(this, mm);

                var player = this as Player;
                if (player != null)
                {
                    player.Session.Network.EnqueueSend(new GameMessagePrivateUpdatePropertyInt(this, PropertyInt.CombatMode, (int)CombatMode.Melee));
                }
            }
            else
            {
                log.InfoFormat("Changing combat mode for {0} - wielded item {1} has not be assigned a default combat style", Guid, mEquipedMelee?.Guid ?? mEquipedTwoHanded?.Guid);
            }
        }
コード例 #34
0
    public void SwitchMode(CombatMode mode)
    {
        switch (mode)
        {
            case CombatMode.Passive:
                break;

            case CombatMode.Aggressive:
                break;

            case CombatMode.Defensive:
                m_FollowEnemy = true;
                m_FireAtEnemy = true;
                break;

        }
    }