Touch with other sprites than Dink.
Ok, I've made a script for a boulder rolling back and forth across the room and killing Dink upon touch (See script below). Is there a way to check if another sprite than Dink touch the boulder and then take damage?
Here's the script so far.
Here's the script so far.
void main(void)
{
int &x = 0;
sp_touch_damage(¤t_sprite, -1);
sp_speed(¤t_sprite, 5);
sp_base_walk(¤t_sprite, 850);
roll:
&x = sp_x(¤t_sprite,-1);
If(&x > 268)
{
move_stop(¤t_sprite, 4, 157, 1);
}
else
{
move_stop(¤t_sprite, 6, 400, 1);
}
goto roll;
}
void touch(void)
{
sp_touch_damage(¤t_sprite, 0);
freeze(1);
&life = 0
wait(100);
sp_que(1, -1);
goto roll;
}Not like that, the touch procedure and damage only works with Dink.
I'm sure there's another way to do it for other sprites, can't think right now though...
I'm sure there's another way to do it for other sprites, can't think right now though...
Try the missile brain. It would come out something like this. Take note that it will change its direction when it hits something outside of its defined boundaries (I assume you have it going back and forth between two walls or something)
Btw if you ever want an enemy sprite to be affected by 'touching' another sprite, using the missile brain is the way to go.
Btw if you ever want an enemy sprite to be affected by 'touching' another sprite, using the missile brain is the way to go.
void main(void)
{
int &x = 0;
sp_brain(¤t_sprite,11);
sp_strength(¤t_sprite,20);
sp_touch_damage(¤t_sprite, -1);
sp_speed(¤t_sprite, 5);
sp_dir(¤t_sprite,6);
roll:
&x = sp_x(¤t_sprite,-1);
If(&x >= 400)
{
sp_dir(¤t_sprite,4);
sp_seq(¤t_sprite,854);
}
if (&x <= 160)
{
sp_dir(¤t_sprite,6);
sp_seq(¤t_sprite,856);
}
}
void touch(void)
{
sp_touch_damage(¤t_sprite, 0);
freeze(1);
&life = 0;
wait(100);
sp_que(1, -1);
}
void damage(void)
{
goto roll;
}
Well, that works, thanks.
I can't figure out how it works though :/
You doesn't tell the stone to move, Does the brain know that it should move in current direction?
I can't figure out how it works though :/
You doesn't tell the stone to move, Does the brain know that it should move in current direction?
I edited the script a few times, the latest didn't actually work XD
I fixed it though. The missile brain will move in the direction you set it to move at the speed you set it to move. There's no move() needed (I don't think move even works for missiles)
I fixed it though. The missile brain will move in the direction you set it to move at the speed you set it to move. There's no move() needed (I don't think move even works for missiles)
Ok.
This is really cool, thank you again rabidwolf!
This is for the first boss, he has lots of hp so the only way to kill him is to lure him into the rolling stones.
This is really cool, thank you again rabidwolf!
This is for the first boss, he has lots of hp so the only way to kill him is to lure him into the rolling stones.
I just remembered that enemies killed by the boulder would give exp because of the missile brain. If that's a problem, you could always use this as a workaround.
//boulder's damage proc
//noexp.c
What noexp is doing is taking away the exp and giving it back if the monster survived. That way, if the monster died during the attack, he has no exp to give the player.
Edit: Too late I now see that you obviously do want exp from a boss
//boulder's damage proc
void damage(void)
{
//If there are hitpoints, the thing obviously wants to be killed
&save_x = sp_hitpoints(&missile_target,-1);
if (&save_x > 0)
external("noexp","main",&missile_target);
goto roll;
}
//noexp.c
void main ()
{
int &targ = &arg1;
int &xphold = sp_exp(&targ,-1);
sp_exp(&targ,0);
wait(0);
wait(0);
&save_x = sp_hitpoints(&targ,-1);
if (&save_x > 0)
sp_exp(&targ,&xphold);
}
What noexp is doing is taking away the exp and giving it back if the monster survived. That way, if the monster died during the attack, he has no exp to give the player.
Edit: Too late I now see that you obviously do want exp from a boss
Sort of ruined the puzzle aspect of the boss here now didn't we?










