tModLoader Official tModLoader Help Thread

You have probably added some unnecessary tokens. You should really let us see the script where the error occurs, so the contents your 'WindofSpeedWings.cs' file.

here is my wings notepad idk what to do please help me senpi

using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace JustMeWingofenddnessFlightMod.Items {
public class Wind of Speed Wings : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}

public override void SetDefaults()
{
item.name = "Wind of Speed Wings";
item.width = 22;
item.height = 20;
item.toolTip = "Just wings.";
item.value = 10000;
item.rare = 2;
item.accessory = true;
}

//these wings use the same values as the solar wings

public override void UpdateAccessory(Player player)
{
player.wingTimeMax = 9999;
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 10f;
acceleration *= 2.5f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 5);
recipe.AddTile(null, "TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
}
}}
[DOUBLEPOST=1444778223,1444778197][/DOUBLEPOST]
i dont get it
i post it
[DOUBLEPOST=1444778316][/DOUBLEPOST]
i dont get it
i post it
 
WindofSpeedWings
here is my wings notepad idk what to do please help me senpi

using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace JustMeWingofenddnessFlightMod.Items {
public class Wind of Speed Wings : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}

public override void SetDefaults()
{
item.name = "Wind of Speed Wings";
item.width = 22;
item.height = 20;
item.toolTip = "Just wings.";
item.value = 10000;
item.rare = 2;
item.accessory = true;
}

//these wings use the same values as the solar wings

public override void UpdateAccessory(Player player)
{
player.wingTimeMax = 9999;
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 10f;
acceleration *= 2.5f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 5);
recipe.AddTile(null, "TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
}
}}
[DOUBLEPOST=1444778223,1444778197][/DOUBLEPOST]
i post it
This is a really easy fix:
You see the line that says 'public class Wind of Speed Wings : ModItem'? The part between 'public class' and ': ModItem' is what we call a class name. You are not allowed to have spaces in your class names, so just remocing those will do the trick. Just make it 'public class WindofSpeedWings : ModItem'.
 
here is my wings notepad idk what to do please help me senpi

using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace JustMeWingofenddnessFlightMod.Items {
public class Wind of Speed Wings : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}

public override void SetDefaults()
{
item.name = "Wind of Speed Wings";
item.width = 22;
item.height = 20;
item.toolTip = "Just wings.";
item.value = 10000;
item.rare = 2;
item.accessory = true;
}

//these wings use the same values as the solar wings

public override void UpdateAccessory(Player player)
{
player.wingTimeMax = 9999;
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 10f;
acceleration *= 2.5f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 5);
recipe.AddTile(null, "TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
}
}}
[DOUBLEPOST=1444778223,1444778197][/DOUBLEPOST]
i post it
[DOUBLEPOST=1444778316][/DOUBLEPOST]
i post it
so what do i do can you fix it for me please
[DOUBLEPOST=1444778554][/DOUBLEPOST]
here is my wings notepad idk what to do please help me senpi

using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace JustMeWingofenddnessFlightMod.Items {
public class Wind of Speed Wings : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}

public override void SetDefaults()
{
item.name = "Wind of Speed Wings";
item.width = 22;
item.height = 20;
item.toolTip = "Just wings.";
item.value = 10000;
item.rare = 2;
item.accessory = true;
}

//these wings use the same values as the solar wings

public override void UpdateAccessory(Player player)
{
player.wingTimeMax = 9999;
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 10f;
acceleration *= 2.5f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 5);
recipe.AddTile(null, "TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
}
}}
[DOUBLEPOST=1444778223,1444778197][/DOUBLEPOST]
i post it
[DOUBLEPOST=1444778316][/DOUBLEPOST]
i post it
i think i got it
 
so what do i do can you fix it for me please
I just told you what you should do, just change the class name ;)
Anyway, here is the code that should work:
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

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

public override void SetDefaults()
{
item.name = "Wind of Speed Wings";
item.width = 22;
item.height = 20;
item.toolTip = "Just wings.";
item.value = 10000;
item.rare = 2;
item.accessory = true;
}

//these wings use the same values as the solar wings

