📧 Message Board Archive

sp_targetting
Hmm.. I think i get some of how this works, yes. ;)

But what I'd need to have is Milder fighting this some enemy, when a friend is helping him. How do I make this enemy the target for the friend too?

Tried for a while and ended up with people running wildly alone the screen and Milder battling alone. ;)
Advance Targeting Help
Ah, this help may be a little late, but I have done some extensive coding in regards to using allies and enemies in Dink.  There's a bit too much to describe in a post, so I'll just e-mail you the information. ;)

Re: Advance Targeting Help
: Ah, this help may be a little late, but I have done some extensive coding in regards to using allies and enemies in Dink. There's a bit too much to describe in a post, so I'll just e-mail you the information. ;)



may you please mail it to me too? Thanks! ;)
Re: sp_targetting
: Hmm.. I think i get some of how this works, yes. ;)

: But what I'd need to have is Milder fighting this some enemy, when a friend is helping him. How do I make this enemy the target for the friend too?

: Tried for a while and ended up with people running wildly alone the screen and Milder battling alone. ;)



Another way is to have the attacking sprite look for the target sp.# like this;

int &targ = get_sprite_with_this_brain(16,&current_sprite);

   if(&targ > 0)

   {

   sp_target(&current_sprite,&targ);

}

This looks for any target with brain 16 , but that can be changed too.But that way he might attack Milder.  Have you considered   int &targ = create_sprite(####);?

When you create a sprite with a script, you already have its number( &targ).
Re: sp_targetting
I was working on a similar script back then. I can't say it's working perfectly, but it worked as far as I know.



If you want the friend to attack the current enemy target of Milder, then you might at first use a global variable, like &temphold widely used in original Dink, to assign that monster's ID.



something like



&temphold = &current_sprite;



in hit(void) in monster's script.



And then you can put a looped procedure in main(void) of that friend to have something



sp_follow(&current_sprite, &temphold);

sp_target(&current_sprite, &temphold);



and maybe a



set_callback_random("target", 1000, 0);



(of course you need to write a target( void ))



sp_follow is not necessary, but if you set the friend to follow Milder originally, it might be crucial to reassign the following target.



Re: sp_targetting
: I was working on a similar script back then. I can't say it's working perfectly, but it worked as far as I know.

: If you want the friend to attack the current enemy target of Milder, then you might at first use a global variable, like &temphold widely used in original Dink, to assign that monster's ID.

: something like

:  &temphold = &current_sprite;

: in hit(void) in monster's script.

: And then you can put a looped procedure in main(void) of that friend to have something

:  sp_follow(&current_sprite, &temphold);

:  sp_target(&current_sprite, &temphold);

: and maybe a

:  set_callback_random("target", 1000, 0);

: (of course you need to write a target( void ))

: sp_follow is not necessary, but if you set the friend to follow Milder originally, it might be crucial to reassign the following target.



OKay, thanks Ric and Mimifish. :)

I didn't even think of using some global variable for that.. i just tried to make it get anything with brain 9, and that didn't work for some reason.

I think i'll get it to work now. :)
Also
: I didn't even think of using some global variable for that.. i just tried to make it get anything with brain 9, and that didn't work for some reason.



If both the friend and the enemy have brain 9, it usually doesn't work..



You could also use something like this, made in en-bong.c:





void main( void )

{

int &mtarget = get_sprite_with_this_brain(9, &current_sprite);



if (&mtarget > 0)

 {

  sp_target(&current_sprite, &mtarget);

 }



set_callback_random("target",2000,0);



}





void target( void )

{

&mtarget = sp_target(&current_sprite, -1);



if (&mtarget == 0)

  {

       &mtarget = get_sprite_with_this_brain(9, &current_sprite);

       if (&mtarget > 0)

         {

          sp_target(&current_sprite, &mtarget);

         }



  }



}

Re: Also
: : I didn't even think of using some global variable for that.. i just tried to make it get anything with brain 9, and that didn't work for some reason.

: If both the friend and the enemy have brain 9, it usually doesn't work..

: You could also use something like this, made in en-bong.c:

: void main( void )

: {

: int &mtarget = get_sprite_with_this_brain(9, &current_sprite);

: if (&mtarget > 0)

:  {

:   sp_target(&current_sprite, &mtarget);

:  }

: set_callback_random("target",2000,0);

: }

: void target( void )

: {

: &mtarget = sp_target(&current_sprite, -1);

: if (&mtarget == 0)

:   {

:   &mtarget = get_sprite_with_this_brain(9, &current_sprite);

:   if (&mtarget > 0)

:   {

:   sp_target(&current_sprite, &mtarget);

:   }

:   }

: }



There should have been a "get_sprite_with_this_team" code in DinkC ;)