PDA

View Full Version : Max HP



Lelouche Vi Britannia
09-20-2017, 09:06 PM
Simple question. I've seen it done on a custom quest so I know it can be done; how do I display max hp numerically on the passive and active subscreens? I'm guessing it's a scripting function which is why I'm asking here.

Edit:
Had a thought. I might be able to do it by using a counter (supported on sunscreens already) to copy the value of the max value of the counter in question. I hate the thought that I might have to eat more counters just to do it this way. If you can think of a different method....

Lelouche Vi Britannia
09-21-2017, 10:55 PM
Woot! I figured it out on my own! Sadly, I do have to take up 4 counters with this nonsense but hey, 24 counters is a lot of extra counters to work with so might as well put them to good use eh?

-=SPOILER=-

I'll probably go ahead and post it on PureZC just because :P

ZoriaRPG
09-21-2017, 11:26 PM
Woot! I figured it out on my own! Sadly, I do have to take up 4 counters with this nonsense but hey, 24 counters is a lot of extra counters to work with so might as well put them to good use eh?

-=SPOILER=-

I'll probably go ahead and post it on PureZC just because :P

This is to do what? Display HP and MP Current/Max as numbers on the subscreen? if so, then aye, this is one of two options that you have available. The other, is to use draw instructions to draw the values. I essentially do what you did here, in several quests, and since then, I have become more focused on scripted draws for the subscreen elements. Either work perfectly well.

You do have one issue in this script: You want a Waitdraw() instruction, so that these update at the correct time:



const int CR_LIFECUR = 7;//set current life mirror to script 1, can be modified if needed
const int CR_LIFEMIRMAX = 8;//Set max life mirror counter to script 2, can be modified if needed
const int CR_MAGICCUR = 9;//set current magic mirror to script 3, can be modified if needed
const int CR_MAGICMIRMAX = 10;//set current magic max mirror counter to script 4, can be modified if needed

//create 4 counters on passive subscreen using script 1, 2, 3, and 4 (or chosen slots) where desired

global script Active
{
void run()
{
while(true)
{
//These should occur before Waitdraw. -Z
Game->Counter[CR_LIFECUR]=Link->HP;
Game->Counter[CR_LIFEMIRMAX]=Link->MaxHP;
Game->Counter[CR_MAGICCUR]=Link->MP;
Game->Counter[CR_MAGICMIRMAX]=Link->MaxMP;
//section may also contain other global script stuff as normal

Waitdraw();
//Stuff that should happen *after* Waitdraw(), goes here. -Z

Waitframe();
}
}
}


This is a function inside the global active script in most of my older RPG-esque quest projects:



//Call before Waitdraw()
void UpdateDisplayCounters(){
Game->Counter[CR_MAX_MP_DISPLAY] = Link->MaxMP;
Game->Counter[CR_MAX_HP_DISPLAY] = Link->MaxHP;
Game->Counter[CR_MP_DISPLAY] = Link->MP;
Game->Counter[CR_HP_DISPLAY] = Link->HP;
}


It might be a tiny bit cleaner to do it that way, and then to call a function prior to Waitdraw().


Also: You also want to use code and /code for your tags for this, not spoiler and /spoiler. You do not need (or want) indent tags. Just paste the code inside code tags, and your indentation is preserved.

As-is, when you copy/paste the code into a text file from the browser, all of your tabbing goes poof. Click the quote button on this post, to see the difference.

Lelouche Vi Britannia
09-23-2017, 12:23 AM
Also: You also want to use code and /code for your tags for this, not spoiler and /spoiler. You do not need (or want) indent tags. Just paste the code inside code tags, and your indentation is preserved.

As-is, when you copy/paste the code into a text file from the browser, all of your tabbing goes poof. Click the quote button on this post, to see the difference.

Thanks, I forgot what the actual command was to set that up.

So basically to call the function as you have it written I just have to add the line "UpdateDisplayCounters();" just before the "Waitdraw();" then put the actual function in (obvious) as you set it.

I wished I remembered that this was a thing. Its been a while since I played with the editor, and I'm still not all that good at scripting.

ZoriaRPG
09-23-2017, 04:58 AM
Thanks, I forgot what the actual command was to set that up.

So basically to call the function as you have it written I just have to add the line "UpdateDisplayCounters();" just before the "Waitdraw();" then put the actual function in (obvious) as you set it.

I wished I remembered that this was a thing. Its been a while since I played with the editor, and I'm still not all that good at scripting.


By command, you mean [ code ] and [ /code ] ...right?

The function hat I posted is custom, not from any common header. All you would need to do is change the counter IDs to whatever you are using, and call it before Waitdraw(). This is a personal style choice, but I hate to see raw instructions in global active scripts. It is far cleaner to encapsulate them all in functions.

Lelouche Vi Britannia
09-23-2017, 02:42 PM
By command, you mean [ code ] and [ /code ] ...right?

The function hat I posted is custom, not from any common header. All you would need to do is change the counter IDs to whatever you are using, and call it before Waitdraw(). This is a personal style choice, but I hate to see raw instructions in global active scripts. It is far cleaner to encapsulate them all in functions.

I agree. I also liked the identifiers you used, better than the ones I made.

Tried it last night and it worked like a charm. Code is cleaner. And now I understand the concept of functions and how they are implemented, so thanks for that!

And yes, I was referring to the "/code" command.