示例#1
0
        public static void ProjectileTypeCheck(Projectile projectile, Item item, ref Item returnitem)
        {
            Dictionary <int, int[]> ProjectileTypeOverride = new Dictionary <int, int[]>()
            {
                { 469, new int[] { 181, 566 } }
            };

            string[] ProjectileTypeNameOverride = new string[] { "CrystiliumMod.Projectiles.DiamondBomb", "CrystiliumMod.Projectiles.Shatter1",
                                                                 "CrystiliumMod.Projectiles.Shatter2", "CrystiliumMod.Projectiles.Shatter3", "SacredTools.Projectiles.FrostExplosion", "SacredTools.Projectiles.CerniumMist",
                                                                 "SacredTools.Projectiles.DarkExplosion", "SacredTools.Projectiles.FlameExplosion", "SacredTools.Projectiles.JusticeSpark", "SpiritMod.Projectiles.Fire" };

            if (item.shoot == projectile.type || (ProjectileTypeOverride.ContainsKey(item.shoot) && ProjectileTypeOverride[item.shoot].Contains(projectile.type)))
            {
                returnitem = item;
            }
            else
            {
                ModProjectile mproj = projectile.modProjectile;
                if (mproj != null)
                {
                    Type mprojtype = mproj.GetType();
                    //Main.NewText(mprojtype.ToString());
                    if (ProjectileTypeNameOverride.Contains(mprojtype.ToString()))
                    {
                        returnitem = ColoredDamageTypes.ProjectileWeaponSpawns[projectile.identity];
                    }
                }
            }
        }
示例#2
0
        public static void LookAt(ModProjectile modProj, Vector2 target)
        {
            Projectile projectile = modProj.projectile;
            Vector2    delta      = target - projectile.position;

            projectile.rotation = (float)Math.Atan2(delta.X, -delta.Y);
        }
示例#3
0
        internal static void StopTime(ModPlayer modPlayer, int duration)
        {
            MainTime      = Main.time;
            MainRainTimer = Main.rainTime;

            for (int i = 0; i < Main.npc.Length; i++)
            {
                NPC npc = Main.npc[i];

                if (!npc.active || IsNPCImmune(npc))
                {
                    continue;
                }

                RegisterStoppedNPC(npc);
            }


            for (int i = 0; i < Main.projectile.Length - 1; i++)
            {
                Projectile projectile = Main.projectile[i];

                if (TBAMod.Instance.TimeStopImmuneProjectiles.Contains(projectile.type))
                {
                    continue;
                }

                if (!projectile.active || projectile.modProjectile is IProjectileHasImmunityToTimeStop phitts && phitts.IsNativelyImmuneToTimeStop())
                {
                    continue;
                }

                ModProjectile modProjectile = projectile.modProjectile as Stand;

                if (modProjectile != null && modProjectile.projectile.owner == modPlayer.player.whoAmI)
                {
                    continue;
                }

                RegisterStoppedProjectile(projectile);
            }


            for (int i = 0; i < Main.item.Length; i++)
            {
                Item item = Main.item[i];

                if (!item.active || IsImmune(item))
                {
                    continue;
                }

                RegisterStoppedItem(item);
            }


            TimeStopper    = modPlayer;
            TimeStoppedFor = duration;
        }
示例#4
0
        public static void HomingAIVanilla(ModProjectile modProj, NPC target, float velocity = 4f, float weight = 0.0333f)
        {
            Projectile projectile = modProj.projectile;
            Vector2    pos        = new Vector2(projectile.position.X + (projectile.width >> 1), projectile.position.Y + (projectile.height >> 1));
            Vector2    aim        = new Vector2(target.position.X + (target.width >> 1), target.position.Y + (target.height >> 1));

            aim -= pos;
            aim *= velocity / aim.Length();
            projectile.velocity *= 1f - weight;
            projectile.velocity += aim * weight;
        }
