How to take all weapons, like in new vegas

Post » Mon Nov 19, 2012 5:46 am

In one of my dialogues i want the npc to take all the players weapons and put them in a chest, like the casinos did in fallout new vegas.

What is the best way for me to go about this?

I've already had a go which works, but un-equips the players worn items in the process:

1. Set up an empty chest with the following script attached (myKeyword property filled with "VendorItemWeapon" keyword)
Spoiler
Scriptname PCKP_KeywordFilterContainerScript extends ObjectReference  Actor Property playerRef  autoKeyword Property myKeyword  autoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)   If akSourceContainer == playerRef      If !akBaseItem.HasKeyword(myKeyword)         RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)         Debug.Trace("Invalid Item")      EndIf   EndifEndEvent
2. In the dialogue, i use
playerRef.RemoveAllItems(WeaponChest, true)

Like i said, it works by sending all the players items to the box, then the filter script on the box only allows the weapons in, sending the rest back to the player. Is there a way i can make it re-equip the armor before the player notices? Or can somebody think of a cleaner way to approach this

- Hypno
User avatar
Crystal Clarke
 
Posts: 3410
Joined: Mon Dec 11, 2006 5:55 am

Post » Mon Nov 19, 2012 9:53 am

I'd make a FormList, then
PlayerREF.RemoveItem(WeaponFLST, Player.GetItemCount(WeaponFLST), True, WeaponChest)
User avatar
*Chloe*
 
Posts: 3538
Joined: Fri Jul 07, 2006 4:34 am

Post » Mon Nov 19, 2012 1:45 pm

Cheers for the help mate, but wouldn't this limit me to just the vanilla weapons? Is there no way to use hasKeyword(VendorItemsWeapon) in there somewhere?

Perhaps using arrays?

I'm not by my pc at the moment, but is there no way to write it so that an array scans the players inventory then only populates itself with items containing the keyword?

I'm just thinking out loud really

Worst comes to worst and in fact there is no way of going the keyword route, then I'll go with your suggestion JustinOther.

- Hypno
User avatar
His Bella
 
Posts: 3428
Joined: Wed Apr 25, 2007 5:57 am

Post » Mon Nov 19, 2012 7:16 am

You could add WEAP forms not already covered to the FormList via an http://www.creationkit.com/OnItemAdded_-_ObjectReference event on a http://www.creationkit.com/ReferenceAlias_Script script to be glued to the player. You can also make http://www.creationkit.com/Arrays_(Papyrus)#Creating_a_FormID_Array and, http://www.creationkit.com/GetFormFromFile_-_Game#Examples, preemptively add appropriate forms to the list http://www.creationkit.com/Complete_Example_Scripts#Maintenance.2Fupdate_code_which_runs_once_per_save_load_and_shows_a_message_when_a_mod_is_updated_or_first_loaded.
User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Mon Nov 19, 2012 1:11 am

...OK...In other words its a bit of an effort for such a small part of the mod....hmmm, I'll probably go the formList route for the time being and then at a later date, if necessary, I'll add in the mod detecting bit. Cheers mate

- Hypno
User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Mon Nov 19, 2012 12:17 am

It isn't THAT hard, but it isn't trivial. My mod does this already. Add an alias to your quest with a script that has a state flag. Before you call remove all items, assign the alias to the player and set the flag to true. Call remove all items.

The alias script should have an OnObjectUnequipped handler. It checks the state, and if it is true, records the item. Maybe doesn't record it if you can cast it to WEAPON. Each event starts a RegisterForSingleUpdate(0.5) on the player. Since the events roll in so quickly, only the last one will actually cause the OnUpdate to fire.

When OnUpdate fires, remove the items from the container with a target of player and then clear the player reference so you stop recieving events.

Note that you will need to use an injected empty formlist. Also, formlists were unstable prior to 1.6.

Feel free to check out my mod Code if you want to lift some example code:

http://skyrim.nexusmods.com/mods/15524

Specifically, TweakPlayerRef.psc and TweakFenceScript.psc. I would post them here, but they are sort of large because of all the item filters my mod offers.
User avatar
no_excuse
 
Posts: 3380
Joined: Sun Jul 16, 2006 3:56 am

Post » Mon Nov 19, 2012 4:13 am

I think i have it figured out using a skse function plus an array. Pretty much fully working, just ironed out the last remaining crease, still got to test. Once i know its 100% working i'll post up my final solution

- Hypno
User avatar
Jose ordaz
 
Posts: 3552
Joined: Mon Aug 27, 2007 10:14 pm


Return to V - Skyrim