- I can't determine how to make some of these variables clientside, or failing that, how to store values by player.
- I can't determine how headshots are registered,
- Players with a shield do not trigger the MutatorTakeDamage function,
Code: Select all
class HMU extends Mutator;
#exec AUDIO IMPORT FILE="Sounds\hitmarker.wav" NAME="Hitmark" GROUP="CustomSound";
#exec AUDIO IMPORT FILE="Sounds\hitmarker_headshot.wav" NAME="HitmarkHeadshot" GROUP="CustomSound";
#exec TEXTURE IMPORT NAME=HitTex FILE=Textures\Hit.PCX GROUP=Skins LODSET=2
var float curr;
var bool bLastHitKill;
var bool bInitialized;
var float lastHit;
function PreBeginPlay()
{
if (!bInitialized)
{
bInitialized = True;
Level.Game.RegisterDamageMutator(Self);
}
}
simulated function Tick(float DeltaTime) {
if ( !bHUDMutator && Level.NetMode != NM_DedicatedServer )
RegisterHUDMutator();
curr = curr + DeltaTime;
}
function MutatorTakeDamage ( out int ActualDamage, Pawn Victim, Pawn InstigatedBy, out Vector HitLocation, out Vector Momentum, name DamageType)
{
local PlayerPawn PP;
if ( NextDamageMutator != None )
NextDamageMutator.MutatorTakeDamage( ActualDamage, Victim, InstigatedBy, HitLocation, Momentum, DamageType );
if (ActualDamage !=0 && InstigatedBy != None ) {
if (InstigatedBy.IsA('PlayerPawn') && PP == None)
{
PP = PlayerPawn(InstigatedBy);
bLastHitKill = Victim.Health - ActualDamage <= 0;
// No idea how to determine headshots
if ( bLastHitKill || ActualDamage > 50 || DamageType == 'decapitated' || DamageType == 'beheaded' || DamageType == 'cmheadshot')
{
PP.clientPlaySound(Sound'HitmarkHeadshot', true, true);
}
else
{
PP.clientPlaySound(Sound'Hitmark', true, true);
}
lastHit = curr;
}
}
}
simulated function PostRender(canvas C) {
local float offset;
offset = FClamp(lastHit-curr+0.25,0,25)*1020;
if ( NextHUDMutator != None )
{
NextHUDMutator.PostRender(C);
}
C.SetPos( C.ClipX/2 -64, C.ClipY/2 -64);
C.bNoSmooth = False;
if (curr < (lastHit + 0.25))
{
C.DrawColor.R = offset;
if (bLastHitKill) {
C.DrawColor.G = 0;
C.DrawColor.B = 0;
}
else
{
C.DrawColor.G = offset;
C.DrawColor.B = offset;
}
C.DrawTile (texture'HitTex', 128, 128, 0, 0, 128, 128);
}
}