The Dink Network

Multiple Brains?

May 17th 2016, 07:23 PM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
This is probably a dumb question, but it's late at night and literally the last thing left for my DMOD.

How would I go about achieving the same effect as having Brain 6 (repeat) and Brain 9 (diag) on the same sprite? I'm trying to create an enemy which cycles through a single sequence, instead of having a walk cycle.

No idea if it's even possible, but figured it's worth asking.
May 17th 2016, 08:01 PM
wizardg.gif
leprochaun
Peasant He/Him Japan bloop
Responsible for making things not look like ass 
A simple way to do that would be to load the sequence you want to repeat into the four walk cycle spots and then give it brain 9. The issue of this is that the animation will reset upon changing directions.

A different way would be to create an enemy and give it brain 9. Then give it sp_nodraw so it isn't seen. Give this all the enemy things you need: hp, defense, strength, etc... Then create the brain 6 sprites you want to use within the enemy sprite script.
Then what you want to do is constantly fetch its x and y coordinates of the invisible enemy and then set the coordinates of the drawn enemy to be the same.

Do you understand that or should I go into further detail.
May 17th 2016, 08:18 PM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
Yeah I get you, I was actually wondering about something like that, it's just a big ol' pain. Was really hoping for some kind of loop function I didn't know about to magically exist.

Cheers though. Might cop out and have it immobile but teleporting on/off screen, then use an invisible sprite like you were saying for hp and stuff.
May 17th 2016, 08:39 PM
burntree.gif
You don't have to do that. I've done this sort of thing in my dmods before including with echoes. Look at some of the scripts such as ghost1.c below.

It is even simpler for a non-directional sprite.

void main(void)
{
preload_seq(876);
int &crap = random(3, 3);
sp_speed(&current_sprite, &crap);
sp_brain(&current_sprite, 9);
sp_base_walk(&current_sprite, -1);
sp_touch_damage(&current_sprite, 6);
sp_hitpoints(&current_sprite, 12);
sp_defense(&current_sprite, 3);
sp_exp(&current_sprite, 8);
//sp_target(&current_sprite, &enemy_sprite);

int &dir;
int &fr = 0;
int &x1 = 1;
int &ct1 = 0;

toploop:

&dir = sp_dir(&current_sprite, -1);

&fr = 0;

if(&dir == 1)
{
&fr = 0;
}

if(&dir == 4)
{
&fr = 0;
}

if(&dir == 3)
{
&fr = 2;
}

if(&dir == 2)
{
&fr = 2;
}

if(&dir == 7)
{
&fr = 4;
}

if(&dir == 8)
{
&fr = 4;
}

if(&dir == 9)
{
&fr = 6;
}

if(&dir == 6)
{
&fr = 6;
}

&fr += &x1;
sp_pframe(&current_sprite, &fr);

&ct1 += 1;
if(&ct1 > 2)
{
&ct1 = 0;
&x1 += 1;
}

if(&x1 > 2)
{
&x1 = 1;
}

wait(33);
wait(99);
goto toploop;

}

void die( void )
{
int &hold = sp_editor_num(&current_sprite);
if (&hold != 0)
editor_type(&hold, 6);

&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
int &junk = create_sprite(&save_x, &save_y, 0, 876, 9);
sp_que(&junk, 1);
external("emake","small");
}
May 17th 2016, 08:49 PM
burntree.gif
This is how simple it is for a non-directional sprite:

void main(void)
{
sp_brain(&current_sprite, 9);
sp_speed(&current_sprite, 4);
sp_exp(&current_sprite, 15);
sp_base_walk(&current_sprite, -1);
sp_touch_damage(&current_sprite, 8);
sp_hitpoints(&current_sprite, 30);
preload_seq(871);

if (random(2,1) == 1)
{
sp_target(&current_sprite, 1);
}

int &fr = 1;
toploop:
sp_pframe(&current_sprite, &fr);
&fr += 1;
if(&fr > 10)
{
&fr = 1;
}
wait(66);
goto toploop;
}

void hit( void )
{
sp_target(&current_sprite, &enemy_sprite);
goto toploop;
}

void die( void )
{
int &hold = sp_editor_num(&current_sprite);
if (&hold != 0)
editor_type(&hold, 6);

&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);

external("emake","small");

}
May 17th 2016, 09:40 PM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
Oh wow, that's actually pretty clever, I hadn't thought about doing it like that. I've just finished building the guy I was working on, but if I ever need to do something similar I'll totally try it your way.
May 17th 2016, 09:44 PM
burntree.gif
Of course if you have 10 blocks left over, you could just give it the one direction and it will do all directions (if it's a non-directional sprite). The problem is that it takes up 10 blocks when it needs only 1. If fact using the loops, you could put multiple monsters in a single block, although that would probably never be necessary.