Standalone [1.3] tModLoader - A Modding API

Hello, I am trying to make a mod for my friend and I to play, its for his birthday so I'm trying to make it as weird and amusing as possible thus the weird item I will ask about. Anyway I am getting this error when I try to add a accessory: (26,25) : CS1518: Expected class, delegate, enum, interface, or struct
I have had so many problems so far which I have worked around. But please help me with this.
My code for the accessory:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SpikyBelly.Items
{
public class BellyEmblem : ModItem
{


public override void SetDefaults()
{
item.name = "Belly Emblem";
item.width = 10;
item.height = 14;
item.toolTip = "Use this if your willing to take the path of a belly.";
item.toolTip2 = "This can be fused with the souls of the bosses";
item.value = 10;
item.rare = 3;
item.accessory = true;
}
}

public override void UpdateAccessory(Player, player bool hideVisual)

{

player.noFallDmg = false;
player.canRocket = false;
player.rocketTime = 0;
player.rocketBoots = 0;
player.rocketTimeMax = 0;
player.aggro += 0;
player.meleeCrit += 0;
player.meleeDamage += 0f;
player.meleeSpeed += 0f;
player.moveSpeed += 0f;
player.rangedCrit += 0;
player.rangedDamage += 0f;
player.maxMinions++;
player.minionDamage += 0f;
player.statManaMax2 += 40;
player.manaCost -= 0.15f;
player.magicCrit += 7;
player.magicDamage += 3f;
}
}
 
I have a couple of questions about npc ai, projectile ai, and other stuff for my custom boss. I be soo lost

- how do I make the npc texture change to something else kinda like the EoC changes to have a mouth.

- how do I make the npc shoot a projectile from the edge of the texture and not the center to where it's facing, not necessarily at the player EDIT: sorta like the way either one of the twins shoots, my shots usually come out in weird angles from the texture center to where the player is when it is shot.

- how do I make the npc stay stationary and spin
- also how might I make the npc invincible and regen while it is spinning

- how do I make the npc hover above the player like the nimbus, only stay in that position relative to the player no matter how fast they move

- how do I draw a giant rectangle, sort of like the circle around the abomination in that it is shaded, with the player's position, when it is first drawn, as the center when the boss is first summoned, and stay put until the boss is defeated or leaves, which it will do if the player dies
- also how might I move the npc to the center of the rectangle
- also how might I make the npc charge super fast at the payer and deal 1,000,000,000,000 damage or what ever the max damage in terraria is and be invincible if the player leaves the inside of the rectangle (I know it's OP, buuut... the summon item will warn you not to leave...)

- how might I make a bouncing projectile, that bounces like the meteorite bullet, but with no limit
- also how could I make this projectile bounce of the side of the rectangle, but only if it hits them from the inside (or is this even possible)
- also how could I make this projectile shoot motionless projectile every single tick to stay along the path it took and damage the player

- how might I make the npc damage and defence increase the more damaged it is

- how might I make the npc shoot a beam like the moon lord's death ray thing

-how do I make the npc face the player and then charge like the expert EoC

EDIT: 'a couple questions' is a huge understatement. I just noticed that

pls help me

can anyone answer any of these, or point me towards tutorials that explain these things to me.
 
Hello, I am trying to make a mod for my friend and I to play, its for his birthday so I'm trying to make it as weird and amusing as possible thus the weird item I will ask about. Anyway I am getting this error when I try to add a accessory: (26,25) : CS1518: Expected class, delegate, enum, interface, or struct
I have had so many problems so far which I have worked around. But please help me with this.
My code for the accessory:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SpikyBelly.Items
{
public class BellyEmblem : ModItem
{


public override void SetDefaults()
{
item.name = "Belly Emblem";
item.width = 10;
item.height = 14;
item.toolTip = "Use this if your willing to take the path of a belly.";
item.toolTip2 = "This can be fused with the souls of the bosses";
item.value = 10;
item.rare = 3;
item.accessory = true;
}
}

public override void UpdateAccessory(Player, player bool hideVisual)

{

player.noFallDmg = false;
player.canRocket = false;
player.rocketTime = 0;
player.rocketBoots = 0;
player.rocketTimeMax = 0;
player.aggro += 0;
player.meleeCrit += 0;
player.meleeDamage += 0f;
player.meleeSpeed += 0f;
player.moveSpeed += 0f;
player.rangedCrit += 0;
player.rangedDamage += 0f;
player.maxMinions++;
player.minionDamage += 0f;
player.statManaMax2 += 40;
player.manaCost -= 0.15f;
player.magicCrit += 7;
player.magicDamage += 3f;
}
}
It's probably that extra } that is terminating the class. Move the UpdateAccessory method into the class.
 
How do I make a weapon chargeable? Like the charged blaster cannon.
 
How to I add throwing damage to a accessory?
 
How do I make a weapon chargeable? Like the charged blaster cannon.
You copy just the code of the charged blaster cannon, and after 1 hour, you can that: http://imgur.com/dvGlUou
For say simple: The item shoot the weapon who is a projectile, then, you need just know coded and you can go easy all things. I do not send because, you can very easy found the code then delete useless thing.

How to I add throwing damage to a accessory?
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.thrownDamage*=1.1f;
//player.thrownCrit
//player.thrownVelocity
}
 
from where can i copy original code?

i would like to add a fifth lunar pillar :}
 
You copy just the code of the charged blaster cannon, and after 1 hour, you can that: http://imgur.com/dvGlUou
For say simple: The item shoot the weapon who is a projectile, then, you need just know coded and you can go easy all things. I do not send because, you can very easy found the code then delete useless thing.
Huh? How do I find the code? I've never been able to find Terraria's code... And what do you mean by delete useless thing? Your reply is unhelpful.
 
