Standalone [1.3] tModLoader - A Modding API

This is probably a dumb question but how do I make a boss summoning item spawn the boss in front of the player?

The code has changed since the last time I've done this so thats why I'm asking this.
 
Thank you so much!i!
Fair warning, that version had to have massive changes to allow for 64 bit compatability, and as such has numerous issues with many mods at the moment. Be careful what you install, and don't expect a lot of help for any bugs you encounter from mod authors while using it.
 
I have these bugs:

c:\Users\I decided to hide my irl name here.\Documents\My Games\Terraria\ModLoader\Mod Sources\testingmod\Items\Suspicious Looking Electric Cube.cs(5,22) : error CS1514: { expected!

Code is this:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Suspicious Looking Electric Cube.Items // Changed from my mod name to this due to bug, stopped getting the bug
{
    public class ItemName : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Suspicious Looking Cube";
            item.width = 100;
            item.height = 100;
            item.maxStack = 10;
            AddTooltip("Summons Cube Bunk");
            item.value = 5000;
            item.rare = 1;
        }
    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(ItemID.DirtBlock, 10);
        recipe.AddTile(TileID.WorkBenches);
        recipe.SetResult(this);
        recipe.AddRecipe()
        }
    }
}
 
I have these bugs:

c:\Users\I decided to hide my irl name here.\Documents\My Games\Terraria\ModLoader\Mod Sources\testingmod\Items\Suspicious Looking Electric Cube.cs(5,22) : error CS1514: { expected!

Code is this:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Suspicious Looking Electric Cube.Items // Changed from my mod name to this due to bug, stopped getting the bug
{
    public class ItemName : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Suspicious Looking Cube";
            item.width = 100;
            item.height = 100;
            item.maxStack = 10;
            AddTooltip("Summons Cube Bunk");
            item.value = 5000;
            item.rare = 1;
        }
    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(ItemID.DirtBlock, 10);
        recipe.AddTile(TileID.WorkBenches);
        recipe.SetResult(this);
        recipe.AddRecipe()
        }
    }
}