public override void UpdateAccessory(Player player)
{
player.wingTimeMax = 9999;
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 10f;
acceleration *= 2.5f;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 5);
recipe.AddTile(null, "TileID.WorkBenches");
recipe.SetResult(this);
recipe.AddRecipe();
}
}}
[/code
 
so what do i do can you fix it for me please
[DOUBLEPOST=1444778554][/DOUBLEPOST]
i think i got it
help me please on this
 

Attachments

  • Untitled.png
    Untitled.png
    129.2 KB · Views: 511
yes here
[DOUBLEPOST=1444781358,1444781295][/DOUBLEPOST]here
 

Attachments

  • WindofSpeedWings_Wings.png
    WindofSpeedWings_Wings.png
    2.5 KB · Views: 380
yes here
[DOUBLEPOST=1444781358,1444781295][/DOUBLEPOST]here

Allright, major error there. Your whole image (exept the wings of course) was white, where it should have been transparent. For future reference: anything in an image that you don't want on screen should be transparent! I fixed it for you in this case, though. Here's the image.
 

Attachments

  • WindofSpeedWings_Wings.png
    WindofSpeedWings_Wings.png
    2 KB · Views: 368
how do i download it or drag it too the screen
Open the file in your explorer (may it be Chrome, Firefox or whatever) then right-click the image and select 'Save Image As..." where you can save it as a .png file.

Also, please do try to refrain from double posting. Use the 'Edit' button at the lower right of an earlier post to make adjustments ;)
 
how do i download it or drag it too the screen
[DOUBLEPOST=1444782245][/DOUBLEPOST]
and your like my senpi
Dont you have a mod or do want to be in my mod i really want you because your like a master mind
[DOUBLEPOST=1444782563,1444782504][/DOUBLEPOST]
Open the file in your explorer (may it be Chrome, Firefox or whatever) then right-click the image and select 'Save Image As..." where you can save it as a .png file.

Also, please do try to refrain from double posting. Use the 'Edit' button at the lower right of an earlier post to make adjustments ;)
but can you teach me how to make stuff see through
 
Dont you have a mod or do want to be in my mod i really want you because your like a master mind
The mistakes you're making are really stupid imo... lol Nothing to do with 'mastermind'
If you don't even know how to save an image.. please..
 
Thx any way
It's true that a lot of these questions are about the basics of the basics regarding modding (or even image creating).
I'd really suggest looking up some info on the topic. Just look for some tutorials that suit your needs.
 
I'm not sure whether this is an appropriate place to ask this (or if such a place exists, really) but I've been having some trouble figuring out how to path to an image file.

My Project is called "StupidSwords". and is in the file structure "Terraria/ModLoader/Mod Sources/StupidSwords". Within this, I have an Items folder, containing TwigSword.cs and twigSword.png. In my StupidSwords.cs file (the main file for the mod, if my understanding is correct) I override Load() with the following:
Code:
AddItem("twigSword", new TwigSword(), "StupidSwords/Items/twigSword");

The ExampleMod never calls AddItem, as far as I can tell, but the docs say that the path format here should be the same as in ModLoader.GetTexture, for which the example calls "ExampleMod/Tiles/AnimatedLoom". ExampleMod(folder), like StupidSwords(folder), holds the Project file for the mod in question, so as far as I can tell the two are functionally equivalent.

Attempting to build and reload in the client results in the following error:
Code:
Missing texture StupidSwords/Items/TwigSword
  at Terraria.ModLoader.ModLoader.GetTexture(String name)
  at Terraria.ModLoader.Mod.SetupContent()
  at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

What file path should I be using to reference the image? The Items subfolder contains the twigSword.png file.


EDIT: Looking back at the start of this thread, it's implied that the filename itself should be left out of the path, but doing so (passing "StupidSwords/Items") results in the same error.

EDIT 2: Resolved by disabling Autoload in SetModInfo(). However, the game now seems to not close properly; Steam thinks I still have it running over a minute later, but neither Terraria.exe or gameoverlayui is visible in task manager.
Sub-edit: It was just being slow, apparently. Long unload time.
 
Last edited:
Hello guys, I need your help with these:

