Jump to content

Photo

Magnet Gloves


  • Please log in to reply
20 replies to this topic

#1 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 29 January 2018 - 09:06 PM

Hello everyone. I have a question for everyone. It's possible to make a Magnet Gloves scripts to make the same thing as Oracle of Seasons game ? Well because i think i'll use it in the quest and i was an idea for that it could be used for the Magnet Balls, Magnets blocks (for make Link move at the direction of the combo or of the opposate direction.), and for the Magnet Block 4 ways (that thing that if Link is enough closed of the combo he'll spin around of the combo depended of spin. like Oracle of Seasons function) I was an idea that would be useful against Darknut to steal the shields from them. (instead for destroy shield with hammer)



#2 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 11 February 2018 - 06:29 PM

Years ago I found such a script, but don't ask me, where I got it from, so I just copy and paste it from my personal script file. ^^

 

It works fine in my quest, but I changed a little bit of the script, so I have no idea, if this works in your script-file too. ;)

 

 

The script uses flag 97 (wich was unused at that time) for magnetic combos. But it shouldn't be too difficult to set it to another flag.

You have to create 2 items. One "positive charged glove" and one "negatic charged glove". They are set to item nr. 154 and 155 in my scriptfile.

It plays SFX nr. 93 constantly as long as you use the magnetic gloves.

//Input Constants Magnetic Gloves

bool magna_gloves_active = false;
bool magna_gloves_positive = false;

const int magna_flag = 97;
const int magna_positive = 155;

const int MAGNETIC_GLOVES_P = 154;
const int MAGNETIC_GLOVES_N = 155;


//Checks if either the positive or negative glove item is in Link's A Button slot
//and if he is pressing the A button.
bool MagnaA(){
  return ( (GetEquipmentA() == MAGNETIC_GLOVES_P || GetEquipmentA() == MAGNETIC_GLOVES_N) && Link->InputA );
}
 
//Checks if either the positive or negative glove item is in Link's B Button slot
//and if he is pressing the B button.
bool MagnaB(){
  return ( (GetEquipmentB() == MAGNETIC_GLOVES_P || GetEquipmentB() == MAGNETIC_GLOVES_N) && Link->InputB );
}




global script Slot_2{

    void run(){

        while(true){







            //Call Magnetic Gloves functions
            if(magna_gloves_active){
            MagnaGlovesWork();
            Game->PlaySound(93);
            }







	Waitframe();



        }               //end while(true)

    }                   //end voidrun

 }                      //end script







