internal static SniperPassiveSkillDef Create(Data.BulletModifier modifier, Boolean headshots, Single critMultiplier, Single critPerLevel)
        {
            SniperPassiveSkillDef def = ScriptableObject.CreateInstance <SniperPassiveSkillDef>();

            def.bulletModifier         = modifier;
            def.canHeadshot            = headshots;
            def.onCritDamageMultiplier = critMultiplier;


            def.activationState            = SkillsCore.StateType <Idle>();
            def.activationStateMachineName = "";
            def.baseMaxStock                 = 0;
            def.baseRechargeInterval         = 0f;
            def.beginSkillCooldownOnSkillEnd = false;
            def.canceledFromSprinting        = false;
            def.fullRestockOnAssign          = false;
            def.interruptPriority            = InterruptPriority.Any;
            def.isBullets      = false;
            def.isCombatSkill  = false;
            def.mustKeyPress   = false;
            def.noSprint       = false;
            def.rechargeStock  = 0;
            def.requiredStock  = 0;
            def.shootDelay     = 0f;
            def.stockToConsume = 0;
            def.critPerLevel   = critPerLevel;

            return(def);
        }
Exemple #2
0
        internal static SniperSkillDef Create <TActivationState>(String stateMachineName) where TActivationState : EntityState
        {
            SniperSkillDef def = CreateInstance <SniperSkillDef>();

            def.activationState            = SkillsCore.StateType <TActivationState>();
            def.activationStateMachineName = stateMachineName;
            def.shootDelay = 0f;

            return(def);
        }
Exemple #3
0
 private void RW_RegisterSkillStates()
 {
     SkillsCore.AddSkill(typeof(HeatwaveWindDown));
     SkillsCore.AddSkill(typeof(Heatwave));
     SkillsCore.AddSkill(typeof(TestSecondary));
     SkillsCore.AddSkill(typeof(PrepGaze));
     SkillsCore.AddSkill(typeof(FireGaze));
     SkillsCore.AddSkill(typeof(IncinerationWindup));
     SkillsCore.AddSkill(typeof(Incineration));
     SkillsCore.AddSkill(typeof(IncinerationRecovery));
 }
Exemple #4
0
 internal void InitStates <TActivation, TReactivation>(String activationMachine, String reactivationMachine)
     where TActivation : ActivationBaseState <TSkillData>
     where TReactivation : ReactivationBaseState <TSkillData>
 {
     this.activationState              = SkillsCore.StateType <TActivation>();
     this.reactivationState            = SkillsCore.StateType <TReactivation>();
     this.activationStateMachineName   = activationMachine;
     this.reactivationStateMachineName = reactivationMachine;
     this.mustKeyPress          = true;
     this.isBullets             = false;
     this.canceledFromSprinting = false;
 }
Exemple #5
0
        private static SkillFamily GetNewSkillFamily(GenericSkill s)
        {
            //if( !s.skillFamily )
            //{
            s._skillFamily = ScriptableObject.CreateInstance <SkillFamily>();
            //skillFamily.Set( s, ScriptableObject.CreateInstance<SkillFamily>() );
            //}
            s.skillFamily.variants = Array.Empty <SkillFamily.Variant>();

            SkillsCore.AddSkillFamily(s.skillFamily);

            return(s.skillFamily);
        }
Exemple #6
0
        private static void AssignVariants(SkillFamily fam, SkillDef[] skills)
        {
            SkillFamily.Variant[] variants = new SkillFamily.Variant[skills.Length];

            for (Int32 i = 0; i < skills.Length; i++)
            {
                variants[i] = new SkillFamily.Variant
                {
                    skillDef       = skills[i],
                    unlockableName = "",
                    viewableNode   = new ViewablesCatalog.Node(skills[i].skillNameToken, false)
                };
                SkillsCore.AddSkillDef(skills[i]);
            }

            fam.variants = variants;
        }
