Jump to content

Weapon script to unlock doors / containers


AxlDave

Recommended Posts

I want to add an effect to a hand2hand weapon that when you strike a door or container that is locked, it will automatically unlock.

 

Initially i tried playing around with the Open - Unlock base effect, but then realised I would probably have more success with a script.

 

Needless to say, I haven't managed to get it to work. I have the command I want to apply to the door / container, but I don't know how to get the game to understand that I want the effect to happen to the door / container I am currently targeting.

 

Here's what i have so far:

 

scn AXLWolverineAdamantiumUnlockScript

ref HitTarget

BEGIN ScriptEffectStart

if ( HitTarget.GetCombatTarget == 1 )
SetOpenState 1
endif

END

 

 

Any suggestions?

Link to comment
Share on other sites

I'm sorry to say that GetCombatTarget only returns actors, not doors. In fact, I can't think of any script that will open/unlock generic doors unless you put the script right on the door itself - which would mean changing every door in the game. Yikes!

 

I have never used the Open base effect, but if you are going to have success, I'm pretty sure it will be with an effect. However, the open effect may be a carry over from TES spell casting such as an unlock spell. I don't know if it will work in FO3, but you can try. I'd be interested to know if it does.

 

The closest I have ever come to doing what you are attempting was making a sliding door that would short circuit and explode when struck by a lead pipe. I had to make a custom script for the door in question. Again, to affect just any door, I'm not sure that can be accomplished.

Link to comment
Share on other sites

Damn, I was afraid that might be the case. And it's so simple in the console, just click and type "unlock".

 

 

However, the open effect may be a carry over from TES spell casting such as an unlock spell.

 

Much like the FrostResist effect, when to my knowledge there is nothing that deals frost damage. However I have successfully implemented EnergyResist, ElectricalResist and EMPResist so hopefully I can with Unlock too.

 

With regard to the base effect, one point I am a little confused about is which flags it should have and whether that actually matters. So far I have: Touch, Target, Hostile all ticked. Most of the others it is obvious I don't want, such as Detrimental, FX Persist, Use skill, Use attribute. But I am a little unsure about the area, duration and magnitude flags.

 

I have tried experimenting with various combinations, but if any one wrong flag could mess up the whole effect I have no way of knowing if the others are working. Not only whether the flags should be ticked, but if not then what value to give, or does it remain at 0? Does it even matter? I read on the GECK page that magnitude for unlock / lock refers to the difficulty that the effect can unlock / will lock to, but I have no idea about the other two.

 

Such are the questions I have running around in my head...

 

 

I'm sorry to say that GetCombatTarget only returns actors, not doors. In fact, I can't think of any script that will open/unlock generic doors unless you put the script right on the door itself - which would mean changing every door in the game. Yikes!

 

So if I were to take on this seemingly monumental task, would the script I have suffice? I'm guessing I would need to change the ref, but what is the scripting name for doors and containers?

Edited by AxlDave
Link to comment
Share on other sites

You could use a combination of GetCrosshairREF to get the reference of the locked object and Player.GetAnimAction (firing a weapon). then call 'unlock' on the Reference. It would require FOSE for GetCrosshairREF. The script would run on a very fast quest script (.016 delay) or an invisible token in the player's inventory to run every frame.

Link to comment
Share on other sites

That's a good idea rickerhk. Tell me, can the getanimaction command discern which weapon is being fired, or would you have to add a test for the equipped weapon as well - to limit the effect to a single weapon type?

 

As for flags, I think you don't want touch either, just target. Again, touch is a remnant of spell casting where the caster would need to touch the intended target. You are making a 'ranged' spell, so I would expect that only target would be required.

 

I've made a few effects, but I'm not overly familiar with base effect flags and required settings, so my best advice would to to try things out. To that end, I don't know what you are referring to when you said, 'other two.' What other two?

 

In so far as making a script for a door, I'd use an OnHitWith {weapon} block to run the code. Still, Rickerhk's idea may be the way to go here, if you are willing to use FOSE. I had mixed results when using GetCrossHairRef in the past - which is why I didn't mention that method myself, but it could work.

Edited by pkleiss
Link to comment
Share on other sites

That's a good idea rickerhk. Tell me, can the getanimaction command discern which weapon is being fired, or would you have to add a test for the equipped weapon as well - to limit the effect to a single weapon type?

 

As for flags, I think you don't want touch either, just target. Again, touch is a remnant of spell casting where the caster would need to touch the intended target. You are making a 'ranged' spell, so I would expect that only target would be required.

 

I've made a few effects, but I'm not overly familiar with base effect flags and required settings, so my best advice would to to try things out. To that end, I don't know what you are referring to when you said, 'other two.' What other two?

 

In so far as making a script for a door, I'd use an OnHitWith {weapon} block to run the code. Still, Rickerhk's idea may be the way to go here, if you are willing to use FOSE. I had mixed results when using GetCrossHairRef in the past - which is why I didn't mention that method myself, but it could work.

Here's a fragment from one of my scripts using GetAnimAction. You'll need other code to specifiy a specific weapon, but you could limit it by weapon type also.

 

set rWeaponREF to Player.GetEquippedObject 5
set iWeaponType to (GetWeaponType rWeaponREF)

if (fTimer > 0)
    set fTimer to (fTimer - GetSecondsPassed)
