Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Terraria;
  4. using Terraria.ID;
  5. using Terraria.ModLoader;
  6. using System;
  7. using System.Collections.Generic;
  8.  
  9. namespace GuidosMod.items.weapons
  10. {
  11. public class TrueNightSky : ModItem
  12. {
  13. public override void SetStaticDefaults()
  14. {
  15. DisplayName.SetDefault("True Night Sky");
  16. Tooltip.SetDefault("A blade forged from the essence of 2000 dark souls.");
  17. }
  18.  
  19. public override void SetDefaults()
  20. {
  21. item.damage = 119;
  22. item.melee = true;
  23. item.width = 50;
  24. item.height = 76;
  25. item.useTime = 12;
  26. item.useAnimation = 12;
  27. item.useStyle = 1;
  28. item.knockBack = 5;
  29. item.value = 10000;
  30. item.rare = 11;
  31. item.UseSound = SoundID.Item88;
  32. item.shootSpeed = 35f;
  33. item.autoReuse = true;
  34. item.useTurn = true;
  35. }
  36.  
  37.  
  38. public override void AddRecipes()
  39. {
  40. ModRecipe recipe = new ModRecipe(mod);
  41. recipe.AddIngredient(null, "TheNightSky", 1);
  42. recipe.AddIngredient(ItemID.SoulofNight, 2000);
  43. recipe.AddTile(TileID.DemonAltar);
  44. recipe.SetResult(this);
  45. recipe.AddRecipe();
  46. }
  47. public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
  48. {
  49.  
  50. player.AddBuff(BuffID.Wrath, 600);
  51. target.AddBuff(39, 420);
  52. }
  53.  
  54. public override void MeleeEffects(Player player, Rectangle hitbox)
  55. {
  56. Vector2 dustPosition;
  57. Vector2 dustVelocity = CalculateDustVelocityNormal(player, -1.57f); //send dust flying backwards of blade vlocity
  58. for (int i = 0; i < 10; i++)
  59. {
  60. float dist = Main.rand.NextFloat();
  61. dustPosition = CalculateDustPosition(player, item, 4, dist, 4f);
  62. int d = Terraria.Dust.NewDust(dustPosition, 0, 0,
  63. 27, player.velocity.X, player.velocity.Y, 0, 0, 1.3f - 0.8f * dist);
  64. Main.dust[d].velocity += dustVelocity * 5 * dist;
  65. }
  66. }
  67.  
  68. private static Vector2 CalculateDustPosition(Player player, Item item, int handleLength, float distNormal, float scaleDisplace)
  69. {
  70. handleLength += 16;
  71. int length = (int)(item.width * 1.414f * item.scale) - handleLength;
  72. float cosRot = (float)Math.Cos(player.itemRotation - 0.78f * player.direction * player.gravDir);
  73. float sinRot = (float)Math.Sin(player.itemRotation - 0.78f * player.direction * player.gravDir);
  74. if (length < 1) length = 1;
  75. return new Vector2(
  76. (float)(player.itemLocation.X + (handleLength + length * distNormal) * cosRot * player.direction) - scaleDisplace,
  77. (float)(player.itemLocation.Y + (handleLength + length * distNormal) * sinRot * player.direction) - scaleDisplace);
  78. }
  79. private static Vector2 CalculateDustVelocityNormal(Player player, float angleOffset)
  80. {
  81. float cosRot = (float)Math.Cos(player.itemRotation - (0.78f - angleOffset) * player.direction * player.gravDir);
  82. float sinRot = (float)Math.Sin(player.itemRotation - (0.78f - angleOffset) * player.direction * player.gravDir);
  83. return new Vector2(
  84. (float)(cosRot * player.direction),
  85. (float)(sinRot * player.direction));
  86. }
  87. public override void HoldItem(Player player)
  88. {
  89. player.armorPenetration += 20;
  90. }
  91.  
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement