Jump to content

NVSE & GetWeaponHasScope


gorey666

Recommended Posts

I need to determine if a weapon has a scope.

 

The NVSE function "GetWeaponHasScope" seems to not function correctly. .ie As long as the weapon has a scope by default OR if it can be attached by means of a weapon mod, the function returns true.

 

for instance, i run the call on an unmodded varmint rifle, the function returns true. not what i need at all.

 

any workaround for this?

Edited by gorey666
Link to comment
Share on other sites

Figured out a solution.

 

I've noticed there are a number of functions not listed in the Script Extender Docs. I looked at another mod and saw some useful funcitons.

 

 

short modIndex
short scopeMod
short modEffect
short weapFlags
ref currWeapon
		
;get the player weapon
set currWeapon to player.GetEquippedObject 5

;scope flag set?
if GetWeaponHasScope currWeapon


; check the possible modifications to see if it can have a scope mod attached to it
set scopeMod to 0
set modIndex to 1

Label 10
set modEffect to GetWeaponItemModEffect modIndex currWeapon
if modEffect == 14
	set scopeMod to modIndex
else
	set modIndex to modIndex + 1
	if modIndex < 4
		GoTo 10	
	endif
endif

if scopeMod
	; scope comes from a mod.. see if player has that mod attached
	set weapFlags to Player.GetEquippedWeaponModFlags		
	if LogicalAnd  weapFlags scopeMod

		; has scope mod attached

	else

		; no scope mod attached

	endif
else

	; weapon has scope built into it

endif
else

; scope not available for this weapon

endif

Edited by gorey666
Link to comment
Share on other sites

  • Recently Browsing   0 members

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