Set projectile.frame to whichever frame you want.How can i manually animate a projectile? I have multiple animation frames in the texture, but how do i switch between them?
Set projectile.frame to whichever frame you want.How can i manually animate a projectile? I have multiple animation frames in the texture, but how do i switch between them?
I don't seem to be able to finde the Vampire Knives "Shot Method".Aaah yes. You can look into the sourcecode by decompiling Terraria.exe, and thus you will need a decompiler. ILSpy is one of the best, and it's free. You can download it via the website ilspy.net You will want to look in Terraria.Terraria.Projectile.VanillaAI()
I think there's some hold offset hook, look in the documentation.I don't seem to be able to finde the Vampire Knives "Shot Method".
And how do I change the way the Player holds the weapon, because the player holds he Gun to far away.
Thats great, thanks. But how do I apply this on my weapon?I think there's some hold offset hook, look in the documentation.
For Vampire Knives, I just searched the source for 1569, the ItemId of Vampire Knives, and I went through the results and found it in Player.ItemCheck.
Overwrite the Shoot method, copy in the relevant code. You might need to change any this or base to player.Thats great, thanks. But how do I apply this on my weapon?
I feel so stupid right now...
Don't i first need to tell the engine how many frames i have?Set projectile.frame to whichever frame you want.
Sadly this doesn't work or I'm doing sth wrong.Overwrite the Shoot method, copy in the relevant code. You might need to change any this or base to player.
Looks like num78 and num79 are the missing ones. Those are probably speedX and speedY. num71, num73, and num74 you can get from context, they probably are the knockback, damage, and typeSadly this doesn't work or I'm doing sth wrong.
You can take a look at the shoot method I used if it helps
In fact I cant even build the source anymore because most the "num[nummber]" are not in the contextpublic override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
int num146 = 4;
if (Main.rand.Next(2) == 0)
{
num146++;
}
if (Main.rand.Next(4) == 0)
{
num146++;
}
if (Main.rand.Next(8) == 0)
{
num146++;
}
if (Main.rand.Next(16) == 0)
{
num146++;
}
for (int num147 = 0; num147 < num146; num147++)
{
float num148 = num78;
float num149 = num79;
float num150 = 0.05f * (float)num147;
num148 += (float)Main.rand.Next(-35, 36) * num150;
num149 += (float)Main.rand.Next(-35, 36) * num150;
num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149));
num80 = num72 / num80;
num148 *= num80;
num149 *= num80;
float x4 = vector2.X;
float y4 = vector2.Y;
Projectile.NewProjectile(x4, y4, num148, num149, num71, num73, num74, i, 0f, 0f);
}
}
Thanks. And how am I going to do the Projectile? I Want the same Projectile(s) the Vampire Knives uses (Vampire Knife / Vampire Heal) just with a different color so I have to recreate the projectile and I'm sadly to stupid to get it to work.Looks like num78 and num79 are the missing ones. Those are probably speedX and speedY. num71, num73, and num74 you can get from context, they probably are the knockback, damage, and type
Thanks. And how am I going to do the Projectile? I Want the same Projectile(s) the Vampire Knives uses (Vampire Knife / Vampire Heal) just with a different color so I have to recreate the projectile and I'm sadly to stupid to get it to work.
public override void AI()
{
projectile.ai[0] += 1f;
if (projectile.ai[0] >= 30f)
{
projectile.alpha += 3;
projectile.damage = (int)((double)projectile.damage * 0.95);
projectile.knockBack = (float)((int)((double)projectile.knockBack * 0.95));
}
if (projectile.ai[0] < 30f)
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
}
if (projectile.velocity.Y > 16f)
{
projectile.velocity.Y = 16f;
}
float num472 = projectile.Center.X;
float num473 = projectile.Center.Y;
float num474 = 400f;
bool flag17 = false;
for (int num475 = 0; num475 < 200; num475++)
{
if (Main.npc[num475].CanBeChasedBy(projectile, false) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num475].Center, 1, 1))
{
float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477);
if (num478 < num474)
{
num474 = num478;
num472 = num476;
num473 = num477;
flag17 = true;
}
}
}
if (flag17)
{
float num483 = 9f;
Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
float num484 = num472 - vector35.X;
float num485 = num473 - vector35.Y;
float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
num486 = num483 / num486;
num484 *= num486;
num485 *= num486;
projectile.velocity.X = (projectile.velocity.X * 20f + num484) / 21f;
projectile.velocity.Y = (projectile.velocity.Y * 20f + num485) / 21f;
return;
}
if (Main.rand.Next(6) == 0)
{
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 20, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f);
}
}
public override void Kill(int timeLeft)
{
for (int num303 = 0; num303 < 3; num303++)
{
int num304 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 20, 0f, 0f, 100, default(Color), 0.8f);
Main.dust[num304].noGravity = true;
Main.dust[num304].velocity *= 1.2f;
Main.dust[num304].velocity -= projectile.oldVelocity * 0.3f;
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(mod.BuffType("HolyLight"), 500);
float num = (float)damage * 0.075f;
if ((int)num == 0)
{
return;
}
if (Main.player[Main.myPlayer].lifeSteal <= 0f)
{
return;
}
Main.player[Main.myPlayer].lifeSteal -= num;
int num2 = projectile.owner;
Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, mod.ProjectileType("RoyalHeal"), 0, 0f, projectile.owner, (float)num2, num);
}
public override void AI()
{
int num487 = (int)projectile.ai[0];
float num488 = 4f;
Vector2 vector36 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
float num489 = Main.player[num487].Center.X - vector36.X;
float num490 = Main.player[num487].Center.Y - vector36.Y;
float num491 = (float)Math.Sqrt((double)(num489 * num489 + num490 * num490));
if (num491 < 50f && projectile.position.X < Main.player[num487].position.X + (float)Main.player[num487].width && projectile.position.X + (float)projectile.width > Main.player[num487].position.X && projectile.position.Y < Main.player[num487].position.Y + (float)Main.player[num487].height && projectile.position.Y + (float)projectile.height > Main.player[num487].position.Y)
{
if (projectile.owner == Main.myPlayer && !Main.player[Main.myPlayer].moonLeech)
{
int num492 = (int)projectile.ai[1];
Main.player[num487].HealEffect(num492, false);
Main.player[num487].statLife += num492;
if (Main.player[num487].statLife > Main.player[num487].statLifeMax2)
{
Main.player[num487].statLife = Main.player[num487].statLifeMax2;
}
NetMessage.SendData(66, -1, -1, "", num487, (float)num492, 0f, 0f, 0, 0, 0);
}
projectile.Kill();
}
num491 = num488 / num491;
num489 *= num491;
num490 *= num491;
projectile.velocity.X = (projectile.velocity.X * 15f + num489) / 16f;
projectile.velocity.Y = (projectile.velocity.Y * 15f + num490) / 16f;
for (int num493 = 0; num493 < 3; num493++)
{
float num494 = projectile.velocity.X * 0.334f * (float)num493;
float num495 = -(projectile.velocity.Y * 0.334f) * (float)num493;
int num496 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 20, 0f, 0f, 100, default(Color), 1.1f);
Main.dust[num496].noGravity = true;
Main.dust[num496].velocity *= 0f;
Dust expr_153E2_cp_0 = Main.dust[num496];
expr_153E2_cp_0.position.X = expr_153E2_cp_0.position.X - num494;
Dust expr_15401_cp_0 = Main.dust[num496];
expr_15401_cp_0.position.Y = expr_15401_cp_0.position.Y - num495;
}
for (int num497 = 0; num497 < 5; num497++)
{
float num498 = projectile.velocity.X * 0.2f * (float)num497;
float num499 = -(projectile.velocity.Y * 0.2f) * (float)num497;
int num500 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 20, 0f, 0f, 100, default(Color), 1.3f);
Main.dust[num500].noGravity = true;
Main.dust[num500].velocity *= 0f;
Dust expr_154F9_cp_0 = Main.dust[num500];
expr_154F9_cp_0.position.X = expr_154F9_cp_0.position.X - num498;
Dust expr_15518_cp_0 = Main.dust[num500];
expr_15518_cp_0.position.Y = expr_15518_cp_0.position.Y - num499;
}
}
@MountainDrew Thanks that's SUPER nice ^^
but didn't you added some new effect to the "Royal Knives" ?
That would be nice but I could do it myself if you would tell me how. The bigger heal Isn't a problem but it would be nice how to change the healed amount for balancing reasonsYeah, they home in on enemies I could remove that and send it back here if you like, but I'm probably going to bed now.
They also heal more than regular vampire knives.
Main.projFrames[projectile.type] = 3;Don't i first need to tell the engine how many frames i have?
1)You add just a dust in the AI projectile, dude, this is a stupid question, that ^^.How do I make a projectile have a "trail" like the Terrarian's projectiles? Also, why is my pet turning invisible then visible again? I just copied the code form the ExamplePet (projectile, buff, and item) and tweaked it a bit.
You include that in your shoot, this is better.how do I make a spear shoot another projectile? I tried it but then the spear completely disappeared
Install VisualStudio, this is not a bug, you have just a variable not declared.If noticed a bug. It says "...Projectiles\DemonKnife.cs(94,44) : error CS0103: Name "num" isn't in the current context
1)You add just a dust in the AI projectile, dude, this is a stupid question, that ^^.
2)Probably because he have include projectile.alpha than you do not need. Read all code of the minion, then rebuild, the code is very simple and this is better.