示例#5
0
        public static bool DrawProjectileCenteredWithTexture(this ModProjectile p, Texture2D texture, SpriteBatch spriteBatch, Color lightColor)
        {
            Rectangle     frame   = texture.Frame(1, Main.projFrames[p.projectile.type], 0, p.projectile.frame);
            Vector2       origin  = frame.Size() / 2 + new Vector2(p.drawOriginOffsetX, p.drawOriginOffsetY);
            SpriteEffects effects = p.projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            Vector2 drawPosition = p.projectile.Center - Main.screenPosition + new Vector2(p.drawOffsetX, 0);

            spriteBatch.Draw(texture, drawPosition, frame, lightColor, p.projectile.rotation, origin, p.projectile.scale, effects, 0f);

            return(false);
        }
示例#6
0
        public static void DrawProjectileTrailCenteredWithTexture(this ModProjectile p, Texture2D texture, SpriteBatch spriteBatch, Color drawColor, float initialOpacity = 0.8f, float opacityDegrade = 0.2f, int stepSize = 1)
        {
            Rectangle     frame   = texture.Frame(1, Main.projFrames[p.projectile.type], 0, p.projectile.frame);
            Vector2       origin  = frame.Size() / 2;
            SpriteEffects effects = p.projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            for (int i = 0; i < ProjectileID.Sets.TrailCacheLength[p.projectile.type]; i += stepSize)
            {
                float opacity = initialOpacity - opacityDegrade * i;
                spriteBatch.Draw(texture, p.projectile.oldPos[i] + p.projectile.Hitbox.Size() / 2 - Main.screenPosition, frame, drawColor * opacity, p.projectile.oldRot[i], origin, p.projectile.scale, effects, 0f);
            }
        }
        };                                                                                         //type of projectile, then corresponding type of buff

        public static void AddBuffs(Assembly code)
        {
            var autoloadminions = code.GetTypes().Where(x => x.IsSubclassOf(typeof(ModProjectile)) && Attribute.IsDefined(x, typeof(AutoloadMinionBuff)));             //read the assembly to find classes that are mod projectiles, and have the autoload minion buff attribute

            foreach (Type MinionType in autoloadminions)
            {
                AutoloadMinionBuff attribute   = (AutoloadMinionBuff)Attribute.GetCustomAttribute(MinionType, typeof(AutoloadMinionBuff));
                ModProjectile      mProjectile = (ModProjectile)Activator.CreateInstance(MinionType);
                SpiritMod.Instance.AddBuff(MinionType.Name + "_buff", new AutoloadedMinionBuff(SpiritMod.Instance.ProjectileType(MinionType.Name), attribute.BuffName, attribute.Description), MinionType.FullName.Replace(".", "/") + "_buff");
                BuffDictionary.Add(SpiritMod.Instance.ProjectileType(MinionType.Name), SpiritMod.Instance.BuffType(MinionType.Name + "_buff"));
            }
        }
示例#8
0
        public static void Bounce(ModProjectile modProj, Vector2 oldVelocity, float bouncyness = 1f)
        {
            Projectile projectile = modProj.projectile;

            if (projectile.velocity.X != oldVelocity.X)
            {
                projectile.velocity.X = -oldVelocity.X * bouncyness;
            }
            if (projectile.velocity.Y != oldVelocity.Y)
            {
                projectile.velocity.Y = -oldVelocity.Y * bouncyness;
            }
        }
示例#9
0
        /// <summary>
        /// Call this in <see cref="ModProjectile.SetStaticDefaults"/> to register this projectile into the "clicker class" category
        /// </summary>
        /// <param name="modProj">The <see cref="ModProjectile"/> that is to be registered</param>
        /// <exception cref="InvalidOperationException"/>
        public static void RegisterClickerProjectile(ModProjectile modProj)
        {
            if (ClickerClass.finalizedRegisterCompat)
            {
                throw new InvalidOperationException("Tried to register a clicker projectile at the wrong time, do so in ModProjectile.SetStaticDefaults");
            }
            int type = modProj.projectile.type;

            if (!ClickerProjectiles.Contains(type))
            {
                ClickerProjectiles.Add(type);
            }
        }
示例#10
0
        public override void PostSetupContent()
        {
            List <int> tempList = new List <int>();

            for (int i = Main.maxProjectileTypes; i < ProjectileLoader.ProjectileCount; i++)
            {
                ModProjectile mProj = ProjectileLoader.GetProjectile(i);
                if (mProj != null && mProj.mod.Name == "AssortedCrazyThings" && mProj.GetType().Name.StartsWith("CuteSlime"))
                {
                    tempList.Add(mProj.projectile.type);
                }
            }
            ACTPetsWithSmallVerticalHitbox = tempList.ToArray();
            Array.Sort(ACTPetsWithSmallVerticalHitbox);
        }
