Jump to content

How to use CreateDetectionEvent efficiently?


irswat

Recommended Posts

I have this script I've been working on to get snipers to react to the player from the maximum possible distance. I am trying to implement the function CreateDetectionEvent, in part, to accomplish this. I am not certain this is the best way to use it.

           scn OldSniperModScriptWithTimer

float hfPlayer
int AlertFlag
ref rSniper
float WeapMaxRange

begin GameMode

        if player.IsInInterior == 1
            MessageEX "Debug Mode Disabled [inside]"
            return
        elseif player.IsInInterior == 0
                set AlertFlag to 0
                set WeapMaxRange to GetMaxRange WeapNVGhillieSniperRifle
             ;set WeapMaxRange to 11000
                set rSniper to GetSelf
                
                 MessageEX "Sniper Mod Debug Mode Enabled"    
                if GetDead
                    MessageEX "Sniper %i is dead" rSniper
                Disable 1
                    MarkForDelete
                set AlertFlag to 0
                return
            endif
               
            if player.GetDead
                    set AlertFlag to 0
                    return
            endif
               
            set hfPlayer to player.GetDistance rSniper
               if hfPlayer <= WeapMaxRange
                set AlertFlag to 1
                   MessageEX "Sniper is %g units away" hfPlayer
                CreateDetectionEvent player 100 3
                if GetDetected player
                           StartCombat player
                endif
            endif
            
                if AlertFlag == 1
                Look player
                rSniper.UseWeapon WeapNVGhillieSniperRifle rSniper player 6 0 0 1 0  
             endif
                return
        endif
        return
end


Edited by irswat
Link to comment
Share on other sites

what is the sound level parameter really mean? does it affect how likely the NPC is to react to the event? What is the event type parameter? Does it make a difference if I use bullet, beam, explosion, or general?

if i want to force the sniper to detect the player

I cant find documentation for this

if the script is attached to the Sniper NPC would I use:

rSniper.CreateDetectionEvent player 100 3

or

player.CreateDetectionEvent rSniper 100 3



Edited by irswat
Link to comment
Share on other sites

  • Recently Browsing   0 members

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