tModLoader Using Projectiles randomly in a mage's weapon

Taskinsk

Terrarian
Hi everyone. I just recently started looking into tmodloader and I got a problem, I couldn't find an example that would help me solve this problem. I want to make a mod in which the magician's weapon will have the ability to fire random projectiles when using a staff, which are used by other staves in the vanilla terraria. Thank you in advance!
And one more thing, I mean not in the item itself, but in \projectiles, so as not to use the code in the items itself, since it is already occupied with other functions.

For example, there is such a code, but I do not know at all how to inject it not into a item, but into a project, so that then through the command item.shoot =; Add it.



public class RandomRR : ModItem
{
private int RandomR;

public override void SetStaticDefaults()
{
this.Tooltip.SetDefault("R");
}

public override void SetDefaults()
{
this.item.height = 20;
this.item.width = 20;


this.item.damage = 55;
this.item.noMelee = true;
this.item.magic = true;
this.item.useStyle = 5;

this.item.knockBack = 5;
this.item.useTime = 10;
this.item.useAnimation = 10;

this.item.value = 1750000;
this.item.rare = 5;

this.item.UseSound = SoundID.Item5;

this.item.autoReuse = true;
this.item.shootSpeed = 22.0f;
this.item.channel = true;
this.item.autoReuse = true;
this.item.shoot = 10;

this.item.mana = 1;

It is this part of the code that I would like to remove from item into projectiles:

public override bool Shoot(
Player player,
ref Vector2 position,
ref float speedX,
ref float speedY,
ref int type,
ref int damage,
ref float knockBack)
{
}
if (this.RandomR == 2)
{
Projectile.NewProjectile((float) position.X, (float) position.Y, speedX , speedY, 645, damage, knockBack, (int) ((Entity) player).whoAmI, 0.0f, 0.0f);
++this.RandomR;
}
if (this.RandomR == 1)
{
Projectile.NewProjectile((float) position.X, (float) position.Y, speedX, speedY, 644, damage, knockBack, (int) ((Entity) player).whoAmI, 0.0f, 0.0f);
++this.RandomR;
}
if (this.RandomR == 0)
{
Projectile.NewProjectile((float) position.X, (float) position.Y, speedX, speedY, 660, damage, knockBack, (int) ((Entity) player).whoAmI, 0.0f, 0.0f);
++this.RandomR;
}
if (this.RandomR == 3)
this.RandomR = 0;
return false;
}
 
Last edited:
Back
Top Bottom