Multiple Brains?
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.
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.
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.
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.
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.
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.
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(¤t_sprite, &crap);
sp_brain(¤t_sprite, 9);
sp_base_walk(¤t_sprite, -1);
sp_touch_damage(¤t_sprite, 6);
sp_hitpoints(¤t_sprite, 12);
sp_defense(¤t_sprite, 3);
sp_exp(¤t_sprite, 8);
//sp_target(¤t_sprite, &enemy_sprite);
int &dir;
int &fr = 0;
int &x1 = 1;
int &ct1 = 0;
toploop:
&dir = sp_dir(¤t_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(¤t_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(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
int &junk = create_sprite(&save_x, &save_y, 0, 876, 9);
sp_que(&junk, 1);
external("emake","small");
}
It is even simpler for a non-directional sprite.
void main(void)
{
preload_seq(876);
int &crap = random(3, 3);
sp_speed(¤t_sprite, &crap);
sp_brain(¤t_sprite, 9);
sp_base_walk(¤t_sprite, -1);
sp_touch_damage(¤t_sprite, 6);
sp_hitpoints(¤t_sprite, 12);
sp_defense(¤t_sprite, 3);
sp_exp(¤t_sprite, 8);
//sp_target(¤t_sprite, &enemy_sprite);
int &dir;
int &fr = 0;
int &x1 = 1;
int &ct1 = 0;
toploop:
&dir = sp_dir(¤t_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(¤t_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(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
int &junk = create_sprite(&save_x, &save_y, 0, 876, 9);
sp_que(&junk, 1);
external("emake","small");
}
This is how simple it is for a non-directional sprite:
void main(void)
{
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 4);
sp_exp(¤t_sprite, 15);
sp_base_walk(¤t_sprite, -1);
sp_touch_damage(¤t_sprite, 8);
sp_hitpoints(¤t_sprite, 30);
preload_seq(871);
if (random(2,1) == 1)
{
sp_target(¤t_sprite, 1);
}
int &fr = 1;
toploop:
sp_pframe(¤t_sprite, &fr);
&fr += 1;
if(&fr > 10)
{
&fr = 1;
}
wait(66);
goto toploop;
}
void hit( void )
{
sp_target(¤t_sprite, &enemy_sprite);
goto toploop;
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
external("emake","small");
}
void main(void)
{
sp_brain(¤t_sprite, 9);
sp_speed(¤t_sprite, 4);
sp_exp(¤t_sprite, 15);
sp_base_walk(¤t_sprite, -1);
sp_touch_damage(¤t_sprite, 8);
sp_hitpoints(¤t_sprite, 30);
preload_seq(871);
if (random(2,1) == 1)
{
sp_target(¤t_sprite, 1);
}
int &fr = 1;
toploop:
sp_pframe(¤t_sprite, &fr);
&fr += 1;
if(&fr > 10)
{
&fr = 1;
}
wait(66);
goto toploop;
}
void hit( void )
{
sp_target(¤t_sprite, &enemy_sprite);
goto toploop;
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
external("emake","small");
}
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.
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.