예제 #1
0
파일: main.cs 프로젝트: v1ld/IEMod.pw
        // PartyMemberAI
        public void UpdateNew()
        {
            if (this.m_mover != null && this.m_mover.AIController == null)
            {
                this.m_mover.AIController = this;
            }
            if (this.m_instructionTimer > 0f)
            {
                PartyMemberAI mInstructionTimer = this;
                mInstructionTimer.m_instructionTimer = mInstructionTimer.m_instructionTimer - Time.deltaTime;
            }
            if (this.m_instructions != null)
            {
                for (int i = 0; i < this.m_instructions.Count; i++)
                {
                    this.m_instructions[i].Update();
                }
            }
            if (GameState.s_playerCharacter != null && base.gameObject == GameState.s_playerCharacter.gameObject && PartyMemberAI.DebugParty)
            {
                UIDebug.Instance.SetText("Party Debug", PartyMemberAI.GetPartyDebugOutput(), Color.cyan);
                UIDebug.Instance.SetTextPosition("Party Debug", 0.95f, 0.95f, UIWidget.Pivot.TopRight);
            }
            if (this.m_destinationCircleState != null)
            {
                if (!base.StateManager.IsStateInStack(this.m_destinationCircleState))
                {
                    this.m_destinationCircleState = null;
                    this.HideDestination();
                }
                else
                {
                    this.ShowDestination(this.m_destinationCirclePosition);
                }
            }
            if (!(GameState.s_playerCharacter != null) || !GameState.s_playerCharacter.RotatingFormation || !this.Selected)
            {
                this.HideDestinationTarget();
            }
            else
            {
                this.ShowDestinationTarget(this.m_desiredFormationPosition);
            }
            if (this.m_revealer == null)
            {
                this.CreateFogRevealer();
            }
            else
            {
                this.m_revealer.WorldPos        = base.gameObject.transform.position;
                this.m_revealer.RequiresRefresh = false;
            }
            if (GameState.Paused)
            {
                base.CheckForNullEngagements();
                if (this.m_ai != null)
                {
                    this.m_ai.Update();
                }
                return;
            }
            if (this.m_ai == null)
            {
                return;
            }
            if (GameState.Option.AutoPause.IsEventSet(AutoPauseOptions.PauseEvent.EnemySpotted))
            {
                this.UpdateEnemySpotted();
            }
            if (this.QueuedAbility != null && this.QueuedAbility.Ready)
            {
                AIState    currentState = this.m_ai.CurrentState;
                Consumable component    = this.QueuedAbility.GetComponent <Consumable>();
                if (!(component != null) || !component.IsFoodDrugOrPotion)
                {
                    Attack         attack         = currentState as Attack;
                    TargetedAttack targetedAttack = currentState as TargetedAttack;
                    if (this.QueuedAbility.Passive || attack == null && targetedAttack == null)
                    {
                        this.QueuedAbility.Activate(currentState.Owner);
                    }
                    else if (targetedAttack == null || !this.QueuedAbility.UsePrimaryAttack && !this.QueuedAbility.UseFullAttack)
                    {
                        Ability queuedAbility = AIStateManager.StatePool.Allocate <Ability>();
                        queuedAbility.QueuedAbility = this.QueuedAbility;
                        if (attack == null)
                        {
                            base.StateManager.PushState(queuedAbility);
                        }
                        else if (!attack.CanCancel)
                        {
                            base.StateManager.QueueStateAtTop(queuedAbility);
                        }
                        else
                        {
                            attack.OnCancel();
                            base.StateManager.PopCurrentState();
                            base.StateManager.PushState(queuedAbility);
                        }
                    }
                }
                else
                {
                    ConsumePotion queuedState = this.m_ai.QueuedState as ConsumePotion;
                    if (!(currentState is ConsumePotion) && (queuedState == null || currentState.Priority < 1))
                    {
                        ConsumePotion animationVariation = AIStateManager.StatePool.Allocate <ConsumePotion>();
                        base.StateManager.PushState(animationVariation);
                        animationVariation.Ability          = this.QueuedAbility;
                        animationVariation.ConsumeAnimation = component.AnimationVariation;
                        AttackBase primaryAttack = this.GetPrimaryAttack();
                        if (!(primaryAttack is AttackMelee) || !(primaryAttack as AttackMelee).Unarmed)
                        {
                            animationVariation.HiddenObjects = primaryAttack.GetComponentsInChildren <Renderer>();
                        }
                    }
                }
                this.QueuedAbility = null;
            }
            BaseUpdate();
            if (GameState.IsLoading || GameState.s_playerCharacter == null)
            {
                return;
            }
            if (this.m_alphaControl != null && this.m_alphaControl.Alpha < 1.401298E-45f)
            {
                this.m_alphaControl.Alpha = 1f;
            }
            if (this.m_mover != null && !GameState.InCombat)
            {
                bool fastSneakActive = false;
                bool canSeeEnemy     = false;
                bool flag            = true;
                for (int i = 0; i < PartyMemberAI.PartyMembers.Length; ++i)
                {
                    var p = PartyMemberAI.PartyMembers[i];
                    if (p != null && p.m_enemySpotted)
                    {
                        canSeeEnemy = true;
                        break;
                    }
                }

                if (!canSeeEnemy)
                {
                    fastSneakActive = true;
                }

                if (Stealth.IsInStealthMode(base.gameObject) && !fastSneakActive)
                {
                    flag = false;
                }

                this.m_mover.UseCustomSpeed((flag ? 4f : 2f));
            }
        }
