mirror of
https://github.com/YouHaveTrouble/YHTMod.git
synced 2026-05-11 21:56:54 +00:00
configure a code style that is not completely cursed
This commit is contained in:
@@ -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,10 +21,9 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
@@ -47,4 +42,4 @@ public class ArcaneMissileBehavior : GlobalNPC
|
||||
|
||||
base.OnHitByProjectile(npc, projectile, hitInfo, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,12 +31,11 @@ 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)
|
||||
.AddIngredient(ItemID.CopperShortsword)
|
||||
.Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-17
@@ -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;
|
||||
@@ -53,4 +48,4 @@ public class KatanaRedo : GlobalItem
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -33,4 +30,4 @@ public class MithrilPebbleOfPigSmiting : ModItem
|
||||
Item.shootSpeed = 20f;
|
||||
Item.shoot = ModContent.ProjectileType<MithrilPebbleOfPigSmitingProjectile>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+32
-35
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
+11
-18
@@ -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,30 +54,28 @@ 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);
|
||||
}
|
||||
|
||||
recipe.Register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user