Standalone [1.3] tModLoader - A Modding API

Can anyone help me when I try to get my npc to spawn on a blood moon I got this error
c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(38,24) : error CS0161: 'EpicnessMod.NPCs.BloodySlime.CanSpawn(Terraria.ModLoader.NPCSpawnInfo)': not all code paths return a value

Here is the npc's code
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessMod.NPCs
{
    public class BloodySlime : ModNPC
    {
public override void SetDefaults()
        {
            npc.name = "Bloody Slime";
            npc.lifeMax = 55;
            npc.damage = 40;
            npc.defense = 45;
            npc.knockBackResist = 0.1f;
            npc.width = 36;
            npc.height = 24;
            animationType = NPCID.MotherSlime;
            npc.aiStyle = 1;
            npc.npcSlots = 1f;
            npc.noGravity = false;
            npc.soundHit = 1;
            npc.soundKilled = 6;
            Main.npcFrameCount[npc.type] = 2;
            npc.value = Item.buyPrice(0, 0, 30, 5);
            npc.buffImmune[BuffID.Poisoned] = true;
            npc.buffImmune[BuffID.Venom] = true;
            banner = npc.type;
            bannerItem = mod.ItemType("BloodySlimeBanner");
        }
        public override void NPCLoot()
        {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType ("BloodGel"));
        }
    public override float CanSpawn(NPCSpawnInfo spawnInfo)
    {
  if (Main.bloodMoon)
{
return 1f;
}
    }

  
}
}
Your CanSpawn is only returning IF Main.bloodmoon is true, but it won't return anything if it is false. hence the error.
Make it an if else statement.
 
Your CanSpawn is only returning IF Main.bloodmoon is true, but it won't return anything if it is false. hence the error.
Make it an if else statement.
I put an if else statement and I got this error
c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(45,8) : error CS1003: Syntax error, '(' expected

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(46,1) : error CS1525: Invalid expression term '{'

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(46,2) : error CS1026: ) expected

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(47,14) : error CS1514: { expected

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(49,3) : error CS1525: Invalid expression term '}'

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(49,4) : error CS1002: ; expected


Here is the code
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessMod.NPCs
{
    public class BloodySlime : ModNPC
    {
public override void SetDefaults()
        {
            npc.name = "Bloody Slime";
            npc.lifeMax = 55;
            npc.damage = 40;
            npc.defense = 45;
            npc.knockBackResist = 0.1f;
            npc.width = 36;
            npc.height = 24;
            animationType = NPCID.MotherSlime;
            npc.aiStyle = 1;
            npc.npcSlots = 1f;
            npc.noGravity = false;
            npc.soundHit = 1;
            npc.soundKilled = 6;
            Main.npcFrameCount[npc.type] = 2;
            npc.value = Item.buyPrice(0, 0, 30, 5);
            npc.buffImmune[BuffID.Poisoned] = true;
            npc.buffImmune[BuffID.Venom] = true;
            banner = npc.type;
            bannerItem = mod.ItemType("BloodySlimeBanner");
        }
        public override void NPCLoot()
        {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType ("BloodGel"));
        }
    public override float CanSpawn(NPCSpawnInfo spawnInfo)   
  {
  if (Main.bloodMoon)
{
return 1f;
}

else if
{
return false;   
}   
  }
}
}
 
how does one use public int music
"The ID of the music that plays when this NPC is on or near the screen. Defaults to -1, which means music plays normally."
in the ModNPC class.
[DOUBLEPOST=1453576699,1453576657][/DOUBLEPOST]
I put an if else statement and I got this error
c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(45,8) : error CS1003: Syntax error, '(' expected

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(46,1) : error CS1525: Invalid expression term '{'

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(46,2) : error CS1026: ) expected

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(47,14) : error CS1514: { expected

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(49,3) : error CS1525: Invalid expression term '}'

c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(49,4) : error CS1002: ; expected


Here is the code
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessMod.NPCs
{
    public class BloodySlime : ModNPC
    {
public override void SetDefaults()
        {
            npc.name = "Bloody Slime";
            npc.lifeMax = 55;
            npc.damage = 40;
            npc.defense = 45;
            npc.knockBackResist = 0.1f;
            npc.width = 36;
            npc.height = 24;
            animationType = NPCID.MotherSlime;
            npc.aiStyle = 1;
            npc.npcSlots = 1f;
            npc.noGravity = false;
            npc.soundHit = 1;
            npc.soundKilled = 6;
            Main.npcFrameCount[npc.type] = 2;
            npc.value = Item.buyPrice(0, 0, 30, 5);
            npc.buffImmune[BuffID.Poisoned] = true;
            npc.buffImmune[BuffID.Venom] = true;
            banner = npc.type;
            bannerItem = mod.ItemType("BloodySlimeBanner");
        }
        public override void NPCLoot()
        {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType ("BloodGel"));
        }
    public override float CanSpawn(NPCSpawnInfo spawnInfo)  
  {
  if (Main.bloodMoon)
{
return 1f;
}

else if
{
return false;  
}  
  }
}
}
Well idk what you are doing, but you're now calling an if statement without even checking anything...
 