示例#11
0
        public void OnProjectileHitNPC(ModProjectile projectile, NPC npc, ref int damage, ref float knockback, ref bool crit)
        {
            if (IsArmorSet(Main.player[projectile.projectile.owner]))
            {
                int kiOrb = 0;

                if (Main.rand.Next(10) == 0)
                {
                    kiOrb = Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ModContent.ItemType <KiOrb>());
                }

                if (Main.netMode == 1 && kiOrb >= 0)
                {
                    NetMessage.SendData(MessageID.SyncItem, -1, -1, null, kiOrb, 1f, 0f, 0f, 0, 0, 0);
                }
            }
        }
示例#12
0
        private bool ModProjectileAction(int pWhoAmI)
        {
            ModProjectile mProj = ProjectileObject(pWhoAmI).modProjectile;

            if (mProj.mod.Name == modInstance.Name)
            {
                try
                {
                    FieldInfo field = mProj.GetType().GetField(damageType, BindingFlags.Public | BindingFlags.Instance);
                    return((bool)field.GetValue(mProj));
                }
                catch { return(false); }
            }
            else
            {
                return(false);
            }
        }
示例#13
0
        public static void HomingAI(ModProjectile modProj, NPC target, float velocity = 4f, float acceleration = 0.1f)
        {
            Projectile projectile = modProj.projectile;
            Vector2    aim        = new Vector2(target.position.X + (float)(target.width >> 1), target.position.Y + (float)(target.height >> 1));
            Vector2    pos        = new Vector2(projectile.position.X + (float)(projectile.width >> 1), projectile.position.Y + (float)(projectile.height >> 1));

            aim -= pos;
            aim *= velocity / aim.Length();
            Vector2 diff = aim - projectile.velocity;

            if (acceleration * acceleration >= diff.LengthSquared())
            {
                projectile.velocity = aim;
            }
            else
            {
                diff *= acceleration / diff.Length();
                projectile.velocity += diff;
            }
        }
示例#14
0
        public static ModProjectile GetModProjectile(string modname, string projname)
        {
            ModProjectile projectile = new ModProjectile();

            if (ModLoader.GetMod(modname) != null)
            {
                Mod mod = ModLoader.GetMod(modname);
                try
                {
                    projectile = mod.GetProjectile(projname);
                }
                catch (Exception)
                {
                    projectile = null;
                    throw new Exception("Can't find this projectile" + projname);
                }
            }

            return(projectile);
        }
示例#15
0
 public static Projectile ProjByName(string n)
 {
     if (n.Contains(":"))
     {
         string mName = n.Split(':')[0];
         string n2    = n.Split(':')[1];
         return(ModLoader.GetMod(mName).GetProjectile(n2).projectile);
     }
     else
     {
         string[] modNames = GetLoadedMods();
         foreach (string name in modNames)
         {
             Mod           mod = ModLoader.GetMod(name);
             ModProjectile m   = mod.GetProjectile(n);
             if (m != null)
             {
                 return(m.projectile);
             }
         }
     }
     return(null);
 }
示例#16
0
 public override void AI()
 {
     if (projectile.ai[0] > 0)
     {
         projectile.ai[0]--;
     }
     else if (projectile.timeLeft % 7 == 0)
     {
         Vector2       pos    = projectile.position + new Vector2(Main.rand.Next(projectile.width), Main.rand.Next(projectile.height));
         Projectile    proj   = Projectile.NewProjectileDirect(pos, Main.rand.NextVector2CircularEdge(3, 3), Felnum_Shock_Leader.ID, projectile.damage / 6, 0, projectile.owner, pos.X, pos.Y);
         ModProjectile parent = this;
         //Projectile parentProjectile = this.projectile;
         if (proj.modProjectile is Felnum_Shock_Leader shock)
         {
             shock.OnStrike += () => {
                 if (parent == projectile.modProjectile)
                 {
                     projectile.ai[0] = 14;
                 }
             };
         }
     }
 }
