Standalone [1.3] tModLoader - A Modding API

Anyone knows why my mod items can't drop from monsters in expert? Everything works in normal but they just won't drop in expert. Here's one of my code in GlobalNPC.cs:

Code:
         if (npc.type == NPCID.GreekSkeleton && !Main.expertMode)
            {
                 if(Main.rand.Next(0, 15) == 0)
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("CaesarSword"));
                }
            }

!Main.expertMode

!=NOT
so this turns it into this
not Main.expertMode
[doublepost=1461783268,1461783179][/doublepost]i dont know how to read terraria's source code how can i do this
 
You did it earlier, you just were comparing the wrong values, did you fix that? Also, you should post your code in every post so I can see what you need to fix. Also, tell me what you expect your code to do.
alight. here is my code:
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Enderuim.Items.Armor
{
    public class EnderuimChest : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Body);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Enderuim Chestplate";
            item.width = 22;
            item.height = 24;
            item.rare = 2;
            item.defense = 38;
        }
public override bool IsArmorSet(Item head, Item body, Item legs)
{
    return body.type == mod.ItemType("EnderuimHelm") && legs.type == mod.ItemType("EnderuimLeggings");
}
                public override void UpdateArmorSet(Player player)
        {
            player.setBonus = "Staying still will make you invincable and take no knockback. Melee abilities increased.";
            player.meleeDamage *= 0.3f;
            player.meleeSpeed += 0.3f;
            player.GetModPlayer<EnderuimBubble>(mod).bubbleArmor = true;

        }
                        public override void UpdateEquip(Player player)
        {
            player.meleeDamage += 0.2f;
            player.meleeSpeed += 0.2f;
        }
    }
}
Now, yes, I did do this before, but I had to go to school before fisnishing it.
 
alight. here is my code:
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Enderuim.Items.Armor
{
    public class EnderuimChest : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Body);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Enderuim Chestplate";
            item.width = 22;
            item.height = 24;
            item.rare = 2;
            item.defense = 38;
        }
public override bool IsArmorSet(Item head, Item body, Item legs)
{
    return body.type == mod.ItemType("EnderuimHelm") && legs.type == mod.ItemType("EnderuimLeggings");
}
                public override void UpdateArmorSet(Player player)
        {
            player.setBonus = "Staying still will make you invincable and take no knockback. Melee abilities increased.";
            player.meleeDamage *= 0.3f;
            player.meleeSpeed += 0.3f;
            player.GetModPlayer<EnderuimBubble>(mod).bubbleArmor = true;

        }
                        public override void UpdateEquip(Player player)
        {
            player.meleeDamage += 0.2f;
            player.meleeSpeed += 0.2f;
        }
    }
}
Now, yes, I did do this before, but I had to go to school before fisnishing it.
You are checking body.type against the helmet. I thought you said you fixed that? Change to head
 
Um one issue. I have this varible. But when I check the varible, I dont get affected by knockback, but I still take damage!

if(this.bubbleActive)
{
damage = 0;
player.noKnockback = true; // Will take 0 damage when the player is hurt when the bubble is active.
}
 
o _ o

