Advertisement
Guest User

Untitled

a guest
May 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.21 KB | None | 0 0
  1. using System;
  2. using Microsoft.Xna.Framework;
  3. using Terraria;
  4. using Terraria.ModLoader;
  5. using Microsoft.Xna.Framework.Graphics;
  6. using System.Collections.Generic;
  7. using Terraria.DataStructures;
  8. using Terraria.GameContent.Achievements;
  9. using Terraria.Graphics.Shaders;
  10. using Terraria.ID;
  11. using Terraria.Localization;
  12. using Terraria.Enums;
  13. using Terraria.ObjectData;
  14.  
  15. namespace Dinosaur.Mounts
  16. {
  17. public class Mount_Controls : ModMountData
  18. {
  19.  
  20. private int counter = 0;
  21. private int counterY = 0;
  22. private int counterZ = 0;
  23. private int counterYawn = 0;
  24.  
  25. private bool attack = false; private int attackCoolDown = 0; private bool slowed;
  26.  
  27. //Variables from mount. Useless for now
  28.  
  29. int i1, i2, i3,
  30. a1, a2, a3,
  31. f1, f2, f3,
  32. r1, r2, r3,
  33. s1, s2, s3;
  34.  
  35. //void Get(int i1, int i2, int i3, int a1, int a2, int a3, int f1, int f2, int f3, int r1, int r2, int r3, int s1, int s2, int s3);
  36. private int temp = 0;
  37.  
  38. public override void UpdateEffects(Player player)
  39. {
  40. //Impacts/Landing
  41. //Sudden Stop
  42. if (Math.Abs(player.velocity.X) > 9f && Math.Abs(player.velocity.Y) == 0f && counter < 180)
  43. {
  44. counter++;
  45. }
  46. if (counter > 20 && (Math.Abs(player.velocity.X) < 6f) && Math.Abs(player.velocity.Y) == 0f)
  47. {
  48. //Normal Dust
  49. int dustIndex = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width - 12, player.height - 98, 31, player.velocity.X * -0.35f, player.velocity.Y * 1.3f, 100, default(Color), 0.2f);
  50. Main.dust[dustIndex].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f;
  51. Main.dust[dustIndex].fadeIn = 2f + (float)Main.rand.Next(90) * 0.1f;
  52. Main.dust[dustIndex].noGravity = true;
  53. //foward
  54. int dustIndex2 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width - 22, player.height - 98, 31, player.velocity.X * 0.1f, player.velocity.Y * 1.3f, 100, default(Color), 0.2f);
  55. Main.dust[dustIndex2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f;
  56. Main.dust[dustIndex2].fadeIn = 1.8f + (float)Main.rand.Next(50) * 0.1f;
  57. Main.dust[dustIndex2].noGravity = true;
  58. //Larger, Alpha Dust
  59. int dustIndex3 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width - 12, player.height - 98, 31, player.velocity.X * -0.55f, player.velocity.Y * 4.3f, 100, default(Color), 0.2f);
  60. Main.dust[dustIndex3].scale = 0.4f + (float)Main.rand.Next(5) * 0.1f;
  61. Main.dust[dustIndex3].fadeIn = 0.2f + (float)Main.rand.Next(9) * 0.1f;
  62. Main.dust[dustIndex3].noGravity = true;
  63. Main.dust[dustIndex3].alpha = 150;
  64. //foward
  65. int dustIndex4 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width - 22, player.height - 98, 31, player.velocity.X * 0.3f, player.velocity.Y * 1.3f, 100, default(Color), 0.2f);
  66. Main.dust[dustIndex4].scale = 0.4f + (float)Main.rand.Next(5) * 0.1f;
  67. Main.dust[dustIndex4].fadeIn = 0.2f + (float)Main.rand.Next(5) * 0.1f;
  68. Main.dust[dustIndex4].noGravity = true;
  69. Main.dust[dustIndex4].alpha = 120;
  70.  
  71.  
  72. //Smoke Gore
  73. int goreIndex = Gore.NewGore(new Vector2(player.position.X + (float)(player.width / 2) - 24f, player.position.Y + 89), default(Vector2), Main.rand.Next(61, 64), 1f);
  74. Main.gore[goreIndex].scale = 0.5f;
  75. Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
  76. Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;
  77. Main.gore[goreIndex].alpha = 230;
  78. counter--;
  79. if (Math.Abs(player.velocity.X) <= 0f && Math.Abs(player.velocity.Y) == 0f)
  80. counter = 0;
  81. }
  82.  
  83. //Up and down
  84. if (Math.Abs(player.velocity.Y) > 8f && counterY < 180)
  85. {
  86. counterY++;
  87. }
  88.  
  89. if (counterY > 20 && (Math.Abs(player.velocity.Y) == 0f))
  90. {
  91. //Normal Dust
  92. for (int i = 0; i < 10; i++)
  93. {
  94. int dustIndex = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width - 12, player.height - 98, 31, player.velocity.X - 1f, player.velocity.Y * -1.3f, 100, default(Color), 0.2f);
  95. Main.dust[dustIndex].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f;
  96. Main.dust[dustIndex].fadeIn = 2f + (float)Main.rand.Next(90) * 0.1f;
  97. Main.dust[dustIndex].noGravity = true;
  98.  
  99. int dustIndex2 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width + 12, player.height - 98, 31, player.velocity.X + 1f, player.velocity.Y * -1.3f, 100, default(Color), 0.2f);
  100. Main.dust[dustIndex2].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f;
  101. Main.dust[dustIndex2].fadeIn = 2f + (float)Main.rand.Next(90) * 0.1f;
  102. Main.dust[dustIndex2].noGravity = true;
  103. }
  104. counterY--;
  105. if (Math.Abs(player.velocity.Y) <= 4f)
  106. counterY = 0;
  107. }
  108.  
  109.  
  110. //Sudden Jump
  111. if (Math.Abs(player.velocity.Y) < 0.1f && counterZ < 60)
  112. {
  113. counterZ++;
  114. }
  115.  
  116. if (counterZ > 10 && (Math.Abs(player.velocity.Y) > 2f))
  117. {
  118. //Normal Dust
  119. for (int i = 0; i < 10; i++)
  120. {
  121. int dustIndex = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width, player.height - 198, 31, player.velocity.X * -1.3f, player.velocity.Y * 0.2f, 100, default(Color), 0.2f);
  122. Main.dust[dustIndex].scale = 0.05f + (float)Main.rand.Next(5) * 0.08f;
  123. Main.dust[dustIndex].fadeIn = 1f + (float)Main.rand.Next(90) * 0.1f;
  124. Main.dust[dustIndex].noGravity = true;
  125.  
  126. int dustIndex2 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width, player.height - 198, 31, player.velocity.X * -0.6f, player.velocity.Y * 0.1f, 100, default(Color), 0.2f);
  127. Main.dust[dustIndex2].scale = 0.05f + (float)Main.rand.Next(5) * 0.08f;
  128. Main.dust[dustIndex2].fadeIn = 1f + (float)Main.rand.Next(90) * 0.1f;
  129. Main.dust[dustIndex2].noGravity = true;
  130. }
  131. counterZ--;
  132. if (Math.Abs(player.velocity.Y) >= 0.1f)
  133. counterZ = 0;
  134. }
  135.  
  136.  
  137. //Idle mechanics
  138. //Sits down
  139. if (counterYawn < 2300 && Math.Abs(player.velocity.X) < .1f && Math.Abs(player.velocity.X) > -.2f && Math.Abs(player.velocity.Y) == 0f)
  140. {
  141. counterYawn++;
  142. }
  143. if (Math.Abs(player.velocity.X) != 0f || Math.Abs(player.velocity.Y) != 0f)
  144. {
  145. counterYawn = 0;
  146. }
  147. if (counterYawn >= 2155)
  148. {
  149. //mountData.yOffset = 10;
  150. mountData.idleFrameCount = 1;
  151. mountData.idleFrameDelay = 15;
  152. mountData.idleFrameStart = 20;
  153. mountData.idleFrameLoop = true;
  154. }
  155.  
  156.  
  157. //Run control
  158. //Running
  159. if (Math.Abs(player.velocity.X) > 3f)
  160. {
  161. mountData.jumpSpeed = 6.5f;
  162. mountData.runningFrameCount = 6;
  163. mountData.runningFrameDelay = 80;
  164. mountData.runningFrameStart = 6;
  165. }
  166. //Sprinting
  167. if (Math.Abs(player.velocity.X) > 8f)
  168. {
  169. mountData.jumpSpeed = 9f;
  170. mountData.runningFrameCount = 6;
  171. mountData.runningFrameDelay = 65;
  172. mountData.runningFrameStart = 6;
  173.  
  174. }
  175. }
  176.  
  177.  
  178.  
  179.  
  180. //Attack
  181. public override void UseAbility(Player player, Vector2 mousePosition, bool toggleOn)
  182. {
  183. if (Main.mouseRight && attackCoolDown == 0 && player.velocity.Y < 1 && player.velocity.Y > -1)
  184. {
  185. attack = true;
  186. attackCoolDown = 65;
  187. temp = 0;
  188. }
  189.  
  190. if (attack == true)
  191. {
  192. //Slowing Down
  193. mountData.runSpeed -= 0.5f;
  194.  
  195. if (mountData.runSpeed == 0)
  196. {
  197. slowed = true;
  198. }
  199. }
  200.  
  201. if (slowed == true)
  202. {
  203. //If mount has slowed down:
  204. mountData.runningFrameCount = 5;
  205. mountData.runningFrameDelay = 15;
  206. mountData.runningFrameStart = 21;
  207.  
  208. //Different Stages to run frames at different speeds, with different momentum.
  209.  
  210. if (attackCoolDown < 50)
  211. {
  212. int dustIndex = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 89), player.width - 12, player.height - 98, 31, player.velocity.X * -0.35f, player.velocity.Y * 1.3f, 100, default(Color), 0.2f);
  213. Main.dust[dustIndex].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f;
  214. Main.dust[dustIndex].fadeIn = 2f + (float)Main.rand.Next(90) * 0.1f;
  215. Main.dust[dustIndex].noGravity = true;
  216. mountData.runningFrameDelay = 14;
  217. player.velocity.X = 0.8f * (player.direction);
  218.  
  219. if (temp < 3)
  220. {
  221. Projectile.NewProjectileDirect(new Vector2(player.position.X + 45 * player.direction, player.position.Y + 2 * attackCoolDown - 20), new Vector2(1.5f * player.velocity.X, player.velocity.Y), mod.ProjectileType("Slash"), 50, 4f, Main.myPlayer, 0, 0);
  222. temp++;
  223. }
  224. }
  225. if (attackCoolDown < 35)
  226. {
  227. mountData.runningFrameDelay = 12;
  228. //player.position.X;
  229. player.velocity.X += 1.75f* player.direction;
  230. }
  231.  
  232. if (attackCoolDown < 20)
  233. {
  234. mountData.runningFrameDelay = 13;
  235. player.velocity.X -= 4f * (player.direction);
  236. }
  237. if (attackCoolDown < 10)
  238. {
  239. mountData.runningFrameDelay = 15;
  240. player.velocity.X /= 1.5f;
  241. }
  242. }
  243. if (attackCoolDown != 0)
  244. {
  245. attackCoolDown--;
  246. }
  247. if (attackCoolDown == 0)
  248. {
  249. mountData.runSpeed = 12f;
  250. attack = false;
  251. slowed = false;
  252. }
  253. }
  254.  
  255.  
  256.  
  257. //continues
  258. }
  259. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement