Standalone [1.3] tModLoader - A Modding API

Oh, well. I still can't find any ai code
Check in Projectile and NPC classes in ilSpy, all of the AI should be under "VanillaAI()". It goes by style first and then by type within the styles. If you can't find them that way, go into the classes, find something like aiStyle, right click and then click on "Analyze". This will tell you where that variable or method is called or what it uses.

what is Terraria. and where can you find codes of stuff in game
What he is talking about is using a program called ilSpy, which allows you to see the source of Terraria. This means that you can see how the developers of Terraria made complicated things like projectile AI and npc AI.
 
oh ya
[doublepost=1458910390,1458910369][/doublepost]there must be a way do
You can manually spawn your Projectile using Projectile.NewProjectile, save the value you get back from that function to call back the new projectile from Main.projectile and set friendly to true.
 
oh ya
[doublepost=1458910390,1458910369][/doublepost]there must be a way do
It's real to shoot NPC, but it will hurt you and will fly down always. so easier to make new projectile
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.Projectiles
{
    public class ChaosBall : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Chaos Ball";
            projectile.width = 16;
            projectile.height = 16;
            projectile.friendly = true;
            projectile.penetrate = 3;
            projectile.tileCollide = false;

        }

        public override void AI()
        {
            float minDistance = 300;
            float dX = 0;
            float dY = 0;
            float distance = 0;
            int target = -1;

            int num272 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 2f);
            Main.dust[num272].noGravity = true;
            Main.dust[num272].velocity *= 0.3f;
            Dust dust26 = Main.dust[num272];
            dust26.velocity.X = dust26.velocity.X - projectile.velocity.X * 0.2f;
            Dust dust27 = Main.dust[num272];
            dust27.velocity.Y = dust27.velocity.Y - projectile.velocity.Y * 0.2f;

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

                if (n.active && n.life > 1)
                {
                    Vector2 center = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
                    dX = n.position.X + (float)(n.width / 2) - center.X;
                    dY = n.position.Y + (float)(n.height / 2) - center.Y;
                    distance = (float)Math.Sqrt((double)(dX * 1.25 + dY * 1.25));
                    if (distance < minDistance)
                    {
                        minDistance = distance;
                        target = i;
                    }
                }
            }
        }        
    }
}
[doublepost=1458910797][/doublepost]Change ModName on your mod's name
 
I wonder why this thing doesn't work
h_1458913917_6097886_acabde75c4.jpg
 
Is there any way that I can use the time on the players computer? (basically, account for timezones, NOT GMT or UNIX)
 
Is there any way that I can use the time on the players computer? (basically, account for timezones, NOT GMT or UNIX)

You want the DateTime structure for that.

DateTime.Now.TimeOfDay will give you the current system time in a TimeSpan, you can access individual parts of that (hours, minutes and seconds) to work with.
I wonder why this thing doesn't work
h_1458913917_6097886_acabde75c4.jpg

UpdateAccessory also needs a bool hideVisual parameter after the Player player one.
 
Last edited:
Hello I'm new to this forum but I was just wondering, do you have an estimate of when the next update will be? Me and my friend really wanna make a server through steam :)
 
Back
Top Bottom