Hitmark Mutator

Search, find and discuss about Mutators!
InstantMix
Posts: 2
Joined: Tue Nov 10, 2020 12:34 pm

Hitmark Mutator

Post by InstantMix »

I made a hitmark mutator last night as a fun little distraction. I have but the shallowest understanding of the language and how Unreal engine actually functions, so I'm not convinced this will work on anything but singleplayer.
  • 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,

Image

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);
    }
}
Download
ProAsm
Skilled
Posts: 235
Joined: Sun Sep 29, 2013 7:12 am

Re: Hitmark Mutator

Post by ProAsm »

To detect a Headshot, use the Mutator function PreventDeath then:
if ( DamageType == 'decapitated' )
Here you can find all sorts of stuff like 'shot', 'Gibbed', 'RedeemerDeath', 'RocketDeath', 'GrenadeDeath' etc
Good luck with your coding :)
User avatar
OjitroC
Godlike
Posts: 3799
Joined: Sat Sep 12, 2015 8:46 pm

Re: Hitmark Mutator

Post by OjitroC »

Yes, interesting that. Certainly works - the only thing is it seems to replace the Player's taunt after a kill - the text appears in the talk area OK but what the Player says isn't heard.

What's that on the ramp in your screenshot (apart from Nikita :P)?
InstantMix
Posts: 2
Joined: Tue Nov 10, 2020 12:34 pm

Re: Hitmark Mutator

Post by InstantMix »

ProAsm wrote: Tue Nov 10, 2020 6:56 pm To detect a Headshot, use the Mutator function PreventDeath then:
if ( DamageType == 'decapitated' )
Here you can find all sorts of stuff like 'shot', 'Gibbed', 'RedeemerDeath', 'RocketDeath', 'GrenadeDeath' etc
Good luck with your coding :)
Ahh thank you, I'll try giving that a bash and see what I can come up with.
OjitroC wrote: Wed Nov 11, 2020 12:25 am Yes, interesting that. Certainly works - the only thing is it seems to replace the Player's taunt after a kill - the text appears in the talk area OK but what the Player says isn't heard.

What's that on the ramp in your screenshot (apart from Nikita :P)?
I'm sure missing a vocal taunt won't be the end of the world. I think it's just a bullet casing, for some odd reason the crosshair isn't centered if your viewmodel is using the left or right hand setting, so I made it invisible. Didn't want it to look like the mitmark image was off!
User avatar
OjitroC
Godlike
Posts: 3799
Joined: Sat Sep 12, 2015 8:46 pm

Re: Hitmark Mutator

Post by OjitroC »

InstantMix wrote: Wed Nov 11, 2020 5:34 pm I'm sure missing a vocal taunt won't be the end of the world.
Perhaps make the hitsounds an option - quite often they are not audible with all the weapon, explosion and gib sounds around - apart from liking the vocalisations of my 'character' (chosen with care from the multitude available), the kill taunt does actually indicate that I have killed something when I may not be able to see that that is the case. I raise it because it may be important for other players as well - at least, it is something to consider.
John Cleese
Novice
Posts: 5
Joined: Wed Oct 07, 2009 10:14 am

Re: Hitmark Mutator

Post by John Cleese »

This is awesome! Thanks. I was just thinking about this today, happy to find this and thanks for the source. :gj:
Darth_nihiluS
Novice
Posts: 7
Joined: Fri Apr 29, 2016 3:55 pm

Re: Hitmark Mutator

Post by Darth_nihiluS »

Hi. Very nice mutator but sometimes when hitting it appears a black square. Is it possible to fix this? thx
User avatar
Hitman
Adept
Posts: 336
Joined: Mon Aug 16, 2010 11:01 am
Location: Sweden

Re: Hitmark Mutator

Post by Hitman »

Yes the black box comes up in the scope, but only if you damage not with a kill, besides that its a good idea so if its fixed I will use it (XopenGL was used at the test)
Darth_nihiluS
Novice
Posts: 7
Joined: Fri Apr 29, 2016 3:55 pm

Re: Hitmark Mutator

Post by Darth_nihiluS »

