Advertisement
Guest User

Untitled

a guest
May 17th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.06 KB | None | 0 0
  1. //Input Constants Magnetic Gloves
  2.  
  3. bool magna_gloves_active = false;
  4. bool magna_gloves_positive = false;
  5.  
  6. const int magna_flag = 105;
  7. const int magna_positive = 155;
  8.  
  9. const int MAGNETIC_GLOVES_P = 154;
  10. const int MAGNETIC_GLOVES_N = 155;
  11.  
  12.  
  13. //Checks if either the positive or negative glove item is in Link's A Button slot
  14. //and if he is pressing the A button.
  15. bool MagnaA(){
  16. return ( (GetEquipmentA() == MAGNETIC_GLOVES_P || GetEquipmentA() == MAGNETIC_GLOVES_N) && Link->InputA );
  17. }
  18.  
  19. //Checks if either the positive or negative glove item is in Link's B Button slot
  20. //and if he is pressing the B button.
  21. bool MagnaB(){
  22. return ( (GetEquipmentB() == MAGNETIC_GLOVES_P || GetEquipmentB() == MAGNETIC_GLOVES_N) && Link->InputB );
  23. }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. //Magnetic Gloves functions
  31. void MagnaGlovesWork() {
  32. if(MagnaA() || MagnaB() ){
  33.  
  34. //Link->Action = LA_FROZEN;
  35.  
  36. if(Screen->isSolid(Link->X+15, Link->Y+15)) {
  37. Link->InputUp = false;
  38. Link->InputDown = false;
  39. Link->InputLeft = false;
  40. Link->InputRight = false;
  41. }
  42.  
  43. else if(Screen->isSolid(Link->X, Link->Y+15)) {
  44. Link->InputUp = false;
  45. Link->InputDown = false;
  46. Link->InputLeft = false;
  47. Link->InputRight = false;
  48. }
  49.  
  50. else if(Screen->isSolid(Link->X+15, Link->Y+7)) {
  51. Link->InputUp = false;
  52. Link->InputDown = false;
  53. Link->InputLeft = false;
  54. Link->InputRight = false;
  55. }
  56.  
  57. else if(Screen->isSolid(Link->X, Link->Y+7)) {
  58. Link->InputUp = false;
  59. Link->InputDown = false;
  60. Link->InputLeft = false;
  61. Link->InputRight = false;
  62. }
  63.  
  64. int lc = 0;
  65. bool yes = false;
  66.  
  67.  
  68. if(Link->Dir == DIR_LEFT) {
  69. for(int i = Floor(Link->X / 16) - 1; i >= 0; i--) {
  70. lc = ComboAt(i * 16, Link->Y + 8);
  71. if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
  72. yes = true;
  73. break;
  74. }
  75. }
  76. if(yes) {
  77. Link->Z = 5;
  78. Link->Jump = 0;
  79. Link->Y = Floor((Link->Y + 8) / 16) * 16;
  80. KillLinkInput();
  81. if(magna_gloves_positive) {
  82. if(!Screen->isSolid(Link->X + 16, Link->Y)) {
  83. Link->X += 1;
  84. }
  85. if(!Screen->isSolid(Link->X + 16, Link->Y)) {
  86. Link->X += 1;
  87. }
  88. } else {
  89. if(!Screen->isSolid(Link->X - 1, Link->Y)) {
  90. Link->X -= 1;
  91. }
  92. if(!Screen->isSolid(Link->X - 1, Link->Y)) {
  93. Link->X -= 1;
  94. }
  95. }
  96. }
  97. } else if(Link->Dir == DIR_RIGHT) {
  98. for(int i = Floor(Link->X / 16) + 1; i <= 16; i++) {
  99. lc = ComboAt(i * 16, Link->Y + 8);
  100.  
  101. if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
  102. yes = true;
  103. break;
  104. }
  105. }
  106. if(yes) {
  107. Link->Z = 5;
  108. Link->Jump = 0;
  109. Link->Y = Floor((Link->Y + 8) / 16) * 16;
  110. KillLinkInput();
  111. if(magna_gloves_positive) {
  112. if(!Screen->isSolid(Link->X - 1, Link->Y)) {
  113. Link->X -= 1;
  114. }
  115. if(!Screen->isSolid(Link->X - 1, Link->Y)) {
  116. Link->X -= 1;
  117. }
  118.  
  119. } else {
  120. if(!Screen->isSolid(Link->X + 16, Link->Y)) {
  121. Link->X += 1;
  122. }
  123. if(!Screen->isSolid(Link->X + 16, Link->Y)) {
  124. Link->X += 1;
  125. }
  126. }
  127.  
  128. }
  129. } else if(Link->Dir == DIR_UP) {
  130. for(int i = Floor((Link->Y + 9) / 16) - 1; i >= 0; i--) {
  131. lc = ComboAt(Link->X + 8, i * 16);
  132. if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
  133. yes = true;
  134. break;
  135. }
  136. }
  137. if(yes) {
  138. Link->Z = 5;
  139. Link->Jump = 0;
  140. Link->X = Floor((Link->X + 8) / 16) * 16;
  141. KillLinkInput();
  142. if(!magna_gloves_positive) {
  143. if(!Screen->isSolid(Link->X, Link->Y - 1)) {
  144. Link->Y -= 1;
  145. }
  146. if(!Screen->isSolid(Link->X, Link->Y - 1)) {
  147. Link->Y -= 1;
  148. }
  149. } else {
  150.  
  151. if(!Screen->isSolid(Link->X, Link->Y + 16)) {
  152. Link->Y += 1;
  153. }
  154. if(!Screen->isSolid(Link->X, Link->Y + 16)) {
  155. Link->Y += 1;
  156. }
  157. }
  158. }
  159. } else if(Link->Dir == DIR_DOWN) {
  160. for(int i = Floor(Link->Y / 16) + 1; i <= 16; i++) {
  161. lc = ComboAt(Link->X + 8, i * 16);
  162.  
  163. if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
  164. yes = true;
  165. break;
  166. }
  167. }
  168. if(yes) {
  169. Link->Z = 5;
  170. Link->Jump = 0;
  171. Link->X = Floor((Link->X + 8) / 16) * 16;
  172. KillLinkInput();
  173. if(!magna_gloves_positive) {
  174. if(!Screen->isSolid(Link->X, Link->Y + 16)) {
  175. Link->Y += 1;
  176. }
  177. if(!Screen->isSolid(Link->X, Link->Y + 16)) {
  178. Link->Y += 1;
  179. }
  180. } else {
  181. if(!Screen->isSolid(Link->X, Link->Y - 1)) {
  182. Link->Y -= 1;
  183. }
  184. if(!Screen->isSolid(Link->X, Link->Y - 1)) {
  185. Link->Y -= 1;
  186. }
  187. }
  188.  
  189. }
  190. }
  191.  
  192. if(!yes) {
  193. int d = Link->Dir;
  194. //well, we're not attached to anything.
  195. //so, let's move around
  196. if(Link->InputUp) {
  197. Link->InputUp = false;
  198. if(!Screen->isSolid(Link->X, Link->Y - 1)) Link->Y -= 1;
  199. }
  200. if(Link->InputDown) {
  201. Link->InputDown = false;
  202. if(!Screen->isSolid(Link->X, Link->Y + 16)) Link->Y += 1;
  203. }
  204. if(Link->InputLeft) {
  205. Link->InputLeft = false;
  206. if(!Screen->isSolid(Link->X - 1, Link->Y)) Link->X -= 1;
  207. }
  208. if(Link->InputRight) {
  209. Link->InputRight = false;
  210. if(!Screen->isSolid(Link->X + 16, Link->Y)) Link->X += 1;
  211. }
  212. //Link->Dir = d;
  213. }
  214. } else {
  215. magna_gloves_active = false;
  216. magna_gloves_positive = !magna_gloves_positive;
  217. //Link->Action = LA_NONE;
  218. Link->Item[magna_positive] = !Link->Item[magna_positive];
  219. }
  220. }
  221.  
  222. void KillLinkInput() {
  223. Link->InputUp = false;
  224. Link->InputDown = false;
  225. Link->InputLeft = false;
  226. Link->InputRight = false;
  227. }
  228.  
  229.  
  230. //balls are negative
  231. //they are also inert
  232. ffc script IronBall {
  233. void run() {
  234. lweapon lw;
  235. while(true) {
  236. //we only need to care if the gloves are active
  237. if(magna_gloves_active) {
  238. //first, is link aligned with us?
  239. if((Link->X + 8 > this->X && Link->X + 8 < this->X + 16) || (Link->Y + 8 > this->Y && Link->Y + 8 < this->Y + 16)) {
  240. //yes he is!
  241. //is he facing us?
  242. int d = link_direction(this);
  243. if(d == DIR_LEFT && Link->Dir == DIR_RIGHT ||
  244. d == DIR_RIGHT && Link->Dir == DIR_LEFT ||
  245. d == DIR_UP && Link->Dir == DIR_DOWN ||
  246. d == DIR_DOWN && Link->Dir == DIR_UP) {
  247.  
  248. //he is! But, we're not done yet...
  249. //is there a pole in the way?
  250. bool ok = true;
  251. if(d == DIR_LEFT) {
  252. for(int i = Floor(this->X / 16) - 1; i > Floor(Link->X / 16); i--) {
  253. if(Screen->ComboF[ComboAt(i * 16, this->Y)] == magna_flag || Screen->ComboI[ComboAt(i * 16, this->Y)] == magna_flag) {
  254. ok = false;
  255. }
  256. }
  257. } else if(d == DIR_RIGHT) {
  258. for(int i = Floor(this->X / 16) + 1; i < Floor(Link->X / 16); i++) {
  259. if(Screen->ComboF[ComboAt(i * 16, this->Y)] == magna_flag || Screen->ComboI[ComboAt(i * 16, this->Y)] == magna_flag) {
  260. ok = false;
  261. }
  262. }
  263. } else if(d == DIR_UP) {
  264. for(int i = Floor(this->Y / 16) - 1; i > Floor(Link->Y / 16); i--) {
  265. if(Screen->ComboF[ComboAt(this->X, i * 16)] == magna_flag || Screen->ComboI[ComboAt(this->X, i * 16)] == magna_flag) {
  266. ok = false;
  267. }
  268. }
  269. } else if(d == DIR_DOWN) {
  270. for(int i = Floor(this->Y / 16) + 1; i < Floor(Link->Y / 16); i++) {
  271. if(Screen->ComboF[ComboAt(this->X, i * 16)] == magna_flag || Screen->ComboI[ComboAt(this->X, i * 16)] == magna_flag) {
  272. ok = false;
  273. }
  274. }
  275. }
  276.  
  277. if(ok) {
  278. //yes! we get to do something!
  279. if(d == DIR_UP) {
  280. //we need to align ourselves to Link
  281. moveH(Link->X - this->X, this);
  282. //... and either move towards him...
  283. if(magna_gloves_positive) {
  284. if(this->Y > Link->Y + 17) moveV(-2,this);
  285. } else {
  286. // or away from him
  287. moveV(2, this);
  288. }
  289. } else if(d == DIR_DOWN) {
  290. moveH(Link->X - this->X, this);
  291. if(magna_gloves_positive) {
  292. if(this->Y < Link->Y - 2) moveV(2, this);
  293. } else {
  294. moveV(-2, this);
  295. }
  296. } else if(d == DIR_LEFT) {
  297. moveV(Link->Y - this->Y, this);
  298. if(magna_gloves_positive) {
  299. if(this->X > Link->X + 17) moveH(-2, this);
  300. } else {
  301. moveH(2, this);
  302. }
  303. } else if(d == DIR_RIGHT) {
  304. moveV(Link->Y - this->Y, this);
  305. if(magna_gloves_positive) {
  306. if(this->X < Link->X - 2) moveH(2, this);
  307. } else {
  308. moveH(-2, this);
  309. }
  310. }
  311.  
  312. //also, we need to damage enemies. so, we'll spawn little lweapons that are invisible
  313. if(lw->isValid()) lw->DeadState = WDS_DEAD;
  314.  
  315. lw = Screen->CreateLWeapon(LW_SCRIPT1);
  316. lw->X = this->X;
  317. lw->Y = this->Y;
  318. lw->Damage = 1;
  319. lw->OriginalTile = 74;
  320. lw->Tile = 74;
  321. } else {
  322. //well, that was a wasted effort.
  323. }
  324. }
  325. }
  326. }
  327.  
  328. Waitframe();
  329. }
  330.  
  331. }
  332.  
  333. void moveV(int amt, ffc this) {
  334. if(amt == 0) return;
  335. if(amt < 0) {
  336. for(int i = 1; i <= Abs(amt); i++) {
  337. if(isSolid(this->X + 8, this->Y - 1) || isSolid(this->X + 12, this->Y - 1)) break;
  338. this->Y--;
  339. }
  340. } else {
  341. for(int i = 1; i <= amt; i++) {
  342. if(isSolid(this->X + 4, this->Y + 1 + 15) || isSolid(this->X + 12, this->Y + 1 + 15)) break;
  343. this->Y++;
  344. }
  345. }
  346. }
  347.  
  348. void moveH(int amt, ffc this) {
  349. if(amt == 0) return;
  350. if(amt < 0) {
  351. for(int i = 1; i <= Abs(amt); i++) {
  352. if(isSolid(this->X - 1, this->Y + 4) || isSolid(this->X - 1, this->Y + 12)) break;
  353. this->X--;
  354. }
  355. } else {
  356. for(int i = 1; i <= amt; i++) {
  357. if(isSolid(this->X + 1 + 15, this->Y + 4) || isSolid(this->X + 1 + 15, this->Y + 12)) break;
  358. this->X++;
  359. }
  360. }
  361. }
  362.  
  363. int link_direction(ffc this) {
  364. int d_x = this->X - Link->X;
  365. int d_y = this->Y - Link->Y;
  366. int a_x = Abs(d_x);
  367. int a_y = Abs(d_y);
  368.  
  369. if(a_x <= a_y) {
  370. if(d_y >= 0) {
  371. return DIR_UP;
  372. } else {
  373. return DIR_DOWN;
  374. }
  375. } else {
  376. if(d_x >= 0) {
  377. return DIR_LEFT;
  378. } else {
  379. return DIR_RIGHT;
  380. }
  381. }
  382. }
  383. }
  384.  
  385.  
  386. ffc script RotatingPole {
  387. void run() {
  388. while(true) {
  389. Waitframes(39);
  390.  
  391. //now we rotate!
  392. if(Link->X >= this->X + 16 && Link->X < this->X + 18 && Link->Y >= this->Y - 4 && Link->Y <= this->Y + 8 && Link->Dir == DIR_LEFT) {
  393. //link is to the right
  394. Link->X = this->X;
  395. Link->Y = this->Y + 16;
  396. Link->Dir = DIR_UP;
  397. } else if(Link->X >= this->X - 18 && Link->X <= this->X - 16 && Link->Y >= this->Y - 4 && Link->Y <= this->Y + 8 && Link->Dir == DIR_RIGHT) {
  398. //link is to the left
  399. Link->X = this->X;
  400. Link->Y = this->Y - 16;
  401. Link->Dir = DIR_DOWN;
  402. } else if(Link->X >= this->X - 2 && Link->X <= this->X + 8 && Link->Y >= this->Y - 18 && Link->Y <= this->Y - 16 && Link->Dir == DIR_DOWN) {
  403. //link is to the top
  404. Link->Y = this->Y;
  405. Link->X = this->X + 16;
  406. Link->Dir = DIR_LEFT;
  407. } else if(Link->X >= this->X - 2 && Link->X <= this->X + 8 && Link->Y >= this->Y + 16 && Link->Y <= this->Y + 18 && Link->Dir == DIR_UP) {
  408. //link is to the bottom
  409. Link->Y = this->Y;
  410. Link->X = this->X - 16;
  411. Link->Dir = DIR_RIGHT;
  412. }
  413.  
  414. Waitframes(9);
  415. }
  416. }
  417. }
  418.  
  419. item script MagnaGloves {
  420. void run() {
  421. magna_gloves_active = true;
  422. }
  423. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement