PDA

View Full Version : Dynamic Heart Piece per Heart Container determining...



beefster09
07-21-2007, 07:58 PM
I had a cool idea, so the more heart containers you assemble, the more you need. It can only be done by scripting, yet I think it lacks the two key variables and a loophole-free conditioning.

1. Is there a scripting-accessible variable that affects the HCP subscreen tile?
2. Can you change the HCP/HC value in scripting?
3. How could I check how many already-completed Heart Containers (like the ones from bosses) the player has?

DarkDragon
07-21-2007, 08:34 PM
1. Not that I know of.
2. Yes. Use Game->Generic[].
3. Link->MaxHP?

beefster09
07-21-2007, 09:04 PM
1. Would it be easy to make? (as in it being a simple enough suggestion that it wouldn't count as a feature)
2. Thanks
3. Sorry, I mean just how many weren't made with HCPs... Though I guess I could just check how many HCPs were collected so far.

4. Is there any suitable workaround for #1 if it isn't allowed?

DarkDragon
07-21-2007, 09:49 PM
Unfortunately, what you're really asking for is the ability to edit the properties of the "Weapons/Misc" objects, which will require significant effort to finish.

beefster09
07-21-2007, 10:43 PM
Couldn't you just enable it for the HCP tile to go along with the Generic value?

EDIT: I found a workaround solution. I would like to know whether pickup scripts are implemented, otherwise it will make things much, much harder. Are pickup scripts implemented?

Dan Furst
07-23-2007, 11:30 AM
This is like the honeycomb system in Banjo Tooie. :)

Yes, you should be able to attach pickup scripts to heart pieces that modify Generic[GEN_HCPPERHC]. However, you should use it in conjunction with Generic[GEN_HEARTPIECES].

When you pick up a container-completing heart piece, you know that Generic[GEN_HEARTPIECES] == 0, so it's as simple as


if(Game->Generic[GEN_HEARTPIECES] == 0)
{
Game->Generic[GEN_HCPPERHC]++;
}

beefster09
07-23-2007, 12:49 PM
Yes, that's where I got the idea, but the problem is with that, the Heart container on the subscreen would appear to be in halves or thirds or whatever I set it to at first. Plus, I'd have to hide 45 Heart Pieces instead of 32, as it would be harder to keep track. (1-9 as opposed to 2,2,3,3,3,4,4,5,6)

I just need to know how to use pickup scripts. Do you just call it an Item Script and assign it the proper number in the item editor on the pickup tab?

Dan Furst
07-23-2007, 01:07 PM
Yep, you write and import it like any ordinary item script, but you set the script in the pickup tab instead of the action tab.

Also, you could always keep track of the HCPs/HC within the game screen with ffcs, if you don't mind it being there.

beefster09
07-23-2007, 01:48 PM
Uhh... I tried it and it won't work. The script refuses to run.

C-Dawg
07-23-2007, 02:47 PM
Just make this from scratch. Make a new item, call it NewHCP. It increments a global variable when you pick it up. Make a game counter that keeps track of how many you have and displays the current number on your subscreen. Global variable keeps track of how many NewHCP you need to collect to make a heart. When you have as many NewHCPs as the global variable, your total hearts and the global variable increase.

beefster09
07-23-2007, 03:54 PM
Do I really have to use global scripts/variables? Yuck!

Dan Furst
07-23-2007, 04:00 PM
C-Dawg: I was under the impression that global variables do not save, which is why I suggested the above method.

beefster: Do you have a Waitframe() or Quit() at the end of it? It might need it. (You can always test that the code is even getting there with my personal favorite method: Link->X+=16 at the top of run(), in this case.)

Now that I think about it more, you could probably implement it just like Banjo-Tooie. Have someone who trades "pieces of heart" for heart containers. They first ask for 2, then eventually 3, 4, etc. This would avoid the need to have half/third/quarter/etc. graphics in the subscreen.

If you wanted to.

Dan Furst
07-23-2007, 04:40 PM
Okay, I just tried this.

There is a subtlety here that makes it a little more difficult. The entire script is run before the number of HCP's is updated. So when you pick up the first one, the script runs and reports that you have zero HCPs. But this is "workaroundable."

Attach this script to the standard HCP to run at pickup (no new item required).

*code removed, see edit*