1.How to make a block inflict debuffs when touched?
2. How to make a block similar to a placed Iron bar?
3.How to make a block act like sand, silt, or slush blocks?
4.How to make trees or grasses?
5.How to make homing projectiles? (Either targeting a player or an NPC)
6.How to put cooldowns when using, let's say sword shooting a beam every 2 seconds?
7.How to make a weapon shoot multiple projectiles?
8.How to make Spears and boomerangs?
9.How to make worm type npcs?
10.How make something, let's say a projectile face it's direction? (Rotation, An Arrow facing it's target)

I have a bunch of questions, but for now this..... You can answer them anytime but I hope you can help me. But yeah, please do respond and don't leave me hanging.. Thanks in advance! :)
 
Hello guys, I need your help with these:

1.How to make a block inflict debuffs when touched?
2. How to make a block similar to a placed Iron bar?
3.How to make a block act like sand, silt, or slush blocks?
4.How to make trees or grasses?
5.How to make homing projectiles? (Either targeting a player or an NPC)
6.How to put cooldowns when using, let's say sword shooting a beam every 2 seconds?
7.How to make a weapon shoot multiple projectiles?
8.How to make Spears and boomerangs?
9.How to make worm type npcs?
10.How make something, let's say a projectile face it's direction? (Rotation, An Arrow facing it's target)

I have a bunch of questions, but for now this..... You can answer them anytime but I hope you can help me. But yeah, please do respond and don't leave me hanging.. Thanks in advance! :)
Allright, I'll try to answer the questions I'm sure I've got an answer for. When there's a '-' behind your question number, then I'm not quite sure if I can answer your question correctly, so I'm leaving that out. Here we go!

1.
- (good start)
2.
I think that creating a regular tile would just be OK (?). I've seen something like this on the tModLoader thread, though, so I'll look it up for you!
3.
This might actually be tougher that you'd think. You need a lot of code for this one, but I'll try to fit in in here...
This is the code for the ball projectile. This is basically a projectile that spawns upon destroying your 'sand' block, so that it can fall down, etc.
Code:
public override void SetDefaults()
{
    projectile.name = "Ball";
    projectile.width = 10;
    projectile.height = 10;
    projectile.knockBack = 6;
    projectile.penetrate = -1;
    projectile.friendly = true;
    projectile.hostile = true;
    projectile.tileCollide = false;
}

public override void AI()
{
    if (Main.rand.Next(2) == 0)
    {
        int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 17, 0f, 0f, 0, default(Color), 1f);
        Main.dust[dust].velocity.X *= 0.4f;
    }
    if (projectile.ai[0] == 1f)
    {
        if (!projectile.hostile)
        {
            projectile.ai[1] += 1f;
            if (projectile.ai[1] >= 60f)
            {
                projectile.ai[1] = 60f;
                projectile.velocity.Y += 0.2f;
            }
        }
        else
        {
            projectile.velocity.Y += 0.41f;
        }
    }
    else if (projectile.ai[0] == 2f)
    {
        projectile.velocity.Y += 0.2f;
        if (projectile.velocity.X < -0.04f)
        {
            projectile.velocity.X += 0.04f;
        }
        else if (projectile.velocity.X > 0.04f)
        {
            projectile.velocity.X -= 0.04f;
        }
        else
        {
            projectile.velocity.X = 0f;
        }
    }
    projectile.rotation += 0.1f;
    if (projectile.velocity.Y > 10f)
    {
        projectile.velocity.Y = 10f;
    }
}

public override void PostAI()
{
    Vector2 oldVelocity = projectile.velocity;
    if (projectile.hostile)
    {
        projectile.velocity = Collision.AnyCollision(projectile.position, projectile.velocity, projectile.width, projectile.height);
    }
    else
    {
        projectile.velocity = Collision.TileCollision(projectile.position, projectile.velocity, projectile.width, projectile.height, true, true, 1);
        }
        if (projectile.velocity != oldVelocity)
        {
            projectile.position += projectile.velocity;
            projectile.Kill();
        }
    }

    public override void Kill(int timeLeft)
    {
        if (projectile.owner == Main.myPlayer && !projectile.noDropItem)
        {
            int tileX = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16;
            int tileY = (int)(projectile.position.Y + (float)(projectile.width / 2)) / 16;
            int tileType = mod.TileType("YourSandTile");
            if (Main.tile[tileX, tileY].halfBrick() && projectile.velocity.Y > 0f && System.Math.Abs(projectile.velocity.Y) > System.Math.Abs(projectile.velocity.X))
            {
                tileY--;
            }
            if (!Main.tile[tileX, tileY].active())
            {
                bool flag = WorldGen.PlaceTile(tileX, tileY, tileType, false, true, -1, 0);
                if (flag)
                {
                    if (Main.tile[tileX, tileY + 1].halfBrick() || Main.tile[tileX, tileY + 1].slope() != 0)
                    {
                        WorldGen.SlopeTile(tileX, tileY + 1, 0);
                        if (Main.netMode == 2)
                        {
                            NetMessage.SendData(17, -1, -1, "", 14, (float)tileX, (float)(tileY + 1), 0f, 0);
                        }
                    }
                    if (Main.netMode != 0)
                    {
                        NetMessage.SendData(17, -1, -1, "", 1, (float)tileX, (float)tileY, (float)tileType, 0);
                    }
                }
            }
    }
}
This is the code for your 'sand' tile.
Code:
public override void SetDefaults()
{
    Main.tileSolid[Type] = true;
    Main.tileMergeDirt[Type] = true;
    Main.tileBlockLight[Type] = true;
    Main.tileSand[Type] = true;
    Main.tileLighted[Type] = true;

    drop = mod.ItemType("YourSandItem");
}

public override bool TileFrame(int x, int y, ref bool resetFrame, ref bool noBreak)
{
    if (WorldGen.noTileActions)
    {
        return false;
    }
    Tile above = Main.tile[x, y - 1];
    Tile below = Main.tile[x, y + 1];

    if (below != null && !below.active() && (!above.active() || !(above.type == 21 || above.type == 323)))
    {
        Main.tile[x, y].active(false);
        if (Main.netMode == 0)
        {
            int proj = Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, mod.ProjectileType("Ball"), 10, 0f, Main.myPlayer, 1f, 0f);
            WorldGen.SquareTileFrame(x, y, true);
        }
        else if (Main.netMode == 2)
        {
            int proj = Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 2.5f, mod.ProjectileType("Ball"), 10, 0f, Main.myPlayer, 1f, 0f);
            Main.projectile[proj].velocity.Y = 0.5f;
            Main.projectile[proj].position.Y += 2f; ;
            Main.projectile[proj].netUpdate = true;
            NetMessage.SendTileSquare(-1, x, y, 1);
            WorldGen.SquareTileFrame(x, y, true);
         }
         return true;
    }
    return true;
}

