public static int GetDuration(InjuryPlayer myplayer) { var mymod = InjuryMod.Instance; if (myplayer != null && myplayer.HeartstringsEffectDuration > 0) { return(mymod.Config.DurationOfBleedingHeart + mymod.Config.HeartstringsAddedDuration); } return(mymod.Config.DurationOfBleedingHeart); }
//////////////// public override void AI() { var mymod = (InjuryMod)this.mod; var proj = this.projectile; var myplayer = Main.player[proj.owner]; InjuryPlayer modplayer = myplayer != null && myplayer.active ? myplayer.GetModPlayer <InjuryPlayer>() : null; int duration = WanderingHeartProjectile.GetDuration(modplayer); int projX = (int)proj.position.X - proj.width; int projY = (int)proj.position.Y - proj.height; int projWidth = proj.width * 3; int projHeight = proj.height * 3; var projRect = new Rectangle(projX - proj.width, projY - proj.height, projWidth, projHeight); // Preserve some bounciness if (proj.velocity.Y < 0) { proj.velocity.Y *= 1.02f; } if ((proj.timeLeft > 60 && proj.timeLeft % 2 == 0) || proj.timeLeft % 5 == 0) { if (Main.rand.Next(4) == 0) { int sparkWho = Dust.NewDust(proj.position, proj.width, proj.height, 55, 0f, 0f, 200, Color.White, 1f); Main.dust[sparkWho].velocity *= 0.1f; Main.dust[sparkWho].scale *= 0.4f; } } if (proj.timeLeft < (duration - 180)) { for (int i = 0; i < 255; i++) { Player player = Main.player[i]; if (player == null || !player.active || player.dead) { continue; } Rectangle playerRect = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); if (projRect.Intersects(playerRect)) { WanderingHeartProjectile.GiveHeartItem(player, this.mod); proj.Kill(); break; } } } }
//////////////// public override void AI() { var mymod = (InjuryMod)this.mod; var proj = this.projectile; var plr = Main.player[proj.owner]; InjuryPlayer myplayer = plr != null && plr.active ? plr.GetModPlayer <InjuryPlayer>() : null; int duration = BleedingHeartProjectile.GetDuration(myplayer); int projX = (int)proj.position.X - proj.width; int projY = (int)proj.position.Y - proj.height; int projWidth = proj.width * 3; int projHeight = proj.height * 3; var projRect = new Rectangle(projX, projY, projWidth, projHeight); // Spew particles if ((proj.timeLeft > 60 && proj.timeLeft % 2 == 0) || proj.timeLeft % 5 == 0) { int bloodWho = Dust.NewDust(proj.Center, 3, 6, 216, 0, 1f, 0, Color.Red, 1f); Main.dust[bloodWho].velocity /= 2f; Main.dust[bloodWho].scale = 0.8f; if (Main.rand.Next(7) == 0) { int sparkWho = Dust.NewDust(proj.position, proj.width, proj.height, 55, 0f, 0f, 200, Color.White, 1f); Main.dust[sparkWho].velocity *= 0.1f; Main.dust[sparkWho].scale *= 0.4f; } } // Enable item pickup if (proj.timeLeft < (duration - 180)) { for (int i = 0; i < 255; i++) { Player player = Main.player[i]; if (player == null || !player.active || player.dead) { continue; } Rectangle playerRect = new Rectangle((int)player.position.X, (int)player.position.Y, player.width, player.height); if (projRect.Intersects(playerRect)) { BleedingHeartProjectile.GiveBrokenHeart(player); proj.Kill(); break; } } } }