Jump to content

NPC ref problem


troyquay

Recommended Posts

hello

this is the script i try to make it work but so far it doesn't work properly
it is a heat vision mod
the problem is when the vision is already activated, when a new NPC/actor appears, it won't be affected by the script and it won't be PMS
but if I turn it off and then turn it on again, it will be affected
can someone pls help?
thanks

scn aaaThermalVisionScript

short i
short size
short depth
short Powered
short isButtonPowerPressed

float timer
ref NPCref

Begin GameMode

set timer To timer + GetSecondsPassed

If IsKeyPressed 45 ;X, to toggle power
If isButtonPowerPressed
Else
	set isButtonPowerPressed To 1
	If Powered == 1 ;switch it off
		PlaySound UIPipBoyLightOff
		set Powered To 0
		player.rimod aaaEMVisionThermalZ
	Else ;switch it on
		PlaySound UIPipBoyLightOn
		set Powered To 1
		player.iMod aaaEMVisionThermalZ
		set timer To 9999
	EndIf
EndIf
Else
set isButtonPowerPressed To 0
EndIf

if (timer >= 1)

set timer To 0

If Powered
	set depth To 3 * (player.IsInInterior == 0)
	set NPCref To Pencil01 ;testing only
	set NPCref To GetFirstRef 200 depth 0
	Label 1 ;Loop Start

	;PHASE 01
	If NPCref != 0
		If NPCref.getdead == 1 ;dead -> white
			If listGetFormIndex aaaThermalVisionList NPCref == -1
				NPCref.listAddReference aaaThermalVisionList
				NPCref.pms aaaDeadESFXv1
			EndIf

		ElseIf NPCref.GetAV Aggression >= 2 ;neutral but verry aggressive -> red
			If listGetFormIndex aaaThermalVisionList NPCref == -1
				NPCref.listAddReference aaaThermalVisionList
				NPCref.pms aaaEnemyESFXv1
			EndIf

		Else ;any actor alife -> green
			If listGetFormIndex aaaThermalVisionList NPCref == -1
				NPCref.listAddReference aaaThermalVisionList
				NPCref.pms aaaFriendESFXv1
			EndIf
		EndIf
		set NPCref To Pencil01
		set NPCref To GetNextRef ;Get the ref of the next NPC
		Goto 1 ;Loop continues as long as NPCref exists
	EndIf

Else
	;PHASE 02
	set i To 0
	set size to (listGetCount aaaThermalVisionList)

	Label 2

	If i < size
		set NPCref To listGetNthForm aaaThermalVisionList i

		If NPCref != 0 && isFormValid NPCref == 1
			NPCref.sms aaaDeadESFXv1
			NPCref.sms aaaEnemyESFXv1
			NPCref.sms aaaFriendESFXv1
		EndIf

		set i To i + 1
		goto 2
	EndIf
	
	;to do
	;remove all NPCref from aaaThermalVisionList
EndIf
EndIf

End

Link to comment
Share on other sites

  • Recently Browsing   0 members

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