Jump to content

Photo

No-win battle


  • Please log in to reply
14 replies to this topic

#1 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 09 September 2010 - 09:37 PM

I'm working on my first original script: the No-Win-Battle Rescuer. Have an enemy that's just too tough? Want said enemy to leave you with a scathing monologue? Well, look no farther because this script (should) provide this!

Here's my code so far:
CODE
//==== * No-win battle * ===============================================
const int CMB_AUTOWARPA = 0; //Only include this once in the script file
ffc script NoWin {
    void run(int critical, int fail) {
    Waitframes(4);
    npc en = Screen->LoadNPC(1);
    int maxHP = en->HP;
        while(true) {
        en->HP = maxHP;
        if (Link->HP <= critical){
                Screen->Message(fail);
                Waitframe();
                this->Data = CMB_AUTOWARPA;
        }
            Waitframe();
        }
    }
}


CMB_AUTOWARPA is defined for another script, the play-message-then-warp script (which, by the way, I modified to optionally run only once per instance of the FFC).
Unfortunately, I get some error when I try to compile this... but the compile popup is so small I can only read the words "...File! Press a Key". This is the latest Windows build, by the way... anyone want to fix that?


Edit: Corrected by Plissken
Edit 2: Enemy regeneration provided by Blaman

Edited by MoscowModder, 26 September 2010 - 09:49 AM.


#2 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 09 September 2010 - 11:11 PM

CODE
ffc script NoWin {
    void run(int critical, int fail) {
        while(true) {
            if (Link->HP <= critical){
                Screen->Message(fail);
                Waitframe();
                this->Data = CMB_AUTOWARPA;
            }
            Waitframe();
        }
    }
}


The error was from the name, you can't put "-" in the script name. In order for this to work, I added a while loop around it so that it checks the status of Link's HP every frame, and not just the first frame you are on the screen (which is what happens if you don't have a while loop on an ffc script.) I got rid of the "else" portion because that is not needed. If you want to check an if statement, but don't need anything in an else section, just don't put an else section. Your second Waitframe(); was not needed the way you had it setup (because there was no while loop!) but it is needed with the while loop I added so I plopped it into the right spot. This script is unchecked, but I'm 99.99% sure it'll work as expected (.005% of that is if I'm understanding what you want it to do wrong, and the other .005% is that I'm an idiot and not catching a run time problem right now.)

EDIT: Forgot to put CMB_AUTOWARPA back in for you. I had replaced it with a simple int instead of creating that value to check the compile.

Edited by Plissken, 09 September 2010 - 11:12 PM.


#3 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 10 September 2010 - 12:34 AM

If you put '-' in a name the compiler will probably want to treat that as an unary minus operator. Names should not contain any special characters besides an underscore.

...
We should of made Waitframe() return true instead of void. :\ So you could do this:

CODE

while( Waitframe() )
{
}


Of course a for loop would be sufficient also:
CODE

for(;; Waitframe() )
{
  //script body
}

/rant icon_smile.gif

#4 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 10 September 2010 - 09:46 AM

Perfect, it works! For anyone who wants to use it, I pair it with my mod of the Message-then-warp script here:
CODE
//================Message then warp=================
const int CMB_AUTOWARPA = 63; //Only include this once in the script file
ffc script MessageWarp{
    void run(int m, int dly, int perm){ //Only set D2 if using One-time-only mod
    //if (Screen->D[perm] == 1){  One-time-only mod
    if (Screen->State[ST_SECRET] == 1){ //No warp after secret triggered mod
        WaitNoAction();
    }else{
        Waitframes(dly);
        Screen->Message(m);
        Waitframe();
        this->Data = CMB_AUTOWARPA;
        Screen->D[perm] = 1;
        }
}
}



Thanks Plissken and Gleeok!

P.S. Is anyone going to fix the tiny script compile window? This is on the latest Windows build in small view.

Edited by MoscowModder, 10 September 2010 - 09:48 AM.


#5 Plissken

Plissken

    What's with these homies dissing our girls?

  • Members

Posted 10 September 2010 - 10:02 AM

It's been fixed about 3 times but it always comes back. That bug has plagued me for ages in small mode. If I get a compile error I have to switch to large mode just to see the error. It effects windowed classic mode a different way for each magnification. For x3 it's that weird small window, for x4 its a tall, thin window on the left side of the screen. Last post from a dev about the subject was Gleeok at AGN with "I literally have no idea why this still happens."

No offense to you Gleeok, I completely trust that it is a strange, elusive, reoccurring bug.

#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 10 September 2010 - 06:49 PM

Funny thing is it was only actually "fixed" once. Every other time it just randomly and magically disappeared for a build. To put it another way; if that bug were a MTG card it would have phasing, invisibility, and could not be the target of spells or effects. icon_razz.gif


#7 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 24 September 2010 - 12:22 PM

I want to expand this script from a rescue to a true no-win battle. I want to add a line that sets the HP of the first enemy to its maximum every frame. How would I go about that?

#8 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 24 September 2010 - 12:59 PM

This wouldn't be hard to do; just have a variable that stores the enemies HP once it appears, then set its HP to it with this variable.

So something like...

CODE

Waitframes(4) //Put this in or it won't work.
npc en = Screen->LoadNPC(1);
int maxHP = en->HP;


...would go before the while loop.

CODE

en->HP = maxHP;


This would go inside the while loop.

#9 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 24 September 2010 - 01:41 PM

Thanks! Updated script in first post.

#10 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 25 September 2010 - 12:44 AM

So what is it exactly supposed to do?

#11 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 25 September 2010 - 01:21 AM

QUOTE(Lynker @ Sep 24 2010, 10:44 PM) View Post

So what is it exactly supposed to do?


It makes it so you can't win of course!...?!

No, it looks like it warps Link when his HP is low. (Enemy has full HP every frame)

#12 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 25 September 2010 - 09:20 AM

Oh, okay!

#13 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 25 September 2010 - 08:43 PM

Hmmm, interesting. I might use it for my WIP Diamond Quest.

With a little tweaking, this could recreate the Ceres Ridley fight from Super Metroid (and yes, I looked into it because I hack the rom with SMILE).



#14 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 26 September 2010 - 09:48 AM

For anyone who is confused - this script actually makes an unwinnable battle. Every frame it completely heals the enemy, and when your HP reaches a certain level (set it equal or greater to the enemy's max hit), a string is played and you are warped with sidewarp A.

AutowarpA has to be set to the combo number of an invisible autowarp A combo.

Perhaps later I'll have it trigger when Link hits 0 hp and then heals him slightly. That would be a better effect.
Speaking of which, how do you check of Link has no HP? Can you do that by just setting "critical" to 0? Will it automatically kick in before the game over screen?

Edited by MoscowModder, 26 September 2010 - 09:51 AM.


#15 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 08 October 2010 - 09:30 PM

If you want to do that, I suggest that you look up the Bottle Fairy script. That can help you a bit. I believe it is in the Database or somewhere around here.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users