4.
This is already possible, but it wouldn't really have much effect. This is because World Hooks have not been implemented yet, so I don't think you can actually make the trees and grass spawn...

5.
You're asking for some stuff that requires quite the code and I'm running out of space... When you're making a bullet that follows an enemy NPC, just loop through the Main.npc array if the projectile doesn't have a target yet. In the loop you need to define the maximum allowed rotation for this bullet (so that it doesn't follow an NPC that's standing right behind the player when shooting) and check that against the direction from the bullet towards the NPC in question. If that's all OK, just set the index of the NPC as your target and make the projectile rotate towards that NPCs position in world space. If you know a bit of programming, this should be no probs ;)

6.
This is also quite easy (although my solution might not actually be the best one. Define an integer variable, give that a value of 120 (2 seconds), update that value every tick and check that value against 0... Here's some code:
Code:
int shootCooldown = 120;

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)
{

    if (shootCooldown <= 0)
    {
                shootCooldown = 120;
                return true;
    }
    return false;
}
public override void UpdateInventory(Player player)
{
    shootCooldown--;
}

7.
Really easy one once again. Just override the Shoot function (like in my answer to the question before this one) and just spawn multiple projectiles using the 'Projectile.NewProjectile' function.

8 & 9.
I'm not going to answer these for you, although I could ( :p ). I'd advice you to take a look at Terraria's source for this. Believe me, it will help you a lot! If you don't know how: Download a program called 'IlSpy', drag and drop your Terraria.exe file in and you can just take a stroll through the source.

