Jump to content

Photo

Reset Quest?


  • Please log in to reply
17 replies to this topic

#1 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 16 January 2009 - 06:15 PM

I had and idea for a script: a script that would reset everything in the quest, kinda like a New Game+, except for the player's inventory. Is this possible to do? If it is, how would I go about it?

Thanks to anyone who can help. icon_biggrin.gif

#2 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 16 January 2009 - 07:20 PM

Theoretically, yes.

You'd have to run through every screen in the quest and clear all of the ScreenState data. (that should take about 10 lines of code)
I believe there is a way to modify your room and position, and you'd have to reset all the key counters and other dungeon items. (10 more lines of code)

It's actually less complicated than one might expect.

#3 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 16 January 2009 - 07:34 PM

That sounds fairly simple to do. (Simpler than I originally thought.) I'll have myself a crack at it, and I'll have to see how it comes out. Thanks for the help! icon_biggrin.gif

#4 trudatman

trudatman

    one point nine hero

  • Members
  • Real Name:that guy
  • Location:State Of Love And Trust, The United State Of Amorica.

Posted 16 January 2009 - 07:55 PM

that's a really good idea. frustratingly awesome.

#5 Joe123

Joe123

    Retired

  • Members

Posted 17 January 2009 - 05:43 AM

The fact that 'Game->GetScreenState' doesn't work properly at the moment doesn't bode well though for this.

#6 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 17 January 2009 - 02:22 PM

I've been testing it in an older version, where Game->SetScreenState works, and the script seems to work. I just need to do a few more modifications, then it's done. But I'm not sure how to modify how many level-specific keys Link has, or how to turn off Link having the 1/2 magic. Other than that, it seems to work pretty well.

#7 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 17 January 2009 - 09:27 PM

One way to reset level keys (untested):

CODE

const int TOTALLEVELS=10; //the number of levels in the quest

//...inside the script that resets everything...
for(int level=0;level<=TOTALLEVELS;level++)
{
    Game->LKeys[level]=0;
}


As far as 1/2 magic goes, I am not sure why there is not a reference to it. I would expect it to be in the Game->Generic[] array, since that is where you can enable Link's Slash, but std.zh doesn't mention it at all. Maybe it IS implemented and there is just no constant for it yet, but I have no idea. I thought you didn't want to reset Link's inventory though, just everything else...

Edited by Elmensajero, 17 January 2009 - 09:27 PM.


#8 Joe123

Joe123

    Retired

  • Members

Posted 18 January 2009 - 05:50 AM

It is in std.zh somewhere I think, I believe it's called magic drain rate. Not that I've ever used it. Which build are you using blaman?

#9 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 18 January 2009 - 12:19 PM

icon_eyebrow.gif
Why not just have a game where the player can return to a certain point in it, and do things over again?

#10 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 18 January 2009 - 01:29 PM

QUOTE(Elmensajero @ Jan 17 2009, 09:27 PM) View Post

One way to reset level keys (untested):

CODE

const int TOTALLEVELS=10; //the number of levels in the quest

//...inside the script that resets everything...
for(int level=0;level<=TOTALLEVELS;level++)
{
    Game->LKeys[level]=0;
}


As far as 1/2 magic goes, I am not sure why there is not a reference to it. I would expect it to be in the Game->Generic[] array, since that is where you can enable Link's Slash, but std.zh doesn't mention it at all. Maybe it IS implemented and there is just no constant for it yet, but I have no idea. I thought you didn't want to reset Link's inventory though, just everything else...


Thanks for the help. I'll have to test it out and see if it works, but I appreciate the help either way. icon_biggrin.gif I did originally want it so it wouldn't reset Link's stuff, but I'm going to leave that up to the user of the script to decide. For completion's sake, really.


QUOTE(Joe123 @ Jan 18 2009, 05:50 AM) View Post

It is in std.zh somewhere I think, I believe it's called magic drain rate. Not that I've ever used it. Which build are you using blaman?


I always thought that was something different entirely, so I never bothered with it. Thanks. icon_biggrin.gif As for the build, I've been using 910.


QUOTE(T. Platinum @ Jan 18 2009, 12:19 PM) View Post

icon_eyebrow.gif
Why not just have a game where the player can return to a certain point in it, and do things over again?


