So, I guess I'm asking for a script that lets you run faster with L and R, while using up the Stamina Bar(Or, the Magic Meter. ) and it replenishes itself over time. I also need it so that when a Spin Attack is executed, magic/stamina is used. The Staff/Wand in my quest will use the Stamina (Magic xD) on it's own, so I got that covered.
So,
When L or R is pressed, and the player moves, they run fast and stamina (magic) is used at a certain speed.
Spin Attack uses stamina (magic)
Is it possible to do this? And will it work with Magic Upgrades? Thanks to whoever can help me with this!
const int stamDrain = 10; //Drain rate in frames const int stamRefill = 60; //Refill rate in frames const int playSFX = 12; //Play SFX every (n) frames const int SFX_LINKDASH = 41; //SFX for Link running. const float Lspeedpercent=150;
global script Slot_2 { void run() { int globaltime; //--For L Run Script float Lspeed=Lspeedpercent/100; int x=Link->X; int y=Link->Y; int curmap=-1; int curscreen=-1; //one time things go here
It seems to work but I just threw it together and didn't really test it. UPDATE: I fixed it so Magic wont drain if Scrolling or holding L. Added constants so the script is more customizable. Added a dashing sound, default uses Grass Cut SFX.
Run with independent stamina meter
CODE
const float Lspeedpercent=150; const int green = 33; //value can be modified depending on tileset palette const int white = 1; //value can be modified depending on tileset palette const int xoffset = 176; //initial x offset for top left rectangle const int yoffset = 4; //initial y offset for top left rectangle const int stamDrain = 15; //Rate per frames stamina will decrease by 8 const int stamFill = 30; //Fill rate int stamMax = 96; //Full stamina meter. int stamina = 96; int stams = 3; //Number of Stamina Cells to display
item script StaminaCell //Increases Max Stamina { void run(){ stamMax += 32; stams += 1; stamina = stamMax;} //Stamina meter is based off magic so a cell is 32
}
global script Slot_2 { void run() { int color; int globaltime; //--For L Run Script float Lspeed=Lspeedpercent/100; int x=Link->X; int y=Link->Y; int curmap=-1; int curscreen=-1; //one time things go here
while(true) { float stamCheck = (stamina / stamMax) * stams; int shade = Ceiling(stamCheck); for(int i=0; i<stams; i++) { if(stams-i > shade) color = white; else color = green;
Modified to have an independent meter. With item for increasing "stamina" and amount of "cells" to display on screen.
Stamina Meter with refill delay and button disabling
CODE
const float Lspeedpercent=150; //Used in L Run script const int green = 33; //value can be modified depending on tileset palette const int white = 1; //value can be modified depending on tileset palette const int xoffset = 176; //initial x offset for top left rectangle const int yoffset = 4; //initial y offset for top left rectangle const int stamDrain = 2; //Drain rate in frames when running const int stamFill = 8; //Fill rate const int stamFillDelay = 120; //Frames to wait before refilling if meter hits 0 const int InpAcost = 8; //Stamina cost of pushing A const int InpBcost = 4; //Stamina cost of pushing A const int Runcost = 2; //Stamina cost of running const int playSFX = 12; //Play SFX every (n) frames const int SFX_LINKDASH = 41; //SFX for Link running. const int DBL_STAM_TILE = 21560;
int stamMax = 96; //Full stamina meter. int stamina = 96; int stams = 3; //Number of Stamina Cells to display bool doublestam; //Double Stamina
item script StaminaCell //Increases Max Stamina and adds a cell to meter. { void run(){ if(doublestam) stamMax += 64; else stamMax += 32; stams += 1; stamina = stamMax;} }
item script StaminaDoubler //Doubles Stamina (first use, after that it only fills stamina meter) { void run(){ if(!doublestam){stamMax = stamMax * 2; doublestam = true;}stamina = stamMax;} }
global script Slot_2 { void run() { int stamDelay; bool InpA; bool InpB;
int color; int globaltime; //--For L Run Script float Lspeed=Lspeedpercent/100; int x=Link->X; int y=Link->Y; int curmap=-1; int curscreen=-1; //one time things go here
Stamina Meter script modified to delay refill and disable all action buttons when Meter is drained to 0.
I intend to add SFX to all scripts, and dust graphics when running. Also looking into changing the meter to use combos instead of simple rectangles. I will take any suggestions to improve the scripts. And if there are any scripts that make custom meters i'd love to see them.
I am also considering combining all scripts with values to select which features to use.
Yeah i wrote the script inside of my Global Script so when I pulled it out to stand alone I forgot to add Waitframe(). Oh and believe me I have crashed ZC a time or two.
the script is great now! thanks, guys! but... (oh no, more questions??) is it possible to create a stamina bar just for this function (independent of the magic bar) and that can be enabled through an item?
Works pretty great! However, is there a way to make a dashing sound effect when the running is used, and a sound effect when stamina is out? Will the stamina/magic out need a different script? Maybe even dust tiles behind Link, to show he's actually running? Or an sfx that is constantly played when he is moving with the L button held down?
Also, can the magic only be used when he's actually running, and not holding it down and standing in one spot?
It is still very basic. If you just hold L or L and *DIR* while scrolling the meter will keep draining.
Run with independent stamina meter
CODE
const float Lspeedpercent=150; const int green = 33; //value can be modified depending on tileset palette const int white = 1; //value can be modified depending on tileset palette const int xoffset = 176; //initial x offset for top left rectangle const int yoffset = 4; //initial y offset for top left rectangle const int stamDrain = 15; //Rate per frames stamina will decrease by 8 const int stamFill = 30; //Fill rate int stamMax = 96; //Full stamina meter. int stamina = 96; int stams = 3; //Number of Stamina Cells to display
item script StaminaCell //Increases Max Stamina { void run(){ stamMax += 32; stams += 1; stamina = stamMax;} //Stamina meter is based off magic so a cell is 32
}
global script Slot_2 { void run() { int color; int globaltime; //--For L Run Script float Lspeed=Lspeedpercent/100; int x=Link->X; int y=Link->Y; int curmap=-1; int curscreen=-1; //one time things go here
while(true) { float stamCheck = (stamina / stamMax) * stams; int shade = Ceiling(stamCheck); for(int i=0; i<stams; i++) { if(stams-i > shade) color = white; else color = green;
I took inspiration(which is to say i stole a chunk of code and modified it to my needs) from Z2 Boss Health Meter: http://www.purezc.co...showtopic=54090
Very cool, dude! But one thing is happening: the stamina bar is being hidden in the elements of layer 3. There's something in the script where I can change the bar to be visible above all layers?
It reminds me that my greatest desire is to remove the passive subscreen, leaving everything visible on the screen (like the mirror of the moon project).
I updated it to draw on the 6th layer. You can also change the first value of Screen->Rectangle to the layer you want the meter to be on.
Also I made a second version by changing the script a little. Pressing A and B now reduce some of the Stamina Meter. If the Stamina Meter hits 0 there is a delay before it starts to refill and while it's empty all buttons but the direction buttons are disabled.
problem with the layers: solved! thanks again :) but new issues have appeared XD the function is still enabled without requiring an item for it. i didn't understand why this is happening. about using stamina with buttons A and B, it makes sense, but it would be disastrous in boss fights! so I preferred to disable this part of the script by changing the values of InpA and InpB to zero.
sorry to ask so many things, buddy. i would like to help more if I knew Zscript...
problem with the layers: solved! thanks again but new issues have appeared XD the function is still enabled without requiring an item for it. i didn't understand why this is happening. about using stamina with buttons A and B, it makes sense, but it would be disastrous in boss fights! so I preferred to disable this part of the script by changing the values of InpA and InpB to zero.
sorry to ask so many things, buddy. i would like to help more if I knew Zscript...
Like I said the script is still basic. Do you mean that if you push A or B and there is no item set there it still uses Stamina? I didn't think that was much of an issue and unless your repeatedly hitting a button that (at that point) does nothing then I doubt most people would notice it. But I will fix it eventually. And about the disabling of buttons when at 0 being disastrous in a Boss Fight, that is kind of the point. The player has to manage their usage, not just go running and slashing about.
If you don't care for the feature where buttons get disabled when Stamina Meter is 0 use the first script.
My plan for this script is to enable the function only when the item is being used (just as the most of the Link's weapons). case it is implemented in the script, will be very useful :) I also think interesting the changes that Jared suggested. I just don't know if it is easy to adapt to the script...
About the problem with buttons A and B, I really will not use this function, so I'll do what you suggested and use the 1st script. Thanks a lot for the help and patience, dude!