Пример #1
0
        ////// Private Methods //////

        void InflictFreezeOrStun(int count, SetStateOnHurt ssoh, DamageReport report, bool isStun)
        {
            if (!report.victim.isInFrozenState)
            {
                if (isStun)
                {
                    if (ssoh.canBeStunned)
                    {
                        ssoh.SetStun(1f);
                    }
                }
                else
                {
                    if (ssoh.canBeFrozen)
                    {
                        ssoh.SetFrozen(2f * report.damageInfo.procCoefficient);
                    }
                }
            }
            report.victim.TakeDamage(new DamageInfo {
                attacker         = report.attacker,
                crit             = report.damageInfo.crit,
                damage           = ((float)(count - 1) * procStackDamage + procBaseDamage) * report.attackerBody.damage,
                damageColorIndex = DamageColorIndex.Item,
                damageType       = DamageType.Generic,
                force            = Vector3.zero,
                inflictor        = report.damageInfo.inflictor,
                position         = report.damageInfo.position,
                procChainMask    = report.damageInfo.procChainMask,
                procCoefficient  = 0f
            });
        }
Пример #2
0
        // Token: 0x06002B71 RID: 11121 RVA: 0x000B73F4 File Offset: 0x000B55F4
        protected override void AddDebuff(CharacterBody body)
        {
            SetStateOnHurt component = body.healthComponent.GetComponent <SetStateOnHurt>();

            if (component != null)
            {
                component.SetStun(-1f);
            }
            if (FirePlantSonicBoom.hitEffectPrefab)
            {
                EffectManager.SpawnEffect(FirePlantSonicBoom.hitEffectPrefab, new EffectData
                {
                    origin = body.corePosition
                }, true);
            }
            if (base.healthComponent)
            {
                HealOrb healOrb = new HealOrb();
                healOrb.origin           = body.corePosition;
                healOrb.target           = base.healthComponent.body.mainHurtBox;
                healOrb.healValue        = FirePlantSonicBoom.healthFractionPerHit * base.healthComponent.fullHealth;
                healOrb.overrideDuration = UnityEngine.Random.Range(0.3f, 0.6f);
                OrbManager.instance.AddOrb(healOrb);
            }
            Util.PlaySound(FirePlantSonicBoom.impactSoundString, base.gameObject);
        }
Пример #3
0
        public void Awake()
        {
            this.body = base.GetComponent <CharacterBody>();
            var model          = base.GetComponent <ModelLocator>();
            var modelTransform = model.modelTransform;

            this.childLocator         = modelTransform.GetComponent <ChildLocator>();
            this.rightDrillBone       = childLocator.FindChild("RightHandDrill");
            this.leftDrillBone        = childLocator.FindChild("LeftHandDrill");
            this.drillRushHitboxPivot = childLocator.FindChild("DrillRushHitboxPivot");
            this.animator             = modelTransform.GetComponent <Animator>();
            this.setStateOnHurt       = base.GetComponent <SetStateOnHurt>();
            this.skillLocator         = base.GetComponent <SkillLocator>();

            if (this.setStateOnHurt)
            {
                this.defaultCanBeFrozen     = setStateOnHurt.canBeFrozen;
                this.defaultCanBeStunned    = setStateOnHurt.canBeStunned;
                this.defaultCanBeHitStunned = setStateOnHurt.canBeHitStunned;
            }
            if (this.skillLocator)
            {
                this.yokoSkill = this.skillLocator.secondary;
            }
            On.RoR2.CharacterBody.RecalculateStats               += CharacterBody_RecalculateStats;
            On.RoR2.CharacterBody.AddBuff_BuffDef                += CharacterBody_AddBuff_BuffDef;
            On.RoR2.CharacterBody.AddTimedBuff_BuffDef_float     += CharacterBody_AddTimedBuff_BuffDef_float;
            On.RoR2.CharacterBody.AddTimedBuff_BuffDef_float_int += CharacterBody_AddTimedBuff_BuffDef_float_int;
        }
 private void Start()
 {
     this.characterBody  = base.GetComponent <CharacterBody>();
     this.teamComponent  = base.GetComponent <TeamComponent>();
     this.setStateOnHurt = base.GetComponent <SetStateOnHurt>();
     this.modelTransform = base.GetComponent <Transform>();
     this.overclockOn    = false;
 }
Пример #5
0
        private void SetupStateMachines()
        {
            SetStateOnHurt stateOnHurt = this.artiBody.GetComponent <SetStateOnHurt>();

            EntityStateMachine[] idles = stateOnHurt.idleStateMachine;
            Array.Resize <EntityStateMachine>(ref idles, 1);
            stateOnHurt.idleStateMachine = idles;
        }
Пример #6
0
 private void SetStateOnHurt_Start(On.RoR2.SetStateOnHurt.orig_Start orig, SetStateOnHurt self)
 {
     orig(self);
     if (RunArtifactManager.instance.IsArtifactEnabled(Firmness))
     {
         self.canBeHitStunned = false;
     }
 }
Пример #7
0
        public override void Effect(GlobalEventManager globalEventManager, DamageInfo damageInfo, GameObject victim, int itemCount)
        {
            SetStateOnHurt HurtStat = victim.GetComponent <SetStateOnHurt>();

            if (HurtStat)
            {
                HurtStat.SetStun(2f);
            }
        }
Пример #8
0
        private void RW_DoStateMachines()
        {
            NetworkStateMachine    net   = this.RW_body.GetComponent <NetworkStateMachine>();
            CharacterDeathBehavior death = this.RW_body.GetComponent <CharacterDeathBehavior>();

            death.idleStateMachine = new EntityStateMachine[2];
            death.deathState       = new SerializableEntityStateType(typeof(EntityStates.Commando.DeathState));



            EntityStateMachine[] netStates = net.stateMachines;// this.stateMachines.Get( net );

            Array.Resize <EntityStateMachine>(ref netStates, 3);

            SetStateOnHurt hurtState = this.RW_body.GetComponent <SetStateOnHurt>();

            hurtState.canBeFrozen     = true;
            hurtState.canBeHitStunned = false;
            hurtState.canBeStunned    = true;
            hurtState.hitThreshold    = 5f;
            hurtState.hurtState       = new SerializableEntityStateType(typeof(EntityStates.FrozenState));

            foreach (EntityStateMachine esm in this.RW_body.GetComponents <EntityStateMachine>())
            {
                switch (esm.customName)
                {
                case "Body":
                    esm.initialStateType         = new SerializableEntityStateType(typeof(SpawnTeleporterState));
                    esm.mainStateType            = new SerializableEntityStateType(typeof(GenericCharacterMain));
                    netStates[0]                 = esm;
                    hurtState.targetStateMachine = esm;
                    death.deathStateMachine      = esm;
                    break;

                case "Weapon":
                    esm.initialStateType      = new SerializableEntityStateType(typeof(Idle));
                    esm.mainStateType         = new SerializableEntityStateType(typeof(Idle));
                    netStates[1]              = esm;
                    death.idleStateMachine[0] = esm;
                    break;

                case "Gaze":
                    esm.initialStateType      = new SerializableEntityStateType(typeof(Idle));
                    esm.mainStateType         = new SerializableEntityStateType(typeof(Idle));
                    netStates[2]              = esm;
                    death.idleStateMachine[1] = esm;
                    break;

                default:
                    break;
                }
            }

            net.stateMachines = netStates;
            //this.stateMachines.Set( net, netStates );
        }