10.
Uhm... Just take the projectiles velocity, normalize it, get a direction out of it, convert to radians and apply to projectile.rotation...

Pffffft finally done!! >< Hope this (at least some of it) helps!
 
Allright, I'll try to answer the questions I'm sure I've got an answer for. When there's a '-' behind your question number, then I'm not quite sure if I can answer your question correctly, so I'm leaving that out. Here we go!

1.
- (good start)
2.
I think that creating a regular tile would just be OK (?). I've seen something like this on the tModLoader thread, though, so I'll look it up for you!
3.
This might actually be tougher that you'd think. You need a lot of code for this one, but I'll try to fit in in here...
This is the code for the ball projectile. This is basically a projectile that spawns upon destroying your 'sand' block, so that it can fall down, etc.
Code:
public override void SetDefaults()
{
    projectile.name = "Ball";
    projectile.width = 10;
    projectile.height = 10;
    projectile.knockBack = 6;
    projectile.penetrate = -1;
    projectile.friendly = true;
    projectile.hostile = true;
    projectile.tileCollide = false;
}

public override void AI()
{
    if (Main.rand.Next(2) == 0)
    {
        int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 17, 0f, 0f, 0, default(Color), 1f);
        Main.dust[dust].velocity.X *= 0.4f;
    }
    if (projectile.ai[0] == 1f)
    {
        if (!projectile.hostile)
        {
            projectile.ai[1] += 1f;
            if (projectile.ai[1] >= 60f)
            {
                projectile.ai[1] = 60f;
                projectile.velocity.Y += 0.2f;
            }
        }
        else
        {
            projectile.velocity.Y += 0.41f;
        }
    }
    else if (projectile.ai[0] == 2f)
    {
        projectile.velocity.Y += 0.2f;
        if (projectile.velocity.X < -0.04f)
        {
            projectile.velocity.X += 0.04f;
        }
        else if (projectile.velocity.X > 0.04f)
        {
            projectile.velocity.X -= 0.04f;
        }
        else
        {
            projectile.velocity.X = 0f;
        }
    }
    projectile.rotation += 0.1f;
    if (projectile.velocity.Y > 10f)
    {
        projectile.velocity.Y = 10f;
    }
}

public override void PostAI()
{
    Vector2 oldVelocity = projectile.velocity;
    if (projectile.hostile)
    {
        projectile.velocity = Collision.AnyCollision(projectile.position, projectile.velocity, projectile.width, projectile.height);
    }
    else
    {
        projectile.velocity = Collision.TileCollision(projectile.position, projectile.velocity, projectile.width, projectile.height, true, true, 1);
        }
        if (projectile.velocity != oldVelocity)
        {
            projectile.position += projectile.velocity;
            projectile.Kill();
        }
    }

    public override void Kill(int timeLeft)
    {
        if (projectile.owner == Main.myPlayer && !projectile.noDropItem)
        {
            int tileX = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16;
            int tileY = (int)(projectile.position.Y + (float)(projectile.width / 2)) / 16;
            int tileType = mod.TileType("YourSandTile");
            if (Main.tile[tileX, tileY].halfBrick() && projectile.velocity.Y > 0f && System.Math.Abs(projectile.velocity.Y) > System.Math.Abs(projectile.velocity.X))
            {
                tileY--;
            }
            if (!Main.tile[tileX, tileY].active())
            {
                bool flag = WorldGen.PlaceTile(tileX, tileY, tileType, false, true, -1, 0);
                if (flag)
                {
                    if (Main.tile[tileX, tileY + 1].halfBrick() || Main.tile[tileX, tileY + 1].slope() != 0)
                    {
                        WorldGen.SlopeTile(tileX, tileY + 1, 0);
                        if (Main.netMode == 2)
                        {
                            NetMessage.SendData(17, -1, -1, "", 14, (float)tileX, (float)(tileY + 1), 0f, 0);
                        }
                    }
                    if (Main.netMode != 0)
                    {
                        NetMessage.SendData(17, -1, -1, "", 1, (float)tileX, (float)tileY, (float)tileType, 0);
                    }
                }
            }
    }
}
This is the code for your 'sand' tile.
Code:
public override void SetDefaults()
{
    Main.tileSolid[Type] = true;
    Main.tileMergeDirt[Type] = true;
    Main.tileBlockLight[Type] = true;
    Main.tileSand[Type] = true;
    Main.tileLighted[Type] = true;

    drop = mod.ItemType("YourSandItem");
}

