Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Global Scripts...

7 replies · 2,011 views · Started 20 April 2009

import "std.zh"

global script potion{
bool use = false
void run(){
while(true){
if(Link->InputL = true && Link->InputR = true){
if(Link->Item[40] = true){
Link->Item[40] = false;
Link->ItemJinx = 0;
Link->SwordJinx = 0;
//We restore HP and MP as it is done with potions.
bool use = true;
waitframe();
}
else if(Link->Item[39] = true && use = false){
Link->Item[39] = false;
Link->ItemJinx = 0;
Link->SwordJinx = 0;
//We restore HP and MP as it is done with potions.
bool use = true;
waitframe();
}
else{
waitframe();
}
}
}
}
}

The desired effect is to simply have the potions easier to use by simply pressing L and R at the same time. "Z+X using default keys." This also allows you to use them if your Jinx by both types of bubbles. Also, is the rest of it look functional?

import "std.zh"

global script potion{
void run(){
while(true){
if(Link->InputL && Link->InputR) DoPotionUse();
Waitframe();
}
}

void DoPotionUse() {
if(Link->Item[I_POTION2]) {
Link->Item[I_POTION2] = false;
Link->Item[I_POTION1] = true;
} else if(Link->Item[I_POTION1]) {
Link->Item[I_POTION1] = false;
} else {
return;
}

Link->ItemJinx = 0;
Link->SwordJinx = 0;
//We restore HP and MP as it is done with potions.
Link->HP = Link->MaxHP;
Link->MP = Link->MaxMP;

//so this is not triggered next frame
Link->InputL = false;
Link->InputR = false;
}
}

No idea how one could simulate the filling effect of a potion, so don't sweat it, and just restore it instantly.

A few tips:

- When comparing booleans in an if statement, you don't have to go:

if(myBoolean == true)

Just go:

if(myBoolean)

(If you do write " == true", make sure you DON'T write " = true", as that's entirely different!)

- Variables can either go inside a function, or outside the whole script. They cannot go inside the script, but outside a function.

- When writing global scripts, please format them like I did, so that it's easier to combine scripts. Now, it's easy to combine with the ladder script, or whatever.

pkmnfrk wrote:No idea how one could simulate the filling effect of a potion, so don't sweat it, and just restore it instantly.

😱
Really?

Store the amount of HP you need to give Link in an integer, then run a for loop for the length of that integer and return 1 hp every frame.
Or something.

Yeah, that's almost it. But here's what you want:


// in your conditional statement
int dif = Link->MaxHP - Link->HP;


// in your main loop
if(dif > 0){
dif--;
Link->HP++;
Game->PlaySound(SFX_REFILL);
}

That will restore hearts as per Z1 style.

Try compiling it first guys. It saves a bunch of hassle on my part. 🙄

I keep geting a T21 error on line 191. It can't match DoPotionUse.

Try compiling it yourself, it saves a bunch of hassle on our part.
The people who are writing the scripts are doing you a favour.
I just tried that script and it compiles fine for me.

And not quite Gleeok, Z1 doesn't restore a 16th of a heart every frame, it restores a whole heart doesn't it?

If you used pkmnfrk's script. Yes, but what if I wanted to do what Gleeok suggested. Which means I'm implementing his idea wrong.

Oh.

int dif;

global script potion{
void run(){
while(true){
if(Link->InputL && Link->InputR) DoPotionUse();
Waitframe();
}
}

void DoPotionUse() {
if(Link->Item[I_POTION2]) {
Link->Item[I_POTION2] = false;
Link->Item[I_POTION1] = true;
dif = Link->MaxHP - Link->HP;
} else if(Link->Item[I_POTION1]) {
Link->Item[I_POTION1] = false;
dif = Link->MaxHP - Link->HP;
} else if(dif == 0){
return;
}

Link->ItemJinx = 0;
Link->SwordJinx = 0;
//We restore HP and MP as it is done with potions.
Link->HP = Link->MaxHP;
Link->MP = Link->MaxMP;

//so this is not triggered next frame
Link->InputL = false;
Link->InputR = false;
dif--;
Link->HP++;
Game->PlaySound(SFX_REFILL);
}
}