Hi all,

I'm writing a game using celstart and python property classes. I've
been trying yesterday to add damage to my bullets. I've tried to use
celDamage of course, but encountered a problem. I wanted to use the
function celDamage.SingleDamage() in my projectile's
"cel.move.collision" message response function as follows:

def Hit(self,args):
  self.damage.SingleDamage(args["entity"].Name)

But the problem was that the message "cel.damage.hit" was always sent
to my bullet entity instead of the entity it hit (and which name I've
given as target to SingleDamage).

I was fairly sure that it was not the way it's supposed to be so I've
taken a look into the damagefact.cpp file in CEL source. I'm not
really into C++, but as far as I can read it, I've found that there is
a DoDamage() function that handles sending "cel.damage.hurt" messages.
That function takes argument ent, which is the target entity given to
the SingleDamage() function for example. At the same time, there is
that entity variable, which seems to be the entity that property class
is attached to. Now, at the beginning of the DoDamage() function, it
gets the ent's behaviour and then, at line 303, it sends message
"pcdamage_hurt" to that behaviour. When there's no behaviour on the
"ent" however, it sends the message "cel.damage.hurt" to the entity in
"entity" variable, rather than the one in the "ent" variable. That
happens on line 307 and it actually results, obviously, in my bullets
receving the "cel.damage.hurt" message, rather than my target receving
it.

That means that when using python property classes instead of
behaviours, the "target" parameter of the SingleDamage() function
seems to simply be ignored.

In my local CEL checkout I have changed the line 307 from this:
dispatcher_hurt = entity->QueryMessageChannel ()->CreateMessageDispatcher (

to this:
dispatcher_hurt = ent->QueryMessageChannel ()->CreateMessageDispatcher (

and now the DoDamage function sends the message to the target
indicated in the parameter in SingleDamage(), but I want to be sure if
that was actually a bug or maybe my logic just deceived me somehow ;).

Ah, forgot, I use CEL 1.4, rather old version 3573 but I've checked
the damagefact.cpp in the newest CEL 1.4, and if what I've shown was a
bug, it's still there.

Greetings,

Peter "Coppertop" Podgorski

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Cel-main mailing list
Cel-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cel-main

Reply via email to