Game Development Community

Team damage and melee

by Terra Snover · in Torque 3D Professional · 06/24/2010 (3:46 pm) · 1 replies

I made a melee weapon that works like normal projectile weapon. I changed the shot lifetime to 5, so it wouldn't go far, and it's working fine there. The problem i'm having is because I set the damage radius high (so it would hit one or 2 enemies) that it's hitting me also. I know there is a way to make it so you don't take damage from your own weapons, I just don't remember how to to it... Could someone out there help me?

#1
06/27/2010 (2:30 pm)
For team damage, this will depend on how you set up your teams, find function Armor::damage() in scripts/server/player.cs add something like the following pseudo code:
// first you figure out which team each player is on 
%attackerTeam = %sourceObject.client.teamId;	
%targetTeam = %obj.client.teamId;	

// then a little logic to only hurt someone from a different team
if(%attackerTeam != %targetTeam) 
    %obj.applyDamage(%damage);

To simply not harm yourself you could do something like this:
if(%sourceObject != %obj)
    %obj.applyDamage(%damage);