The Dink Network

Reply to Re: discarded dmod ideas?

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
August 23rd 2006, 06:23 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
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(&current_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(&current_sprite);
int &oldhp = editor_seq(&ednum, -1);
if (&oldhp != 0)
{
sp_hitpoints(&current_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, &current_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(&current_sprite, 100);
sp_que(&current_sprite, -20);
int ÷

//Wait a bit so we can transfer some variables. Maybe not needed.
wait(1);
int &shadowing = sp_brain_parm(&current_sprite, -1);
int &maxhp = sp_custom("maxhp", &current_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(&current_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.