Exemple #7
0
        private void AW_SetupUtility()
        {
            var skillLoc   = this.AW_body.GetComponent <SkillLocator>();
            var utilityFam = ScriptableObject.CreateInstance <SkillFamily>();
            var utilityDef = ScriptableObject.CreateInstance <SkillDef>();

            SkillsCore.AddSkillDef(utilityDef);
            SkillsCore.AddSkillFamily(utilityFam);
            SkillsCore.AddSkill(typeof(AWChargeUtility));
            SkillsCore.AddSkill(typeof(AWFireUtility));


            utilityDef.activationState            = new SerializableEntityStateType(typeof(AWChargeUtility));
            utilityDef.activationStateMachineName = "Weapon";
            utilityDef.baseMaxStock                 = 1;
            utilityDef.baseRechargeInterval         = 23f;
            utilityDef.beginSkillCooldownOnSkillEnd = true;
            utilityDef.canceledFromSprinting        = false;
            utilityDef.fullRestockOnAssign          = true;
            utilityDef.icon = Resources.Load <Sprite>("NotAPath");
            utilityDef.interruptPriority     = EntityStates.InterruptPriority.Skill;
            utilityDef.isBullets             = false;
            utilityDef.isCombatSkill         = true;
            utilityDef.mustKeyPress          = false;
            utilityDef.noSprint              = false;
            utilityDef.rechargeStock         = 1;
            utilityDef.requiredStock         = 1;
            utilityDef.shootDelay            = 0.1f;
            utilityDef.skillDescriptionToken = "";
            utilityDef.skillName             = "";
            utilityDef.skillNameToken        = "";
            utilityDef.stockToConsume        = 1;

            utilityFam.variants = new SkillFamily.Variant[]
            {
                new SkillFamily.Variant
                {
                    skillDef       = utilityDef,
                    unlockableName = "",
                    viewableNode   = new ViewablesCatalog.Node("aaaaaa", false)
                }
            };
            skillLoc.utility._skillFamily = utilityFam;
            //skillFamily.Set( skillLoc.utility, utilityFam );
        }
        internal static SniperScopeSkillDef Create <TSecondary>(ZoomParams zoomParams) where TSecondary : ScopeBaseState
        {
            SniperScopeSkillDef def = ScriptableObject.CreateInstance <SniperScopeSkillDef>();

            def.zoomParams                  = zoomParams;
            def.activationState             = SkillsCore.StateType <TSecondary>();
            def.activationStateMachineName  = "Scope";
            def.canceledFromSprinting       = true;
            def.cancelSprintingOnActivation = true;
            def.fullRestockOnAssign         = true;
            def.interruptPriority           = InterruptPriority.Skill;
            def.isCombatSkill               = false;
            def.mustKeyPress                = false;
            //def.shootDelay = 0f;
            def.stockToConsume = 0;

            return(def);
        }
        internal static SniperReloadableFireSkillDef Create <TPrimaryData, TReload>(String fireStateMachineName, String reloadStateMachineName)
            where TPrimaryData : struct, ISniperPrimaryDataProvider
            where TReload : EntityState, ISniperReloadState
        {
            SniperReloadableFireSkillDef def = ScriptableObject.CreateInstance <SniperReloadableFireSkillDef>();

            def.activationState              = SkillsCore.StateType <SnipeState <TPrimaryData> >();
            def.activationStateMachineName   = fireStateMachineName;
            def.baseRechargeInterval         = 1f;
            def.beginSkillCooldownOnSkillEnd = true;
            def.canceledFromSprinting        = false;
            def.isCombatSkill          = true;
            def.fullRestockOnAssign    = false;
            def.mustKeyPress           = true;
            def.noSprint               = true;
            def.reloadActivationState  = SkillsCore.StateType <TReload>();
            def.reloadStateMachineName = reloadStateMachineName;
            def.baseMaxStock           = 0;
            return(def);
        }