With this, when the first piece is picked up, the internal HCP/HC goes to two before it records that you have 1. At the next piece, you have two so it completes a HC. At the next piece, it thinks you have 0 so it increases the counter again (to 3). Rinse, repeat.

To have the standard 9 containers' worth of pieces, you'd need 54 HCPs. If you started at one instead of two, you'd need 45. If you wanted a (223334456) scheme, well, I don't know how you'd accomplish that. (Like I said, I'm pretty sure global variables don't save.)


EDIT:

I further refined the script, since it didn't exactly work with an initial HCP/HC of 1.


import "std.zh"
item script hcp{
void run()
{
if(Game->Generic[GEN_HEARTPIECES] ==
Game->Generic[GEN_HCPPERHC] - 1)
{
Game->Generic[GEN_HCPPERHC]++;
Game->Generic[GEN_HEARTPIECES] = -1;
Link->MaxHP += 16;
Link->HP += 16;
}
}
}

With this code, set the init data to whatever you truly want it to be at start.


Edit Again:

Verified that global variables don't save. I tried this code
import "std.zh"

int repeat;

item script hcp{
void run()
{
if(Game->Generic[GEN_HEARTPIECES] ==
Game->Generic[GEN_HCPPERHC] - 1)
{
if(Game->Generic[GEN_HCPPERHC] == 2)
{
if(repeat < 1)
{
repeat++;
}
else
{
Game->Generic[GEN_HCPPERHC]++;
repeat = 0;
}
}
else if(Game->Generic[GEN_HCPPERHC] == 3)
{
if(repeat < 2)
{
repeat++;
}
else
{
Game->Generic[GEN_HCPPERHC]++;
repeat = 0;
}
}
else if(Game->Generic[GEN_HCPPERHC] == 4)
{
if(repeat < 1)
{
repeat++;
}
else
{
Game->Generic[GEN_HCPPERHC]++;
repeat = 0;
}
}
else if(Game->Generic[GEN_HCPPERHC] > 4)
{
Game->Generic[GEN_HCPPERHC]++;
repeat = 0;
}
Game->Generic[GEN_HEARTPIECES] = -1;
Link->MaxHP += 16;
Link->HP += 16;
}
}
}


which is setup to allow for (223334456) upgrading. It works if you don't save and quit. If you do, "repeat" always gets set back to zero.

HOWEVER,

I belive you could infact get around even this. You could create two new miscellaneous items, and check Link->Item[] to see if he has them. Basically, having neither is like repeat == 0, having the first is like repeat == 1, and having both is like repeat == 2.


My final answer is, yes even with all these limitations, you can in fact have a non-buggy 223334456 HCP/HC progression. Don't ask me about the subscreen. :googly:

beefster09
07-23-2007, 05:05 PM
Okay, Now I should be able to fix it. And global variables do save. So I could do it your way if I just wanted numbers instead of pictures.
And, well your script would be helpful, But I am doing things a bit differently. I told ZC that there are 35 HCP's per HC, so at each increment, it adds a heart to the meter. And there is a foolproof measuring device preventing you from going over the nine containers via a potential glitch or any extra pieces I might hide.

Dan Furst
07-23-2007, 05:31 PM
If globals save, I'm not seeing it. How are you achieving this?

I've tried with 478 and 492 and I'm pretty convinced globals don't save.

beefster09
07-23-2007, 05:52 PM
Well, they only save according to the Devs. I haven't really messed with them. Maybe it's a bug. Report it.

Dan Furst
07-23-2007, 06:07 PM
Yeah, we talked about it in this thread:
http://www.armageddongames.net/forums/showthread.php?t=98188

I don't know what the original intended behavior was, or whether this would break old scripts. I think jman is the guy to talk to. It would be nice if someone could email/AIM/YIM/ICQ/fax/visit him and ask.

beefster09
07-23-2007, 06:56 PM
Jman quit the team for a Sonic project... I guess they aren't saved.

beefster09
08-11-2007, 08:39 PM
Crap!! I have to redo the script because of that annoying bug that erases the scripts in the buffer! XD

DarkDragon
08-11-2007, 09:39 PM
Globals save as of the last build. There was a bug in the global script system that caused globals to be reinitialized every time a quest started.

What buffer bug?

beefster09
09-02-2007, 12:27 AM
When you import a new buffer, it erases all of the scripts in the loader except for the name.