Advertisement
Guest User

SGAWorld

a guest
Jan 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using Microsoft.Xna.Framework;
  5. using Terraria;
  6. using Terraria.ID;
  7. using Terraria.DataStructures;
  8. using Terraria.Localization;
  9. using Terraria.ModLoader;
  10. using Terraria.ModLoader.IO;
  11.  
  12. namespace SGAmod
  13. {
  14. public class SGAWorld: ModWorld
  15. {
  16. //Setting up variables for invasion
  17. public static bool customInvasionUp = false;
  18. public static bool downedCustomInvasion = false;
  19. public static bool downedSPinky = false;
  20. public static bool downedTPD = false;
  21.  
  22. //Initialize all variables to their default values
  23. public override void Initialize()
  24. {
  25. Main.invasionSize = 0;
  26. customInvasionUp = false;
  27. downedCustomInvasion = false;
  28. downedSPinky = false;
  29. downedTPD = false;
  30. }
  31.  
  32. //Save downed data
  33. public override TagCompound Save()
  34. {
  35. var downed = new List<string>();
  36. if (downedCustomInvasion) downed.Add("customInvasion");
  37. if (downedSPinky) downed.Add("downedSPinky");
  38. if (downedTPD) downed.Add("downedTPD");
  39.  
  40. return new TagCompound {
  41. {"downed", downed}
  42. };
  43. }
  44.  
  45. //Load downed data
  46. public override void Load(TagCompound tag)
  47. {
  48. var downed = tag.GetList<string>("downed");
  49. downedCustomInvasion = downed.Contains("customInvasion");
  50. downedSPinky=downed.Contains("downedSPinky");
  51. downedTPD=downed.Contains("downedTPD");
  52. }
  53.  
  54. //Sync downed data
  55. public override void NetSend(BinaryWriter writer)
  56. {
  57. BitsByte flags = new BitsByte();
  58. flags[0] = downedCustomInvasion;
  59. flags[1] = downedSPinky;
  60. flags[2] = downedTPD;
  61. writer.Write(flags);
  62. }
  63.  
  64. //Sync downed data
  65. public override void NetReceive(BinaryReader reader)
  66. {
  67. BitsByte flags = reader.ReadByte();
  68. downedCustomInvasion = flags[0];
  69. downedSPinky = flags[1];
  70. downedTPD = flags[2];
  71.  
  72. }
  73.  
  74.  
  75.  
  76. public static void Shattershots(Vector2 here,Vector2 there,Vector2 widthheight,int type,int damage,float Speed,float spread,int count,bool centershot,float globalangularoffset,bool tilecollidez,int timeleft){
  77. //if (Main.netMode!=1){
  78.  
  79. Vector2 vector8 = new Vector2(here.X + (0), here.Y + (0));
  80. //int type = mod.ProjectileType("EnkiduWind");
  81. //Main.PlaySound(2, (int)here.X, (int)here.Y, 12);
  82. float rotation = (float)Math.Atan2(vector8.Y - (there.Y + (widthheight.X * 0.5f)), vector8.X - (there.X + (widthheight.Y * 0.5f)));
  83. spread = spread * (0.0174f);
  84. float baseSpeed = (float)Math.Sqrt((float)((Math.Cos(rotation) * Speed) * -1) * (float)((Math.Cos(rotation) * Speed) * -1) + (float)((Math.Sin(rotation) * Speed) * -1) * (float)((Math.Sin(rotation) * Speed) * -1));
  85. double startAngle = Math.Atan2((float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1));
  86. double deltaAngle = spread/count;
  87. double offsetAngle;
  88. int i;
  89. for (i = 0; i < count;i++ )
  90. {
  91. offsetAngle = (startAngle+globalangularoffset) + deltaAngle * i;
  92. double offsetAngle2 = (startAngle+globalangularoffset) - (deltaAngle * i);
  93. if (centershot==true || i>0){
  94. int proj=Projectile.NewProjectile(vector8.X, vector8.Y, baseSpeed*(float)Math.Sin(offsetAngle), baseSpeed*(float)Math.Cos(offsetAngle), type, damage, Speed, 0);
  95. Main.projectile[proj].friendly=false;
  96. Main.projectile[proj].hostile=true;
  97. Main.projectile[proj].tileCollide = tilecollidez;
  98. Main.projectile[proj].timeLeft = timeleft;
  99. }
  100. if (i>0){
  101. int proj2=Projectile.NewProjectile(vector8.X, vector8.Y, baseSpeed*(float)Math.Sin(offsetAngle2), baseSpeed*(float)Math.Cos(offsetAngle2), type, damage, Speed, 0);
  102. Main.projectile[proj2].friendly=false;
  103. Main.projectile[proj2].hostile=true;
  104. Main.projectile[proj2].tileCollide = tilecollidez;
  105. Main.projectile[proj2].timeLeft = timeleft;
  106.  
  107. }
  108. }
  109.  
  110.  
  111.  
  112. //}
  113. }
  114. //end of function
  115.  
  116.  
  117.  
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement