public override void SetupBehavior() { base.SetupBehavior(); PermanentScannerPrefab = PrefabAPI.InstantiateClone(Resources.Load <GameObject>("Prefabs/NetworkedObjects/ChestScanner"), "Bulletstorm_ChestScanner", true); ChestRevealer chestRevealer = PermanentScannerPrefab.GetComponent <ChestRevealer>(); chestRevealer.radius = 1000; chestRevealer.pulseTravelSpeed = 1000; chestRevealer.revealDuration = 1; chestRevealer.pulseInterval = 10; chestRevealer.pulseEffectScale = 0; // a scale of zero should make it invisible //chestRevealer.pulseEffectPrefab = null; //throws an error if null if (ScanDuration <= 0) { chestRevealer.revealDuration = 99999; //~27 hours } else { chestRevealer.revealDuration = Mathf.Max(1, ScanDuration); } DestroyOnTimer destroyOnTimer = PermanentScannerPrefab.GetComponent <DestroyOnTimer>(); if (KeepScanningPastStart) { //UnityEngine.Object.Destroy(destroyOnTimer); destroyOnTimer.duration = 99999; } else { destroyOnTimer.duration = ScanDuration; } if (PermanentScannerPrefab) { PrefabAPI.RegisterNetworkPrefab(PermanentScannerPrefab); } if (Compat_ItemStats.enabled) { Compat_ItemStats.CreateItemStatDef(itemDef, ((count, inv, master) => { return(ScanChance + ScanChancePerStack * (count - 1)); }, (value, inv, master) => { return($"Scan Chance: {Pct(value)}"); } )); Compat_ItemStats.CreateItemStatDef(itemDef, ((count, inv, master) => { return(ScanDuration); }, (value, inv, master) => { string text = $"Scan Duration: "; text += ScanDuration == 0 ? $"27:00:00" : $"{GenTimeSpanFromSeconds(value)}"; return(text); } )); } }
public override void OnLoad() { base.OnLoad(); itemDef.name = "MysticsItems_DeathCeremony"; SetItemTierWhenAvailable(ItemTier.Tier2); itemDef.tags = new ItemTag[] { ItemTag.Damage }; itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Death Ceremony/Model.prefab")); HopooShaderToMaterial.Standard.Apply(itemDef.pickupModelPrefab.GetComponentInChildren <Renderer>().sharedMaterial); HopooShaderToMaterial.Standard.Emission(itemDef.pickupModelPrefab.GetComponentInChildren <Renderer>().sharedMaterial, 1f); itemDef.pickupIconSprite = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Death Ceremony/Icon.png"); itemDisplayPrefab = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false)); onSetupIDRS += () => { AddDisplayRule("CommandoBody", "CalfL", new Vector3(0.07748F, 0.19394F, -0.03508F), new Vector3(351.2407F, 38.31051F, 271.2653F), new Vector3(0.08418F, 0.08418F, 0.08418F)); AddDisplayRule("HuntressBody", "CalfL", new Vector3(0.01081F, 0.33039F, -0.04676F), new Vector3(271.8222F, -0.00021F, 329.7724F), new Vector3(0.07837F, 0.07837F, 0.07837F)); AddDisplayRule("Bandit2Body", "CalfL", new Vector3(0.03402F, 0.33989F, -0.05447F), new Vector3(275.6507F, 198.2068F, 136.1487F), new Vector3(0.07333F, 0.07333F, 0.07333F)); AddDisplayRule("ToolbotBody", "CalfL", new Vector3(-0.76507F, 2.13588F, -0.16809F), new Vector3(0F, 0F, 92.59356F), new Vector3(0.6665F, 0.6665F, 0.6665F)); AddDisplayRule("EngiBody", "CalfL", new Vector3(0.06642F, 0.07521F, -0.07491F), new Vector3(2.18099F, 54.26896F, 272.251F), new Vector3(0.07373F, 0.07373F, 0.07373F)); AddDisplayRule("EngiTurretBody", "LegBar2", new Vector3(-0.00001F, 0.25339F, 0.2332F), new Vector3(87.51187F, 180F, 180F), new Vector3(0.31299F, 0.31299F, 0.31299F)); AddDisplayRule("EngiWalkerTurretBody", "LegBar2", new Vector3(-0.00001F, 0.32614F, 0.3331F), new Vector3(80.43612F, 180F, 180F), new Vector3(0.35353F, 0.35353F, 0.35353F)); AddDisplayRule("MageBody", "CalfL", new Vector3(-0.05753F, 0.055F, -0.00398F), new Vector3(283.2863F, 250.2234F, 182.1714F), new Vector3(0.08759F, 0.08759F, 0.08759F)); AddDisplayRule("MercBody", "CalfL", new Vector3(0F, 0.06378F, -0.0637F), new Vector3(275.3986F, 0F, 0F), new Vector3(0.0835F, 0.0835F, 0.0835F)); AddDisplayRule("TreebotBody", "FootFrontL", new Vector3(-0.00003F, 0.2441F, -0.14866F), new Vector3(270.8983F, 0F, 0F), new Vector3(0.20205F, 0.20205F, 0.20205F)); AddDisplayRule("LoaderBody", "CalfL", new Vector3(0.10101F, 0.10896F, -0.05009F), new Vector3(286.7617F, 305.9382F, 3.19435F), new Vector3(0.10456F, 0.10456F, 0.10456F)); AddDisplayRule("CrocoBody", "CalfL", new Vector3(-0.72054F, 1.36348F, -0.3729F), new Vector3(355.4709F, 323.8942F, 83.82096F), new Vector3(0.78694F, 0.78694F, 0.78694F)); AddDisplayRule("CaptainBody", "CalfL", new Vector3(0F, 0.05716F, -0.09369F), new Vector3(287.3015F, 0F, 0F), new Vector3(0.10502F, 0.10502F, 0.10502F)); AddDisplayRule("BrotherBody", "CalfL", BrotherInfection.green, new Vector3(0.00384F, 0.00536F, -0.03235F), new Vector3(14.82572F, 260.7474F, 350.3363F), new Vector3(0.04861F, 0.10534F, 0.10724F)); AddDisplayRule("ScavBody", "CalfL", new Vector3(0.33272F, -0.17368F, -1.09799F), new Vector3(277.8127F, 180F, 165.8016F), new Vector3(1.08614F, 1.08614F, 1.08614F)); if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper) { AddDisplayRule("SniperClassicBody", "CalfL", new Vector3(-0.04687F, 0.03461F, 0.08856F), new Vector3(80.03226F, 0F, 32.95736F), new Vector3(0.07694F, 0.07694F, 0.07694F)); } AddDisplayRule("RailgunnerBody", "CalfL", new Vector3(0.07292F, 0.00507F, 0.09758F), new Vector3(65.51882F, 247.9167F, 209.6704F), new Vector3(0.10736F, 0.10736F, 0.10736F)); AddDisplayRule("VoidSurvivorBody", "ThighL", new Vector3(0.08283F, 0.31418F, 0.06681F), new Vector3(11.83692F, 314.669F, 281.4625F), new Vector3(0.09226F, 0.09226F, 0.09226F)); }; GameObject debuffedVFX = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Death Ceremony/MarkedVFX.prefab"); GameObject vfxOrigin = debuffedVFX.transform.Find("Origin").gameObject; vfxOrigin.transform.localScale *= 3f; CustomTempVFXManagement.MysticsRisky2UtilsTempVFX tempVFX = debuffedVFX.AddComponent <CustomTempVFXManagement.MysticsRisky2UtilsTempVFX>(); RotateAroundAxis rotateAroundAxis = vfxOrigin.gameObject.AddComponent <RotateAroundAxis>(); rotateAroundAxis.relativeTo = Space.Self; rotateAroundAxis.rotateAroundAxis = RotateAroundAxis.RotationAxis.X; rotateAroundAxis.fastRotationSpeed = 17f; rotateAroundAxis.speed = RotateAroundAxis.Speed.Fast; rotateAroundAxis = vfxOrigin.gameObject.AddComponent <RotateAroundAxis>(); rotateAroundAxis.relativeTo = Space.Self; rotateAroundAxis.rotateAroundAxis = RotateAroundAxis.RotationAxis.Z; rotateAroundAxis.fastRotationSpeed = 34f; rotateAroundAxis.speed = RotateAroundAxis.Speed.Fast; ObjectScaleCurve fadeOut = vfxOrigin.AddComponent <ObjectScaleCurve>(); fadeOut.overallCurve = new AnimationCurve { keys = new Keyframe[] { new Keyframe(0f, 1f, Mathf.Tan(180f * Mathf.Deg2Rad), Mathf.Tan(-20f * Mathf.Deg2Rad)), new Keyframe(1f, 0f, Mathf.Tan(160f * Mathf.Deg2Rad), 0f) } }; fadeOut.useOverallCurveOnly = true; fadeOut.enabled = false; fadeOut.timeMax = 0.2f; tempVFX.exitBehaviours = new MonoBehaviour[] { fadeOut }; ObjectScaleCurve fadeIn = vfxOrigin.AddComponent <ObjectScaleCurve>(); fadeIn.overallCurve = new AnimationCurve { keys = new Keyframe[] { new Keyframe(0f, 0f, Mathf.Tan(180f * Mathf.Deg2Rad), Mathf.Tan(70f * Mathf.Deg2Rad)), new Keyframe(1f, 1f, Mathf.Tan(-160f * Mathf.Deg2Rad), 0f) } }; fadeIn.useOverallCurveOnly = true; fadeIn.enabled = false; fadeIn.timeMax = 0.2f; tempVFX.enterBehaviours = new MonoBehaviour[] { fadeIn }; CustomTempVFXManagement.allVFX.Add(new CustomTempVFXManagement.VFXInfo { prefab = debuffedVFX, condition = (x) => { var component = x.GetComponent <MysticsItemsDeathCeremonyMark>(); if (component) { return(component.markTimer > 0f); } return(false); }, radius = CustomTempVFXManagement.DefaultRadiusCall }); damageShareOrbEffect = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Death Ceremony/DeathCeremonyOrbEffect.prefab"); EffectComponent effectComponent = damageShareOrbEffect.AddComponent <EffectComponent>(); effectComponent.positionAtReferencedTransform = false; effectComponent.parentToReferencedTransform = false; effectComponent.applyScale = true; VFXAttributes vfxAttributes = damageShareOrbEffect.AddComponent <VFXAttributes>(); vfxAttributes.vfxPriority = VFXAttributes.VFXPriority.Low; vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.Low; OrbEffect orbEffect = damageShareOrbEffect.AddComponent <OrbEffect>(); orbEffect.startVelocity1 = new Vector3(-10f, 0f, -10f); orbEffect.startVelocity2 = new Vector3(-10f, 10f, 10f); orbEffect.endVelocity1 = new Vector3(-10f, 0f, -10f); orbEffect.endVelocity2 = new Vector3(10f, 10f, 10f); orbEffect.movementCurve = new AnimationCurve { keys = new Keyframe[] { new Keyframe(0f, 0f), new Keyframe(1f, 1f) }, preWrapMode = WrapMode.Clamp, postWrapMode = WrapMode.Clamp }; orbEffect.faceMovement = true; orbEffect.callArrivalIfTargetIsGone = false; DestroyOnTimer destroyOnTimer = damageShareOrbEffect.transform.Find("Trail").gameObject.AddComponent <DestroyOnTimer>(); destroyOnTimer.duration = 0.5f; destroyOnTimer.enabled = false; MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsOrbEffectOnArrivalDefaults onArrivalDefaults = damageShareOrbEffect.AddComponent <MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsOrbEffectOnArrivalDefaults>(); onArrivalDefaults.orbEffect = orbEffect; onArrivalDefaults.transformsToUnparentChildren = new Transform[] { damageShareOrbEffect.transform }; onArrivalDefaults.componentsToEnable = new MonoBehaviour[] { destroyOnTimer }; MysticsItemsContent.Resources.effectPrefabs.Add(damageShareOrbEffect); CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal; GenericGameEvents.OnHitEnemy += GenericGameEvents_OnHitEnemy; R2API.RecalculateStatsAPI.GetStatCoefficients += RecalculateStatsAPI_GetStatCoefficients; }
internal static GameObject CreateSmallAmmoTracer(Material mainMat, Material trailMat) { GameObject obj = PrefabsCore.CreatePrefab("Standard Tracer", false); Transform tracerHead = new GameObject("TracerHead").transform; tracerHead.parent = obj.transform; tracerHead.localPosition = Vector3.zero; tracerHead.localRotation = Quaternion.identity; //tracerHead.localEulerAngles = new Vector3( 0f, 90f, 0f ); tracerHead.localScale = Vector3.one; Transform tracerTail = new GameObject("TracerTail").transform; tracerTail.parent = obj.transform; tracerTail.localPosition = Vector3.zero; tracerTail.localRotation = Quaternion.identity; tracerTail.localScale = Vector3.one; Transform trail = new GameObject("trail").transform; trail.parent = tracerTail; trail.localPosition = Vector3.zero; trail.localRotation = Quaternion.identity; trail.localScale = Vector3.one; Transform headBeam = new GameObject("HeadBeam").transform; headBeam.parent = tracerTail; headBeam.localPosition = Vector3.zero; headBeam.localEulerAngles = new Vector3(0f, 90f, 0f); headBeam.localScale = Vector3.one; EffectComponent effectComp = obj.AddComponent <EffectComponent>(); Tracer tracer = obj.AddComponent <Tracer>(); VFXAttributes vfxAtrib = obj.AddComponent <VFXAttributes>(); Rigidbody headRb = tracerHead.AddComponent <Rigidbody>(); Rigidbody tailRb = tracerTail.AddComponent <Rigidbody>(); ParticleSystem mainPs = headBeam.AddComponent <ParticleSystem>(); ParticleSystemRenderer mainPsr = headBeam.AddOrGetComponent <ParticleSystemRenderer>(); ParticleSystem trailPs = trail.AddComponent <ParticleSystem>(); ParticleSystemRenderer trailPsr = trail.AddOrGetComponent <ParticleSystemRenderer>(); DestroyTracerOnDelay cleanup = obj.AddComponent <DestroyTracerOnDelay>(); cleanup.delay = 2f; cleanup.tracer = tracer; ZeroTracerLengthOverDuration zeroLength = obj.AddComponent <ZeroTracerLengthOverDuration>(); zeroLength.tracer = tracer; DestroyOnTimer timer = obj.AddComponent <DestroyOnTimer>(); timer.duration = 10f; effectComp.effectIndex = EffectIndex.Invalid; effectComp.positionAtReferencedTransform = false; effectComp.parentToReferencedTransform = false; effectComp.applyScale = false; effectComp.soundName = null; effectComp.disregardZScale = false; tracer.startTransform = null; tracer.beamObject = null; tracer.beamDensity = 0f; tracer.speed = 600f; tracer.headTransform = tracerHead; tracer.tailTransform = tracerTail; tracer.length = 20f; tracer.reverse = false; headRb.isKinematic = true; headRb.useGravity = false; tailRb.isKinematic = true; tailRb.useGravity = false; vfxAtrib.optionalLights = null; vfxAtrib.secondaryParticleSystem = null; vfxAtrib.vfxIntensity = VFXAttributes.VFXIntensity.Low; vfxAtrib.vfxPriority = VFXAttributes.VFXPriority.Always; mainPs.PlayOnStart(); mainPs.SetupSmallTracerMain(); mainPs.SetupSmallTracerEmission(); mainPs.SetupSmallTracerShape(); mainPs.SetupSmallTracerColorOverLifetime(); mainPs.SetupSmallTracerSizeOverLifetime(); mainPsr.SetupSmallTracerRenderer(mainMat); ParticleSystem.VelocityOverLifetimeModule mainPsVol = mainPs.velocityOverLifetime; mainPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule mainPsLvol = mainPs.limitVelocityOverLifetime; mainPsLvol.enabled = false; ParticleSystem.InheritVelocityModule mainPsIvel = mainPs.inheritVelocity; mainPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule mainPsFol = mainPs.forceOverLifetime; mainPsFol.enabled = false; ParticleSystem.ColorBySpeedModule mainPsCbs = mainPs.colorBySpeed; mainPsCbs.enabled = false; ParticleSystem.SizeBySpeedModule mainPsSbs = mainPs.sizeBySpeed; mainPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule mainPsRol = mainPs.rotationOverLifetime; mainPsRol.enabled = false; ParticleSystem.RotationBySpeedModule mainPsRbs = mainPs.rotationBySpeed; mainPsRbs.enabled = false; ParticleSystem.ExternalForcesModule mainPsExt = mainPs.externalForces; mainPsExt.enabled = false; ParticleSystem.NoiseModule mainPsNoise = mainPs.noise; mainPsNoise.enabled = false; ParticleSystem.CollisionModule mainPsColl = mainPs.collision; mainPsColl.enabled = false; ParticleSystem.TriggerModule mainPsTrig = mainPs.trigger; mainPsTrig.enabled = false; ParticleSystem.SubEmittersModule mainPsSub = mainPs.subEmitters; mainPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule mainPsTex = mainPs.textureSheetAnimation; mainPsTex.enabled = false; ParticleSystem.LightsModule mainPsLight = mainPs.lights; mainPsLight.enabled = false; ParticleSystem.TrailModule mainPsTrail = mainPs.trails; mainPsTrail.enabled = false; ParticleSystem.CustomDataModule mainPsData = mainPs.customData; mainPsData.enabled = false; trailPs.PlayOnStart(); trailPs.SetupSmallTracerTrailMain(); trailPs.SetupSmallTracerTrailEmission(); trailPs.SetupSmallTracerTrailNoise(); trailPs.SetupSmallTracerTrailTrail(); trailPsr.SetupSmallTracerTrailRenderer(trailMat); ParticleSystem.ShapeModule trailPsShape = trailPs.shape; trailPsShape.enabled = false; ParticleSystem.VelocityOverLifetimeModule trailPsVol = trailPs.velocityOverLifetime; trailPsVol.enabled = false; ParticleSystem.LimitVelocityOverLifetimeModule trailPsLvol = trailPs.limitVelocityOverLifetime; trailPsLvol.enabled = false; ParticleSystem.InheritVelocityModule trailPsIvel = trailPs.inheritVelocity; trailPsIvel.enabled = false; ParticleSystem.ForceOverLifetimeModule trailPsFol = trailPs.forceOverLifetime; trailPsFol.enabled = false; ParticleSystem.ColorOverLifetimeModule trailPsCol = trailPs.colorOverLifetime; trailPsCol.enabled = false; ParticleSystem.ColorBySpeedModule trailPsCbs = trailPs.colorBySpeed; trailPsCbs.enabled = false; ParticleSystem.SizeOverLifetimeModule trailPsSol = trailPs.sizeOverLifetime; trailPsSol.enabled = false; ParticleSystem.SizeBySpeedModule trailPsSbs = trailPs.sizeBySpeed; trailPsSbs.enabled = false; ParticleSystem.RotationOverLifetimeModule trailPsRol = trailPs.rotationOverLifetime; trailPsRol.enabled = false; ParticleSystem.RotationBySpeedModule trailPsRbs = trailPs.rotationBySpeed; trailPsRbs.enabled = false; ParticleSystem.ExternalForcesModule trailPsExt = trailPs.externalForces; trailPsExt.enabled = false; ParticleSystem.NoiseModule trailPsNoise = trailPs.noise; trailPsNoise.enabled = true; ParticleSystem.CollisionModule trailPsColl = trailPs.collision; trailPsColl.enabled = false; ParticleSystem.TriggerModule trailPsTrig = trailPs.trigger; trailPsTrig.enabled = false; ParticleSystem.SubEmittersModule trailPsSub = trailPs.subEmitters; trailPsSub.enabled = false; ParticleSystem.TextureSheetAnimationModule trailPsTex = trailPs.textureSheetAnimation; trailPsTex.enabled = false; ParticleSystem.LightsModule trailPsLigh = trailPs.lights; trailPsLigh.enabled = false; ParticleSystem.CustomDataModule trailPsData = trailPs.customData; trailPsData.enabled = false; return(obj); }
public override void OnLoad() { base.OnLoad(); itemDef.name = "MysticsItems_ExplosivePickups"; SetItemTierWhenAvailable(ItemTier.Tier2); itemDef.tags = new ItemTag[] { ItemTag.Utility, ItemTag.OnKillEffect }; itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Contraband Gunpowder/Model.prefab")); itemDef.pickupIconSprite = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Contraband Gunpowder/Icon.png"); HopooShaderToMaterial.Standard.Apply(itemDef.pickupModelPrefab.transform.Find("мешок").Find("порох").GetComponent <MeshRenderer>().sharedMaterial); HopooShaderToMaterial.Standard.Apply(itemDef.pickupModelPrefab.transform.Find("мешок").GetComponent <MeshRenderer>().sharedMaterial); HopooShaderToMaterial.Standard.Apply(itemDef.pickupModelPrefab.transform.Find("мешок").Find("верёвка").GetComponent <MeshRenderer>().sharedMaterial); HopooShaderToMaterial.Standard.Gloss(itemDef.pickupModelPrefab.transform.Find("мешок").Find("порох").GetComponent <MeshRenderer>().sharedMaterial, 0f); HopooShaderToMaterial.Standard.Gloss(itemDef.pickupModelPrefab.transform.Find("мешок").GetComponent <MeshRenderer>().sharedMaterial, 0f); HopooShaderToMaterial.Standard.Gloss(itemDef.pickupModelPrefab.transform.Find("мешок").Find("верёвка").GetComponent <MeshRenderer>().sharedMaterial, 0.4f); itemDisplayPrefab = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false)); onSetupIDRS += () => { AddDisplayRule("CommandoBody", "Stomach", new Vector3(-0.175F, 0.066F, 0.045F), new Vector3(16.687F, 66.665F, 36.228F), new Vector3(0.042F, 0.042F, 0.042F)); AddDisplayRule("HuntressBody", "Pelvis", new Vector3(-0.12F, -0.064F, -0.052F), new Vector3(355.162F, 32.177F, 180.96F), new Vector3(0.042F, 0.042F, 0.042F)); AddDisplayRule("Bandit2Body", "Stomach", new Vector3(0.156F, 0.031F, 0.127F), new Vector3(350.191F, 244.703F, 340.178F), new Vector3(0.037F, 0.037F, 0.037F)); AddDisplayRule("ToolbotBody", "Chest", new Vector3(-0.837F, 1.169F, 3.112F), new Vector3(29.795F, 9.384F, 2.716F), new Vector3(0.489F, 0.489F, 0.489F)); AddDisplayRule("EngiBody", "Pelvis", new Vector3(-0.206F, 0.04F, -0.104F), new Vector3(4.991F, 46.464F, 181.437F), new Vector3(0.065F, 0.065F, 0.065F)); AddDisplayRule("EngiTurretBody", "Head", new Vector3(0.834F, 0.462F, 0.717F), new Vector3(33.04F, 48.09F, 359.072F), new Vector3(0.168F, 0.168F, 0.168F)); AddDisplayRule("EngiWalkerTurretBody", "Head", new Vector3(0.715F, 0.235F, 0.228F), new Vector3(22.677F, 152.024F, 24.393F), new Vector3(0.134F, 0.163F, 0.131F)); AddDisplayRule("MageBody", "Pelvis", new Vector3(-0.058F, 0F, -0.164F), new Vector3(0.366F, 347.899F, 165.881F), new Vector3(0.044F, 0.044F, 0.044F)); AddDisplayRule("MercBody", "ThighR", new Vector3(-0.077F, 0.008F, 0.041F), new Vector3(15.315F, 124.284F, 220.104F), new Vector3(0.034F, 0.034F, 0.034F)); AddDisplayRule("TreebotBody", "FlowerBase", new Vector3(-0.062F, -0.523F, -1.156F), new Vector3(41.662F, 244.258F, 1.504F), new Vector3(0.107F, 0.107F, 0.107F)); AddDisplayRule("LoaderBody", "MechBase", new Vector3(0.07F, 0.023F, 0.444F), new Vector3(7.628F, 218.893F, 342.184F), new Vector3(0.054F, 0.054F, 0.054F)); AddDisplayRule("CrocoBody", "SpineChest2", new Vector3(0.779F, 1.753F, -0.514F), new Vector3(337.83F, 226.76F, 273.311F), new Vector3(0.411F, 0.411F, 0.411F)); AddDisplayRule("CaptainBody", "Stomach", new Vector3(-0.102F, 0.12F, 0.147F), new Vector3(11.46F, 212.011F, 335.706F), new Vector3(0.053F, 0.048F, 0.053F)); AddDisplayRule("BrotherBody", "Stomach", BrotherInfection.green, new Vector3(-0.18F, 0.131F, 0.075F), new Vector3(303.36F, 82.78F, 283.641F), new Vector3(0.063F, 0.063F, 0.063F)); AddDisplayRule("ScavBody", "MuzzleEnergyCannon", new Vector3(0.586F, 3.872F, 0.073F), new Vector3(54.107F, 148.5F, 149.008F), new Vector3(0.835F, 0.858F, 0.835F)); if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper) { AddDisplayRule("SniperClassicBody", "Pelvis", new Vector3(-0.19573F, 0.1786F, -0.09573F), new Vector3(4.5648F, 55.41101F, 9.99794F), new Vector3(0.053F, 0.053F, 0.053F)); } AddDisplayRule("RailgunnerBody", "Pelvis", new Vector3(-0.15453F, 0.10747F, -0.16311F), new Vector3(359.8358F, 321.1621F, 178.6592F), new Vector3(0.05825F, 0.05825F, 0.05825F)); AddDisplayRule("VoidSurvivorBody", "Neck", new Vector3(0.08624F, 0.00251F, 0.20226F), new Vector3(23.68506F, 25.82453F, 8.87328F), new Vector3(0.062F, 0.062F, 0.062F)); }; MysticsRisky2Utils.Utils.CopyChildren(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Contraband Gunpowder/ExplosivePack.prefab"), gunpowderPickup); gunpowderPickup.transform.localScale *= 0.33f; gunpowderPickup.layer = LayerIndex.debris.intVal; DestroyOnTimer destroyOnTimer = gunpowderPickup.AddComponent <DestroyOnTimer>(); destroyOnTimer.duration = 60f; destroyOnTimer.resetAgeOnDisable = false; BeginRapidlyActivatingAndDeactivating blink = gunpowderPickup.AddComponent <BeginRapidlyActivatingAndDeactivating>(); blink.blinkFrequency = 20f; blink.delayBeforeBeginningBlinking = destroyOnTimer.duration - 1f; blink.blinkingRootObject = gunpowderPickup.transform.Find("мешок").gameObject; Rigidbody rigidbody = gunpowderPickup.GetComponent <Rigidbody>(); VelocityRandomOnStart velocity = gunpowderPickup.AddComponent <VelocityRandomOnStart>(); velocity.minSpeed = 10f; velocity.maxSpeed = 20f; velocity.baseDirection = Vector3.up; velocity.localDirection = false; velocity.directionMode = VelocityRandomOnStart.DirectionMode.Cone; velocity.coneAngle = 15f; velocity.maxAngularSpeed = velocity.minAngularSpeed = 0f; gunpowderPickup.AddComponent <RoR2.Projectile.ProjectileNetworkTransform>(); TeamFilter teamFilter = gunpowderPickup.AddComponent <TeamFilter>(); GameObject pickupTrigger = gunpowderPickup.transform.Find("PickupTrigger").gameObject; pickupTrigger.layer = LayerIndex.pickups.intVal; pickupTrigger.AddComponent <TeamFilter>(); ExplosivePack explosivePack = pickupTrigger.AddComponent <ExplosivePack>(); explosivePack.baseObject = gunpowderPickup; explosivePack.teamFilter = teamFilter; GameObject gravitationController = gunpowderPickup.transform.Find("GravitationController").gameObject; ExplosivePackGravitate gravitatePickup = gravitationController.AddComponent <ExplosivePackGravitate>(); gravitatePickup.rigidbody = rigidbody; gravitatePickup.teamFilter = teamFilter; gravitatePickup.acceleration = 5f; gravitatePickup.maxSpeed = 40f; /* * explosionPrefab = Main.AssetBundle.LoadAsset<GameObject>("Assets/Items/Contraband Gunpowder/Explosion.prefab"); * EffectComponent effectComponent = explosionPrefab.AddComponent<EffectComponent>(); * effectComponent.applyScale = true; * effectComponent.soundName = "Play_mage_m1_impact"; * VFXAttributes vfxAttributes = explosionPrefab.AddComponent<VFXAttributes>(); * vfxAttributes.vfxPriority = VFXAttributes.VFXPriority.Medium; * vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.Medium; * vfxAttributes.optionalLights = new Light[] * { * explosionPrefab.transform.Find("Point Light").gameObject.GetComponent<Light>() * }; * vfxAttributes.secondaryParticleSystem = new ParticleSystem[] * { * explosionPrefab.transform.Find("Big Circle").gameObject.GetComponent<ParticleSystem>(), * explosionPrefab.transform.Find("Small Circles").gameObject.GetComponent<ParticleSystem>() * }; * DestroyOnTimer destroyOnTimer1 = explosionPrefab.AddComponent<DestroyOnTimer>(); * destroyOnTimer1.duration = 2f; * ShakeEmitter shakeEmitter = explosionPrefab.AddComponent<ShakeEmitter>(); * shakeEmitter.shakeOnStart = true; * shakeEmitter.wave = new Wave * { * amplitude = 1f, * frequency = 180f, * cycleOffset = 0f * }; * shakeEmitter.duration = 0.15f; * shakeEmitter.radius = 10f; * shakeEmitter.scaleShakeRadiusWithLocalScale = true; * shakeEmitter.amplitudeTimeDecay = true; * explosionPrefab.transform.Find("Point Light").gameObject.GetComponent<Light>().gameObject.AddComponent<MysticsItemsScaleLight>(); * * AssetManager.RegisterEffect(explosionPrefab); */ explosionPrefab = PrefabAPI.InstantiateClone(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Contraband Gunpowder/Explosion.prefab"), "MysticsItems_OmniExplosionVFXExplosivePickups", false); ConfigOptions.ConfigurableValue.CreateBool( ConfigManager.General.categoryGUID, ConfigManager.General.categoryName, ConfigManager.General.config, "Effects", "Reduce Contraband Gunpowder VFX", false, "Reduce the visual effects of Contraband Gunpowder explosions", onChanged: (newValue) => { explosionPrefab.transform.Find("Light Flash").gameObject.SetActive(!newValue); explosionPrefab.transform.Find("Sparks").gameObject.SetActive(!newValue); explosionPrefab.transform.Find("Swirls").gameObject.SetActive(!newValue); } ); VFXAttributes vfxAttributes = explosionPrefab.AddComponent <VFXAttributes>(); vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.High; vfxAttributes.vfxPriority = VFXAttributes.VFXPriority.Always; EffectComponent effectComponent = explosionPrefab.AddComponent <EffectComponent>(); effectComponent.applyScale = true; ConfigOptions.ConfigurableValue.CreateBool( ConfigManager.General.categoryGUID, ConfigManager.General.categoryName, ConfigManager.General.config, "Effects", "Disable Contraband Gunpowder SFX", false, "Disable the sound effects of Contraband Gunpowder explosions", onChanged: (newValue) => { effectComponent.soundName = newValue ? "" : "MysticsItems_Play_item_proc_gunpowder"; } ); explosionPrefab.AddComponent <DestroyOnTimer>().duration = 2f; ShakeEmitter shakeEmitter = explosionPrefab.AddComponent <ShakeEmitter>(); shakeEmitter.duration = 0.1f; shakeEmitter.scaleShakeRadiusWithLocalScale = true; shakeEmitter.amplitudeTimeDecay = true; shakeEmitter.radius = 1.5f; shakeEmitter.shakeOnStart = true; ConfigOptions.ConfigurableValue.CreateFloat( ConfigManager.General.categoryGUID, ConfigManager.General.categoryName, ConfigManager.General.config, "Effects", "Contraband Gunpowder Screenshake", 1f, 0f, 1f, "Adjust the intensity of Contraband Gunpowder explosion screenshake", onChanged: (newValue) => { shakeEmitter.wave = new Wave { amplitude = 9f * newValue, frequency = 4f * newValue }; } ); MysticsItemsContent.Resources.effectPrefabs.Add(explosionPrefab); /* * Main.OnHitEnemy += delegate (DamageInfo damageInfo, Main.GenericCharacterInfo attackerInfo, Main.GenericCharacterInfo victimInfo) * { * if (NetworkServer.active) * { * if (attackerInfo.inventory && attackerInfo.inventory.GetItemCount(itemIndex) > 0) * { * if (Util.CheckRoll(7f, attackerInfo.master)) * { * GameObject gameObject = Object.Instantiate(gunpowderPickup, damageInfo.position, Quaternion.identity); * gameObject.GetComponent<TeamFilter>().teamIndex = attackerInfo.teamIndex; * NetworkServer.Spawn(gameObject); * } * } * } * }; */ On.RoR2.CharacterBody.HandleOnKillEffectsServer += (orig, self, damageReport) => { orig(self, damageReport); if (self.inventory && self.inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_ExplosivePickups) > 0 && self.master && Util.CheckRoll(flaskDropChance, self.master)) { GameObject gameObject = Object.Instantiate(gunpowderPickup, Util.GetCorePosition(damageReport.victim.gameObject), Quaternion.Euler(Random.onUnitSphere.normalized)); gameObject.GetComponent <TeamFilter>().teamIndex = TeamComponent.GetObjectTeam(self.gameObject); NetworkServer.Spawn(gameObject); } }; IL.RoR2.HealthPickup.OnTriggerStay += (il) => { ILCursor c = new ILCursor(il); if (c.TryGotoNext( MoveType.After, x => x.MatchLdarg(0), x => x.MatchLdfld <HealthPickup>("baseObject"), x => x.MatchCallOrCallvirt <Object>("Destroy") )) { c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldarg_1); c.EmitDelegate <System.Action <MonoBehaviour, Collider> >((pickup, collider) => { CharacterBody body = collider.GetComponent <CharacterBody>(); if (body) { Inventory inventory = body.inventory; if (inventory && inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_ExplosivePickups) > 0) { Explode(body); } } }); } }; IL.RoR2.MoneyPickup.OnTriggerStay += (il) => { ILCursor c = new ILCursor(il); if (c.TryGotoNext( MoveType.After, x => x.MatchLdarg(0), x => x.MatchLdfld <MoneyPickup>("baseObject"), x => x.MatchCallOrCallvirt <Object>("Destroy") )) { c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldarg_1); c.EmitDelegate <System.Action <MonoBehaviour, Collider> >((pickup, collider) => { CharacterBody body = collider.GetComponent <CharacterBody>(); if (body) { Inventory inventory = body.inventory; if (inventory && inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_ExplosivePickups) > 0) { Explode(body); } } }); } }; IL.RoR2.BuffPickup.OnTriggerStay += (il) => { ILCursor c = new ILCursor(il); if (c.TryGotoNext( MoveType.After, x => x.MatchLdarg(0), x => x.MatchLdfld <BuffPickup>("baseObject"), x => x.MatchCallOrCallvirt <Object>("Destroy") )) { c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldarg_1); c.EmitDelegate <System.Action <MonoBehaviour, Collider> >((pickup, collider) => { CharacterBody body = collider.GetComponent <CharacterBody>(); if (body) { Inventory inventory = body.inventory; if (inventory && inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_ExplosivePickups) > 0) { Explode(body); } } }); } }; IL.RoR2.AmmoPickup.OnTriggerStay += (il) => { ILCursor c = new ILCursor(il); if (c.TryGotoNext( MoveType.After, x => x.MatchLdarg(0), x => x.MatchLdfld <AmmoPickup>("baseObject"), x => x.MatchCallOrCallvirt <Object>("Destroy") )) { c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldarg_1); c.EmitDelegate <System.Action <MonoBehaviour, Collider> >((pickup, collider) => { CharacterBody body = collider.GetComponent <CharacterBody>(); if (body) { Inventory inventory = body.inventory; if (inventory && inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_ExplosivePickups) > 0) { Explode(body); } } }); } }; }
public override void OnLoad() { base.OnLoad(); itemDef.name = "MysticsItems_MysticSword"; SetItemTierWhenAvailable(ItemTier.Tier2); itemDef.tags = new ItemTag[] { ItemTag.Damage, ItemTag.OnKillEffect, ItemTag.AIBlacklist }; itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Mystic Sword/Model.prefab")); itemDef.pickupIconSprite = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Mystic Sword/Icon.png"); var mat = itemDef.pickupModelPrefab.GetComponentInChildren <Renderer>().sharedMaterial; HopooShaderToMaterial.Standard.Apply(mat); HopooShaderToMaterial.Standard.Emission(mat, 1f, new Color32(0, 250, 255, 255)); itemDef.pickupModelPrefab.transform.Find("GameObject").localScale *= 0.1f; var swordFollowerPrefab = PrefabAPI.InstantiateClone(PrepareItemDisplayModel(PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Mystic Sword/DisplayModel.prefab"))), "MysticsItems_MysticSwordItemFollowerPrefab", false); swordFollowerPrefab.transform.Find("TranslatePivot").transform.localScale *= 0.02f; ObjectTransformCurve objectTransformCurve = swordFollowerPrefab.transform.Find("TranslatePivot").gameObject.AddComponent <ObjectTransformCurve>(); objectTransformCurve.translationCurveX = AnimationCurve.Constant(0f, 1f, 0f); var floatY = 0.1f; objectTransformCurve.translationCurveY = new AnimationCurve { keys = new Keyframe[] { new Keyframe(0.25f, floatY), new Keyframe(0.75f, -floatY) }, preWrapMode = WrapMode.PingPong, postWrapMode = WrapMode.PingPong }; objectTransformCurve.translationCurveZ = AnimationCurve.Constant(0f, 1f, 0f); objectTransformCurve.useTranslationCurves = true; objectTransformCurve.timeMax = 10f; objectTransformCurve.rotationCurveX = AnimationCurve.Constant(0f, 1f, 0f); objectTransformCurve.rotationCurveY = AnimationCurve.Linear(0f, 0f, 1f, 360f); objectTransformCurve.rotationCurveY.preWrapMode = WrapMode.Loop; objectTransformCurve.rotationCurveY.postWrapMode = WrapMode.Loop; objectTransformCurve.rotationCurveZ = AnimationCurve.Constant(0f, 1f, 0f); objectTransformCurve.useRotationCurves = true; objectTransformCurve.gameObject.AddComponent <MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsObjectTransformCurveLoop>(); itemDisplayPrefab = PrefabAPI.InstantiateClone(new GameObject("MysticsItems_MysticSwordFollower"), "MysticsItems_MysticSwordFollower", false); itemDisplayPrefab.AddComponent <ItemDisplay>(); ItemFollower itemFollower = itemDisplayPrefab.AddComponent <ItemFollower>(); itemFollower.followerPrefab = swordFollowerPrefab; itemFollower.distanceDampTime = 0.1f; itemFollower.distanceMaxSpeed = 20f; itemFollower.targetObject = itemDisplayPrefab; var itemDisplayHelper = itemDisplayPrefab.AddComponent <MysticsItemsMysticSwordItemDisplayHelper>(); itemDisplayHelper.itemFollower = itemFollower; onSetupIDRS += () => { AddDisplayRule("CommandoBody", "Base", new Vector3(0.17794F, -0.28733F, -0.73752F), new Vector3(3.15473F, 89.99998F, 270.0002F), Vector3.one); AddDisplayRule("HuntressBody", "Base", new Vector3(0.17816F, -0.23663F, -0.52846F), new Vector3(2.42504F, 269.9999F, 90.0001F), Vector3.one); AddDisplayRule("Bandit2Body", "Base", new Vector3(0.4537F, 0.29041F, -0.57258F), new Vector3(270F, 0F, 0F), Vector3.one); AddDisplayRule("ToolbotBody", "Base", new Vector3(-1.04879F, -4.19278F, 5.42458F), new Vector3(0F, 90F, 90F), Vector3.one); AddDisplayRule("EngiBody", "Base", new Vector3(0.0113F, -0.52335F, -0.69199F), new Vector3(270F, 0F, 0F), Vector3.one); AddDisplayRule("EngiTurretBody", "Base", new Vector3(1.03266F, 3.98892F, -2.18302F), new Vector3(0F, 90F, 0F), Vector3.one); AddDisplayRule("EngiWalkerTurretBody", "Base", new Vector3(1.53037F, 3.79942F, -2.10391F), new Vector3(0F, 90F, 0F), Vector3.one); AddDisplayRule("MageBody", "Base", new Vector3(0.38669F, -0.43447F, -0.48611F), new Vector3(270F, 0F, 0F), Vector3.one); AddDisplayRule("MercBody", "Base", new Vector3(0.38005F, -0.35752F, -0.53391F), new Vector3(270F, 0F, 0F), Vector3.one); AddDisplayRule("TreebotBody", "Base", new Vector3(0.69145F, -1.39195F, -1.94014F), new Vector3(270F, 0F, 0F), Vector3.one * 1f); AddDisplayRule("LoaderBody", "Base", new Vector3(0.26563F, -0.57799F, -0.60309F), new Vector3(270F, 0F, 0F), Vector3.one); AddDisplayRule("CrocoBody", "Base", new Vector3(2.43278F, 4.85691F, 4.92643F), new Vector3(90F, 0F, 0F), Vector3.one * 1f); AddDisplayRule("CaptainBody", "Base", new Vector3(0.52281F, -0.26508F, -0.8575F), new Vector3(270F, 0F, 0F), Vector3.one); AddDisplayRule("BrotherBody", "HandR", BrotherInfection.green, new Vector3(-0.00915F, 0.08592F, 0.02786F), new Vector3(77.05167F, 128.9087F, 289.6218F), new Vector3(0.06672F, 0.02927F, 0.06676F)); AddDisplayRule("ScavBody", "Base", new Vector3(4.53188F, 14.35975F, 10.88982F), new Vector3(90F, 0F, 0F), Vector3.one * 2f); if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper) { AddDisplayRule("SniperClassicBody", "Base", new Vector3(-0.74382F, 1.77236F, -0.52436F), new Vector3(0F, 0F, 0F), new Vector3(1F, 1F, 1F)); } AddDisplayRule("RailgunnerBody", "Base", new Vector3(0.25904F, -0.39171F, -0.30991F), new Vector3(270F, 0F, 0F), new Vector3(1F, 1F, 1F)); AddDisplayRule("VoidSurvivorBody", "Base", new Vector3(0.4739F, 0.74488F, 0.37712F), new Vector3(68.90421F, 0F, 0F), new Vector3(1F, 1F, 1F) * 0.8f); }; { onKillVFX = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Mystic Sword/SwordPowerUpKillEffect.prefab"); EffectComponent effectComponent = onKillVFX.AddComponent <EffectComponent>(); effectComponent.applyScale = true; VFXAttributes vfxAttributes = onKillVFX.AddComponent <VFXAttributes>(); vfxAttributes.vfxPriority = VFXAttributes.VFXPriority.Medium; vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.Medium; onKillVFX.AddComponent <DestroyOnTimer>().duration = 1f; MysticsItemsContent.Resources.effectPrefabs.Add(onKillVFX); } { onKillOrbEffect = Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Mystic Sword/SwordPowerUpOrbEffect.prefab"); EffectComponent effectComponent = onKillOrbEffect.AddComponent <EffectComponent>(); effectComponent.positionAtReferencedTransform = false; effectComponent.parentToReferencedTransform = false; effectComponent.applyScale = true; VFXAttributes vfxAttributes = onKillOrbEffect.AddComponent <VFXAttributes>(); vfxAttributes.vfxPriority = VFXAttributes.VFXPriority.Always; vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.Medium; OrbEffect orbEffect = onKillOrbEffect.AddComponent <OrbEffect>(); orbEffect.startVelocity1 = new Vector3(-25f, 5f, -25f); orbEffect.startVelocity2 = new Vector3(25f, 50f, 25f); orbEffect.endVelocity1 = new Vector3(0f, 0f, 0f); orbEffect.endVelocity2 = new Vector3(0f, 0f, 0f); var curveHolder = onKillVFX.transform.Find("Origin/Particle System").GetComponent <ParticleSystem>().sizeOverLifetime; orbEffect.movementCurve = curveHolder.size.curve; orbEffect.faceMovement = true; orbEffect.callArrivalIfTargetIsGone = false; DestroyOnTimer destroyOnTimer = onKillOrbEffect.transform.Find("Origin/Unparent").gameObject.AddComponent <DestroyOnTimer>(); destroyOnTimer.duration = 0.5f; destroyOnTimer.enabled = false; MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsOrbEffectOnArrivalDefaults onArrivalDefaults = onKillOrbEffect.AddComponent <MysticsRisky2Utils.MonoBehaviours.MysticsRisky2UtilsOrbEffectOnArrivalDefaults>(); onArrivalDefaults.orbEffect = orbEffect; onArrivalDefaults.transformsToUnparentChildren = new Transform[] { onKillOrbEffect.transform.Find("Origin/Unparent") }; onArrivalDefaults.componentsToEnable = new MonoBehaviour[] { destroyOnTimer }; MysticsItemsContent.Resources.effectPrefabs.Add(onKillOrbEffect); } onKillSFX = ScriptableObject.CreateInstance <NetworkSoundEventDef>(); onKillSFX.eventName = "MysticsItems_Play_item_proc_MysticSword"; MysticsItemsContent.Resources.networkSoundEventDefs.Add(onKillSFX); CharacterMaster.onStartGlobal += CharacterMaster_onStartGlobal; GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal; RecalculateStatsAPI.GetStatCoefficients += RecalculateStatsAPI_GetStatCoefficients; if (!SoftDependencies.SoftDependenciesCore.itemStatsEnabled) { On.RoR2.UI.ItemIcon.SetItemIndex += ItemIcon_SetItemIndex; } GenericGameEvents.BeforeTakeDamage += GenericGameEvents_BeforeTakeDamage; MysticsItemsMysticSwordItemDisplayHelper.materialFlash = LegacyResourcesAPI.Load <Material>("Materials/matHuntressFlashBright"); MysticsItemsMysticSwordItemDisplayHelper.blinkEffect = Addressables.LoadAssetAsync <GameObject>("RoR2/Base/Huntress/HuntressBlinkEffect.prefab").WaitForCompletion(); }