Example #1
0
        public override void PickAmmo(Item weapon, Item ammo, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
        {
            EGGPlayer modPlayer = player.GetModPlayer <EGGPlayer>();

            if (weapon.useAmmo == AmmoID.Bullet && modPlayer.gunslingerBuff)
            {
                knockback = (int)((double)((float)knockback) * 1.2f);
                damage    = (int)((double)((float)damage) * 1.2f);
            }
            base.PickAmmo(weapon, ammo, player, ref type, ref speed, ref damage, ref knockback);
        }
Example #2
0
        public override bool PreAI(Projectile projectile)
        {
            Player    owner     = Main.player[projectile.owner];
            EGGPlayer modPlayer = owner.GetModPlayer <EGGPlayer>();

            //if (modPlayer.hasMuzzle || modPlayer.hasMag) //Test for muzzle and ranged projectile
            //{
            //    //if (bulletTypes.Contains(projectile.type)) {
            //    //    projectile.extraUpdates = 600;
            //    //    projectile.alpha = 255;
            //    //    HitscanBeamAI(projectile);
            //    //}
            //}
            if (projectile.ranged && projectile.friendly && !projectile.npcProj && projectile.owner == Main.myPlayer)
            {
            }
            return(base.PreAI(projectile));
        }
Example #3
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            EGGModMessageType msgType = (EGGModMessageType)reader.ReadByte();

            switch (msgType)
            {
            // This message syncs ExamplePlayer.exampleLifeFruits
            case EGGModMessageType.EGGPlayerSyncPlayer:
                byte      playernumber = reader.ReadByte();
                EGGPlayer modPlayer    = Main.player[playernumber].GetModPlayer <EGGPlayer>();
                int       serums       = reader.ReadInt32();
                modPlayer.serums = serums;
                // SyncPlayer will be called automatically, so there is no need to forward this data to other clients.
                break;

            default:
                //.WarnFormat("ExtraGunGear: Unknown Message type: {0}", msgType);
                break;
            }
            //ModNetHandler.HandlePacket(reader, whoAmI);
        }
Example #4
0
 public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit)
 {
     if (projectile.ranged && projectile.friendly && projectile.owner == Main.myPlayer && !projectile.npcProj)
     {
         Player    owner     = Main.player[projectile.owner];
         EGGPlayer modPlayer = owner.GetModPlayer <EGGPlayer>();
         //Test for bullet types
         //(projectile.type == ProjectileID.Bullet) || (projectile.type == ProjectileID.BulletHighVelocity) || (projectile.type == ProjectileID.ChlorophyteBullet) || (projectile.type == ProjectileID.CrystalBullet) || (projectile.type == ProjectileID.CursedBullet) || (projectile.type == ProjectileID.ExplosiveBullet) || (projectile.type == ProjectileID.GoldenBullet) || (projectile.type == ProjectileID.IchorBullet) || (projectile.type == ProjectileID.MoonlordBullet) || (projectile.type == ProjectileID.NanoBullet) || (projectile.type == ProjectileID.PartyBullet) || (projectile.type == ProjectileID.VenomBullet))
         if (modPlayer.hasMuzzle) //Test for muzzle and ranged projectile
         {
             if (bulletTypes.Contains(projectile.type))
             {
                 target.AddBuff(BuffID.OnFire, 60 * 8);
             }
         }
         if (modPlayer.hasMag) //Test for muzzle and ranged projectile
         {
             target.AddBuff(BuffID.ShadowFlame, 60 * 12);
         }
     }
     base.OnHitNPC(projectile, target, damage, knockback, crit);
 }
Example #5
0
        public override bool ConsumeAmmo(Item weapon, Item ammo)
        {
            EGGPlayer modPlayer = Main.player[weapon.owner].GetModPlayer <EGGPlayer>();
            //if (!base.ConsumeAmmo(weapon, ammo)) return false;
            Random rnd = new Random();

            if (modPlayer.hasMag)
            {
                double saveChance = rnd.NextDouble();
                if (saveChance < 0.20)
                {
                    return(false);
                }
            }
            if (modPlayer.hasBeskarBreast)
            {
                double saveChance = rnd.NextDouble();
                if (saveChance < 0.30)
                {
                    return(false);
                }
            }
            return(base.ConsumeAmmo(weapon, ammo));
        }
