Standalone [1.3] tModLoader - A Modding API

Just tried to play Terraria after updating, and game crashes to desktop every time i place any block.
I get the little white box saying this.

3/13/2017 7:55:54 AM
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Terraria.ModLoader.ItemLoader.GetItemInfo(Item item, Mod mod, String name)
at Terraria.Item.GetModInfo(Mod mod, String name)
at Terraria.Item.GetModInfo[T](Mod mod)
at ItemCustomizer.CustomizerPlayer.<weaponDye>m__0(PlayerDrawInfo drawInfo)
at Terraria.ModLoader.DrawLayer`1.Draw(InfoType& drawInfo)
at Terraria.Main.DrawPlayer(Player drawPlayer, Vector2 Position, Single rotation, Vector2 rotationOrigin, Single shadow)
at Terraria.Main.DrawPlayers()
at Terraria.Main.do_Draw(GameTime gameTime)
at Terraria.Main.DoDraw(GameTime gameTime)
at Terraria.Main.Draw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame(String[] args)
View attachment 162633



P. S. I'm not using item customizer. And when all mods disabled. It stopped immediately when I reverted back to the previous tmodloader version.
 
P. S. I'm not using item customizer. And when all mods disabled. It stopped immediately when I reverted back to the previous tmodloader version.
Your error log indicates you were using item customizer at some point. Many using that mod have been reporting crashes recently, as it needs to be updated.

And the crashes would've stopped immediately when you switched back to an older version of tMod, because Item Customizer is only having problems with the latest version of tMod.
 
Hey, the developers of TmodLoader, I am LonelyStar. As a Chinese student who love playing Terraria, translation is always a problem. If you don't know, many Chinese player use illegal pirate version of terraria just because they cannot read English. (I don't want to talk about other reason since that is not what I want to say here.)

So, as one of a leader of the translation group , I want to translate TmodLoader to Chinese version so that more Chinese player will know, play and discuss mods and tmodloader. I can promiss that I won't make it to private version. (Well, I am a student who study in University of Sydney and I definitely know what plagiarism is and how worse it is.) And I will put a link of the website and all the developers name in a word document and put it in a group file and force everyone in that group read it.

Wait, group? Word document? I know it is a bit confused, but I will explain the reason.

1. The group is a QQ group, you can google what QQ means. You can write announcement, upload files, document or pictures and share resources with other members in the group. Right now, there is a thousand of people in my group. People have to answer the question : Are you using a steam version of terraria? They can only enter the group if they say yes. Some people do lie on this question but I will kick him out as soon as I find they are lying.

2. I will only share tmods and tmodloader in this group whether they are English or Chinese version. Some of you may know about the Chinese Terraria forums called Tieba, many Chinese may already ask you to share the tmodloader on Tieba. However, I do not trust people in Tieba because most of them prefer pirate version instead of cost 36 RMB (less than 6 US dollars) to buy terraria on Steam. I'd better tell you that there are already a pirate version of TmodLoader and tricks about how to play Tmodloader without Steam which make me kind angry.

Therefore, I choose to share these resources in my group, not Tieba. They want to play? Then buy Terraria and join my group.

Actually, the Chinese version of TML has been released for few months which attract a lot of people to buy terraria and join my group. I apologise about that. But it would be appreciate that you can allowed me share the Tmodloader and even translate it. I will ask for the permission of translating some mod with the developers later on.

Thank you, and I am willing to answer any question about Tieba and my QQ group. (please be friendly about my language XD)
@bluemagic123
 
jopojelly, can you help me with this? - http://prnt.sc/eju2ox
It appears when my world has been creating.
Without mods, world created.
Mods: Calamity and Tremor
 
npc.HitSound = new LegacySoundStyle(SoundID.Tink, 1);
should work.
[doublepost=1489536684,1489536629][/doublepost]
It would be prety mysterious if you hear the Crystillium biome music without having it installed. Anyway, disable mods until you figure out the problem mod.
[doublepost=1489536767][/doublepost]
No, modders shouldn't do that. The solution for all problems is to just get more "tModLoader peeps", but we'll think about it and probably come up with a solution.

I really hope you guys can figure out a solution for the weapon racks/Mannequins, I'm the kind of guy who really enjoys good spritework, and love some of the sprites these mod-makers can create (Shout-out to the Spirit Mod Team), and it really hurts not being able to display my trophies over my base.

I've actually just been waiting for a fix to this issue before I really start playing, my friends are the same way.
 
I apologize if this is common knowledge, I'm still fairly new to using mods. I also ran a couple searches and didn't see anything about this:

Is there a limit to the amount of NPC portraits that can be displayed on the housing tab in the engine or tModLoader or am I experiencing a specific mod-related bug?
From the screenshot, you will see that I have 50 NPC portraits displayed (51 including the question mark), the next NPC portrait is invisible at the end of that list but can still be clicked on to move the NPC (Mutant NPC from Fargo's mod.)
Any NPCs after that (I have at least 2 more -- Lone Trapper from Spirit and Demon Artist from Legend of Terraria 3) can not be moved because there doesn't seem to be any invisible portrait for them for me to click on.
 

Attachments

  • NPC.jpg
    NPC.jpg
    611.9 KB · Views: 220
Last edited:
I've been having an issue with tmodloader whilst playing multiplayer. Recently, a few friends and I started playing, and we experience a rather annoying slow-down of the game, only fixable when entering a menu, such as a chest or pressing esc. It's incredibly annoying, and we've spent hours filing through the mods that we have installed, and we've come to the conclusion that it's none of the individual mods causing it, but rather tmodloader itself. All of us are getting the issue, does anyone have any experience with fixes we could use?
 
I need help, I made a pet and it's completely in the ground. Help? :/ This was my script:

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExtraVanity.Projectiles.Pets
{
    public class CorruptBunnyPet : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.Bunny);
            projectile.name = "Corrupt Bunny Pet";
            aiType = ProjectileID.Bunny;
            Main.projFrames[projectile.type] = 8;
            Main.projPet[projectile.type] = true;
        }
        public override bool PreAI()
        {
            Player player = Main.player[projectile.owner];
            player.bunny = false;
            return true;
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];
            MyPlayer modPlayer = player.GetModPlayer<MyPlayer>(mod);
            if (player.dead)
            {
                modPlayer.Pet = false;
            }
            if (modPlayer.Pet)
            {
                projectile.timeLeft = 2;
            }
        }
    }
}
 
Is a solution possibly to have modders create "statues" displaying their armours as an extra, with the same look as a mannequin, but not the same functionality, rather than having it tied to the mannequin code? It would mean a bit more work on their part, but it's possibly going to create less stress on the tmodloader peeps. That way, we can still have the armours/weapons displayed, but they loose their ability to add/remove pieces at will. It LOOKS the same, just doesn't ACT the same. I'd be ok with this, if it meant I could display things like usual, it just means more for the modders to code/sprite.
No. Yoraiz0r has fixing for mannequins on his list. It's vanilla that direly needs changes on that area before tModLoader can do anything with it.

jopojelly, can you help me with this? - http://prnt.sc/eju2ox
It appears when my world has been creating.
Without mods, world created.
Mods: Calamity and Tremor
It appears Tremor has issues with worldgen. Disable/update the mod and try again.

Is there a limit to the amount of NPC portraits that can be displayed on the housing tab in the engine or tModLoader or am I experiencing a specific mod-related bug?
It is probably a set limit in the vanilla source code, we could change it to be scrollable vertically instead (so it doesn't need a limit)
 
Help me please, I made a pet, but it's buried in the ground... Is there some sort of hitbox config? Please help.. :/

I think it involves the type of pet, it was originally a flying pet but I swapped the code to the Bunny AI.

This is the code VVV

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExtraVanity.Projectiles.Pets
{
    public class CorruptBunnyPet : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.Bunny);
            projectile.name = "Corrupt Bunny Pet";
            aiType = ProjectileID.Bunny;
            Main.projFrames[projectile.type] = 8;
            Main.projPet[projectile.type] = true;
        }
        public override bool PreAI()
        {
            Player player = Main.player[projectile.owner];
            player.bunny = false;
            return true;
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];
            MyPlayer modPlayer = player.GetModPlayer<MyPlayer>(mod);
            if (player.dead)
            {
                modPlayer.Pet = false;
            }
            if (modPlayer.Pet)
            {
                projectile.timeLeft = 2;
            }
        }
    }
}

I am also able to spawn 2 bunnies of once.. Help?
 
Last edited:
This is the place to Report Tmod Bugs right? Well here it is... when I use a consumable, such as a potion or buff, I cannot click or use any of my items, kinda like my mouse except the right mouse button is locked. This started happening after I updated Tmod. This also used to happen if you used a recall or teleportation potion. The only way i've found to reset the bug is re-enter the world. Any help with this???
 
This is the place to Report Tmod Bugs right? Well here it is... when I use a consumable, such as a potion or buff, I cannot click or use any of my items, kinda like my mouse except the right mouse button is locked. This started happening after I updated Tmod. This also used to happen if you used a recall or teleportation potion. The only way i've found to reset the bug is re-enter the world. Any help with this???
That's not a tmodloader bug, it's a specific mod bug. It's only a tmodloader bug if you disable ALL mods, restart, and it still happens. Go disable your mods until you figure it out, or it might just be Even More Modifiers.
 
so, uhh, have you ever had any problems with people just not being able to install it? and it uninstalling randomly all by itself? (probably due to me recently updating it)
 
My game now crashes to desktop whenever I try to access the Mod Browser. The window comes up, but right about where I'd expect the list to appear, the game just poofs.
 
This is the place to Report Tmod Bugs right? Well here it is... when I use a consumable, such as a potion or buff, I cannot click or use any of my items, kinda like my mouse except the right mouse button is locked. This started happening after I updated Tmod. This also used to happen if you used a recall or teleportation potion. The only way i've found to reset the bug is re-enter the world. Any help with this???

Hey, instead of berating you, i'll help you, i had the same problem myself, turned off all my mods, and turned them on one by one until i figured out which ones did the thing. and everyone kept saying it was Even more modifiers, which was true, but not alone, i found out it was also "Basic classes" by bil, and "starter weapons" also by bil. if you don't have those three, or if the problem still happens after you disable those three, use the same method yourself to figure out which one is causing the problem for you

That's not a tmodloader bug, it's a specific mod bug. It's only a tmodloader bug if you disable ALL mods, restart, and it still happens. Go disable your mods until you figure it out, or it might just be Even More Modifiers.

i would think, that since the bug happened to at least three mods,and not "just a specific mod" after tmodloader updated, that would in fact make it a tmodloader bug, that occurs with multiple mods
 
Hey, instead of berating you, i'll help you, i had the same problem myself, turned off all my mods, and turned them on one by one until i figured out which ones did the thing. and everyone kept saying it was Even more modifiers, which was true, but not alone, i found out it was also "Basic classes" by bil, and "starter weapons" also by bil. if you don't have those three, or if the problem still happens after you disable those three, use the same method yourself to figure out which one is causing the problem for you



i would think, that since the bug happened to at least three mods,and not "just a specific mod" after tmodloader updated, that would in fact make it a tmodloader bug, that occurs with multiple mods
I went back to 0.9.1.1 and Even more modifiers caused the same bug there. I did not try the other. Even more modifiers was updated at the same time as tmodloader, so to me it seemed like 0.9.2 was the problem, but testing it on old versions convinced me otherwise. I'll have to check out the other 2 you mention.

Edit: ok, looks like tmod devs have some thinking to do, there are some situations that were never addressed before that we need to thing about.
 
Last edited:
I used to use v0.9.1 and i just updated my tmod to v0.9.2.1 today and after I updated, I am unable to Host&Play the world that i used to. The world was created when i was using v0.9.1. It just stops at " Starting server". There was once that it shows that "You are not using the same version as this server". Is there any way to Host & Play a server in a new version of tMod that was created in the previous version of tMod?
 
I've been having an issue with tmodloader whilst playing multiplayer. Recently, a few friends and I started playing, and we experience a rather annoying slow-down of the game, only fixable when entering a menu, such as a chest or pressing esc. It's incredibly annoying, and we've spent hours filing through the mods that we have installed, and we've come to the conclusion that it's none of the individual mods causing it, but rather tmodloader itself. All of us are getting the issue, does anyone have any experience with fixes we could use?

I've been having the same issue for months, I believe it could be the NPCS as it doesn't happen when nobody is at spawn, although most of us just play with our menus open and it's not such a big deal, would like to see a fix however :)
 
I'm pretty sure this is the place to report mod bugs.. But I need help with my mod desperately, i've created some pets, but there are a few bugs with them.. I can spawn 2 pets at once, and when I spawned them, they're buried in the ground. I used a different type of script, it was originally a flying pet script, but I changed the behavior of it from the Zephyr Fish data to the Bunny Pet data. However when I switched it, the pets are completely in the ground, as I said. Here is the script of the pet - All help would be appriciated!

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExtraVanity.Projectiles.Pets
{
    public class CorruptBunnyPet : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.Bunny);
            projectile.name = "Corrupt Bunny Pet";
            aiType = ProjectileID.Bunny;
            Main.projFrames[projectile.type] = 8;
            Main.projPet[projectile.type] = true;
        }
        public override bool PreAI()
        {
            Player player = Main.player[projectile.owner];
            player.bunny = false;
            return true;
        }
        public override void AI()
        {
            Player player = Main.player[projectile.owner];
            MyPlayer modPlayer = player.GetModPlayer<MyPlayer>(mod);
            if (player.dead)
            {
                modPlayer.Pet = false;
            }
            if (modPlayer.Pet)
            {
                projectile.timeLeft = 2;
            }
        }
    }
}
 
i could need a little bit help right now (or maybe a bigger bit) im trying to make a weapon which should shoot a projectile like the solar eruption but i cant get anything from it besides of this:
d60CWUO.jpg

or this (recently):

vLTWH1K.jpg
(yeah im shooting)
and here are the code (right from IlSpy):
the item:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Aoa.Items.Weapons
{
    public class beastcutter : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Solar Eruption";
            item.useStyle = 5;
            item.useAnimation = 20;
            item.useTime = 20;
            item.shootSpeed = 24f;
            item.knockBack = 2f;
            item.width = 16;
            item.height = 16;
            item.UseSound = SoundID.Item116;
            item.shoot = 611;
            item.rare = 10;
            item.value = Item.sellPrice(0, 10, 0, 0);
            item.noMelee = true;
            item.noUseGraphic = true;
            item.channel = true;
            item.autoReuse = true;
            item.melee = true;
            item.damage = 105;
            item.shoot = mod.ProjectileType("handle");
            return;
        }
    }
}
the "handle":
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Aoa.Projectiles
{
    public class handle : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.SolarCounter);
            projectile.name = "handle";
        }
        public override void AI()
        {
            projectile.ai[1] += 0.01f;
            projectile.scale = projectile.ai[1];
            projectile.ai[0] += 1f;
            if (projectile.ai[0] >= (float)(3 * Main.projFrames[projectile.type]))
            {
                projectile.Kill();
                return;
            }
            if (++projectile.frameCounter >= 3)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= Main.projFrames[projectile.type])
                {
                    projectile.hide = true;
                }
            }
            projectile.alpha -= 63;
            if (projectile.alpha < 0)
            {
                projectile.alpha = 0;
            }
            bool flag56 = projectile.type == 612;
            bool flag57 = projectile.type == 624;
            if (flag56)
            {
                Lighting.AddLight(projectile.Center, 0.9f, 0.8f, 0.6f);
            }
            if (projectile.ai[0] == 1f)
            {
                projectile.position = projectile.Center;
                projectile.width = (projectile.height = (int)(52f * projectile.scale));
                projectile.Center = projectile.position;
                projectile.Damage();
                if (flag56)
                {
                    Main.PlaySound(SoundID.Item14, projectile.position);
                    for (int num980 = 0; num980 < 4; num980++)
                    {
                        int num981 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default(Color), 1.5f);
                        Main.dust[num981].position = projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f;
                    }
                    for (int num982 = 0; num982 < 10; num982++)
                    {
                        int num983 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 200, default(Color), 2.7f);
                        Main.dust[num983].position = projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f;
                        Main.dust[num983].noGravity = true;
                        Main.dust[num983].velocity *= 3f;
                        num983 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default(Color), 1.5f);
                        Main.dust[num983].position = projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f;
                        Main.dust[num983].velocity *= 2f;
                        Main.dust[num983].noGravity = true;
                        Main.dust[num983].fadeIn = 2.5f;
                    }
                    for (int num984 = 0; num984 < 5; num984++)
                    {
                        int num985 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 0, default(Color), 2.7f);
                        Main.dust[num985].position = projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)projectile.velocity.ToRotation(), default(Vector2)) * (float)projectile.width / 2f;
                        Main.dust[num985].noGravity = true;
                        Main.dust[num985].velocity *= 3f;
                    }
                    for (int num986 = 0; num986 < 10; num986++)
                    {
                        int num987 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 0, default(Color), 1.5f);
                        Main.dust[num987].position = projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)projectile.velocity.ToRotation(), default(Vector2)) * (float)projectile.width / 2f;
                        Main.dust[num987].noGravity = true;
                        Main.dust[num987].velocity *= 3f;
                    }
                }
                if (flag57)
                {
                    Main.PlaySound(SoundID.Item14, projectile.position);
                    for (int num988 = 0; num988 < 20; num988++)
                    {
                        int num989 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 100, default(Color), 1.5f);
                        Main.dust[num989].position = projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)projectile.width / 2f;
                        Main.dust[num989].velocity *= 2f;
                        Main.dust[num989].noGravity = true;
                        Main.dust[num989].fadeIn = 2.5f;
                    }
                    for (int num990 = 0; num990 < 15; num990++)
                    {
                        int num991 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0f, 0f, 0, default(Color), 2.7f);
                        Main.dust[num991].position = projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)projectile.velocity.ToRotation(), default(Vector2)) * (float)projectile.width / 2f;
                        Main.dust[num991].noGravity = true;
                        Main.dust[num991].velocity *= 3f;
                    }
                    float num992 = (float)Main.rand.NextDouble() * 6.28318548f;
                    float num993 = (float)Main.rand.NextDouble() * 6.28318548f;
                    float num994 = (float)Main.rand.NextDouble() * 6.28318548f;
                    float num995 = 7f + (float)Main.rand.NextDouble() * 7f;
                    float num996 = 7f + (float)Main.rand.NextDouble() * 7f;
                    float num997 = 7f + (float)Main.rand.NextDouble() * 7f;
                    float num998 = num995;
                    if (num996 > num998)
                    {
                        num998 = num996;
                    }
                    if (num997 > num998)
                    {
                        num998 = num997;
                    }
                    for (int num999 = 0; num999 < 200; num999++)
                    {
                        int num1000 = 135;
                        float scaleFactor14 = num998;
                        if (num999 > 50)
                        {
                            scaleFactor14 = num996;
                        }
                        if (num999 > 100)
                        {
                            scaleFactor14 = num995;
                        }
                        if (num999 > 150)
                        {
                            scaleFactor14 = num997;
                        }
                        int num1001 = Dust.NewDust(projectile.position, 6, 6, num1000, 0f, 0f, 100, default(Color), 1f);
                        Vector2 vector123 = Main.dust[num1001].velocity;
                        Main.dust[num1001].position = projectile.Center;
                        vector123.Normalize();
                        vector123 *= scaleFactor14;
                        if (num999 > 150)
                        {
                            vector123.Y *= 0.5f;
                            vector123 = vector123.RotatedBy((double)num994, default(Vector2));
                        }
                        else if (num999 > 100)
                        {
                            vector123.X *= 0.5f;
                            vector123 = vector123.RotatedBy((double)num992, default(Vector2));
                        }
                        else if (num999 > 50)
                        {
                            vector123.Y *= 0.5f;
                            vector123 = vector123.RotatedBy((double)num993, default(Vector2));
                        }
                        Main.dust[num1001].velocity *= 0.2f;
                        Main.dust[num1001].velocity += vector123;
                        if (num999 <= 200)
                        {
                            Main.dust[num1001].scale = 2f;
                            Main.dust[num1001].noGravity = true;
                            Main.dust[num1001].fadeIn = Main.rand.NextFloat() * 2f;
                            if (Main.rand.Next(4) == 0)
                            {
                                Main.dust[num1001].fadeIn = 2.5f;
                            }
                            Main.dust[num1001].noLight = true;
                            if (num999 < 100)
                            {
                                Main.dust[num1001].position += Main.dust[num1001].velocity * 20f;
                                Main.dust[num1001].velocity *= -1f;
                            }
                        }
                    }
                }
            }
        }
    }
}
and the actual projectile:
Code:
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Aoa.Projectiles
{
    public class beastcutterwhip : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.SolarWhipSword);
            projectile.name = "beastcutterwhip";
            aiType = ProjectileID.SolarWhipSword;
        }
        public override void AI()
        {
            {
                Player player = Main.player[projectile.owner];
                float num = 1.57079637f;
                Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true);
                projectile.ai[0] += 1f;
                int num2 = 0;
                if (projectile.ai[0] >= 40f)
                {
                    num2++;
                }
                if (projectile.ai[0] >= 80f)
                {
                    num2++;
                }
                if (projectile.ai[0] >= 120f)
                {
                    num2++;
                }
                int num3 = 24;
                int num4 = 6;
                projectile.ai[1] += 1f;
                bool flag = false;
                if (projectile.ai[1] >= (float)(num3 - num4 * num2))
                {
                    projectile.ai[1] = 0f;
                    flag = true;
                }
                projectile.frameCounter += 1 + num2;
                if (projectile.frameCounter >= 4)
                {
                    projectile.frameCounter = 0;
                    projectile.frame++;
                    if (projectile.frame >= 6)
                    {
                        projectile.frame = 0;
                    }
                }
                if (projectile.soundDelay <= 0)
                {
                    projectile.soundDelay = num3 - num4 * num2;
                    if (projectile.ai[0] != 1f)
                    {
                        Main.PlaySound(SoundID.Item91, projectile.position);
                    }
                }
                if (projectile.ai[1] == 1f && projectile.ai[0] != 1f)
                {
                    Vector2 vector2 = Vector2.UnitX * 24f;
                    vector2 = vector2.RotatedBy((double)(projectile.rotation - 1.57079637f), default(Vector2));
                    Vector2 value = projectile.Center + vector2;
                    for (int i = 0; i < 2; i++)
                    {
                        int num5 = Dust.NewDust(value - Vector2.One * 8f, 16, 16, 135, projectile.velocity.X / 2f, projectile.velocity.Y / 2f, 100, default(Color), 1f);
                        Main.dust[num5].velocity *= 0.66f;
                        Main.dust[num5].noGravity = true;
                        Main.dust[num5].scale = 1.4f;
                    }
                }
                if (flag && Main.myPlayer == projectile.owner)
                {
                    bool flag2 = player.channel && player.CheckMana(player.inventory[player.selectedItem].mana, true, false) && !player.noItems && !player.CCed;
                    if (flag2)
                    {
                        float scaleFactor = player.inventory[player.selectedItem].shootSpeed * projectile.scale;
                        Vector2 value2 = vector;
                        Vector2 value3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - value2;
                        if (player.gravDir == -1f)
                        {
                            value3.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - value2.Y;
                        }
                        Vector2 vector3 = Vector2.Normalize(value3);
                        if (float.IsNaN(vector3.X) || float.IsNaN(vector3.Y))
                        {
                            vector3 = -Vector2.UnitY;
                        }
                        vector3 *= scaleFactor;
                        if (vector3.X != projectile.velocity.X || vector3.Y != projectile.velocity.Y)
                        {
                            projectile.netUpdate = true;
                        }
                        projectile.velocity = vector3;
                        int num6 = 440;
                        float scaleFactor2 = 14f;
                        int num7 = 7;
                        for (int j = 0; j < 2; j++)
                        {
                            value2 = projectile.Center + new Vector2((float)Main.rand.Next(-num7, num7 + 1), (float)Main.rand.Next(-num7, num7 + 1));
                            Vector2 spinningpoint = Vector2.Normalize(projectile.velocity) * scaleFactor2;
                            spinningpoint = spinningpoint.RotatedBy(Main.rand.NextDouble() * 0.19634954631328583 - 0.098174773156642914, default(Vector2));
                            if (float.IsNaN(spinningpoint.X) || float.IsNaN(spinningpoint.Y))
                            {
                                spinningpoint = -Vector2.UnitY;
                            }
                            Projectile.NewProjectile(value2.X, value2.Y, spinningpoint.X, spinningpoint.Y, num6, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
                        }
                    }
                    else
                    {
                        projectile.Kill();
                    }
                }
            }
        }
    }
}
i hope that i can get an answer soon:)
 
Last edited:
Back
Top Bottom