else                ; timer for mine droppings

    set iWeaponAnim to Player.GetAnimAction
    if ((iWeaponAnim > 1) && (iWeaponAnim < 7))                ; weapon animation
        if (iWeaponType >= 11)                                ; One-hand mine
            set fTimer to 3
        else
            ;Weapon fired - do stuff
        endif
    endif
endif

For GetCrossHairREF to work reliably, you may have to extend the game setting iActivatePickLength when your weapon is out because it defaults to 150 - which is probably pretty close if you are shooing at a box or door

 

Link to comment
Share on other sites

As for flags, I think you don't want touch either, just target. Again, touch is a remnant of spell casting where the caster would need to touch the intended target. You are making a 'ranged' spell, so I would expect that only target would be required.

 

I've made a few effects, but I'm not overly familiar with base effect flags and required settings, so my best advice would to to try things out. To that end, I don't know what you are referring to when you said, 'other two.' What other two?

 

That's what I thought, but I can only attach a base effect to a weapon object effect if it is flagged for "touch". I figured it referred to the collision data, i.e when the weapon / projectile impacts something.

 

The other two I was referring to were area and duration. I am fairly confident that I know what I should put for the magnitude, and I figured that both area and duration should be zero, as I want the effect to be instantaneously applied to one point. However this does not work, so either I'm wrong or the effect doesn't work.

 

 

In so far as making a script for a door, I'd use an OnHitWith {weapon} block to run the code. Still, Rickerhk's idea may be the way to go here, if you are willing to use FOSE. I had mixed results when using GetCrossHairRef in the past - which is why I didn't mention that method myself, but it could work.

 

It would probably be a lot easier than scripting every single door. Especially given how that would clash with many mods and wouldn't work on others.

 

Okay I'm going to have another crack at it, I'll post back with any success, or more likely failure (this scripting business is hard work).

Edited by AxlDave
Link to comment
Share on other sites

Here is the latest script I have cobbled together:

 

scn AXLWolverineAdamantiumUnlockScript

Ref WeaponREF
Ref WeaponSpecific
Ref WeaponAnim

BEGIN GameMode

set WeaponREF to Player.GetEquippedObject 5
set WeaponSpecific to GetWeaponType WeaponREF
set WeaponAnim to Player.GetAnimAction

if ( ( WeaponAnim > 1 ) && ( WeaponAnim < 7 ) )
if ( WeaponSpecific == 1 )
GetCrosshairREF
Unlock
endif
endif

END

 

Of course, there are a couple of problems. First of all I cannot save this as a Quest script without some kind of reference for Unlock command, which I thought I had done with GetCrosshairREF.

 

Secondly, I am pretty sure I have not implemented the Weapon bits correctly, particularly as I have not been able to find a way to specify my weapon, AXLWolverineAdamantiumClawsWeapon. Also, I am not familiar with the specific values for GetAnimAction and GetEquippedObject.

 

--EDIT--

 

Okay, after a small brainwave I have altered the script such that it will allow me to save as a Quest script:

 

scn AXLWolverineAdamantiumUnlockScript

Ref WeaponREF
Ref WeaponSpecific
Ref WeaponAnim
Ref TargetREF

BEGIN GameMode

set WeaponREF to Player.GetEquippedObject 5
set WeaponSpecific to GetWeaponType WeaponREF
set WeaponAnim to Player.GetAnimAction
set TargetREF to GetCrosshairREF

if ( ( WeaponAnim > 1 ) && ( WeaponAnim < 7 ) )
if ( WeaponSpecific == 1 )
TargetREF.Unlock
endif
endif

END

 

However I am still unsure about the Weapon references and the specific values for GetEquippedObject and GetAnimAction...

Edited by AxlDave
Link to comment
Share on other sites

However I am still unsure about the Weapon references and the specific values for GetEquippedObject and GetAnimAction...

I may have led this down the wrong path a bit - you would only need GetEquippedObject and GetWeaponType if you wanted the script to work in general with certain weapon types: http://fose.silverlock.org/fose_command_doc.html#Weapon_Type

If it's for a specific weapon then it's easier. In a quest script you always have to give the reference that a function is working on. In this case the player.

Also, make sure the quest delay is like .016 so it's going to be running almost 60 times a second (if you are able to get 60FPS, that is).

Weaponanim is a short - not a ref.

 

scn AXLWolverineAdamantiumUnlockScript


short WeaponAnim
short TargetType
Ref TargetREF

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)            ;make sure we have captured something
                set TargetType to GetType TargetREF
                if (TargetType == 27) || (TargetType == 28)        ;container (27)  or door (28) http://fose.silverlock.org/fose_command_doc.html#Form_Type_IDs
                    TargetREF.Unlock
                endif
            endif
        endif
    endif
END
Link to comment
Share on other sites

Ah I see, so I was about halfway there. Cheers for that man, I'll give it a go once I've had some sleep *yawn*.

 

--EDIT--

 

Works like a charm, cheers man. And thanks for including the form list link, that's going to come in handy in the future.

 

For anyone who's interested, SetOpenState 1 does not actually open a door or container, it just makes it say it is open. And using it can cause the game to crash, particularly if you use it on the Megaton Clinic door.

 

 

Also, make sure the quest delay is like .016 so it's going to be running almost 60 times a second (if you are able to get 60FPS, that is).

 

So if I had a quest script running faster than this, could it cause game lag / crashes?

 

Thanks for both of your help!

Edited by AxlDave
Link to comment
Share on other sites

  • Recently Browsing   0 members

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