Exemple #10
0
 private void AW_SetupEnrage()
 {
     SkillsCore.AddSkill(typeof(AWDefaultMain));
     SkillsCore.AddSkill(typeof(AWEnrageTransition));
     SkillsCore.AddSkill(typeof(AWEnrageMainState));
 }
Exemple #11
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();
            }
        }
Exemple #12
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;
        }
Exemple #13
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);
        }
Exemple #14
0
        private static GameObject CreateDecoyMaster()
        {
            GameObject master = PrefabsCore.CreatePrefab("SniperDecoyMaster", true);

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

            CharacterMaster charMaster = master.AddOrGetComponent <CharacterMaster>();

            charMaster.masterIndex        = new MasterCatalog.MasterIndex(-1);
            charMaster.bodyPrefab         = GetDecoyPrefab();
            charMaster.spawnOnStart       = false;
            charMaster.teamIndex          = TeamIndex.Player;
            charMaster.destroyOnBodyDeath = true;
            charMaster.isBoss             = false;
            charMaster.preventGameOver    = true;


            _ = master.AddOrGetComponent <Inventory>();


            BaseAI ai = master.AddOrGetComponent <BaseAI>();

            ai.fullVision = true;
            ai.neverRetaliateFriendlies = true;
            //ai.minDistanceFromEnemy = 0;
            ai.enemyAttentionDuration = 0;
            //ai.navigationType = BaseAI.NavigationType.Nodegraph;
            ai.desiredSpawnNodeGraphType = RoR2.Navigation.MapNodeGroup.GraphType.Ground;
            EntityStateMachine esm = ai.stateMachine = master.AddOrGetComponent <EntityStateMachine>();

            ai.isHealer          = false;
            ai.enemyAttention    = 0f;
            ai.aimVectorDampTime = 0f;
            ai.aimVectorMaxSpeed = 0f;
            //ai.desiredAimDirection = Vector3.up;
            //ai.drawAIPath = false;
            ai.selectedSkilldriverName = null;
            ai.debugEnemyHurtBox       = null;
            ai.currentEnemy            = null;
            ai.leader       = null;
            ai.customTarget = null;

            esm.customName       = "AI";
            esm.initialStateType = SkillsCore.StateType <BlankAI>();
            esm.mainStateType    = SkillsCore.StateType <BlankAI>();

            AISkillDriver driver = master.AddOrGetComponent <AISkillDriver>();

            driver.customName                        = "Sit there and look pretty";
            driver.skillSlot                         = SkillSlot.None;
            driver.requiredSkill                     = null;
            driver.requireSkillReady                 = false;
            driver.requireEquipmentReady             = false;
            driver.moveTargetType                    = AISkillDriver.TargetType.CurrentEnemy;
            driver.minUserHealthFraction             = Single.NegativeInfinity;
            driver.maxUserHealthFraction             = Single.PositiveInfinity;
            driver.minTargetHealthFraction           = Single.NegativeInfinity;
            driver.maxTargetHealthFraction           = Single.PositiveInfinity;
            driver.minDistance                       = Single.NegativeInfinity;
            driver.maxDistance                       = Single.PositiveInfinity;
            driver.selectionRequiresTargetLoS        = false;
            driver.activationRequiresTargetLoS       = false;
            driver.activationRequiresAimConfirmation = false;
            driver.movementType                      = AISkillDriver.MovementType.Stop;
            driver.moveInputScale                    = 0f;
            driver.aimType                   = AISkillDriver.AimType.None;
            driver.ignoreNodeGraph           = true;
            driver.driverUpdateTimerOverride = 1f;
            driver.resetCurrentEnemyOnNextDriverSelection = false;
            driver.noRepeat            = false;
            driver.shouldSprint        = true;
            driver.shouldFireEquipment = false;
            driver.shouldTapButton     = false;


            _ = master.AddOrGetComponent <MinionOwnership>();


            AIOwnership aiOwnership = master.AddOrGetComponent <AIOwnership>();

            aiOwnership.ownerMaster = null;


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


            MastersCore.Add(master);

            return(master);
        }