Jump to content

Photo

My Script Wishlist and Your Script Ideas


  • Please log in to reply
242 replies to this topic

#136 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 01 August 2015 - 10:37 PM

 

Script Activates Specific Triggers

 

Every screen in the game has its own array with 8 elements that gets saved to the save file. You can access it with Screen->D[index], where index is from 0 to 7. You can tie your combo changes to this array instead of relying on the binary screen secret state. If 8 numbers isn't enough, you can pack more info into each number with bitwise operations.

 

 

Easy Character Switching

 

Using LTMs seems like it would be easier than drawing over Link. You can use a global array to keep track of what each character's inventory should be. Just include a line in every item's pickup script to set the values in these arrays, and the character switch code would alter Link->Item[] to match the contents of whichever character's array you're switching to. You could even get fancy and have every pickup script give a grayed out, non-selectable version of the item that goes in the same spot on the subscreen. They wouldn't be visible while using the correct character, but then show up when you switch. Binx had a thread on this before, I think on this forum? It might have more specific info if you can find it.


  • ywkls likes this

#137 ywkls

ywkls

    Master

  • Members

Posted 02 August 2015 - 09:17 AM

Here's what I worked out for the "Script triggers specific secrets" thing. Instead of relying on the secrets built into the screen, it just changes any combo whose flag falls between two values to the next combo in the list. I'm surprised that I've never seen anything like it before. For optimal results on permanent secrets, make it run at screen init. This also means that all types of lweapons could have a "lweapon-type"-next combo.

Secret Combo 1.0


Edited by ywkls, 07 September 2015 - 09:14 AM.


#138 ywkls

ywkls

    Master

  • Members

Posted 02 August 2015 - 10:12 PM

On the whole Character Switching Idea, one problem I've encountered already while trying to develop a simple version of this is that LTM don't let you change Link's Cset. And Rings change the palette, which is kind of hard to see while editing tiles. Additionally, offsetting and animating the tiles correctly can be an extreme pain.

 

So... this is totally messing with my plans for my next game. I may have to start some of my work over from scratch or figure out how to adjust Link's Cset or palette. Or something. Thankfully, most of the mask ideas won't require this sort of complexity and that's much farther off. I should have this first problem cracked by then (I hope), but I don't think I'll be able to do it without some help.

 

And speaking of Link's Palettes... what are they and where can you alter them?



#139 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 02 August 2015 - 10:24 PM

You'll have to adjust Link's CSet using ring items, because scripts can't directly access it.

 

http://www.shardstor.../ZCwiki/Palette

 

That page has the default locations of palettes for the blue, red, and gold rings, although you can change those with the item editor. You can also change a ring's damage divisor to 1, so it has no effect other than shifting palette.


  • ywkls likes this

#140 Local_Droog

Local_Droog

    Newbie

  • Members
  • Real Name:Droog
  • Location:Athens GA

Posted 07 August 2015 - 04:03 AM

Alright so you think you could tell me hoe to make an FFC that when I have Item 1 of item X Y and Z (Put the item number thare) That the Secerts of that Screen Trigger?



#141 ywkls

ywkls

    Master

  • Members

Posted 07 August 2015 - 09:25 AM

Are you referring to merely having that item without having it equipped or using that item? The answer differs depending on which you mean. For example, let's say you have an item but can't use it. (A common example would be the Rings, which affect how much damage you take and your appearance, but little else.) So you enter a room. And it that room, there is this ffc script.

//D0- Item number of item to trigger secrets

ffc script item_secret{
      void run(int item_to_trigger){
             //If you don't have the item, do nothing.
             //An extra check for screen secrets is included, so secrets are only triggered once.
             while(!Link->Item[item_to_trigger] || !Screen->State[ST_SECRET])Waitframe();
             //You have the item. Trigger secrets.
             Screen->TriggerSecrets();
             Screen->Stete[ST_SECRET] = true;
      }
}

Then, there is this code; designed to make specific secrets trigger when you use an item anywhere in that room. (Or stand in a particular spot and use an item, or hit an ffc with an lweapon.)

Secret Combo 2.0

This might need some additional refinement, but it lets you use any flag to trigger or create secrets. Please remember that only flags 16-31 can be changed by screen secrets.


Edited by ywkls, 07 September 2015 - 09:15 AM.


#142 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 August 2015 - 03:42 PM

Every screen in the game has its own array with 8 elements that gets saved to the save file. You can access it with Screen->D[index], where index is from 0 to 7. You can tie your combo changes to this array instead of relying on the binary screen secret state. If 8 numbers isn't enough, you can pack more info into each number with bitwise operations.
 

 
Using LTMs seems like it would be easier than drawing over Link. You can use a global array to keep track of what each character's inventory should be. Just include a line in every item's pickup script to set the values in these arrays, and the character switch code would alter Link->Item[] to match the contents of whichever character's array you're switching to. You could even get fancy and have every pickup script give a grayed out, non-selectable version of the item that goes in the same spot on the subscreen. They wouldn't be visible while using the correct character, but then show up when you switch. Binx had a thread on this before, I think on this forum? It might have more specific info if you can find it.

 
Script template, and test quest, for using an alternative sprite. Code is in the buffer.

Note that this is an example, and it's set up without LTMs in mind.

Edited by ZoriaRPG, 07 August 2015 - 03:44 PM.

  • ywkls likes this

#143 ywkls

ywkls

    Master

  • Members

Posted 07 August 2015 - 04:09 PM

I may need a few more explanations of that test quest to understand just how to use it. For example, to set up the item that changes your appearance; I see that you put the script in the action slot, but you don't have to use it for the effect to take place. Ideally, you could have a button that switches the effect on and off, or changes to the next available effect. (Such as if you're supposed to have multiple characters.)

 

I also notice that the item script has a value that it can have as an argument, but putting something in there doesn't seem to change things. So I'm guessing that acquiring the item is what alters your appearance. (Much like the rings.) Is altering the code the only way to change what is shown? Or can this be part of the item script? Example: You get item and when you select it and press the button, it changes your appearance to that of another character.

 

I'm also a little unclear on why you recommend putting certain things into an array. Plus, there is a bunch of stuff that is commented out. Is this redundant code? Or is it an alternate way to do these things? Or what?

 

In the example quest, you hard code the sprite used to be number 88.Could you easily change this to use multiple sprites?

Otherwise, it looks like an excellent method of accomplishing this.


Edited by ywkls, 07 August 2015 - 04:10 PM.


#144 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 August 2015 - 08:12 PM

It's a work-in-progress, for RPG.zh. There's quite a lot there, for the purpose of testing it. That item script was used to change the sprite ID in the array, to ensure that it was working as I intended.

 

It still needs some things, including a series of constants to adjust based on LTMs, what the src tiles should be; and of course, running it in a game would revolve around if statements.

 

Now, what I was doing, is using an eweapon for the sprite, rather than an ffc, because I want to save FFC slots. That's the point of it; and yes, you can draw eweapons to higher layers, to, for example, draw specific armour over the player sprite. The most important facet of this, is that it preserves the sprite animation, which was a pain to figure out at first. I needed to both maintain the animation, and kill the eweapon (and recreate it) every frame.

 

Keeping it alive creates a trail of sprites, which is something that I use elsewhere, for a special effect.

 

I use arrays, because I don;t want to waste global vars. The initial code used a slew of global vars, and then I condensed it. (I will further condense it later, for full integration into RPG.zh; into one of the main game arrays.)

 

I also don't hardcode the sprite. The sprite used, is drawn from an array: The index positions in the array, match the present DMAP. thus, if I want to make a sea DMAP, or a space DMAP, I can make a boat, or space saucer sprite, plug the number into the array, and be done. The game will automatically use that sprite, on those DMAPs.

 

The '88' value is the initial value for DMAP 0. The test file only had one DMAP ('0'), so that was all that I needed.

 

SetPlayerSprite(int dmap, int sprite) is used to change those values at any time, thus:

 

SetPlayerSprite(0,16);
//This would change the sprite for DMAP 0 to Sprite ID 16

 

That is the function to set those values, and change them at any arbitrary time.

 

P.S. I set the tiles for Link to blank tiles, rather than Link->Invisible, because the latter also makes Link class weapons (e.g. swords, hammers, hookshots) invisible too.

 

P.P.S. The vars that I commented out are those that I moved into the array. The commented out code blocks, are for the most part, replaced by more streamlined versions. One may be for checking LTMs, and is incomplete, based on checking for inventory items, before choosing the src tile bank. It looks like all of my commented out code-blocks in that file though, are just old code that I replaced, so you can safely ignore, or remove those lines.


Edited by ZoriaRPG, 07 August 2015 - 08:26 PM.

  • ywkls likes this

#145 ywkls

ywkls

    Master

  • Members

Posted 07 August 2015 - 10:09 PM

It still needs some things, including a series of constants to adjust based on LTMs, what the src tiles should be; and of course, running it in a game would revolve around if statements.

 

I'm not sure what you mean by src tiles, but the rest of what you said up to this point makes sense.

 

 

Now, what I was doing, is using an eweapon for the sprite, rather than an ffc, because I want to save FFC slots. That's the point of it; and yes, you can draw eweapons to higher layers, to, for example, draw specific armour over the player sprite. The most important facet of this, is that it preserves the sprite animation, which was a pain to figure out at first. I needed to both maintain the animation, and kill the eweapon (and recreate it) every frame.

 

That was manifestly clear and in fact what I imagined would have to be done to accomplish this.

 

 

I use arrays, because I don;t want to waste global vars. The initial code used a slew of global vars, and then I condensed it. (I will further condense it later, for full integration into RPG.zh; into one of the main game arrays.)

 

I realize that you use arrays, to save on variable space; because you use a lot of variables. (I remember one topic where you were discussing running out of variables.) Of course, not everybody uses that many variables, so they might be able to leave some things as they are rather than putting them into an array.

 

However, those things that do need to be in arrays could probably use better explanations of the following.

 

1, How big the array should be and why. An array with 3024 elements seems rather... large to me.

2. What to put into the array and how.

3. Where to use the array in the code to do stuff and how.

 

 

I also don't hardcode the sprite. The sprite used, is drawn from an array: The index positions in the array, match the present DMAP. thus, if I want to make a sea DMAP, or a space DMAP, I can make a boat, or space saucer sprite, plug the number into the array, and be done. The game will automatically use that sprite, on those DMAPs.

 

Are you saying that instead of having the game pull the correct sprite from the available weapons sprites, you're getting it to be generated using the array? 

 

 

The '88' value is the initial value for DMAP 0. The test file only had one DMAP ('0'), so that was all that I needed.

 

SetPlayerSprite(int dmap, int sprite) is used to change those values at any time, thus:

SetPlayerSprite(0,16);
//This would change the sprite for DMAP 0 to Sprite ID 16

That is the function to set those values, and change them at any arbitrary time.

 

This seems to be pretty straightforward. Would this run in the global script or the item script?

 

 

P.S. I set the tiles for Link to blank tiles, rather than Link->Invisible, because the latter also makes Link class weapons (e.g. swords, hammers, hookshots) invisible too.

 

I noted in the test quest that Link is actually visible for a fraction of a second before the effect shows up.

 

Again, a very streamlined version of this idea. A few tips for using it and I think I'll be ready to start experimenting.



#146 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 August 2015 - 11:50 PM

I'm not sure what you mean by src tiles, but the rest of what you said up to this point makes sense.

 

Source tiles: The code copies Link;s tiles ( src ) to a back-up bank ( dest ) of blank tiles. Then it copies a blank tile to all of the tiles that it backed up. Making Link visible again, reverses this process, and restores all the tiles in ( dest ) to a blank state.

 