//Magnetic Gloves functions
  void MagnaGlovesWork() {
      if(MagnaA() || MagnaB() ){
      
      //Link->Action = LA_FROZEN;

        if(Screen->isSolid(Link->X+15, Link->Y+15)) {
	Link->InputUp = false;
	Link->InputDown = false;
	Link->InputLeft = false;
	Link->InputRight = false;
        }

        else if(Screen->isSolid(Link->X, Link->Y+15)) {
	Link->InputUp = false;
	Link->InputDown = false;
	Link->InputLeft = false;
	Link->InputRight = false;
        }
        
	else if(Screen->isSolid(Link->X+15, Link->Y+7)) {
	Link->InputUp = false;
	Link->InputDown = false;
	Link->InputLeft = false;
	Link->InputRight = false;
        }

        else if(Screen->isSolid(Link->X, Link->Y+7)) {
	Link->InputUp = false;
	Link->InputDown = false;
	Link->InputLeft = false;
	Link->InputRight = false;
        }

      int lc = 0;
      bool yes = false;
      
      
      if(Link->Dir == DIR_LEFT) {
        for(int i = Floor(Link->X / 16)  - 1; i >= 0; i--) {
          lc = ComboAt(i * 16, Link->Y + 8);
          if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
            yes = true;
            break;
          }
        }
        if(yes) {
          Link->Z = 5;
          Link->Jump = 0;
          Link->Y = Floor((Link->Y + 8) / 16) * 16;
          KillLinkInput();
          if(magna_gloves_positive) {
            if(!Screen->isSolid(Link->X + 16, Link->Y)) {
              Link->X += 1;
            }
            if(!Screen->isSolid(Link->X + 16, Link->Y)) {
              Link->X += 1;
            }
          } else {
            if(!Screen->isSolid(Link->X - 1, Link->Y)) {
              Link->X -= 1;
            }
            if(!Screen->isSolid(Link->X - 1, Link->Y)) {
              Link->X -= 1;
            }
          }
        }
      } else if(Link->Dir == DIR_RIGHT) {
        for(int i = Floor(Link->X / 16) + 1; i <= 16; i++) {
          lc = ComboAt(i * 16, Link->Y + 8);
          
          if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
            yes = true;
            break;
          }
        }
        if(yes) {
          Link->Z = 5;
          Link->Jump = 0;
          Link->Y = Floor((Link->Y + 8) / 16) * 16;
          KillLinkInput();
          if(magna_gloves_positive) {
            if(!Screen->isSolid(Link->X - 1, Link->Y)) {
              Link->X -= 1;
            }
            if(!Screen->isSolid(Link->X - 1, Link->Y)) {
              Link->X -= 1;
            }

          } else {
            if(!Screen->isSolid(Link->X + 16, Link->Y)) {
              Link->X += 1;
            }
            if(!Screen->isSolid(Link->X + 16, Link->Y)) {
              Link->X += 1;
            }
          }
          
        }
      } else if(Link->Dir == DIR_UP) {
        for(int i = Floor((Link->Y + 9) / 16) - 1; i >= 0; i--) {
          lc = ComboAt(Link->X + 8, i * 16);
          if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
            yes = true;
            break;
          }
        }
        if(yes) {
          Link->Z = 5;
          Link->Jump = 0;
          Link->X = Floor((Link->X + 8) / 16) * 16;
          KillLinkInput();
          if(!magna_gloves_positive) {
            if(!Screen->isSolid(Link->X, Link->Y - 1)) {
              Link->Y -= 1;
            }
            if(!Screen->isSolid(Link->X, Link->Y - 1)) {
              Link->Y -= 1;
            }
          } else {
            
            if(!Screen->isSolid(Link->X, Link->Y + 16)) {
              Link->Y += 1;
            }
            if(!Screen->isSolid(Link->X, Link->Y + 16)) {
              Link->Y += 1;
            }
          }
        }
      } else if(Link->Dir == DIR_DOWN) {
        for(int i = Floor(Link->Y / 16) + 1; i <= 16; i++) {
          lc = ComboAt(Link->X + 8, i * 16);
          
          if(Screen->ComboF[lc] == magna_flag || Screen->ComboI[lc] == magna_flag) {
            yes = true;
            break;
          }
        }
        if(yes) {
          Link->Z = 5;
          Link->Jump = 0;
          Link->X = Floor((Link->X + 8) / 16) * 16;
          KillLinkInput();
          if(!magna_gloves_positive) {
            if(!Screen->isSolid(Link->X, Link->Y + 16)) {
              Link->Y += 1;
            }
            if(!Screen->isSolid(Link->X, Link->Y + 16)) {
              Link->Y += 1;
            }
          } else {
            if(!Screen->isSolid(Link->X, Link->Y - 1)) {
              Link->Y -= 1;
            }
            if(!Screen->isSolid(Link->X, Link->Y - 1)) {
              Link->Y -= 1;
            }
          }
          
        }
      }
      
      if(!yes) {
        int d = Link->Dir;
        //well, we're not attached to anything.
        //so, let's move around
        if(Link->InputUp) {
          Link->InputUp = false;
          if(!Screen->isSolid(Link->X, Link->Y - 1)) Link->Y -= 1;
        }
        if(Link->InputDown) {
          Link->InputDown = false;
          if(!Screen->isSolid(Link->X, Link->Y + 16)) Link->Y += 1;
        }
        if(Link->InputLeft) {
          Link->InputLeft = false;
          if(!Screen->isSolid(Link->X - 1, Link->Y)) Link->X -= 1;
        }
        if(Link->InputRight) {
          Link->InputRight = false;
          if(!Screen->isSolid(Link->X + 16, Link->Y)) Link->X += 1;
        }
        //Link->Dir = d;
      }
    } else {
      magna_gloves_active = false;
      magna_gloves_positive = !magna_gloves_positive;
      //Link->Action = LA_NONE;
      Link->Item[magna_positive] = !Link->Item[magna_positive];
    }
 } 

  void KillLinkInput() {
    Link->InputUp = false;
    Link->InputDown = false;
    Link->InputLeft = false;
    Link->InputRight = false;
  }







 

Then there's an ffc-script for the iron ball:


