Flamingfury56
Terrarian
I need help, i am trying to make it so that if you are within a certain radius (about 10 to 20 blocks) of this projectile then you will get the regen buff. However it gives you regen if you are anywhere while the projectile is out. Anyone know how to do that or know what i'm doing wrong? Help would be much appreciated
Thank you in advance
Thank you in advance
Code:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System;
namespace RCT.Projectiles
{
public class MedicSphereBallProj : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Guardian Sphere Projectile";
projectile.width = 20;
projectile.height = 20;
projectile.aiStyle = 47;
projectile.ranged = true;
projectile.penetrate = 2;
projectile.timeLeft = 1800;
projectile.ignoreWater = true;
projectile.friendly = true;
projectile.hostile = false;
projectile.tileCollide = false;
}
public override void AI()
{
projectile.rotation += (float)projectile.direction * 0.8f;
projectile.light = 1;
Player owner = Main.player[projectile.owner];
if (owner.position.X - projectile.position.X <= 10f && owner.position.Y - projectile.position.Y <= 10f || owner.position.X - projectile.position.X >= 10f && owner.position.Y - projectile.position.Y >= 10f || owner.position.X - projectile.position.X <= 10f && owner.position.Y - projectile.position.Y >= 10f || owner.position.X - projectile.position.X >= 10f && owner.position.Y - projectile.position.Y <= 10f)
{
owner.AddBuff(2, 1800);
}
}
}
}