Jump to content

Weapon script to unlock doors / containers


AxlDave

Recommended Posts

I have come across a new problem in trying to add to the script. Basically, I want a message to pop-up informing the player that they have broken the lock. Here is what I have so far:

 

scn AXLWolverineAdamantiumUnlockScript

short WeaponAnim
short TargetType
short DoOnce
ref TargetREF
float fTimer
int iStage

BEGIN GameMode

if Player.GetEquipped AXLWolverineAdamantiumClawsWeapon && Player.IsWeaponOut
set WeaponAnim to Player.GetAnimAction
if ( ( WeaponAnim > 1 ) && ( WeaponAnim < 7 ) )
set TargetREF to GetCrosshairREF
if (TargetREF != 0)
set TargetType to GetType TargetREF
if (TargetType == 27) || (TargetType == 28)
TargetREF.Unlock

if fTimer > 0
set fTimer to fTimer - GetSecondsPassed
elseif iStage == 0
set iStage to 1
set fTimer to 2
elseif iStage == 1
ShowMessage AXLWolverineUnlockMessage
set iStage to 2
endif

endif
endif
endif
endif

END

 

 

The problems I am having are that the message seems to only pop-up the once and will never again. Also it pops-up whether the door has actually been unlocked or already was. I would like it to only happen when unlocking is occurring, but do not know the appropriate if function.

 

Also, on a side note, anyone happen to know what the GECK calls the power attacks? e.g Attack 3, Attack 4, Attack Left, Attack Right?

 

Again, any help appreciated.

Edited by AxlDave
Link to comment
Share on other sites

The problems I am having are that the message seems to only pop-up the once

 

 

That is because you haven't reset Timer and iStage back to 0. The second time this code runs, iStage will still be 2 and therefore fail both elseif iStage code segments.

 

 

Also it pops-up whether the door has actually been unlocked or already was.

 

This is because your code does not check to see if the door/container is initially locked or not. It just unlocks every reference it finds by default. You'll need to add another check: If TargetRef.GetLocked == 1

 

Sorry, I don't know which is the power attack...

Link to comment
Share on other sites

Thanks for the advice, here is what I have changed it to, however now the message doesn't show at all.

 

scn AXLWolverineAdamantiumUnlockScript

short WeaponAnim
short TargetType
short DoOnce
ref TargetREF
float fTimer
int iStage

BEGIN GameMode

if Player.GetEquipped AXLWolverineAdamantiumClawsWeapon && Player.IsWeaponOut
set WeaponAnim to Player.GetAnimAction
if ( ( WeaponAnim > 1 ) && ( WeaponAnim < 7 ) )
set TargetREF to GetCrosshairREF
if ( TargetREF != 0 )
set TargetType to GetType TargetREF
if ( TargetType == 27 ) || ( TargetType == 28 )
if TargetREF.GetLocked == 1
TargetREF.Unlock

if fTimer > 0
set fTimer to fTimer - GetSecondsPassed
elseif iStage == 0
set iStage to 1
set fTimer to 2
elseif iStage == 1
ShowMessage AXLWolverineUnlockMessage
set iStage to 2
set fTimer to 0
elseif iStage == 2
set iStage to 0
set fTimer to 0
endif

endif
endif
endif
endif
endif

END

 

 

The door still unlocks though, so I'm pretty sure I've got the GetLocked function correct.

Edited by AxlDave
Link to comment
Share on other sites

Okay, after some more work and logical thinking, I have a working script. The only small problem is that I have to strike to door / container twice to unlock it and get the message. Apart from that it works fine, and this is actually a fairly good alternative to power attacks. If you could still explain where I've gone wrong for future reference though, that would be great.

 

Here's the script:

 

scn AXLWolverineAdamantiumUnlockScript

short WeaponAnim
short TargetType
short DoOnce
ref TargetREF
float fTimer
int iStage

BEGIN GameMode

if Player.GetEquipped AXLWolverineAdamantiumClawsWeapon && Player.IsWeaponOut
set WeaponAnim to Player.GetAnimAction
if ( ( WeaponAnim > 1 ) && ( WeaponAnim < 7 ) )
set TargetREF to GetCrosshairREF
if ( TargetREF != 0 )
set TargetType to GetType TargetREF
if ( TargetType == 27 ) || ( TargetType == 28 )
if TargetREF.GetLocked == 1

if fTimer > 0
set fTimer to fTimer - GetSecondsPassed
elseif iStage == 0
set iStage to 1
set fTimer to 1
elseif iStage == 1
ShowMessage AXLWolverineUnlockMessage
TargetREF.Unlock
set iStage to 2
set fTimer to 0
elseif iStage == 2
set iStage to 0
set fTimer to 0
endif

endif
endif
endif
endif
endif

END

 

 

--EDIT--

 

Fixed the problem by putting all the weaponequip and targetref conditions under iStage == 0, then having the actual unlock and message under iStage == 1. iStage == 2 is obsolete.

Edited by AxlDave
Link to comment
Share on other sites

  • Recently Browsing   0 members

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