Example #6
0
        public override void AI(Projectile projectile)
        {
            Player    owner     = Main.player[projectile.owner];
            EGGPlayer modPlayer = owner.GetModPlayer <EGGPlayer>();

            if (projectile.ranged && projectile.friendly && !projectile.npcProj /* && projectile.owner == Main.myPlayer*/)
            {
                //Vector2 cursor = (Main.MouseWorld - owner.Center).SafeNormalize(Vector2.UnitX);
                //Vector2 projVelocity = cursor * projectile.velocity.Length();
                //if (modPlayer.hasGrip && (projectile.timeLeft == 600)) //Test for grip and test that the bullet just spawned
                //{
                //    //float angle = projectile.velocity.ToRotation().AngleTowards(projVelocity.ToRotation(), 30);
                //    //if (projectile.velocity.ToRotation() > projVelocity.RotatedBy(Math.PI / 12).ToRotation())/*projectile velocity rotation is greater than threshold*/{
                //    //Vector2 perturbedSpeed = projVelocity.RotatedByRandom(MathHelper.ToRadians(1f));
                //    projectile.velocity.X = projVelocity.X;
                //    projectile.velocity.Y = projVelocity.Y;
                //    projectile.netUpdate = true;
                //    //}
                //}
                if (Main.myPlayer == projectile.owner)
                {
                    Vector2 cursor       = (Main.MouseWorld - owner.Center).SafeNormalize(Vector2.UnitX);
                    Vector2 projVelocity = cursor * projectile.velocity.Length();
                    if (modPlayer.hasGrip && (projectile.timeLeft == 600) && modPlayer.gripEnabled) //Test for grip and test that the bullet just spawned
                    {
                        //float angle = projectile.velocity.ToRotation().AngleTowards(projVelocity.ToRotation(), 30);
                        //if (projectile.velocity.ToRotation() > projVelocity.RotatedBy(Math.PI / 12).ToRotation())/*projectile velocity rotation is greater than threshold*/{
                        //Vector2 perturbedSpeed = projVelocity.RotatedByRandom(MathHelper.ToRadians(1f));
                        projectile.velocity.X = projVelocity.X;
                        projectile.velocity.Y = projVelocity.Y;
                        projectile.netUpdate  = true;
                        //}
                    }
                }

                if ((modPlayer.hasMuzzle || modPlayer.hasMag) && modPlayer.muzzleEnabled) //Test for muzzle and ranged projectile
                {
                    if (bulletTypes.Contains(projectile.type))
                    {
                        projectile.extraUpdates = 100;
                        projectile.alpha        = 255;
                        HitscanBeamAI(projectile);
                        projectile.netUpdate = true;
                    }
                    if (modPlayer.hasMuzzle)
                    {
                        Lighting.AddLight(projectile.position, 1f, 0.40f, 0f);
                        if (Main.rand.Next(2) == 0)
                        {
                            Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire);
                        }
                        projectile.netUpdate = true;
                    }
                    if (modPlayer.hasMag)
                    {
                        Lighting.AddLight(projectile.position, 1f, 0.40f, 0f);
                        if (Main.rand.Next(2) == 0)
                        {
                            Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Shadowflame);
                        }
                        projectile.netUpdate = true;
                    }
                }
            }
            projectile.netUpdate = true;
            base.AI(projectile);
        }
Example #7
0
 public override void SendClientChanges(ModPlayer clientPlayer)
 {
     // Here we would sync something like an RPG stat whenever the player changes it.
     EGGPlayer clone = clientPlayer as EGGPlayer;
 }
Example #8
0
 public override void clientClone(ModPlayer clientClone)
 {
     // Here we would make a backup clone of values that are only correct on the local players Player instance.
     EGGPlayer clone = clientClone as EGGPlayer;
 }