GameLivingEvent.EnemyHealed

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

GameLivingEvent.EnemyHealed

Postby Kakuri » Sat Mar 14, 2009 2:53 am

This is driving me a little batty...

Mobs on my server mysteriously stopped receiving EnemyHealed events. A quick search of the entire project revealed there's only one origin for EnemyHealed events, and it's in GameLiving.ChangeHealth. If my health changes, and it's the result of a heal (rather than health regen), I notify all my attackers with an EnemyHealed event. In quick look at the SVN history for GameLiving.cs I didn't see any recent changes to this method.

So here's the kicker:
Why did this ever work? It looks like it notifies all of your attackers of the EnemyHealed event except for the one you have targeted.
Code: Select all
foreach (GameObject attacker in attackers)
{
if (attacker is GameLiving && attacker != TargetObject)
{
(attacker as GameLiving).Notify(GameLivingEvent.EnemyHealed, (GameLiving)attacker, args);
(attacker as GameLiving).AddXPGainer(changeSource, healthChanged);
}
}
I changed that loop to the following and it's now working:
Code: Select all
foreach ( GameLiving attacker in attackers )
{
if ( attacker != null )
{
attacker.Notify( GameLivingEvent.EnemyHealed, attacker, args );
attacker.AddXPGainer( changeSource, healthChanged );
}
}
Should I commit this change, or can anyone tell me some good reason for the original code? Has anyone else noticed this not working?
User avatar
Kakuri
Developer
 
Posts: 803
Joined: Tue Oct 28, 2008 10:40 pm
Website: http://enlight.hostrator.com/

Re: GameLivingEvent.EnemyHealed

Postby Graveen » Sat Mar 14, 2009 8:11 am

I don't even understand why it worked previously.

The event is fired on health changes; can we fall in a recursive loop ?

Can the attackers table contains yourself, or strictly non related objects to attack ?

I suggest to commit, anw.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: GameLivingEvent.EnemyHealed

Postby Aredhel » Sat Mar 14, 2009 9:29 pm

Seems like an ok fix to me.
User avatar
Aredhel
Inactive Staff Member
 
Posts: 1024
Joined: Sat Apr 14, 2007 1:49 pm
Location: Germany


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest