Reply to Re: discarded dmod ideas?
If you don't have an account, just leave the password field blank.
Healthbars could be made by making them a "shadow" of the original monster (some strange sp_brain and sp_brain_parm setting), and let them have a script that checks health changes
Here's a some code I wrote up:
en-monster.c //or whatever enemy you have
void main( void )
{
//Little used trick to retrieve the value you set.
//Change 50 to whatever you want.
int &hp = sp_hitpoints(¤t_sprite, 50);
//This block can be left out if you don't store hp.
//editor_frame could be used instead.
int &ednum = sp_editor_num(¤t_sprite);
int &oldhp = editor_seq(&ednum, -1);
if (&oldhp != 0)
{
sp_hitpoints(¤t_sprite, &oldhp);
}
//(seq, fr) is the healthbar's pic.
//Brain 15 is the shadow brain. It now mimicks the monster's x and y coördinate, and size.
//Too bad about the size... Mini-monsters will have mini-healthbars.
int &hbar = create_sprite(1,1,15,seq,fr);
sp_brain_parm(&hbar, ¤t_sprite);
sp_custom("maxhp", &hbar, &hp);
sp_script(&hbar, "healthbar");
//rest of monster script here...
}
healthbar.c
void main( void )
{
//full-size, on top of the sprite
sp_size(¤t_sprite, 100);
sp_que(¤t_sprite, -20);
int ÷
//Wait a bit so we can transfer some variables. Maybe not needed.
wait(1);
int &shadowing = sp_brain_parm(¤t_sprite, -1);
int &maxhp = sp_custom("maxhp", ¤t_sprite, -1);
loop:
//A wait so the loop doesn't crash the game.
wait(100);
//Retrieve the current amount of hp.
&div = sp_hitpoints(&shadowing, -1);
&div * 100;
&div / &maxhp;
//&div is now the percentage of health.
if (&div > 100)
{
//More health than the maximum? That's not something we can display
&div = 100;
}
//Limit it to the 0-20 range.
//0 is no health, 20 is full health, 10 is middle health, etc.
//Divide by 10 to convert to 0-10 range.
&div / 5;
//For every number between 0 and 20 you should have a frame, else just change the range.
sp_pframe(¤t_sprite, &div);
//And loop back!
goto loop;
}
Note: This is experimental. I haven't ever attached a script to a shadow-brained sprite before, and I don't know what will happen, or if it even works. If there's a way to do it, though, then this is.
Here's a some code I wrote up:
en-monster.c //or whatever enemy you have
void main( void )
{
//Little used trick to retrieve the value you set.
//Change 50 to whatever you want.
int &hp = sp_hitpoints(¤t_sprite, 50);
//This block can be left out if you don't store hp.
//editor_frame could be used instead.
int &ednum = sp_editor_num(¤t_sprite);
int &oldhp = editor_seq(&ednum, -1);
if (&oldhp != 0)
{
sp_hitpoints(¤t_sprite, &oldhp);
}
//(seq, fr) is the healthbar's pic.
//Brain 15 is the shadow brain. It now mimicks the monster's x and y coördinate, and size.
//Too bad about the size... Mini-monsters will have mini-healthbars.
int &hbar = create_sprite(1,1,15,seq,fr);
sp_brain_parm(&hbar, ¤t_sprite);
sp_custom("maxhp", &hbar, &hp);
sp_script(&hbar, "healthbar");
//rest of monster script here...
}
healthbar.c
void main( void )
{
//full-size, on top of the sprite
sp_size(¤t_sprite, 100);
sp_que(¤t_sprite, -20);
int ÷
//Wait a bit so we can transfer some variables. Maybe not needed.
wait(1);
int &shadowing = sp_brain_parm(¤t_sprite, -1);
int &maxhp = sp_custom("maxhp", ¤t_sprite, -1);
loop:
//A wait so the loop doesn't crash the game.
wait(100);
//Retrieve the current amount of hp.
&div = sp_hitpoints(&shadowing, -1);
&div * 100;
&div / &maxhp;
//&div is now the percentage of health.
if (&div > 100)
{
//More health than the maximum? That's not something we can display
&div = 100;
}
//Limit it to the 0-20 range.
//0 is no health, 20 is full health, 10 is middle health, etc.
//Divide by 10 to convert to 0-10 range.
&div / 5;
//For every number between 0 and 20 you should have a frame, else just change the range.
sp_pframe(¤t_sprite, &div);
//And loop back!
goto loop;
}
Note: This is experimental. I haven't ever attached a script to a shadow-brained sprite before, and I don't know what will happen, or if it even works. If there's a way to do it, though, then this is.