Game Development Community

get damage inflicted

by N.K. · in Torque Game Engine · 03/28/2009 (5:49 am) · 3 replies

Hi,
If I were creating a game in which each player scores points for the amount of damage it inflicts on the opponent, how would I get the damage on the other player after one player fires the crossbow.

I thought of casting a ray just before firing the crossbow but the projectile takes time to reach the destination and the rays reach immediately. The opponent can have moved out of the way by the time the projectile reaches him.

Cheers,
N

#1
03/28/2009 (11:13 am)
In player.cs you'll see function Armor::damage(), you'll want to add your "sendScore" code inside of there. Armor::damage() knows the amount of damage, the object taking damage, who dealt the damage, and it can deal with client callbacks. Just so you know: function GameConnection::onDeath() in game.cs handles scoring when you kill someone.
#2
03/28/2009 (2:11 pm)
I've a "feeling" that projectiles get deleted before any chance of tracing who fired them, so if there are more than 2 players there might be a problem. (with just 2 players you can "sendScore" to the other player).

[bad_psuedo-code]
if(%obj = "player1")
{%this.sendScore = "player2")};
[bad_psuedo-code/]

If you want to trace who fired the projectile I believe that will require code changes in the engine (which requires paying for a license).
#3
03/28/2009 (11:50 pm)
Scoring is dealt with already in stock TGE - Projectile objects have a 'source client' and this information is passed through the whole damage chain, right up to onDeath. So if you really wanted, it's probably possible to track detailed stats for each player - amount of damage done per weapon per enemy, etc.

Oh, and what Michael said :P.