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?
Printable View
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:
I haven't tested it, but it compiles fine.Code: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;
}
}
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?
D1: Amount to refilCode: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;
}
}
}
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.
Code: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();
}
}
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:
Wouldn't that work and be less complicated than your script?Quote:
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;
}
}
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)?
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.
Yeah, that's what the 'if(Link->MP > Link->MaxMP) Link->MP = Link->MaxMP;' line is for.