Jump to content

Photo

Making an FFC script do something when Link leaves the screen


  • Please log in to reply
10 replies to this topic

#1 UninspiredUsername404

UninspiredUsername404

    Newbie

  • Members

Posted 12 April 2014 - 11:26 PM

Basicly I need to make an FFC script execute some code (specifically set Link's health to a variable set earlier) when Link leaves the screen, when the FFC is no longer on the screen that Link is on, or something else along those lines. I've been trying to do it for two hours and I can't think of anyway to do it that could actually work, save for putting FFCs with the necessary scripts on every screen adjacent to this one (but that just seems dumb). 

 

Forgive me if my explanation isn't very helpful, I'm very tired.



#2 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 April 2014 - 11:41 PM

Unfortunately, FFC scripts stop when Link leaves the screen. Seems you will need to a) Put FFCs on adjacent screens like you said, or b) Do something with a global script.



#3 UninspiredUsername404

UninspiredUsername404

    Newbie

  • Members

Posted 12 April 2014 - 11:49 PM

I was actually trying to find a way to do it with global scripts, but I couldn't find a way for it to tell if the script stopped, or if Link left the screen, or if there was an FFC with that script running or not, or whatever. Sigh... I've been noticing that with zscript, you need to find a stupid hacky workaround for EVERYTHING you try to do with it.



#4 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 April 2014 - 11:55 PM

Sigh... I've been noticing that with zscript, you need to find a stupid hacky workaround for EVERYTHING you try to do with it.

 

Welcome to ZScript!

 

What exactly are you trying to accomplish?


  • Russ likes this

#5 UninspiredUsername404

UninspiredUsername404

    Newbie

  • Members

Posted 13 April 2014 - 12:07 AM

Basically, a """monster""" that seriously screws with Link's everything, then sets it all back to normal if a) Link leaves the screen, or b) the screen secret is triggered (this is done by setting the kill all enemies -> secret flag and having Link kill his "minions".) Because the monster is a wizard with magic and stuff.


Edited by UninspiredUsername404, 13 April 2014 - 12:08 AM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 13 April 2014 - 02:40 AM

Oh, that's much easier. If all you want to do is change things while Link is on a screen, just make a while loop on the FFC:

while (this->isValid)
or
while(true)

Place the effects that you want the monster to cause inside the loop. Because those effects are only live while the FFC is valid, or active, under the conditions that you present, they will only work on that screen (where you place the FFC. You can tie them into enemy death too, so that if Link kills the creature causing them, the spell on him ends, even if he remains on that screen.

Because when Link leaves the screen, the effects of the FFc are no longer working, Link will return to his normal state.

#7 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 13 April 2014 - 05:49 AM

Sure, this can probably be done; albeit in, as you said, a hackish way.

Have an FFC on both (or all adjacent) screens. The one the player enters first, before leaving it, will set an internal D variable to 1. Then when he leaves, the FFC on that screen has a script that checks whether that first D Variable on that screen has the D Variable set. If it does, it does all the effects described above.

#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 13 April 2014 - 10:21 AM

Sure, this can probably be done; albeit in, as you said, a hackish way.

Have an FFC on both (or all adjacent) screens. The one the player enters first, before leaving it, will set an internal D variable to 1. Then when he leaves, the FFC on that screen has a script that checks whether that first D Variable on that screen has the D Variable set. If it does, it does all the effects described above.

 

You don;t need anything like that. The OP really wants the FFC to create effects while Link is on screens with specific creatures, not when actually leaving a screen. It's pretty straightforward to make an FFC affect Link while it is true, and as soon as Link leaves the screen, the effect can become un-true.

 

If you want to go further, you can create global variables, in boolean form, or as ints, and then use the FFCs to change their global value, until something else changes them again. you could, for example, make an FFC that disables certain items, setting them to false.

 

If you do this, you want to ensure that you create a marker that indicates if they were true before, and that they were set to false by a specific effect. Then, you can have a second FFC that checks to see if that effect set anything to false, and resets it to true; but if it was not set to false by that effect (because your boolean flag isn;t set to true), then it doesn't make it true. (This prevents giving Link items that he didnlt have, if he encounters the screens that set it back to true.)

 

@UninspiredUsername404: I could probably make this for you pretty easily. If you specify exactly what effects you want, I can work on it sometime in the next few days. What you want is an FFC that changes certain attributes when Link is on the same screen, but when Link leaves the screen, or performs a certain action,. the effect ends. That works best with a while(this->isValid) loop, because you can create an event that removes the FFC within that FFC, so you only need to put one FFC on a screen to achieve the entire effect, and only on screens where that effect should happen. You do not need to put FFCs on adjacent screens to achieve this goal: One FFC can achieve all of what you want to do.

 

You could tie the FFC to the enemy, or a list of enemies, with if statements; or to other conditions, with if statements. I have some things set up like this in my projects, which are rather close to what you are describing, but I haven;t had the time to finish them, because the major components (the effects that the FFC will trigger) are unfinished.

 

If the actual effects that you want to cause to happen to Link are complex, it will take longer, but if it;s something simple, like setting items to false, then I can provide you with everything you will need, and of course, you can expand on it later. Send me a PM if you want me to lend you a hand.

 

If you want to tie the effect to an enemy being on the screen, I can easily ensure that the enemy is set in the FFC arguments, so that you can recycle it for multiple enemies, with different effects. I can further make the actual effects selectable with arguments, reducing your code overhead to one script.

 

Otherwise, if you want to handle this on your own, that's fine too.



#9 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 13 April 2014 - 10:48 AM

FFC/Global partial code:

int savedHP = -1; //Global variable
 
//FFC SCRIPT
savedHP = Link->HP;
{whatever else you want}
 
//GLOBAL SCRIPT
if(savedHP > 0 && !ffcOnScreen()){
    Link->HP = savedHP;
    savedHP = -1;
}
 
bool ffcOnScreen(){
    int scriptName[] = "hpChanger"; //The name of the FFC script above
    int scriptNum = Game->GetFFCScript(scriptName);
    for(int i = 1; i <= 32; i++){
        ffc f = Screen->LoadFFC(i);
        if(f->Script = scriptNum)
            return true;
    return false;
}


#10 UninspiredUsername404

UninspiredUsername404

    Newbie

  • Members

Posted 13 April 2014 - 02:55 PM

I can't get this to work. Mostly because I can't figure out how to remove an FFC (ZC wiki being helpful as always >_<) and setting an FFC's script to 0 does nothing.

 

I don't even know why I'm doing this. I started working on this as practice for zscript, and I've just been trying to get it working out of spite.

 

 

Edit: It also doesn't work if Link walks off screen, what gives!


Edited by UninspiredUsername404, 13 April 2014 - 03:31 PM.


#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 14 April 2014 - 07:06 AM

Without seeing what you've done, we really can;t debug it. If you post the code, someone can tell you what you're doing wrongly. (Be sure to enclose it in 'code' tags.)

What you want here is something like this:
 
ffc script enemyModifiesLink{
    void run(int enemy) {
        bool exists = true;
        while (exists) {
            for(int i = 1; i < Screen->NumNPCs(); i++)
            { 
                npc enem = Screen->LoadNPC(i);
                if(enem->ID == enemy) { 
                    //Do these things
                    }
                
                else {
                    exists = false;
                    this->Data = 0;
                    return;
                }
            }
            Waitframe();
        }
    }
}        
Untested, but should work.

Edited by ZoriaRPG, 14 April 2014 - 07:20 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users