Jump to content

Help to complete a hat equip script


Agnot2006

Recommended Posts

I have a small script gleaned from the forums:

 

 

Scn sashaSummonSCRIPT

Ref HatSave
Short DidSave

Begin OnEquip
if player.GetEquippedObject 10, is wearing a hat
	Set HatSave to player.GetEquippedObject 10, save what Im wearing
	Set DidSave to 1
endif
SashaREF.moveto player
	If DidSave >0
		EquipItem.HatSave ,Re-equip the hat I was wearing
Endif
	ElseIf DidSave == 0
		UnequipItem PartyHatREF , remove the party hat from head.
	Endif

End

I have added the script to a Party Hat so I can use a quick key; this enables me to call my companion when she gets stuck. Begin OnEquip , SashaREF.moveto player, end. This works.

My problem is:

If I am wearing a hat or helmet or something already I have to open my inventory and re-equip it afterwards.

Can someone help with an addition to detect if I am wearing a hat, save it, equip the Party hat to call my companion then re-equip the saved hat again?

This is my first attempt at the script I don’t think it should be an OnEquip though.

Can anyone help me sort this out?

Edited by Agnot2006
Link to comment
Share on other sites

On Equip should work. You just need to reference the player, and a If/else/endif issue. And use semi-colons for comments. Also, for the party hat, Player.UnequipItem PartyHatREF might be wrong unless the base object of your hat is actually named PartyHatREF

 

 

Scn sashaSummonSCRIPT 

Ref HatSave 
Short DidSave 

Begin OnEquip

 set HatSave to 0
 set Didsave to 0
 
 if player.GetEquippedObject 10, is wearing a hat 
  Set HatSave to player.GetEquippedObject 10 ; save what Im wearing 
  Set DidSave to 1 
 endif 
 SashaREF.moveto player 
 If DidSave > 0 
  Player.EquipItem HatSave   ;Re-equip the hat I was wearing 
 else
  Player.UnequipItem PartyHatREF ; remove the party hat from head. 
 Endif 
 
End

 

 

Link to comment
Share on other sites

I think you're right about On Equip not being enough. You need to capture the current hat in a game or menu mode

 

Scn sashaSummonSCRIPT 

Ref HatSave 
Short DidSave
Short Teleporting

Begin OnEquip

 set Teleporting to 1
 
End

Begin MenuMode 1002	;Inventory

if Teleporting == 0

	set HatSave to player.GetEquippedObject 10	;Monitor current hat when pipboy up in inventory
	if (HatSave)
		set DidSave to 1
	else
		set DidSave to 0
	endif
else

	SashaREF.moveto player 

	If DidSave > 0 
		Player.EquipItem HatSave   ;Re-equip the hat I was wearing 
	else
		Player.UnequipItem PartyHatREF ; remove the party hat from head. 
	Endif
	
	set Teleporting to 0
	
endif

END

Link to comment
Share on other sites

Hello,

 

the problem with GetEquippedObject in a OnEquip block is that when that block is executed, it is already too late to detect the old hat. It has already been replaced.

So you would have to go the way Rickerhk suggested and monitor the content of the slot all the time during game and menu mode ... which is, in my humble opinion, not a very elegant way to do it. The script would run all the time and eat up resources. Not much of course, but still. My mantra is to avoid such scripts at all costs whenever possible.

 

Does it have to be a hat? You could change the Biped slot to something more obscure. One of the three BodyAddOn slots, for example. Or the MouthObject slot. Those are usually empty.

You could even go so far and select NO slot at all (and remove the NIF model files). The GECK will complain about this and warn you, but it saves and works. The OnEquip block of this armor (without slot) is still executed in the game, if you equip the item.

 

Personally, I would do it completely different. I would use a ingestible, not a armor item to do the teleporting. You can hotkey them, they don't need a Biped slot, and the ingestible tab of the inventory is cluttered up with “crap” anyway.

 

Adding a script effect to an ingestible is not totally straight forward though, so I'll explain it step by step, in case you want to do it this way. If you want to do it with a armor item, you can stop reading now ;)

 

First we need our ingestible. Lets use Buffout as a template. Go to Game Effects → Ingestible and locate Buffout. Give it a new name “SummonSashaPill” and choose Yes to create a new form. Then open our new ingestible with a double click.

Change the ingame name from Buffout to “[summon Sasha]” (the brackets will make it show up at the bottom of the inventory), set “Use Sound” to NONE, Addiction Chance to 0, Addiction to NONE, delete the four existing effects and tick the Auto-Calculate Checkbox. Then click OK. The GECK will complain that our pill has no effect, we just ignore this for now, we come back later.

 

Now we create the script. Open the script editor (the pencil icon in the tool bar) and create a new script. Make sure “Script Type” is set to Effect, then copy paste the following short script into the editor and save the new script:

 

ScriptName SummonSashaPillEffectScript

Begin ScriptEffectStart
SashaREF.MoveTo Player			;move actor to player
Player.AddItem SummonSashaPill 1 1	;silently add a new pill, we used the existing one
End

 

The AddItem command will make sure we never run out of summon pills. Doing this during a ScriptEffectStart block will also make sure that the pill is not removed from the hotkey.

 

Now we need to create an Effect with this script. Go to Game Effects → Base Effects, right click into the list and choose New. As ID enter “SummonSashaEffect”, as Name enter “Summon Sasha”, change “Effect Archetype” to Script and in the “Assoc. Item” dropdown menu you select our script “SummonSashaPillEffectScript”. In the Flags field, make sure the “Self” checkbox is checked. Then click OK.

 

Almost done. Go back to Game Effect → Ingestible, locate the SummonSashaPill and open it with a double click. Rightclick into the Result list and choose new to add a new effect. Choose SummonSashaEffect, make sure Range is set to Self and click OK. Done. Click OK again to close the ingestible editor. At this point you might want to write down the Form ID of the new pill we created so you can add it to your character in the game.

 

Now every time you “take” one of these pills, the actor should be teleported to your location and you immediately get a new pill. You can hotkey the pill and it will stay hot-keyed.

 

I hope this, rather lengthy post, helps.

 

Have a nice day.

Link to comment
Share on other sites

Absolutly fantastic. Ive seen it done with the Hat by other people and got tunnel vision it didn’t occur to me to use an ingestable.

I have created the pill and it works fine no Hat required.

Thank you for a great solution

 

Kudos to you

Link to comment
Share on other sites

  • Recently Browsing   0 members

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