public override bool TileFrame(int x, int y, ref bool resetFrame, ref bool noBreak)
{
    if (WorldGen.noTileActions)
    {
        return false;
    }
    Tile above = Main.tile[x, y - 1];
    Tile below = Main.tile[x, y + 1];

    if (below != null && !below.active() && (!above.active() || !(above.type == 21 || above.type == 323)))
    {
        Main.tile[x, y].active(false);
        if (Main.netMode == 0)
        {
            int proj = Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, mod.ProjectileType("Ball"), 10, 0f, Main.myPlayer, 1f, 0f);
            WorldGen.SquareTileFrame(x, y, true);
        }
        else if (Main.netMode == 2)
        {
            int proj = Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 2.5f, mod.ProjectileType("Ball"), 10, 0f, Main.myPlayer, 1f, 0f);
            Main.projectile[proj].velocity.Y = 0.5f;
            Main.projectile[proj].position.Y += 2f; ;
            Main.projectile[proj].netUpdate = true;
            NetMessage.SendTileSquare(-1, x, y, 1);
            WorldGen.SquareTileFrame(x, y, true);
         }
         return true;
    }
    return true;
}

4.
This is already possible, but it wouldn't really have much effect. This is because World Hooks have not been implemented yet, so I don't think you can actually make the trees and grass spawn...

5.
You're asking for some stuff that requires quite the code and I'm running out of space... When you're making a bullet that follows an enemy NPC, just loop through the Main.npc array if the projectile doesn't have a target yet. In the loop you need to define the maximum allowed rotation for this bullet (so that it doesn't follow an NPC that's standing right behind the player when shooting) and check that against the direction from the bullet towards the NPC in question. If that's all OK, just set the index of the NPC as your target and make the projectile rotate towards that NPCs position in world space. If you know a bit of programming, this should be no probs ;)

6.
This is also quite easy (although my solution might not actually be the best one. Define an integer variable, give that a value of 120 (2 seconds), update that value every tick and check that value against 0... Here's some code:
Code:
int shootCooldown = 120;

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)
{

    if (shootCooldown <= 0)
    {
                shootCooldown = 120;
                return true;
    }
    return false;
}
public override void UpdateInventory(Player player)
{
    shootCooldown--;
}

7.
Really easy one once again. Just override the Shoot function (like in my answer to the question before this one) and just spawn multiple projectiles using the 'Projectile.NewProjectile' function.

8 & 9.
I'm not going to answer these for you, although I could ( :p ). I'd advice you to take a look at Terraria's source for this. Believe me, it will help you a lot! If you don't know how: Download a program called 'IlSpy', drag and drop your Terraria.exe file in and you can just take a stroll through the source.

10.
Uhm... Just take the projectiles velocity, normalize it, get a direction out of it, convert to radians and apply to projectile.rotation...

Pffffft finally done!! >< Hope this (at least some of it) helps!
Hehe of course the code surely did help, about 2 and 4, I asked because I wanted my block to act as of a tree, if first block is removed, so as everything on top of it. :p
5 I was just assuming if anyone can tell me the projectile AI of it, I remember using it before (the Bee, Bat, Flairon Bubbles, etc AIs).
6-7 I know this already however it this error shows "No Suitable Method found to override"... I have done it to tapi before but won't work on tML now... Can you tell me why please? ;(
8-9 Aww... Men... Do I really need to do the thing Red does not want people to do? I mean.. You know why not tell? XP
10 err I don't really get things much, unless it's coded.. Or oh well i'll just go check the tAPI template. :)P

Either ways, I am very glad you responded. Thank you very much! :)