I realised that there cant be spaces due to where it expected {
[doublepost=1549904078,1549903553][/doublepost]c:\Users\[SENSITIVE INFORMATION]\Documents\My Games\Terraria\ModLoader\Mod Sources\testingmod\Items\Suspicious Looking Electric Cube.cs(10,18) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
[doublepost=1549904138][/doublepost]i have that bug for no apparent reason.

i used a modding tutorial for help, same exact code style, and i have an error.
 
I realised that there cant be spaces due to where it expected {
[doublepost=1549904078,1549903553][/doublepost]c:\Users\[SENSITIVE INFORMATION]\Documents\My Games\Terraria\ModLoader\Mod Sources\testingmod\Items\Suspicious Looking Electric Cube.cs(10,18) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
[doublepost=1549904138][/doublepost]i have that bug for no apparent reason.

i used a modding tutorial for help, same exact code style, and i have an error.
I think that the code is invalid,
Code:
    public class NAME: ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("NAME");
            Tooltip.SetDefault("ITEMTOOLTIP");
        }

        public override void SetDefaults()
        {
            item.whatever
        }
If that doesn't fix it try adding using Microsoft.Xna.Framework; to the top of the code
 
So I dont know how to intall this at all. Can someone help me? Maybe explain a few things because i dont know anything
 
Is there a way to make an enemy spawn after a boss from my mod is killed? For example a line reading "if(downedKingSlime = true; ) ..." but instead checks if a boss from my mod has been downed instead. Thanks in advance.
 
Last edited:
using Terraria;
using Terraria.ModLoader;
using System;

namespace Hypaxi
{
public abstract class InsanityItem : ModItem
{
public static bool insanity = true;
public override void SetDefaults()
{
item.melee = false;
item.ranged = false;
item.thrown = false;
item.magic = false;
item.summon = false;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
{
var tt = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria");
if (tt != null)
{
string[] split = tt.text.Split(' ');
tt.text = split.First() + " insanity " + split.Last();
}
}
public override void GetWeaponDamage(Player player, ref int damage)
{
HypaxiPlayer modPlayer = player.GetModPlayer<HypaxiPlayer>(mod);
int originalDamage = damage;
damage = (int)(damage * modPlayer.insanityDamage);
float globalDmg = 1f;
globalDmg = player.meleeDamage - 1;
if (player.magicDamage - 1 < globalDmg)
globalDmg = player.magicDamage - 1;
if (player.rangedDamage - 1 < globalDmg)
globalDmg = player.rangedDamage - 1;
if (player.thrownDamage - 1 < globalDmg)
globalDmg = player.thrownDamage - 1;
if (player.minionDamage - 1 < globalDmg)
globalDmg = player.minionDamage - 1;
if (globalDmg > 1)
damage = damage + (int)(originalDamage * globalDmg);
}
}
}


(18,37) : error CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)

Can someone help me I am making a new damage type and I do not know how to fix this?
 
Is there a way to make an enemy spawn after a boss from my mod is killed? For example a line reading "if(downedKingSlime = true; ) ..." but instead checks if a boss from my mod has been downed instead. Thanks in advance.
You would probably need to create a ModWorld class (if you don't have one already) and create a bool there that stores whether or not your boss has been killed. You can check against that bool before spawning your NPC. You'll need to use override void save and override void load to save this bool between sessions.

using Terraria;
using Terraria.ModLoader;
using System;

namespace Hypaxi
{
public abstract class InsanityItem : ModItem
{
public static bool insanity = true;
public override void SetDefaults()
{
item.melee = false;
item.ranged = false;
item.thrown = false;
item.magic = false;
item.summon = false;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
{
var tt = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria");
if (tt != null)
{
string[] split = tt.text.Split(' ');
tt.text = split.First() + " insanity " + split.Last();
}
}
public override void GetWeaponDamage(Player player, ref int damage)
{
HypaxiPlayer modPlayer = player.GetModPlayer<HypaxiPlayer>(mod);
int originalDamage = damage;
damage = (int)(damage * modPlayer.insanityDamage);
float globalDmg = 1f;
globalDmg = player.meleeDamage - 1;
if (player.magicDamage - 1 < globalDmg)
globalDmg = player.magicDamage - 1;
if (player.rangedDamage - 1 < globalDmg)
globalDmg = player.rangedDamage - 1;
if (player.thrownDamage - 1 < globalDmg)
globalDmg = player.thrownDamage - 1;
if (player.minionDamage - 1 < globalDmg)
globalDmg = player.minionDamage - 1;
if (globalDmg > 1)
damage = damage + (int)(originalDamage * globalDmg);
}
}
}


(18,37) : error CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)

Can someone help me I am making a new damage type and I do not know how to fix this?
I believe that you need to add using System.Collections.Generic to the other using statements. That way, the class will know what a list is.
 
Hello , thx for your work ^^

i curretly collect (atleast try) every Dev set , and i've notice some are from Tmodloader ,so where can i find the complet list of Tmodloader dev Set please ?

For now i've these one :
ed80b06d55a5e728c5138b86cd3e3e70.png

So :
-Kittykitcatcat
-dinidini
-Polyblank
-toplayz
 
please remove the "move to cloud" button, it's destroys saves
 
Hi,I have problem when compiling a mod.
Here the .cs files and compile log.Sorry for my english because i'm a russian.
 

Attachments

Hi,I have problem when compiling a mod.
Here the .cs files and compile log.Sorry for my english because i'm a russian.
There are a lot of errors that come from a few things. On the shortsword code, uncomment the
Code:
public override void AddRecipes()
line and then add a closing bracket after the
Code:
recipe.AddRecipe();
line. For the Ztalker you have to comment out the last two closing brackets. If you arent using visual studio to code you should try it out. It helps alot for simple errors like these. If you are using it then you should figure out why it isnt pointing these errors out to you.
[doublepost=1552086574,1552086346][/doublepost]
Hi,I have problem when compiling a mod.
Here the .cs files and compile log.Sorry for my english because i'm a russian.
Also, the majority of errors are coming from a file called "ExamplePerson.cs" but you upload the file and i cant read the russian compile errors so i cant really help you out there.
 
Somebody helps me every time I want a code for an enemy I get it wrong
 
Somebody helps me every time I want a code for an enemy I get it wrong
can you show the code and the error? also, you should try going to the discord. people are a lot more active over there.
 
c:\Users\Nassa\Documents\My Games\Terraria\ModLoader\Mod Sources\GalacticMod\NPCs\Slimi.cs(28,31) : error CS0115: 'GalacticMod.NPCs.Slimi.CanSpawn(Terraria.ModLoader.NPCSpawnInfo)': no se encontró ningún miembro adecuado que invalidar

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace GalacticMod.NPCs
{
public class Slimi : ModNPC
{
public override void SetDefaults()
{
npc.name = "Slimi";
npc.displayName = "Slimi";
npc.width = 33;
npc.height = 22;
npc.damage = 4;
npc.defense = 2;
npc.lifeMax = 30;
npc.soundHit = 1;
npc.soundKilled = 2;
npc.value = 60f;
npc.knockBackResist = 0.5f;
npc.aiStyle = 1; //see here: http://tconfig.wikia.com/wiki/List_of_NPC_AI_Styles
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Slime];
aiType = NPCID.Slime;
animationType = NPCID.Slime;
}

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.worldSurface && Main.dayTime ? 1.0f : 0f; //spawn at day
}

public override void NPCLoot()
{
if (Main.rand.Next(1, 50) == 1) //drop chance - This gives a 49% chance as 50-1 = 49
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.LunarBar, Main.rand.Next(5, 10)); //amount
}
}
}
}
[doublepost=1552112865,1552112739][/doublepost]
Somebody helps me every time I want a code for an enemy I get it wrong

Tell me the record please
[doublepost=1552112960][/doublepost]discord Which
 
c:\Users\Nassa\Documents\My Games\Terraria\ModLoader\Mod Sources\GalacticMod\NPCs\Slimi.cs(28,31) : error CS0115: 'GalacticMod.NPCs.Slimi.CanSpawn(Terraria.ModLoader.NPCSpawnInfo)': no se encontró ningún miembro adecuado que invalidar

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace GalacticMod.NPCs
{
public class Slimi : ModNPC
{
public override void SetDefaults()
{
npc.name = "Slimi";
npc.displayName = "Slimi";
npc.width = 33;
npc.height = 22;
npc.damage = 4;
npc.defense = 2;
npc.lifeMax = 30;
npc.soundHit = 1;
npc.soundKilled = 2;
npc.value = 60f;
npc.knockBackResist = 0.5f;
npc.aiStyle = 1; //see here: http://tconfig.wikia.com/wiki/List_of_NPC_AI_Styles
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Slime];
aiType = NPCID.Slime;
animationType = NPCID.Slime;
}

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.worldSurface && Main.dayTime ? 1.0f : 0f; //spawn at day
}

public override void NPCLoot()
{
if (Main.rand.Next(1, 50) == 1) //drop chance - This gives a 49% chance as 50-1 = 49
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.LunarBar, Main.rand.Next(5, 10)); //amount
}
}
}
}
[doublepost=1552112865,1552112739][/doublepost]

Tell me the record please
[doublepost=1552112960][/doublepost]discord Which
the discord is in the original post. can you post the error too?
 
c:\Users\Nassa\Documents\My Games\Terraria\ModLoader\Mod Sources\GalacticMod\NPCs\Slimi.cs(28,31) : error CS0115: 'GalacticMod.NPCs.Slimi.CanSpawn(Terraria.ModLoader.NPCSpawnInfo)': no se encontró ningún miembro adecuado que invalidar

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace GalacticMod.NPCs
{
public class Slimi : ModNPC
{
public override void SetDefaults()
{
npc.name = "Slimi";
npc.displayName = "Slimi";
npc.width = 33;
npc.height = 22;
npc.damage = 4;
npc.defense = 2;
npc.lifeMax = 30;
npc.soundHit = 1;
npc.soundKilled = 2;
npc.value = 60f;
npc.knockBackResist = 0.5f;
npc.aiStyle = 1; //see here: http://tconfig.wikia.com/wiki/List_of_NPC_AI_Styles
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Slime];
aiType = NPCID.Slime;
animationType = NPCID.Slime;
}

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.worldSurface && Main.dayTime ? 1.0f : 0f; //spawn at day
}

public override void NPCLoot()
{
if (Main.rand.Next(1, 50) == 1) //drop chance - This gives a 49% chance as 50-1 = 49
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.LunarBar, Main.rand.Next(5, 10)); //amount
}
}
}
}
[doublepost=1552112865,1552112739][/doublepost]

Tell me the record please
[doublepost=1552112960][/doublepost]discord Which

I passed the link
 
I passed the link
oh sorry, didnt see it. Try switching out
Code:
public override float CanSpawn(NPCSpawnInfo spawnInfo)
with
Code:
public override float SpawnChance(NPCSpawnInfo spawnInfo)
.
Also, I think you might be using the older format for the code. Try following this example.
 
Back
Top Bottom