"The ID of the music that plays when this NPC is on or near the screen. Defaults to -1, which means music plays normally."
in the ModNPC class.
[DOUBLEPOST=1453576699,1453576657][/DOUBLEPOST]
Well idk what you are doing, but you're now calling an if statement without even checking anything...
I understand thats where i got it
I want to know how to get the Plantera theme to play
 
"The ID of the music that plays when this NPC is on or near the screen. Defaults to -1, which means music plays normally."
in the ModNPC class.
[DOUBLEPOST=1453576699,1453576657][/DOUBLEPOST]
Well idk what you are doing, but you're now calling an if statement without even checking anything...
Well here is the code for the npc....
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessMod.NPCs
{
    public class BloodySlime : ModNPC
    {
public override void SetDefaults()
        {
            npc.name = "Bloody Slime";
            npc.lifeMax = 55;
            npc.damage = 40;
            npc.defense = 45;
            npc.knockBackResist = 0.1f;
            npc.width = 36;
            npc.height = 24;
            animationType = NPCID.MotherSlime;
            npc.aiStyle = 1;
            npc.npcSlots = 1f;
            npc.noGravity = false;
            npc.soundHit = 1;
            npc.soundKilled = 6;
            Main.npcFrameCount[npc.type] = 2;
            npc.value = Item.buyPrice(0, 0, 30, 5);
            npc.buffImmune[BuffID.Poisoned] = true;
            npc.buffImmune[BuffID.Venom] = true;
            banner = npc.type;
            bannerItem = mod.ItemType("BloodySlimeBanner");
        }
        public override void NPCLoot()
        {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType ("BloodGel"));
        }
    public override float CanSpawn(NPCSpawnInfo spawnInfo)   
  {
  if (Main.bloodMoon == true)
{
return 1f;
}
else if (Main.bloodMoon == false)
{
return false;   
}   
  }
}
}

For some reason I get this error
c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(46,8) : error CS0029: Cannot implicitly convert type 'bool' to 'float'
 
Well here is the code for the npc....
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessMod.NPCs
{
    public class BloodySlime : ModNPC
    {
public override void SetDefaults()
        {
            npc.name = "Bloody Slime";
            npc.lifeMax = 55;
            npc.damage = 40;
            npc.defense = 45;
            npc.knockBackResist = 0.1f;
            npc.width = 36;
            npc.height = 24;
            animationType = NPCID.MotherSlime;
            npc.aiStyle = 1;
            npc.npcSlots = 1f;
            npc.noGravity = false;
            npc.soundHit = 1;
            npc.soundKilled = 6;
            Main.npcFrameCount[npc.type] = 2;
            npc.value = Item.buyPrice(0, 0, 30, 5);
            npc.buffImmune[BuffID.Poisoned] = true;
            npc.buffImmune[BuffID.Venom] = true;
            banner = npc.type;
            bannerItem = mod.ItemType("BloodySlimeBanner");
        }
        public override void NPCLoot()
        {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType ("BloodGel"));
        }
    public override float CanSpawn(NPCSpawnInfo spawnInfo) 
  {
  if (Main.bloodMoon == true)
{
return 1f;
}
else if (Main.bloodMoon == false)
{
return false; 
} 
  }
}
}

For some reason I get this error
c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\NPCs\BloodySlime.cs(46,8) : error CS0029: Cannot implicitly convert type 'bool' to 'float'

I don't know about you, but I'd look at some basic c# (csharp) tutorials if I were you. The method CanSpawn expects to return a float value, not a boolean. In your code, you're trying to return both types.
[DOUBLEPOST=1453577152,1453577020][/DOUBLEPOST]
im stupid and dont know how to use the context
what do i need to put in the method
im stupid and dont know how to use the context
what do i need to put in the method
music = MusicID.Plantera;
or
music = 24;

???
 
I got an error with music:
error CS1501: No overload for method 'music' takes 1 arguments
Code:
        public int music()
{
        music(24);
        }
You are treating it like a method while it's actually a field/property, so you can just get; and set; it.
For example: music = 24;
 
How can I edit this AI to make my entity pass through blocks
[DOUBLEPOST=1453586868,1453586852][/DOUBLEPOST]
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System;

