Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import "std.zh"
- import "string.zh"
- import "ffcscript.zh"
- // This script is a pickup script that will give some items.
- // This was mostly made to bundle the Bow and Arrows into one item,
- // but it could have other uses.
- // Bundle this with an item that increases a counter to also increase counters.
- // D0-D7: Items to give.
- // D0: If D0 is negative, it will display an item pickup message containing the positive version of the number entered...
- item script itemBundle{
- void run(int item1, int item2, int item3, int item4, int item5, int item6, int item7, int item8)
- {
- if(item1 > 0)
- Link->Item[item1] = true;
- if(item2 > 0)
- Link->Item[item2] = true;
- if(item3 > 0)
- Link->Item[item3] = true;
- if(item4 > 0)
- Link->Item[item4] = true;
- if(item5 > 0)
- Link->Item[item5] = true;
- if(item6 > 0)
- Link->Item[item6] = true;
- if(item7 > 0)
- Link->Item[item7] = true;
- if(item8 > 0)
- Link->Item[item8] = true;
- // Display Item pickup message?
- if(item1 < 0)
- {
- Screen->Message(item1 * -1);
- }
- }//!End void run()
- }//!End item script itemBundle
- ffc script Signpost{
- void run(int m,int input){
- int loc = ComboAt(this->X,this->Y);
- while(true){
- while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
- SetInput(input,false);
- Screen->Message(m);
- Waitframe();
- }
- }
- bool AgainstComboBase(int loc){
- return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
- }
- }
- //!!These functions should only be included in your script file once!!
- bool SelectPressInput(int input){
- if(input == 0) return Link->PressA;
- else if(input == 1) return Link->PressB;
- else if(input == 2) return Link->PressL;
- else if(input == 3) return Link->PressR;
- }
- void SetInput(int input, bool state){
- if(input == 0) Link->InputA = state;
- else if(input == 1) Link->InputB = state;
- else if(input == 2) Link->InputL = state;
- else if(input == 3) Link->InputR = state;
- }
- //===============Global=Variables=&=Constants===================
- const int SFX_GBSHIELD = 17; //Shield active SFX
- int shieldItem; //Shield item to give (set by item script, reset each frame)
- bool shieldButton; //False = B, True = A
- const int SCRIPT_BARRIERS = 2; // Must refer to "Barrier"'s ffc script slot in the quest
- // ID's of barrier-related combos
- // Barriers in raised state
- const int BARRIER_A_RAISED = 60;
- const int BARRIER_B_RAISED = 61;
- // Barriers in lowered state
- const int BARRIER_A_LOWERED = 62;
- const int BARRIER_B_LOWERED = 63;
- // Barriers animating to raised state
- const int BARRIER_A_ANIMRAISE = 64;
- const int BARRIER_B_ANIMRAISE = 65;
- // Barriers animating to lowered state
- const int BARRIER_A_ANIMLOWER = 66;
- const int BARRIER_B_ANIMLOWER = 67;
- // Raised barriers that Link can walk on
- const int BARRIER_A_WALKABLE = 68;
- const int BARRIER_B_WALKABLE = 69;
- // Barrier switches
- const int BARRIER_A_SWITCH = 70;
- const int BARRIER_B_SWITCH = 71;
- const int BARRIER_SWITCH_DUMMY = 177; // ID of a switch hit detection dummy enemy
- const int BARRIER_SWITCH_DUMMY_HP = 32767;
- // Global array to store the state of barriers per dmap
- // If you have more than 16 dmaps you can change the capacity in the []'s
- // You may change the states in other scripts, but the changes will not be visible
- // until there is a new screen, so set them before Barriers_NewScreen() is called.
- bool barriers[16]; // false = blue barriers raised, true = red barriers raised
- //Common Constant, only need to define once per script file.
- const int BIG_LINK = 0; //Set this constant to 1 if using the Large Link Hit Box feature.
- //Constants used by Bottomless Pits & Lava.
- const int CT_HOLELAVA = 128; //Combo type to use for pit holes and lava."No Ground Enemies by default"
- const int CF_PIT = 98; //The combo flag to register combos as pits.
- const int CF_LAVA = 99; //The combo flag to register combos as lava.
- const int WPS_LINK_FALL = 89; //The weapon sprite to display when Link falls into a pit. "Sprite 88 by default"
- const int WPS_LINK_LAVA = 90; //The weapon sprite to display when Link drowns in lava. "Sprite 89 by default"
- const int SFX_LINK_FALL = 38; //The sound to play when Link falls into a pit. "SFX_FALL by default"
- const int SFX_LINK_LAVA = 55; //The sound to play when Link drowns in Lava. "SFX_SPLASH by default.
- const int CMB_AUTOWARP = 48; //The first of your four transparent autowarp combos.
- const int HOLELAVA_DAMAGE = 8; //Damage in hit points to inflict on link. "One Heart Container is worth 16 hit points"
- //Global variables used by Bottomless Pits & Lava.
- int Falling;
- bool Warping;
- //=========Global=Script=====================================
- global script script2 {
- void run() {
- // Initialize variables used to listen on screen changes
- int curscreen = -1;
- bool shieldOn;
- //Initialize variables used to store Link's strating position on Screen Init.
- int olddmap = Game->GetCurDMap();
- int oldscreen = Game->GetCurDMapScreen();
- int startx = Link->X;
- int starty = Link->Y;
- int startdir = Link->Dir;
- //Clear global variables used by Bottomless pits.
- Falling = 0;
- Warping = false;
- while (true) {
- // Keep track of screen changes
- // Run a Barrier script on every screen change
- if (Game->GetCurScreen() != curscreen) {
- curscreen = Game->GetCurScreen();
- Barriers_NewScreen();}
- if( !shieldOn && shieldItem ){ //Enable shield when using dummy
- shieldOn=true; //Set shield state to on
- Link->Item[shieldItem]=true; //Give the shield
- Game->PlaySound(SFX_GBSHIELD); //Play the sound
- }
- else if( ( (shieldButton && !Link->InputA)||(!shieldButton && !Link->InputB)) //When button is released
- && shieldOn){ //And shield is still on
- Link->Item[shieldItem]=false; //Remove shield
- shieldItem = 0; //Reset shield item variable
- shieldOn = false; //Set shield state to off
- }
- {
- Waitdraw();
- if(Link->Action != LA_SCROLLING)
- {
- Update_HoleLava(startx, starty, olddmap, oldscreen, startdir);
- if(Link->Z==0 && !Falling && (oldscreen != Game->GetCurDMapScreen() || olddmap != Game->GetCurDMap()))
- {
- olddmap = Game->GetCurDMap();
- oldscreen = Game->GetCurDMapScreen();
- startx = Link->X;
- starty = Link->Y;
- startdir = Link->Dir;
- }
- }
- Waitframe();}}}
- // Function that makes preparations for barriers on each screen and starts an FFC script
- void Barriers_NewScreen() {
- // Search for a barrier-related combo
- for (int i = 0; i <= 175; i++) {
- int cd = Screen->ComboD[i];
- if (cd == BARRIER_A_RAISED || cd == BARRIER_A_LOWERED || cd == BARRIER_A_SWITCH ||
- cd == BARRIER_B_RAISED || cd == BARRIER_B_LOWERED || cd == BARRIER_B_SWITCH) {
- // A barrier-related combo was found
- // Make initial changes to combos
- if (barriers[Game->GetCurDMap()]) {
- for (int j = i; j <= 175; j++) {
- int cd = Screen->ComboD[j];
- if (cd == BARRIER_A_RAISED) Screen->ComboD[j] = BARRIER_A_LOWERED;
- else if (cd == BARRIER_B_LOWERED) Screen->ComboD[j] = BARRIER_B_RAISED;
- else if (cd == BARRIER_A_SWITCH) Screen->ComboD[j] = BARRIER_B_SWITCH;}}
- else {
- for (int j = i; j <= 175; j++) {
- int cd = Screen->ComboD[j];
- if (cd == BARRIER_B_RAISED) Screen->ComboD[j] = BARRIER_B_LOWERED;
- else if (cd == BARRIER_A_LOWERED) Screen->ComboD[j] = BARRIER_A_RAISED;
- else if (cd == BARRIER_B_SWITCH) Screen->ComboD[j] = BARRIER_A_SWITCH;}}
- // So run FFCscript to control barriers
- int args[] = {0,0,0,0,0,0,0,0};
- RunFFCScript(SCRIPT_BARRIERS, args);
- break;}
- }}
- // This lets you toggle barriers on any dmap
- bool ToggleBarriers(int dmap) {
- if (dmap == Game->GetCurDMap()) ToggleBarriers();
- else barriers[dmap] = !barriers[dmap];
- return barriers[dmap];}
- // This toggles barriers on the current dmap
- bool ToggleBarriers() {
- int curdmap = Game->GetCurDMap();
- if (!barriers[curdmap]) {
- barriers[curdmap] = true;
- for (int i = 0; i <= 175; i++) {
- int cd = Screen->ComboD[i];
- if (cd == BARRIER_A_RAISED || cd == BARRIER_A_WALKABLE || cd == BARRIER_A_ANIMRAISE) {
- Screen->ComboD[i] = BARRIER_A_ANIMLOWER;}
- else if (cd == BARRIER_B_LOWERED || cd == BARRIER_B_ANIMLOWER) {
- Screen->ComboD[i] = BARRIER_B_ANIMRAISE;}
- else if (cd == BARRIER_A_SWITCH) {Screen->ComboD[i] = BARRIER_B_SWITCH;}}}
- else {
- barriers[curdmap] = false;
- for (int i = 0; i <= 175; i++) {
- int cd = Screen->ComboD[i];
- if (cd == BARRIER_B_RAISED || cd == BARRIER_B_WALKABLE || cd == BARRIER_B_ANIMRAISE) {
- Screen->ComboD[i] = BARRIER_B_ANIMLOWER;}
- else if (cd == BARRIER_A_LOWERED || cd == BARRIER_A_ANIMLOWER) {
- Screen->ComboD[i] = BARRIER_A_ANIMRAISE;}
- else if (cd == BARRIER_B_SWITCH) {Screen->ComboD[i] = BARRIER_A_SWITCH;}}}
- return barriers[curdmap];
- }
- //Handles Pit Combo Functionality.
- void Update_HoleLava (int x, int y, int dmap, int scr, int dir)
- {
- lweapon hookshot = LoadLWeaponOf(LW_HOOKSHOT);
- if(hookshot->isValid()) return;
- if(Falling)
- {
- if(IsSideview()) Link->Jump=0;
- Falling--;
- if(Falling == 1)
- {
- int buffer[] = "Holelava";
- if(CountFFCsRunning(Game->GetFFCScript(buffer)))
- {
- ffc f = Screen->LoadFFC(FindFFCRunning(Game->GetFFCScript(buffer)));
- Warping = true;
- if(f->InitD[1]==0)
- {
- f->InitD[6] = x;
- f->InitD[7] = y;
- }
- }
- else
- {
- Link->X = x;
- Link->Y = y;
- Link->Dir = dir;
- Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
- Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
- Link->HP -= HOLELAVA_DAMAGE;
- Link->Action = LA_GOTHURTLAND;
- Link->HitDir = -1;
- Game->PlaySound(SFX_OUCH);
- if(Game->GetCurDMap()!=dmap || Game->GetCurDMapScreen()!=scr)
- Link->PitWarp(dmap, scr);
- }
- NoAction();
- Link->Action = LA_NONE;
- }
- }
- else if(Link->Z==0 && OnPitCombo() && !Warping)
- {
- Link->DrawXOffset += Cond(Link->DrawXOffset < 0, -1000, 1000);
- Link->HitXOffset += Cond(Link->HitXOffset < 0, -1000, 1000);
- int comboflag = OnPitCombo();
- SnaptoGrid();
- Game->PlaySound(Cond(comboflag == CF_PIT, SFX_LINK_FALL, SFX_LINK_LAVA));
- lweapon dummy = CreateLWeaponAt(LW_SCRIPT10, Link->X, Link->Y);
- dummy->UseSprite(Cond(comboflag == CF_PIT, WPS_LINK_FALL, WPS_LINK_LAVA));
- dummy->DeadState = dummy->NumFrames*dummy->ASpeed;
- dummy->DrawXOffset = 0;
- dummy->DrawYOffset = 0;
- Falling = dummy->DeadState;
- NoAction();
- Link->Action = LA_NONE;
- }
- }}
- //==============Barriers=FFC=Script=========================
- // This script controls barriers on the screen
- // The FFC is automatically created by Barriers_NewScreen()
- ffc script Barriers {
- void run() {
- // Initialize storage for bswitch hit dummies
- int bswitch_count;
- npc bswitch[8];
- for (int i = 0; i <= 175; i++) {
- if (Screen->ComboD[i] == BARRIER_A_SWITCH || Screen->ComboD[i] == BARRIER_B_SWITCH) {
- npc bs = CreateNPCAt(BARRIER_SWITCH_DUMMY, ComboX(i), ComboY(i));
- bs->HitWidth = 8; // Smaller hit box to avoid annoying collisions with Link
- bs->HitHeight = 8;
- bs->HP = BARRIER_SWITCH_DUMMY_HP;
- bswitch[bswitch_count++] = bs;}}
- // Change raised barriers to walkable ones if Link enters screen on a raised barrier
- int lcombo = LinkOnComboD();
- bool onbarrier = (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED);
- if (onbarrier) for (int i = 0; i < 176; i++) {
- if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
- else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}
- while (true) {
- // Detect hits on bswitches, and change combos accordingly
- for (int j = 0; j < bswitch_count; j++) {
- if (bswitch[j]->HP < BARRIER_SWITCH_DUMMY_HP) {
- bswitch[j]->HP = BARRIER_SWITCH_DUMMY_HP;
- ToggleBarriers();
- break;}} //break so that only one bswitch hit may register per frame
- // Make barriers walkable if Link is on raised barriers, or unwalkable if not
- lcombo = LinkOnComboD();
- if (!onbarrier && (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED)) {
- onbarrier = true;
- for (int i = 0; i <= 175; i++) {
- if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
- else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}}
- else if (onbarrier && !(lcombo == BARRIER_A_WALKABLE || lcombo == BARRIER_B_WALKABLE)) {
- onbarrier = false;
- for (int i = 0; i <= 175; i++) {
- if (Screen->ComboD[i] == BARRIER_A_WALKABLE) {Screen->ComboD[i] = BARRIER_A_RAISED;}
- else if (Screen->ComboD[i] == BARRIER_B_WALKABLE) {Screen->ComboD[i] = BARRIER_B_RAISED;}}}
- Waitframe();}
- }}
- // A utility function that returns the ID of the combo that Link appears to stand on
- int LinkOnComboD() {
- return Screen->ComboD[ComboAt(Link->X+8, Link->Y+13)];
- }
- //D0: "Real" shield item to give
- item script gbshield{
- void run ( int shield ){
- shieldItem = shield;
- if ( Link->PressB ) shieldButton = false;
- else if ( Link->PressA ) shieldButton = true;
- }
- }
- //=================Freeform=Doors=======================
- ffc script Locked{
- void run(int dir, int offset, int adjacent, bool boss, bool big){
- //Wait until the door is unlocked by Link if not already unlocked on screen init.
- while(!GetScreenDBit(0, dir) && !OpeningDoor(this, dir%4, boss)) Waitframe();
- //Initialize a variable as the location of combo the ffc is placed at.
- int comboLoc = ComboAt(this->X, this->Y);
- //Change the variable we just initialized according to the dir and big arguments.
- if(dir%4 == 0 || big) comboLoc -= 16;
- if(dir%4 == 2) comboLoc -= 1;
- //Loop through the horizontal combos.
- for(int i; i < 2; i++){
- //In each iteration of the loop, loop through the vertical combos.
- for(int j; (big && j < 3) || j < 2; j++){
- //Increment the combo data of the combo by the offset argument.
- int combo = comboLoc + i + (16 * j);
- Screen->ComboD[combo] += offset;
- }
- }
- //Check the screen D bit (dir) on register 0, and if it's already set skip the rest of the script.
- if(!GetScreenDBit(0, dir)){
- //It wasn't set which means Link just opened the door. So set it so it opens on screen init.
- SetScreenDBit(0, dir, true);
- //For back to back doors we need to set the screen bit on the adjacent screen.
- SetScreenDBit(adjacent, 0, AdjacentDir(dir), true);
- //If not a boss door subtract 1 key from Link's inventory.
- if(!boss){
- if(Game->LKeys[Game->GetCurLevel()] > 0) Game->LKeys[Game->GetCurLevel()]--;
- else Game->Counter[CR_KEYS]--;
- }
- //Lastly play a sound effect.
- Game->PlaySound(SFX_SHUTTER);
- }
- }
- //This function checks if link is trying to open the door, and meets the requirements to do so.
- bool OpeningDoor(ffc this, int dir, bool boss){
- //If a boss door and the player has no boss key return false;
- if(boss && !GetLevelItem(LI_BOSSKEY)) return false;
- //If not a boss door and the player has no keys return false;
- else if(!boss && Game->Counter[CR_KEYS] == 0 && Game->LKeys[Game->GetCurLevel()] == 0) return false;
- //Check if Link is near-centered with the door nonfacing central axis.
- else if(dir < 2 && Abs(Link->X - this->X) >= 4) return false;
- else if(dir >= 2 && Abs(Link->Y - this->Y) >= 4) return false;
- //Lastly return whether or not Link is next to the door and pushing against it.
- else if(dir == 0) return (Link->Y == this->Y + 8 && Link->InputUp);
- else if(dir == 1) return (Link->Y == this->Y - 16 && Link->InputDown);
- else if(dir == 2) return (Link->X == this->X + 16 && Link->InputLeft);
- else if(dir == 3) return (Link->X == this->X - 16 && Link->InputRight);
- }
- //This Function returns the direction of the adjacent screens locked door.
- int AdjacentDir(int dir){
- //We need a variable for both loops which is the number of doors
- int i;
- //dir%4 incrementing i by one each time we wrap.
- for(; dir >= 4; i++) dir -= 4;
- //Flip dir around so we have the opposite direction.
- dir = OppositeDir(dir);
- //Now add i4 to dir.
- dir += (i*4);
- //Lastly return dir.
- return dir;
- }
- }
- ffc script Shutter{
- void run(int dir, int offset, int type, bool oneway, bool big){
- //Check if Link is in the doorway.
- if(InDoorway(this, OppositeDir(dir))){
- //Link is in the doorway so open the shutter, copy & pasted from above.
- int comboLoc = ComboAt(this->X, this->Y);
- if(dir == 0 || big) comboLoc -= 16;
- if(dir == 2) comboLoc -= 1;
- for(int i; i < 2; i++){
- for(int j; (big && j < 3) || j < 2; j++){
- int combo = comboLoc + i + (16 * j);
- Screen->ComboD[combo] += offset;
- }
- }
- //Wait until the screen finishes scrolling.
- do{
- Waitframe(); //The scrolling doesn't start on screen init but one frame afterwards.
- } while(Link->Action == LA_SCROLLING);
- //Force Link into the room by nulling all controls accept the correct arrow key.
- while(InDoorway(this, dir)){
- NoAction();
- if(dir == 0) Link->InputDown = true;
- else if(dir == 1) Link->InputUp = true;
- else if(dir == 2) Link->InputRight = true;
- else if(dir == 3) Link->InputLeft = true;
- Waitframe();
- }
- //Close the shutter behind Link, copy & pasted from above.
- for(int i; i < 2; i++){
- for(int j; (big && j < 3) || j < 2; j++){
- int combo = comboLoc + i + (16 * j);
- Screen->ComboD[combo] -= offset;
- }
- }
- //Play the shutter sound effect.
- Game->PlaySound(SFX_SHUTTER);
- }
- //Otherwise wait a while. "Makes it so all shutters open simultaneously if the condition is fulfilled on screen init."
- else{
- do{
- Waitframe();
- } while(Link->Action == LA_SCROLLING);
- Waitframes(25);
- }
- //End the script here if it's a one way shutter.
- if(oneway) Quit();
- //Initialize blocks as the number of blocks on the screen.
- int blocks = NumBlocks();
- //Wait until the condition for opening the shutter is fulfilled.
- while(true){
- if(type == 0 && NoEnemies()) break;
- else if(type == 1 && NumBlocks() != blocks) break;
- else if(type == 2 && LastComboFlagOf(CF_BLOCKTRIGGER, 0) == -1) break;
- else if(type == 3 && Screen->State[ST_SECRET]) break;
- //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.
- Waitframe();
- }
- //If it's a block->shutter wait 20 frames.
- if(type == 1) Waitframes(20);
- //Else if it's a secret->shutter set the secret screen state to false.
- else if(type == 3) Screen->State[ST_SECRET] = false;
- //Open the shutter, copy and pasted from above.
- int comboLoc = ComboAt(this->X, this->Y);
- if(dir == 0 || big) comboLoc -= 16;
- if(dir == 2) comboLoc -= 1;
- for(int i; i < 2; i++){
- for(int j; (big && j < 3) || j < 2; j++){
- int combo = comboLoc + i + (16 * j);
- Screen->ComboD[combo] += offset;
- }
- }
- //Lastly play the shutter sound since it just opened.
- Game->PlaySound(SFX_SHUTTER);
- }
- //This function checks if link is in the doorway.
- bool InDoorway(ffc this, int dir){
- //Simply check link's position relative to the number and the location of the ffc.
- if(dir == 0) return(Link->X == this->X && Link->Y < 32);
- else if(dir == 1) return(Link->X == this->X && Link->Y > 128);
- else if(dir == 2) return(Link->Y == this->Y && Link->X < 32);
- else if(dir == 3) return(Link->Y == this->Y && Link->X > 208);
- }
- //This function check if all enemies have been defeated as if it was a normal shutter room.
- bool NoEnemies(){
- //Initialize a boolean as true.
- bool condition = true;
- //Loop through every npc.
- for(int i = Screen->NumNPCs(); i > 0; i--){
- //Load each npc to a pointer.
- npc n = Screen->LoadNPC(i);
- //Continue if the enemy is a item fairy.
- if(n->ID == NPC_ITEMFAIRY) continue;
- //Continue if the enemy has the "Doesn't count as beatable enemy" flag.
- else if(GetNPCMiscFlag(n, 8)) continue;
- //Since a beatable enemy exists, set condition to false and break out of the loop.
- condition = false;
- break;
- }
- return condition;
- }
- //This function returns the number of combos with push _ trigger flags.
- int NumBlocks(){
- //Declare the blocks variable.
- int blocks;
- //Loop through all 176 combos.
- for(int i; i < 176; i++){
- //If the inherited or placement flag is 1, 2, or 47 - 51 increment blocks.
- if(ComboFI(i, 1)) blocks++;
- else if(ComboFI(i, 2)) blocks++;
- else if(ComboFI(i, 47)) blocks++;
- else if(ComboFI(i, 48)) blocks++;
- else if(ComboFI(i, 49)) blocks++;
- else if(ComboFI(i, 50)) blocks++;
- else if(ComboFI(i, 51)) blocks++;
- }
- //Return the blocks variable.
- return blocks;
- }
- }
- ffc script Bombable{
- void run(int dir, int offset, int adjacent, int dustdata, int dustloc, bool big){
- //Check if the wall was already bombed by checking screen d bit (dir) on register 0.
- if(GetScreenDBit(0, dir)){
- //Open a hole in the wall, copy and pasted from above.
- int comboLoc = ComboAt(this->X, this->Y);
- if(dir == 0 || big) comboLoc -= 16;
- if(dir == 2) comboLoc -= 1;
- for(int i; i < 2; i++){
- for(int j; (big && j < 3) || j < 2; j++){
- int combo = comboLoc + i + (16 * j);
- Screen->ComboD[combo] += offset;
- }
- }
- //Change the ffc's data to dustdata and reposition it.
- this->Data = dustdata;
- this->X = ComboX(dustloc);
- this->Y = ComboY(dustloc);
- //Check if Link is in the doorway.
- if(InDoorway(this, OppositeDir(dir), big)){
- //The following is copy and pasted from the shutter script.
- do{
- Waitframe();
- } while(Link->Action == LA_SCROLLING);
- while(InDoorway(this, dir, big)){
- NoAction();
- if(dir%4 == 0) Link->InputDown = true;
- else if(dir%4 == 1) Link->InputUp = true;
- else if(dir%4 == 2) Link->InputRight = true;
- else if(dir%4 == 3) Link->InputLeft = true;
- Waitframe();
- }
- }
- //Since there's nothing else to do end the script.
- Quit();
- }
- //Declare the bombed variable.
- bool bombed;
- //Loop until bombed becomes true.
- while(!bombed){
- //Loop through each lweapon on screen.
- for(int i = Screen->NumLWeapons(); i > 0 && !bombed; i--){
- //Load the lweapon to a pointer.
- lweapon l = Screen->LoadLWeapon(i);
- //If the weapon is not a bomb blast or super bomb blast end this iteration of the loop.
- if(l->ID != LW_BOMBBLAST && l->ID != LW_SBOMBBLAST) continue;
- //If collision for the weapon is on and it collided with the ffc set bombed to true.
- if(Collision(this, l) && l->CollDetection) bombed = true;
- }
- Waitframe();
- }
- //copy and pasted from locked script.
- int comboLoc = ComboAt(this->X, this->Y);
- if(dir == 0 || big) comboLoc -= 16;
- if(dir == 2) comboLoc -= 1;
- for(int i; i < 2; i++){
- for(int j; (big && j < 3) || j < 2; j++){
- int combo = comboLoc + i + (16 * j);
- Screen->ComboD[combo] += offset;
- }
- }
- //copy and pasted from above.
- this->Data = dustdata;
- this->X = ComboX(dustloc);
- this->Y = ComboY(dustloc);
- //Set the screen D bit for (dir) on register 0.
- SetScreenDBit(0, dir, true);
- //Set the screen D bit for the adjacent screen.
- SetScreenDBit(adjacent, 0, AdjacentDir(dir), true);
- }
- //Function copy and pasted from shutter script.
- bool InDoorway(ffc this, int dir, bool big){
- int mod = 0;
- if(dir < 2 || !big) mod = 8;
- if(dir == 0) return(Link->X == this->X+mod && Link->Y < 32);
- else if(dir == 1) return(Link->X == this->X+mod && Link->Y > 128);
- else if(dir == 2) return(Link->Y == this->Y+mod && Link->X < 32);
- else if(dir == 3) return(Link->Y == this->Y+mod && Link->X > 208);
- }
- //Function copy and pasted from locked script.
- int AdjacentDir(int dir){
- int i;
- for(; dir >= 4; i++) dir -= 4;
- dir = OppositeDir(dir);
- dir += (i*4);
- return dir;
- }
- }
- //===================Shooter==========================
- // FFC Script to Fire EWeapons at Link at certain speeds and intervals
- // d0 = The weapon ID to fire. Can use EW_ constants or... (DEFAULT: fireball)
- // 0 = Fireball
- // 1 = Boss fireball
- // 2 = Rock
- // 3 = Fire (short distance)
- // 4 = Fire (long distance)
- // 5 = Wind
- // 6 = Bomb
- // d1 = Direction to fire in. For DIR_ constants, add 1 to them (DEFAULT: at link)
- // 0 = At Link
- // 1 = Up
- // 2 = Down
- // 3 = Left
- // 4 = Right
- // 5 = Left Up
- // 6 = Right Up
- // 7 = Left Down
- // 8 = Right Down
- // d2 = Frequency (60 is about 1 second) (DEFAULT: 120)
- // d3 = Speed (100 = 60 pixels a second) (DEFAULT: 100)
- // d4 = Damage (DEFAULT: 1)
- // d5 = Sound effect (DEFAULT: SFX_FIREBALL)
- // d6 = Initial Delay before firing
- // d7 = Flags
- // 1 = Unblockable
- // 2 = Stops when the FFC's combo changes
- // 3 = Unblockable and stops when the FFC's combo changes
- ffc script ffcShooter
- {
- void run(int weaponID, int dir, int frequency, int speed, int damage, int soundeffect, int initDelay, int flags)
- {
- // Create defaults for weapon IDs
- if(weaponID == 0)
- weaponID = EW_FIREBALL;
- else if(weaponID == 1)
- weaponID = EW_FIREBALL2;
- else if(weaponID == 2)
- weaponID = EW_ROCK;
- else if(weaponID == 3)
- weaponID = EW_FIRE;
- else if(weaponID == 4)
- weaponID = EW_FIRE2;
- else if(weaponID == 5)
- weaponID = EW_WIND;
- else if(weaponID == 6)
- weaponID = EW_BOMB;
- // Create defaults for other values
- if(frequency == 0)
- frequency = 120;
- if(speed == 0)
- speed = 100;
- if(damage == 0)
- damage = 1;
- if(soundeffect == 0)
- soundeffect = SFX_FIREBALL;
- int counter = 0;
- int startingCombo = this->Data;
- // Delay for the initial amount of time
- Waitframes(initDelay);
- // Continue forever if it's not set to end when the combo change... or end if the combo changed
- while(flags <= 1 || this->Data == startingCombo)
- {
- if(counter == 0)
- {
- // Play the sound effect
- if(soundeffect > 0)
- Game->PlaySound(soundeffect);
- // Here we go ahead and create the weapon
- eweapon weapon = Screen->CreateEWeapon(weaponID);
- weapon->X = this->X + this->EffectWidth/2 - 8;
- weapon->Y = this->Y + this->EffectHeight/2 - 8;
- weapon->Damage = damage;
- weapon->Step = speed;
- // If no proper direction was set, have it fire at Link
- if(dir < 1 || dir > 9)
- {
- weapon->Angular = true;
- weapon->Angle = RadianAngle(this->X + this->EffectWidth/2 - 8, this->Y + this->EffectHeight/2 - 8, Link->X+8, Link->Y+8);
- weapon->Dir = RadianAngleDir8(weapon->Angle);
- }
- // Else a proper direction was set, so set it to that
- else
- weapon->Dir = dir-1;
- // Up the weapon's dir if it was set as unblockable
- if(flags == 1 || flags == 3)
- weapon->Dir += 8;
- }
- counter = (counter+1)%frequency;
- Waitframe();
- } //! End of while(flags <= 1 || this->Data == startingCombo)
- } //! End of void run(int weaponID, int dir, int frequency, int speed, int damage, int soundeffect, int initDelay, int flags)
- } //! End of ffc script ffcShooter
- //================Holelava=FFC=Script=======================
- ffc script Holelava
- {
- void run(int warp, bool position, int damage)
- {
- while(true)
- {
- while(!Warping) Waitframe();
- if(warp > 0)
- {
- this->Data = CMB_AUTOWARP+warp-1;
- this->Flags[FFCF_CARRYOVER] = true;
- Waitframe();
- this->Data = FFCS_INVISIBLE_COMBO;
- this->Flags[FFCF_CARRYOVER] = false;
- Link->Z = Link->Y;
- Warping = false;
- Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
- Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
- Quit();
- }
- if(position)
- {
- Link->X = this->X;
- Link->Y = this->Y;
- }
- else
- {
- Link->X = this->InitD[6];
- Link->Y = this->InitD[7];
- }
- if(damage)
- {
- Link->HP -= damage;
- Link->Action = LA_GOTHURTLAND;
- Link->HitDir = -1;
- Game->PlaySound(SFX_OUCH);
- }
- Link->DrawXOffset -= Cond(Link->DrawXOffset < 0, -1000, 1000);
- Link->HitXOffset -= Cond(Link->HitXOffset < 0, -1000, 1000);
- Warping = false;
- Waitframe();
- }
- }
- }
- //Used to determine if Link is on a Pit or Lava combo.
- int OnPitCombo()
- {
- int comboLoc = ComboAt(Link->X+8, Link->Y + Cond(BIG_LINK==0, 12, 8));
- if(Screen->ComboT[comboLoc] != CT_HOLELAVA)
- return 0;
- else if(Screen->ComboI[comboLoc] == CF_PIT || Screen->ComboI[comboLoc] == CF_LAVA)
- return Screen->ComboI[comboLoc];
- else if(Screen->ComboF[comboLoc] == CF_PIT || Screen->ComboF[comboLoc] == CF_LAVA)
- return Screen->ComboF[comboLoc];
- else
- return 0;
- }
- //Snaps Link to the combo so he appears completely over pit and lava combos.
- void SnaptoGrid()
- {
- int x = Link->X;
- int y = Link->Y + Cond(BIG_LINK==0, 8, 0);
- int comboLoc = ComboAt(x, y);
- //X Axis
- if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
- Link->X = ComboX(comboLoc);
- else if(Screen->ComboT[comboLoc+1] == CT_HOLELAVA && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
- Link->X = ComboX(comboLoc+1);
- if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+16] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
- Link->X = ComboX(comboLoc+16);
- else if(Cond(y % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(x % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
- Link->X = ComboX(comboLoc+17);
- //Y Axis
- if(Screen->ComboT[comboLoc] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+16] != CT_HOLELAVA))
- Link->Y = ComboY(comboLoc);
- else if(Screen->ComboT[comboLoc+16] == CT_HOLELAVA && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc] != CT_HOLELAVA))
- Link->Y = ComboY(comboLoc+16);
- if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+1] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+17] != CT_HOLELAVA))
- Link->Y = ComboY(comboLoc+1);
- else if(Cond(x % 16 == 0, false, Screen->ComboT[comboLoc+17] == CT_HOLELAVA) && Cond(y % 16 == 0, true, Screen->ComboT[comboLoc+1] != CT_HOLELAVA))
- Link->Y = ComboY(comboLoc+17);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement