Jump to content

Line Of Sight? RegisterForSingleLOSGain/Lost


SadSun

Recommended Posts

Posted

How, does one RegisterForSingleLOSGain/Lost on the player, or for RegisterForLOS/UnregisterForLOS on the player?

 

I'm trying to get NPCs to spot the character after an event has triggered.

 

Something Like:

 

Event OnInit()

     RegisterForSingleLOSLost({},Game.GetPlayer())

     RegisterForSingleLOSGain({},Game.GetPlayer())

EndEvent

 

Event OnGainLOS(Actor akViewer, ObjectReference akTarget)

     akTarget as Actor

     if akTarget == Game.GetPlayer()

          Debug.Notification("You've Been spotted!")

          RegisterForSingleLOSLost({},Game.GetPlayer())

     endif

EndEvent

 

I believe I have worked out that you need "Game.GetPlayer()" in the second (Target) block. Is this Correct? What exactly goes where the {} are in this script.  How do I get the player to be the target and all playable races to be the viewers?  Anything else missing?

 

I've tried several ways and I keep getting a compile error:

type mismatch on parameter 1 (did you forget a cast?)

 

Also, I'm wanting to attach animations into my mod.  I have the FNIS for Modders Documentation and have skimmed it.  It explains how to handle the mod packaging.  I need help on how to code animation changes into your script.  How do you call your script to replace idle, run/walk, sneak animations then restore them to default. A good reference would be handy.  All I could find was bits and pieces from Fore talking to others in a skyrim forum.  (Wasn't too helpful for me as those he was talking to knew what they were doing already.  I also tried dissecting his Fnis Sexymove source file.  Wasn't successful at that either.)

 

Thanks in advance!

 
Posted

To answer your FNIS question: why didn't you directly approach me? And I have a "FNIS for Modders" thread in the modders resource section.

 

What you are looking for, and which is used in FNIS SM, are what I called Alternate Animations. However, I have only implemented that for walk/run. Not idle or sneak. And it's described in thge modders' doc, chapter 9. 

 

If you have further questions, I recommend you ask at http://www.loverslab.com/topic/17067-fnis-for-modders-fnis-40-wip

Posted

To answer your FNIS question: why didn't you directly approach me? And I have a "FNIS for Modders" thread in the modders resource section.

 

What you are looking for, and which is used in FNIS SM, are what I called Alternate Animations. However, I have only implemented that for walk/run. Not idle or sneak. And it's described in thge modders' doc, chapter 9. 

 

If you have further questions, I recommend you ask at http://www.loverslab.com/topic/17067-fnis-for-modders-fnis-40-wip

 

I didn't think It was a FNIS question specifically.  I will move a question into the linked forum.

 

Thanks for your help.

Posted

The LoS events are very intensive, as a result there are limitations on execution.

 

The first argument must be a reference to the specific actor that will see the player - it's not possible (and not desirable under the circumstances) to register an entire race.

Posted

The LoS events are very intensive, as a result there are limitations on execution.

 

The first argument must be a reference to the specific actor that will see the player - it's not possible (and not desirable under the circumstances) to register an entire race.

 

So, it would be too intensive to just register a LOS gain on your player character and trigger with any other npc actor that happens to be around? then give conditions that if they're a playable race it triggers a function?  I'm only wanting to register the LOS gain on the player.  Alternatively, is there a way to tap into the game's sneak system to achieve something of the same result without having to register a LOS event?

Posted

 

The LoS events are very intensive, as a result there are limitations on execution.

 

The first argument must be a reference to the specific actor that will see the player - it's not possible (and not desirable under the circumstances) to register an entire race.

 

So, it would be too intensive to just register a LOS gain on your player character and trigger with any other npc actor that happens to be around? then give conditions that if they're a playable race it triggers a function?  I'm only wanting to register the LOS gain on the player.  Alternatively, is there a way to tap into the game's sneak system to achieve something of the same result without having to register a LOS event?

 

You could use a regular cloak spell on the player with Area Effect Ignores LOS unchecked, then run a script for those hit. This means that the script would not run at the moment of detection/los gain but some seconds afterwards depending on how often you fire the cloak spell.

 

You should be able to get a basic idea of how it would work form this tutorial. This is actually about attaching scripts to individual NPCs but you may not need that whole solution so you could skip applying spells to the NPCs and just run the script on the OnEffectStart event which gives you the target actor ref.

 

I have to admit I'm not 100% certain Area Effect Ignores LOS will function as expected with a cloak spell. I've encountered issues with LoS conditions just not working reliably.

Posted

 

 

The LoS events are very intensive, as a result there are limitations on execution.

 

The first argument must be a reference to the specific actor that will see the player - it's not possible (and not desirable under the circumstances) to register an entire race.

 

So, it would be too intensive to just register a LOS gain on your player character and trigger with any other npc actor that happens to be around? then give conditions that if they're a playable race it triggers a function?  I'm only wanting to register the LOS gain on the player.  Alternatively, is there a way to tap into the game's sneak system to achieve something of the same result without having to register a LOS event?

 

You could use a regular cloak spell on the player with Area Effect Ignores LOS unchecked, then run a script for those hit. This means that the script would not run at the moment of detection/los gain but some seconds afterwards depending on how often you fire the cloak spell.

 

You should be able to get a basic idea of how it would work form this tutorial. This is actually about attaching scripts to individual NPCs but you may not need that whole solution so you could skip applying spells to the NPCs and just run the script on the OnEffectStart event which gives you the target actor ref.

 

I have to admit I'm not 100% certain Area Effect Ignores LOS will function as expected with a cloak spell. I've encountered issues with LoS conditions just not working reliably.

 

 

Success!  I used the dynamic cloak effect and an .IsDetectedBy() command on akTarget to tap into the detection system.

 

This is my Script for future posterity:

 

Follow the linked tutorial above in it's entirety.

 

Then alter the "applying script" so that it reads the detection level of the npcs caught in the cloak spell:

 

Scriptname _applyingScript01 extends activemagiceffect
 
Event OnEffectStart(Actor akTarget, Actor akCaster)
     bool dovaDetected = Game.GetPlayer().IsDetectedBy(akTarget)
          if dovaDetected == True
               Debug.Notification("You've Been detected!")
               {Other things to be applied!}
          endif
EndEvent
 
And you're good to go!
 
Thanks goes to Sailing Rebel for pointing me in the right direction!

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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