Hitman wrote: Tue Mar 18, 2025 7:33 pm Yes the black box comes up in the scope, but only if you damage not with a kill, besides that its a good idea so if its fixed I will use it (XopenGL was used at the test)
for me it appears sometimes with or without scope, and sometimes with or without kill, test every renderer i have... icbind.... vulkan... opengl... xopengl... etc. Still with the issue.
thx for the reply man
User avatar
esnesi
Godlike
Posts: 1079
Joined: Mon Aug 31, 2015 12:58 pm
Personal rank: Dialed in.

Re: Hitmark Mutator

Post by esnesi »

Thanks for the mutator, nice work!
Darth_nihiluS wrote: Tue Mar 18, 2025 8:12 pm for me it appears sometimes with or without scope, and sometimes with or without kill, test every renderer i have... icbind.... vulkan... opengl... xopengl... etc. Still with the issue.
thx for the reply man
It's present in a lot of sniper forks.
Set HighDetailActors=True or False to solve this issue.
It will influence your HUD being solid or not though.
User avatar
Hitman
Adept
Posts: 336
Joined: Mon Aug 16, 2010 11:01 am
Location: Sweden

Re: Hitmark Mutator

Post by Hitman »

esnesi wrote: Tue Mar 18, 2025 9:54 pm Thanks for the mutator, nice work!
Darth_nihiluS wrote: Tue Mar 18, 2025 8:12 pm for me it appears sometimes with or without scope, and sometimes with or without kill, test every renderer i have... icbind.... vulkan... opengl... xopengl... etc. Still with the issue.
thx for the reply man
It's present in a lot of sniper forks.
Set HighDetailActors=True or False to solve this issue.
It will influence your HUD being solid or not though.
I know this but it needs a fix if possible, we can't ask every player that join to go in and poke in their settings to fix it when they join...if they even speak eng
User avatar
esnesi
Godlike
Posts: 1079
Joined: Mon Aug 31, 2015 12:58 pm
Personal rank: Dialed in.

Re: Hitmark Mutator

Post by esnesi »

Hitman wrote: Tue Mar 18, 2025 11:19 pm I know this but it needs a fix if possible, we can't ask every player that join to go in and poke in their settings to fix it when they join...if they even speak eng
The better solution is to re import the hud/zoom texture with the right translucency changes.
Easily said then done (For some, at least me)

Give @_21 a PM, he probably can give you some tips on it.
Darth_nihiluS
Novice
Posts: 7
Joined: Fri Apr 29, 2016 3:55 pm

Re: Hitmark Mutator

Post by Darth_nihiluS »

esnesi wrote: Tue Mar 18, 2025 9:54 pm Thanks for the mutator, nice work!
Darth_nihiluS wrote: Tue Mar 18, 2025 8:12 pm for me it appears sometimes with or without scope, and sometimes with or without kill, test every renderer i have... icbind.... vulkan... opengl... xopengl... etc. Still with the issue.
thx for the reply man
It's present in a lot of sniper forks.
Set HighDetailActors=True or False to solve this issue.
It will influence your HUD being solid or not though.
ive set that to false and true in every renderer i have. black square still appears
sorry, but what do you mean by solid HUD? thx
User avatar
Hitman
Adept
Posts: 336
Joined: Mon Aug 16, 2010 11:01 am
Location: Sweden

Re: Hitmark Mutator

Post by Hitman »

Any update on this ?
Darth_nihiluS
Novice
Posts: 7
Joined: Fri Apr 29, 2016 3:55 pm

Re: Hitmark Mutator

Post by Darth_nihiluS »

i couldnt solve anything. im not an expert in the kind of things, i only tried changing renderers... setting highdetailactors to true... nothing more :(

@lol sent me this but i dont understand shit

"it's not to false but true

search your render section in UT.ini and edit or add the line if you not found it

This link is under http not https so your browser probably ask you for allow open it
http://unrealtournament.99.free.fr/foru ... 59&start=0

Pour le bug du carré noir le joueur doit aller dans:

Image


C:\UnrealTournament\System\UnrealTournament.ini
[OpenGLDrv.OpenGLRenderDevice] ou autre render que vous utilisez.
HighDetailActors=True


build on

if ( Level.bHighDetailMode )
Canvas.Style = ERenderStyle.STY_Translucent; // The way it should be on your screen and not block your view.
else
Canvas.Style = ERenderStyle.STY_Normal; // How the crosshair looks with a black box obscuring your view. Ugh.