• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.4 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

Standalone [1.3] tModLoader - A Modding API

Eldrazi

Eater of Worlds
My sprite artist is causing a holdup but Ill tell you then.
[DOUBLEPOST=1457578539,1457578329][/DOUBLEPOST]I tested with an old sprite and damn they are hilarious to watch but ya they work xD
Allright good to hear!
When you're ready for some projectile spawning let me know and I'll see if I can come up with an example for that fighter AI.
 

Endershot355

Steampunker
My pleasure

NPC code
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System;

namespace Enderuim.NPCs
{
    public class BruteZombie : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Brutish Zombie";
            npc.displayName = "Brutish Zombie";
            npc.width = 26;
            npc.height = 26;
            npc.damage = 80;
            npc.defense = 7;
            npc.lifeMax = 1000;
            npc.soundHit = 1;
            npc.soundKilled = 1;
            npc.value = 60f;
            npc.knockBackResist = 0.5f;
            Main.npcFrameCount[npc.type] = 3;
        }
            public override bool PreAI()
{
    MyModNPCAIExtras.FighterAI(npc.whoAmI, 5, 0.3F, null);
    return false;
}           
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
    if(((myModPlayer)spawnInfo.player.GetModPlayer(mod, "myModPlayer")).accessoryOn== true);
    {
        return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;
    }
    return 0f;
    }
    public override void FindFrame(int frameHeight)
{
    npc.frameCounter += 0.1F; // Determines the animation speed. Higher value = faster animation.
    npc.frameCounter %= Main.npcFrameCount[npc.type];
    int frame = (int)npc.frameCounter;
    npc.frame.Y = frame * frameHeight;

    npc.spriteDirection = npc.direction;
}
}
}
Modplayer
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Enderuim
{
public class myModPlayer : ModPlayer
{
public bool accessoryOn = false;


public override void PreUpdate()
{
accessoryOn = false;
}

}}
Item
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Enderuim.Items
{
public class EnderuimTotem : ModItem
{
public override void SetDefaults()
{
item.name = "Enderuim Totem";
item.width = 30;
item.height = 30;
item.toolTip = "Awakens monsters of Dark Mode when worn";
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 9;
item.accessory = true;
item.defense = 6;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn= true;
}


}
}
 

Eldrazi

Eater of Worlds
My pleasure

NPC code
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System;

namespace Enderuim.NPCs
{
    public class BruteZombie : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Brutish Zombie";
            npc.displayName = "Brutish Zombie";
            npc.width = 26;
            npc.height = 26;
            npc.damage = 80;
            npc.defense = 7;
            npc.lifeMax = 1000;
            npc.soundHit = 1;
            npc.soundKilled = 1;
            npc.value = 60f;
            npc.knockBackResist = 0.5f;
            Main.npcFrameCount[npc.type] = 3;
        }
            public override bool PreAI()
{
    MyModNPCAIExtras.FighterAI(npc.whoAmI, 5, 0.3F, null);
    return false;
}          
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
    if(((myModPlayer)spawnInfo.player.GetModPlayer(mod, "myModPlayer")).accessoryOn== true);
    {
        return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;
    }
    return 0f;
    }
    public override void FindFrame(int frameHeight)
{
    npc.frameCounter += 0.1F; // Determines the animation speed. Higher value = faster animation.
    npc.frameCounter %= Main.npcFrameCount[npc.type];
    int frame = (int)npc.frameCounter;
    npc.frame.Y = frame * frameHeight;

    npc.spriteDirection = npc.direction;
}
}
}
Modplayer
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Enderuim
{
public class myModPlayer : ModPlayer
{
public bool accessoryOn = false;


public override void PreUpdate()
{
accessoryOn = false;
}

}}
Item
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace Enderuim.Items
{
public class EnderuimTotem : ModItem
{
public override void SetDefaults()
{
item.name = "Enderuim Totem";
item.width = 30;
item.height = 30;
item.toolTip = "Awakens monsters of Dark Mode when worn";
item.value = Item.buyPrice(0, 10, 0, 0);
item.rare = 9;
item.accessory = true;
item.defense = 6;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
((myModPlayer)player.GetModPlayer(mod, "myModPlayer")).accessoryOn= true;
}


}
}
Allright well for one, I'd replace PreUpdate on your ModPlayer with ResetEffects.