so, custom reforge slot..... can anyone help me or no?
It'd be really hard. Try going through the vanilla code and seeing how it works and seeing where the hooks are.
does anyone know if it is possible to have one mod sell items from another mod?
yeah
Code:
        public override void SetupShop(Chest shop, ref int nextSlot)
        {
            if (ModLoader.GetLoadedMods().Contains("SummonersAssociation"))
            {
                shop.item[nextSlot].SetDefaults(ModLoader.GetMod("SummonersAssociation").ItemType("BloodTalisman"));
                nextSlot++;
            }
.....
Um one issue. I have this varible. But when I check the varible, I dont get affected by knockback, but I still take damage!

if(this.bubbleActive)
{
damage = 0;
player.noKnockback = true; // Will take 0 damage when the player is hurt when the bubble is active.
}
I need more context, I don't even know what hook this is.
 
It'd be really hard. Try going through the vanilla code and seeing how it works and seeing where the hooks are.

yeah
Code:
        public override void SetupShop(Chest shop, ref int nextSlot)
        {
            if (ModLoader.GetLoadedMods().Contains("SummonersAssociation"))
            {
                shop.item[nextSlot].SetDefaults(ModLoader.GetMod("SummonersAssociation").ItemType("BloodTalisman"));
                nextSlot++;
            }
.....

I need more context, I don't even know what hook this is.
Prehurt
 
Is there any solution to the multiplayer bug?, that one when you hit an ennemy it dissapear:(
:srry for my bad english, i'm spanish native speaker
 
Seems my post had somehow been swallowed....:sigh:

Still having trouble with the item's stuff stuff...
So I spawned some items using NewItem on the position of certain player. But, maybe it's how it should be, the player would grab the item in no delay. Then I found that there is the bool noGrabDelay. I thought it would be the controller of whether an dropping item will have to wait for a while till it can be picked up by players. But whatever it is true or false, the generated item will be picked up instantly...
What's wrong in these steps? Maybe the method itself is OK, my fault. But, it doesn't work for me... Is there any way I can let an item created by NewItem have the Delay before it can be picked up, just like those items dropping from the mobs.

And codes here (if needed)
Code:
Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("IchorKnifeOnPickup"), item.stack, false, 0, false, false);
 
So, I know this is a super noob question, but I am a super noob, so it fits. :p
When I'm building my mod I get this error:
Items\Weapons\RainBow.cs(26,13) : error CS0118: 'Terraria.ModLoader.ModItem.item' is a 'property' but is used like a 'type'
My code being:
Code:
using Terraria;
using System;
using Terraria.ID;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Terraria.ModLoader;

namespace XMod.Items.Weapons
{

    public class RainBow : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Rain Bow";
            item.damage = 47;
            item.noMelee = true;
            item.ranged = true;
            item.width = 24;
            item.height = 52;
            item.toolTip = "Transforms Wooden Arrows into Frostburn Arrows";
            item.useTime = 30;
            item.useAnimation = 30;
            item.useStyle = 5;
            item.shoot = 3;
            item useAmmo = 1;
            item.knockBack = 1;
            item.value = 100000;
            item.rare = 8;
            item.useSound = 5;
            item.autoReuse = true;
            item.shootSpeed = 10f;

        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.FrostburnArrow, damage, knockBack, player.whoAmI, 0f, 0f);
            return false;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Line 26 is item.useAmmo = 1;

I've probably just misstyped something or forgotten something important, but any help would be appreciated.
 
So, I know this is a super noob question, but I am a super noob, so it fits. :p
When I'm building my mod I get this error:
Items\Weapons\RainBow.cs(26,13) : error CS0118: 'Terraria.ModLoader.ModItem.item' is a 'property' but is used like a 'type'
My code being:
Code:
using Terraria;
using System;
using Terraria.ID;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Terraria.ModLoader;

namespace XMod.Items.Weapons
{

    public class RainBow : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Rain Bow";
            item.damage = 47;
            item.noMelee = true;
            item.ranged = true;
            item.width = 24;
            item.height = 52;
            item.toolTip = "Transforms Wooden Arrows into Frostburn Arrows";
            item.useTime = 30;
            item.useAnimation = 30;
            item.useStyle = 5;
            item.shoot = 3;
            item useAmmo = 1;
            item.knockBack = 1;
            item.value = 100000;
            item.rare = 8;
            item.useSound = 5;
            item.autoReuse = true;
            item.shootSpeed = 10f;

        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.FrostburnArrow, damage, knockBack, player.whoAmI, 0f, 0f);
            return false;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Line 26 is item.useAmmo = 1;

I've probably just misstyped something or forgotten something important, but any help would be appreciated.
Your code says item useAmmo = 1; not item.useAmmo = 1;....is that a typo?
 
Back
Top Bottom