question, how would one accomplish the whole, OnTileCollide place this block? Is it something like, tile.newTile? If so, it would be greatly appreciated if you could post the string to accomplish this
int xPos => X Position in Tile Coordinates
int yPos => Y Position in Tile Coordinates
int tileType => ID of the tile to place
bool mute => If true do not play sound and do not create dust. Default is false
bool forced => If true override current tile. Default is false
int player => The ID of the player placing the tile. Used to determine the players direction when placing a directional tile. Default is -1, no player direction check.
int tileStyle => The style of tile to place. All banners are tile ID 91. The style is what determines which one is created. Default is 0.
WorldGen.PlaceTile(xPos, yPos, tileType, mute, forced, player, tileStyle);
Thanks! just one more question, in the line "int type = myprojectile;" would I have to type something like "projdef.byName["my projectile"] to make it work with my custom projectile?
ProjDef.byName["InternalModName:ProjectileName"].type is what you would use.
most likely, that's what it seems like you would need to do... there may be a different method, however
[DOUBLEPOST=1431388396,1431388263][/DOUBLEPOST]
or even better, as I'm not sure that ProjDef.byname could be converted to an integer, you may just want to go into the line
Code:
Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
and replace the type, with ProjDef.byname["myprojectile'sname"].type
byName is a IDictionary<string, Projectile>. You provide a string, and a projectile is returned. Adding '.type' to the end would indeed return the projectiles type.
I found some code for that awhile ago on either the Tapi page or another modding help page, however it was for turning liquids into a tile when the projectile hit it, I edited it a bit, so it should work but I haven't tested it with this method of giving gravity to blocks, but here it is anyway
Code:
public override void PostKill()
{
int x = (int)(projectile.Center.X / 16f);
int y = (int)(projectile.Center.Y/ 16f);
Main.tile[x, y].type = TileDef.byName["Ardium:ScarredSand"];
Main.tile[x, y].active(true);
if (Main.netMode == 2)
{
NetMessage.SendTileSquare(-1, x, y, 1);
}
else
{
WorldGen.SquareTileFrame(x, y, true);
I give full credit to bluemagic for this code.
I would use this when transforming one active tile into another, and WorldGen.PlaceTile when placing a tile into an empty spot. I use something similar to the code you showed to transform a Closed Hatch tile into an Open Hatch tile and back, but use PlaceTile when first placing the tile.
Well, I may be stupid, or lazy, but is there just a way to make the projectile die when it meets your cursor? Or, if you don't know that, is there a way to make it so you can place a tile in midair?
Main.mouseWorld returns the mouses position in the world as a Vector2. You can compare that to the projectiles position.