示例#17
0
        public static bool DrawProjectileCentered(this ModProjectile p, SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture = Main.projectileTexture[p.projectile.type];

            return(p.DrawProjectileCenteredWithTexture(texture, spriteBatch, lightColor));
        }
示例#18
0
 public static TBARGlobalProjectile GetGlobal(this ModProjectile p)
 {
     return(p.projectile.GetGlobalProjectile <TBARGlobalProjectile>());
 }
示例#19
0
        // this method will be improved later
        public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback,
                                                   ref bool crit, ref int hitDirection)
        {
            knockback = 0;
            crit      = false;

            for (int i = 0; i < ballProjectiles.Length; i++)
            {
                if (projectile.type == mod.ProjectileType(ballProjectiles[i]) && projectile.ai[1] == 1)
                {
                    if (ballProjectiles[i] == "MasterBallProjectile") // Master Ball never fails
                    {
                        Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <MasterBallCaught>());
                        return;
                    }
                    else if (ballProjectiles[i] == "ZeroBallProjectile") // Master Ball never fails
                    {
                        if (Main.rand.NextFloat() < .1190f)
                        {
                            Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <ZeroBallCaught>());
                            return;
                        }
                    }
                    else if (ballProjectiles[i] == "DuskBallProjectile") // Special Condition day/night
                    {
                        ballUsage++;
                        if (!Main.dayTime && Main.rand.NextFloat() < catchChances[i][0] ||
                            Main.dayTime && Main.rand.NextFloat() < catchChances[i][1])
                        {
                            Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <DuskBallCaught>());
                            return;
                        }
                    }
                    else if (ballProjectiles[i] == "QuickBallProjectile") // Special Condition
                    {
                        ballUsage++;
                        if (ballUsage == 1) // 2x catch chance
                        {
                            if (Main.rand.NextFloat() < .2380f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 2) // 1.8x catch chance
                        {
                            if (Main.rand.NextFloat() < .2142f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 3) // 1.6x catch chance
                        {
                            if (Main.rand.NextFloat() < .1904f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 4) // 1.4x catch chance
                        {
                            if (Main.rand.NextFloat() < .1666f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 5) // 1.2x catch chance
                        {
                            if (Main.rand.NextFloat() < .1428f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 6) // 1x catch chance
                        {
                            if (Main.rand.NextFloat() < .1190f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 7) // 0.75x catch chance
                        {
                            if (Main.rand.NextFloat() < .08925f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage >= 8) // anything more.. 0.5x
                        {
                            if (Main.rand.NextFloat() < .0595f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <QuickBallCaught>());
                                return;
                            }
                        }
                    }
                    else if (ballProjectiles[i] == "TimerBallProjectile") // Special Condition
                    {
                        ballUsage++;
                        if (ballUsage == 1) // 0.5x catch chance
                        {
                            if (Main.rand.NextFloat() < .0595f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 2) // 0.75x catch chance
                        {
                            if (Main.rand.NextFloat() < .08925f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 3) // 1x catch chance
                        {
                            if (Main.rand.NextFloat() < .1190f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 4) // 1.2x catch chance
                        {
                            if (Main.rand.NextFloat() < .1428f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 5) // 1.4x catch chance
                        {
                            if (Main.rand.NextFloat() < .1666f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 6) // 1.6x catch chance
                        {
                            if (Main.rand.NextFloat() < .1904f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 7) // 1.8x catch chance
                        {
                            if (Main.rand.NextFloat() < .2142f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 8) // 2x catch chance
                        {
                            if (Main.rand.NextFloat() < .2380f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 9) // 2.2x catch chance
                        {
                            if (Main.rand.NextFloat() < .2618f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 10) // 2.4x catch chance
                        {
                            if (Main.rand.NextFloat() < .2856f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 11) // 2.6x catch chance
                        {
                            if (Main.rand.NextFloat() < .3094f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage == 12) // 2.8x catch chance
                        {
                            if (Main.rand.NextFloat() < .3332f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }

                        if (ballUsage >= 13) // anything more.. 3x
                        {
                            if (Main.rand.NextFloat() < .3570f)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }
                    }
                    else if (ballProjectiles[i] == "ShadowBallProjectile")
                    {
                        string        name        = GetType().ToString().Substring(0, GetType().ToString().Length - 3);
                        ModProjectile pokemonProj = mod.GetProjectile(name);
                        ParentPokemon pkmn        = pokemonProj as ParentPokemon;
                        for (int types = 0; types < pkmn.PokemonTypes.Length; types++)
                        {
                            if (Main.halloween || pkmn.PokemonTypes[types] == PokemonType.Ghost || pkmn.PokemonTypes[types] == PokemonType.Dark)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }
                        if (!Main.dayTime)
                        {
                            if (Main.rand.Next(0, 100) < 60)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }
                        else
                        {
                            if (Main.rand.Next(0, 100) < 20)
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <TimerBallCaught>());
                                return;
                            }
                        }
                    }

                    ballUsage++;
                    for (int j = 0; j < catchChances[i].Length; j++) // Retain loop for improvement later
                    {
                        if (Main.rand.NextFloat() < catchChances[i][j])
                        {
                            if (projectile.type == ModContent.ProjectileType <PokeballProjectile>()
                                ) // Special Condition
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <PokeballCaught>());
                            }
                            if (projectile.type == ModContent.ProjectileType <GreatBallProjectile>()
                                ) // Special Condition
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <GreatBallCaught>());
                            }
                            if (projectile.type == ModContent.ProjectileType <UltraBallProjectile>()
                                ) // Special Condition
                            {
                                Catch(ref projectile, ref crit, ref damage, ModContent.ItemType <UltraBallCaught>());
                            }
                            if (projectile.type == ModContent.ProjectileType <PremierBallProjectile>()
                                ) // Special Condition
                            {
                                Catch(ref projectile, ref crit, ref damage,
                                      ModContent.ItemType <PremierBallCaught>());
                            }
                            return;
                        }
                    }
                    break;
                }
            }

            CombatText.NewText(npc.Hitbox, Color.White, "Miss...", true);

            if (projectile.type == ModContent.ProjectileType <PokeballProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <PokeballItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <GreatBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <GreatBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <UltraBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <UltraBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <DuskBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <DuskBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <PremierBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <PremierBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <QuickBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <QuickBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <TimerBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <TimerBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <ZeroBallProjectile>()) // Special Condition
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <ZeroBallItem>());
                }
            }
            if (projectile.type == ModContent.ProjectileType <ShadowBallProjectile>())
            {
                if (Main.rand.Next(3) == 0)
                {
                    Item.NewItem(npc.getRect(), ModContent.ItemType <ShadowBallItem>());
                }
            }

            damage           = 0;
            npc.life         = npc.lifeMax + 1;
            projectile.ai[1] = 0;
        }
示例#20
0
 public static Item NewItem(this ModProjectile proj, int type, int stack = 1)
 => NewItem(proj.projectile, type, stack);
 public override void Apply(ModProjectile projectile)
 {
 }
 /// <summary>
 /// Call this in <see cref="ModProjectile.SetStaticDefaults"/> to register this projectile into the "clicker class" category
 /// </summary>
 /// <param name="modProj">The <see cref="ModProjectile"/> that is to be registered</param>
 internal static void RegisterClickerProjectile(ModProjectile modProj) => ClickerClass?.Call("RegisterClickerProjectile", versionString, modProj);
示例#23
0
        public static void DrawProjectileTrailCentered(this ModProjectile p, SpriteBatch spriteBatch, Color drawColor, float initialOpacity = 0.8f, float opacityDegrade = 0.2f, int stepSize = 1)
        {
            Texture2D texture = Main.projectileTexture[p.projectile.type];

            p.DrawProjectileTrailCenteredWithTexture(texture, spriteBatch, drawColor, initialOpacity, opacityDegrade, stepSize);
        }
示例#24
0
        public static void LookAlongVelocity(ModProjectile modProj)
        {
            Projectile projectile = modProj.projectile;

            projectile.rotation = (float)Math.Atan2(projectile.velocity.X, -projectile.velocity.Y);
        }
示例#25
0
 public static NPC NewNPC(this ModProjectile proj, int type, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, float ai3 = 0f, int target = 255, int start = 0, float offsetX = 0f, float offsetY = 0f)
 => NewNPC(proj.projectile, type, ai0, ai1, ai2, ai3, target, start, offsetX, offsetY);
示例#26
0
        public static void CreateDust(ModProjectile modProjectile, Vector2 position)
        {
            Projectile projectile = modProjectile.projectile;

            GlassID glassType;
            bool    shard;

            if (modProjectile is CrimglassProjectile || modProjectile is CrimglassShard)
            {
                glassType = GlassID.CrimGlass;
            }
            else if (modProjectile is EbonglassProjectile || modProjectile is EbonglassShard)
            {
                glassType = GlassID.EbonGlass;
            }
            else if (modProjectile is PearlglassProjectile || modProjectile is PearlglassShard)
            {
                glassType = GlassID.PearlGlass;
            }
            else
            {
                glassType = GlassID.Glass;
            }

            if (modProjectile is GlassProjectile)
            {
                shard = false;
            }
            else
            {
                shard = true;
            }

            if (glassType == GlassID.CrimGlass)
            {
                int count = shard ? 1 : 3;
                for (int i = 0; i < count; i++) // red bloody
                {
                    int dust = Dust.NewDust(position, projectile.width, projectile.height, 25);
                    Main.dust[dust].velocity.X *= 0.4f;
                }
                for (int i = 0; i < count; i++) // black muddy
                {
                    int dust = Dust.NewDust(position, projectile.width, projectile.height, 53);
                    Main.dust[dust].velocity.X *= 0.2f;
                }
                if (Main.rand.NextBool(1, 5)) // ichor
                {
                    float scale = shard ? 1.7f : 1.3f;
                    int   dust  = Dust.NewDust(position, projectile.width, projectile.height, 87, Scale: scale);
                    Main.dust[dust].velocity.X *= 0.4f;
                }
            }
            else if (glassType == GlassID.EbonGlass)
            {
                int dust = Dust.NewDust(position, projectile.width, projectile.height, 186); // purple corruption stuff
                Main.dust[dust].velocity.X *= 0.4f;

                dust = Dust.NewDust(position, projectile.width, projectile.height, 14); // purple corruption stuff
                Main.dust[dust].velocity.X *= 0.4f;

                if (Main.rand.NextBool(1, 6)) // cursed flame
                {
                    float scale = shard ? 3.25f : 2.5f;
                    dust = Dust.NewDust(position, projectile.width, projectile.height, 75, Scale: scale);
                    Main.dust[dust].velocity.X *= 0.4f;
                }
            }
            else if (glassType == GlassID.PearlGlass)
            {
                if (!shard || Main.rand.NextBool(1, 3))                                          // pink light
                {
                    int dust = Dust.NewDust(position, projectile.width, projectile.height, 164); // 164, 134
                    Main.dust[dust].velocity.X *= 0.4f;
                }
            }
            else
            {
                for (int i = 0; i < 1; i++) // glass
                {
                    int dust = Dust.NewDust(position, projectile.width, projectile.height, 42);
                    Main.dust[dust].velocity.X *= 0.4f;
                }
            }
        }
示例#27
0
 public abstract void Apply(ModProjectile projectile);
        public static void JavelinOnHit(NPC target, Projectile projectile, ref double damage)
        {
            if (projectile.ai[1] == (int)JavelinType.Ice)//Ice
            {
                if (Main.rand.Next(0, 4) == 1)
                {
                    target.AddBuff(BuffID.Frostburn, 60 * (projectile.type == ModContent.ProjectileType <JavelinProj>() ? 2 : 3));
                }
            }
            if (projectile.ai[1] == (int)JavelinType.Dynasty)//Dynasty
            {
                if (projectile.penetrate > 1)
                {
                    int thisoned = Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-64, 64), projectile.Center.Y - 800, Main.rand.NextFloat(-2, 2), 14f, projectile.type, projectile.damage, projectile.knockBack, Main.player[projectile.owner].whoAmI);
                    Main.projectile[thisoned].ai[1]             = projectile.ai[1];
                    Main.projectile[thisoned].Throwing().thrown = true;
                    Main.projectile[thisoned].penetrate         = projectile.penetrate - 1;
                    Main.projectile[thisoned].netUpdate         = true;
                }
            }

            if (projectile.ai[1] == (int)JavelinType.Hallowed)//Hallow
            {
                if (Main.rand.Next(0, projectile.modProjectile.GetType() == typeof(JavelinProjMelee) ? 2 : 0) == 0)
                {
                    int thisoned = Projectile.NewProjectile(projectile.Center.X + Main.rand.NextFloat(-64, 64), projectile.Center.Y - 800, Main.rand.NextFloat(-2, 2), 14f, ProjectileID.HallowStar, (int)(projectile.damage * damage), projectile.knockBack, projectile.owner);
                    Main.projectile[thisoned].Throwing().thrown = true;
                    Main.projectile[thisoned].penetrate         = 2;
                    Main.projectile[thisoned].netUpdate         = true;
                    IdgProjectile.Sync(thisoned);
                    NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, thisoned);
                }
            }
            if (projectile.ai[1] == (int)JavelinType.Shadow)//Shadow
            {
                if (Main.rand.Next(0, 4) == 1)
                {
                    target.AddBuff(BuffID.ShadowFlame, 60 * (projectile.type == ModContent.ProjectileType <JavelinProj>() ? 3 : 5));
                }
            }
            if (projectile.ai[1] == (int)JavelinType.SanguineBident)//Sanguine Bident
            {
                int bleed = ModContent.BuffType <MassiveBleeding>();
                if (target.buffImmune[BuffID.Bleeding])
                {
                    damage += 0.25;
                }

                if (projectile.modProjectile.GetType() == typeof(JavelinProj))
                {
                    if (target.active && target.life > 0 && Main.rand.Next(0, 12) < (target.HasBuff(bleed) || target.HasBuff(BuffID.Bleeding) ? 8 : 1))
                    {
                        projectile.vampireHeal((int)(projectile.damage / 2f), projectile.Center);
                    }
                }
                else
                {
                    target.AddBuff(ModContent.BuffType <MassiveBleeding>(), 60 * 5);
                }
                projectile.netUpdate = true;
            }
            if (projectile.ai[1] == (int)JavelinType.TerraTrident)//Terra Trident
            {
                if (projectile.modProjectile.GetType() == typeof(JavelinProj))
                {
                    Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 60, 0.6f, 0.25f);
                    Vector2 velo = projectile.velocity; velo.Normalize();
                    int     prog = Projectile.NewProjectile(projectile.Center.X + (velo.X * 20f), projectile.Center.Y + (velo.Y * 20f), velo.X * 6f, velo.Y * 6f, SGAmod.Instance.ProjectileType("TerraTridentProj"), (int)(projectile.damage * 0.75), projectile.knockBack / 2f, Main.myPlayer);
                    Main.projectile[prog].penetrate         = 3;
                    Main.projectile[prog].timeLeft         /= 4;
                    Main.projectile[prog].melee             = false;
                    Main.projectile[prog].Throwing().thrown = true;
                    Main.projectile[prog].netUpdate         = true;
                    IdgProjectile.Sync(prog);
                    NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, prog);
                }
            }
            if (projectile.ai[1] == (int)JavelinType.CrimsonCatastrophe)//Crimson Catastrophe
            {
                int bleed = ModContent.BuffType <MassiveBleeding>();
                if (target.buffImmune[BuffID.Bleeding])
                {
                    damage += 0.50;
                }

                ModProjectile modproj = projectile.modProjectile;
                if (modproj.GetType() == typeof(JavelinProj))
                {
                    (modproj as JavelinProj).maxStickTime = (int)((modproj as JavelinProj).maxStickTime / 1.25);
                    foreach (NPC enemy in Main.npc.Where(enemy => enemy.active && enemy.active && enemy.life > 0 && !enemy.friendly && !enemy.dontTakeDamage && enemy.Distance(projectile.Center) < 500 && (modproj as JavelinProj).stickin != enemy.whoAmI && enemy.HasBuff(bleed)))
                    {
                        CrimsonCatastrophe.BloodyExplosion(enemy, projectile);
                    }
                }
                else
                {
                    target.AddBuff(bleed, 60 * 5);
                }
                projectile.netUpdate = true;
            }
            if (projectile.ai[1] == (int)JavelinType.Thermal)//Thermal
            {
                target.AddBuff(ModContent.BuffType <ThermalBlaze>(), 60 * (projectile.type == ModContent.ProjectileType <JavelinProj>() ? 2 : 5));
            }
            if (projectile.ai[1] == (int)JavelinType.SwampSovnya)//Swamp Sovnya
            {
                if (!target.buffImmune[BuffID.Poisoned])
                {
                    ModProjectile modproj = projectile.modProjectile;
                    if (modproj.GetType() == typeof(JavelinProj))
                    {
                        if (Main.rand.Next(0, 100) < 50 && !target.boss)
                        {
                            target.AddBuff(ModContent.BuffType <DankSlow>(), (int)(60 * 3f));
                        }
                    }
                }
                else
                {
                    damage += 0.25f;
                }
            }
        }
示例#29
0
        public static Types GetType(Projectile projectile)
        {
            if (ProjectileOverrideList.ContainsKey(projectile.Name))
            {
                return(ProjectileOverrideList[projectile.Name]);
            }

            ModProjectile mproj = projectile.modProjectile;

            if (mproj != null)
            {
                Type mprojtype = mproj.GetType();

                if (ProjectileOverrideList.ContainsKey(mprojtype.ToString()))
                {
                    return(ProjectileOverrideList[mprojtype.ToString()]);
                }
                if (Config.Instance.DebugMode)
                {
                    ColoredDamageTypes.Log("Projectile: " + mprojtype.ToString());
                }
            }

            //ThoriumMod Check
            if (ColoredDamageTypes.ThoriumMod != null && mproj != null && mproj.mod == ColoredDamageTypes.ThoriumMod)
            {
                Type   mprojtype = mproj.GetType();
                string typestr   = mprojtype.ToString();
                if (typestr.Contains("ThoriumMod.Projectiles.Scythe") || typestr.Contains("ThoriumMod.Projectiles.Healer"))
                {
                    return(Types.Radiant);
                }
                else if (typestr.Contains("ThoriumMod.Projectiles.Bard"))
                {
                    return(Types.Symphonic);
                }
                else if (typestr.Contains("ThoriumMod.Items.ThrownItems"))
                {
                    return(Types.Thrown);
                }
            }

            /*
             * if (ColoredDamageTypes.TremorMod != null && mproj != null && mproj.mod == ColoredDamageTypes.TremorMod) {
             *      Type mprojType = mproj.GetType();
             *      string mitemTypestr = mprojType.ToString();
             *      bool isAlchemic = mitemTypestr.Contains("Alchemist.") || mitemTypestr.Contains("Alchemic.") || mitemTypestr.Contains("NovaPillar.");
             *      if (mprojType != null && isAlchemic == true) return Types.Alchemic;
             * }
             */

            Item item         = null;
            Item selecteditem = Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem];

            ProjectileTypeCheck(projectile, selecteditem, ref item);

            if (item == null)
            {
                foreach (Item i in Main.player[projectile.owner].inventory)
                {
                    if (i.shoot == projectile.type)
                    {
                        item = i;
                        break;
                    }
                }
            }
            if (item != null)               // Found item in inventory
            {
                return(GetType(item));
            }
            else               // Didn't find item. Use projectile type
            {
                int fromsummon = 0;

                for (int i = 0; i < 1000; i++)
                {
                    Projectile CheckProjectile = Main.projectile[i];
                    if (CheckProjectile.active && (CheckProjectile.sentry) && CheckProjectile.type + 1 == projectile.type)
                    {
                        fromsummon = 2;                         // Is a sentry
                        break;
                    }
                    else if (CheckProjectile.active && (CheckProjectile.minion) && CheckProjectile.type + 1 == projectile.type)
                    {
                        fromsummon = 1;                         // Is a minion
                        break;
                    }
                }

                if (projectile.melee && !projectile.magic && !projectile.thrown)
                {
                    return(Types.Melee);
                }
                else if (projectile.ranged && !projectile.magic && !projectile.thrown)
                {
                    return(Types.Ranged);
                }
                else if (projectile.magic)
                {
                    return(Types.Magic);
                }
                else if (projectile.thrown)
                {
                    return(Types.Thrown);
                }
                else if (fromsummon == 2 || projectile.sentry)
                {
                    return(Types.Sentry);
                }
                else if (fromsummon == 1 || projectile.minion)
                {
                    return(Types.Summon);
                }

                return(Types.Unknown);
            }
        }