configure a code style that is not completely cursed

This commit is contained in:
2026-01-07 19:08:34 +01:00
parent a945f17711
commit fff8b5e7f1
18 changed files with 188 additions and 298 deletions
+10 -15
View File
@@ -4,32 +4,27 @@ using Terraria.ModLoader;
namespace YHTMod.Buffs;
public class SummonerAmbitionBuff : ModBuff
{
public override void SetStaticDefaults()
{
public class SummonerAmbitionBuff : ModBuff {
public override void SetStaticDefaults() {
Main.buffNoSave[Type] = true;
Main.buffNoTimeDisplay[Type] = true;
}
public override void ModifyBuffText(ref string buffName, ref string tip, ref int rare)
{
var modPlayer = Main.LocalPlayer.TryGetModPlayer<YhtPlayer>(out var mp) ? mp : null;
public override void ModifyBuffText(ref string buffName, ref string tip, ref int rare) {
YhtPlayer modPlayer = Main.LocalPlayer.TryGetModPlayer<YhtPlayer>(out var mp) ? mp : null;
if (modPlayer == null) return;
tip = Language.GetTextValue("Mods.YHTMod.Buffs.SummonerAmbitionBuff.Description", modPlayer.SummonerAmbitions.Count);
tip = Language.GetTextValue("Mods.YHTMod.Buffs.SummonerAmbitionBuff.Description",
modPlayer.SummonerAmbitions.Count);
}
public override void Update(Player player, ref int buffIndex)
{
var modPlayer = player.GetModPlayer<YhtPlayer>();
public override void Update(Player player, ref int buffIndex) {
YhtPlayer modPlayer = player.GetModPlayer<YhtPlayer>();
if (modPlayer.SummonerAmbition)
{
if (modPlayer.SummonerAmbition) {
player.buffTime[buffIndex] = 18000;
}
else
{
else {
player.DelBuff(buffIndex);
buffIndex--;
}
+5 -10
View File
@@ -4,22 +4,17 @@ using YHTMod.Projectiles.Weapons;
namespace YHTMod.Buffs;
public class ToclafaneMinionBuff : ModBuff
{
public override void SetStaticDefaults()
{
public class ToclafaneMinionBuff : ModBuff {
public override void SetStaticDefaults() {
Main.buffNoSave[Type] = true;
Main.buffNoTimeDisplay[Type] = true;
}
public override void Update(Player player, ref int buffIndex)
{
if (player.ownedProjectileCounts[ModContent.ProjectileType<ToclafaneMinion>()] > 0)
{
public override void Update(Player player, ref int buffIndex) {
if (player.ownedProjectileCounts[ModContent.ProjectileType<ToclafaneMinion>()] > 0) {
player.buffTime[buffIndex] = 18000;
}
else
{
else {
player.DelBuff(buffIndex);
buffIndex--;
}
+9 -16
View File
@@ -7,12 +7,9 @@ using Terraria.ModLoader;
namespace YHTMod.Changes;
public class BossKillListener : GlobalNPC
{
public override void OnKill(NPC npc)
{
switch (npc.type)
{
public class BossKillListener : GlobalNPC {
public override void OnKill(NPC npc) {
switch (npc.type) {
case NPCID.KingSlime:
HandleBossKill(npc, "king_slime");
break;
@@ -22,9 +19,8 @@ public class BossKillListener : GlobalNPC
case NPCID.EaterofWorldsHead:
case NPCID.EaterofWorldsBody:
case NPCID.EaterofWorldsTail:
var foundEaterSegments = 0;
foreach (var activeNpC in Main.ActiveNPCs)
{
int foundEaterSegments = 0;
foreach (NPC activeNpC in Main.ActiveNPCs) {
if (activeNpC.friendly || activeNpC.townNPC) continue;
if (activeNpC.type is not NPCID.EaterofWorldsBody
and not NPCID.EaterofWorldsHead
@@ -55,15 +51,12 @@ public class BossKillListener : GlobalNPC
base.OnKill(npc);
}
private static void HandleBossKill(NPC npc, string bossKey)
{
foreach (var player in Main.ActivePlayers)
{
var modPlayer = player.GetModPlayer<YhtPlayer>();
private static void HandleBossKill(NPC npc, string bossKey) {
foreach (Player player in Main.ActivePlayers) {
YhtPlayer modPlayer = player.GetModPlayer<YhtPlayer>();
if (!npc.playerInteraction[player.whoAmI]) continue;
if (modPlayer.SummonerAmbition && modPlayer.SummonerAmbitions.Add(bossKey))
{
if (modPlayer.SummonerAmbition && modPlayer.SummonerAmbitions.Add(bossKey)) {
ChatHelper.SendChatMessageToClient(
NetworkText.FromLiteral("Your Summoner Ambition's potential grows stronger!"),
Color.MediumPurple,
+5 -9
View File
@@ -8,19 +8,15 @@ using YHTMod.Items.ArcaneMissile;
namespace YHTMod.Changes;
public class NpcLoot : GlobalNPC
{
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
{
var id = npc.type;
public class NpcLoot : GlobalNPC {
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) {
int id = npc.type;
if (NPCID.Sets.CountsAsCritter[id])
{
if (NPCID.Sets.CountsAsCritter[id]) {
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<MithrilPebbleOfPigSmiting>(), 400));
}
switch (id)
{
switch (id) {
case NPCID.Plantera:
npcLoot.Add(ItemDropRule.Common(ItemID.ChlorophyteOre, 1, 60, 80));
break;
+10 -17
View File
@@ -5,24 +5,19 @@ using Vector2 = Microsoft.Xna.Framework.Vector2;
namespace YHTMod.Changes;
public class SummonerOnHitEffects : GlobalProjectile
{
public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone)
{
var player = Main.player[projectile.owner];
var modPlayer = player.GetModPlayer<YhtPlayer>();
if (projectile.minion && Main.myPlayer == projectile.owner)
{
if (modPlayer.SummonerAmbition)
{
public class SummonerOnHitEffects : GlobalProjectile {
public override void OnHitNPC(Projectile projectile, NPC target, NPC.HitInfo hit, int damageDone) {
Player player = Main.player[projectile.owner];
YhtPlayer modPlayer = player.GetModPlayer<YhtPlayer>();
if (projectile.minion && Main.myPlayer == projectile.owner) {
if (modPlayer.SummonerAmbition) {
if (
modPlayer.SummonerAmbitions.Contains("deerclops")
&& modPlayer.SummonerAmbitionDeerclopsCooldown == 0
&& Main.rand.NextBool(10)
)
{
) {
modPlayer.SummonerAmbitionDeerclopsCooldown = 5 * 60;
var direction = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f));
Vector2 direction = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f));
direction.Normalize();
direction *= Main.rand.NextFloat(4f, 8f);
Projectile.NewProjectile(
@@ -39,15 +34,13 @@ public class SummonerOnHitEffects : GlobalProjectile
if (
modPlayer.SummonerAmbitions.Contains("queen_bee")
&& Main.rand.NextBool(4)
)
{
) {
target.AddBuff(BuffID.Poisoned, 5 * 60);
}
}
}
if (projectile.WhipSettings.Segments > 0)
{
if (projectile.WhipSettings.Segments > 0) {
projectile.damage = (int)(projectile.damage * 1.1);
}
+4 -8
View File
@@ -5,15 +5,12 @@ using Terraria.ModLoader;
namespace YHTMod.Items.ArcaneMissile;
public class ArcaneMissile : ModItem
{
public override void SetStaticDefaults()
{
public class ArcaneMissile : ModItem {
public override void SetStaticDefaults() {
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void SetDefaults()
{
public override void SetDefaults() {
Item.width = 32;
Item.height = 32;
Item.accessory = true;
@@ -24,8 +21,7 @@ public class ArcaneMissile : ModItem
Item.noUseGraphic = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
public override void UpdateAccessory(Player player, bool hideVisual) {
player.GetModPlayer<YhtPlayer>().ArcaneMissile = Item.damage;
base.UpdateAccessory(player, hideVisual);
+7 -12
View File
@@ -4,27 +4,22 @@ using Terraria.ModLoader;
namespace YHTMod.Items.ArcaneMissile;
public class ArcaneMissileBehavior : GlobalNPC
{
public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hitInfo, int damage)
{
if (!hitInfo.Crit)
{
public class ArcaneMissileBehavior : GlobalNPC {
public override void OnHitByProjectile(NPC npc, Projectile projectile, NPC.HitInfo hitInfo, int damage) {
if (!hitInfo.Crit) {
base.OnHitByProjectile(npc, projectile, hitInfo, damage);
return;
}
if (Main.netMode == NetmodeID.Server)
{
if (Main.netMode == NetmodeID.Server) {
return;
}
var player = Main.LocalPlayer;
Player player = Main.LocalPlayer;
if (player.GetModPlayer<YhtPlayer>().ArcaneMissile != 0 && projectile.DamageType == DamageClass.Magic)
{
if (player.GetModPlayer<YhtPlayer>().ArcaneMissile != 0 && projectile.DamageType == DamageClass.Magic) {
// player just crit with magic weapon while having arcane missile accessory
var proj = Projectile.NewProjectileDirect(
Projectile proj = Projectile.NewProjectileDirect(
projectile.GetSource_FromThis("arcaneMissile"),
Main.LocalPlayer.position,
npc.position.DirectionFrom(Main.LocalPlayer.position),
+4 -8
View File
@@ -5,15 +5,12 @@ using YHTMod.Projectiles.Weapons;
namespace YHTMod.Items;
public class CopperSwordOnAStick : ModItem
{
public override void SetStaticDefaults()
{
public class CopperSwordOnAStick : ModItem {
public override void SetStaticDefaults() {
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void SetDefaults()
{
public override void SetDefaults() {
Item.DamageType = DamageClass.Melee;
Item.damage = 3;
Item.width = 80;
@@ -34,8 +31,7 @@ public class CopperSwordOnAStick : ModItem
Item.shoot = ModContent.ProjectileType<CopperSwordOnAStickProjectile>();
}
public override void AddRecipes()
{
public override void AddRecipes() {
CreateRecipe()
.AddIngredient(ItemID.Wood, 5)
.AddIngredient(ItemID.Rope, 5)
+11 -16
View File
@@ -6,41 +6,36 @@ using Terraria.ModLoader;
namespace YHTMod.Items;
public class KatanaRedo : GlobalItem
{
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
{
public class KatanaRedo : GlobalItem {
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips) {
if (item.type != ItemID.Katana) return;
tooltips.Insert(5, new TooltipLine(YHTMod.GetInstance(), "flavor", "Nothing personel kid."));
tooltips.Insert(6, new TooltipLine(YHTMod.GetInstance(), "usage", "Right click to teleport behind them."));
}
public override bool AltFunctionUse(Item item, Player player)
{
public override bool AltFunctionUse(Item item, Player player) {
return item.type == ItemID.Katana || base.AltFunctionUse(item, player);
}
public override bool? UseItem(Item item, Player player)
{
public override bool? UseItem(Item item, Player player) {
if (item.type != ItemID.Katana || player.altFunctionUse != 2) return null;
var yhtPlayer = player.GetModPlayer<YhtPlayer>();
YhtPlayer yhtPlayer = player.GetModPlayer<YhtPlayer>();
if (yhtPlayer.KatanaTeleportCooldown > 0) return null;
yhtPlayer.KatanaTeleportCooldown = 300;
for (var i = 0; i < Main.maxNPCs; i++)
{
var npc = Main.npc[i];
for (int i = 0; i < Main.maxNPCs; i++) {
NPC npc = Main.npc[i];
if (!npc.CanBeChasedBy()) continue;
var between = Vector2.Distance(npc.Center, player.Center);
var inRange = between < 650;
float between = Vector2.Distance(npc.Center, player.Center);
bool inRange = between < 650;
var lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position,
bool lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position,
npc.width, npc.height);
if (!inRange || !lineOfSight) continue;
var tpPos = npc.position;
Vector2 tpPos = npc.position;
tpPos.X += -(npc.direction * npc.width + (player.width * 2));
if (Collision.TileCollision(tpPos, Vector2.Zero, player.width, player.height) != Vector2.Zero) return true;
+3 -6
View File
@@ -5,15 +5,12 @@ using YHTMod.Projectiles.Weapons;
namespace YHTMod.Items;
public class MithrilPebbleOfPigSmiting : ModItem
{
public override void SetStaticDefaults()
{
public class MithrilPebbleOfPigSmiting : ModItem {
public override void SetStaticDefaults() {
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void SetDefaults()
{
public override void SetDefaults() {
Item.DamageType = DamageClass.Ranged;
Item.damage = 16;
Item.width = 8;
+27 -30
View File
@@ -7,17 +7,14 @@ using Terraria.ModLoader;
namespace YHTMod.Items;
public class SummonersAmbition : ModItem
{
public override void SetStaticDefaults()
{
public class SummonersAmbition : ModItem {
public override void SetStaticDefaults() {
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override LocalizedText Tooltip => Language.GetText("");
public override void SetDefaults()
{
public override void SetDefaults() {
Item.width = 32;
Item.height = 32;
Item.accessory = true;
@@ -27,76 +24,76 @@ public class SummonersAmbition : ModItem
ItemID.Sets.ShimmerTransformToItem[Type] = 0;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
var modPlayer = player.GetModPlayer<YhtPlayer>();
public override void UpdateAccessory(Player player, bool hideVisual) {
YhtPlayer modPlayer = player.GetModPlayer<YhtPlayer>();
modPlayer.SummonerAmbition = true;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
{
var player = Main.LocalPlayer.GetModPlayer<YhtPlayer>();
public override void ModifyTooltips(List<TooltipLine> tooltips) {
YhtPlayer player = Main.LocalPlayer.GetModPlayer<YhtPlayer>();
tooltips.Add(new TooltipLine(Mod, "SummonerAmbition",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Tooltip",
player.GetSummonersAmbitionMinionBonus())));
if (player.SummonerAmbitions.Contains("king_slime"))
{
if (player.SummonerAmbitions.Contains("king_slime")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionKingSlime",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.KingSlime")));
}
if (player.SummonerAmbitions.Contains("eye_of_cthulhu"))
{
if (player.SummonerAmbitions.Contains("eye_of_cthulhu")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionEyeOfCthulhu",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.EyeOfCthulhu")));
}
if (player.SummonerAmbitions.Contains("deerclops"))
{
if (player.SummonerAmbitions.Contains("deerclops")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionDeerclops",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Deerclops")));
}
if (player.SummonerAmbitions.Contains("eater_of_worlds"))
{
if (player.SummonerAmbitions.Contains("eater_of_worlds")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionEaterOfWorlds",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.EaterOfWorlds")));
}
if (player.SummonerAmbitions.Contains("brain_of_cthulhu"))
{
if (player.SummonerAmbitions.Contains("brain_of_cthulhu")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionBrainOfCthulhu",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.BrainOfCthulhu")));
}
if (player.SummonerAmbitions.Contains("queen_bee"))
{
if (player.SummonerAmbitions.Contains("queen_bee")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionQueenBee",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.QueenBee")));
}
if (player.SummonerAmbitions.Contains("skeletron"))
{
if (player.SummonerAmbitions.Contains("skeletron")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionSkeletron",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.Skeletron")));
}
if (player.SummonerAmbitions.Contains("wall_of_flesh"))
{
if (player.SummonerAmbitions.Contains("wall_of_flesh")) {
tooltips.Add(new TooltipLine(Mod, "SummonerAmbitionWallOfFlesh",
Language.GetTextValue("Mods.YHTMod.Items.SummonersAmbition.WallOfFlesh")));
}
}
public override void AddRecipes()
{
public override void AddRecipes() {
CreateRecipe()
.AddIngredient(ItemID.Rope, 5)
.AddRecipeGroup(RecipeGroupID.Squirrels)
.AddIngredient(ItemID.Acorn, 25)
.AddTile(TileID.WorkBenches)
.Register();
}
public static bool IsPreHardmodeRealized(Player player) {
YhtPlayer modPlayer = player.GetModPlayer<YhtPlayer>();
return modPlayer.SummonerAmbitions.Contains("king_slime")
&& modPlayer.SummonerAmbitions.Contains("eye_of_cthulhu")
&& modPlayer.SummonerAmbitions.Contains("deerclops")
&& modPlayer.SummonerAmbitions.Contains("eater_of_worlds")
&& modPlayer.SummonerAmbitions.Contains("brain_of_cthulhu")
&& modPlayer.SummonerAmbitions.Contains("queen_bee")
&& modPlayer.SummonerAmbitions.Contains("skeletron")
&& modPlayer.SummonerAmbitions.Contains("wall_of_flesh");
}
}
+10 -17
View File
@@ -10,18 +10,15 @@ using YHTMod.Projectiles.Weapons;
namespace YHTMod.Items;
public class ToclafaneStaff : ModItem
{
public override void SetStaticDefaults()
{
public class ToclafaneStaff : ModItem {
public override void SetStaticDefaults() {
ItemID.Sets.GamepadWholeScreenUseRange[Item.type] =
true; // This lets the player target anywhere on the whole screen while using a controller.
ItemID.Sets.LockOnIgnoresCollision[Item.type] = true;
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}
public override void SetDefaults()
{
public override void SetDefaults() {
Item.damage = 30;
Item.knockBack = 3f;
Item.mana = 10;
@@ -40,16 +37,14 @@ public class ToclafaneStaff : ModItem
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity,
int type, int damage, float knockback)
{
int type, int damage, float knockback) {
player.AddBuff(Item.buffType, 2);
position = Main.MouseWorld;
return base.Shoot(player, source, position, velocity, type, damage, knockback);
}
public override void AddRecipes()
{
var watchGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.AnyWatch"),
public override void AddRecipes() {
RecipeGroup watchGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.AnyWatch"),
ItemID.GoldWatch,
ItemID.SilverWatch,
ItemID.TinWatch,
@@ -59,27 +54,25 @@ public class ToclafaneStaff : ModItem
);
RecipeGroup.RegisterGroup("YHTMod:Watches", watchGroup);
var tier2BarGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.Tier2Bars"),
RecipeGroup tier2BarGroup = new RecipeGroup(() => Language.GetTextValue("Mods.YHTMod.Recipes.Tier2Bars"),
ItemID.MythrilBar,
ItemID.OrichalcumBar
);
RecipeGroup.RegisterGroup("YHTMod:Tier2Bars", tier2BarGroup);
var recipe = CreateRecipe();
Recipe recipe = CreateRecipe();
recipe.AddRecipeGroup(watchGroup);
recipe.AddIngredient(ItemID.GuideVoodooDoll);
recipe.AddTile(TileID.MythrilAnvil);
// Calamity delays when you obtain hallowed bars, so use alternate recipe if Calamity is installed
if (ModLoader.HasMod("CalamityMod"))
{
if (ModLoader.HasMod("CalamityMod")) {
recipe.AddRecipeGroup(tier2BarGroup, 35);
recipe.AddIngredient(ItemID.SoulofLight, 10);
recipe.AddIngredient(ItemID.SoulofNight, 10);
}
else
{
else {
recipe.AddIngredient(ItemID.HallowedBar, 15);
}
@@ -6,10 +6,8 @@ using Terraria.ModLoader;
namespace YHTMod.Projectiles.Weapons;
class CopperSwordOnAStickProjectile : ModProjectile
{
public override void SetDefaults()
{
class CopperSwordOnAStickProjectile : ModProjectile {
public override void SetDefaults() {
Projectile.width = 80;
Projectile.height = 80;
@@ -23,8 +21,7 @@ class CopperSwordOnAStickProjectile : ModProjectile
Projectile.aiStyle = ProjAIStyleID.ShortSword;
}
public override void AI()
{
public override void AI() {
base.AI();
float random = (float)(Random.Shared.NextDouble() / 5f);
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 -
@@ -5,10 +5,8 @@ using Terraria.ModLoader;
namespace YHTMod.Projectiles.Weapons;
class MithrilPebbleOfPigSmitingProjectile : ModProjectile
{
public override void SetDefaults()
{
class MithrilPebbleOfPigSmitingProjectile : ModProjectile {
public override void SetDefaults() {
Projectile.width = 8;
Projectile.height = 8;
Projectile.friendly = true;
@@ -22,12 +20,11 @@ class MithrilPebbleOfPigSmitingProjectile : ModProjectile
Projectile.light = 0.3f;
}
public override void AI()
{
public override void AI() {
base.AI();
DrawOriginOffsetX = 0;
DrawOffsetX = 0;
var dust = Dust.NewDust(Projectile.Center, 1, 1, DustID.Mythril, 0f, 0f, 0, default(Color), 1f);
int dust = Dust.NewDust(Projectile.Center, 1, 1, DustID.Mythril, 0f, 0f, 0, default(Color), 1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 0.3f;
}
+30 -59
View File
@@ -7,13 +7,11 @@ using YHTMod.Buffs;
namespace YHTMod.Projectiles.Weapons;
public class ToclafaneMinion : ModProjectile
{
public class ToclafaneMinion : ModProjectile {
private int _shootCooldown = 0;
private AttackMode _attackMode = AttackMode.Ranged;
public override void SetStaticDefaults()
{
public override void SetStaticDefaults() {
// Sets the amount of frames this minion has on its spritesheet
Main.projFrames[Projectile.type] = 8;
// This is necessary for right-click targeting
@@ -23,8 +21,7 @@ public class ToclafaneMinion : ModProjectile
ProjectileID.Sets.MinionSacrificable[Projectile.type] = true;
}
public sealed override void SetDefaults()
{
public sealed override void SetDefaults() {
Projectile.width = 32;
Projectile.height = 32;
Projectile.scale = 0.65f;
@@ -37,29 +34,24 @@ public class ToclafaneMinion : ModProjectile
Projectile.penetrate = -1;
}
public override bool? CanCutTiles()
{
public override bool? CanCutTiles() {
return false;
}
public override bool MinionContactDamage()
{
public override bool MinionContactDamage() {
return true;
}
public override void AI()
{
var player = Main.player[Projectile.owner];
public override void AI() {
Player player = Main.player[Projectile.owner];
#region Active check
if (player.dead || !player.active)
{
if (player.dead || !player.active) {
player.ClearBuff(ModContent.BuffType<ToclafaneMinionBuff>());
}
if (player.HasBuff(ModContent.BuffType<ToclafaneMinionBuff>()))
{
if (player.HasBuff(ModContent.BuffType<ToclafaneMinionBuff>())) {
Projectile.timeLeft = 2;
}
@@ -67,8 +59,7 @@ public class ToclafaneMinion : ModProjectile
#region General behavior
if (_shootCooldown > 0)
{
if (_shootCooldown > 0) {
_shootCooldown = _shootCooldown - 1;
}
@@ -85,8 +76,7 @@ public class ToclafaneMinion : ModProjectile
// Teleport to player if distance is too big
var vectorToIdlePosition = idlePosition - Projectile.Center;
var distanceToIdlePosition = vectorToIdlePosition.Length();
if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f)
{
if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f) {
// Whenever you deal with non-regular events that change the behavior or position drastically, make sure to only run the code on the owner of the projectile,
// and then set netUpdate to true
Projectile.position = idlePosition;
@@ -96,8 +86,7 @@ public class ToclafaneMinion : ModProjectile
// If your minion is flying, you want to do this independently of any conditions
const float overlapVelocity = 0.04f;
for (var i = 0; i < Main.maxProjectiles; i++)
{
for (var i = 0; i < Main.maxProjectiles; i++) {
// Fix overlap with other minions
var other = Main.projectile[i];
if (i == Projectile.whoAmI || !other.active || other.owner != Projectile.owner ||
@@ -119,23 +108,19 @@ public class ToclafaneMinion : ModProjectile
var foundTarget = false;
// This code is required if your minion weapon has the targeting feature
if (player.HasMinionAttackTargetNPC)
{
if (player.HasMinionAttackTargetNPC) {
var npc = Main.npc[player.MinionAttackTargetNPC];
var between = Vector2.Distance(npc.Center, Projectile.Center);
// Reasonable distance away so it doesn't target across multiple screens
if (between < 2000f)
{
if (between < 2000f) {
distanceFromTarget = between;
targetCenter = npc.Center;
foundTarget = true;
}
}
if (!foundTarget)
{
for (var i = 0; i < Main.maxNPCs; i++)
{
if (!foundTarget) {
for (var i = 0; i < Main.maxNPCs; i++) {
var npc = Main.npc[i];
if (!npc.CanBeChasedBy()) continue;
var between = Vector2.Distance(npc.Center, Projectile.Center);
@@ -163,24 +148,20 @@ public class ToclafaneMinion : ModProjectile
var speed = 8f;
var inertia = 20f;
if (foundTarget)
{
if (foundTarget) {
var direction = targetCenter - Projectile.Center;
direction.Normalize();
if (distanceFromTarget > 40f)
{
if (distanceFromTarget > 40f) {
// The immediate range around the target (so it doesn't latch onto it when close)
direction *= speed;
Projectile.velocity = (Projectile.velocity * (inertia - 1) + direction) / inertia;
}
switch (distanceFromTarget)
{
switch (distanceFromTarget) {
case <= 120f:
_attackMode = AttackMode.Melee;
break;
case > 120f when _shootCooldown == 0:
{
case > 120f when _shootCooldown == 0: {
_shootCooldown = 60; // 1 second between shots
var laser = Projectile.NewProjectileDirect(player.GetSource_FromThis(), Projectile.Center,
direction, ProjectileID.DeathLaser, 30, Projectile.knockBack, Projectile.owner);
@@ -192,24 +173,20 @@ public class ToclafaneMinion : ModProjectile
}
}
}
else
{
else {
// Minion doesn't have a target: return to player and idle
if (distanceToIdlePosition > 600f)
{
if (distanceToIdlePosition > 600f) {
// Speed up the minion if it's away from the player
speed = 12f;
inertia = 60f;
}
else
{
else {
// Slow down the minion if closer to the player
speed = 4f;
inertia = 80f;
}
if (distanceToIdlePosition > 20f)
{
if (distanceToIdlePosition > 20f) {
// The immediate range around the player (when it passively floats about)
// This is a simple movement formula using the two parameters and its desired direction to create a "homing" movement
@@ -217,8 +194,7 @@ public class ToclafaneMinion : ModProjectile
vectorToIdlePosition *= speed;
Projectile.velocity = (Projectile.velocity * (inertia - 1) + vectorToIdlePosition) / inertia;
}
else if (Projectile.velocity == Vector2.Zero)
{
else if (Projectile.velocity == Vector2.Zero) {
// If there is a case where it's not moving at all, give it a little "poke"
Projectile.velocity.X = -0.15f;
Projectile.velocity.Y = -0.05f;
@@ -234,14 +210,11 @@ public class ToclafaneMinion : ModProjectile
const int frameSpeed = 8;
Projectile.frameCounter++;
if (Projectile.frameCounter >= frameSpeed)
{
if (Projectile.frameCounter >= frameSpeed) {
Projectile.frameCounter = 0;
switch (_attackMode)
{
switch (_attackMode) {
case AttackMode.Melee:
switch (Projectile.frame)
{
switch (Projectile.frame) {
case 0:
case 1:
case 2:
@@ -266,8 +239,7 @@ public class ToclafaneMinion : ModProjectile
break;
case AttackMode.Ranged:
switch (Projectile.frame)
{
switch (Projectile.frame) {
case 0:
Projectile.frame = 5;
break;
@@ -301,8 +273,7 @@ public class ToclafaneMinion : ModProjectile
#endregion
}
private enum AttackMode
{
private enum AttackMode {
Melee,
Ranged,
}
+11 -10
View File
@@ -1,14 +1,15 @@
using Terraria.ModLoader;
namespace YHTMod {
public class YHTMod : Mod {
private static YHTMod _mod;
public YHTMod() {
_mod = this;
}
namespace YHTMod;
public static YHTMod GetInstance() {
return _mod;
}
}
public class YHTMod : Mod {
private static YHTMod _mod;
public YHTMod() {
_mod = this;
}
public static YHTMod GetInstance() {
return _mod;
}
}
-2
View File
@@ -5,6 +5,4 @@
<AssemblyName>YHTMod</AssemblyName>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
</Project>
+17 -32
View File
@@ -6,8 +6,7 @@ using YHTMod.Buffs;
namespace YHTMod;
public class YhtPlayer : ModPlayer
{
public class YhtPlayer : ModPlayer {
public int ArcaneMissile = 0;
public int KatanaTeleportCooldown = 0;
public int SummonerAmbitionDeerclopsCooldown = 0;
@@ -20,68 +19,54 @@ public class YhtPlayer : ModPlayer
*/
public HashSet<string> SummonerAmbitions = [];
public override void PreUpdate()
{
public override void PreUpdate() {
KatanaTeleportCooldown = Math.Max(KatanaTeleportCooldown - 1, 0);
SummonerAmbitionDeerclopsCooldown = Math.Max(SummonerAmbitionDeerclopsCooldown - 1, 0);
}
public override void PostUpdateEquips()
{
if (SummonerAmbition)
{
public override void PostUpdateEquips() {
if (SummonerAmbition) {
Player.AddBuff(ModContent.BuffType<SummonerAmbitionBuff>(), 1);
Player.maxMinions += GetSummonersAmbitionMinionBonus();
if (SummonerAmbitions.Contains("king_slime"))
{
if (SummonerAmbitions.Contains("king_slime")) {
Player.whipRangeMultiplier += 0.2f;
}
if (SummonerAmbitions.Contains("eater_of_worlds"))
{
if (SummonerAmbitions.Contains("eater_of_worlds")) {
Player.GetArmorPenetration(DamageClass.Summon) += 5;
}
if (SummonerAmbitions.Contains("brain_of_cthulhu"))
{
if (SummonerAmbitions.Contains("brain_of_cthulhu")) {
Player.GetDamage(DamageClass.Summon) += 0.05f;
}
if (SummonerAmbitions.Contains("skeletron"))
{
if (SummonerAmbitions.Contains("skeletron")) {
Player.GetKnockback(DamageClass.Summon) += 0.1f;
}
}
}
public override void ResetEffects()
{
public override void ResetEffects() {
ArcaneMissile = 0;
SummonerAmbition = false;
base.ResetEffects();
}
public override void SaveData(TagCompound tag)
{
public override void SaveData(TagCompound tag) {
tag["summonerAmbitions"] = new List<string>(SummonerAmbitions);
}
public override void LoadData(TagCompound tag)
{
if (tag.ContainsKey("summonerAmbitions"))
{
var list = tag.GetList<string>("summonerAmbitions");
SummonerAmbitions = new HashSet<string>(list);
}
public override void LoadData(TagCompound tag) {
if (!tag.ContainsKey("summonerAmbitions")) return;
IList<string> list = tag.GetList<string>("summonerAmbitions");
SummonerAmbitions = new HashSet<string>(list);
}
public int GetSummonersAmbitionMinionBonus()
{
var amount = 1;
if (SummonerAmbitions.Contains("wall_of_flesh"))
{
public int GetSummonersAmbitionMinionBonus() {
int amount = 1;
if (SummonerAmbitions.Contains("wall_of_flesh")) {
amount += 1;
}