Just in case if you know how, can you tell me how to animate a tile consisting of 15 frames with 4 tiles (16 x16) per frame (chest like) ? Because I'm kinda having a hard time doing so... :(
 
Allright, I'll try to answer the questions I'm sure I've got an answer for. When there's a '-' behind your question number, then I'm not quite sure if I can answer your question correctly, so I'm leaving that out. Here we go!

1.
- (good start)
2.
I think that creating a regular tile would just be OK (?). I've seen something like this on the tModLoader thread, though, so I'll look it up for you!
3.
This might actually be tougher that you'd think. You need a lot of code for this one, but I'll try to fit in in here...
This is the code for the ball projectile. This is basically a projectile that spawns upon destroying your 'sand' block, so that it can fall down, etc.
Code:
public override void SetDefaults()
{
    projectile.name = "Ball";
    projectile.width = 10;
    projectile.height = 10;
    projectile.knockBack = 6;
    projectile.penetrate = -1;
    projectile.friendly = true;
    projectile.hostile = true;
    projectile.tileCollide = false;
}

public override void AI()
{
    if (Main.rand.Next(2) == 0)
    {
        int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 17, 0f, 0f, 0, default(Color), 1f);
        Main.dust[dust].velocity.X *= 0.4f;
    }
    if (projectile.ai[0] == 1f)
    {
        if (!projectile.hostile)
        {
            projectile.ai[1] += 1f;
            if (projectile.ai[1] >= 60f)
            {
                projectile.ai[1] = 60f;
                projectile.velocity.Y += 0.2f;
            }
        }
        else
        {
            projectile.velocity.Y += 0.41f;
        }
    }
    else if (projectile.ai[0] == 2f)
    {
        projectile.velocity.Y += 0.2f;
        if (projectile.velocity.X < -0.04f)
        {
            projectile.velocity.X += 0.04f;
        }
        else if (projectile.velocity.X > 0.04f)
        {
            projectile.velocity.X -= 0.04f;
        }
        else
        {
            projectile.velocity.X = 0f;
        }
    }
    projectile.rotation += 0.1f;
    if (projectile.velocity.Y > 10f)
    {
        projectile.velocity.Y = 10f;
    }
}

public override void PostAI()
{
    Vector2 oldVelocity = projectile.velocity;
    if (projectile.hostile)
    {
        projectile.velocity = Collision.AnyCollision(projectile.position, projectile.velocity, projectile.width, projectile.height);
    }
    else
    {
        projectile.velocity = Collision.TileCollision(projectile.position, projectile.velocity, projectile.width, projectile.height, true, true, 1);
        }
        if (projectile.velocity != oldVelocity)
        {
            projectile.position += projectile.velocity;
            projectile.Kill();
        }
    }

    public override void Kill(int timeLeft)
    {
        if (projectile.owner == Main.myPlayer && !projectile.noDropItem)
        {
            int tileX = (int)(projectile.position.X + (float)(projectile.width / 2)) / 16;
            int tileY = (int)(projectile.position.Y + (float)(projectile.width / 2)) / 16;
            int tileType = mod.TileType("YourSandTile");
            if (Main.tile[tileX, tileY].halfBrick() && projectile.velocity.Y > 0f && System.Math.Abs(projectile.velocity.Y) > System.Math.Abs(projectile.velocity.X))
            {
                tileY--;
            }
            if (!Main.tile[tileX, tileY].active())
            {
                bool flag = WorldGen.PlaceTile(tileX, tileY, tileType, false, true, -1, 0);
                if (flag)
                {
                    if (Main.tile[tileX, tileY + 1].halfBrick() || Main.tile[tileX, tileY + 1].slope() != 0)
                    {
                        WorldGen.SlopeTile(tileX, tileY + 1, 0);
                        if (Main.netMode == 2)
                        {
                            NetMessage.SendData(17, -1, -1, "", 14, (float)tileX, (float)(tileY + 1), 0f, 0);
                        }
                    }
                    if (Main.netMode != 0)
                    {
                        NetMessage.SendData(17, -1, -1, "", 1, (float)tileX, (float)tileY, (float)tileType, 0);
                    }
                }
            }
    }
}
This is the code for your 'sand' tile.
Code:
public override void SetDefaults()
{
    Main.tileSolid[Type] = true;
    Main.tileMergeDirt[Type] = true;
    Main.tileBlockLight[Type] = true;
    Main.tileSand[Type] = true;
    Main.tileLighted[Type] = true;

    drop = mod.ItemType("YourSandItem");
}