//balls are negative
//they are also inert
ffc script IronBall {
  void run() {
    lweapon lw;
    while(true) {
      //we only need to care if the gloves are active
      if(magna_gloves_active) {
        //first, is link aligned with us?
        if((Link->X + 8 > this->X && Link->X + 8 < this->X + 16) || (Link->Y + 8 > this->Y && Link->Y + 8 < this->Y + 16)) {
          //yes he is!
          //is he facing us?
          int d = link_direction(this);
          if(d == DIR_LEFT && Link->Dir == DIR_RIGHT ||
             d == DIR_RIGHT && Link->Dir == DIR_LEFT ||
             d == DIR_UP && Link->Dir == DIR_DOWN ||
             d == DIR_DOWN && Link->Dir == DIR_UP) {
             
            //he is! But, we're not done yet...
            //is there a pole in the way?
            bool ok = true;
            if(d == DIR_LEFT) {
              for(int i = Floor(this->X / 16) - 1; i > Floor(Link->X / 16); i--) {
                if(Screen->ComboF[ComboAt(i * 16, this->Y)] == magna_flag || Screen->ComboI[ComboAt(i * 16, this->Y)] == magna_flag) {
                  ok = false;
                }
              }
            } else if(d == DIR_RIGHT) {
              for(int i = Floor(this->X / 16) + 1; i < Floor(Link->X / 16); i++) {
                if(Screen->ComboF[ComboAt(i * 16, this->Y)] == magna_flag || Screen->ComboI[ComboAt(i * 16, this->Y)] == magna_flag) {
                  ok = false;
                }
              }
            } else if(d == DIR_UP) {
              for(int i = Floor(this->Y / 16) - 1; i > Floor(Link->Y / 16); i--) {
                if(Screen->ComboF[ComboAt(this->X, i * 16)] == magna_flag || Screen->ComboI[ComboAt(this->X, i * 16)] == magna_flag) {
                  ok = false;
                }
              }
            } else if(d == DIR_DOWN) {
              for(int i = Floor(this->Y / 16) + 1; i < Floor(Link->Y / 16); i++) {
                if(Screen->ComboF[ComboAt(this->X, i * 16)] == magna_flag || Screen->ComboI[ComboAt(this->X, i * 16)] == magna_flag) {
                  ok = false;
                }
              }
            }
            
            if(ok) {
              //yes! we get to do something!
              if(d == DIR_UP) {
                //we need to align ourselves to Link
                moveH(Link->X - this->X, this);
                //... and either move towards him...
                if(magna_gloves_positive) {
                  if(this->Y > Link->Y + 17) moveV(-2,this);
                } else {
                  // or away from him
                  moveV(2, this);
                }
              } else if(d == DIR_DOWN) {
                moveH(Link->X - this->X, this);
                if(magna_gloves_positive) {
                  if(this->Y < Link->Y - 2) moveV(2, this);
                } else {
                  moveV(-2, this);
                }
              } else if(d == DIR_LEFT) {
                moveV(Link->Y - this->Y, this);
                if(magna_gloves_positive) {
                  if(this->X > Link->X + 17) moveH(-2, this);
                } else {
                  moveH(2, this);
                }
              } else if(d == DIR_RIGHT) {
                moveV(Link->Y - this->Y, this);
                if(magna_gloves_positive) {
                  if(this->X < Link->X - 2) moveH(2, this);
                } else {
                  moveH(-2, this);
                }
              }
              
              //also, we need to damage enemies. so, we'll spawn little lweapons that are invisible
              if(lw->isValid()) lw->DeadState = WDS_DEAD;
              
              lw = Screen->CreateLWeapon(LW_SCRIPT1);
              lw->X = this->X;
              lw->Y = this->Y;
              lw->Damage = 1;
              lw->OriginalTile = 74;
              lw->Tile = 74;
            } else {
              //well, that was a wasted effort.
            }
          }
        }
      }
      
      Waitframe();
    }
    
  }
  
  void moveV(int amt, ffc this) {
    if(amt == 0) return;
    if(amt < 0) {
      for(int i = 1; i <= Abs(amt); i++) {
        if(isSolid(this->X + 8, this->Y - 1) || isSolid(this->X + 12, this->Y - 1)) break;
        this->Y--;
      }
    } else {
      for(int i = 1; i <= amt; i++) {
        if(isSolid(this->X + 4, this->Y + 1 + 15) || isSolid(this->X + 12, this->Y + 1 + 15)) break;
        this->Y++;
      }
    }
  }
  
  void moveH(int amt, ffc this) {
    if(amt == 0) return;
    if(amt < 0) {
      for(int i = 1; i <= Abs(amt); i++) {
        if(isSolid(this->X - 1, this->Y + 4) || isSolid(this->X - 1, this->Y + 12)) break;
        this->X--;
      }
    } else {
      for(int i = 1; i <= amt; i++) {
        if(isSolid(this->X + 1 + 15, this->Y + 4) || isSolid(this->X + 1 + 15, this->Y + 12)) break;
        this->X++;
      }
    }
  }
  
  int link_direction(ffc this) {
    int d_x = this->X - Link->X;
    int d_y = this->Y - Link->Y;
    int a_x = Abs(d_x);
    int a_y = Abs(d_y);
    
    if(a_x <= a_y) {
      if(d_y >= 0) {
        return DIR_UP;
      } else {
        return DIR_DOWN;
      }
    } else {
      if(d_x >= 0) {
        return DIR_LEFT;
      } else {
        return DIR_RIGHT;
      }
    }
  }
}

 

 

 

