I wrote a script!!! but it ain't dun wurk good...
I'm writing a friggin script!!!! Yep, so anyone wan't to help me?
Here's what I got:
Code:
import "std.zh"
item script Enmity
{
void run()
{
if (Link->MaxHP <= 16);
{
Quit();
}
else if (Link->HP += 360);
PlaySound(25);
Link->HP -= 16;
Link->MaxHP -= 16;
}
}
So what i'm trying to do is make a VERY simple item script that:
1) plays sfx
2) Refills your life
3) Removes a heart container
*Note that I am trying to put the sacrifice heart container last to get rid of those damned else if's*;)
---------Got this one---------------------------
-Okay round 2: (I think i'm getting better....)- still need help with this though....
Code:
item script Wand_of_Wonder
{
void run()
{
if(Game->Counter[CR_RUPEES] == 0 // Link has no rupees?...
playsound(2);
playsound(2);
playsound(2);
playsound(2);
playsound(2);
Game->Counter[CR_RUPEES] = 5; // give him some!
waitframes(6);
CreateNPC(105) * NPC_PATRA3 // and create a Patra 3... fuck yeah
{
else if(Game->Counter[CR_PUPEES] >= 1; // But don't get greedy or...
waitframe();
playsound(15);
Game->Counter[CR_LIFE] = 0; // Link dies...oopsie!
}
}
}
Heh, the second one is just for learning purposes...well they're all for learning purposes, but any feedback of what i'm doing wrong would help out ALOT.
EDIT: I'm learning :rolleyes:
----------------Got this one as well. thanks pknklfk....hmm-----------------
Code:
item script Rod_of_Ouchy
{
void run()
{
if (int HP <= 16)
{
Quit()
}
else if (ScrnNPC == 0)
{
Quit()
}
else if (int HP ->16)
{
ScrnNPC == 1 (ScrnNPC HP -= 6)
}
Link max HP -= 16
}
}
}
Keep in mind that these are my first scripts ever. :D
Re: I wrote a script!!! but it ain't dun wurk good...
Couple questions >_>
Code:
item script Rod_of_Ouchy
{
void run()
{
if (int HP <= 16)
{
Quit()
}
else if (ScrnNPC == 0)
{
Quit()
}
else if (int HP ->16)
{
ScrnNPC == 1 (ScrnNPC HP -= 6)
}
Link max HP -= 16
}
}
}
where is ScrnNPC declared? You seem to play around with it a lot, but it doesn't actually exist anywhere.
"Link" does, but then the compiler would get confused by "max" and "HP" following it.
Also, == means "equals", = means "set".
The arrow operator (->) is used only to dereference pointers, not to fill in for the greater than operator (>)
Every statement (sentence) needs a semicolon (period) at the end.
Here is a fixed version:
Code:
item script Rod_of_Ouchy
{
void run()
{
if (Link->HP <= 16) { //Link has to have a minimum amount of health
Quit();
} else if (Screen-NumNPCs() == 0) { //And, there has to be an enemy
Quit();
} else { //by this point, we know that link has more than 16 HP and there are enemies on screen
npc enemy = Screen->LoadNPC(1); //Find the first enemy
enemy->HP -= 6; //hurt it (maybe even kill it)
Link->HP -= 16; //subtract one heart, and...
Link->MaxHP -= 16;//... one heart container.
}
} //the Quit() here is implied by the end of the script
}
Re: I wrote a script!!! but it ain't dun wurk good...
Quote:
where is ScrnNPC declared? You seem to play around with it a lot, but it doesn't actually exist anywhere.
I don't know :shrugs: You know how long it took me to come up with that? I have basically the std.zh and the documentation thread written by DarkDragon to go by.
Quote:
"Link" does, but then the compiler would get confused by "max" and "HP" following it.
Doh! I knew I fucked that up...
Quote:
Also, == means "equals", = means "set".
You've just saved me hours right there.
Quote:
The arrow operator (->) is used only to dereference pointers, not to fill in for the greater than operator (>)
Again, thank you much!
Alright, i'm gonna rewrite it myself and not just copy it.
Code:
item script Rod_of_Ouchy
{
void run()
if(link->HP <=16); // >= means less than or equal!!! yay!
}
Quit();
}
else if (ScrnNPC == 0); //this line does work...right?
{
Quit()
}
else;
{
npc enemy = Screen->LoadNPC(1); //i'm a little confused...
enemy->HP -= 6; // I didn't think it was that simple
Link->HP -= 16; //only hurt...not maim.
}
}
} // Why three }}}?
Thanks alot. I just learned a bunch of stuff. I think I can give the first one onother go now. :D
EDIT: Damnit, what's wrong with this. it looks good enough...it compiled but it didn't do anything...crap.
Code:
import "std.zh"
item script Enmity
{
void run()
{
if (Link->MaxHP <= 16){
Quit();
} else if (Link->MaxHP > 16) {
Link->HP += 360;
Link->HP -= 16;
Link->MaxHP -= 16;
playsound(25)
}
}
}
Re: I wrote a script!!! but it ain't dun wurk good...
In your rewrite, remember that Link must be capitalized. (So "Link->HP", not "link->HP")
I've commented what your code is doing:
Code:
import "std.zh"
item script Enmity
{
void run()
{
if (Link->MaxHP <= 16){ // Checks whether Link's MAXIMUM, not CURRENT
// Hit Points are equal to or less than 16.
Quit(); // So, it will quit if Link doesn't have MORE THAN 16
// heart containers. Fair enough.
} else if (Link->MaxHP > 16) { // You don't need another if statement.
// if Link does not have 16 or less heart
// containers, he's must have more than 16
// right? Just use "else."
Link->HP += 360; // This will add 360 to Link's current health
// irrespective of Link's total hearts. You
// will end up having more health than
// heart containers. Won't display, but it
// will count against enemy hits. In other
// words, maximum HP is not a hard cap
// unless you specifically code it that way.
Link->HP -= 16; // This reduces the 360 you just awarded
// by 16. Link ends up gaining 344 HP.
Link->MaxHP -= 16; // Goodbye, one heart.
playsound(25) // You want: "Game->PlaySound(25);"
}
}
}
Re: I wrote a script!!! but it ain't dun wurk good...
Stupid, ...stupid.
Thanks C- , I knew I was off somewhere in there...
I feel like I understand a little more of this stuff every day.
***2CD REVISION*** Haha!
import "std.zh"
Code:
item script Nemesis
{
void run()
{
if (Link->MaxHP <= 16){
Game->PlaySound(19);
Game->PlaySound(9);
Quit();
} else {
Link->HP = Link->MaxHP;
Link->HP -= 16;
Link->MaxHP -= 16;
Game->PlaySound(15);
Game->PlaySound(23);
Game->PlaySound(14);
}
}
}
Re: I wrote a script!!! but it ain't dun wurk good...
Heh, pretty nice. So this script would recharge Link's health to full, then subtract an equal one hearts worth of health and maximum health. How dire. :p
Why not also put Game->Playsound(xx) right before the "Quit();" where it'd play an error message instead of just quitting? It's good to have some sort of output rather than nothing happening. At least you know the script is working that way.
And what the hell. When wouldn't we need the line: import "std.zh" ?
Re: I wrote a script!!! but it ain't dun wurk good...
Holy Shit! I Just wrote a MFing Script!!!!!!!!!!!!!!!!!!!!! :D:D:D:D:D:D:D:D:D:D
And It works!! It friggin works!!!!!! That's awesome...
Two day's age I was calling ffc "FCC" and now I finished a script and pigs didn't fly out of my ass. who knew.
Pshh, it was nothing. :cool:
Quote:
Heh, pretty nice. So this script would recharge Link's health to full, then subtract an equal one hearts worth of health and maximum health. How dire.
Why not also put Game->Playsound(xx) right before the "Quit();" where it'd play an error message instead of just quitting? It's good to have some sort of output rather than nothing happening. At least you know the script is working that way.
And what the hell. When wouldn't we need the line: import "std.zh" ?
Yeah, thanks ;) That's a good idea. Hopefully these will get easier to make without this much hassle. I must of read "std.zh" like 20 times.
Hey Petoe, monkeys can make scripts...see.
Hmm...now I gotta actually name it. That could take another day right there. :googly:
Thank's everybody!
Re: I wrote a script!!! but it ain't dun wurk good...
Heh. Nice stuff, man! Now, perhaps we could even "fancy it up" a little? For example, we could count out how many Heart Containers Link has, and how many of those are filled. We could take the difference, divide by, say, four, (16 Hits per container, so each quarter is four. Though technically the Gold Ring introduces two-segments at a time. x x. ) and we could play the healing sound for every quarter (Or eighth?) that it heals Link. Could be done with a for loop. Not sure if those are in ZScript though.
Re: I wrote a script!!! but it ain't dun wurk good...
Anything you want to do, you can do in ZScript.
Anything.*
Ponder that for a minute, and realize why it's such a good idea to learn to script.
* = Anything involving arrays or large switch statements will be a mega pain in the ass to do. But it can be done with nested if/else statements.
Re: I wrote a script!!! but it ain't dun wurk good...
Yep you can use for loops in ZScript. For loop, While loop, Do Loop (i think never tried it). It seems you guys are picking up scripting pretty quickly.. (now you probley get why everyone always says its not that hard to understand :p )