Jump to content

Script for LOS condition


Recommended Posts

I want to make an adjustment to a mod that tweaks it so a warning of enemies occurs based on perception. How the script works is with the IsInCombat returning 1, which subsequently triggers the warning. I'd like to make it so two conditions need to be met for the warning to occur: the PC has to be in combat mode(the CAUTION/DANGER hud prompts are displayed), and the source of danger has to be out of the PC's line of sight, meaning any threat visible at the time the CAUTION/DANGER messages pop up will not trigger the warning. 

I think GetLOS is the command to use, but I don't know how to implement it into the script. Could someone help me with this?

Link to comment
Share on other sites

I think you would have to run a loop one way or the other. Maybe no more than every 0.1 seconds for performance reasons and depending on your needs.

This is straight out of my head and may have errors. 

Basic code as I see it:

if player.IsInCombat == 1 && bPlayerSeesThreat == 0
    set fTimer to fTimer + getSecondsPassed
    if fTimer > 0.2 || bFirstRun == 0
        set bFirstRun to 1
        set bRunLoop to 1
        set fTimer to 0
    endif
else
    set bPlayerSeesThreat to 0
    set bFirstRun to 0
    set bRunLoop to 0
    set fTimer to 0
endif
 
if bRunLoop == 1
    set bPlayerSeesThreat to 0
    set rGetActor to GetFirstRef 200 1
    label 1
    if rGetActor != 0
        if rGetActor.GetDisabled == 0
            if player.GetLineOfSight rGetActor == 1
                set bPlayerSeesThreat to 1
            endif
        endif
        set rGetActor to GetNextRef
        GoTo 1
    else
        if bPlayerSeesThreat == 0
            MessageEXAlt "Unseen Threat Detected" ; MessageEXAlt is provided in ButcherPete
        endif
    endif
    set bRunLoop to 0
    set fTimer to 0
endif

 

I think I remember using GetLOS before, and it was a bit dodgy. Like if they are behind a pole, it won't pick them up even though you can see 75% of them.

Good luck with the rest of it

Edited by Drarack
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...