There's several reasons why I'm doing it this way, actually. I want to have it like in many RPGs where you can do the game over again, but with all your stuff. I'm also planning on rigging the dungeons so you can almost skip them (as in, getting the boss key and getting to the door without going through the rest.) with the dungeon item, so it wouldn't exactly take long to go through it again.

Also, I wanted to do multiple endings with certain conditions. If I reset the quest, all the conditions are also reset, allowing the player to get an alternative ending. (Maybe I've been playing a little too much Disgaea, but hey, multiple endings add replay value. :yum:) And I wanted to have some stuff after you beat the quest, mainly for the fun of it (and one final ending for doing it all.)

#11 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 20 January 2009 - 12:07 PM

I finished it, but I haven't testing it yet.
Thanks everyone for your help! icon_biggrin.gif

CODE

//New Game+ by Blaman
//
//This is a simple script that will reset EVERY screen back
//to its original state,
//
//Also, you can reset Link's inventory, hearts, magic, and counters if
//you want to. Look at the third part if you want to make a few changes.
//Instructions will be provided.
//
//Parameters:
//D0: Number of maps
//D1: Set to 1 to reset Link's inventory
//D2: Set to 1 to reset Link's Hearts
//D3: Set to 1 to reset Link's Magic
//D4: Set to 1 to reset Link's counters and other misc things(bombs, arrows, double magic, slash
//
//Thanks to Beefster, Joe123 and Elmensajero for helping me massively with this script.

ffc script newGamePlus
    {
        int mapCounter = 1;
        bool keepitem;
        void Run(int mpNum, int resetI, int resetH, int resetM, int resetC)
        {
                     //PART 1:Reset all the maps and screens
                     while(mapCounter != mNum)
                     {
                            for (int i; i < 135; i++)
                            {
                                Game->SetScreenState(mapCounter, i, 0, false);
                                Game->SetScreenState(mapCounter, i, 1, false);
                                Game->SetScreenState(mapCounter, i, 2, false);
                                Game->SetScreenState(mapCounter, i, 3, false);
                                Game->SetScreenState(mapCounter, i, 4, false);
                                Game->SetScreenState(mapCounter, i, 5, false);
                                Game->SetScreenState(mapCounter, i, 6, false);
                                Game->SetScreenState(mapCounter, i, 7, false);
                                Game->SetScreenState(mapCounter, i, 8, false);
                                Game->SetScreenState(mapCounter, i, 9, false);
                                Game->SetScreenState(mapCounter, i, 10, false);
                                Game->SetScreenState(mapCounter, i, 11, false);
                                Game->SetScreenState(mapCounter, i, 12, false);
                                Game->SetScreenState(mapCounter, i, 13, false);
                                Game->SetScreenState(mapCounter, i, 14, false);

                            }
                            mapCounter ++;
                     }
                     //PART 2:Reset all the level items
                     for (int i; i < 255; i++)
                     {
                         Game->LItems[i] = 00000;
                         Game->Counter[5] = 0;
                         Link->Lkeys[i] = 0;

                     }
                     //PART 3: Rests Misc Things

                     //This part checks if the user wants Link's items to be
                     //reset. If you want specific items to remain, get the item
                     //ID and then copy the following code after "for(int i; i <255; i++)
                     //and the curly brace,replacing
                     //"x" with the item ID of your choice.
                     //if(Link->Item[x] == true)
                     //{
                     //    keepItem = true;
                     //}
                     //The next bit of code goes after Link->Item[i] = false;
                     //if(keepItem == true)
                     //{
                     //    Link->Item[i] = true;
                     //}
                     //
                     //You will need to copy both codes in the right places
                     //for each item you want Link to keep. This does not
                     //include dungeon items nor keys.

                     if(resetI == 1)
                     {
                         for(int i; i <255; i++)
                         {
                              Link->Item[i] = false;
                         }
                     }

                     //This part checks if the user wants Link's hearts to be
                     //reset. Change the number at the end of Link->MaxHP = 3; to
                     //however many hearts you want him to have after the reset.
                     if(resetH == 1)
                     {
                         Link->MaxHP = 3;
                     }

                     //This part checks if the user wants Link's magicto be
                     //reset. Change the number at the end of Link->MaxMP = 32; to
                     //however much magic you want him to have after the reset.
                     if(resetM == 1)
                     {
                         Link->MaxMP = 32;
                     }

                     //Finally, this part checks to see if the user wants the counters
                     //to be reset. Look at the appropriate counters, and just as
                     //before, change the value at the end to fit your own desire.
                     if(resetC == 1)
                     {
                               Game->Counter[0] = 0; //Rupees
                               Game->Counter[1] = 0; //Bombs
                               Game->Counter[2] = 0; //Arrows
                               Game->Counter[3] = Link->MaxMP; //Magic, change Link->MaxMP to whatever number you may want, or leave as is.
                               Game->Counter[6] = 0; //Super Bombs
                               Game->Generic[0] = 0; //Number of Heart Pieces in possesion
                               Game->Generic[1] = false; //Delete this line if you want Link to retain 1/2 Magic after reset
                               Game->Generic[2] = false;  //Delete this line if you want Link to be able to slash after reset
                               //Keys were left out, since they were already delt with.
                     }
        }
    }


I'm most likely going to change with having constants at the top instead of having to modify the number in the 'if' statement.
Anyways, here it is. I'll probably submit it when I've tested it fully and made all the needed fixes.


#12 Joe123

Joe123

    Retired

  • Members

Posted 20 January 2009 - 03:29 PM

That mostly looks pretty good.
There's a couple things that won't quite work out properly though.
One heart container is 16 HP in the world of scripting, so if you set Link's Max HP to 3, that's generally not a good idea ^_^
What you wanted to set it to was 3*16, so 48.

All of the 'Game->Generic' variables are part of the same array, so they must all be the same data-type.
So that means you're likely to get a 'Cast from Float to Bool' error with the ones you've set false, as they're all integers rather than booleans.

That means you just need to set the 'slash' one to 0.
Looking at the magic drain rate though, I think you need to set it to 1.
See where it says 'magic usage = 1/n' in std.zh?
Well I think that means the value in Game->Generic is what you're dividing by (so a drain rate of two would be 1/2 magic usage). Therefore 0 isn't a good number for it =P

The 'LKeys' variable is a part of the 'Game' object, not the 'Link' object, so it should be 'Game->LKeys', rather than 'Link->LKeys'.


The last three are just small things really; setting something to '00000' is the same as setting it to '0' - whether it's binary or not - so you don't need to set Game->LItems to '00000', just '0'. Not that it really matters, just pointing out.
The screen state script should work, but it's a little convoluted. What you could do is use three for loops, rather than one for, a while and a load of functions written out.
CODE
for(int mapcounter=1;mapcounter<=mpNum;mapcounter++){
    for(int i;i<135;i++){
        for(int j;j<15;j++){
            Game->SetScreenState(mapcounter, i, j, false);
        }
    }
}


And you shouldn't really declare variables before void run().
That's where global variables used to be declared, but that system is now deprecated and global variables are declared outside of scripts altogether.
I think you just need to declare them after void run() though, they don't look like they need to be global.

#13 Elmensajero

Elmensajero

    Doyen(ne)

  • Members
  • Real Name:John
  • Location:Raleigh, North Carolina

Posted 20 January 2009 - 03:42 PM

Hey, you almost finished it, nice! Bugs i noticed so far... (I haven't tested it, only tried compiling it.)

Edit: Oops, Joe posted before me... I should of refreshed the page beforehand, oh well...

-The variables mapcounter and keepitem have to be either declared outside of the ffc script (making them global) or inside the void run function.

-It is "void run()", not "void Run()"

-You declared variable mpNum, but then used mNum instead two lines down.

-It is "Game->LKeys[]", not "Link->Lkeys[]".

-The magic drain rate is not a boolean value. It is an integer "n" that causes the magic drain rate to become 1/n. (I never noticed that variable before, I am glad Joe mentioned it.) So you set it to "1", not false.

-Oddly enough, the canslash index is not a boolean either. This is because it is part of the Generic array, which can't be half boolean/ half integer. I assume setting it to 0 will remove Link slash, but I could be wrong.

Since there were quite a few compile-time error bugs, here is a version of the script that fixes the errors I mentioned. Again, I haven't actually tested it in game, but if you would like me to, let me know.

CODE

//New Game+ by Blaman
//
//This is a simple script that will reset EVERY screen back
//to its original state,
//
//Also, you can reset Link's inventory, hearts, magic, and counters if
//you want to. Look at the third part if you want to make a few changes.
//Instructions will be provided.
//
//Parameters:
//D0: Number of maps
//D1: Set to 1 to reset Link's inventory
//D2: Set to 1 to reset Link's Hearts
//D3: Set to 1 to reset Link's Magic
//D4: Set to 1 to reset Link's counters and other misc things(bombs, arrows, double magic, slash
//
//Thanks to Beefster, Joe123 and Elmensajero for helping me massively with this script.

ffc script newGamePlus
    {
        void run(int mpNum, int resetI, int resetH, int resetM, int resetC)
        {
                    int mapCounter = 1;
                    bool keepitem;

                     //PART 1:Reset all the maps and screens
                     while(mapCounter != mpNum)
                     {
                            for (int i; i < 135; i++)
                            {
                                Game->SetScreenState(mapCounter, i, 0, false);
                                Game->SetScreenState(mapCounter, i, 1, false);
                                Game->SetScreenState(mapCounter, i, 2, false);
                                Game->SetScreenState(mapCounter, i, 3, false);
                                Game->SetScreenState(mapCounter, i, 4, false);
                                Game->SetScreenState(mapCounter, i, 5, false);
                                Game->SetScreenState(mapCounter, i, 6, false);
                                Game->SetScreenState(mapCounter, i, 7, false);
                                Game->SetScreenState(mapCounter, i, 8, false);
                                Game->SetScreenState(mapCounter, i, 9, false);
                                Game->SetScreenState(mapCounter, i, 10, false);
                                Game->SetScreenState(mapCounter, i, 11, false);
                                Game->SetScreenState(mapCounter, i, 12, false);
                                Game->SetScreenState(mapCounter, i, 13, false);
                                Game->SetScreenState(mapCounter, i, 14, false);

                            }
                            mapCounter ++;
                     }
                     //PART 2:Reset all the level items
                     for (int i; i < 255; i++)
                     {
                         Game->LItems[i] = 00000;
                         Game->Counter[5] = 0;
                         Game->LKeys[i] = 0;

                     }
                     //PART 3: Rests Misc Things

                     //This part checks if the user wants Link's items to be
                     //reset. If you want specific items to remain, get the item
                     //ID and then copy the following code after "for(int i; i <255; i++)
                     //and the curly brace,replacing
                     //"x" with the item ID of your choice.
                     //if(Link->Item[x] == true)
                     //{
                     //    keepItem = true;
                     //}
                     //The next bit of code goes after Link->Item[i] = false;
                     //if(keepItem == true)
                     //{
                     //    Link->Item[i] = true;
                     //}
                     //
                     //You will need to copy both codes in the right places
                     //for each item you want Link to keep. This does not
                     //include dungeon items nor keys.

                     if(resetI == 1)
                     {
                         for(int i; i <255; i++)
                         {
                              Link->Item[i] = false;
                         }
                     }

                     //This part checks if the user wants Link's hearts to be
                     //reset. Change the number at the end of Link->MaxHP = 3; to
                     //however many hearts you want him to have after the reset.
                     if(resetH == 1)
                     {
                         Link->MaxHP = 3;
                     }

                     //This part checks if the user wants Link's magicto be
                     //reset. Change the number at the end of Link->MaxMP = 32; to
                     //however much magic you want him to have after the reset.
                     if(resetM == 1)
                     {
                         Link->MaxMP = 32;
                     }

                     //Finally, this part checks to see if the user wants the counters
                     //to be reset. Look at the appropriate counters, and just as
                     //before, change the value at the end to fit your own desire.
                     if(resetC == 1)
                     {
                               Game->Counter[0] = 0; //Rupees
                               Game->Counter[1] = 0; //Bombs
                               Game->Counter[2] = 0; //Arrows
                               Game->Counter[3] = Link->MaxMP; //Magic, change Link->MaxMP to whatever number you may want, or leave as is.
                               Game->Counter[6] = 0; //Super Bombs
                               Game->Generic[0] = 0; //Number of Heart Pieces in possesion
                               Game->Generic[1] = 1; //Delete this line if you want Link to retain 1/2 Magic after reset
                               Game->Generic[2] = 0;  //Delete this line if you want Link to be able to slash after reset
                               //Keys were left out, since they were already delt with.
                     }
        }
    }

Edited by Elmensajero, 20 January 2009 - 03:44 PM.


#14 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 20 January 2009 - 05:06 PM

Thank you very much to you both Joe123 and Elmensajero for the help and advice. icon_biggrin.gif

I've got to make some smaller changes yet, simplify the screen-reset part like Joe123 suggested, and generally make it more friendly. Then I've just got to test it a bit, and it should be finished. (I hope... icon_sweat.gif )

Thank again! icon_biggrin.gif

#15 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 21 January 2009 - 06:42 PM

Alright, I just fixed some of the problems. I have a feeling I missed something, though...

Anyways, I added a global cycle variable to keep track of how many times the game's been reset. It may have more uses than you know. icon_wink.gif I also made an array to allow users to more easily decide what items they want to keep and reset.

Again, I haven't tested it yet. I would appreciate it if someone could test it, but I could test it myself later.

CODE
//New Game+ by Blaman
//
//This is a simple script that will reset EVERY screen back
//to its original state,
//
//Also, you can reset Link's inventory, hearts, magic, and counters if
//you want to. You can change a good chunk of numbers to whatever default
//
//Parameters:
//D0: Number of maps
//D1: Set to 1 to reset Link's inventory
//D2: Set to 1 to reset Link's Hearts
//D3: Set to 1 to reset Link's Magic
//D4: Set to 1 to reset Link's counters and other misc things(bombs, arrows, double magic, slash
//
//A big thank you to Beefster, Joe123, and Elmensajero


ffc script newGamePlus
    {
        int cycle; //This is to keep track on a global scale how many times the
                   //quest has been reset.
        void Run(int mpNum, int resetI, int resetH, int resetM, int resetC)
        {

                     const int magic = 32; //How magic to keep after reset. (in 32ths of a container)
                     const int life = 48;  //How life to keep after reset. (in 16ths of a heart)
                     const int rupee = 0;  //How many rupees after reset.
                     const int bomb = 0;   //How many bombs after rest.
                     const int arrow = 0;  //How many arrows after reset.
                     const int superbomb = 0;   //How many super bombs after reset.
                     const int hcp = 0;   //How many heart container pieces after reset.
                     const int slash = 0; //0 = disallow slash after reset, 1 = allow
                     const int magicdrain = 1; //1 = disables 1/2 magic, 2 = 1/2 magic

                     int mapCounter = 1;
                     bool[255] items;

                     //Items you wish to be kept:

                     items[0] = true; //Change 0 to an item ID you don't want lost after
                                      //the reset. Add as many as you wish here.


                     //Reset all maps and screens
                     while(mapCounter != mpNum)
                     {
                            for (int i; i < 135; i++)
                            {
                               for (int j; j <= 14; j++)
                               {
                                 Game->SetScreenState(mapCounter, i, j, false);
                               }
                            }
                            mapCounter ++;
                     }

                     //Reset all the level items
                     for (int i; i < 255; i++)
                     {
                         Game->LItems[i] = 0;
                         Game->Counter[5] = 0;
                         Game->Lkeys[i] = 0;

                     }

                     //Reset Link's inventory
                     if(resetI == 1)
                     {
                         for(int i; i <255; i++)
                         {
                              if (items[i] == true)
                              {

                              }
                              else
                              {
                                 Link->Item[i] = false;
                              }
                         }
                     }

                     //Reset Link's HP
                     if(resetH == 1)
                     {
                         Link->MaxHP = life;
                     }

                     //Reset Libk's MP
                     if(resetM == 1)
                     {
                         Link->MaxMP = magic;
                     }

                     //Reset Other COunters
                     if(resetC == 1)
                     {
                               Game->Counter[0] = rupee;
                               Game->Counter[1] = bomb;
                               Game->Counter[2] = arrow;
                               Game->Counter[3] = Link->MaxMP;
                               Game->Counter[6] = superbomb;
                               Game->Generic[0] = hcp;
                               Game->Generic[1] = slash;
                               Game->Generic[2] = magicdrain;
                     }
                     cycle ++; //Adds one to the cycle counter
        }
    }



So, how does that look?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users