Custom homing marker

hello so on my mod, (witch i already had help on) i want to put a custom homing marker instade of the triangle that aprease, any help?
the homing marker sprite i want to use is below the mod is also below
 

Attachments

  • HomingMarker.png
    HomingMarker.png
    7.3 KB · Views: 72
hello so on my mod, (witch i already had help on) i want to put a custom homing marker instade of the triangle that aprease, any help?
the homing marker sprite i want to use is below the mod is also below
With the use of P_LookForEnemies(), you could store the closest enemy into a variable, then use P_SpawnLockOn() to draw a lock-on target over the enemy's head.

Example Code:
freeslot("SPR_EXMP", "S_CUSTOMMARKER") -- SPR_EXMP and S_CUSTOMMARKER can be swapped out for whatever names you think fit best. SPR_* constants have to use four letters, whereas states can use around 24 afaik
states[S_CUSTOMMARKER] = {
    sprite = SPR_EXMP,
    frame = A,
    duration = -1,
    nextstate = S_CUSTOMMARKER
}

addHook("PlayerThink", function(player)
    if player.mo and player.mo.skin == "skinname" then -- skinname is just a placeholder. Replace it with your character's skin name.
        player.lockon = P_LookForEnemies(player) -- Store an enemy into a variable.
        if player.lockon and player.lockon.valid then -- Does the enemy exist?
            P_SpawnLockon(player, player.lockon, S_CUSTOMMARKER) -- Spawn a lock-on target with our custom sprite.
        end
    end
end)
 
With the use of P_LookForEnemies(), you could store the closest enemy into a variable, then use P_SpawnLockOn() to draw a lock-on target over the enemy's head.

Example Code:
freeslot("SPR_EXMP", "S_CUSTOMMARKER") -- SPR_EXMP and S_CUSTOMMARKER can be swapped out for whatever names you think fit best. SPR_* constants have to use four letters, whereas states can use around 24 afaik
states[S_CUSTOMMARKER] = {
    sprite = SPR_EXMP,
    frame = A,
    duration = -1,
    nextstate = S_CUSTOMMARKER
}

addHook("PlayerThink", function(player)
    if player.mo and player.mo.skin == "skinname" then -- skinname is just a placeholder. Replace it with your character's skin name.
        player.lockon = P_LookForEnemies(player) -- Store an enemy into a variable.
        if player.lockon and player.lockon.valid then -- Does the enemy exist?
            P_SpawnLockon(player, player.lockon, S_CUSTOMMARKER) -- Spawn a lock-on target with our custom sprite.
        end
    end
end)
That would make it never disappear though. I'd recommend doing the following changes:
Changed Example Code:
states[S_CUSTOMMARKER] = {
    sprite = SPR_EXMP,
    frame = A,
    duration = 2, -- It appears for at least one frame
    nextstate = S_NULL -- then disappears
}
-- ...
Even then, it'd float ABOVE the enemy, so
 
That would make it never disappear though. I'd recommend doing the following changes:
Changed Example Code:
states[S_CUSTOMMARKER] = {
    sprite = SPR_EXMP,
    frame = A,
    duration = 2, -- It appears for at least one frame
    nextstate = S_NULL -- then disappears
}
-- ...
Even then, it'd float ABOVE the enemy, so
For the floating above part, wouldn’t you just set an offset for the sprite?
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top