PDA

View Full Version : Locational hitdamage help?


Euphoric Beaver
21st Aug 2001, 04:51 PM
I've coded a machine gun that takes clips. (Hey that's good for me! :D )

And took a peek at Chimeric and the locational hit code got me wondering.

Does anybody know the best and complete code for locational hit damage and could they possibly post it here. :D
Come on were all friends here. ;)

Smoke39
21st Aug 2001, 05:26 PM
Here's what I got. You can ignore all the sparks it spawns, that was just for this gun.

function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
local UT_Shellcase s;
local UT_HeavyWallHitEffect u;
local vector realLoc;
local int HitHeight, HitAngle;

realLoc = Owner.Location + CalcDrawOffset();
s = Spawn(class'UT_ShellCase',, '', realLoc + 20 * X + FireOffset.Y * Y + Z);
if ( s != None )
s.Eject(((FRand()*0.3+0.4)*X + (FRand()*0.2+0.2)*Y + (FRand()*0.3+1.0) * Z)*160);

if (Other == Level)
{
u = Spawn(class'UT_HeavyWallHitEffect',,, HitLocation+HitNormal, Rotator(HitNormal));
u.DrawScale = 0.2;
u.Fatness = 115;
Spawn(class'SmallSpark2',,, HitLocation+HitNormal, Rotator(HitNormal));
Spawn(class'SmallSpark',,, HitLocation+HitNormal, Rotator(HitNormal));
Spawn(class'Spark32',,, HitLocation+HitNormal, Rotator(HitNormal));
spawn(class'UT_SpriteSmokePuff',,,HitLocation+HitNormal*9);
}
else if (Other.IsA('Pawn'))
{
HitHeight = HitLocation.Z - Other.Location.Z;
HitAngle = (Other.Rotation.Yaw - rotator(HitLocation - Other.Location).Yaw) & 65535;

if (HitHeight > 0.72 * Other.CollisionHeight)
{
BroadcastMessage("Head hit");
Other.TakeDamage(200, Pawn(Owner), HitLocation, 35000.0*X, AltDamageType);
}
else if (HitHeight <= 0.72 * Other.CollisionHeight && HitHeight > 0.36 * Other.CollisionHeight)
{
BroadcastMessage("Chest hit");
Other.TakeDamage(60, Pawn(Owner), HitLocation, 32500.0*X, MyDamageType);
}
else if (HitHeight < 0.10 * Other.CollisionHeight)
{
BroadcastMessage("Leg hit");
Other.TakeDamage(5, Pawn(Owner), HitLocation, 27500.0*X, MyDamageType);
}
else
{
BroadcastMessage("Stomach hit");
Other.TakeDamage(35, Pawn(Owner), HitLocation, 30000.0*X, MyDamageType);
}
}
else
Other.TakeDamage(35, Pawn(Owner), HitLocation, 30000.0*X, MyDamageType);
}

Euphoric Beaver
21st Aug 2001, 05:37 PM
Wow! Thanks. :D
This place is much better than PU.

But I'm afraid I have a question. :)

What does this if statement do? I've never seen Level before.

Originally posted by Smoke39
if (Other == Level)

Smoke39
21st Aug 2001, 05:42 PM
That just checks to see if the tracer hit the level, so it knows if it should create sparks or not.

Euphoric Beaver
21st Aug 2001, 05:45 PM
What counts as the level?
Is it any object in the level?

Smoke39
21st Aug 2001, 05:50 PM
I think It includes any kind of brush. Pawns, decorations, inventory and such are not part of the level.

Euphoric Beaver
21st Aug 2001, 05:53 PM
Ah thankyou.

So if I wanted to test if it hit a pawn it would be?

if (Other == pawn)

Smoke39
21st Aug 2001, 06:23 PM
Look at the else if, it shows how to check if it hit a Pawn.