nicked on 13/4/2020 at 08:30
Making a new post to share the steps for this in case anyone is searching in the future.
Creating an AI that freezes when looked at
This will create an AI that works like a Boo from Mario, or a Weeping Angel from Doctor Who, in that it will freeze when directly observed, and come to life as soon as the player is not looking. You could also easily adjust this setup to make the opposite - an AI that will move when looked at but freeze when you look away, or trigger any other effect based on whether the player is looking or not.
1. Load NVScript and tnhscript (script_load NVScript , script_load tnhscript).
2. Save and set your gamesys if you haven't already.
3. Create your AI and place it in the world. Any AI will work.
4. Create a Gizmo > Levers > Up/Down Switch in a blue room.
5. On the switch, open the property Tweq > JointsState and set AnimS to On. Now you have a switch which defaults to being On.
6. In the Object Hierarchy, under fnord > TrapTrig, create a new Archetype called NVRelayTrap. Open it and add S > Scripts, type NVRelayTrap and click OK. This script requires NVScript to be loaded.
7. Under fnord > TrapTrig, create a new Archetype called VisibleRelay. Open it and add S > Scripts, type VisibleRelay and click OK. This script requires tnhscript to be loaded.
8. Create an NVRelayTrap. We'll call this NVRelayTrap1. Add the property Editor > Design Note and type the following: NVRelayTrapExclusiveDelay=1; NVRelayTrapRepeat=-1; NVRelayTrapDelay=500
This will cause this NVRelayTrap to repeatedly send a signal every half second when triggered. You can adjust the delay if you like, but probably not a good idea to have the signal sent too frequently, especially if you are going to have multiple versions of this setup.
9. Add a ControlDevice link from the Up/Down Switch to the NVRelayTrap.
10. Create two VisibleRelays and call them VisibleRelayOn and VisibleRelayOff.
11. Add a ScriptParams link from both VisibleRelays to the AI. Open Data for both links and type Visible.
12. Add a ControlDevice link from NVRelayTrap1 to both VisibleRelays.
13. Open VisibleRelayOff and click Add Script > Trap Control Flags and tick Invert.
13. Open the Object Hierarchy and select Act/React Stimuli from the drop-down at the top.
14. Click Add and create a new Stim called AIVisibleStim. Then create another one called AIInvisibleStim. Then close the Object Hierarchy.
15. Create another NVRelayTrap. We'll call this NVRelayTrap2. Add the property Editor > Design Note and type the following: NVRelayTrapTOn="[1.00]AIVisibleStim"; NVRelayTrapTOff="[1.00]AIInvisibleStim"
This will convert TurnOn and TurnOff signals into the Stims we just created. Why do we need a second NVRelayTrap I hear you ask? That's because the VisibleRelay script will only relay TurnOn and TurnOff, so we need to convert it after this point.
16. Add a ControlDevice link from VisibleRelayOn to NVRelayTrap2.
17. Create a fnord > TrapTrig > Inverter. Add a ControlDevice link from VisibleRelayOff to the Inverter.
18. Add a ControlDevice link from the Inverter to NVRelayTrap2.
19. Add a ControlDevice link from NVRelayTrap2 to the AI.
20. Open the AI's properties and click Add > Act/React > Receptrons.
21. Add a new Receptron. Stimulus should be AIVisibleStim. Tick No Min Intensity and set 2 as the Max Intensity. For Effect select Set Property. For Target Object, select Me. For Agent Object, type M-PosedCorpse. Click Edit Effect and type AI. Click OK.
22. Add another Receptron. Stimulus should be AIInvisibleStim. Tick No Min Intensity and set 2 as the Max Intensity. For Effect select Set Property. For Target Object, select Me. For Agent Object, type the name of the AI's archetype (e.g. sword guard). Click Edit Effect and type AI. Click OK.
23. Remember to save your mission and gamesys when done.
ALTERNATE: Replace steps 21 and 22 above with:
21. Add a new Receptron. Stimulus should be AIVisibleStim. Tick No Min Intensity and set 2 as the Max Intensity. For Effect select Freeze AI. Edit the Duration Multiplier to be 1000 (or any value that is longer than the first Relay's delay value).
And that's it! Go ingame and check it out.
[video=youtube;vjgF5hj12Ic]https://www.youtube.com/watch?v=vjgF5hj12Ic[/video]
Here's how it works:
* The switch automatically triggers NVRelayTrap1, which then continues to send a TurnOn signal every half a second indefinitely.
* VisibleRelayOn and VisibleRelayOff check to see whether the AI is onscreen or offscreen respectively. VisibleRelayOn relays the TurnOn signal if the AI is onscreen. VisibleRelayOff relays the TurnOn signal if the AI is offscreen.
* The Inverter converts VisibleRelayOff's relayed signal to a TurnOff.
* NVRelayTrap2 converts TurnOn signals to AIVisibleStim (intensity 1), and TurnOff signals to AIInvisibleStim (intensity 1).
* NVRelayTrap2 then pings the AI with these stims.
* The AI reacts to AIVisibleStim by grabbing the AI property from M-PosedCorpse (thereby setting the AI to null).
* The AI reacts to AIInvisibleStim by grabbing the AI property from its own archetype (thereby resetting its AI to normal).
If you want a different effect, just change the AI's receptrons to do different things. You could have an AI that hurts to be looked at, for example, or a friendly AI that calls you out if you're not paying attention to them, or conversely, if you're staring.
FireMage on 13/4/2020 at 19:31
Hmm... Instead of changing the AI, I think it would be more wiser to change the timewrap like LGS did to zombies when they're "killed". Because changing the AI might resurrect the guard.
nicked on 13/4/2020 at 19:58
The problem with Time Warp is that receiving messages is also affected. So a creature with, say, Time Warp 500 will indeed appear frozen, but will then take 500 times as long to unfreeze. There's likely a better way to do it than AI though, for sure.
ZylonBane on 13/4/2020 at 23:09
Does the "Freeze AI" receptron effect not work?
To make the opposite, an AI that only moves when observed, I'd think the Efficiency settings could do that.
Nameless Voice on 14/4/2020 at 00:49
A much simpler way to do it is to use a FlickerTrigger, since tweqs can already run or not run based on being on-screen.
1) Add AIVisibleStim stimulus, as above.
2) Add the scripts TrigFlicker and NVRelayTrap to the AI.
3) Add a ControlDevice link from the AI to themselves.
4) Add Tweq->Flicker with Halt: Continue, a rate of 100 and None flags set in AnimC. (Must not set Sim; can use OffScreen to invert the effect.)
5) Add Tweq->FickerState: AnimC: On.
6) Add Editor -> Design Note: NVRelayTrapTOn="[1.00]AIVisibleStim"
7) Add Act/React receptrons, 0 to No Max, Freeze AI, Duration Multiplier: 150
The FlickerTrigger will send TurnOn every 100ms, but since the Sim flag is not set, it will only trigger while the AI is on-screen.
You can adjust the flicker rate and AI freeze duration to be a bit higher if you don't want it firing every 100ms.
john9818a on 14/4/2020 at 02:54
Quote Posted by ZylonBane
Does the "Freeze AI" receptron effect not work?
To make the opposite, an AI that only moves when observed, I'd think the Efficiency settings could do that.
It does but the effect eventually is removed. I used a Duration Multiplier of 10000, and after about 25 seconds the stimmed AI started walking again.
nicked on 14/4/2020 at 07:32
Quote Posted by Nameless Voice
A much simpler way to do it is to use a FlickerTrigger, since tweqs can already run or not run based on being on-screen.
1) Add AIVisibleStim stimulus, as above.
2) Add the scripts
TrigFlicker and
NVRelayTrap to the AI.
3) Add a ControlDevice link from the AI to themselves.
4) Add Tweq->Flicker with
Halt: Continue, a rate of
100 and
None flags set in AnimC. (Must not set Sim; can use OffScreen to invert the effect.)
5) Add Tweq->FickerState:
AnimC: On.
6) Add Editor -> Design Note: NVRelayTrapTOn="[1.00]AIVisibleStim"
7) Add Act/React receptrons, 0 to No Max,
Freeze AI, Duration Multiplier:
150The FlickerTrigger will send TurnOn every 100ms, but since the Sim flag is not set, it will only trigger while the AI is on-screen.
You can adjust the flicker rate and AI freeze duration to be a bit higher if you don't want it firing every 100ms.
Oh jeez, that's way better. It even freezes the audio if you look away mid voice line.
Another difference is that with this version, the frozen AI can still see you and then react after coming to the life again, rather than literally being a statue until offscreen.
Niborius on 14/4/2020 at 07:57
Great information in this topic, thanks for sharing!
nicked on 14/6/2020 at 14:55
I'm finally revisiting this topic now I'm ready to implement some of these AIs.
I'm not sure why, but when I use your method, NV, the framerate steadily drops while the AI is onscreen (frozen) until it's in the 20s. :(