Advertisement
Guest User

ZQscript

a guest
Mar 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.28 KB | None | 0 0
  1. import "std.zh"
  2. import "string.zh"
  3. import "ffcscript.zh"
  4.  
  5. // This script is a pickup script that will give some items.
  6. // This was mostly made to bundle the Bow and Arrows into one item,
  7. // but it could have other uses.
  8. // Bundle this with an item that increases a counter to also increase counters.
  9. // D0-D7: Items to give.
  10. // D0: If D0 is negative, it will display an item pickup message containing the positive version of the number entered...
  11. item script itemBundle{
  12. void run(int item1, int item2, int item3, int item4, int item5, int item6, int item7, int item8)
  13. {
  14. if(item1 > 0)
  15. Link->Item[item1] = true;
  16. if(item2 > 0)
  17. Link->Item[item2] = true;
  18. if(item3 > 0)
  19. Link->Item[item3] = true;
  20. if(item4 > 0)
  21. Link->Item[item4] = true;
  22. if(item5 > 0)
  23. Link->Item[item5] = true;
  24. if(item6 > 0)
  25. Link->Item[item6] = true;
  26. if(item7 > 0)
  27. Link->Item[item7] = true;
  28. if(item8 > 0)
  29. Link->Item[item8] = true;
  30.  
  31. // Display Item pickup message?
  32. if(item1 < 0)
  33. {
  34. Screen->Message(item1 * -1);
  35. }
  36. }//!End void run()
  37. }//!End item script itemBundle
  38.  
  39. ffc script Signpost{
  40. void run(int m,int input){
  41. int loc = ComboAt(this->X,this->Y);
  42. while(true){
  43. while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
  44. SetInput(input,false);
  45. Screen->Message(m);
  46. Waitframe();
  47. }
  48. }
  49. bool AgainstComboBase(int loc){
  50. return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
  51. }
  52. }
  53.  
  54. //!!These functions should only be included in your script file once!!
  55. bool SelectPressInput(int input){
  56. if(input == 0) return Link->PressA;
  57. else if(input == 1) return Link->PressB;
  58. else if(input == 2) return Link->PressL;
  59. else if(input == 3) return Link->PressR;
  60. }
  61. void SetInput(int input, bool state){
  62. if(input == 0) Link->InputA = state;
  63. else if(input == 1) Link->InputB = state;
  64. else if(input == 2) Link->InputL = state;
  65. else if(input == 3) Link->InputR = state;
  66. }
  67.  
  68. //===============Global=Variables=&=Constants===================
  69.  
  70. const int SFX_GBSHIELD = 17; //Shield active SFX
  71.  
  72. int shieldItem; //Shield item to give (set by item script, reset each frame)
  73. bool shieldButton; //False = B, True = A
  74.  
  75.  
  76.  
  77.  
  78. const int SCRIPT_BARRIERS = 2; // Must refer to "Barrier"'s ffc script slot in the quest
  79.  
  80. // ID's of barrier-related combos
  81. // Barriers in raised state
  82. const int BARRIER_A_RAISED = 60;
  83. const int BARRIER_B_RAISED = 61;
  84.  
  85. // Barriers in lowered state
  86. const int BARRIER_A_LOWERED = 62;
  87. const int BARRIER_B_LOWERED = 63;
  88.  
  89. // Barriers animating to raised state
  90. const int BARRIER_A_ANIMRAISE = 64;
  91. const int BARRIER_B_ANIMRAISE = 65;
  92.  
  93. // Barriers animating to lowered state
  94. const int BARRIER_A_ANIMLOWER = 66;
  95. const int BARRIER_B_ANIMLOWER = 67;
  96.  
  97. // Raised barriers that Link can walk on
  98. const int BARRIER_A_WALKABLE = 68;
  99. const int BARRIER_B_WALKABLE = 69;
  100.  
  101. // Barrier switches
  102. const int BARRIER_A_SWITCH = 70;
  103. const int BARRIER_B_SWITCH = 71;
  104.  
  105. const int BARRIER_SWITCH_DUMMY = 177; // ID of a switch hit detection dummy enemy
  106. const int BARRIER_SWITCH_DUMMY_HP = 32767;
  107.  
  108. // Global array to store the state of barriers per dmap
  109. // If you have more than 16 dmaps you can change the capacity in the []'s
  110. // You may change the states in other scripts, but the changes will not be visible
  111. // until there is a new screen, so set them before Barriers_NewScreen() is called.
  112. bool barriers[16]; // false = blue barriers raised, true = red barriers raised
  113.  
  114.  
  115. //Common Constant, only need to define once per script file.
  116. const int BIG_LINK = 0; //Set this constant to 1 if using the Large Link Hit Box feature.
  117.  
  118. //Constants used by Bottomless Pits & Lava.
  119. const int CT_HOLELAVA = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
  120. const int CF_PIT = 98; //The combo flag to register combos as pits.
  121. const int CF_LAVA = 99; //The combo flag to register combos as lava.
  122. const int WPS_LINK_FALL = 89; //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
  123. const int WPS_LINK_LAVA = 90; //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
  124. const int SFX_LINK_FALL = 38; //The sound to play when Link falls into a pit. "SFX_FALL by default"
  125. const int SFX_LINK_LAVA = 55; //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
  126. const int CMB_AUTOWARP = 48; //The first of your four transparent autowarp combos.
  127. const int HOLELAVA_DAMAGE = 8; //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"
  128.  
  129. //Global variables used by Bottomless Pits & Lava.
  130. int Falling;
  131. bool Warping;
  132.  
  133. //=========Global=Script=====================================
  134. global script script2 {
  135. void run() {
  136. // Initialize variables used to listen on screen changes
  137. int curscreen = -1;
  138. bool shieldOn;
  139.  
  140. //Initialize variables used to store Link's strating position on Screen Init.
  141. int olddmap = Game->GetCurDMap();
  142. int oldscreen = Game->GetCurDMapScreen();
  143. int startx = Link->X;
  144. int starty = Link->Y;
  145. int startdir = Link->Dir;
  146.  
  147. //Clear global variables used by Bottomless pits.
  148. Falling = 0;
  149. Warping = false;
  150.  
  151. while (true) {
  152. // Keep track of screen changes
  153. // Run a Barrier script on every screen change
  154. if (Game->GetCurScreen() != curscreen) {
  155. curscreen = Game->GetCurScreen();
  156. Barriers_NewScreen();}
  157. if( !shieldOn && shieldItem ){ //Enable shield when using dummy
  158. shieldOn=true; //Set shield state to on
  159. Link->Item[shieldItem]=true; //Give the shield
  160. Game->PlaySound(SFX_GBSHIELD); //Play the sound
  161. }
  162. else if( ( (shieldButton && !Link->InputA)||(!shieldButton && !Link->InputB)) //When button is released
  163. && shieldOn){ //And shield is still on
  164. Link->Item[shieldItem]=false; //Remove shield
  165. shieldItem = 0; //Reset shield item variable
  166. shieldOn = false; //Set shield state to off
  167. }
  168. {
  169. Waitdraw();
  170. if(Link->Action != LA_SCROLLING)
  171. {
  172. Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
  173. if(Link->Z==0 && !Falling && (oldscreen != Game->GetCurDMapScreen() || olddmap != Game->GetCurDMap()))
  174. {
  175. olddmap = Game->GetCurDMap();
  176. oldscreen = Game->GetCurDMapScreen();
  177. startx = Link->X;
  178. starty = Link->Y;
  179. startdir = Link->Dir;
  180. }
  181. }
  182. Waitframe();}}}
  183.  
  184.  
  185. // Function that makes preparations for barriers on each screen and starts an FFC script
  186. void Barriers_NewScreen() {
  187.  
  188. // Search for a barrier-related combo
  189. for (int i = 0; i <= 175; i++) {
  190. int cd = Screen->ComboD[i];
  191. if (cd == BARRIER_A_RAISED || cd == BARRIER_A_LOWERED || cd == BARRIER_A_SWITCH ||
  192. cd == BARRIER_B_RAISED || cd == BARRIER_B_LOWERED || cd == BARRIER_B_SWITCH) {
  193. // A barrier-related combo was found
  194.  
  195. // Make initial changes to combos
  196. if (barriers[Game->GetCurDMap()]) {
  197. for (int j = i; j <= 175; j++) {
  198. int cd = Screen->ComboD[j];
  199. if (cd == BARRIER_A_RAISED) Screen->ComboD[j] = BARRIER_A_LOWERED;
  200. else if (cd == BARRIER_B_LOWERED) Screen->ComboD[j] = BARRIER_B_RAISED;
  201. else if (cd == BARRIER_A_SWITCH) Screen->ComboD[j] = BARRIER_B_SWITCH;}}
  202. else {
  203. for (int j = i; j <= 175; j++) {
  204. int cd = Screen->ComboD[j];
  205. if (cd == BARRIER_B_RAISED) Screen->ComboD[j] = BARRIER_B_LOWERED;
  206. else if (cd == BARRIER_A_LOWERED) Screen->ComboD[j] = BARRIER_A_RAISED;
  207. else if (cd == BARRIER_B_SWITCH) Screen->ComboD[j] = BARRIER_A_SWITCH;}}
  208.  
  209. // So run FFCscript to control barriers
  210. int args[] = {0,0,0,0,0,0,0,0};
  211. RunFFCScript(SCRIPT_BARRIERS, args);
  212. break;}
  213. }}
  214.  
  215. // This lets you toggle barriers on any dmap
  216. bool ToggleBarriers(int dmap) {
  217. if (dmap == Game->GetCurDMap()) ToggleBarriers();
  218. else barriers[dmap] = !barriers[dmap];
  219. return barriers[dmap];}
  220.  
  221. // This toggles barriers on the current dmap
  222. bool ToggleBarriers() {
  223.  
  224. int curdmap = Game->GetCurDMap();
  225. if (!barriers[curdmap]) {
  226. barriers[curdmap] = true;
  227. for (int i = 0; i <= 175; i++) {
  228. int cd = Screen->ComboD[i];
  229. if (cd == BARRIER_A_RAISED || cd == BARRIER_A_WALKABLE || cd == BARRIER_A_ANIMRAISE) {
  230. Screen->ComboD[i] = BARRIER_A_ANIMLOWER;}
  231. else if (cd == BARRIER_B_LOWERED || cd == BARRIER_B_ANIMLOWER) {
  232. Screen->ComboD[i] = BARRIER_B_ANIMRAISE;}
  233. else if (cd == BARRIER_A_SWITCH) {Screen->ComboD[i] = BARRIER_B_SWITCH;}}}
  234. else {
  235. barriers[curdmap] = false;
  236. for (int i = 0; i <= 175; i++) {
  237. int cd = Screen->ComboD[i];
  238. if (cd == BARRIER_B_RAISED || cd == BARRIER_B_WALKABLE || cd == BARRIER_B_ANIMRAISE) {
  239. Screen->ComboD[i] = BARRIER_B_ANIMLOWER;}
  240. else if (cd == BARRIER_A_LOWERED || cd == BARRIER_A_ANIMLOWER) {
  241. Screen->ComboD[i] = BARRIER_A_ANIMRAISE;}
  242. else if (cd == BARRIER_B_SWITCH) {Screen->ComboD[i] = BARRIER_A_SWITCH;}}}
  243.  
  244. return barriers[curdmap];
  245. }
  246.  
  247. //Handles Pit Combo Functionality.
  248. void Update_HoleLava (int x, int y, int dmap, int scr, int dir)
  249. {
  250. lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
  251. if(hookshot->isValid()) return;
  252.  
  253. if(Falling)
  254. {
  255. if(IsSideview()) Link->Jump=0;
  256. Falling--;
  257. if(Falling == 1)
  258. {
  259. int buffer[] = "Holelava";
  260. if(CountFFCsRunning(Game->GetFFCScript(buffer)))
  261. {
  262. ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
  263. Warping = true;
  264. if(f->InitD[1]==0)
  265. {
  266. f->InitD[6] = x;
  267. f->InitD[7] = y;
  268. }
  269. }
  270. else
  271. {
  272. Link->X = x;
  273. Link->Y = y;
  274. Link->Dir = dir;
  275. Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  276. Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  277. Link->HP -= HOLELAVA_DAMAGE;
  278. Link->Action = LA_GOTHURTLAND;
  279. Link->HitDir = -1;
  280. Game->PlaySound(SFX_OUCH);
  281. if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
  282. Link->PitWarp(dmap, scr);
  283. }
  284. NoAction();
  285. Link->Action = LA_NONE;
  286. }
  287. }
  288. else if(Link->Z==0 && OnPitCombo() && !Warping)
  289. {
  290. Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
  291. Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
  292. int comboflag = OnPitCombo();
  293. SnaptoGrid();
  294. Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
  295. lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
  296. dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
  297. dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
  298. dummy->DrawXOffset = 0;
  299. dummy->DrawYOffset = 0;
  300. Falling = dummy->DeadState;
  301. NoAction();
  302. Link->Action = LA_NONE;
  303. }
  304. }}
  305.  
  306.  
  307.  
  308.  
  309. //==============Barriers=FFC=Script=========================
  310. // This script controls barriers on the screen
  311. // The FFC is automatically created by Barriers_NewScreen()
  312. ffc script Barriers {
  313. void run() {
  314.  
  315. // Initialize storage for bswitch hit dummies
  316. int bswitch_count;
  317. npc bswitch[8];
  318.  
  319. for (int i = 0; i <= 175; i++) {
  320. if (Screen->ComboD[i] == BARRIER_A_SWITCH || Screen->ComboD[i] == BARRIER_B_SWITCH) {
  321. npc bs = CreateNPCAt(BARRIER_SWITCH_DUMMY, ComboX(i), ComboY(i));
  322. bs->HitWidth = 8; // Smaller hit box to avoid annoying collisions with Link
  323. bs->HitHeight = 8;
  324. bs->HP = BARRIER_SWITCH_DUMMY_HP;
  325. bswitch[bswitch_count++] = bs;}}
  326.  
  327. // Change raised barriers to walkable ones if Link enters screen on a raised barrier
  328. int lcombo = LinkOnComboD();
  329. bool onbarrier = (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED);
  330. if (onbarrier) for (int i = 0; i < 176; i++) {
  331. if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
  332. else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}
  333.  
  334.  
  335. while (true) {
  336.  
  337. // Detect hits on bswitches, and change combos accordingly
  338. for (int j = 0; j < bswitch_count; j++) {
  339. if (bswitch[j]->HP < BARRIER_SWITCH_DUMMY_HP) {
  340. bswitch[j]->HP = BARRIER_SWITCH_DUMMY_HP;
  341. ToggleBarriers();
  342. break;}} //break so that only one bswitch hit may register per frame
  343.  
  344.  
  345. // Make barriers walkable if Link is on raised barriers, or unwalkable if not
  346. lcombo = LinkOnComboD();
  347. if (!onbarrier && (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED)) {
  348. onbarrier = true;
  349. for (int i = 0; i <= 175; i++) {
  350. if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
  351. else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}}
  352. else if (onbarrier && !(lcombo == BARRIER_A_WALKABLE || lcombo == BARRIER_B_WALKABLE)) {
  353. onbarrier = false;
  354. for (int i = 0; i <= 175; i++) {
  355. if (Screen->ComboD[i] == BARRIER_A_WALKABLE) {Screen->ComboD[i] = BARRIER_A_RAISED;}
  356. else if (Screen->ComboD[i] == BARRIER_B_WALKABLE) {Screen->ComboD[i] = BARRIER_B_RAISED;}}}
  357.  
  358. Waitframe();}
  359. }}
  360.  
  361.  
  362.  
  363. // A utility function that returns the ID of the combo that Link appears to stand on
  364. int LinkOnComboD() {
  365. return Screen->ComboD[ComboAt(Link->X+8, Link->Y+13)];
  366. }
  367.  
  368. //D0: "Real" shield item to give
  369. item script gbshield{
  370. void run ( int shield ){
  371. shieldItem = shield;
  372. if ( Link->PressB ) shieldButton = false;
  373. else if ( Link->PressA ) shieldButton = true;
  374. }
  375. }
  376.  
  377.  
  378. //=================Freeform=Doors=======================
  379. ffc script Locked{
  380. void run(int dir, int offset, int adjacent, bool boss, bool big){
  381. //Wait until the door is unlocked by Link if not already unlocked on screen init.
  382. while(!GetScreenDBit(0, dir) && !OpeningDoor(this, dir%4, boss)) Waitframe();
  383. //Initialize a variable as the location of combo the ffc is placed at.
  384. int comboLoc = ComboAt(this->X, this->Y);
  385. //Change the variable we just initialized according to the dir and big arguments.
  386. if(dir%4 == 0 || big) comboLoc -= 16;
  387. if(dir%4 == 2) comboLoc -= 1;
  388. //Loop through the horizontal combos.
  389. for(int i; i < 2; i++){
  390. //In each iteration of the loop, loop through the vertical combos.
  391. for(int j; (big && j < 3) || j < 2; j++){
  392. //Increment the combo data of the combo by the offset argument.
  393. int combo = comboLoc + i + (16 * j);
  394. Screen->ComboD[combo] += offset;
  395. }
  396. }
  397. //Check the screen D bit (dir) on register 0, and if it's already set skip the rest of the script.
  398. if(!GetScreenDBit(0, dir)){
  399. //It wasn't set which means Link just opened the door. So set it so it opens on screen init.
  400. SetScreenDBit(0, dir, true);
  401. //For back to back doors we need to set the screen bit on the adjacent screen.
  402. SetScreenDBit(adjacent, 0, AdjacentDir(dir), true);
  403. //If not a boss door subtract 1 key from Link's inventory.
  404. if(!boss){
  405. if(Game->LKeys[Game->GetCurLevel()] > 0) Game->LKeys[Game->GetCurLevel()]--;
  406. else Game->Counter[CR_KEYS]--;
  407. }
  408. //Lastly play a sound effect.
  409. Game->PlaySound(SFX_SHUTTER);
  410. }
  411. }
  412. //This function checks if link is trying to open the door, and meets the requirements to do so.
  413. bool OpeningDoor(ffc this, int dir, bool boss){
  414. //If a boss door and the player has no boss key return false;
  415. if(boss && !GetLevelItem(LI_BOSSKEY)) return false;
  416. //If not a boss door and the player has no keys return false;
  417. else if(!boss && Game->Counter[CR_KEYS] == 0 && Game->LKeys[Game->GetCurLevel()] == 0) return false;
  418. //Check if Link is near-centered with the door nonfacing central axis.
  419. else if(dir < 2 && Abs(Link->X - this->X) >= 4) return false;
  420. else if(dir >= 2 && Abs(Link->Y - this->Y) >= 4) return false;
  421. //Lastly return whether or not Link is next to the door and pushing against it.
  422. else if(dir == 0) return (Link->Y == this->Y + 8 && Link->InputUp);
  423. else if(dir == 1) return (Link->Y == this->Y - 16 && Link->InputDown);
  424. else if(dir == 2) return (Link->X == this->X + 16 && Link->InputLeft);
  425. else if(dir == 3) return (Link->X == this->X - 16 && Link->InputRight);
  426. }
  427. //This Function returns the direction of the adjacent screens locked door.
  428. int AdjacentDir(int dir){
  429. //We need a variable for both loops which is the number of doors
  430. int i;
  431. //dir%4 incrementing i by one each time we wrap.
  432. for(; dir >= 4; i++) dir -= 4;
  433. //Flip dir around so we have the opposite direction.
  434. dir = OppositeDir(dir);
  435. //Now add i4 to dir.
  436. dir += (i*4);
  437. //Lastly return dir.
  438. return dir;
  439. }
  440. }
  441.  
  442. ffc script Shutter{
  443. void run(int dir, int offset, int type, bool oneway, bool big){
  444. //Check if Link is in the doorway.
  445. if(InDoorway(this, OppositeDir(dir))){
  446. //Link is in the doorway so open the shutter, copy & pasted from above.
  447. int comboLoc = ComboAt(this->X, this->Y);
  448. if(dir == 0 || big) comboLoc -= 16;
  449. if(dir == 2) comboLoc -= 1;
  450. for(int i; i < 2; i++){
  451. for(int j; (big && j < 3) || j < 2; j++){
  452. int combo = comboLoc + i + (16 * j);
  453. Screen->ComboD[combo] += offset;
  454. }
  455. }
  456. //Wait until the screen finishes scrolling.
  457. do{
  458. Waitframe(); //The scrolling doesn't start on screen init but one frame afterwards.
  459. } while(Link->Action == LA_SCROLLING);
  460. //Force Link into the room by nulling all controls accept the correct arrow key.
  461. while(InDoorway(this, dir)){
  462. NoAction();
  463. if(dir == 0) Link->InputDown = true;
  464. else if(dir == 1) Link->InputUp = true;
  465. else if(dir == 2) Link->InputRight = true;
  466. else if(dir == 3) Link->InputLeft = true;
  467. Waitframe();
  468. }
  469. //Close the shutter behind Link, copy & pasted from above.
  470. for(int i; i < 2; i++){
  471. for(int j; (big && j < 3) || j < 2; j++){
  472. int combo = comboLoc + i + (16 * j);
  473. Screen->ComboD[combo] -= offset;
  474. }
  475. }
  476. //Play the shutter sound effect.
  477. Game->PlaySound(SFX_SHUTTER);
  478. }
  479. //Otherwise wait a while. "Makes it so all shutters open simultaneously if the condition is fulfilled on screen init."
  480. else{
  481. do{
  482. Waitframe();
  483. } while(Link->Action == LA_SCROLLING);
  484. Waitframes(25);
  485. }
  486. //End the script here if it's a one way shutter.
  487. if(oneway) Quit();
  488. //Initialize blocks as the number of blocks on the screen.
  489. int blocks = NumBlocks();
  490. //Wait until the condition for opening the shutter is fulfilled.
  491. while(true){
  492. if(type == 0 && NoEnemies()) break;
  493. else if(type == 1 && NumBlocks() != blocks) break;
  494. else if(type == 2 && LastComboFlagOf(CF_BLOCKTRIGGER, 0) == -1) break;
  495. else if(type == 3 && Screen->State[ST_SECRET]) break;
  496. //If you need a custom condition for the shutter just add a else if at the end of the loop and assign it a number other than 0-3.
  497. Waitframe();
  498. }
  499. //If it's a block->shutter wait 20 frames.
  500. if(type == 1) Waitframes(20);
  501. //Else if it's a secret->shutter set the secret screen state to false.
  502. else if(type == 3) Screen->State[ST_SECRET] = false;
  503. //Open the shutter, copy and pasted from above.
  504. int comboLoc = ComboAt(this->X, this->Y);
  505. if(dir == 0 || big) comboLoc -= 16;
  506. if(dir == 2) comboLoc -= 1;
  507. for(int i; i < 2; i++){
  508. for(int j; (big && j < 3) || j < 2; j++){
  509. int combo = comboLoc + i + (16 * j);
  510. Screen->ComboD[combo] += offset;
  511. }
  512. }
  513. //Lastly play the shutter sound since it just opened.
  514. Game->PlaySound(SFX_SHUTTER);
  515. }
  516. //This function checks if link is in the doorway.
  517. bool InDoorway(ffc this, int dir){
  518. //Simply check link's position relative to the number and the location of the ffc.
  519. if(dir == 0) return(Link->X == this->X && Link->Y < 32);
  520. else if(dir == 1) return(Link->X == this->X && Link->Y > 128);
  521. else if(dir == 2) return(Link->Y == this->Y && Link->X < 32);
  522. else if(dir == 3) return(Link->Y == this->Y && Link->X > 208);
  523. }
  524. //This function check if all enemies have been defeated as if it was a normal shutter room.
  525. bool NoEnemies(){
  526. //Initialize a boolean as true.
  527. bool condition = true;
  528. //Loop through every npc.
  529. for(int i = Screen->NumNPCs(); i > 0; i--){
  530. //Load each npc to a pointer.
  531. npc n = Screen->LoadNPC(i);
  532. //Continue if the enemy is a item fairy.
  533. if(n->ID == NPC_ITEMFAIRY) continue;
  534. //Continue if the enemy has the "Doesn't count as beatable enemy" flag.
  535. else if(GetNPCMiscFlag(n, 8)) continue;
  536. //Since a beatable enemy exists, set condition to false and break out of the loop.
  537. condition = false;
  538. break;
  539. }
  540. return condition;
  541. }
  542. //This function returns the number of combos with push _ trigger flags.
  543. int NumBlocks(){
  544. //Declare the blocks variable.
  545. int blocks;
  546. //Loop through all 176 combos.
  547. for(int i; i < 176; i++){
  548. //If the inherited or placement flag is 1, 2, or 47 - 51 increment blocks.
  549. if(ComboFI(i, 1)) blocks++;
  550. else if(ComboFI(i, 2)) blocks++;
  551. else if(ComboFI(i, 47)) blocks++;
  552. else if(ComboFI(i, 48)) blocks++;
  553. else if(ComboFI(i, 49)) blocks++;
  554. else if(ComboFI(i, 50)) blocks++;
  555. else if(ComboFI(i, 51)) blocks++;
  556. }
  557. //Return the blocks variable.
  558. return blocks;
  559. }
  560. }
  561.  
  562. ffc script Bombable{
  563. void run(int dir, int offset, int adjacent, int dustdata, int dustloc, bool big){
  564. //Check if the wall was already bombed by checking screen d bit (dir) on register 0.
  565. if(GetScreenDBit(0, dir)){
  566. //Open a hole in the wall, copy and pasted from above.
  567. int comboLoc = ComboAt(this->X, this->Y);
  568. if(dir == 0 || big) comboLoc -= 16;
  569. if(dir == 2) comboLoc -= 1;
  570. for(int i; i < 2; i++){
  571. for(int j; (big && j < 3) || j < 2; j++){
  572. int combo = comboLoc + i + (16 * j);
  573. Screen->ComboD[combo] += offset;
  574. }
  575. }
  576. //Change the ffc's data to dustdata and reposition it.
  577. this->Data = dustdata;
  578. this->X = ComboX(dustloc);
  579. this->Y = ComboY(dustloc);
  580. //Check if Link is in the doorway.
  581. if(InDoorway(this, OppositeDir(dir), big)){
  582. //The following is copy and pasted from the shutter script.
  583. do{
  584. Waitframe();
  585. } while(Link->Action == LA_SCROLLING);
  586. while(InDoorway(this, dir, big)){
  587. NoAction();
  588. if(dir%4 == 0) Link->InputDown = true;
  589. else if(dir%4 == 1) Link->InputUp = true;
  590. else if(dir%4 == 2) Link->InputRight = true;
  591. else if(dir%4 == 3) Link->InputLeft = true;
  592. Waitframe();
  593. }
  594. }
  595. //Since there's nothing else to do end the script.
  596. Quit();
  597. }
  598. //Declare the bombed variable.
  599. bool bombed;
  600. //Loop until bombed becomes true.
  601. while(!bombed){
  602. //Loop through each lweapon on screen.
  603. for(int i = Screen->NumLWeapons(); i > 0 && !bombed; i--){
  604. //Load the lweapon to a pointer.
  605. lweapon l = Screen->LoadLWeapon(i);
  606. //If the weapon is not a bomb blast or super bomb blast end this iteration of the loop.
  607. if(l->ID != LW_BOMBBLAST && l->ID != LW_SBOMBBLAST) continue;
  608. //If collision for the weapon is on and it collided with the ffc set bombed to true.
  609. if(Collision(this, l) && l->CollDetection) bombed = true;
  610. }
  611. Waitframe();
  612. }
  613. //copy and pasted from locked script.
  614. int comboLoc = ComboAt(this->X, this->Y);
  615. if(dir == 0 || big) comboLoc -= 16;
  616. if(dir == 2) comboLoc -= 1;
  617. for(int i; i < 2; i++){
  618. for(int j; (big && j < 3) || j < 2; j++){
  619. int combo = comboLoc + i + (16 * j);
  620. Screen->ComboD[combo] += offset;
  621. }
  622. }
  623. //copy and pasted from above.
  624. this->Data = dustdata;
  625. this->X = ComboX(dustloc);
  626. this->Y = ComboY(dustloc);
  627. //Set the screen D bit for (dir) on register 0.
  628. SetScreenDBit(0, dir, true);
  629. //Set the screen D bit for the adjacent screen.
  630. SetScreenDBit(adjacent, 0, AdjacentDir(dir), true);
  631. }
  632. //Function copy and pasted from shutter script.
  633. bool InDoorway(ffc this, int dir, bool big){
  634. int mod = 0;
  635. if(dir < 2 || !big) mod = 8;
  636. if(dir == 0) return(Link->X == this->X+mod && Link->Y < 32);
  637. else if(dir == 1) return(Link->X == this->X+mod && Link->Y > 128);
  638. else if(dir == 2) return(Link->Y == this->Y+mod && Link->X < 32);
  639. else if(dir == 3) return(Link->Y == this->Y+mod && Link->X > 208);
  640. }
  641. //Function copy and pasted from locked script.
  642. int AdjacentDir(int dir){
  643. int i;
  644. for(; dir >= 4; i++) dir -= 4;
  645. dir = OppositeDir(dir);
  646. dir += (i*4);
  647. return dir;
  648. }
  649. }
  650.  
  651. //===================Shooter==========================
  652. // FFC Script to Fire EWeapons at Link at certain speeds and intervals
  653. // d0 = The weapon ID to fire. Can use EW_ constants or... (DEFAULT: fireball)
  654. // 0 = Fireball
  655. // 1 = Boss fireball
  656. // 2 = Rock
  657. // 3 = Fire (short distance)
  658. // 4 = Fire (long distance)
  659. // 5 = Wind
  660. // 6 = Bomb
  661. // d1 = Direction to fire in. For DIR_ constants, add 1 to them (DEFAULT: at link)
  662. // 0 = At Link
  663. // 1 = Up
  664. // 2 = Down
  665. // 3 = Left
  666. // 4 = Right
  667. // 5 = Left Up
  668. // 6 = Right Up
  669. // 7 = Left Down
  670. // 8 = Right Down
  671. // d2 = Frequency (60 is about 1 second) (DEFAULT: 120)
  672. // d3 = Speed (100 = 60 pixels a second) (DEFAULT: 100)
  673. // d4 = Damage (DEFAULT: 1)
  674. // d5 = Sound effect (DEFAULT: SFX_FIREBALL)
  675. // d6 = Initial Delay before firing
  676. // d7 = Flags
  677. // 1 = Unblockable
  678. // 2 = Stops when the FFC's combo changes
  679. // 3 = Unblockable and stops when the FFC's combo changes
  680. ffc script ffcShooter
  681. {
  682. void run(int weaponID, int dir, int frequency, int speed, int damage, int soundeffect, int initDelay, int flags)
  683. {
  684.  
  685. // Create defaults for weapon IDs
  686. if(weaponID == 0)
  687. weaponID = EW_FIREBALL;
  688. else if(weaponID == 1)
  689. weaponID = EW_FIREBALL2;
  690. else if(weaponID == 2)
  691. weaponID = EW_ROCK;
  692. else if(weaponID == 3)
  693. weaponID = EW_FIRE;
  694. else if(weaponID == 4)
  695. weaponID = EW_FIRE2;
  696. else if(weaponID == 5)
  697. weaponID = EW_WIND;
  698. else if(weaponID == 6)
  699. weaponID = EW_BOMB;
  700.  
  701. // Create defaults for other values
  702. if(frequency == 0)
  703. frequency = 120;
  704. if(speed == 0)
  705. speed = 100;
  706. if(damage == 0)
  707. damage = 1;
  708. if(soundeffect == 0)
  709. soundeffect = SFX_FIREBALL;
  710.  
  711. int counter = 0;
  712. int startingCombo = this->Data;
  713.  
  714. // Delay for the initial amount of time
  715. Waitframes(initDelay);
  716.  
  717. // Continue forever if it's not set to end when the combo change... or end if the combo changed
  718. while(flags <= 1 || this->Data == startingCombo)
  719. {
  720.  
  721. if(counter == 0)
  722. {
  723.  
  724. // Play the sound effect
  725. if(soundeffect > 0)
  726. Game->PlaySound(soundeffect);
  727.  
  728. // Here we go ahead and create the weapon
  729. eweapon weapon = Screen->CreateEWeapon(weaponID);
  730. weapon->X = this->X + this->EffectWidth/2 - 8;
  731. weapon->Y = this->Y + this->EffectHeight/2 - 8;
  732. weapon->Damage = damage;
  733. weapon->Step = speed;
  734.  
  735. // If no proper direction was set, have it fire at Link
  736. if(dir < 1 || dir > 9)
  737. {
  738. weapon->Angular = true;
  739. weapon->Angle = RadianAngle(this->X + this->EffectWidth/2 - 8, this->Y + this->EffectHeight/2 - 8, Link->X+8, Link->Y+8);
  740. weapon->Dir = RadianAngleDir8(weapon->Angle);
  741. }
  742. // Else a proper direction was set, so set it to that
  743. else
  744. weapon->Dir = dir-1;
  745.  
  746. // Up the weapon's dir if it was set as unblockable
  747. if(flags == 1 || flags == 3)
  748. weapon->Dir += 8;
  749. }
  750.  
  751.  
  752. counter = (counter+1)%frequency;
  753. Waitframe();
  754. } //! End of while(flags <= 1 || this->Data == startingCombo)
  755. } //! End of void run(int weaponID, int dir, int frequency, int speed, int damage, int soundeffect, int initDelay, int flags)
  756. } //! End of ffc script ffcShooter
  757.  
  758.  
  759. //================Holelava=FFC=Script=======================
  760. ffc script Holelava
  761. {
  762. void run(int warp, bool position, int damage)
  763. {
  764. while(true)
  765. {
  766. while(!Warping) Waitframe();
  767. if(warp > 0)
  768. {
  769. this->Data = CMB_AUTOWARP+warp-1;
  770. this->Flags[FFCF_CARRYOVER] = true;
  771. Waitframe();
  772. this->Data = FFCS_INVISIBLE_COMBO;
  773. this->Flags[FFCF_CARRYOVER] = false;
  774. Link->Z = Link->Y;
  775. Warping = false;
  776. Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  777. Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  778. Quit();
  779. }
  780. if(position)
  781. {
  782. Link->X = this->X;
  783. Link->Y = this->Y;
  784. }
  785. else
  786. {
  787. Link->X = this->InitD[6];
  788. Link->Y = this->InitD[7];
  789. }
  790. if(damage)
  791. {
  792. Link->HP -= damage;
  793. Link->Action = LA_GOTHURTLAND;
  794. Link->HitDir = -1;
  795. Game->PlaySound(SFX_OUCH);
  796. }
  797. Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
  798. Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
  799. Warping = false;
  800. Waitframe();
  801. }
  802. }
  803. }
  804.  
  805. //Used to determine if Link is on a Pit or Lava combo.
  806. int OnPitCombo()
  807. {
  808. int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
  809. if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
  810. return 0;
  811. else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
  812. return Screen->ComboI[comboLoc];
  813. else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
  814. return Screen->ComboF[comboLoc];
  815. else
  816. return 0;
  817. }
  818.  
  819.  
  820. //Snaps Link to the combo so he appears completely over pit and lava combos.
  821. void SnaptoGrid()
  822. {
  823. int x = Link->X;
  824. int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
  825. int comboLoc = ComboAt(x, y);
  826.  
  827. //X Axis
  828. if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  829. Link->X = ComboX(comboLoc);
  830. else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  831. Link->X = ComboX(comboLoc+1);
  832. if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  833. Link->X = ComboX(comboLoc+16);
  834. else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  835. Link->X = ComboX(comboLoc+17);
  836.  
  837. //Y Axis
  838. if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
  839. Link->Y = ComboY(comboLoc);
  840. else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
  841. Link->Y = ComboY(comboLoc+16);
  842. if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
  843. Link->Y = ComboY(comboLoc+1);
  844. else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
  845. Link->Y = ComboY(comboLoc+17);
  846. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement