Standalone [1.3] tModLoader - A Modding API

DoYouEvenCookie

Terrarian
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
 

Myth

Terrarian
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.
 

Dan Yami

Empress of Light
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...)
 

Dan Yami

Empress of Light
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!!!!!!!!!!!!
 

TheTrueBrawler

Plantera
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?
 

Dan Yami

Empress of Light
OMG!!! ITS BECUS ITS SacredTools.Weapons and not SacredTools.Items.Weapons -.-

ARGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
[doublepost=1468762956,1468762689][/doublepost]next question:
i wanted to make a Custom Ore, but i want it to be mined ONLY with Pickaxe Power 250%
how can i do this??
 

Argo11

Terrarian
hello. I am really new to the Tmodloader, and after a while of modded terraria and searching for a mod that suits me, I realized that I cannot find it. So i decided to create my own mod. which i dont know how to do.

The basic idea of my Mod is to expand on the Fishing system of Terraria. In vanilla terraira, you can kill at least Duke Fishron with only things you can collect from Fishing. I want to make Fishing a significant thing, by adding more fishable items, and even maybe a Boss or two. My ultimate goal is to create a powerful fishing class character that can kill the MOON LORD with items gained from only fishing. and on EXPERT.

Of course, a mod that allows you to expand one class and let it kill high level bosses on expert sounds like something of Zoalkan or maybe Thorium.(both mods have a side that boosts Thrower class significantly) It sounds difficult, and im not even sure if Tmodloader can support modded fishing(that may be why I cant seem to find any...) but I want to create it anyways.

Maybe in the future, I may expand this mod to support other side classes like Thrower, Demolitionist(explosive only) or healer class. But thats my basic idea. For now, I want to work on the fishing side.

If anyone can help me with this, especially the coding(The best i can do is Sprite, but I have created a small mod for minecraft before. although they are really different) I would be very happy.

P.S.) this idea came from the basis of a youtuber. He sort of made me want to do a modded fishing class, so when i didnt find one I just decided to create one. Or at least get the idea out there. I have several ideas already.

If someone could get back to me, thank you. (geeze this sounds like a letter to someone...)

Edit: If instead of creating my own mod, You think having me help create your mod is better, then sure. But my main priority is to create a mod that somehow adds expansions to fishing. I can help with your own mod, especially with sprites.
 
Last edited:

Dan Yami

Empress of Light
hey snrasha ur back!
sorry to bother, but how do i make a projectile make an animated explosion when it hits something??
(with sound and dust and stuff, and damage)

SORRY, I DIDNT FIND ANYTHING
 

Joost8910

Dungeon Spirit
How to I make a npc aim at the player when it fires? Like a skeleton archer. But I still want a custom animation for the NPC, not use the exact same frameanimation as the archer.
EDIT: I also need to know how to make a NPC face right when going that way.
 
Last edited:

Snrasha

Terrarian
hey snrasha ur back!
sorry to bother, but how do i make a projectile make an animated explosion when it hits something??
(with sound and dust and stuff, and damage)

SORRY, I DIDNT FIND ANYTHING
Check method damage in the vanilla code, with the type of a rocket. (Then, you include that in OnhitNpc or other.)
Yes, here, i can understand than you do not found, but after my help, if you do not found, i cannot help you(Because this is that, the answer.)

After, i am a holiday, so, no i am not back, i cannot help too. (And, if i help you too, you have a problem, ^^')
 

DoYouEvenCookie

Terrarian
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. I want this so it shoots the way it is facing when it spins.

- 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 draw a giant rectangle, sort of like the circle around the abomination in that it is shaded, but more like the purity spirit's arena rectangle, 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. Reword : find 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...)

- also how could I make a bouncing 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 a projectile shoot motionless projectile every single tick to stay along the path it took and damage the player Basically, I want a damaging trail left behind a projectile

- how might I make the npc damage and defense 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

green is for important parts of each question that were already in the question that I need to know
red is for rewriting the question if it is not complete

PLEASE Help or find me good, complete tutorials. I can't find anything on this.
 

Terminator

Skeletron Prime
On MacOSX it doesn't even load up, says its running for a few seconds, and then syncs and doesn't say anything. i feel like it might have to do with the terraria.exe not being an .app, but when you change it to an .app, it disappears, and goes invisible, and your not able to change the terrariaOld back, since terraria.app is used

I tied to change the terraria file at the start to .app which worked, but now it wont allow me to paste any of the files into the Steam Terraria folder, and it says that an item is already named terraria, even after changing the name to TerrariaOld
 
Last edited:
Top Bottom