public void AddHitEffect() { if (!Utils.GetTheGame().bEffectsOn) { return; } Random knark = Utils.GetTheGame().randomInVisual; Vector2 v2Orig = xOwner.xTransform.v2Pos + new Vector2(0f, -3f); for (int i = 0; i < 6; i++) { Vector2 v2RandDir = new Vector2(-1f + (float)knark.NextDouble() * 2f, -1f + (float)knark.NextDouble() * 2f); if (v2RandDir == Vector2.Zero) { v2RandDir = new Vector2(1f, 0f); } v2RandDir = v2RandDir.SafeNormalized(); SortedAnimated.SortedAnimatedEffects enEff = SortedAnimated.SortedAnimatedEffects._HitEffect_SlimeParticle; if (xOwner.enType == EnemyCodex.EnemyTypes.RedSlime) { enEff = SortedAnimated.SortedAnimatedEffects._HitEffect_RedSlimeParticle; } float fRandGrade = (float)knark.NextDouble(); SortedAnimated eff = Utils.GetTheGame()._EffectMaster_AddEffect(new _Effect_MovingAnimated(v2Orig, enEff, v2RandDir * (0.5f + (float)Utils.GetTheGame().randomInVisual.NextDouble() * 2f), 35 + (int)(25f * fRandGrade), 25, 0.9f)) as SortedAnimated; eff.xRenderComponent.fVirtualHeight += xOwner.xRenderComponent.fVirtualHeight; (eff.xRenderComponent as AnimatedRenderComponent).fAnimationTimeWarp = 0.7f + fRandGrade * 0.6f; } }
public static void InstanceBuilder(Enemy xEn) { xEn.xBaseStats.fMovementSpeed = 4f; xEn.xBehaviour = new ModSlimeAI(xEn); xEn.sAttackPhaseCategory = "GreenSlime"; xEn.lenAssociatedEffects.Add(SortedAnimated.SortedAnimatedEffects._HitEffect_SlimeParticle); xEn.enDeathEffect = SortedAnimated.SortedAnimatedEffects.SlimeDeath; xEn.liAnimationsWithAttackphase.Add(4); xEn.liAnimationsWithAttackphase.Add(5); xEn.liAnimationsWithAttackphase.Add(6); xEn.liAnimationsWithAttackphase.Add(7); xEn.xRenderComponent.dixAnimations.Add(0, ItemExampleMod.Animations[0].Clone()); xEn.xRenderComponent.dixAnimations.Add(1, ItemExampleMod.Animations[1].Clone()); xEn.xRenderComponent.dixAnimations.Add(2, ItemExampleMod.Animations[2].Clone()); xEn.xRenderComponent.dixAnimations.Add(3, ItemExampleMod.Animations[3].Clone()); xEn.xRenderComponent.dixAnimations.Add(4, ItemExampleMod.Animations[4].Clone()); xEn.xRenderComponent.dixAnimations.Add(5, ItemExampleMod.Animations[5].Clone()); xEn.xRenderComponent.dixAnimations.Add(6, ItemExampleMod.Animations[6].Clone()); xEn.xRenderComponent.dixAnimations.Add(7, ItemExampleMod.Animations[7].Clone()); xEn.xRenderComponent.dixAnimations.Add(8, ItemExampleMod.Animations[8].Clone()); xEn.xRenderComponent.dixAnimations.Add(40000, ItemExampleMod.Animations[9].Clone()); xEn.xRenderComponent.dixAnimations.Add(40001, ItemExampleMod.Animations[10].Clone()); xEn.xRenderComponent.dixAnimations.Add(40002, ItemExampleMod.Animations[11].Clone()); xEn.xRenderComponent.dixAnimations.Add(40003, ItemExampleMod.Animations[12].Clone()); xEn.xRenderComponent.dixAnimations.Add(40004, ItemExampleMod.Animations[13].Clone()); xEn.xRenderComponent.dixAnimations.Add(40005, ItemExampleMod.Animations[14].Clone()); xEn.xRenderComponent.dixAnimations.Add(40006, ItemExampleMod.Animations[15].Clone()); xEn.xRenderComponent.dixAnimations.Add(40007, ItemExampleMod.Animations[16].Clone()); xEn.aiHitAnimation[0] = 2; xEn.aiHitAnimation[1] = 2; xEn.aiHitAnimation[2] = 2; xEn.aiHitAnimation[3] = 2; xEn.xBaseStats.enSize = BaseStats.BodySize.Small; xEn.v2DamageNumberPosOffset = new Vector2(-2f, -2f); xEn.iOverrideDamageNumberWidth = 14; xEn.xBaseStats.bCanBeKnockedUp = true; SortedAnimated.PreLoadMany(SortedAnimated.SortedAnimatedEffects._HitEffect_SlimeParticle, SortedAnimated.SortedAnimatedEffects.SlimeDeath); Utils.GetTheGame().xRenderMaster.RegisterSortedRenderComponent(xEn.xRenderComponent); xEn.xCollisionComponent.xMovementCollider = new SphereCollider(5f, Vector2.Zero, xEn.xTransform, 9f + (float)CAS.RandomInLogic.NextDouble(), xEn); xEn.xCollisionComponent.xMovementCollider.bIsLarge = false; xEn.xCollisionComponent.AddHitboxCollider(new SphereCollider(8f, Vector2.Zero, xEn.xTransform, 0f, xEn), Collider.ColliderLayers.Enemies); }
// TO DO: Consider transforming this into a transpile /// <summary> Patches _Enemy_MakeElite so that SoG can scale modded enemy instances if they're elite. </summary> private static bool _Enemy_MakeElite_PrefixPatch(ref bool __result, Enemy xEn, bool bAttachEffect) { __result = false; if (!xEn.enType.IsModEnemy()) { return(true); // Executes original method } if (xEn.xBehaviour.bIsElite) { return(false); // Skips original method (No changes needed) } ModEnemyData xModData = ModLibrary.EnemyDetails[xEn.enType]; if (xModData.EliteBuilder != null) { xModData.EliteBuilder(xEn); __result = true; } if (__result) { Game1 xGame = Utils.GetTheGame(); xEn.xBehaviour.bIsElite = true; if (xGame.xStateMaster.enGameMode == StateMaster.GameModes.RogueLike && RogueLikeMode.randLevelLoadStuff.Next(Math.Max(20 - xGame.xGameSessionData.xRogueLikeSession.iCurrentFloor * 2, 5)) == 0) { xEn.lxLootTable.Add(new DropChance(100000, ItemCodex.ItemTypes._KeyItem_RoguelikeEssence)); } if (xModData.bGrantEliteBonuses) { xEn.xBaseStats.iBaseMaxHP = (int)((float)xEn.xBaseStats.iBaseMaxHP * (0.75f + 0.25f * (float)CAS.NumberOfPlayers)); xEn.xBaseStats.iHP = xEn.xBaseStats.iMaxHP; foreach (PlayerView xView in xGame.dixPlayers.Values) { if (xView.xEquipment.HasBadge(PinCodex.PinType.ElitesIncreaseATKMATKPermanentlyButAlsoStronger)) { xView.xEntity.xBaseStats.dxfModifiedResistanceVsTarget[xEn] = 1.5f; } } } if (CAS.GameMode == StateMaster.GameModes.Story) { if (xModData.bGrantEliteBonuses && !xEn.bSuppressEliteDropBonus) { xEn.iBonusMoney = xEn.xBaseStats.iLevel * 20; foreach (DropChance x in xEn.lxLootTable) { x.iChance *= 5; } xEn.xBaseStats.iLevel += 3; } xEn.sOverrideName = RogueLikeMode.GetSuperSuffix(xEn.xEnemyDescription.sFullName, xEn.enType); } if (bAttachEffect) { SortedAnimated xEffe = xGame._EffectMaster_AddEffect(new SortedAnimated(xEn.xTransform.v2Pos, SortedAnimated.SortedAnimatedEffects.BuffEffectEliteEnemy)) as SortedAnimated; xEffe.xRenderComponent.xTransform = xEn.xRenderComponent.xTransform; xEn.xEliteEffect = xEffe; if (xEn.enType == EnemyCodex.EnemyTypes.Desert_Solem) { xEffe.xRenderComponent.fScale = 1.5f; } xGame._EntityMaster_AddWatcher(new Watchers.EnemyAttachedEffectWatcher(xEn, xEffe)); } } return(false); // Skips original method }