Guest User

Untitled

a guest
Apr 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.20 KB | None | 0 0
  1. global script slot2
  2. {
  3. void run()
  4. {
  5.  
  6. //Initialize variables used to store Link's strating position on Screen Init.
  7. int olddmap = Game->GetCurDMap();
  8. int oldscreen = Game->GetCurDMapScreen();
  9. int startx = Link->X;
  10. int starty = Link->Y;
  11. int startdir = Link->Dir;
  12.  
  13. //Clear global variables used by Bottomless pits.
  14. Falling = 0;
  15. Warping = false;
  16.  
  17. //Global variables for Farore's Wind
  18. int faroresWindTimer = 0;
  19. Link->Invisible = false;
  20.  
  21.  
  22. //Main Loop
  23. while(true)
  24. {
  25.  
  26. Update_HotRoom();
  27.  
  28. //Ice Rod Global
  29. for(foriceone = 1; foriceone <= Screen->NumLWeapons(); foriceone++){
  30. lweapon tweapon = Screen->LoadLWeapon(foriceone);
  31. if(tweapon->Misc[4] == 42){
  32. for(foricetwo = 1; foricetwo <= Screen->NumNPCs(); foricetwo++){
  33. npc tnpc = Screen->LoadNPC(foricetwo);
  34. if(RectCollision(tweapon->X, tweapon->Y, tweapon->X+15, tweapon->Y+15,
  35.  
  36. tnpc->X+tnpc->HitXOffset, tnpc->Y+tnpc->HitYOffset, tnpc->X+tnpc->HitXOffset+tnpc->HitWidth,
  37.  
  38. tnpc->Y+tnpc->HitYOffset+tnpc->HitHeight)){
  39. Game->PlaySound(freezesound);
  40. if(CanFreeze(tnpc) && tnpc->ID != iceblocknpc){
  41. tnpc->HP -= tweapon->Misc[10];
  42. if(tnpc->HP<=0){
  43. tnpc->HP=500;
  44. tnpc->Misc[12]=145;
  45. }
  46. else tnpc->Misc[12] = 144;
  47. tnpc->Stun = Stunframes+1;
  48. npc IceCol = Screen->CreateNPC(iceblocknpc);
  49. IceCol->X = tnpc->X-8;
  50. IceCol->Y = tnpc->Y-8;
  51. if(tnpc->TileHeight == 2 && tnpc->TileWidth == 2){
  52. IceCol->HitHeight = 48;
  53. IceCol->HitWidth = 48;
  54. }
  55. else{
  56. IceCol->HitHeight = 32;
  57. IceCol->HitWidth = 32;
  58. }
  59. }
  60. tweapon->DeadState = WDS_DEAD;
  61. }
  62. }
  63. }
  64. }
  65. for(foricethree = 1; foricethree <= Screen->NumNPCs(); foricethree++){
  66. npc itnpc = Screen->LoadNPC(foricethree);
  67. if(itnpc->Misc[12] == 144 || itnpc->Misc[12] == 145){
  68. if(itnpc->Stun > 1){
  69. itnpc->CollDetection = false;
  70. if(itnpc->TileWidth == 2 && itnpc->TileHeight == 2){
  71. Screen->DrawTile(IceLayer(itnpc), itnpc->X-8, itnpc->Y-8, threebythreeice, 3, 3,
  72.  
  73. icecset, -1, -1, 0, 0, 0, 0, true, icetransparency());
  74. }
  75. else{
  76. Screen->DrawTile(IceLayer(itnpc), itnpc->X-8, itnpc->Y-8, twobytwoice, 2, 2, icecset,
  77.  
  78. -1, -1, 0, 0, 0, 0, true, icetransparency());
  79. }
  80. }
  81. else{
  82. itnpc->CollDetection = true;
  83. lweapon Melt = Screen->CreateLWeapon(EW_SCRIPT1);
  84. Melt->X = itnpc->X;
  85. Melt->Y = itnpc->Y;
  86. Melt->DrawStyle = DS_CLOAKED;
  87. for(foricefour = 1; foricefour <= Screen->NumNPCs(); foricefour++){
  88. npc ibnpc = Screen->LoadNPC(foricefour);
  89. if(Collision(Melt, ibnpc) && ibnpc->ID == iceblocknpc){
  90. ibnpc->X = 256;
  91. ibnpc->Y = 176;
  92. ibnpc->HP = 0;
  93. }
  94. }
  95. Melt->DeadState = WDS_DEAD;
  96. if(itnpc->Misc[12]==145) itnpc->HP=0;
  97. }
  98. }
  99. else{
  100. IceTurn(itnpc);
  101. }
  102. }
  103. Waitdraw();
  104. //Attack Ring global
  105. for(int i = 1; i <= Screen->NumLWeapons(); i++){
  106. lweapon weap = Screen->LoadLWeapon(i);
  107. if(weap->ID != LW_SWORD && weap->Misc[MISC_LW_BOOSTED] == 0){
  108. weap->Damage *= attackRingPower;
  109. weap->Misc[MISC_LW_BOOSTED] = 1;
  110. }
  111. }
  112.  
  113. //Generic Trigger Global
  114. for (int i = 1; i <= Screen->NumLWeapons(); i++) {
  115. lweapon lw = Screen->LoadLWeapon(i);
  116. if (lw->Misc[LWEAPON_MISC_SOURCE] == 0) {
  117. lw->Misc[LWEAPON_MISC_SOURCE] = LastItemUsed;}}
  118.  
  119.  
  120.  
  121. //Stops enemies from dropping ammunition items that Link doesn't have a way to carry (Bomb bag, quiver, etc.).
  122. for ( int i = 1; i <= Screen->NumItems(); i++){
  123. item drop = Screen->LoadItem(i);
  124. if ( (drop->ID == I_ARROWAMMO1 && !Link->Item[I_QUIVER1])
  125. || ( drop->ID == I_ARROWAMMO10 && !Link->Item[I_QUIVER1])
  126. || ( drop->ID == I_ARROWAMMO30 && !Link->Item[I_QUIVER1])
  127. || ( drop->ID == I_ARROWAMMO5 && !Link->Item[I_QUIVER1])
  128. || ( drop->ID == I_BOMBAMMO1 && !Link->Item[I_BOMBBAG1])
  129. || ( drop->ID == I_BOMBAMMO4 && !Link->Item[I_BOMBBAG1])
  130. || ( drop->ID == I_BOMBAMMO8 && !Link->Item[I_BOMBBAG1])
  131. || ( drop->ID == I_BOMBAMMO30 && !Link->Item[I_BOMBBAG1]) )
  132. Remove (drop);
  133.  
  134.  
  135. //Triforce Check
  136. if ( (drop->ID == I_TFP && Link->Item[I_TFW]))
  137. drop->ID = I_TFPW;
  138. if ( (drop->ID == I_TFC && Link->Item[I_TFP]))
  139. drop->ID = I_TFCP;
  140. if ( (drop->ID == I_TFW && Link->Item[I_TFP]))
  141. drop->ID = I_TFPW;
  142. if ( (drop->ID == I_TFP && Link->Item[I_TFC]))
  143. drop->ID = I_TFCP;
  144. if ( (drop->ID == I_TFC && Link->Item[I_TFW]))
  145. drop->ID = I_TFWC;
  146. if ( (drop->ID == I_TFW && Link->Item[I_TFC]))
  147. drop->ID = I_TFWC;
  148. if ( (drop->ID == I_TFP && Link->Item[I_TFWC]))
  149. drop->ID = I_TFWHOLE;
  150. if ( (drop->ID == I_TFC && Link->Item[I_TFPW]))
  151. drop->ID = I_TFWHOLE;
  152. if ( (drop->ID == I_TFW && Link->Item[I_TFCP]))
  153. drop->ID = I_TFWHOLE;
  154.  
  155.  
  156. //Magic Container Piece Global
  157.  
  158. //Magic Container checks
  159. if ( (drop->ID == I_MCPDUMMY))
  160. drop->ID = I_MCPIECE1;
  161. if ( (drop->ID == I_MCPIECE1 && Link->Item[I_MCPIECE1]))
  162. drop->ID = I_MCPIECE2;
  163. if ( (drop->ID == I_MCPIECE2 && Link->Item[I_MCPIECE2]))
  164. drop->ID = I_MCPIECE3;
  165. if ( (drop->ID == I_MCPIECE3 && Link->Item[I_MCPIECE3]))
  166. drop->ID = I_MCPIECE4;
  167.  
  168.  
  169.  
  170. }
  171. if ( (Link->Item[I_MCPIECE1] == true) && //Manually enter item number for MC_1.
  172. (Link->Item[I_MCPIECE2] == true) && //Manually enter item number for MC_2.
  173. (Link->Item[I_MCPIECE3] == true) && //Manually enter item number for MC_3.
  174. (Link->Item[I_MCPIECE4] == true) ) //Manually enter item number for MC_4.
  175.  
  176. //If Link has four Magic Containers
  177. {
  178. Link->Item[I_MCPIECE1] = false; //Removes MPC1; Manually enter item number for MC_1.
  179. Link->Item[I_MCPIECE2] = false; //Removes MCP2; Manually enter item number for MC_2.
  180. Link->Item[I_MCPIECE3] = false; //Removes MCP3; Manually enter item number for MC_3.
  181. Link->Item[I_MCPIECE4] = false; //Removes MCP4; Manually enter item number for MC_4.
  182. item MCWhole = Screen->CreateItem(I_MAGICCONTAINER); //Gives link a whole MC.
  183. MCWhole->X = Link->X;
  184. MCWhole->Y = Link->Y;
  185. MCWhole->Z = Link->Z;
  186. }
  187.  
  188. //Implement cooldown for Farore's Wind
  189. if ( faroresWindTimer > 0 )
  190. faroresWindTimer--;
  191.  
  192. //If Farores Wind was called by item script
  193. if ( fwData[FWD_ACTIVE] != 0 ){
  194. //No warp point set: set one
  195. if ( fwData[FWD_DMAP] < 0 ){
  196. //Start animation (sprite above Link)
  197. Game->PlaySound(SFX_FARORESWINDSET);
  198. lweapon anim = CreateLWeaponAt(LW_SPARKLE, Link->X, Link->Y-16);
  199. anim->UseSprite(WPS_FARORESWINDSET);
  200. freezeScreen();
  201.  
  202. //Let it finish
  203. while(anim->isValid())
  204. WaitNoAction();
  205.  
  206. //Animation done; set warp point
  207. unfreezeScreen();
  208.  
  209. //Store warp point data
  210. fwData[FWD_DMAP] = Game->GetCurDMap();
  211. fwData[FWD_SCREEN] = Game->GetCurDMapScreen();
  212. fwData[FWD_X] = Link->X;
  213. fwData[FWD_Y] = Link->Y;
  214. fwData[FWD_ACTIVE] = 0;
  215.  
  216. createWarpPointFFC();
  217. }
  218.  
  219. //Warp point set: warp to it
  220. else{
  221. //Start animation (sprite replaces Link)
  222. Game->PlaySound(SFX_FARORESWINDWARP);
  223. lweapon anim = CreateLWeaponAt(LW_SPARKLE, Link->X, Link->Y);
  224. anim->UseSprite(WPS_FARORESWINDWARP);
  225. Link->Invisible = true;
  226. freezeScreen();
  227.  
  228. //Let it finish
  229. while(anim->isValid())
  230. WaitNoAction();
  231.  
  232. //Animation done; warp
  233. unfreezeScreen();
  234. Link->Invisible = false;
  235. Screen->SetSideWarp(0, fwData[FWD_SCREEN], fwData[FWD_DMAP], WT_IWARPWAVE);
  236. ffc warpFFC = loadUnusedFFC(true);
  237. warpFFC->Data = CMB_AUTOW2;
  238.  
  239. //Wait for warp to take place (warp pauses global script), then place Link
  240. Waitframe();
  241. Link->X = fwData[FWD_X];
  242. Link->Y = fwData[FWD_Y];
  243.  
  244. //Un-set warp
  245. fwData[FWD_DMAP] = -1;
  246. }
  247.  
  248. fwData[FWD_ACTIVE] = 0;
  249. }
  250.  
  251.  
  252.  
  253.  
  254. if(Link->Action != LA_SCROLLING)
  255. {
  256. Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
  257. if(Link->Z==0 && !Falling && (oldscreen != Game->GetCurDMapScreen() || olddmap != Game->GetCurDMap()))
  258. {
  259. olddmap = Game->GetCurDMap();
  260. oldscreen = Game->GetCurDMapScreen();
  261. startx = Link->X;
  262. starty = Link->Y;
  263. startdir = Link->Dir;
  264. }
  265. }
  266. //THIS REPLACES YOUR NORMAL WAITFRAME()
  267. //Any other scripts that check screen changes can share this section
  268. if ( WaitframeCheckScreenChange() ){
  269. createWarpPointFFC(); //If screen changed, try to create warp point
  270. }
  271. }
  272. }
  273. }
  274. void Update_HotRoom()
  275. {
  276. if(Link->Item[I_GORONTUNIC])
  277. {
  278. hotroominit = false;
  279. if((Screen->Flags[SF_MISC] & 4<<HOTROOM_FLAG)!=0)
  280. {
  281. Link->Item[I_RING2] = true;
  282. }
  283. else
  284. {
  285. Link->Item[I_RING2] = false;
  286. }
  287. return;
  288. }
  289. else if((Screen->Flags[SF_MISC] & 4<<HOTROOM_FLAG)!=0)
  290. {
  291. if(hotroominit)
  292. {
  293. Game->Counter[CR_SECONDS] = (Game->Counter[CR_SECONDS] + 1)%60;
  294. if(Game->Counter[CR_SECONDS] == 0) hotroomtimer--;
  295. }
  296. else hotroomtimer = HOTROOM_TIME;
  297. hotroominit = true;
  298. if(hotroomtimer == 0)
  299. {
  300. hotroominit = false;
  301. Link->HP = 0;
  302. Quit();
  303. }
  304. }
  305. else
  306. {
  307. hotroominit = false;
  308. hotroomtimer = 0;
  309. return;
  310. }
  311. if(hotroominit)
  312. {
  313. //Create an array of characters.
  314. int string[5];
  315. //Add the minutes to the array.
  316. itoa(string, 0, Div(hotroomtimer, 60));
  317. //Add the : after the minutes.
  318. string[strlen(string)] = ':';
  319. //Add the seconds after the colon.
  320. int seconds = hotroomtimer % 60;
  321. if(seconds < 10) string[strlen(string)] = '0';
  322. itoa(string, strlen(string), seconds);
  323. //Draw the timer to the screen.
  324. Screen->DrawString(7, 0, 0, FONT_DEF, SOLID_WHITE, SOLID_BLACK, TF_NORMAL, string, 128);
  325. }
  326. }
  327. void createWarpPointFFC(){
  328. if ( Game->GetCurDMap() == fwData[FWD_DMAP] //If on warp point DMap/screen
  329. && Game->GetCurDMapScreen() == fwData[FWD_SCREEN]
  330. ){
  331. ffc warpPointFFC = loadUnusedFFC(false); //Get an unused FFC
  332.  
  333. if ( !ffcIsBlank(warpPointFFC) ) //If non-blank FFC, quit now
  334. return;
  335.  
  336. //Place the FFC
  337. warpPointFFC->Data = CMB_WARPPOINT;
  338. warpPointFFC->X = fwData[FWD_X];
  339. warpPointFFC->Y = fwData[FWD_Y];
  340. }
  341. }
  342. //Handles Pit Combo Functionality.
  343. void Update_HoleLava(int x, int y, int dmap, int scr, int dir)
  344. {
  345. lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
  346. if(hookshot->isValid()) return;
  347.  
  348. if(Falling)
  349. {
  350. Falling--;
  351. if(Falling == 1)
  352. {
  353. int buffer[] = "holelava";
  354. if(CountFFCsRunning(Game->GetFFCScript(buffer)))
  355. {
  356. ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
  357. Warping = true;
  358. if(f->InitD[1]==0)
  359. {
  360. f->InitD[6] = x;
  361. f->InitD[7] = y;
  362. }
  363. }
  364. else
  365. {
  366. Link->X = x;
  367. Link->Y = y;
  368. Link->Dir = dir;
  369. Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  370. Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  371. Link->HP -= HOLELAVA_DAMAGE;
  372. Link->Action = LA_GOTHURTLAND;
  373. Link->HitDir = -1;
  374. Game->PlaySound(SFX_OUCH);
  375. if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
  376. Link->PitWarp(dmap, scr);
  377. }
  378. NoAction();
  379. Link->Action = LA_NONE;
  380. }
  381. }
  382. else if(Link->Z==0 && OnPitCombo() && !Warping)
  383. {
  384. Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
  385. Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
  386. int comboflag = OnPitCombo();
  387. SnaptoGrid();
  388. Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
  389. lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  390. dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
  391. dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
  392. dummy->DrawXOffset = 0;
  393. dummy->DrawYOffset = 0;
  394. Falling = dummy->DeadState;
  395. NoAction();
  396. Link->Action = LA_NONE;
  397. }
  398. }
Add Comment
Please, Sign In to add comment