The Dink Network

Touch with other sprites than Dink.

October 28th 2009, 01:39 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
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.

void main(void)
{
	
	int &x = 0;
	sp_touch_damage(&current_sprite, -1);	
	sp_speed(&current_sprite, 5);	
	sp_base_walk(&current_sprite, 850);	
	roll:
	&x = sp_x(&current_sprite,-1);
	If(&x > 268)
	{
		move_stop(&current_sprite, 4, 157, 1);
	}
	else
	{
		move_stop(&current_sprite, 6, 400, 1);
	}	
	goto roll;			
}
void touch(void)
{
	sp_touch_damage(&current_sprite, 0);	
	freeze(1);
	&life = 0
	wait(100);
	sp_que(1, -1);
	goto roll;
}
October 28th 2009, 02:17 PM
dinkdead.gif
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...
October 28th 2009, 02:24 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
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.

void main(void)
{
int &x = 0;
sp_brain(&current_sprite,11);
sp_strength(&current_sprite,20);
sp_touch_damage(&current_sprite, -1);	
sp_speed(&current_sprite, 5);
sp_dir(&current_sprite,6);

roll:
&x = sp_x(&current_sprite,-1);
If(&x >= 400)
{
sp_dir(&current_sprite,4);
sp_seq(&current_sprite,854);
}
if (&x <= 160)
{
sp_dir(&current_sprite,6);
sp_seq(&current_sprite,856);
}	
		
}

void touch(void)
{
sp_touch_damage(&current_sprite, 0);	
freeze(1);
&life = 0;
wait(100);
sp_que(1, -1);
}

void damage(void)
{
goto roll;
}
October 28th 2009, 04:33 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
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?
October 28th 2009, 04:49 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
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)
October 28th 2009, 05:17 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
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.
October 28th 2009, 05:19 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
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
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
October 28th 2009, 05:20 PM
duck.gif
wesley
Peasant He/Him United States
 
Sort of ruined the puzzle aspect of the boss here now didn't we?
October 28th 2009, 05:23 PM
custom_iplaydink.gif
iplaydink
Peasant He/Him Sweden
Hmm.. 
Wasn't to hard to figure out, was it?
October 28th 2009, 07:51 PM
duck.gif
wesley
Peasant He/Him United States
 
Probably not but it still is fun to "figure out" such things. At least that in my opinion Since I don't typically play DMODs then I guess that is of little worth