Standalone [1.3] tModLoader - A Modding API

how come your sword shoots chaos balls?
[doublepost=1458910257,1458910140][/doublepost]witch is a projectile form the game
 
oh ya
[doublepost=1458910390,1458910369][/doublepost]there must be a way do
 
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
 
How can I make flails and spears?
[doublepost=1458913055,1458912778][/doublepost]And boomerangs please?
 
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)
 
Dropbox download? Pls notice me senpai...
 
Last edited:
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:
How can I make flails and boomerangs?
 
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 :)
 
How to modify vanilla items, NPCs etc? For example adding drops for enemies or adding attributes to armor.
 
How to modify vanilla items, NPCs etc? For example adding drops for enemies or adding attributes to armor.
ExampleMod has plenty of examples of changing Vanilla stuff. It is usually in a class with Global in the name. Search the source code for examples.
 
ExampleMod has plenty of examples of changing Vanilla stuff. It is usually in a class with Global in the name. Search the source code for examples.
Huh, which item in examplemod can show this?
 
em so I was going to the dungeon In a new world but a op charecter and when i wasnt even in the jungle two queen bees spawn i tried to record so i went abit away from them so i could click start recording(something happend to my hotkeys and had to go to the program ) when i came to the game they disappeared maybe i whent to far away from them or they just disappeared
 
How can I check that plantera has been downed?
 
How can I check that plantera has been downed?
NPC.downedPlantBoss
[doublepost=1459005417,1459004969][/doublepost]So I have this gun, that when shot, sends you backwards. Problem is, you can go through tiles with my current code. Is there a way to check my next position, and stop my character if it would be in a tile? Is there just an easier way to accomplish this items effect?

Code:
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            float spread = 2f * 0.1750f;
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);
            double randomAngle = baseAngle + (Main.rand.NextFloat() - 0.75f) * spread;
            float randomSpeed = Main.rand.NextFloat() * 0.2f + 1f;
            speedX = baseSpeed * randomSpeed * (float)Math.Sin(randomAngle);
            speedY = baseSpeed * randomSpeed * (float)Math.Cos(randomAngle);
           
            if (player.direction > 0)
            {
                player.position.X -= 10;
                return true;
            }
            if (player.direction < 0)
            {
                player.position.X += 10;
                return true;
            }
            return true;
        }
 
How can I make flails and boomerangs? Could somebody help please, there is nothing about it in ExampleMod :(
 
Back
Top Bottom