Then the following line:
Code:
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;
Will make sure that even if it's daytime the NPC will spawn. If you want to change this, change the second 100 to 0.
 

Endershot355

Steampunker
how do I make the monster more or less common?
[DOUBLEPOST=1457579349,1457579328][/DOUBLEPOST]and what was the 100f : 100f ratio dong?
[DOUBLEPOST=1457579457][/DOUBLEPOST]OH my god they are still spawning even when the Totem is taken out of my inventory
 

Eldrazi

Eater of Worlds
how do I make the monster more or less common?
[DOUBLEPOST=1457579349,1457579328][/DOUBLEPOST]and what was the 100f : 100f ratio dong?
It's an alternate 'if' statement, meaning that this:
Code:
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;
Is practically the same as this:
Code:
if(spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime)
    return 100;
else
    return 100;
And oh wth... Your syntax is wrong:
Code:
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
    if(((myModPlayer)spawnInfo.player.GetModPlayer(mod, "myModPlayer")).accessoryOn== true); // That last ; here is not supposed to be there!
    {
        return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;
    }
    return 0f;
}
 

jokekid

Terrarian
YAY IT :red:ING WORKED! mind my french im happy rn
[DOUBLEPOST=1457580336,1457579806][/DOUBLEPOST]Alright I is calm now
if you're using this code:
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;

please do yourself a favor, and replace it with this:
return 100f;

there's no point in doing multiple checks, if you're always returning the same thing...
 

Endershot355

Steampunker
if you're using this code:
return spawnInfo.spawnTileY < Main.rockLayer && !Main.dayTime ? 100f : 100f;

please do yourself a favor, and replace it with this:
return 100f;

there's no point in doing multiple checks, if you're always returning the same thing...
Im not doing that anymore :/
 

Eldrazi

Eater of Worlds
is heaven real? other than that nothing else, you helped me enough today! OH WAIT I REMEMBERED HOW DO YOU MAKE ITEMS FLOAT LIKE SOULS
You'll want to put the following inside your SetDefaults function (of your soul item I mean):
Code:
ItemID.Sets.ItemNoGravity[item.type] = true;
 

Endershot355

Steampunker
with the method I was using how do I lower the spawn rate?
[DOUBLEPOST=1457583514,1457582939][/DOUBLEPOST]because they WONT STOP COMING
 

Diabetes

Terrarian
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Hypaxi.Items
{
public class ExampleGun : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemId.DirtBlock);
recipe.SetResult(ItemID.Specter Rifle);
recipe.AddRecipe();
}
}
}





It keeps telling me line 37-38 are messed up but how and if you see anything else wrong could you guys help I'm new at CS
 

Kazzymodus

Moderator
Staff member
Moderator
It keeps telling me line 37-38 are messed up but how and if you see anything else wrong could you guys help I'm new at CS
AddIngredient takes at least two arguments, you need to specify how much Dirt Blocks are required. If you need only one, type:
Code:
recipe.AddIngredient(ItemID.DirtBlock, 1);
Also note how ItemID spells ID with two uppercase letters.

As for SetResult, there are three problems here. First of all, ItemID is only used for items in the vanilla game. Secondly, you can't use spaces in arguments that aren't strings, C# doesn't understand that. Thirdly, SetResult also needs an argument for the amount of items created.

This is what you want:
Code:
recipe.SetResult(this, 1);
You can use 'this' instead of the name of your class, and 1 means that you will only craft one.
 
Top Bottom