namespace Enderuim.NPCs
{
    public class Angel : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "AngelicBeing";
            npc.displayName = "Angelic Being";
            npc.width = 250;
            npc.height = 208;
            npc.damage = 200;
            npc.defense = 20;
            npc.lifeMax = 30000;
            npc.soundHit = 1;
            npc.soundKilled = 2;
            npc.value = 60f;
            npc.knockBackResist = 0f;
            music = 24;
        }
                                            public override bool PreAI()
{
    npc.noGravity = true;
    // The following handles the collision: 
 
    npc.TargetClosest(true);
        npc.ai[0]++;
            if (npc.ai[0] > 80)
            {
                if (npc.HasValidTarget && Main.player[npc.target].Distance(npc.Center) < 500f)
                {
                    Vector2 direction = Main.player[npc.target].Center - npc.Center;
                    direction.Normalize();
                    if (Main.rand.Next(2) == 0)
                    {
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction.X * 5f, direction.Y * 5f, mod.ProjectileType("AngelicOrb"), 10, 1, Main.myPlayer, 0, 0);
                    }
                    else
                    {
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction.X * 5f, direction.Y * 5f, mod.ProjectileType("AngelicBolt"), 10, 1, Main.myPlayer, 0, 0);
                    }
                    npc.ai[0] = 0;
                }
            }
   
    float num1 = 4f;
    float num2 = 1.5f;
    float num3 = num1 * (float) (1.0 + (1.0 - (double) npc.scale));
    float num4 = num2 * (float) (1.0 + (1.0 - (double) npc.scale));
    if (npc.direction == -1 && (double) npc.velocity.X > -(double) num3)
    {
        npc.velocity.X = npc.velocity.X - 0.1f;
        if ((double) npc.velocity.X > (double) num3)
            npc.velocity.X = npc.velocity.X - 0.1f;
        else if ((double) npc.velocity.X > 0.0)
            npc.velocity.X = npc.velocity.X + 0.05f;
        if ((double) npc.velocity.X < -(double) num3)
         npc.velocity.X = -num3;
    }
    else if (npc.direction == 1 && (double) npc.velocity.X < (double) num3)
    {
        npc.velocity.X = npc.velocity.X + 0.1f;
        if ((double) npc.velocity.X < -(double) num3)
            npc.velocity.X = npc.velocity.X + 0.1f;
        else if ((double) npc.velocity.X < 0.0)
            npc.velocity.X = npc.velocity.X - 0.05f;
        if ((double) npc.velocity.X > (double) num3)
            npc.velocity.X = num3;
    }
    if (npc.directionY == -1 && (double) npc.velocity.Y > -(double) num4)
    {
        npc.velocity.Y = npc.velocity.Y - 0.04f;
        if ((double) npc.velocity.Y > (double) num4)
            npc.velocity.Y = npc.velocity.Y - 0.05f;
        else if ((double) npc.velocity.Y > 0.0)
            npc.velocity.Y = npc.velocity.Y + 0.03f;
        if ((double) npc.velocity.Y < -(double) num4)
            npc.velocity.Y = -num4;
    }
    else if (npc.directionY == 1 && (double) npc.velocity.Y < (double) num4)
    {
        npc.velocity.Y = npc.velocity.Y + 0.04f;
        if ((double) npc.velocity.Y < -(double) num4)
            npc.velocity.Y = npc.velocity.Y + 0.05f;
        else if ((double) npc.velocity.Y < 0.0)
            npc.velocity.Y = npc.velocity.Y - 0.03f;
        if ((double) npc.velocity.Y > (double) num4)
            npc.velocity.Y = num4;
    }
 
    if(!npc.wet)
        return false;
 
    if ((double) npc.velocity.Y > 0.0)
        npc.velocity.Y = npc.velocity.Y * 0.95f;
    npc.velocity.Y = npc.velocity.Y - 0.5f;
    if ((double) npc.velocity.Y < -4.0)
        npc.velocity.Y = -4f;
    npc.TargetClosest(true);

 
    return false;
}
        public override void NPCLoot()
        {   
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("ShatteredHalo"));
        }
    }
}
 
GraniteGreatSword.gif

I need this to spawn 4 pieces of gore when the projectile is dead
 
How do I make my Boss summon small lil :red:s.
[DOUBLEPOST=1453588651,1453588274][/DOUBLEPOST]Okay, so how do I make a projectile effect the player with a debuff?
 
I am trying to create a server to play a mod with my friend on Terraria, the tremor mod, but it won't work! I hit multiplayer, choose my player and my world, and it freezes on "Starting Server..." can you not do multiplayer with tmodloader?
 
I am trying to create a server to play a mod with my friend on Terraria, the tremor mod, but it won't work! I hit multiplayer, choose my player and my world, and it freezes on "Starting Server..." can you not do multiplayer with tmodloader?
Well, you can actually enter your world with mods, only it is not recommended, since multiplayer is not officially supported yet now. If you insist to play multiplayer with tmodloader, for now, it's gonna be bad, 'cause there will be a lot of bugs and wired phenomena which will disturb your game process.
 
how do I make a beam projectile? I want it to be a steady beam, but i have 2 issues
1: Sprites only face one way
2:Annoying af noise
 
Back
Top Bottom