Moving sprite damaging other sprites
I've been messing around with moving objects that damage everything that touch them. My first guess was to use brain 11, but it seems a brain 11 sprite is unable to move.
What I'm trying to accomplish is this:
1) The lethal object has to move vertically from outside of the screen at the top, to outside of the screen at the bottom, and back again, and repeat.
2) The lethal object has to hurt anyone who touches it.
3) When a sprite (or Dink) touches the lethal object, the object freezes and after 500 milliseconds or so, the object stops hurting Dink or the sprites.
4) When Dink hits the object, it starts moving vertically again, and again hurting anyone who touches it.
I already made it work that it does all this, but I can't figure out how to make it that the lethal object also hurts other sprites besides Dink.
This is my script:
void main (void)
{
int &dam;
sp_brain(¤t_sprite, 10);
sp_hitpoints(¤t_sprite, 10);
sp_base_death(¤t_sprite, 210);
sp_touch_damage(¤t_sprite, 1);
sp_speed(¤t_sprite, 11);
loop:
freeze(¤t_sprite);
move_stop(¤t_sprite, 2, 600, 1);
move_stop(¤t_sprite, 8, -250, 1);
freeze(¤t_sprite);
wait(100);
goto loop;
}
void hit (void)
{
&dam = sp_hitpoints(¤t_sprite, -1);
if (&dam > 7)
{
int &crap = random(2,1);
if (&crap == 1)
{
sp_speed(¤t_sprite, 16);
sp_touch_damage(¤t_sprite, 3);
freeze(¤t_sprite);
move_stop(¤t_sprite, 2, 600, 1);
freeze(¤t_sprite);
}
if (&crap == 2)
{
sp_speed(¤t_sprite, 16);
sp_touch_damage(¤t_sprite, 3);
freeze(¤t_sprite);
move_stop(¤t_sprite, 8, -250, 1);
freeze(¤t_sprite);
}
}
if (&dam < 8)
{
sp_touch_damage(¤t_sprite, 0);
freeze(¤t_sprite); }
}
void touch (void)
{
wait(500);
sp_touch_damage(¤t_sprite, -1);
sp_speed(¤t_sprite, 0);
}
What I'm trying to accomplish is this:
1) The lethal object has to move vertically from outside of the screen at the top, to outside of the screen at the bottom, and back again, and repeat.
2) The lethal object has to hurt anyone who touches it.
3) When a sprite (or Dink) touches the lethal object, the object freezes and after 500 milliseconds or so, the object stops hurting Dink or the sprites.
4) When Dink hits the object, it starts moving vertically again, and again hurting anyone who touches it.
I already made it work that it does all this, but I can't figure out how to make it that the lethal object also hurts other sprites besides Dink.
This is my script:
void main (void)
{
int &dam;
sp_brain(¤t_sprite, 10);
sp_hitpoints(¤t_sprite, 10);
sp_base_death(¤t_sprite, 210);
sp_touch_damage(¤t_sprite, 1);
sp_speed(¤t_sprite, 11);
loop:
freeze(¤t_sprite);
move_stop(¤t_sprite, 2, 600, 1);
move_stop(¤t_sprite, 8, -250, 1);
freeze(¤t_sprite);
wait(100);
goto loop;
}
void hit (void)
{
&dam = sp_hitpoints(¤t_sprite, -1);
if (&dam > 7)
{
int &crap = random(2,1);
if (&crap == 1)
{
sp_speed(¤t_sprite, 16);
sp_touch_damage(¤t_sprite, 3);
freeze(¤t_sprite);
move_stop(¤t_sprite, 2, 600, 1);
freeze(¤t_sprite);
}
if (&crap == 2)
{
sp_speed(¤t_sprite, 16);
sp_touch_damage(¤t_sprite, 3);
freeze(¤t_sprite);
move_stop(¤t_sprite, 8, -250, 1);
freeze(¤t_sprite);
}
}
if (&dam < 8)
{
sp_touch_damage(¤t_sprite, 0);
freeze(¤t_sprite); }
}
void touch (void)
{
wait(500);
sp_touch_damage(¤t_sprite, -1);
sp_speed(¤t_sprite, 0);
}
Well, you should name the NPCs as temp1hold and so on. And when the NPC touches it you could put hurt(&temp1hold, damage you want here);
Ofcourse, you'd have to give the NPC health points first. You can set it like this: sp_hitpoints(&temp1hold, health you want here);
Ofcourse, you'd have to give the NPC health points first. You can set it like this: sp_hitpoints(&temp1hold, health you want here);
Use brain 11 anyway, but use sp_mx and sp_my (or sp_move_x and sp_move_y) for movement, like how it's done in the fireball script.
Only dink can trigger the touch() procedure, but anything will trigger the damage() procedure. I don't know if damage() suffers from the same issue as touch(), i.e. if it keeps running as long as it detects that it's being triggered. The fix for touch is to set sp_touch_damage() to -1, not sure how to do it if the same thing happens with missiles. Probably set sp_brain() to 0 or something, and back to missile brain when done.
Only dink can trigger the touch() procedure, but anything will trigger the damage() procedure. I don't know if damage() suffers from the same issue as touch(), i.e. if it keeps running as long as it detects that it's being triggered. The fix for touch is to set sp_touch_damage() to -1, not sure how to do it if the same thing happens with missiles. Probably set sp_brain() to 0 or something, and back to missile brain when done.
sp_my didn't do the trick, but sp_dir did!
The only thing that isn't working anymore is that I can't damage the missile by touching it. I know this sounds ridiculous, but I can't tell you what I'm working on yet. I just need to make it so when I touch the missile, it gets damage. With brain 10, I used to do this:
void touch (void)
{
hurt(¤t_sprite, 100);
}
simple as that. Now it's a missile brain, I made this:
void touch (void)
{
sp_touch_damage(¤t_sprite, -1);
sp_brain(¤t_sprite, 10);
hurt(¤t_sprite, 100);
}
However, it doesn't work: the missile sprite doesn't receive any damage. It does receive damage when I hit it however (which is good).
Anyone know how to fix this?
The only thing that isn't working anymore is that I can't damage the missile by touching it. I know this sounds ridiculous, but I can't tell you what I'm working on yet. I just need to make it so when I touch the missile, it gets damage. With brain 10, I used to do this:
void touch (void)
{
hurt(¤t_sprite, 100);
}
simple as that. Now it's a missile brain, I made this:
void touch (void)
{
sp_touch_damage(¤t_sprite, -1);
sp_brain(¤t_sprite, 10);
hurt(¤t_sprite, 100);
}
However, it doesn't work: the missile sprite doesn't receive any damage. It does receive damage when I hit it however (which is good).
Anyone know how to fix this?
Maybe you should add hitpoints to it. Like this, sp_hitpoints(¤t_sprite, health you want here);
Or if I'm wrong, the problem probably is that you added the sp_touch_damage(¤t_sprite, -1);
I'm not sure, though.
Or if I'm wrong, the problem probably is that you added the sp_touch_damage(¤t_sprite, -1);
I'm not sure, though.
No offense Skull, but I know how to script
You're just naming the absolute basics, but I'm trying to figure out how to utilize the missile brain by letting it not act like a missile.
With a brain 10, I can hurt it by touching it, but with brain 11, it doesn't take damage by the "hurt" procedure. It does take damage by hitting it however. I tried to change its brain back to 10 when touching it, but it doesn't work.
Regardless, thanks for helping!

With a brain 10, I can hurt it by touching it, but with brain 11, it doesn't take damage by the "hurt" procedure. It does take damage by hitting it however. I tried to change its brain back to 10 when touching it, but it doesn't work.
Regardless, thanks for helping!

Hmm, it seems the script doesn't trigger the touch procedure at all. Is that always the case with missile brains, or can I adapt to it somehow?
void damage(void)
{
if (&missile_target == 1)
hurt(¤t_sprite,10);
}
something like that.
{
if (&missile_target == 1)
hurt(¤t_sprite,10);
}
something like that.
D'oh, I figured it out. I can't believe how stupid my scripting errors always are.
I forgot to put sp_touch_damage(¤t_sprite, -1); in the main procedure. It works perfectly now.
I forgot to put sp_touch_damage(¤t_sprite, -1); in the main procedure. It works perfectly now.
Well, Christiaan, sometimes it is better to name the absolute basics.
Though, I didn't just name THAT basic.