Note that tile copying is not preserved through saving, so this will need an onContinue, and onExit script, to re-set the variable states for the flags that mark if tiles were copied, or restored. Those are stored at the end of the array, in the last two indices.
 

That was manifestly clear and in fact what I imagined would have to be done to accomplish this.
 
 
 
I realize that you use arrays, to save on variable space; because you use a lot of variables. (I remember one topic where you were discussing running out of variables.) Of course, not everybody uses that many variables, so they might be able to leave some things as they are rather than putting them into an array.
 
However, those things that do need to be in arrays could probably use better explanations of the following.
 
1, How big the array should be and why. An array with 3024 elements seems rather... large to me.
2. What to put into the array and how.
3. Where to use the array in the code to do stuff and how.

 
It's a psudo-2D array:
 
We have 512 DMAPs, and six variables to set, per DMAP:

  • The sprite ID to use.
  • Whether Link should be invisible ( 0/1 )
  • The present sprite frame.
  • The maximum number of sprite frames.
  • The present timer for animation delay.
  • The max value for the animation delay.

512 DMAPs * ( Sprite + Is_Link_Visible + Sprite_Anim_Cycle + Anim_Number_of_Frames + Delay_Timer + Delay_Timer_Max ) = 3072 indices.
 
Then, we need two flags, to determine if sprites have been copied, or restored this frame.

3072 + SPRITES_COPIED + SPRITES_RESTORED = 3074.
 
Therefore, we use 3074 indices, numbered from 0, to 3073. The constants on lines 127, through 134, establish the starting value for reading into the table. The rest is maths:
 
arr[n+CONSTANT]
 
I used a base of 512, as that is the maximum number of DMAPs that a user can create in ZQuest; but if you use only ten DMAPs, you could safely truncate the array to a size of 62, and correct the constants for the tile copying flags. The array size should be ( ( number of DMAPs * 6 ) + 2 ).
 

Are you saying that instead of having the game pull the correct sprite from the available weapons sprites, you're getting it to be generated using the array?

 
No, you must set up the sprite, and its animation via Sprites->Weapons/Misc. The array simply holds the required information, to display the desired sprite, with the desired animation, on a per-DMAP basis. That makes it automatic, as soon as the player is sent to a DMAP, at any point, by any means, the sprite changes. 

 

If you don;t need this facility, you'd want to use other functions to generate your effect; such as an array to hold gear status, and functiosn to display sprite overlays, based on gear. The functions allow a user to change the array values, at any arbitrary point.
 
The active code, runs from a global active loop, so it is always running, and uses sprites, animations, and timers, pulled from that one array. Again, this is where the pseudo-2D array maths come into play. These active instructions then display things, based on the datum they read from the appropriate array indices.
 

This seems to be pretty straightforward. Would this run in the global script or the item script?

 
Which part? You can call one of the Get/Set functions, from anywhere. An item script, and FFC, or a global script (of any kind). The main drawing functions run from the global active script.
 

I noted in the test quest that Link is actually visible for a fraction of a second before the effect shows up.
 
Again, a very streamlined version of this idea. A few tips for using it and I think I'll be ready to start experimenting.

 
I know about that. It's something that I believe I could correct, with an opening wipe animation of some kind. Unfortunately, writing the correct base tiles, to the tiles Link is using, occurs after Waitdraw()--the reason behind this is somewhat complicated--so there's no simple solution around it. It may also be possible to start a game with Link->Invisible = true, then disable Link->Invisible after six frames, or devise another solution.
 
I'm not sure that this is ready for general consumption. It's uncommented, and undocumented; and certainly needs further expansion. It relies on knowing a specific tile index, for copying Link's tiles, rather than anything that detects his tile, and does some kind of practical extrapolation from that. I considered doing it that way, but Link's walk cycle frames would potentially cause that to be prone to errors.
 
A later version, would need to include the standard shield LTMs, and such, with if statements that select starting tile positions to back-up to the blank tile bank.


  • ywkls likes this

