The Dink Network

Code for enemy hit?

December 3rd 2010, 12:56 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
Is there some code (variable, whatever) that I can use to find what enemy was hit with Dink's weapon?

For example, if I wanted to suck away some HP from the enemy as a 'bonus' and give it to the player, it'd be something like this:

int &enemy_health = sp_hitpoints((the enemy Dink hit), -1);
&enemy_health -= 5;
sp_hitpoints((the enemy Dink hit), &enemy_health);
&life += 5;


right?
I wanna know what to use for (the enemy Dink hit).
Thanks in advance, ya'll.
December 3rd 2010, 01:59 AM
pq_knight.gif
ExDeathEvn
Peasant He/Him New Zealand rumble
"Skinny Legend" 
Sounds like you're making a complicated Vampiric weapon/spell, lol? So the damage dealt to an opponent is, for example, split into a quarter and the new value given to Dink as health?

Seems like it could be a very simple or very complicated script, but if I had an answer rather than a way to expand what you've described I would only be too happy to offer the solution.
December 3rd 2010, 02:16 AM
spike.gif
I don't think there's any straightforward way to check that out...

Your best bet would probably be to add the code to the enemy's hit() procedure, and check if it was Dink hitting him with the right weapon there.

Something like this (writing on the fly, success not quaranteed):
if (&missle_source == 1)
{
compare_weapon("SwordOfSucking");
if (&return == 1)
{
// vampiric stuff
}
}
December 3rd 2010, 08:19 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Yep, this is basically it. You need to add this code to every enemy script. Although it seems like an annoying thing to do, it does also allow you to make certain enemies (undead? machines?) immune to the effect by not including the code in their scripts. I would strongly suggest making an external script for these extra effects so you can just include one line inside the enemy scripts that calls the external.
December 4th 2010, 03:48 AM
sob_scorpy.gif
DinkDude95
Peasant He/Him Australia
The guy with the cute D-Mod. 
So I'd call it with

external("script", "vampire");


right? And then have in the script:

void vampire( void )
{
if (&missle_source == 1)
{
  compare_weapon("SwordOfSucking");
  if (&return == 1)
  {
    // vampiric stuff
  }
}
}


Thanks, fellas.