The Dink Network

A bit of scripting help needed!

April 16th 2007, 08:56 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
Ok, I have come across yet another problem. I will try to explain is as briefly as possible. Now I made a script which summons creatures taking a lot of ideas from rabidwolf9's Summon Spell. Now if this summoned creature kills an enemy how do you add experience to Dink's pocket. I have tried using the method rabid used in his file but with no success. Using a local variable, say:

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

&ehp = sp_hitpoints(&mtarget, -1);
&my_exp = sp_exp(&mtarget, - 1);

Now in the atack sommand of the summoned creature's script I use:

void attack(void)
{
int &mcounter;
playsound(31, 18050,0,&current_sprite, 0);
&mcounter = random(4000,0);
sp_attack_wait(&current_sprite, &mcounter);

if (&enemy_ehp == 0)
{
add_exp(&my_exp, 1);
&my_exp = 0;
&mtarget = 0;
}
}

Someone please help me by pointing out where exactly I am committing the huge blunder!
April 16th 2007, 09:17 AM
bonca.gif
MichaelV
Peasant He/Him Australia
It's all in the mind, you know 
Could it be something to do with the &ehp variable? Does the script regularly 'update' the &ehp variable, so that when the enemy is dead the &ehp variable is actually 0?
I think if you put the &ehp = <no. of hitpoints> just before the if(&ehp == 0) line, then the &ehp variable should be 0 if the monster is dead.

Unless... If a monster is dead, does it actually have 0 hp or is it non-existent?
April 16th 2007, 09:35 AM
duck.gif
wesley
Peasant He/Him United States
 
In your attack procedure, there is no check to see what the current hp of the enemy is. You would need to add the line:

&enemy_ehp = sp_hitpoints(&mtarget, -1);

That will set the &enemy_ehp to the current hp.

The other issue is that it will probably check the current hp before the enemy is hit by the SM. You might need to add a

wait(250);

You might need to adjust the time of the wait if it doesn't line up right with the animation.
Make it longer if it still isn't working or shorter if there is a delay after the enemy dies.

Finally, if the target has 1 hp left and you hit it for 2 damage, I don't know if the hitpoints equals 0 or -1, so I would change the check to be just to be safe.

if (&enemy_ehp <= 0)
{
add_exp(&my_exp, 1);
&my_exp = 0;
&mtarget = 0;
}

Hope that helps (and works ).