예제 #2
0
        // PartyMemberAI
        public void UpdateNew()
        {
            if (this.m_mover != null && this.m_mover.AIController == null)
            {
                this.m_mover.AIController = this;
            }
            if (this.m_instructionTimer > 0f)
            {
                PartyMemberAI mInstructionTimer = this;
                mInstructionTimer.m_instructionTimer = mInstructionTimer.m_instructionTimer - Time.deltaTime;
            }
            if (this.m_instructions != null)
            {
                foreach (SpellCastData mInstruction in this.m_instructions)
                {
                    mInstruction.Update();
                }
            }
            if (GameState.s_playerCharacter != null && base.gameObject == GameState.s_playerCharacter.gameObject && PartyMemberAI.DebugParty)
            {
                UIDebug.Instance.SetText("Party Debug", PartyMemberAI.GetPartyDebugOutput(), Color.cyan);
                UIDebug.Instance.SetTextPosition("Party Debug", 0.95f, 0.95f, UIWidget.Pivot.TopRight);
            }
            if (this.m_destinationCircleState != null)
            {
                if (!base.StateManager.IsStateInStack(this.m_destinationCircleState))
                {
                    this.m_destinationCircleState = null;
                    this.HideDestination();
                }
                else
                {
                    this.ShowDestination(this.m_destinationCirclePosition);
                }
            }
            if (!(GameState.s_playerCharacter != null) || !GameState.s_playerCharacter.RotatingFormation || !this.Selected)
            {
                this.HideDestinationTarget();
            }
            else
            {
                this.ShowDestinationTarget(this.m_desiredFormationPosition);
            }
            if (this.m_revealer == null)
            {
                this.CreateFogRevealer();
            }
            else
            {
                this.m_revealer.WorldPos        = base.gameObject.transform.position;
                this.m_revealer.RequiresRefresh = false;
            }
            if (GameState.Paused)
            {
                base.CheckForNullEngagements();
                if (this.m_ai != null)
                {
                    this.m_ai.Update();
                }
                base.DrawDebugText();
                return;
            }
            if (this.m_ai == null)
            {
                return;
            }
            if (GameState.Option.AutoPause.IsEventSet(AutoPauseOptions.PauseEvent.EnemySpotted) || IEModOptions.FastSneak != IEModOptions.FastSneakOptions.Normal)
            {
                this.UpdateEnemySpotted();
            }
            if (this.QueuedAbility != null && this.QueuedAbility.Ready)
            {
                AIState    currentState = this.m_ai.CurrentState;
                Consumable component    = this.QueuedAbility.GetComponent <Consumable>();
                if (!(component != null) || !component.IsIngestibleOrPotion)
                {
                    Attack         attack         = currentState as Attack;
                    TargetedAttack targetedAttack = currentState as TargetedAttack;
                    if (this.QueuedAbility.Passive || attack == null && targetedAttack == null)
                    {
                        this.QueuedAbility.Activate(currentState.Owner);
                    }
                    else if (targetedAttack == null || !this.QueuedAbility.UsePrimaryAttack && !this.QueuedAbility.UseFullAttack)
                    {
                        Ability queuedAbility = AIStateManager.StatePool.Allocate <Ability>();
                        queuedAbility.QueuedAbility = this.QueuedAbility;
                        if (attack == null)
                        {
                            base.StateManager.PushState(queuedAbility);
                        }
                        else if (!attack.CanCancel)
                        {
                            base.StateManager.QueueStateAtTop(queuedAbility);
                        }
                        else
                        {
                            attack.OnCancel();
                            base.StateManager.PopCurrentState();
                            base.StateManager.PushState(queuedAbility);
                        }
                    }
                }
                else
                {
                    ConsumePotion queuedState = this.m_ai.QueuedState as ConsumePotion;
                    if (!(currentState is ConsumePotion) && (queuedState == null || currentState.Priority < 1))
                    {
                        ConsumePotion animationVariation = AIStateManager.StatePool.Allocate <ConsumePotion>();
                        base.StateManager.PushState(animationVariation);
                        animationVariation.Ability          = this.QueuedAbility;
                        animationVariation.ConsumeAnimation = component.AnimationVariation;
                        AttackBase primaryAttack = this.GetPrimaryAttack();
                        if (!(primaryAttack is AttackMelee) || !(primaryAttack as AttackMelee).Unarmed)
                        {
                            animationVariation.HiddenObjects = primaryAttack.GetComponentsInChildren <Renderer>();
                        }
                    }
                }
                this.QueuedAbility = null;
            }
            BaseUpdate();
            if (GameState.IsLoading || GameState.s_playerCharacter == null)
            {
                return;
            }
            if (this.m_alphaControl != null && this.m_alphaControl.Alpha < 1.401298E-45f)
            {
                this.m_alphaControl.Alpha = 1f;
            }
            if (this.m_mover != null && !GameState.InCombat)
            {
                bool fastSneakActive = false;
                if (IEModOptions.FastSneak != IEModOptions.FastSneakOptions.Normal && !(mod_Player.WalkMode))
                {
                    bool canSeeEnemy = false;

                    if (IEModOptions.FastSneak == IEModOptions.FastSneakOptions.FastScoutingSingleLOS)
                    {
                        canSeeEnemy = this.m_enemySpotted;
                    }
                    else if (IEModOptions.FastSneak == IEModOptions.FastSneakOptions.FastScoutingAllLOS)
                    {
                        // if the fastSneak mod is active, then check if any enemies are spotted
                        // if so...we walk
                        for (int i = 0; i < PartyMemberAI.PartyMembers.Length; ++i)
                        {
                            var p = PartyMemberAI.PartyMembers[i];
                            if (p != null && p.m_enemySpotted)
                            {
                                canSeeEnemy = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        //Should never get here, but make default behavior to not override stealth
                        canSeeEnemy = true;
                    }

                    if (!canSeeEnemy)
                    {
                        fastSneakActive = true;
                    }
                }

                bool         flag                 = ((Stealth.IsInStealthMode(base.gameObject) && !fastSneakActive) || mod_Player.WalkMode);
                float        desiredSpeed         = (!flag ? this.m_mover.GetRunSpeed() : this.m_mover.GetWalkSpeed());
                GameObject[] selectedPartyMembers = PartyMemberAI.SelectedPartyMembers;
                for (int i = 0; i < (int)selectedPartyMembers.Length; i++)
                {
                    GameObject gameObject = selectedPartyMembers[i];
                    if (!(gameObject == null) && !(gameObject == base.gameObject) && flag == Stealth.IsInStealthMode(gameObject))
                    {
                        Mover mover = gameObject.GetComponent <Mover>();
                        if (((!Stealth.IsInStealthMode(gameObject) || fastSneakActive)  ? mover.GetRunSpeed() : mover.GetWalkSpeed()) < desiredSpeed)
                        {
                            desiredSpeed = mover.DesiredSpeed;
                        }
                    }
                }
                if (desiredSpeed < this.m_mover.GetWalkSpeed() * 0.75f)
                {
                    desiredSpeed = this.m_mover.GetWalkSpeed();
                }
                this.m_mover.UseCustomSpeed(desiredSpeed);
            }
        }
예제 #3
0
        public void mod_Update()
        {
            //METHOD SHOULD BE ASSUMED TO BE THE SAME AS THE ORIGINAL EXCEPT WHERE DOCUMENTED OTHERWISE

            string abilityString = "no ability";

            if (this.GetAbility() != null)
            {
                abilityString = this.GetAbility().Name();
            }

            bool flag;

            if (this.m_ai == null)
            {
                Debug.LogError("AI update run without OnEnter being run first!");
                return;
            }

            //CHANGE TO AVOID RECURSION
            add_BaseUpdate();
            //END CHANGE

            if (this.m_queueWeaponSetChange)
            {
                this.m_attackToUse          = null;
                this.m_weaponAttack         = null;
                this.m_targetTeam           = null;
                this.m_targetMover          = null;
                this.m_inCombat             = false;
                this.m_switchHands          = false;
                this.m_isStealthAttack      = false;
                this.m_queueWeaponSetChange = false;
                this.OnEnter();
                return;
            }
            AIController.AggressionType autoAttackAggression = this.m_ai.GetAutoAttackAggression();
            //CHANGE TO EXEMPT SELF-RADIUS HOSTILE ATTACKS FROM FIZZLING BECAUSE WE CAN'T ATTACK OURSELVES
            if (!this.CanAttackTarget() && !this.m_attackToUse.ApplyToSelfOnly && (autoAttackAggression == AIController.AggressionType.Passive || !this.m_partyMemberAI.AutoPickNearbyEnemy(this)))
            //END CHANGE
            {
                base.Manager.PopCurrentState();
                return;
            }
            if (this.m_attackToUse == null || this.m_switchHands)
            {
                this.SetupAttack();
                this.m_switchHands = false;
                if (this.m_issuedSelfCast)
                {
                    this.m_issuedSelfCast = false;
                    return;
                }
                if (this.m_ai.StateManager.CurrentState is AI.Player.Ability)
                {
                    return;
                }
            }
            this.m_ai.UpdateEngagement(base.Owner, AIController.GetPrimaryAttack(base.Owner));
            AttackFirearm mAttackToUse = this.m_attackToUse as AttackFirearm;

            if (mAttackToUse != null && mAttackToUse.BaseIsReady() && mAttackToUse.RequiresReload)
            {
                base.PushState <ReloadWeapon>().AttackToUse = mAttackToUse;
                return;
            }
            if (base.OutOfCharges(this.m_attackToUse))
            {
                base.Manager.PopCurrentState();
                return;
            }
            if (this.m_isAutoAttack && !GameState.InCombat)
            {
                base.Manager.PopCurrentState();
                return;
            }
            Vector3 mTarget = this.m_target.transform.position - this.m_owner.transform.position;
            float   single  = mTarget.magnitude;
            float   radius  = this.m_ai.Mover.Radius + this.m_targetMover.Radius;

            single = single - radius;
            if (this.m_attackToUse == null)
            {
                return;
            }
            if (single <= this.m_attackToUse.TotalAttackDistance && (!(this.m_attackToUse is AttackRanged) || base.LineOfSightToTarget(this.m_target)))
            {
                if (this.m_target != null && !this.m_attackToUse.ApplyToSelfOnly && !this.m_attackToUse.IsValidTarget(this.m_target))
                {
                    base.Manager.PopCurrentState();
                    return;
                }
                if (this.m_target == null)
                {
                    this.m_inCombat = GameState.InCombat;
                }
                else
                {
                    Faction component = this.m_target.GetComponent <Faction>();
                    if (component != null && (this.m_faction.IsHostile(component) || component.IsHostile(this.m_faction)))
                    {
                        this.m_inCombat = GameState.InCombat;
                    }
                }
                if (!this.m_attackToUse.IsReady())
                {
                    this.m_ai.FaceTarget(this.m_attackToUse);
                    return;
                }
                if (this.m_attackToUse.ApplyToSelfOnly && !this.m_isAutoAttack)
                {
                    base.Manager.PopCurrentState();
                }
                if (this.m_isStealthAttack)
                {
                    this.m_attackToUse.IsStealthAttack = this.m_isStealthAttack;
                }
                this.m_isStealthAttack = Stealth.IsInStealthMode(this.m_owner);
                AI.Achievement.Attack mEffectsOnLaunch = base.PushState <AI.Achievement.Attack>();
                mEffectsOnLaunch.Parameters.Attack             = this.m_attackToUse;
                mEffectsOnLaunch.Parameters.TargetObject       = this.m_target;
                mEffectsOnLaunch.Parameters.EffectsOnLaunch    = this.m_effectsOnLaunch;
                mEffectsOnLaunch.Parameters.WeaponAttack       = this.m_weaponAttack;
                mEffectsOnLaunch.Parameters.Ability            = this.GetAbility();
                mEffectsOnLaunch.Parameters.ShouldAttackObject = mEffectsOnLaunch.Parameters.TargetObject != null;
                this.m_switchHands = true;
                return;
            }
            if (this.m_isAutoAttack && this.m_ai.EngagedBy.Count > 0)
            {
                if (autoAttackAggression != AIController.AggressionType.Passive && this.m_partyMemberAI.AutoPickNearbyEnemy(this))
                {
                    return;
                }
                base.Manager.PopCurrentState();
                return;
            }
            if (this.m_target == null)
            {
                base.Manager.PopCurrentState();
                return;
            }
            float totalAttackDistance = this.m_attackToUse.TotalAttackDistance;

            if (totalAttackDistance > 4f)
            {
                totalAttackDistance = totalAttackDistance - 1f;
            }
            else if (totalAttackDistance > 1f)
            {
                totalAttackDistance = totalAttackDistance - 0.5f;
            }
            else if (totalAttackDistance > 0.4f)
            {
                totalAttackDistance = totalAttackDistance - 0.1f;
            }
            AI.Achievement.PathToPosition pathToPosition = base.PushState <AI.Achievement.PathToPosition>();
            pathToPosition.Parameters.Target    = this.m_target;
            pathToPosition.Parameters.StopOnLOS = true;
            pathToPosition.Parameters.Range     = totalAttackDistance;
            pathToPosition.ParentState          = this;
            if (this.m_attackToUse is AttackMelee && totalAttackDistance > 1f && totalAttackDistance < 2f)
            {
                pathToPosition.Parameters.IgnoreObstaclesWithinRange = true;
            }
            pathToPosition.Parameters.PopOnEnterIfTargetInvalid = true;
            bool        mAttackToUse1 = this.m_attackToUse is AttackRanged;
            AttackMelee attackMelee   = this.m_attackToUse as AttackMelee;

            AI.Achievement.PathToPosition.Params parameters = pathToPosition.Parameters;
            if (mAttackToUse1)
            {
                flag = false;
            }
            else
            {
                flag = (attackMelee == null ? true : attackMelee.TotalAttackDistance < 0.01f);
            }
            parameters.GetAsCloseAsPossible           = flag;
            pathToPosition.Parameters.DesiresMaxRange = mAttackToUse1;
        }