Jump to content

Photo

Scripted triggers


  • Please log in to reply
2 replies to this topic

#1 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 23 April 2017 - 02:17 PM

So, yeah, a few years back, I had asked for a generic trigger for some of my weapons (I think it was grayswandir that provided it), and it's been hella useful for scripted weapons, but I I never needed it for anything other than weapons, and now I do. Specifically, what it does is change a combo on the screen if a specific LWeapon comes in contact with it, but I was trying to make a second level Whistle, that would be able to trigger secrets that the normal built-in whistle can't I kinda understand how it works, but I'm not sure what to change so that it can trigger by standing on the ffc and using it rather than hitting the ffc with a weapon:

ffc script Trigger {
  void run(int fromCombo, int toCombo, int itemNo) {
    int loc = ComboAt(this->X + 8, this->Y + 8);
    int underCombo = Screen->ComboD[loc];
 
    // Wait until
    while (// We're hit by the right item type, or
           !CollisionAllLWeapon(this, LWEAPON_MISC_SOURCE, itemNo) &&
           // The combo on layer 0 changes.
           Screen->ComboD[loc] == underCombo) {
      Waitframe();}
 
    // Cancel out if the underlying combo changed.
    if (Screen->ComboD[loc] != underCombo) {
      return;}
 
    // Otherwise, we were hit by the item, so change the combos on screen.
    for (int i = 0; i < 176; i++) {
      if (Screen->ComboD[i] == fromCombo) {
        Screen->ComboD[i] = toCombo;}}}}

Any advice on how to change it would be much appreciated, cuz I'm pretty certain it CAN be used, just not quite sure how to do it.

 

EDIT: Actually, what would *really* be nice would be if it could have an extra 2 arguments, so that I can use just the one script, making it a pretty much perfect generic trigger for all purposes, one to determine if you need to strike the trigger (what it already does) or if you need to stand on it, and one for any items you have to have in your inventory in order to use it. I've pretty much abandoned the idea of making a custom whistle, but since the songs were such a big part of OoT, I could make them into passive equipment items that open up the path to the dungeon (like making the Hookshot targets at  the forest temple appear) when you activate the FFC trigger, plus it would solve a problem I've been having with how to make Zelda into more than a skippable exposition dump.


Edited by Binx, 23 April 2017 - 02:41 PM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 29 April 2017 - 04:28 PM

You want the item to change combos if Link uses it while standing on an ffc, or just on a specific combo?

I would run this from the item script:

item script whistle2{
    void run(int check_for_combo) {
        if ( ComboAt(Link->X, Link->Y) == check_for_combo ) { 
            //Do effect.
        }
    }
}
You can check if Link is standing on an ffc, as well, that has its own script.

item script whistle2{
    void run(int check_for_combo, int ffc_script, int standing_required) {
        ffc f;
        for ( int q = 1; q <= 32; q++ ) {
            f = Screen->LoadFFC(q); //Load every ffc on the screen
                if ( standing_required && DistXY(f, 3) ) { //If Link is reasonably standing on it, and we require him to do thus. 
                    if ( f->Data == check_for_combo && f->Script == ffc_script) { //...and it has the correct combo and script
                    //Do effects, possibly send a signal to a misc slot of that ffc
                    //so that the ffc does what you want. 
                    //e.g. f->Misc[15] = 20; //Tell the ffc that the whistle 2 was used on it. 
                    //In the ffc script for this ffc, if its Misc[15] == 20, it is ready to do the special effects. 
                    //You can set it up with while(this->Misc[15] != 20 ) Waitframe(); to wait until it receives the signal. 
                }
            }
        }
    }
}

  • Binx likes this

#3 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 29 April 2017 - 05:39 PM

Oh, right I forgot to say I already figured it out (with lots of help). I made individual songs, rather than using the default whistle.
item script SONG_OBSTACLE
{
    void run (int SFX, int Combo1, int Combo2, int Combo3, int Combo4, int Combo5, int Combo6, int FreezeTime)
    {
        int Song_Obstacle[] = "Song_Obstacle";
        int Args[8] = {SFX, Combo1, Combo2, Combo3, Combo4, Combo5,Combo6, FreezeTime};
        RunFFCScript(Game->GetFFCScript(Song_Obstacle), Args);
    }
}

ffc script Song_Obstacle
{
    void run (int SFX, int Combo1, int Combo2, int Combo3, int Combo4, int Combo5, int Combo6, int FreezeTime)
{
ScreenFreeze();
Game->PlaySound(SFX);
Waitframes(FreezeTime);
ScreenUnfreeze();
if (Screen->ComboT[ComboAt(Link->X+8, Link->Y+8)] == CT_SCRIPT5)
{
  for (int i = 0; i < 176; i++) 
{
    
  if (Screen->ComboD[i] == Combo1) 
  {
        Screen->ComboD[i] = Combo2;
        Game->PlaySound(27);
  }       
  if (Screen->ComboD[i] == Combo3) 
  {
        Screen->ComboD[i] = Combo4;
        Game->PlaySound(27);
  }
  if (Screen->ComboD[i] == Combo5) 
  {
        Screen->ComboD[i] = Combo6;
        Game->PlaySound(27);
  }

}  
}
}
}


Also working on a version that warps Link, but I haven't done it yet, because I don't need it until after you get the Master Sword.

Edited by Binx, 29 April 2017 - 08:01 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users