A_judgementalLizard
Terrarian
If you are reading this thread, you likely know how to create at least a basic item/weapon, if that's the case: Good! you can move right on to the next section.
However you may be completely new to modding in general in which case I wouldn't recommend starting with this.
Instead read this Tutorial first,
http://forums.terraria.org/index.php?threads/getting-started-with-modding.7832/
it covers a lot of basics in modding and will help you get started.
Now onto the real tutorial.
I hope this was helpful to you, and, if not please tell me why!
(for more projectile special effects and code visit this tutorial by Sin Costan
http://forums.terraria.org/index.php?threads/tutorial-projectile-guide-and-implementation.13048/ )
Currently there is a small bug with this code that changes the blue moon's chain texture into your modded one, I am trying to work this out, however if I remove the line of code that causes the problem, it will change your modded flail into the blue moon's chain texture
Great thanks to Everybody for helping me figure out how to do this
However you may be completely new to modding in general in which case I wouldn't recommend starting with this.
Instead read this Tutorial first,
http://forums.terraria.org/index.php?threads/getting-started-with-modding.7832/
it covers a lot of basics in modding and will help you get started.
Now onto the real tutorial.
In this tutorial you will learn how to make a basic flail type weapon edit its stats.
It will be divided into three parts telling you how to make the chain of the flail, the actual flail, and the item
It will be divided into three parts telling you how to make the chain of the flail, the actual flail, and the item
Creating the chain
In your mod folder, create another folder called Gores
inside this folder create a .png called ExampleChain
For now you can just use this one
(provided by Zoomo)
Great! you're done with step one.
In your mod folder, create another folder called Gores
inside this folder create a .png called ExampleChain
For now you can just use this one
Great! you're done with step one.
Creating the item
Step 1:
In your mod folder create another folder called Items
in that folder make a new Item json called ExampleFlail
inside that file use this code
After you've done that you will need an image for you flail item
for now just use this
(Provided by Zoomo).
Finally you need your item CS file which will look something like this
And that's it for your item.
Step 1:
In your mod folder create another folder called Items
in that folder make a new Item json called ExampleFlail
inside that file use this code
Code:
{
"code": "ExampleFlail",
"displayName": "Example Flail",
"size": [30,36],
"maxStack": 1,
"value": [0,0,0,0],
"rare": 0,
"pretendType": 163,
"useStyle": 5,
"useAnimation": 45,
"useTime": 30,
"damage": 30,
"knockback": 8,
"useSound": 1,
"noMelee": true,
"melee": true,
"shoot": "YourModNameHere:ExampleBall",
"shootSpeed": 18,
"noUseGraphic": true,
"channel": true,
"recipes":
[{
"items": { "Dirt Block": 1 },
"tiles": [ "Work Bench" ],
"creates": 1
}]
}
for now just use this
Finally you need your item CS file which will look something like this
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using TAPI;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace YourModNameHere
{
public class ExampleFlail : ModItem
{
public override void HoldStyle(Player P)
{
Main.chain3Texture = Main.goreTexture[GoreDef.gores["YourModNameHere:ExampleChain"]];
}
}
}
The Flail Projectile
Yet again in your mod folder create a new folder called Projectiles
inside that folder you will make three files.
Number one will be the .png file, which will be you flail head(the actual mace part)
just use this sprite for now
(also provided by Zoomo)
then lets move onto your projectiles json code
And now your .json is finished
moving on to the .cs of your projectile
you can put extra code in here for your projectile to have extra special effects(more on that later)
And now you should have a working flail!, which you can edit and use to your hearts content.
Yet again in your mod folder create a new folder called Projectiles
inside that folder you will make three files.
Number one will be the .png file, which will be you flail head(the actual mace part)
just use this sprite for now
then lets move onto your projectiles json code
Code:
{
"displayName": "Example Ball",
"size": [30, 30], //size in this projectile means the hitbox, so it can be as big or small as you want.
"aiStyle": 15,
"friendly": true,
"hostile": false,
"tileCollide": true,
"damage": 30,
"melee": true,
"penetrate": 40
}
moving on to the .cs of your projectile
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using TAPI;
using Terraria;
namespace YourModNameHere.Projectiles
{
public class ExampleBall : ModProjectile
{
}
}
First download this image and put it in your gore folder with the other chain texture
Then in your mod folder create a file to modify your player class, it should look something like this
and now whenever you switch to the bluemoon it will change its texture.
Then in your mod folder create a file to modify your player class, it should look something like this
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using TAPI;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Mod
{
public class MPlayer : TAPI.ModPlayer
{
public override void PreUpdate()
{
int held_item = player.inventory[player.selectedItem].type;
if (held_item == 163)
{
Main.chain3Texture = Main.goreTexture[GoreDef.gores["Mod:Chain4"]]; //don't change any of this code
}
}
}
}
(for more projectile special effects and code visit this tutorial by Sin Costan
http://forums.terraria.org/index.php?threads/tutorial-projectile-guide-and-implementation.13048/ )
Currently there is a small bug with this code that changes the blue moon's chain texture into your modded one, I am trying to work this out, however if I remove the line of code that causes the problem, it will change your modded flail into the blue moon's chain texture
Great thanks to Everybody for helping me figure out how to do this
Last edited:
A_judgementalLizard
Terrarian
Jupa
Terrarian
Thank you very much for the flail tutorial, it's extremely helpful, but i noticed a bit of a bug. Since you are replacing the chain texture, that means by holding the " example flail " and then switching over to a blue moon, the blue moon chain texture will be changed to the one you're using for your custom flail. Is there anyway to fix this?
A_judgementalLizard
Terrarian
I'll check it out, is it permanent? or does blue moon revert back to normal at some point?Thank you very much for the flail tutorial, it's extremely helpful, but i noticed a bit of a bug. Since you are replacing the chain texture, that means by holding the " example flail " and then switching over to a blue moon, the blue moon chain texture will be changed to the one you're using for your custom flail. Is there anyway to fix this?
I'll try and fix it now.
Jupa
Terrarian
I'll check it out, is it permanent? or does blue moon revert back to normal at some point?
I'll try and fix it now.
From what i know, it will only revert if you reload the world. How Ironic, i was so sick of seeing the flails having the blue moon chains and didn't know how to fix it, and now the opposite problem appears! Oh well, i'm sure you could find some way to check if the player is no longer holding the item, and then change the texture back to normal.
A_judgementalLizard
Terrarian
It's strange, it permanently changes the texture for me, looking for a way to fix it now.From what i know, it will only revert if you reload the world. How Ironic, i was so sick of seeing the flails having the blue moon chains and didn't know how to fix it, and now the opposite problem appears! Oh well, i'm sure you could find some way to check if the player is no longer holding the item, and then change the texture back to normal.
Jupa
Terrarian
It's strange, it permanently changes the texture for me, looking for a way to fix it now.
Reload your world and use ONLY the blue flail, i have a felling you did what i did that confused me originally, and had the test flail in my hot bar. Simply scrolling over it will change the texture. Either way, should probably get it fixed
A_judgementalLizard
Terrarian
The cs item file is there so that the chain texture doesn't become blue moon at all times, unfortunately this also overrides blue moon's chain texture, also I can't seem to change the code without the modded chain becoming blue moon again. I will continue working on this problem though, thanks for bringing it to my attention.Reload your world and use ONLY the blue flail, i have a felling you did what i did that confused me originally, and had the test flail in my hot bar. Simply scrolling over it will change the texture. Either way, should probably get it fixed
Sin Costan
Eye of Cthulhu
The simplest solution is probably to get the vanilla chain textures, label them as your own under gore, and then when you need to switch them back, you just set the chain texture back to the original chain that you c&p using the PostKill() method for your projectile. Never tested this, but logically it should work.The cs item file is there so that the chain texture doesn't become blue moon at all times, unfortunately this also overrides blue moon's chain texture, also I can't seem to change the code without the modded chain becoming blue moon again. I will continue working on this problem though, thanks for bringing it to my attention.
A_judgementalLizard
Terrarian
so something like this? Just asking so I can put this in the tutorial.The simplest solution is probably to get the vanilla chain textures, label them as your own under gore, and then when you need to switch them back, you just set the chain texture back to the original chain that you c&p using the PostKill() method for your projectile. Never tested this, but logically it should work.
Code:
namespace Mod.Projectiles
{
public class ExampleBall : ModProjectile
{
public override void PostKill()
{
Main.chain3Texture = Main.goreTexture[GoreDef.gores["Mod:Chain4"]];
}
}
}
Eli10293
Spazmatism
Could i Possibly make a flail controllabe like a magic missle by adding in code likeThe simplest solution is probably to get the vanilla chain textures, label them as your own under gore, and then when you need to switch them back, you just set the chain texture back to the original chain that you c&p using the PostKill() method for your projectile. Never tested this, but logically it should work.
Code:
public override void AI()
{
if (projectile.aiStyle == 15)
{
{
int num142 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 3.5f);
Main.dust[num142].noGravity = true;
Main.dust[num142].velocity *= 1.4f;
num142 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1.5f);
}
if (Main.myPlayer == projectile.owner && projectile.ai[0] == 0f)
{
if (Main.player[projectile.owner].channel)
{
float num146 = 12f;
if (projectile.type == 16)
{
num146 = 15f;
}
Vector2 vector10 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
float num147 = (float)Main.mouseX + Main.screenPosition.X - vector10.X;
float num148 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y;
if (Main.player[projectile.owner].gravDir == -1f)
{
num148 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y;
}
float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
if (num149 > num146)
{
num149 = num146 / num149;
num147 *= num149;
num148 *= num149;
int num150 = (int)(num147 * 1000f);
int num151 = (int)(projectile.velocity.X * 1000f);
int num152 = (int)(num148 * 1000f);
int num153 = (int)(projectile.velocity.Y * 1000f);
if (num150 != num151 || num152 != num153)
{
projectile.netUpdate = true;
}
projectile.velocity.X = num147;
projectile.velocity.Y = num148;
}
}
}
}
}
}
}
A_judgementalLizard
Terrarian
No I don't think it would work, I believe you have to make the projectile ai style the same as magic missiles if you want that to workCould i Possibly make a flail controllabe like a magic missle by adding in code like
Code:public override void AI() { if (projectile.aiStyle == 15) { { int num142 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 3.5f); Main.dust[num142].noGravity = true; Main.dust[num142].velocity *= 1.4f; num142 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1.5f); } if (Main.myPlayer == projectile.owner && projectile.ai[0] == 0f) { if (Main.player[projectile.owner].channel) { float num146 = 12f; if (projectile.type == 16) { num146 = 15f; } Vector2 vector10 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float num147 = (float)Main.mouseX + Main.screenPosition.X - vector10.X; float num148 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; if (Main.player[projectile.owner].gravDir == -1f) { num148 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; } float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148)); num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148)); if (num149 > num146) { num149 = num146 / num149; num147 *= num149; num148 *= num149; int num150 = (int)(num147 * 1000f); int num151 = (int)(projectile.velocity.X * 1000f); int num152 = (int)(num148 * 1000f); int num153 = (int)(projectile.velocity.Y * 1000f); if (num150 != num151 || num152 != num153) { projectile.netUpdate = true; } projectile.velocity.X = num147; projectile.velocity.Y = num148; } } } } } } }
Eli10293
Spazmatism
This is literally the internal code for the magic missle and Im combining it with flail AINo I don't think it would work, I believe you have to make the projectile ai style the same as magic missiles if you want that to work
Sin Costan
Eye of Cthulhu
I saw this before, forgot to answer you. Yes, you can, tested it before actually...Could i Possibly make a flail controllabe like a magic missle by adding in code like
Code:public override void AI() { if (projectile.aiStyle == 15) { { int num142 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 3.5f); Main.dust[num142].noGravity = true; Main.dust[num142].velocity *= 1.4f; num142 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 27, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 1.5f); } if (Main.myPlayer == projectile.owner && projectile.ai[0] == 0f) { if (Main.player[projectile.owner].channel) { float num146 = 12f; if (projectile.type == 16) { num146 = 15f; } Vector2 vector10 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); float num147 = (float)Main.mouseX + Main.screenPosition.X - vector10.X; float num148 = (float)Main.mouseY + Main.screenPosition.Y - vector10.Y; if (Main.player[projectile.owner].gravDir == -1f) { num148 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector10.Y; } float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148)); num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148)); if (num149 > num146) { num149 = num146 / num149; num147 *= num149; num148 *= num149; int num150 = (int)(num147 * 1000f); int num151 = (int)(projectile.velocity.X * 1000f); int num152 = (int)(num148 * 1000f); int num153 = (int)(projectile.velocity.Y * 1000f); if (num150 != num151 || num152 != num153) { projectile.netUpdate = true; } projectile.velocity.X = num147; projectile.velocity.Y = num148; } } } } } } }
A_judgementalLizard
Terrarian
I uploaded a way to fix the blue moon chain texture into the tutorial.
Eli10293
Spazmatism
Are U Ever Going 2 Upload The Finished Flail?I uploaded a way to fix the blue moon chain texture into the tutorial.
A_judgementalLizard
Terrarian
I will right now. I was waiting until I worked out the bug with the blue moon chain.Are U Ever Going 2 Upload The Finished Flail?
[DOUBLEPOST=1430022993,1430022605][/DOUBLEPOST]
The working flail has been uploaded, message me if there are any problems(it's literally exactly what you did in the tutorial so there shouldn't beI will right now. I was waiting until I worked out the bug with the blue moon chain.
Eli10293
Spazmatism
I Thought You Were Going To Post An Image Of itI will right now. I was waiting until I worked out the bug with the blue moon chain.
[DOUBLEPOST=1430022993,1430022605][/DOUBLEPOST]
The working flail has been uploaded, message me if there are any problems(it's literally exactly what you did in the tutorial so there shouldn't be
Similar threads
- Replies
- 2
- Views
- 268
- Replies
- 1
- Views
- 881
- Replies
- 14
- Views
- 1K
- Replies
- 0
- Views
- 268
-
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.