And one for the rotating pole:



ffc script RotatingPole {
  void run() {
    while(true) {
      Waitframes(39);
      
      //now we rotate!
      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) {
        //link is to the right
        Link->X = this->X;
        Link->Y = this->Y + 16;
        Link->Dir = DIR_UP;
      } 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) {
        //link is to the left
        Link->X = this->X;
        Link->Y = this->Y - 16;
        Link->Dir = DIR_DOWN;
      } 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) {
        //link is to the top
        Link->Y = this->Y;
        Link->X = this->X + 16;
        Link->Dir = DIR_LEFT;
      } 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) {
        //link is to the bottom
        Link->Y = this->Y;
        Link->X = this->X - 16;
        Link->Dir = DIR_RIGHT;
      }
      
      Waitframes(9);
    }
  }
}


 

 

 

 

 

I hope, it works in your script file too. :D



#3 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 11 February 2018 - 06:39 PM

Alright i'll test it :)



#4 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 11 February 2018 - 06:55 PM

the script file works but the function is pretty wierd... do you have any exemple quest for that ?


Edited by Sans, 11 February 2018 - 09:11 PM.


#5 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 12 February 2018 - 06:20 AM

I made an enemy for the EotM Contest some time ago. You can test the scriptfile, because it uses the magnetic glove script. :)

 

 

https://www.mediafir...el_Magmatos.rar

 

 

Here's a video of the enemies of the contest:

 

https://www.youtube....IWw2EgKSI00KpWg

 

 

 

 

 

(Don't forget that you have to create a new "save-file" for your quest, after adding a global script! Otherwise most global scripts won't work.)


Edited by Rastael, 12 February 2018 - 06:27 AM.

  • judasrising likes this

#6 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 12 February 2018 - 08:56 AM

ok thanks but one more question: the iron balls will active the Blocs Triggers too ? exemple when the ball is in a switch ?

Edited by Sans, 12 February 2018 - 09:38 AM.


#7 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 12 February 2018 - 12:07 PM

I don't think so. I'm using the iron ball for fighting enemies.

 

Maybe you can use this script for triggers?

https://www.purezc.n...=scripts&id=303



#8 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 12 February 2018 - 12:27 PM

i'll give it a try then.



#9 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 12 February 2018 - 04:03 PM

Wait a minute. There's not the MagnaGloves item script for the script 



#10 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 12 February 2018 - 04:47 PM

Wait a minute. There's not the MagnaGloves item script for the script


item script MagnaGloves {
void run() {
magna_gloves_active = true;
}
}

#11 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 12 February 2018 - 04:50 PM

thanks in the good time :P however the magnetic gloves don't change the color and letter. And also the Iron Ball is not solid when i put it like the exemple quest.


Edited by Sans, 12 February 2018 - 07:13 PM.


#12 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 13 February 2018 - 01:26 AM

I'm sorry, I forgot the item script. I will put it here after work. :)

 

 

But I can't help you with your other Problems, because I'm not a Scripting-expert.



#13 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 13 February 2018 - 07:35 AM

item script MagnaGloves {
  void run() {
    magna_gloves_active = true;
  }
}

You have to asign that script to BOTH magnetic glove items. :)



#14 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 13 February 2018 - 10:46 AM

but that's what i did too. 



#15 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 13 February 2018 - 11:54 AM

Do they change from "positive" to "negativ" oder do they not change at all?

 

 

The iron balls in my quest are not solid too, I guess.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users