public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            projectile.aiStyle = -1;
            double mul = 1.00;

            JavelinProj.JavelinOnHit(target, projectile, ref mul);
            damage = (int)(damage * mul);

            int foundsticker = 0;

            for (int i = 0; i < Main.maxProjectiles; i++) // Loop all projectiles
            {
                Projectile currentProjectile = Main.projectile[i];
                if (i != projectile.whoAmI && // Make sure the looped projectile is not the current javelin
                    currentProjectile.active && // Make sure the projectile is active
                    currentProjectile.owner == Main.myPlayer && // Make sure the projectile's owner is the client's player
                    currentProjectile.type == projectile.type && // Make sure the projectile is of the same type as this javelin
                    currentProjectile.modProjectile is JavelinProj JavelinProjz && // Use a pattern match cast so we can access the projectile like an ExampleJavelinProjectile
                    JavelinProjz.stickin == target.whoAmI)
                {
                    foundsticker += 1;
                    //projectile.Kill();
                }
            }

            if (foundsticker < maxstick)
            {
                if (projectile.penetrate > 1)
                {
                    offset  = (target.Center - projectile.Center);
                    stickin = target.whoAmI;
                    projectile.netUpdate = true;
                }
            }
        }
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            double blank = 1.0;

            JavelinProj.JavelinOnHit(target, projectile, ref blank);
        }
        public override void AI()
        {
            projectile.localAI[0] -= 1f;
            float facingleft = projectile.velocity.X > 0 ? 1f : -1f;

            projectile.rotation = ((float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f) + (float)((Math.PI) * -0.25f);

            if (projectile.ignoreWater == true)
            {
                projectile.ignoreWater = false;
                if (Main.dedServ)
                {
                    Texture2D texture = ModContent.GetTexture(JavelinProj.tex[(int)projectile.ai[1]]);
                    int       xx      = (texture.Width - (int)(projectile.width)) / 2;
                    int       yy      = (texture.Height - (int)(projectile.height)) / 2;
                    projectile.position.X -= (xx / 2);
                    projectile.position.Y -= (yy / 2);
                    projectile.width       = texture.Width / 2;
                    projectile.height      = texture.Height / 2;
                }
            }

            if (stickin > -1)
            {
                NPC himz = Main.npc[stickin];
                projectile.tileCollide = false;

                if ((himz != null && himz.active) && projectile.penetrate > 0)
                {
                    projectile.Center = (himz.Center - offset) - (projectile.velocity * 0.2f);
                    if (projectile.timeLeft < 100)
                    {
                        projectile.penetrate -= 1;
                        projectile.timeLeft   = 100 + maxStickTime;
                        double damageperc = 0.75;

                        if (Main.player[projectile.owner].GetModPlayer <SGAPlayer>().JavelinBaseBundle)
                        {
                            damageperc += 0.25;
                        }

                        JavelinProj.JavelinOnHit(himz, projectile, ref damageperc);

                        int theDamage = (int)(projectile.damage * damageperc);
                        himz.StrikeNPC(theDamage, 0, 1);
                        Main.player[projectile.owner].addDPS(theDamage);

                        if (Main.netMode != NetmodeID.SinglePlayer)
                        {
                            NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, himz.whoAmI, (float)(projectile.damage * damageperc), 16f, (float)1, 0, 0, 0);
                        }
                    }
                }
                else
                {
                    projectile.Kill();
                }
            }
            else
            {
                if (projectile.ai[1] == (int)JavelinType.CrimsonCatastrophe)//Sanguine Bident
                {
                    if (stickin < 0)
                    {
                        for (float i = 2f; i > 0.25f; i -= Main.rand.NextFloat(0.25f, 1.25f))
                        {
                            Vector2 position = projectile.position + Vector2.Normalize(projectile.velocity) * Main.rand.NextFloat(0f, 48f);
                            position -= new Vector2(projectile.width, projectile.height) / 2f;
                            Dust dust = Dust.NewDustDirect(position, projectile.height, projectile.width, DustID.Fire, 0, 0, 200, Scale: 0.5f);
                            dust.velocity = new Vector2((projectile.velocity.X / 3f) * i, projectile.velocity.Y * i);

                            dust          = Dust.NewDustDirect(position, projectile.height, projectile.width, DustID.Blood, 0, 0, 200, Scale: 0.5f);
                            dust.velocity = new Vector2(projectile.velocity.X * i, (projectile.velocity.Y / 3f) * i);
                        }
                    }
                }
                else
                {
                    if (Main.rand.NextBool(3))
                    {
                        Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, DustID.LunarOre,
                                                       projectile.velocity.X * .2f, projectile.velocity.Y * .2f, 200, Scale: 0.5f);
                        dust.velocity += projectile.velocity * 0.3f;
                        dust.velocity *= 0.2f;
                    }
                }

                if (projectile.ai[1] == (int)JavelinType.CrimsonCatastrophe)
                {
                    if (projectile.aiStyle != 0)
                    {
                        float rotvalue = projectile.timeLeft / 300f;
                        projectile.velocity = projectile.velocity.RotatedBy(((projectile.aiStyle + 100f) / 1200f) * -rotvalue);
                    }
                    return;
                }

                if (projectile.velocity.Y < 16f)
                {
                    if (projectile.aiStyle < 1)
                    {
                        projectile.velocity = projectile.velocity + new Vector2(0, 0.1f);
                    }
                }
            }
        }
        public virtual void OnThrow(int type, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type2, ref int damage, ref float knockBack, JavelinProj jav)
        {
//nullz
        }
