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

[Request] Custom potions

16 replies · 5,834 views · Started 21 December 2008

I'm posting this here because I'm pretty sure this can't be done without scripting.

I want to have seperate potions for HP and MP. I know I can edit the normal potions to refill HP only, but can I make a custom item to refill MP?

Sure you can. It would be a very simple script. I might try to right it. I'll see if I can.

Edit:


import "std.zh"

//This script, when attached to an item, works as a magic potion.
//It refills Link's magic, but disappears after one use.
//A simple script, but useful.
//Set D0 to be the ID of the item.

item script MagicPotion{

void run (int id){

Link->MP=Link->MaxMP;
Link->Item[id] = false;

}

}

I haven't tested it, but it compiles fine.

It works~

Though… I forgot to specify that I only want it to refill 128MP, not 100%.

EDIT: Blerrblerrblehgh.

Urm....

When you pick up a magic jar item, does your HP increase steadily or instantly?
If it's steadily, then this script wouldn't be very hard to do.

If it's instantly then you'd have to add a section to the global script which is a bit of a pain really.

Ya' know, that part's not important. Forget the gradual refill. What I really need if for the potion to fill 128 MP instead of the maximum. Also, how would I change this to work for HP, so I can make custom health potions as well?

item script CustomPotion{
void run(int refil,int counter){
if(counter == 0){
Link->MP += refil;
if(Link->MP > Link->MaxMP) Link->MP = Link->MaxMP;
}else{
Link->HP += refil;
if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
}
}
}

D1: Amount to refil
D2: 1 to refil hearts, 0 to refil magic

To take the item away after useage, there's a little checkbox somewhere in the item editor.

No, it's actually quite easy to do.

void Refill(){
int hp = Link->MaxHP-Link->HP;
for(int i;i<mp;i++){
Link->HP++;
Game->PlaySound(SFX_REFILL);
Waitframe();
}
}

void RefillMagic(){
int mp = Link->MaxMP-Link->MP;
for(int i;i<hp;i++){
Link->MP++;
if(Link->MP < Link->MaxMP){
Link->MP++;i++;
}
Game->PlaySound(SFX_REFILL);
Waitframe();
}
}

Joe123 wrote:
item script CustomPotion{
void run(int refil,int counter){
if(counter == 0){
Link->MP += refil;
if(Link->MP > Link->MaxMP) Link->MP = Link->MaxMP;
}else{
Link->HP += refil;
if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
}
}
}

D1: Amount to refil
D2: 0 to refil hearts, 1 to refil magic

To take the item away after useage, there's a little checkbox somewhere in the item editor.

Schweet~ Everything works. Except you said the D2 thing backwards; 0 is magic and 1 is hearts.

Oops. Nevermind.

Gleeok wrote:No, it's actually quite easy to do.

If you want to A: add a section to the global script and B: stop all other functions in the global script for 128 frames or something then yeah sure...

Yeah, I'm not worried about the gradual refill. I just wanted the custom MP potion to match the behavior of the normal potion, but I'm just using a custom HP potion instead so the both refill instantly.

Well, if the magic jar item refils gradually you could just spawn a magic jar on top of Link when he drinks a potion. I can't remember though.

Wait, why does it need to be that complicated? Couldn't you just make it like:


import "std.zh"

//This script, when attached to an item, works as a magic potion.
//It refills Link's magic, but disappears after one use.
//A simple script, but useful.
//Set D0 to be the ID of the item.

item script MagicPotion{

void run (int id){

Link->MP+=128;
Link->Item[id] = false;

}

}


Wouldn't that work and be less complicated than your script?

Yes, but good programming habits say to make your code as general as possible, so it can be re-used.

Speaking of which, can't this be done w/o scripting (using the item editor)?

CaRmAgE wrote:Speaking of which, can't this be done w/o scripting (using the item editor)?

I don't think so, beause there's only one potion class. You have to use a custom item class to make a seperate potion, and custom classes aren't exactly customisable [without scripting].

Yes, but my script works for both types of potion, and you can choose how much it'll refill.

Your script will also fill Link's MP over the max, which is never very good.
You don't really need the line to remove the item either, as there's an option in the item editor which does that.

Scripts can set Link's MP high than his max MP? Just goes to show how much I know about scripting.