AxlDave Posted October 20, 2013 Author Share Posted October 20, 2013 (edited) 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 AXLWolverineAdamantiumUnlockScriptshort WeaponAnimshort TargetTypeshort DoOnceref TargetREFfloat fTimerint iStageBEGIN 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 endifEND 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 October 20, 2013 by AxlDave Link to comment Share on other sites More sharing options...
pkleiss Posted October 21, 2013 Share Posted October 21, 2013 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 More sharing options...
AxlDave Posted October 21, 2013 Author Share Posted October 21, 2013 (edited) Thanks for the advice, here is what I have changed it to, however now the message doesn't show at all. scn AXLWolverineAdamantiumUnlockScriptshort WeaponAnimshort TargetTypeshort DoOnceref TargetREFfloat fTimerint iStageBEGIN 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 endifEND The door still unlocks though, so I'm pretty sure I've got the GetLocked function correct. Edited October 21, 2013 by AxlDave Link to comment Share on other sites More sharing options...
AxlDave Posted October 21, 2013 Author Share Posted October 21, 2013 (edited) 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 AXLWolverineAdamantiumUnlockScriptshort WeaponAnimshort TargetTypeshort DoOnceref TargetREFfloat fTimerint iStageBEGIN 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 endifEND --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 October 25, 2013 by AxlDave Link to comment Share on other sites More sharing options...
Recommended Posts