Пример #5
0
        public override void OnThrow(int type, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type2, ref int damage, ref float knockBack, JavelinProj madeproj)
        {
            if (type == 1)
            {
                Vector2 normalizedspeed = new Vector2(speedX, speedY);
                normalizedspeed.Normalize();
                normalizedspeed   *= (Throwspeed * player.thrownVelocity);
                normalizedspeed.Y -= Math.Abs(normalizedspeed.Y * 0.1f);
                if (player.altFunctionUse == 2)
                {
                    for (int i = -15; i < 16; i += 30)
                    {
                        Vector2 perturbedSpeed = ((new Vector2(normalizedspeed.X, normalizedspeed.Y)).RotatedBy(MathHelper.ToRadians(i))).RotatedByRandom(MathHelper.ToRadians(10)) * 0.85f;
                        float   scale          = 1f - (Main.rand.NextFloat() * .01f);
                        perturbedSpeed = perturbedSpeed * scale;
                        type2          = mod.ProjectileType("JavelinProj");

                        int thisoneddddd = Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type2, damage, knockBack, Main.myPlayer);
                        Main.projectile[thisoneddddd].ai[1]  = Speartype;
                        Main.projectile[thisoneddddd].melee  = false;
                        Main.projectile[thisoneddddd].thrown = true;

                        (Main.projectile[thisoneddddd].modProjectile as JavelinProj).maxstick = madeproj.maxstick;
                        Main.projectile[thisoneddddd].penetrate = madeproj.projectile.penetrate;
                        Main.projectile[thisoneddddd].netUpdate = true;
                        IdgProjectile.Sync(thisoneddddd);
                    }
                }
            }
        }
 public override void OnThrow(int type, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type2, ref int damage, ref float knockBack, JavelinProj madeproj)
 {
     //nothing
 }
Пример #7
0
 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     JavelinProj.JavelinOnHit(target, projectile);
 }
Пример #8
0
        public override void AI()
        {
            float facingleft = projectile.velocity.X > 0 ? 1f : -1f;

            projectile.rotation = ((float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f) + (float)((Math.PI) * -0.25f);

            Texture2D texture = ModContent.GetTexture(JavelinProj.tex[(int)projectile.ai[1]]);

            if (!hitboxchange)
            {
                hitboxchange = true;
                int xx = (texture.Width - (int)(projectile.width)) / 2;
                int yy = (texture.Height - (int)(projectile.height)) / 2;
                projectile.position.X -= (xx / 2);
                projectile.position.Y -= (yy / 2);
                projectile.width       = texture.Width / 2;
                projectile.height      = texture.Height / 2;
            }

            if (stickin > -1)
            {
                NPC himz = Main.npc[stickin];
                projectile.tileCollide = false;

                if ((himz != null && himz.active) && projectile.penetrate > 0)
                {
                    projectile.Center = (himz.Center - offset) - (projectile.velocity * 0.2f);
                    if (projectile.timeLeft < 100)
                    {
                        projectile.penetrate -= 1;
                        projectile.timeLeft   = 200;
                        JavelinProj.JavelinOnHit(himz, projectile);
                        double damageperc = 0.75;
                        if (Main.player[projectile.owner].GetModPlayer <SGAPlayer>().JavelinBaseBundle)
                        {
                            damageperc += 0.25;
                        }
                        himz.StrikeNPC((int)(projectile.damage * damageperc), 0, 1);
                    }
                }
                else
                {
                    projectile.Kill();
                }
            }
            else
            {
                if (Main.rand.NextBool(3))
                {
                    Dust dust = Dust.NewDustDirect(projectile.position, projectile.height, projectile.width, DustID.LunarOre,
                                                   projectile.velocity.X * .2f, projectile.velocity.Y * .2f, 200, Scale: 0.5f);
                    dust.velocity += projectile.velocity * 0.3f;
                    dust.velocity *= 0.2f;
                }

                if (projectile.velocity.Y < 16f)
                {
                    if (projectile.aiStyle < 1)
                    {
                        projectile.velocity = projectile.velocity + new Vector2(0, 0.1f);
                    }
                }
            }
        }