Jump to content

Real quick question about a lock and unlock script


kibblesticks

Recommended Posts

Hey guys, I really need some help

 

I need a script for a weapon that causes containers, doors and terminals to unlock when shot at.

 

I honestly can't work out where to start, so if any kind soul feels like putting me out of my misery I'll be most appreciative! :thumbsup:

Link to comment
Share on other sites

I haven't done this before, but I have used GetAnimAction to detect if the player has fired a shot, and it works every time.

I would start with this (requires FOSE):

 

scn MyWeaponUnlockScript

short iAmEquipped
short iWeaponAnim
short iObjectType
ref rBaseObjectREF
ref rTargetREF

BEGIN ONEquip Player

set iAmEquipped to 1

END

BEGIN ONUnequip

set iAmEquipped to 0

END

BEGIN ONDrop

set iAmEquipped to 0

END

BEGIN GameMode

if (iAmEquipped == 0)
	return
endif

set iWeaponAnim to Player.GetAnimAction
if ((iWeaponAnim > 1) && (iWeaponAnim < 7))		; weapon animation captures that a shot was fired
	set rTargetREF to GetCrosshairREF			;Must be within activation distance of locked object
	if (rTargetREF)
		set rBaseObjectREF to rTargetREF.GetBaseObject
		set iObjectType to GetObjectType rBaseObjectREF
		if ((iObjectType == 23) || (iObjectType == 27) || (iObjectType == 28)) ;Terminal, Container, Door
			If (rTargetREF.GetLocked)
				rTargetREF.Unlock
				rTargetREF.PlaySound UILockpickingUnlock
			else
				return
			endif
		endif
	endif
endif

END

Link to comment
Share on other sites

  • Recently Browsing   0 members

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