Well, because you do not read my previous answer just belove your question :p
 
What do I do with the ExampleMod when I download it? Do I put the Mod Sources folder and dllReferences folder in the Mod Compile Folder?
 
How do I use a custom sound in main.playsound?
EDIT: I can't get it to work with items Either, what am I doing wrong?
Code:
using Microsoft.Xna.Framework.Audio;
using Terraria;
using Terraria.ModLoader;

namespace JoostMod.Sounds.Item
{
public class IceBeam : ModSound
{
public override void PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type)
{
soundInstance = sound.CreateInstance();
soundInstance.Volume = volume * .5f;
soundInstance.Pan = pan;
soundInstance.Pitch = -1.0f;
Main.PlaySoundInstance(soundInstance);
}
}
}
Code:
item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/IceBeam");
EDIT: I found that I need to use AutoLoadSounds in the mod.cs
EDIT: But I still don't know how with modsound, like for when a projectile dies
 
Last edited:
For some reason it keeps saying the side-by-side configuration is incorrect whenever I try to launch Terraria..
 
So I updated my tModLoader, installed some mods, and whenever I try to make a world it just gets stuck in the middle of "Generating Structures...Minecart Tracks".
 
it the mulitplayer server working here with windows? and how i make one? plz help
 
Last edited:
How might I prevent an enemy npc from despawning?
I have a worm and some of the segments despawn and it gets annoying since it's a boss

I want it to never despawn like the destroyer


on another note, how do I make it disappear if the player dies or when it's day. I can never get that to happen
 
Just reinstalled after needing to reinstall Terraria and before I had it so vanilla Terraria would still be the original Terraria.exe and renamed the new one for tMod to be Terraria1.exe and had a shortcut on my desktop for it. Both worked, but now they won't. Both open tmodloader and neither are opening the vanilla game.

I renamed the Terraria1.3.1.1.exe to Terraria2 to rename the file created to run tmod to Terraria 1.

Any help? I don't want tmod to load everytime I start the game in Steam, just the vanilla game and if I want to run tmod I want to use the shortcut I've got made on my desktop.
 
i need help: does someone have the code for throwing weapons??? i wanna make one so BADLY, but the download link in al0n37's video doesnt work and i didnt find anything in the ExampleMod, nor the rest of the Internet...

(srry snrasha for asking again... i REALLY searched this time but still didnt find anything...)
 
nvm, found something... problem is: WHY DOES THIS NOT WORK?!?!?!

Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;

namespace SacredTools.Weapons
{
    public class NovaKnifePack : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Nova Knife Pack";
            item.damage = 90;
            item.noMelee = true;
            item.thrown = true;
            item.width = 40;
            item.height = 40;
            item.toolTip = "'throws several Nova Knifes'";
            item.useTime = 16;
            item.useAnimation = 16;
            item.useStyle = 1;
            item.knockBack = 4;
            item.rare = 10;
            item.value = Item.sellPrice(0, 10, 0, 0);
            item.useSound = 1;
            item.autoReuse = false;
            item.shoot = mod.ProjectileType("NovaKnife");
            item.shootSpeed = 10f;
            item.useTurn = true;
            item.maxStack = 1;
            item.consumable = false;
            item.noUseGraphic = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "FragmentNova", 18);
            recipe.AddTile(TileID.LunarCraftingStation);
            recipe.SetResult(this, 15);
            recipe.AddRecipe();
        }
       
        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 = 45f * 0.0174f;//45 degrees converted to radians
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);
            double randomAngle = baseAngle+(Main.rand.NextFloat()-0.5f)*spread;
            speedX = baseSpeed*(float)Math.Sin(randomAngle);
            speedY = baseSpeed*(float)Math.Cos(randomAngle);
            return true;
        }
    }
}

it always gets the GetTexture error and the mod gets disabled... WHY?!?!?! THERE IS THE SPRITE!!!!!!!!!!!!
 
nvm, found something... problem is: WHY DOES THIS NOT WORK?!?!?!

Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;

namespace SacredTools.Weapons
{
    public class NovaKnifePack : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Nova Knife Pack";
            item.damage = 90;
            item.noMelee = true;
            item.thrown = true;
            item.width = 40;
            item.height = 40;
            item.toolTip = "'throws several Nova Knifes'";
            item.useTime = 16;
            item.useAnimation = 16;
            item.useStyle = 1;
            item.knockBack = 4;
            item.rare = 10;
            item.value = Item.sellPrice(0, 10, 0, 0);
            item.useSound = 1;
            item.autoReuse = false;
            item.shoot = mod.ProjectileType("NovaKnife");
            item.shootSpeed = 10f;
            item.useTurn = true;
            item.maxStack = 1;
            item.consumable = false;
            item.noUseGraphic = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "FragmentNova", 18);
            recipe.AddTile(TileID.LunarCraftingStation);
            recipe.SetResult(this, 15);
            recipe.AddRecipe();
        }
      
        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 = 45f * 0.0174f;//45 degrees converted to radians
            float baseSpeed = (float)Math.Sqrt(speedX * speedX + speedY * speedY);
            double baseAngle = Math.Atan2(speedX, speedY);
            double randomAngle = baseAngle+(Main.rand.NextFloat()-0.5f)*spread;
            speedX = baseSpeed*(float)Math.Sin(randomAngle);
            speedY = baseSpeed*(float)Math.Cos(randomAngle);
            return true;
        }
    }
}

it always gets the GetTexture error and the mod gets disabled... WHY?!?!?! THERE IS THE SPRITE!!!!!!!!!!!!

What is the sprite size?
 
Back
Top Bottom