#147 ywkls

ywkls

    Master

  • Members

Posted 09 August 2015 - 08:21 PM

So, my latest scripting experiment is a multi-form boss battle. So far the problem is coming from switching between forms. I've managed to condense it down from 3 while loops to one, but it simply isn't switching forms. I don't know it this is because it is losing more HP every time I hit it than the amount I set to trigger the change in forms or what. So I thought that I'd post the code and see if any body has any suggestions to offer.

Vaati 1.0


Edited by ywkls, 06 September 2015 - 09:53 PM.


#148 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 09 August 2015 - 10:37 PM

You have the while loop set to end once HP becomes less than 0, which causes the script to end. Set it to while(true), and add an if statement where if (HP <= 10 && form == 3), then add a death effect.



#149 ywkls

ywkls

    Master

  • Members

Posted 10 August 2015 - 12:03 AM

@Dimentio- There was an error in that while loop, though I think it is was actually the fact that it was supposed to end if HP dropped below ten and It was set up to check whether that had happened. Self-contradictory, I know. I have concluded that this would be simpler to do as three separate bosses. My only problem is aligning the larger form's parts with the actual boss.

 

Here's the code that runs them, on separate screens with autowarps between each version.

Vaati 2.0

Except for the glitchy behavior of the huge final boss, this works really well. I may change it if I can come up with a final form that is smaller.


Edited by ywkls, 06 September 2015 - 09:53 PM.


#150 ywkls

ywkls

    Master

  • Members

Posted 19 August 2015 - 01:31 PM

So, I was reviewing this topic and I'm surprised to find that I've either been provided with or developed some of the things I suggested as advanced scripting ideas. Here's some links to topics discussing each of these ideas in more detail.
 
Multiple Items/Scripted Triggers
 
Multiple Songs/Ocarinas (WIP)
 
Mask System (WIP)
 
True Minigames (WIP)
 
Sideview Enemies
 
Multiple Rafts

 

However, there are a still a few things I haven't been able to find on my own.

 

Misc Room Script Flags- I know that they exist and even that there are 5 types. Here's the only one I know of.

Screen->Flags[SF_MISC]&0x008;//Screen flag Script 2

So, what are the other four? How can they be used most effectively?
 

Mysterious Script Crashes- Some times, for no apparent reason; scripts activate when they shouldn't. At others, they don't work when they should (and have up to that point). When no change has been made to the scripts in the meantime, how can the source of these errors be discovered?

 

Other Movement Patterns- I'm familiar enough with the various Ghost.zh commands to figure out how to use each one. However, other movement patterns have been suggested; for example a sine wave or an infinity loop.  Another pattern I don't know how to mimic is that of the common Wizzrobe. So how can these be done? And what are some other movement patterns?

 

Detecting If All Switches/FFCS Have Been Activated- One script that I had provided for me does this. I'm trying to refine another (the one utilized by the script you'll see in the Multiple Songs/Ocarinas topic) where when all of the ffcs running that script are activated; then other secrets, triggers, ffcs or whatever is activated as well.

 

This script is probably one of my most revolutionary designs, since It easily allows you to create up to 8 secrets on screen that can be triggered permanently and 15 others that can be set off temporarily; opens up extra secret flags; bypasses the whole secret combo setup routine and generally allows a greater amount of variety in the puzzle setup available to the player. So, naturally I want it to be the best it can be.

 

Time to Tango- I'm going to begin delving into Tango.zh soon. I've looked over the example quest and I've noted the following details. The commands are prefaced by the @ symbol. Syntax seems to be similar to other functions (if, else if, else, append, delay, rand, playsfx, etcetera...)

 

So the big question is... what are the commands that this uses just with the global script and creating no custom functions of your own? What do commands like @a0 do? What are the codes for the various letters? (Example, @256 is used in the example quest to create an A with a circle around it.) How do you set up the background for the various strings?

 

Obviously, this isn't a conundrum that will solve itself overnight. But I'm ready to start learning.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users