How to check what hit it
How do you check what hits a sprite? And I don't mean compare_weapon. For example you can cut down some bushes with a sword. How do you check that bush is hit by a sword? because if you use compare_weapon the bush will also disapear if you cast fireball on it while carrying a sword.
You'll have to use compare_weapon, but also &missle_source. Yes, &missle is spelled incorrectly, but that's the Seth way of doing things.
&enemy_sprite will return 1 when hit by a missile.
&missle_source will return the missle number when hit by a missile. Otherwise, it'll return the attacker.
void hit( void )
{
if (&missle_source == 1)
{
int &crap = compare_weapon("item-sw1");
int &crap2 = compare_weapon("item-sw2");
int &crap3 = compare_weapon("item-sw3");
int &swordarmed = 0;
if (&crap == 1)
{
&swordarmed = 1;
}
if (&crap2 == 1)
{
&swordarmed = 1;
}
if (&crap3 == 1)
{
&swordarmed = 1;
}
if (&swordarmed == 1)
{
say("Ouch! That's a sword!",¤t_sprite);
}
}
}
&enemy_sprite will return 1 when hit by a missile.
&missle_source will return the missle number when hit by a missile. Otherwise, it'll return the attacker.
void hit( void )
{
if (&missle_source == 1)
{
int &crap = compare_weapon("item-sw1");
int &crap2 = compare_weapon("item-sw2");
int &crap3 = compare_weapon("item-sw3");
int &swordarmed = 0;
if (&crap == 1)
{
&swordarmed = 1;
}
if (&crap2 == 1)
{
&swordarmed = 1;
}
if (&crap3 == 1)
{
&swordarmed = 1;
}
if (&swordarmed == 1)
{
say("Ouch! That's a sword!",¤t_sprite);
}
}
}
And what should I do if I only want it to react to an arrow?
Cheap hack, I'm sure there are more stylish ways of doing it.
void hit( void )
{
int &crap = sp_pseq(&missle_source, -1);
if (&crap == &arrow_seq)
{
//Replace &arrow_seq by the seq number of the arrow
say("Eeek! An arrow!");
}
}
}
This will also react to arrows shot by enemies. Maybe &enemy_sprite can fix that up. The DinkC reference says it's 1 when hit by a missile. I have no idea if it's also 1 when hit by a missile made by an enemy (the 'owner' of the missile is usually in sp_brain_parm())
I don't know how FIAT does it, but it has a script that checks if it got hit by an arrow, then does something; or hit by an axe, then does something else.
void hit( void )
{
int &crap = sp_pseq(&missle_source, -1);
if (&crap == &arrow_seq)
{
//Replace &arrow_seq by the seq number of the arrow
say("Eeek! An arrow!");
}
}
}
This will also react to arrows shot by enemies. Maybe &enemy_sprite can fix that up. The DinkC reference says it's 1 when hit by a missile. I have no idea if it's also 1 when hit by a missile made by an enemy (the 'owner' of the missile is usually in sp_brain_parm())
I don't know how FIAT does it, but it has a script that checks if it got hit by an arrow, then does something; or hit by an axe, then does something else.
I have no idea if it's also 1 when hit by a missile made by an enemy
If I remember correctly, Paul Pliska said in his Enemy Shot Now shoots at whoever it's fighting, not only Dink, so if he did find a trick to this(I was too lazy to read his entire script, maybe I will).
If I remember correctly, Paul Pliska said in his Enemy Shot Now shoots at whoever it's fighting, not only Dink, so if he did find a trick to this(I was too lazy to read his entire script, maybe I will).
Usually missiles are from Dink. If the Enemy Shoot changes targets when it got hit by another Enemy Shoot-missile from Dink to the other shooter, then there's a way around it.
Here's my attempt:
int &crap = sp_brain(&missle_source, -1);
if (&crap == &missile_brain)
{
//I know there are two missile brains, but you get the idea.
int &p1 = sp_brain_parm(&missle_source, -1);
int &p2 = sp_brain_parm2(&missle_source, -1);
//Missiles traditionally have the caster and the shadow in their brain parms
&crap = &p1;
&p1 = sp_brain(&p1, -1);
if (&p1 == &shadow_brain)
{
&crap = &p2;
}
}
After this, &crap will hold the caster of the missile, assuming it's either in sp_brain_parm or sp_brain_parm2(). These parameters are sprites that the missile shouldn't damage.
Hey, it just might work.
Here's my attempt:
int &crap = sp_brain(&missle_source, -1);
if (&crap == &missile_brain)
{
//I know there are two missile brains, but you get the idea.
int &p1 = sp_brain_parm(&missle_source, -1);
int &p2 = sp_brain_parm2(&missle_source, -1);
//Missiles traditionally have the caster and the shadow in their brain parms
&crap = &p1;
&p1 = sp_brain(&p1, -1);
if (&p1 == &shadow_brain)
{
&crap = &p2;
}
}
After this, &crap will hold the caster of the missile, assuming it's either in sp_brain_parm or sp_brain_parm2(). These parameters are sprites that the missile shouldn't damage.
Hey, it just might work.









