Standalone [1.3] tModLoader - A Modding API

My projectile's trail isn't being drawn on the screen. Can anyone help me?
Code:
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);
            for (int k = 0; k <= projectile.oldPos.Length; k++)
            {
                Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);
                spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, Color.White, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);
            }
            return true;
        }
EDIT: nevermind I fixed it
 
Can anyone tell where to find buffs in Terraria's source code? I'm trying to find source code for vanilla buffs, but it seems that there isn't a Buff class in vanilla Terraria(like with tiles).
 
Can anyone tell where to find buffs in Terraria's source code? I'm trying to find source code for vanilla buffs, but it seems that there isn't a Buff class in vanilla Terraria(like with tiles).
You should probably check with the Player class's update methods. Those should be the ones that does the stuff when the player has a buff.
 
Hello, i am having trouble playing the
ZoaklenMod
This is the error that came up once i tried to load the mod:
The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Terraria.ModLoader.ModLoader.LoadMod (Terraria.ModLoader.IO.TmodFile modFile, Terraria.ModLoader.BuildProperties properties) [0x00000] in <filename unknown>:0
at Terraria.ModLoader.ModLoader.LoadMods () [0x00000] in <filename unknown>:0
Im posting this incase it has something to do with the mod loader and not the mod itself, if you can help that would be great. Thanks
 
Last edited:
So in my public override void UpdateAccessory(Player player, bool hideVisual), I have this. I would imagine it would make the visual or equips.Add(EquipType.Balloon); I'm using to become invisible until the buff was gone. But it doesn't seem to work, any ideas?
Code:
if (player.HasBuff(mod.BuffType("DeBuff")) > -1)
            {
                hideVisual = true;
               
            }
 
So in my public override void UpdateAccessory(Player player, bool hideVisual), I have this. I would imagine it would make the visual or equips.Add(EquipType.Balloon); I'm using to become invisible until the buff was gone. But it doesn't seem to work, any ideas?
Code:
if (player.HasBuff(mod.BuffType("DeBuff")) > -1)
            {
                hideVisual = true;
              
            }
The problem is that hideVisual is a value parameter, not a reference parameter. So any changes you make to it will only have effect within that method. If you want to hide accessories, you can try setting player.balloonSlot, etc., to either 0 or -1 (I forget which one it's supposed to be) in this hook: https://github.com/bluemagic123/tModLoader/wiki/ModPlayer#public-virtual-void-frameeffects

its telling me that it cant find to place to install!
[DOUBLEPOST=1457758364,1457758233][/DOUBLEPOST]i mean can not find place to install to
:kingslime:;(
That means your Steam folder is probably different than normal. You'll have to manually copy your files to your Steam Terraria folder.
 
what does that mean? im a noob at modded terraria:cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool:
[DOUBLEPOST=1457758661,1457758603][/DOUBLEPOST]i mean what do you mean by "manully"
[DOUBLEPOST=1457758730][/DOUBLEPOST]im all confused:confused:
[DOUBLEPOST=1457758960][/DOUBLEPOST]anyone want to answer that plz? :red2:
:indifferent:
[DOUBLEPOST=1457759176][/DOUBLEPOST]really? nobody is gonna answer that question?
[DOUBLEPOST=1457759249][/DOUBLEPOST]
 
Last edited:
So this doesn't work, obviously, but could you tell me whats wrong about it? I assume the Main.mouse(X,Y) are not as set in stone as I would think and I need to actually set them before calling them. Maybe Main.mouse(X,Y) doesn't work with projectiles at all?
Code:
public override void Kill(int timeLeft)
        {
            Projectile.NewProjectile(Main.mouseX, Main.mouseY, 0f, 0f, mod.ProjectileType("Projectile"), 28, 5, projectile.owner, 0f, 0f);
        }
 
So this doesn't work, obviously, but could you tell me whats wrong about it? I assume the Main.mouse(X,Y) are not as set in stone as I would think and I need to actually set them before calling them. Maybe Main.mouse(X,Y) doesn't work with projectiles at all?
Code:
public override void Kill(int timeLeft)
        {
            Projectile.NewProjectile(Main.mouseX, Main.mouseY, 0f, 0f, mod.ProjectileType("Projectile"), 28, 5, projectile.owner, 0f, 0f);
        }
You have to add a value to Main.mouseX, screenPosition. Here's an example from my Rainbow Vortex projectile from my mod, COFP. This was stuffed on the AI portion and this allowed the projectile to stick to the mouse.

Code:
Player p = Main.player[projectile.owner];

Vector2 vector14;
vector14.X = (float)Main.mouseX + Main.screenPosition.X;
if (p.gravDir == 1f)
{
   vector14.Y = (float)Main.mouseY + Main.screenPosition.Y - (float)p.height;
}
else
{
   vector14.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
}

projectile.position = vector14;
 
Sounds like you want UseItemFrame.
Well, how about that? I'm certain that I checked there before, but that was several updates ago. Clearly, I needed to check again before asking.

You have to add a value to Main.mouseX, screenPosition. Here's an example from my Rainbow Vortex projectile from my mod, COFP. This was stuffed on the AI portion and this allowed the projectile to stick to the mouse.

Code:
Player p = Main.player[projectile.owner];

Vector2 vector14;
vector14.X = (float)Main.mouseX + Main.screenPosition.X;
if (p.gravDir == 1f)
{
   vector14.Y = (float)Main.mouseY + Main.screenPosition.Y - (float)p.height;
}
else
{
   vector14.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
}

projectile.position = vector14;
You could also try Main.MouseWorld. It works for me.
 
You have to add a value to Main.mouseX, screenPosition. Here's an example from my Rainbow Vortex projectile from my mod, COFP. This was stuffed on the AI portion and this allowed the projectile to stick to the mouse.

Code:
Player p = Main.player[projectile.owner];

Vector2 vector14;
vector14.X = (float)Main.mouseX + Main.screenPosition.X;
if (p.gravDir == 1f)
{
   vector14.Y = (float)Main.mouseY + Main.screenPosition.Y - (float)p.height;
}
else
{
   vector14.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
}

projectile.position = vector14;

You could also try Main.MouseWorld. It works for me.
Good call. Main.MouseWorld is almost exactly the same as the code posted, except you never have to write the code at all.
Code:
public static Vector2 MouseWorld
        {
            get
            {
                Vector2 result = Main.MouseScreen + Main.screenPosition;
                if (Main.player[Main.myPlayer].gravDir == -1f)
                {
                    result.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
                }
                return result;
            }
        }
Edit: Additional question, what do I change for, say, making it spawn in lava layer depths?
try Main.rockLayer? Actually, maybe WorldGen.lavaLine? lavaline is an int.
 
Back
Top Bottom