mirror of
https://github.com/YouHaveTrouble/YHTMod.git
synced 2026-05-12 05:56:56 +00:00
Compare commits
13 Commits
feat-thekey
...
1.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| ee06338f22 | |||
| cc2849737c | |||
| e3f74c2e21 | |||
| cc6d8d6dc2 | |||
| e300c3cddb | |||
| 8a9730f61f | |||
| 4819ceee25 | |||
| f46e4e1673 | |||
| bf556d059f | |||
| eb1bf9014d | |||
| 4a0f37f652 | |||
| 68025dd762 | |||
| 4495fd9cc3 |
@@ -2,23 +2,26 @@ using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using YHTMod.Projectiles.Weapons;
|
||||
|
||||
namespace YHTMod.Buffs;
|
||||
namespace YHTMod.Buffs;
|
||||
|
||||
public class ToclafaneMinionBuff : ModBuff {
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
DisplayName.SetDefault("Summon Toclafane");
|
||||
Description.SetDefault("It came from a parallel world to fight for its Master.");
|
||||
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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-6
@@ -1,19 +1,32 @@
|
||||
|
||||
using Terraria;
|
||||
using Terraria.GameContent.ItemDropRules;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using YHTMod.Items;
|
||||
using YHTMod.Items.ArcaneMissile;
|
||||
|
||||
|
||||
namespace YHTMod.Changes;
|
||||
|
||||
public class NpcLoot : GlobalNPC
|
||||
{
|
||||
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) {
|
||||
int id = npc.type;
|
||||
if (NPCID.Sets.CountsAsCritter[id]) {
|
||||
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<MithrilPebbleOfPigSmiting>(), 400, 1, 1));
|
||||
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot)
|
||||
{
|
||||
var id = npc.type;
|
||||
|
||||
if (NPCID.Sets.CountsAsCritter[id])
|
||||
{
|
||||
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<MithrilPebbleOfPigSmiting>(), 400));
|
||||
}
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case NPCID.Plantera:
|
||||
npcLoot.Add(ItemDropRule.Common(ItemID.ChlorophyteOre, 1, 60, 80));
|
||||
break;
|
||||
case NPCID.Tim:
|
||||
npcLoot.Add(ItemDropRule.Common(ModContent.ItemType<ArcaneMissile>()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace YHTMod.Items.ArcaneMissile;
|
||||
|
||||
public class ArcaneMissile : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 64;
|
||||
Item.height = 64;
|
||||
Item.accessory = true;
|
||||
Item.damage = 10;
|
||||
Item.rare = ItemRarityID.LightRed;
|
||||
Item.DamageType = DamageClass.Magic;
|
||||
Item.noMelee = true;
|
||||
Item.noUseGraphic = true;
|
||||
}
|
||||
|
||||
public override void UpdateAccessory(Player player, bool hideVisual)
|
||||
{
|
||||
player.GetModPlayer<YhtPlayer>().arcaneMissle = Item.damage;
|
||||
|
||||
base.UpdateAccessory(player, hideVisual);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,50 @@
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
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)
|
||||
{
|
||||
base.OnHitByProjectile(npc, projectile, hitInfo, damage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.netMode == NetmodeID.Server)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var player = Main.LocalPlayer;
|
||||
|
||||
if (player.GetModPlayer<YhtPlayer>().arcaneMissle != 0 && projectile.DamageType == DamageClass.Magic)
|
||||
{
|
||||
// player just crit with magic weapon while having arcane missile accessory
|
||||
var proj = Projectile.NewProjectileDirect(
|
||||
projectile.GetSource_FromThis("arcaneMissile"),
|
||||
Main.LocalPlayer.position,
|
||||
npc.position.DirectionFrom(Main.LocalPlayer.position),
|
||||
ProjectileID.MagicMissile,
|
||||
player.GetModPlayer<YhtPlayer>().arcaneMissle,
|
||||
0,
|
||||
Main.LocalPlayer.whoAmI
|
||||
);
|
||||
proj.friendly = true;
|
||||
proj.hostile = false;
|
||||
proj.timeLeft = 300;
|
||||
proj.maxPenetrate = 1;
|
||||
proj.tileCollide = false;
|
||||
proj.DamageType = DamageClass.Magic;
|
||||
proj.aiStyle = ProjAIStyleID.MagicMissile;
|
||||
|
||||
// Prevent crits for the missiles
|
||||
proj.CritChance = int.MinValue;
|
||||
}
|
||||
|
||||
base.OnHitByProjectile(npc, projectile, hitInfo, damage);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ namespace YHTMod.Items;
|
||||
|
||||
public class CopperSwordOnAStick : ModItem {
|
||||
public override void SetStaticDefaults() {
|
||||
DisplayName.SetDefault("Copper Sword On A Stick");
|
||||
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
|
||||
}
|
||||
|
||||
|
||||
+34
-30
@@ -6,47 +6,51 @@ using Terraria.ModLoader;
|
||||
|
||||
namespace YHTMod.Items;
|
||||
|
||||
public class KatanaRedo : GlobalItem {
|
||||
|
||||
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."));
|
||||
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) {
|
||||
if (item.type != ItemID.Katana) {
|
||||
return base.AltFunctionUse(item, player);
|
||||
}
|
||||
return true;
|
||||
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;
|
||||
for (int i = 0; i < Main.maxNPCs; i++) {
|
||||
NPC npc = Main.npc[i];
|
||||
var 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];
|
||||
if (!npc.CanBeChasedBy()) continue;
|
||||
|
||||
float between = Vector2.Distance(npc.Center, player.Center);
|
||||
bool inRange = between < 650;
|
||||
|
||||
bool lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position,
|
||||
var between = Vector2.Distance(npc.Center, player.Center);
|
||||
var inRange = between < 650;
|
||||
|
||||
var lineOfSight = Collision.CanHitLine(player.position, player.width, player.height, npc.position,
|
||||
npc.width, npc.height);
|
||||
|
||||
if (inRange && lineOfSight) {
|
||||
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;
|
||||
|
||||
player.Teleport(tpPos, TeleportationStyleID.RodOfDiscord);
|
||||
player.velocity = Vector2.Zero;
|
||||
player.NinjaDodge();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!inRange || !lineOfSight) continue;
|
||||
var 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;
|
||||
|
||||
player.Teleport(tpPos, TeleportationStyleID.RodOfDiscord);
|
||||
player.velocity = Vector2.Zero;
|
||||
player.NinjaDodge();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,6 @@ namespace YHTMod.Items;
|
||||
|
||||
public class MithrilPebbleOfPigSmiting : ModItem {
|
||||
public override void SetStaticDefaults() {
|
||||
DisplayName.SetDefault("Mithril Pebble of Pig Smiting");
|
||||
Tooltip.SetDefault(
|
||||
"For you see long ago this pebble was forged in the fiery pits of Tartarus. By the grand blacksmith of Lucifer himself. In a time before the world began there were\n" +
|
||||
"pigs that roamed the world of aincrad. They took what they pleased and did what they wanted. The humans tried to survive but the pigs were too powerful. Then a man stood against the hogs!\n" +
|
||||
"His name... Well its not a Him its a Her...HER name...was...Akane! Lucifer crafted this mighty weapon for Akane. Amd she threw it Over and Over, Again and Again. She freed\n" +
|
||||
"the humans but the pigs wouldn't give up! In a mighty battle Akane fell to the Hogs Hero, Becon! Like Bacon but with a 'E' instead of a 'A'. ANYWAY Becon used his Cleaver to strike\n" +
|
||||
"down Akane. And the pebble fell. One of the hogs tried to pick it up but that hog died as soon as he touched the stone. Another Hero picked up the pebble. It was Akanes Apprentice. Sophie.\n" +
|
||||
"The hogs ran from the battlefield as Sophie threw the pebble. Striking many of them down. But there were too many. After returning home Sophie trained hard and set off to find Becon.\n" +
|
||||
"She killed hog after hog looking for him. One little piggy spilled and told her when he was. She made Becon, Into Bacon. Battle after battle the Hogs Became weaker. With time so did Sophie.\n" +
|
||||
"She died because she ate too much Pork. And the Pebble was passed too Marjosa. He made a decision. Instead of killing them all. He made them walk on four legs. He would eat them and keep them\n" +
|
||||
"locked up where they cant escape. Some Hogs rebelled but most of them went with it. Accepting defeat. Then as Marjosa was Hunting wild Hogs. 3 appeared at once. Taking him by surprise.\n" +
|
||||
"They hit him with there sharp horns. Marjosa hit the with the Mighty Pebble killing them all but he was weak and far from anyone who could offer help. And Thus, Marjosa\n" +
|
||||
"Guardian of the Pebble fell to his knees and passed from this world. Leaving behind the mighty weapon. For he knew. One day its power would be required once more.\n" +
|
||||
"But the Legacy of the pebble lives on.");
|
||||
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace YHTMod.Items;
|
||||
public class ToclafaneStaff : ModItem {
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
DisplayName.SetDefault("Toclafane Staff");
|
||||
Tooltip.SetDefault("Summons a toclafane to remove population for you");
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
Buffs: {
|
||||
ToclafaneMinionBuff: {
|
||||
DisplayName: Summon Toclafane
|
||||
Description: It came from a parallel world to fight for its Master.
|
||||
}
|
||||
}
|
||||
|
||||
Items: {
|
||||
ArcaneMissile: {
|
||||
DisplayName: Arcane Missile
|
||||
Tooltip:
|
||||
'''
|
||||
Magical projectile crits shoot a homing arcane missile
|
||||
Arcane missiles cannot crit
|
||||
'''
|
||||
}
|
||||
|
||||
CopperSwordOnAStick: {
|
||||
DisplayName: Copper Sword On A Stick
|
||||
Tooltip: ""
|
||||
}
|
||||
|
||||
MithrilPebbleOfPigSmiting: {
|
||||
DisplayName: Mithril Pebble Of Pig Smiting
|
||||
Tooltip:
|
||||
'''
|
||||
For you see long ago this pebble was forged in the fiery pits of Tartarus. By the grand blacksmith of Lucifer himself.
|
||||
In a time before the world began there were pigs that roamed the world of Aincrad. They took what they pleased and did
|
||||
what they wanted. The humans tried to survive but the pigs were too powerful. Then a man stood against the hogs! His
|
||||
name... Well its not a Him its a Her...HER name...was...Akane! Lucifer crafted this mighty weapon for Akane. And she
|
||||
threw it Over and Over, Again and Again. She freed the humans but the pigs wouldn't give up! In a mighty battle Akane
|
||||
fell to the Hogs Hero, Becon! Like Bacon but with a 'E' instead of a 'A'. ANYWAY Becon used his Cleaver to strike down
|
||||
Akane. And the pebble fell. One of the hogs tried to pick it up but that hog died as soon as he touched the stone.
|
||||
Another Hero picked up the pebble. It was Akane's Apprentice. Sophie. The hogs ran from the battlefield as Sophie threw
|
||||
the pebble. Striking many of them down. But there were too many. After returning home Sophie trained hard and set off
|
||||
to find Becon. She killed hog after hog looking for him. One little piggy spilled and told her when he was. She made
|
||||
Becon, Into Bacon. Battle after battle the Hogs Became weaker. With time so did Sophie. She died because she ate too
|
||||
much Pork. And the Pebble was passed too Marjosa. He made a decision. Instead of killing them all. He made them walk
|
||||
on four legs. He would eat them and keep them locked up where they cant escape. Some Hogs rebelled but most of them
|
||||
went with it. Accepting defeat. Then as Marjosa was Hunting wild Hogs. 3 appeared at once. Taking him by surprise.
|
||||
They hit him with there sharp horns. Marjosa hit the with the Mighty Pebble killing them all but he was weak and far
|
||||
from anyone who could offer help. And Thus, Marjosa Guardian of the Pebble fell to his knees and passed from this
|
||||
world. Leaving behind the mighty weapon. For he knew. One day its power would be required once more.
|
||||
But the Legacy of the pebble lives on.
|
||||
'''
|
||||
}
|
||||
|
||||
ToclafaneStaff: {
|
||||
DisplayName: Toclafane Staff
|
||||
Tooltip: Summons a toclafane to remove population for you
|
||||
}
|
||||
}
|
||||
|
||||
Projectiles: {
|
||||
CopperSwordOnAStickProjectile.DisplayName: Copper Sword On A Stick
|
||||
MithrilPebbleOfPigSmitingProjectile.DisplayName: Mithril Pebble Of Pig Smiting
|
||||
ToclafaneMinion.DisplayName: Toclafane Minion
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class MithrilPebbleOfPigSmitingProjectile : ModProjectile {
|
||||
base.AI();
|
||||
DrawOriginOffsetX = 0;
|
||||
DrawOffsetX = 0;
|
||||
int dust = Dust.NewDust(Projectile.Center, 1, 1, DustID.Mythril, 0f, 0f, 0, default(Color), 1f);
|
||||
var 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;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ using YHTMod.Buffs;
|
||||
|
||||
namespace YHTMod.Projectiles.Weapons;
|
||||
|
||||
public class ToclafaneMinion : ModProjectile {
|
||||
public class ToclafaneMinion : ModProjectile
|
||||
{
|
||||
private int _shootCooldown = 0;
|
||||
private AttackMode _attackMode = AttackMode.Ranged;
|
||||
|
||||
private int shootCooldown = 0;
|
||||
private AttackMode attackMode = AttackMode.RANGED;
|
||||
|
||||
public override void SetStaticDefaults() {
|
||||
DisplayName.SetDefault("Toclafane Minion");
|
||||
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,7 +23,8 @@ 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;
|
||||
@@ -36,24 +37,29 @@ 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() {
|
||||
Player player = Main.player[Projectile.owner];
|
||||
public override void AI()
|
||||
{
|
||||
var 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;
|
||||
}
|
||||
|
||||
@@ -61,13 +67,14 @@ public class ToclafaneMinion : ModProjectile {
|
||||
|
||||
#region General behavior
|
||||
|
||||
if (shootCooldown > 0) {
|
||||
shootCooldown = shootCooldown - 1;
|
||||
if (_shootCooldown > 0)
|
||||
{
|
||||
_shootCooldown = _shootCooldown - 1;
|
||||
}
|
||||
|
||||
attackMode = AttackMode.RANGED;
|
||||
_attackMode = AttackMode.Ranged;
|
||||
|
||||
Vector2 idlePosition = player.Center;
|
||||
var idlePosition = player.Center;
|
||||
idlePosition.Y -= 48f;
|
||||
|
||||
float minionPositionOffsetX = (10 + Projectile.minionPos * 40) * -player.direction;
|
||||
@@ -76,9 +83,10 @@ public class ToclafaneMinion : ModProjectile {
|
||||
// All of this code below this line is adapted from Spazmamini code (ID 388, aiStyle 66)
|
||||
|
||||
// Teleport to player if distance is too big
|
||||
Vector2 vectorToIdlePosition = idlePosition - Projectile.Center;
|
||||
float distanceToIdlePosition = vectorToIdlePosition.Length();
|
||||
if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f) {
|
||||
var vectorToIdlePosition = idlePosition - Projectile.Center;
|
||||
var distanceToIdlePosition = vectorToIdlePosition.Length();
|
||||
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;
|
||||
@@ -87,18 +95,18 @@ public class ToclafaneMinion : ModProjectile {
|
||||
}
|
||||
|
||||
// If your minion is flying, you want to do this independently of any conditions
|
||||
float overlapVelocity = 0.04f;
|
||||
for (int i = 0; i < Main.maxProjectiles; i++) {
|
||||
const float overlapVelocity = 0.04f;
|
||||
for (var i = 0; i < Main.maxProjectiles; i++)
|
||||
{
|
||||
// Fix overlap with other minions
|
||||
Projectile other = Main.projectile[i];
|
||||
if (i != Projectile.whoAmI && other.active && other.owner == Projectile.owner &&
|
||||
Math.Abs(Projectile.position.X - other.position.X) +
|
||||
Math.Abs(Projectile.position.Y - other.position.Y) < Projectile.width) {
|
||||
if (Projectile.position.X < other.position.X) Projectile.velocity.X -= overlapVelocity;
|
||||
else Projectile.velocity.X += overlapVelocity;
|
||||
if (Projectile.position.Y < other.position.Y) Projectile.velocity.Y -= overlapVelocity;
|
||||
else Projectile.velocity.Y += overlapVelocity;
|
||||
}
|
||||
var other = Main.projectile[i];
|
||||
if (i == Projectile.whoAmI || !other.active || other.owner != Projectile.owner ||
|
||||
!(Math.Abs(Projectile.position.X - other.position.X) +
|
||||
Math.Abs(Projectile.position.Y - other.position.Y) < Projectile.width)) continue;
|
||||
if (Projectile.position.X < other.position.X) Projectile.velocity.X -= overlapVelocity;
|
||||
else Projectile.velocity.X += overlapVelocity;
|
||||
if (Projectile.position.Y < other.position.Y) Projectile.velocity.Y -= overlapVelocity;
|
||||
else Projectile.velocity.Y += overlapVelocity;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -106,40 +114,42 @@ public class ToclafaneMinion : ModProjectile {
|
||||
#region Find target
|
||||
|
||||
// Starting search distance
|
||||
float distanceFromTarget = 700f;
|
||||
Vector2 targetCenter = Projectile.position;
|
||||
bool foundTarget = false;
|
||||
var distanceFromTarget = 700f;
|
||||
var targetCenter = Projectile.position;
|
||||
var foundTarget = false;
|
||||
|
||||
// This code is required if your minion weapon has the targeting feature
|
||||
if (player.HasMinionAttackTargetNPC) {
|
||||
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
||||
float between = Vector2.Distance(npc.Center, Projectile.Center);
|
||||
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 (int i = 0; i < Main.maxNPCs; i++) {
|
||||
NPC npc = Main.npc[i];
|
||||
if (npc.CanBeChasedBy()) {
|
||||
float between = Vector2.Distance(npc.Center, Projectile.Center);
|
||||
bool closest = Vector2.Distance(Projectile.Center, targetCenter) > between;
|
||||
bool inRange = between < distanceFromTarget;
|
||||
bool lineOfSight = Collision.CanHitLine(Projectile.position, Projectile.width,
|
||||
Projectile.height, npc.position, npc.width, npc.height);
|
||||
// Additional check for this specific minion behavior, otherwise it will stop attacking once it dashed through an enemy while flying though tiles afterwards
|
||||
// The number depends on various parameters seen in the movement code below. Test different ones out until it works alright
|
||||
bool closeThroughWall = between < 100f;
|
||||
if (((closest && inRange) || !foundTarget) && (lineOfSight || closeThroughWall)) {
|
||||
distanceFromTarget = between;
|
||||
targetCenter = npc.Center;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
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);
|
||||
var closest = Vector2.Distance(Projectile.Center, targetCenter) > between;
|
||||
var inRange = between < distanceFromTarget;
|
||||
var lineOfSight = Collision.CanHitLine(Projectile.position, Projectile.width,
|
||||
Projectile.height, npc.position, npc.width, npc.height);
|
||||
// Additional check for this specific minion behavior, otherwise it will stop attacking once it dashed through an enemy while flying though tiles afterwards
|
||||
// The number depends on various parameters seen in the movement code below. Test different ones out until it works alright
|
||||
var closeThroughWall = between < 100f;
|
||||
if (((!closest || !inRange) && foundTarget) || (!lineOfSight && !closeThroughWall)) continue;
|
||||
distanceFromTarget = between;
|
||||
targetCenter = npc.Center;
|
||||
foundTarget = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,46 +160,56 @@ public class ToclafaneMinion : ModProjectile {
|
||||
#region Movement
|
||||
|
||||
// Default movement parameters (here for attacking)
|
||||
float speed = 8f;
|
||||
float inertia = 20f;
|
||||
var speed = 8f;
|
||||
var inertia = 20f;
|
||||
|
||||
if (foundTarget) {
|
||||
Vector2 direction = targetCenter - Projectile.Center;
|
||||
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;
|
||||
}
|
||||
|
||||
if (distanceFromTarget <= 120f) {
|
||||
attackMode = AttackMode.MELEE;
|
||||
}
|
||||
|
||||
if (distanceFromTarget > 120f && shootCooldown == 0) {
|
||||
shootCooldown = 60; // 1 second between shots
|
||||
Projectile laser = Projectile.NewProjectileDirect(player.GetSource_FromThis(), Projectile.Center,
|
||||
direction, ProjectileID.DeathLaser, 30, Projectile.knockBack, Projectile.owner);
|
||||
laser.friendly = true;
|
||||
laser.hostile = false;
|
||||
laser.penetrate = 5;
|
||||
attackMode = AttackMode.RANGED;
|
||||
switch (distanceFromTarget)
|
||||
{
|
||||
case <= 120f:
|
||||
_attackMode = AttackMode.Melee;
|
||||
break;
|
||||
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);
|
||||
laser.friendly = true;
|
||||
laser.hostile = false;
|
||||
laser.penetrate = 5;
|
||||
_attackMode = AttackMode.Ranged;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -197,7 +217,8 @@ 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;
|
||||
@@ -211,66 +232,67 @@ public class ToclafaneMinion : ModProjectile {
|
||||
// So it will lean slightly towards the direction it's moving
|
||||
Projectile.rotation = Projectile.velocity.X * 0.05f;
|
||||
|
||||
int frameSpeed = 8;
|
||||
const int frameSpeed = 8;
|
||||
Projectile.frameCounter++;
|
||||
if (Projectile.frameCounter >= frameSpeed) {
|
||||
if (Projectile.frameCounter >= frameSpeed)
|
||||
{
|
||||
Projectile.frameCounter = 0;
|
||||
if (attackMode == AttackMode.MELEE) {
|
||||
switch (Projectile.frame) {
|
||||
case 0:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 1:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 2:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 3:
|
||||
Projectile.frame = 0;
|
||||
break;
|
||||
case 4:
|
||||
Projectile.frame = 1;
|
||||
break;
|
||||
case 5:
|
||||
Projectile.frame = 2;
|
||||
break;
|
||||
case 6:
|
||||
Projectile.frame = 3;
|
||||
break;
|
||||
case 7:
|
||||
Projectile.frame = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (_attackMode)
|
||||
{
|
||||
case AttackMode.Melee:
|
||||
switch (Projectile.frame)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 3:
|
||||
Projectile.frame = 0;
|
||||
break;
|
||||
case 4:
|
||||
Projectile.frame = 1;
|
||||
break;
|
||||
case 5:
|
||||
Projectile.frame = 2;
|
||||
break;
|
||||
case 6:
|
||||
Projectile.frame = 3;
|
||||
break;
|
||||
case 7:
|
||||
Projectile.frame = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
if (attackMode == AttackMode.RANGED) {
|
||||
switch (Projectile.frame) {
|
||||
case 0:
|
||||
Projectile.frame = 5;
|
||||
break;
|
||||
case 1:
|
||||
Projectile.frame = 6;
|
||||
break;
|
||||
case 2:
|
||||
Projectile.frame = 7;
|
||||
break;
|
||||
case 3:
|
||||
Projectile.frame = 4;
|
||||
break;
|
||||
case 4:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 5:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 6:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 7:
|
||||
Projectile.frame = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case AttackMode.Ranged:
|
||||
switch (Projectile.frame)
|
||||
{
|
||||
case 0:
|
||||
Projectile.frame = 5;
|
||||
break;
|
||||
case 1:
|
||||
Projectile.frame = 6;
|
||||
break;
|
||||
case 2:
|
||||
Projectile.frame = 7;
|
||||
break;
|
||||
case 3:
|
||||
Projectile.frame = 4;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
Projectile.frame++;
|
||||
break;
|
||||
case 7:
|
||||
Projectile.frame = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +301,9 @@ public class ToclafaneMinion : ModProjectile {
|
||||
#endregion
|
||||
}
|
||||
|
||||
enum AttackMode {
|
||||
MELEE,
|
||||
RANGED
|
||||
private enum AttackMode
|
||||
{
|
||||
Melee,
|
||||
Ranged,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace YHTMod;
|
||||
|
||||
public class YhtPlayer : ModPlayer {
|
||||
|
||||
public int arcaneMissle = 0;
|
||||
public int katanaTeleportCooldown = 0;
|
||||
|
||||
public override void PreUpdate() {
|
||||
this.katanaTeleportCooldown = Math.Max(this.katanaTeleportCooldown - 1, 0);
|
||||
}
|
||||
|
||||
public override void ResetEffects() {
|
||||
|
||||
this.arcaneMissle = 0;
|
||||
|
||||
base.ResetEffects();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
displayName = YHT Mod
|
||||
author = YouHaveTrouble
|
||||
version = 1.0.1
|
||||
version = 1.1.2
|
||||
@@ -1,5 +1,7 @@
|
||||
Bunch of random additions ranging from QoL to random references
|
||||
|
||||
All new content and changes are documented on the wiki.
|
||||
|
||||
Wiki: https://github.com/YouHaveTrouble/YHTMod/wiki
|
||||
Source: https://github.com/YouHaveTrouble/YHTMod
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
A bunch of random additions ranging from QoL to random references
|
||||
|
||||
Steam workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=2897350075
|
||||
|
||||
Mod wiki: https://github.com/YouHaveTrouble/YHTMod/wiki
|
||||
|
||||
Discussion discord: [](https://discord.gg/j8KK5dGBps)
|
||||
|
||||
Code: YouHaveTrouble
|
||||
|
||||
Sprites: YouHaveTrouble, Patrxon
|
||||
Reference in New Issue
Block a user