Пример #9
0
 public static bool CheckIfEntityIsStunned(SetStateOnHurt s)
 {
     if (s != null)
     {
         if (s.targetStateMachine.GetType() == typeof(StunState))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #10
0
        // Token: 0x06002B6A RID: 11114 RVA: 0x000B72F0 File Offset: 0x000B54F0
        protected virtual void AddDebuff(CharacterBody body)
        {
            body.AddTimedBuff(BuffIndex.Weak, this.slowDuration);
            SetStateOnHurt component = body.healthComponent.GetComponent <SetStateOnHurt>();

            if (component == null)
            {
                return;
            }
            component.SetStun(-1f);
        }
Пример #11
0
            private static void SetStateOnHurt_SetFrozen(On.RoR2.SetStateOnHurt.orig_SetFrozen orig,
                                                         SetStateOnHurt self, float duration)
            {
                float newduration = duration;
                var   component   = self.GetComponentInChildren <DebuffStatComponent>();

                if (component)
                {
                    newduration *= component.Reduction;
                }
                orig(self, newduration);
            }
Пример #12
0
        private void OnHitEnemy_On(HooksCore.RoR2.GlobalEventManager.OnHitEnemy.Orig orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
        {
            orig(self, damageInfo, victim);
            if (damageInfo.procCoefficient <= 0f || damageInfo.rejected || !NetworkServer.active || !damageInfo.attacker)
            {
                return;
            }
            CharacterBody body = damageInfo.attacker.GetComponent <CharacterBody>();

            if (!body)
            {
                return;
            }
            Inventory inventory = body.inventory;

            if (!inventory)
            {
                return;
            }
            Int32 stunCount = inventory.GetItemCount(ItemIndex.StunChanceOnHit);

            if (stunCount <= 0)
            {
                return;
            }
            Single sqCoef = Mathf.Sqrt(damageInfo.procCoefficient);

            if (!RoR2.Util.CheckRoll(RoR2.Util.ConvertAmplificationPercentageIntoReductionPercentage(sqCoef * 5f * stunCount), body.master))
            {
                return;
            }
            SetStateOnHurt stateOnHurt = victim.GetComponent <SetStateOnHurt>();

            if (!stateOnHurt)
            {
                return;
            }
            stateOnHurt.SetStun(sqCoef * 2f);
        }
Пример #13
0
 public void SetGigaDrillBreakerTarget(CharacterBody bossBody)
 {
     if (currentGigaDrillBreakerTarget != bossBody)
     {
         if (currentGigaDrillBreakerTarget)
         {
             DetachShadesBinding();
         }
         currentGigaDrillBreakerTarget = bossBody;
         if (currentGigaDrillBreakerTarget)
         {
             AttachShadesBinding(0);
         }
     }
     else if (currentGigaDrillBreakerTarget)
     {
         AttachShadesBinding(1);
     }
     if (bossBody)
     {
         SetStateOnHurt.SetStunOnObject(bossBody.gameObject, 10f);
     }
 }
Пример #14
0
 //F**K HOPOO - fixes ice explosion killing people
 IEnumerator FixIce()
 {
     while (true)
     {
         GameObject bandit = BodyCatalog.FindBodyPrefab("BanditBody");
         if (bandit != null)
         {
             SetStateOnHurt setStateOnHurt = bandit.GetComponent <SetStateOnHurt>();
             if (setStateOnHurt != null)
             {
                 var ildeStateMachine = setStateOnHurt.idleStateMachine;
                 if (ildeStateMachine != null)
                 {
                     if (ildeStateMachine.Length != 0)
                     {
                         ildeStateMachine[0] = ildeStateMachine[1];
                         yield return(null);
                     }
                 }
             }
         }
         yield return(new WaitForFixedUpdate());
     }
 }
Пример #15
0
        internal static void CreatePrefab()
        {
            SniperMain.sniperBodyPrefab     = PrefabsCore.CreatePrefab("Sniper", true);
            SniperMain.sniperBodyPrefab.tag = "Finish";
            GameObject obj = SniperMain.sniperBodyPrefab;

            NetworkIdentity netId = obj.AddOrGetComponent <NetworkIdentity>();

            netId.localPlayerAuthority = true;


            var modelBase = new GameObject("ModelBase");

            modelBase.transform.parent        = obj.transform;
            modelBase.transform.localPosition = new Vector3(0f, -0.81f, 0f);
            modelBase.transform.localRotation = Quaternion.identity;
            modelBase.transform.localScale    = new Vector3(1f, 1f, 1f);

            var cameraPivot = new GameObject("CameraPivot");

            cameraPivot.transform.parent        = modelBase.transform;
            cameraPivot.transform.localPosition = new Vector3(0f, 1.6f, 0f);
            cameraPivot.transform.localRotation = Quaternion.identity;
            cameraPivot.transform.localScale    = Vector3.one;

            var aimOrigin = new GameObject("AimOrigin");

            aimOrigin.transform.parent        = modelBase.transform;
            aimOrigin.transform.localPosition = new Vector3(0f, 1.4f, 0f);
            aimOrigin.transform.localRotation = Quaternion.identity;
            aimOrigin.transform.localScale    = Vector3.one;

            GameObject model          = ModelModule.GetModel();
            Transform  modelTransform = model.transform;

            modelTransform.parent        = modelBase.transform;
            modelTransform.localPosition = Vector3.zero;
            modelTransform.localScale    = Vector3.one;
            modelTransform.localRotation = Quaternion.identity;



            CharacterDirection direction = obj.AddOrGetComponent <CharacterDirection>();

            direction.moveVector      = Vector3.zero;
            direction.targetTransform = modelBase.transform;
            direction.overrideAnimatorForwardTransform = null;
            direction.rootMotionAccumulator            = null;
            direction.modelAnimator         = null;
            direction.driveFromRootRotation = false;
            direction.turnSpeed             = 720f;

            //CharacterBody borkBorkBody = null;
            //if(borkBorkBody is null) return;


            //borkBorkBody.baseMaxHealth = 150f;
            //borkBorkBody.baseMoveSpeed = 9f;
            //borkBorkBody.baseJumpPower = 20f;
            //borkBorkBody.baseDamage = 12f;



            SniperCharacterBody body = obj.AddOrGetComponent <SniperCharacterBody>();

            body.bodyIndex             = (BodyIndex)(-1);
            body.baseNameToken         = Tokens.SNIPER_NAME;
            body.subtitleNameToken     = Tokens.SNIPER_SUBTITLE;
            body.bodyFlags             = CharacterBody.BodyFlags.ImmuneToExecutes;
            body.rootMotionInMainState = false;
            body.mainRootSpeed         = 0f;

            body.baseMaxHealth  = 130f;
            body.levelMaxHealth = 39f;

            body.baseRegen  = 2f;
            body.levelRegen = 0.4f;

            body.baseMaxShield  = 0f;
            body.levelMaxShield = 0f;

            body.baseMoveSpeed  = 7f;
            body.levelMoveSpeed = 0f;

            body.baseAcceleration = 60f;

            body.baseJumpPower  = 15f;
            body.levelJumpPower = 0f;

            body.baseDamage  = 12f;
            body.levelDamage = 3.6f;

            body.baseAttackSpeed  = 1f;
            body.levelAttackSpeed = 0f;

            body.baseCrit  = 1f;
            body.levelCrit = 0f;

            body.baseArmor  = 0f;
            body.levelArmor = 0f;

            body.baseJumpCount = 1;

            body.sprintingSpeedMultiplier = 1.45f;

            body.wasLucky                  = false;
            body.spreadBloomDecayTime      = 1f;
            body.spreadBloomCurve          = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
            body.crosshairPrefab           = UIModule.GetCrosshair();
            body.hideCrosshair             = false;
            body.aimOriginTransform        = aimOrigin.transform;
            body.hullClassification        = HullClassification.Human;
            body.portraitIcon              = UIModule.GetPortraitIcon();
            body.isChampion                = false;
            body.currentVehicle            = null;
            body.preferredPodPrefab        = MiscModule.GetPodPrefab();
            body.preferredInitialStateType = SkillsCore.StateType <Uninitialized>();
            body.skinIndex                 = 0u;


            CharacterMotor motor = obj.AddOrGetComponent <CharacterMotor>();

            motor.walkSpeedPenaltyCoefficient = 1f;
            motor.characterDirection          = direction;
            motor.muteWalkMotion = false;
            motor.mass           = 100f;
            motor.airControl     = 0.25f;
            motor.disableAirControlUntilCollision = false;
            motor.generateParametersOnAwake       = true;
            motor.useGravity = true;
            motor.isFlying   = false;


            InputBankTest input = obj.AddOrGetComponent <InputBankTest>();

            input.moveVector = Vector3.zero;



            CameraTargetParams ctp = obj.AddOrGetComponent <CameraTargetParams>();

            ctp.cameraParams         = MiscModule.GetCharCameraParams();
            ctp.cameraPivotTransform = null;
            ctp.aimMode             = CameraTargetParams.AimType.Standard;
            ctp.recoil              = Vector2.zero;
            ctp.idealLocalCameraPos = Vector3.zero;
            ctp.dontRaycastToPivot  = false;


            ModelLocator modelLocator = obj.AddOrGetComponent <ModelLocator>();

            modelLocator.modelTransform           = modelTransform;
            modelLocator.modelBaseTransform       = modelBase.transform;
            modelLocator.dontReleaseModelOnDeath  = false;
            modelLocator.autoUpdateModelTransform = true;
            modelLocator.dontDetatchFromParent    = false;
            modelLocator.noCorpse         = false;
            modelLocator.normalizeToFloor = false;
            modelLocator.preserveModel    = false;


            EntityStateMachine bodyMachine = obj.AddOrGetComponent <EntityStateMachine>();

            bodyMachine.customName       = "Body";
            bodyMachine.initialStateType = SkillsCore.StateType <SpawnTeleporterState>();
            bodyMachine.mainStateType    = SkillsCore.StateType <GenericCharacterMain>();


            EntityStateMachine weaponMachine = obj.AddComponent <EntityStateMachine>();

            weaponMachine.customName       = "Weapon";
            weaponMachine.initialStateType = SkillsCore.StateType <Idle>();
            weaponMachine.mainStateType    = SkillsCore.StateType <Idle>();


            EntityStateMachine scopeMachine = obj.AddComponent <EntityStateMachine>();

            scopeMachine.customName       = "Scope";
            scopeMachine.initialStateType = SkillsCore.StateType <Idle>();
            scopeMachine.mainStateType    = SkillsCore.StateType <Idle>();


            EntityStateMachine reloadMachine = obj.AddComponent <EntityStateMachine>();

            reloadMachine.customName       = "Reload";
            reloadMachine.initialStateType = SkillsCore.StateType <Idle>();
            reloadMachine.mainStateType    = SkillsCore.StateType <Idle>();


            EntityStateMachine[] allStateMachines     = new[] { bodyMachine, weaponMachine, scopeMachine, reloadMachine };
            EntityStateMachine[] nonBodyStateMachines = new[] { weaponMachine, scopeMachine, reloadMachine };


            GenericSkill ammoSkill = obj.AddOrGetComponent <GenericSkill>();

            ammoSkill._skillFamily = SkillFamiliesModule.GetAmmoSkillFamily();
            HooksModule.AddReturnoverride(ammoSkill);


            //GenericSkill passiveSkill = obj.AddComponent<GenericSkill>();
            //passiveSkill._skillFamily = SkillFamiliesModule.GetPassiveSkillFamily();
            //HooksModule.AddReturnoverride( passiveSkill );


            GenericSkill primarySkill = obj.AddComponent <GenericSkill>();

            primarySkill._skillFamily = SkillFamiliesModule.GetPrimarySkillFamily();


            GenericSkill secondarySkill = obj.AddComponent <GenericSkill>();

            secondarySkill._skillFamily = SkillFamiliesModule.GetSecondarySkillFamily();


            GenericSkill utilitySkill = obj.AddComponent <GenericSkill>();

            utilitySkill._skillFamily = SkillFamiliesModule.GetUtilitySkillFamily();


            GenericSkill specialSkill = obj.AddComponent <GenericSkill>();

            specialSkill._skillFamily = SkillFamiliesModule.GetSpecialSkillFamily();


            SkillLocator skillLocator = obj.AddOrGetComponent <SkillLocator>();

            skillLocator.primary      = primarySkill;
            skillLocator.secondary    = secondarySkill;
            skillLocator.utility      = utilitySkill;
            skillLocator.special      = specialSkill;
            skillLocator.passiveSkill = new SkillLocator.PassiveSkill
            {
                enabled = false,
                icon    = null,
                skillDescriptionToken = null,
                skillNameToken        = null,
            };


            TeamComponent team = obj.AddOrGetComponent <TeamComponent>();

            team.hideAllyCardDisplay = false;
            team.teamIndex           = TeamIndex.None;


            HealthComponent health = obj.AddOrGetComponent <HealthComponent>();

            health.health            = 100;
            health.shield            = 0;
            health.barrier           = 0;
            health.magnetiCharge     = 0;
            health.body              = null;
            health.dontShowHealthbar = false;
            health.globalDeathEventChanceCoefficient = 1f;


            Interactor interactor = obj.AddOrGetComponent <Interactor>();

            interactor.maxInteractionDistance = 3f;


            InteractionDriver interaction = obj.AddOrGetComponent <InteractionDriver>();

            interaction.highlightInteractor = true;


            CharacterDeathBehavior death = obj.AddOrGetComponent <CharacterDeathBehavior>();

            death.deathStateMachine = bodyMachine;
            death.deathState        = SkillsCore.StateType <EntityStates.Commando.DeathState>();
            death.idleStateMachine  = nonBodyStateMachines;


            CharacterNetworkTransform netTrans = obj.AddOrGetComponent <CharacterNetworkTransform>();

            netTrans.positionTransmitInterval = 0.05f;
            netTrans.lastPositionTransmitTime = Single.MinValue;
            netTrans.interpolationFactor      = 3f;
            netTrans.debugDuplicatePositions  = false;
            netTrans.debugSnapshotReceived    = false;


            NetworkStateMachine netStates = obj.AddOrGetComponent <NetworkStateMachine>();

            netStates.stateMachines = allStateMachines;
            //stateMachines.Set( netStates, allStateMachines );


            CharacterEmoteDefinitions emotes = obj.AddOrGetComponent <CharacterEmoteDefinitions>();

            emotes.emoteDefinitions = null;


            EquipmentSlot equip = obj.AddOrGetComponent <EquipmentSlot>();


            SfxLocator sfx = obj.AddOrGetComponent <SfxLocator>();

            sfx.deathSound      = "Play_ui_player_death";
            sfx.barkSound       = "";
            sfx.openSound       = "";
            sfx.landingSound    = "Play_char_land";
            sfx.fallDamageSound = "Play_char_land_fall_damage";
            sfx.aliveLoopStart  = "";
            sfx.aliveLoopStop   = "";


            Rigidbody rb = obj.AddOrGetComponent <Rigidbody>();

            rb.mass                   = 100f;
            rb.drag                   = 0f;
            rb.angularDrag            = 0f;
            rb.useGravity             = false;
            rb.isKinematic            = true;
            rb.interpolation          = RigidbodyInterpolation.None;
            rb.collisionDetectionMode = CollisionDetectionMode.Discrete;
            rb.constraints            = RigidbodyConstraints.None;


            CapsuleCollider col = obj.AddOrGetComponent <CapsuleCollider>();

            col.isTrigger = false;
            col.material  = null;
            col.center    = new Vector3(0f, 0f, 0f);
            col.radius    = 0.5f;
            col.height    = 1.82f;
            col.direction = 1;


            KinematicCharacterMotor kinCharMot = obj.AddOrGetComponent <KinematicCharacterMotor>();

            kinCharMot.CharacterController = motor;
            kinCharMot.Capsule             = col;
            kinCharMot.Rigidbody           = rb;

            kinCharMot.CapsuleRadius                     = 0.5f;
            kinCharMot.CapsuleHeight                     = 1.82f;
            kinCharMot.CapsuleYOffset                    = 0f;
            kinCharMot.CapsulePhysicsMaterial            = null;
            kinCharMot.DetectDiscreteCollisions          = false;
            kinCharMot.GroundDetectionExtraDistance      = 0f;
            kinCharMot.MaxStepHeight                     = 0.2f;
            kinCharMot.MinRequiredStepDepth              = 0.1f;
            kinCharMot.MaxStableSlopeAngle               = 55f;
            kinCharMot.MaxStableDistanceFromLedge        = 0.5f;
            kinCharMot.PreventSnappingOnLedges           = false;
            kinCharMot.MaxStableDenivelationAngle        = 55f;
            kinCharMot.RigidbodyInteractionType          = RigidbodyInteractionType.None;
            kinCharMot.PreserveAttachedRigidbodyMomentum = true;
            kinCharMot.HasPlanarConstraint               = false;
            kinCharMot.PlanarConstraintAxis              = Vector3.up;
            kinCharMot.StepHandling  = StepHandlingMethod.None;
            kinCharMot.LedgeHandling = true;
            kinCharMot.InteractiveRigidbodyHandling = true;
            kinCharMot.SafeMovement = false;


            SetStateOnHurt hurt = obj.AddOrGetComponent <SetStateOnHurt>();

            hurt.hitThreshold       = 5f;
            hurt.targetStateMachine = bodyMachine;
            hurt.idleStateMachine   = nonBodyStateMachines;
            hurt.hurtState          = SkillsCore.StateType <Idle>();
            hurt.canBeHitStunned    = false;
            hurt.canBeStunned       = false;
            hurt.canBeFrozen        = true;



            CharacterModel charModel = model.AddOrGetComponent <CharacterModel>();

            charModel.body = body;
            charModel.itemDisplayRuleSet = ItemDisplayModule.GetSniperItemDisplay(model.AddOrGetComponent <ChildLocator>());


            HurtBoxGroup hurtBoxGroup = model.AddOrGetComponent <HurtBoxGroup>();
            HurtBox      tempHb       = model.GetComponentInChildren <HurtBox>();

            tempHb.gameObject.layer = LayerIndex.entityPrecise.intVal;
            tempHb.healthComponent  = health;
            tempHb.isBullseye       = true;
            tempHb.damageModifier   = HurtBox.DamageModifier.Normal;
            tempHb.hurtBoxGroup     = hurtBoxGroup;
            tempHb.indexInGroup     = 0;

            hurtBoxGroup.hurtBoxes = new[]
            {
                tempHb,
            };
            hurtBoxGroup.mainHurtBox   = tempHb;
            hurtBoxGroup.bullseyeCount = 1;


            FootstepHandler footsteps = model.AddComponent <FootstepHandler>();

            footsteps.baseFootstepString           = "Play_player_footstep";
            footsteps.sprintFootstepOverrideString = "";
            footsteps.enableFootstepDust           = true;
            footsteps.footstepDustPrefab           = UnityEngine.Resources.Load <GameObject>("Prefabs/GenericFootstepDust");


            RagdollController ragdoll = model.AddOrGetComponent <RagdollController>();

            ragdoll.bones = null; // FUTURE: Setup sniper ragdoll controller
            ragdoll.componentsToDisableOnRagdoll = null;


            AimAnimator aimAnimator = model.AddOrGetComponent <AimAnimator>();

            aimAnimator.inputBank          = input;
            aimAnimator.directionComponent = direction;
            aimAnimator.pitchRangeMax      = 55f;
            aimAnimator.pitchRangeMin      = -50f;
            aimAnimator.yawRangeMin        = -40f;
            aimAnimator.yawRangeMax        = 45f;

            aimAnimator.pitchGiveupRange = 30f;
            aimAnimator.yawGiveupRange   = 10f;
            aimAnimator.giveupDuration   = 8f;


            ModelSkinController skinController = model.AddOrGetComponent <ModelSkinController>();

            SkinDef[] skinsArray = skinController.skins;
            for (Int32 i = 0; i < skinsArray.Length; ++i)
            {
                SkinDef skin = skinsArray[i];
                skin.minionSkinReplacements = new[]
                {
                    new SkinDef.MinionSkinReplacement
                    {
                        minionBodyPrefab = DecoyModule.GetDecoyPrefab(),
                        minionSkin       = skin
                    },
                };
            }

            foreach (IRuntimePrefabComponent comp in obj.GetComponents <IRuntimePrefabComponent>())
            {
                comp.InitializePrefab();
            }
        }
Пример #16
0
        private static GameObject CreateDecoyPrefab()
        {
            GameObject obj = PrefabsCore.CreatePrefab("SniperDecoy", true);

            TeamComponent teamComp = obj.AddOrGetComponent <TeamComponent>();

            teamComp.hideAllyCardDisplay = false;
            teamComp.teamIndex           = TeamIndex.None;


            NetworkIdentity netId = obj.AddOrGetComponent <NetworkIdentity>();


            Transform modelBase = new GameObject("ModelBase").transform;

            modelBase.parent        = obj.transform;
            modelBase.localPosition = new Vector3(0f, -0.81f, 0f);
            modelBase.localScale    = Vector3.one;
            modelBase.localRotation = Quaternion.identity;


            GameObject mdlSniper = UnityEngine.Object.Instantiate <GameObject>(ModelModule.GetModel(), modelBase);

            mdlSniper.transform.localPosition = Vector3.zero;
            mdlSniper.transform.localScale    = Vector3.one;
            mdlSniper.transform.localRotation = Quaternion.identity;



            CharacterBody body = obj.AddOrGetComponent <CharacterBody>();

            body.bodyIndex             = (BodyIndex)(-1);
            body.baseNameToken         = Properties.Tokens.SNIPER_NAME;
            body.subtitleNameToken     = Properties.Tokens.SNIPER_SUBTITLE;
            body.bodyFlags             = CharacterBody.BodyFlags.ResistantToAOE | CharacterBody.BodyFlags.ImmuneToExecutes;
            body.rootMotionInMainState = false;
            body.mainRootSpeed         = 0f;

            // CLEANUP: Abstract out base stats for decoy and sniper
            body.baseMaxHealth  = 130f;
            body.levelMaxHealth = 39f;

            body.baseRegen  = 1f;
            body.levelRegen = 0.2f;

            body.baseMaxShield  = 0f;
            body.levelMaxShield = 0f;

            body.baseMoveSpeed  = 0f;
            body.levelMoveSpeed = 0f;

            body.baseAcceleration = 0f;

            body.baseJumpPower  = 0f;
            body.levelJumpPower = 0f;

            body.baseDamage  = 12f;
            body.levelDamage = 2.4f;

            body.baseAttackSpeed  = 1f;
            body.levelAttackSpeed = 0f;

            body.baseCrit  = 0f;
            body.levelCrit = 0f;

            body.baseArmor  = 50f;
            body.levelArmor = 10f;

            body.baseJumpCount = 1;

            body.sprintingSpeedMultiplier = 0f;

            //body.killCount = 0;
            body.wasLucky                  = false;
            body.spreadBloomDecayTime      = 0.45f;
            body.spreadBloomCurve          = new AnimationCurve();
            body.crosshairPrefab           = null;
            body.hideCrosshair             = false;
            body.aimOriginTransform        = body.transform;
            body.hullClassification        = HullClassification.Human;
            body.portraitIcon              = UIModule.GetPortraitIcon();
            body.isChampion                = false;
            body.currentVehicle            = null;
            body.preferredPodPrefab        = null;
            body.preferredInitialStateType = SkillsCore.StateType <GenericCharacterMain>();
            body.skinIndex                 = 0u;



            CharacterModel model = mdlSniper.AddOrGetComponent <CharacterModel>();

            model.body = body;
            model.itemDisplayRuleSet = ItemDisplayModule.GetSniperItemDisplay(model.AddOrGetComponent <ChildLocator>());



            HealthComponent health = obj.AddOrGetComponent <HealthComponent>();

            health.health            = 100;
            health.shield            = 0;
            health.barrier           = 0;
            health.magnetiCharge     = 0;
            health.body              = null;
            health.dontShowHealthbar = false;
            health.globalDeathEventChanceCoefficient = 1f;



            HurtBoxGroup hurtBoxGroup = model.AddOrGetComponent <HurtBoxGroup>();
            HurtBox      tempHb       = model.GetComponentInChildren <HurtBox>();

            tempHb.gameObject.layer = LayerIndex.entityPrecise.intVal;
            tempHb.healthComponent  = health;
            tempHb.isBullseye       = true;
            tempHb.damageModifier   = HurtBox.DamageModifier.Normal;
            tempHb.hurtBoxGroup     = hurtBoxGroup;
            tempHb.indexInGroup     = 0;

            hurtBoxGroup.hurtBoxes = new[]
            {
                tempHb,
            };
            hurtBoxGroup.mainHurtBox   = tempHb;
            hurtBoxGroup.bullseyeCount = 1;


            InputBankTest inputs = obj.AddOrGetComponent <InputBankTest>();

            inputs.moveVector = Vector3.zero;


            CameraTargetParams cameraTargetParams = obj.AddOrGetComponent <CameraTargetParams>();

            cameraTargetParams.cameraParams         = MiscModule.GetCharCameraParams();
            cameraTargetParams.cameraPivotTransform = null;
            cameraTargetParams.aimMode             = CameraTargetParams.AimType.Standard;
            cameraTargetParams.recoil              = Vector2.zero;
            cameraTargetParams.idealLocalCameraPos = Vector3.zero;
            cameraTargetParams.dontRaycastToPivot  = false;



            ModelLocator modelLocator = obj.AddOrGetComponent <ModelLocator>();

            modelLocator.modelTransform           = mdlSniper.transform;
            modelLocator.modelBaseTransform       = modelBase;
            modelLocator.dontReleaseModelOnDeath  = false;
            modelLocator.autoUpdateModelTransform = true;
            modelLocator.dontDetatchFromParent    = false;
            modelLocator.noCorpse         = true;
            modelLocator.normalizeToFloor = false;
            modelLocator.preserveModel    = false;


            EntityStateMachine esm = obj.AddOrGetComponent <EntityStateMachine>();

            esm.customName       = "Body";
            esm.initialStateType = SkillsCore.StateType <BeingADecoy>();
            esm.mainStateType    = SkillsCore.StateType <BeingADecoy>();


            SkillLocator skillLocator = obj.AddOrGetComponent <SkillLocator>();

            skillLocator.primary   = null;
            skillLocator.secondary = null;
            skillLocator.utility   = null;
            skillLocator.special   = null;


            CharacterDeathBehavior deathBehaviour = obj.AddOrGetComponent <CharacterDeathBehavior>();

            deathBehaviour.deathStateMachine = esm;
            deathBehaviour.deathState        = SkillsCore.StateType <DecoyDeathState>();
            deathBehaviour.idleStateMachine  = Array.Empty <EntityStateMachine>();


            CharacterNetworkTransform netTrans = obj.AddOrGetComponent <CharacterNetworkTransform>();

            netTrans.positionTransmitInterval = 0.1f;
            netTrans.lastPositionTransmitTime = Single.NegativeInfinity;
            netTrans.interpolationFactor      = 2f;
            netTrans.debugDuplicatePositions  = false;
            netTrans.debugSnapshotReceived    = false;


            NetworkStateMachine netStates = obj.AddOrGetComponent <NetworkStateMachine>();

            //netStates._SetStateMachines( esm );
            netStates.stateMachines = new[] { esm };


            Interactor interactor = obj.AddOrGetComponent <Interactor>();

            interactor.maxInteractionDistance = 1f;


            InteractionDriver interactionDriver = obj.AddOrGetComponent <InteractionDriver>();

            interactionDriver.highlightInteractor = false;


            CapsuleCollider cap = obj.AddOrGetComponent <CapsuleCollider>();

            cap.isTrigger = false;
            cap.material  = null;
            cap.center    = Vector3.zero;
            cap.radius    = 0.5f;
            cap.height    = 1.82f;
            cap.direction = 1;


            SetStateOnHurt hurtState = obj.AddOrGetComponent <SetStateOnHurt>();

            hurtState.hitThreshold       = 5f;
            hurtState.targetStateMachine = esm;
            hurtState.idleStateMachine   = Array.Empty <EntityStateMachine>();
            hurtState.hurtState          = SkillsCore.StateType <Idle>();
            hurtState.canBeHitStunned    = false;
            hurtState.canBeFrozen        = true;
            hurtState.canBeStunned       = false;


            SfxLocator sfx = obj.AddOrGetComponent <SfxLocator>();
            // FUTURE: Death sounds for decoy


            Rigidbody rb = obj.AddOrGetComponent <Rigidbody>();

            rb.mass                   = 1000f;
            rb.drag                   = 0f;
            rb.angularDrag            = 0f;
            rb.useGravity             = false;
            rb.isKinematic            = true;
            rb.interpolation          = RigidbodyInterpolation.None;
            rb.collisionDetectionMode = CollisionDetectionMode.Discrete;


            CharacterMotor charMot = obj.AddOrGetComponent <CharacterMotor>();

            charMot.walkSpeedPenaltyCoefficient = 1f;
            CharacterDirection charDir = charMot.characterDirection = obj.AddOrGetComponent <CharacterDirection>();

            charMot.muteWalkMotion = false;
            charMot.mass           = 1000f;
            charMot.airControl     = 0.25f;
            charMot.disableAirControlUntilCollision = false;
            charMot.generateParametersOnAwake       = true;
            charMot.useGravity = true;
            charMot.isFlying   = false;


            charDir.moveVector      = Vector3.zero;
            charDir.targetTransform = modelBase;
            charDir.overrideAnimatorForwardTransform = null;
            charDir.rootMotionAccumulator            = null;
            charDir.modelAnimator         = null;
            charDir.driveFromRootRotation = false;
            charDir.driveFromRootRotation = false;
            charDir.turnSpeed             = 180f;


            KinematicCharacterController.KinematicCharacterMotor kinCharMot = obj.AddOrGetComponent <KinematicCharacterController.KinematicCharacterMotor>();
            kinCharMot.CharacterController               = charMot;
            kinCharMot.Capsule                           = cap;
            kinCharMot.Rigidbody                         = rb;
            kinCharMot.CapsuleRadius                     = 0.5f;
            kinCharMot.CapsuleHeight                     = 1.8f;
            kinCharMot.CapsuleYOffset                    = 0f;
            kinCharMot.DetectDiscreteCollisions          = false;
            kinCharMot.GroundDetectionExtraDistance      = 0f;
            kinCharMot.MaxStepHeight                     = 0.5f;
            kinCharMot.MinRequiredStepDepth              = 0.1f;
            kinCharMot.MaxStableSlopeAngle               = 55f;
            kinCharMot.MaxStableDistanceFromLedge        = 0.5f;
            kinCharMot.PreventSnappingOnLedges           = false;
            kinCharMot.MaxStableDenivelationAngle        = 55f;
            kinCharMot.RigidbodyInteractionType          = KinematicCharacterController.RigidbodyInteractionType.None;
            kinCharMot.PreserveAttachedRigidbodyMomentum = true;
            kinCharMot.HasPlanarConstraint               = false;
            kinCharMot.PlanarConstraintAxis              = Vector3.up;
            kinCharMot.StepHandling                      = KinematicCharacterController.StepHandlingMethod.Standard;
            kinCharMot.LedgeHandling                     = true;
            kinCharMot.InteractiveRigidbodyHandling      = true;
            kinCharMot.SafeMovement                      = false;


            _ = obj.AddComponent <DecoyDeployableSync>();


            obj.layer = LayerIndex.fakeActor.intVal;


            foreach (IRuntimePrefabComponent comp in obj.GetComponents <IRuntimePrefabComponent>())
            {
                comp.InitializePrefab();
            }


            BodiesCore.Add(obj);

            return(obj);
        }
Пример #17
0
        private void On_SSOHOnTakeDamageServer(On.RoR2.SetStateOnHurt.orig_OnTakeDamageServer orig, SetStateOnHurt self, DamageReport damageReport)
        {
            orig(self, damageReport);
            int icnt = GetCount(damageReport.attackerMaster);

            if (icnt < 1)
            {
                return;
            }
            var ch = Util.ConvertAmplificationPercentageIntoReductionPercentage(procChance * icnt * damageReport.damageInfo.procCoefficient);

            if (!Util.CheckRoll(ch))
            {
                return;
            }
            if (self.canBeFrozen)
            {
                self.SetFrozen(freezeTime);
                damageReport.victim?.body.AddTimedBuff(ClassicItemsPlugin.freezeBuff, freezeTime);
            }
            if ((self.canBeFrozen || slowUnfreezable) && damageReport.victim)
            {
                damageReport.victim.body.AddTimedBuff(BuffIndex.Slow60, slowTime);
            }
        }
Пример #18
0
        private void ModifyClayMan()
        {
            AISkillDriver clayPrimary = clayMaster.GetComponent <AISkillDriver>();

            clayPrimary.maxDistance = 16f;
            clayMaster.GetComponent <CharacterMaster>().bodyPrefab = clayObject;

            LanguageAPI.Add("CLAY_BODY_NAME", "Clay Man");

            LanguageAPI.Add("CLAY_BODY_LORE", "Quick with his sword and quicker with his feet; the agility of these clay 'people' is unexpected with a form so roughly shaped.\n\nWhen faced with one of the few creatures here which I feel some humanity in, my aloneness closes in. Why do they have clay pots on their heads? Could it be protection from this cruel reality, or maybe just to hide the scars from this brutal planet.");
            clayObject.AddComponent <Interactor>().maxInteractionDistance = 3f;
            clayObject.AddComponent <InteractionDriver>();

            ModelLocator clayModelLocator = clayObject.GetComponent <ModelLocator>();

            clayModelLocator.modelTransform.gameObject.layer = LayerIndex.entityPrecise.intVal;
            clayModelLocator.modelTransform.localScale      *= 1.2f;
            clayModelLocator.noCorpse = true;

            CharacterDeathBehavior clayCDB = clayObject.GetComponent <CharacterDeathBehavior>();

            clayCDB.deathState = Resources.Load <GameObject>("prefabs/characterbodies/WispBody").GetComponent <CharacterDeathBehavior>().deathState;

            CharacterBody clayCB = clayObject.GetComponent <CharacterBody>();

            clayCB.baseNameToken  = "CLAY_BODY_NAME";
            clayCB.baseJumpPower  = 22f;
            clayCB.baseMaxHealth  = 140f;
            clayCB.levelMaxHealth = clayCB.baseMaxHealth * 0.3f;
            clayCB.baseArmor      = 0f;
            clayCB.baseDamage     = 11f;
            clayCB.levelDamage    = clayCB.baseDamage * 0.2f;
            clayCB.baseMoveSpeed  = 9f;
            clayCB.baseRegen      = 0f;
            clayCB.levelRegen     = 0f;
            clayCB.bodyFlags      = CharacterBody.BodyFlags.ImmuneToGoo;

            //Debug.Log(clayCB.GetComponent<DeathRewards>().logUnlockableName);

            /*UnlockableDef clayLog = ScriptableObject.CreateInstance<UnlockableDef>();
             * clayCB.GetComponent<DeathRewards>().logUnlockableDef = clayLog;*/

            SetStateOnHurt claySSoH = clayObject.AddComponent <SetStateOnHurt>();

            claySSoH.canBeFrozen     = true;
            claySSoH.canBeStunned    = true;
            claySSoH.canBeHitStunned = false;
            claySSoH.hitThreshold    = 0.15f;

            SfxLocator claySFX = clayObject.GetComponent <SfxLocator>();

            claySFX.deathSound = "Play_clayboss_M1_explo";
            claySFX.barkSound  = "";

            //Ice Fix Credits: SushiDev
            int i = 0;

            EntityStateMachine[] esmr = new EntityStateMachine[2];
            foreach (EntityStateMachine esm in clayObject.GetComponentsInChildren <EntityStateMachine>())
            {
                switch (esm.customName)
                {
                case "Body":
                    claySSoH.targetStateMachine = esm;
                    break;

                default:
                    if (i < 2)
                    {
                        esmr[i] = esm;
                    }
                    i++;
                    break;
                }
            }

            #region hitbox
            Component[] clayComponents           = clayObject.GetComponentsInChildren <Transform>();
            Transform   clayTransform            = null;
            Transform   clayHeadTransform        = null;
            Transform   claySwordHitboxTransform = null;
            foreach (Transform t in clayComponents)
            {
                if (t.name == "chest")
                {
                    clayTransform = t;
                }
                else if (t.name == "head")
                {
                    clayHeadTransform = t;
                }
                else if (t.name == "Hitbox")
                {
                    claySwordHitboxTransform = t;
                }
                if (clayTransform != null && clayHeadTransform != null && claySwordHitboxTransform != null)
                {
                    break;
                }
            }

            ItemDisplays.headTransform = clayHeadTransform;

            HurtBoxGroup clayHurtBoxGroup = clayModelLocator.modelTransform.gameObject.AddComponent <HurtBoxGroup>();
            claySwordHitboxTransform.localScale *= 2.4f; //2.8 -> 2.4

            #region chest
            clayTransform.gameObject.layer = LayerIndex.entityPrecise.intVal;
            CapsuleCollider clayCollider = clayTransform.gameObject.AddComponent <CapsuleCollider>();
            clayCollider.center -= new Vector3(0, 0.6f, 0);
            clayCollider.height *= 0.25f;
            clayCollider.radius *= 1.16f;
            HurtBox clayHurtBox = clayTransform.gameObject.AddComponent <HurtBox>();
            clayHurtBox.isBullseye      = true;
            clayHurtBox.healthComponent = clayObject.GetComponent <HealthComponent>();
            clayHurtBox.damageModifier  = HurtBox.DamageModifier.Normal;
            clayHurtBox.hurtBoxGroup    = clayHurtBoxGroup;
            clayHurtBox.indexInGroup    = 0;
            //clayHurtBox.name = "ChestHurtbox";
            #endregion

            #region head


            clayHeadTransform.gameObject.layer = LayerIndex.entityPrecise.intVal;
            CapsuleCollider clayHeadCollider = clayHeadTransform.gameObject.AddComponent <CapsuleCollider>();
            clayHeadCollider.height *= 0.4f;
            clayHeadCollider.radius *= 0.3f;
            clayHeadCollider.center += new Vector3(0, 0.2f, 0);
            HurtBox clayHeadHurtBox = clayHeadTransform.gameObject.AddComponent <HurtBox>();
            clayHeadHurtBox.isBullseye      = false;
            clayHeadHurtBox.healthComponent = clayObject.GetComponent <HealthComponent>();
            clayHeadHurtBox.damageModifier  = HurtBox.DamageModifier.SniperTarget;
            clayHeadHurtBox.hurtBoxGroup    = clayHurtBoxGroup;
            clayHeadHurtBox.indexInGroup    = 1;
            //clayHeadHurtBox.name = "HeadHurtbox";

            #endregion

            HurtBox[] clayHurtBoxArray = new HurtBox[]
            {
                clayHurtBox, clayHeadHurtBox
            };

            clayHurtBoxGroup.bullseyeCount = 1;
            clayHurtBoxGroup.hurtBoxes     = clayHurtBoxArray;
            clayHurtBoxGroup.mainHurtBox   = clayHurtBox;

            #endregion

            EntityLocator clayLocator = clayObject.AddComponent <EntityLocator>();
            clayLocator.entity = clayObject;
        }
Пример #19
0
        private void AW_GetBody()
        {
            this.AW_body = Resources.Load <GameObject>("Prefabs/CharacterBodies/AncientWispBody").ClonePrefab("WispBossBody", true);

            var sound = this.AW_body.AddComponent <StartEndSound>();

            sound.startSound = "Play_huntress_R_aim_loop";
            sound.endSound   = "Stop_huntress_R_aim_loop";

            var charBody = this.AW_body.GetComponent <CharacterBody>();

            charBody.baseNameToken     = Rein.Properties.Tokens.ANCIENT_WISP_BODY_NAME;
            charBody.subtitleNameToken = Rein.Properties.Tokens.ANCIENT_WISP_BODY_SUBNAME;

            //LanguageCore.AddLanguageToken( "ANCIENT_WISP_BODY_NAME", "Ancient Wisp" );
            //LanguageCore.AddLanguageToken( "ANCIENT_WISP_BODY_SUBNAME", "Banished and Chained" );
            //R2API.AssetPlus.Languages.AddToken( "ANCIENT_WISP_BODY_NAME", "Ancient Wisp" );
            //R2API.AssetPlus.Languages.AddToken( "ANCIENT_WISP_BODY_SUBNAME", "Banished and Chained" );

            charBody.baseMaxHealth  = 10000;
            charBody.levelMaxHealth = 3000;

            charBody.baseRegen  = 0f;
            charBody.levelRegen = 0f;

            charBody.baseMaxShield  = 0f;
            charBody.levelMaxShield = 0f;

            charBody.baseMoveSpeed  = 15f;
            charBody.levelMoveSpeed = 0f;

            charBody.baseAcceleration = 10f;

            charBody.baseJumpPower  = 0f;
            charBody.levelJumpPower = 0f;

            charBody.baseDamage  = 40f;
            charBody.levelDamage = 8f;

            charBody.baseAttackSpeed  = 1f;
            charBody.levelAttackSpeed = 0f;

            charBody.baseCrit  = 0f;
            charBody.levelCrit = 0f;

            charBody.baseArmor  = 30f;
            charBody.levelArmor = 0f;

            charBody.baseJumpCount = 0;



            NetworkStateMachine    net   = this.AW_body.GetComponent <NetworkStateMachine>();
            CharacterDeathBehavior death = this.AW_body.GetComponent <CharacterDeathBehavior>();

            death.idleStateMachine = new EntityStateMachine[1];
            death.deathState       = new EntityStates.SerializableEntityStateType(typeof(EntityStates.Commando.DeathState));

            EntityStateMachine[] netStates = net.stateMachines;
            Array.Resize <EntityStateMachine>(ref netStates, 2);


            SetStateOnHurt hurtState = this.AW_body.AddOrGetComponent <SetStateOnHurt>();

            hurtState.canBeFrozen     = false;
            hurtState.canBeHitStunned = false;
            hurtState.canBeStunned    = false;
            hurtState.hitThreshold    = 5f;
            hurtState.hurtState       = new SerializableEntityStateType(typeof(EntityStates.FrozenState));

            SkillsCore.AddSkill(typeof(AWDefaultMain));
            SkillsCore.AddSkill(typeof(AWEnrageTransition));
            SkillsCore.AddSkill(typeof(AWEnrageMainState));

            foreach (EntityStateMachine esm in this.AW_body.GetComponents <EntityStateMachine>())
            {
                switch (esm.customName)
                {
                case "Body":
                    netStates[0]                 = esm;
                    esm.mainStateType            = new SerializableEntityStateType(typeof(AWDefaultMain)); //typeof( AWDefaultMain ).EntityStateType();
                    esm.initialStateType         = new SerializableEntityStateType(typeof(AWDefaultMain)); //typeof( AWDefaultMain ).EntityStateType();
                    hurtState.targetStateMachine = esm;
                    death.deathStateMachine      = esm;
                    break;

                case "Weapon":
                    esm.initialStateType      = new SerializableEntityStateType(typeof(Idle));
                    esm.mainStateType         = new SerializableEntityStateType(typeof(Idle));
                    netStates[1]              = esm;
                    death.idleStateMachine[0] = esm;
                    break;

                default:
                    break;
                }
            }

            net.stateMachines = netStates;
        }
Пример #20
0
        private void ShieldOnHit(On.RoR2.SetStateOnHurt.orig_OnTakeDamageServer orig, SetStateOnHurt self, DamageReport damageReport)
        {
            var InvenCount = GetCount(damageReport.attackerMaster);

            if (InvenCount > 0)
            {
                float procCoeff = damageReport.damageInfo.procCoefficient;
                damageReport.attackerBody.healthComponent.RechargeShield(InvenCount * procCoeff);
            }
            orig(self, damageReport);
        }
Пример #21
0
        private void On_SSOHOnTakeDamageServer(On.RoR2.SetStateOnHurt.orig_OnTakeDamageServer orig, SetStateOnHurt self, RoR2.DamageReport damageReport)
        {
            orig(self, damageReport);
            int icnt = GetCount(damageReport.attackerMaster);

            if (icnt < 1)
            {
                return;
            }
        }
Пример #22
0
            public void Update()
            {
                // The charge fraction is synced over network only every few frames, so the animation becomes laggy
                // Predict the teleporter charge locally to make it smooth
                predictionChargeFractionDeltaTime += Time.deltaTime;
                float num = holdoutZoneController.charge - predictionChargeFractionLast;

                if (num != 0f)
                {
                    chargeFraction                    = holdoutZoneController.charge;
                    predictionChargeSpeed             = num / predictionChargeFractionDeltaTime;
                    predictionChargeFractionDeltaTime = 0f;
                }
                predictionChargeFractionLast = holdoutZoneController.charge;
                chargeFraction = Mathf.Clamp01(chargeFraction + predictionChargeSpeed * Time.deltaTime);

                int itemCount = Util.GetItemCountForTeam(TeamIndex.Player, MysticsItemsContent.Items.MysticsItems_CrystalWorld.itemIndex, true);

                if (itemCount > 0)
                {
                    float nextPulse = NextPulse(pulses + pulsesPerStack * (itemCount - 1));
                    if (!holdoutZoneController.enabled)
                    {
                        nextPulse = 100f;
                    }
                    if (nextPulse >= 1f)
                    {
                        nextPulse = 100f;
                    }

                    float t = (1f - (nextPulse - chargeFraction) / windup) * 0.5f;
                    if (chargeFraction <= (prevPulse + winddown))
                    {
                        t = ((chargeFraction - prevPulse) / winddown) * 0.5f + 0.5f;
                    }
                    t = Mathf.Clamp01(t);

                    currentSpin   = finalSpin * animationCurve.Evaluate(t);
                    currentHeight = finalHeight * animationCurve.Evaluate(t);
                    if (model)
                    {
                        if (!model.activeSelf)
                        {
                            model.SetActive(true);
                        }
                        model.transform.Rotate(new Vector3(0f, currentSpin * Time.deltaTime, 0f), Space.Self);
                        model.transform.localPosition = offset + Vector3.up * currentHeight;
                    }

                    if (holdoutZoneController.charge > nextPulse)
                    {
                        prevPulse = nextPulse;
                        if (NetworkServer.active)
                        {
                            EffectManager.SpawnEffect(pulsePrefab, new EffectData
                            {
                                origin = transform.position,
                                scale  = holdoutZoneController.currentRadius * 2f
                            }, true);
                            sphereSearch.radius = holdoutZoneController.currentRadius;
                            foreach (HurtBox hurtBox in sphereSearch.RefreshCandidates().FilterCandidatesByHurtBoxTeam(teamMask).FilterCandidatesByDistinctHurtBoxEntities().GetHurtBoxes())
                            {
                                HealthComponent healthComponent = hurtBox.healthComponent;
                                if (healthComponent)
                                {
                                    CharacterBody body = healthComponent.body;
                                    if (body)
                                    {
                                        SetStateOnHurt setStateOnHurt = body.gameObject.GetComponent <SetStateOnHurt>();
                                        if (setStateOnHurt && setStateOnHurt.canBeFrozen)
                                        {
                                            setStateOnHurt.SetFrozen(freezeTime);

                                            // Deal a bit of damage to force execute
                                            DamageInfo damageInfo = new DamageInfo
                                            {
                                                attacker        = null,
                                                damage          = 12f * 2.4f * TeamManager.instance.GetTeamLevel(TeamIndex.Player),
                                                procCoefficient = 0f,
                                                position        = hurtBox.transform.position,
                                                crit            = false
                                            };
                                            healthComponent.TakeDamage(damageInfo);
                                        }
                                        else
                                        {
                                            body.AddTimedBuff(MysticsItemsContent.Buffs.MysticsItems_Crystallized, freezeTime);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (model && model.activeSelf)
                    {
                        model.SetActive(false);
                    }
                }
            }