public override bool TileFrame(int x, int y, ref bool resetFrame, ref bool noBreak)
{
    if (WorldGen.noTileActions)
    {
        return false;
    }
    Tile above = Main.tile[x, y - 1];
    Tile below = Main.tile[x, y + 1];

    if (below != null && !below.active() && (!above.active() || !(above.type == 21 || above.type == 323)))
    {
        Main.tile[x, y].active(false);
        if (Main.netMode == 0)
        {
            int proj = Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, mod.ProjectileType("Ball"), 10, 0f, Main.myPlayer, 1f, 0f);
            WorldGen.SquareTileFrame(x, y, true);
        }
        else if (Main.netMode == 2)
        {
            int proj = Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 2.5f, mod.ProjectileType("Ball"), 10, 0f, Main.myPlayer, 1f, 0f);
            Main.projectile[proj].velocity.Y = 0.5f;
            Main.projectile[proj].position.Y += 2f; ;
            Main.projectile[proj].netUpdate = true;
            NetMessage.SendTileSquare(-1, x, y, 1);
            WorldGen.SquareTileFrame(x, y, true);
         }
         return true;
    }
    return true;
}

4.
This is already possible, but it wouldn't really have much effect. This is because World Hooks have not been implemented yet, so I don't think you can actually make the trees and grass spawn...

5.
You're asking for some stuff that requires quite the code and I'm running out of space... When you're making a bullet that follows an enemy NPC, just loop through the Main.npc array if the projectile doesn't have a target yet. In the loop you need to define the maximum allowed rotation for this bullet (so that it doesn't follow an NPC that's standing right behind the player when shooting) and check that against the direction from the bullet towards the NPC in question. If that's all OK, just set the index of the NPC as your target and make the projectile rotate towards that NPCs position in world space. If you know a bit of programming, this should be no probs ;)

6.
This is also quite easy (although my solution might not actually be the best one. Define an integer variable, give that a value of 120 (2 seconds), update that value every tick and check that value against 0... Here's some code:
Code:
int shootCooldown = 120;

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)
{

    if (shootCooldown <= 0)
    {
                shootCooldown = 120;
                return true;
    }
    return false;
}
public override void UpdateInventory(Player player)
{
    shootCooldown--;
}

7.
Really easy one once again. Just override the Shoot function (like in my answer to the question before this one) and just spawn multiple projectiles using the 'Projectile.NewProjectile' function.

8 & 9.
I'm not going to answer these for you, although I could ( :p ). I'd advice you to take a look at Terraria's source for this. Believe me, it will help you a lot! If you don't know how: Download a program called 'IlSpy', drag and drop your Terraria.exe file in and you can just take a stroll through the source.

10.
Uhm... Just take the projectiles velocity, normalize it, get a direction out of it, convert to radians and apply to projectile.rotation...

Pffffft finally done!! >< Hope this (at least some of it) helps!
Hehe of course the code surely did help, about 2 and 4, I asked because I wanted my block to act as of a tree, if first block is removed, so as everything on top of it. :p
5 I was just assuming if anyone can tell me the projectile AI of it, I remember using it before (the Bee, Bat, Flairon Bubbles, etc AIs).
6-7 I know this already however it this error shows "No Suitable Method found to override"... I have done it to tapi before but won't work on tML now... Can you tell me why please? ;(
8-9 Aww... Men... Do I really need to do the thing Red does not want people to do? I mean.. You know why not tell? XP
10 err I don't really get things much, unless it's coded.. Or oh well i'll just go check the tAPI template. :)P

Either ways, I am very glad you responded. Thank you very much! :)

Just in case if you know how, can you tell me how to animate a tile consisting of 15 frames with 4 tiles (16 x16) per frame (chest like) ? Because I'm kinda having a hard time doing so... :(
 
Back
Top Bottom