Jump to content

Scripting Help?


blazeda59

Recommended Posts

Im trying to setup a helmet rack of sorts for the player. After a bit of playing around I've got a rough setup semi working my problem is I cant figure out how to get the code to look for the helmet. Im basing the code off of the weapons rack script but that works by looking for what the player has in their hands not whats on their head and after searching through the wiki I cant figure out a function that will work anyway here's the problem part of the code hope someone can help....Cheers

Auto STATE EmptyRack
	EVENT onActivate(ObjectReference TriggerRef)	


		If (TriggerRef == Game.GetPlayer() as Actor)
			; Only the player can activate this
			
			MessageAlreadyShown = WRackGlobal.GetValue()
			
				if (MessageAlreadyShown == FALSE)
					; If the help message hasn't been shown before then show it.
					HelmetStandActivateMESSAGE.Show()
					WRackGlobal.SetValue(1)
				else
					
					;if (Game.GetPlayer()) && (PlayersEquippedHelmet.IsHelmet()) //Not Working
					;if (Game.GetPlayer() && Game.GetPlayer().IsEquipped(ArmorHelmet)) //Not Working
					; Grabs the weapon from the player and places it in the correct place.
					HandleHelmetPlacement()
					
						
					else
					; If the player doesn't have a shield equipped tell him he needs one.
						HelmetStandNoHelmetMESSAGE.Show()
						

				endif
			
			endif
		endif


	endEVENT
endSTATE

Link to comment
Share on other sites

There is no vanilla function to check which helmet or armor someone has equipped, you need SKSE for that.

The function you are looking for is http://www.creationkit.com/GetWornForm_-_Actor, the example shown in the page will tell you which armor the player has equipped. To detect the helmet I think that this line will work:

Armor Helmet = Game.GetPlayer().GetWornForm(0x00000002) as Armor

It checks which object you have equipped in the hair slot, I think that all helmets use that slot so it should work, if not you can try try 0x00000001 (head slot) but not all helmets use it.

Link to comment
Share on other sites

cheers I knew I would probably find what I needed within the skse. I'd already tried a few other function from it but couldn't get them working. Anyway after adding the line of code you gave me I was no longer getting the "you need a helmet to use the rack" message which means it found the helmet and was ready to continue but nothing would happen. Like a tool I removed the part of the code that takes the helmet on places it on the rack....dahhh :wallbash: but all's good now I have a working helmet rack all I gotta do now is get the placement right. Thanks for the help :biggrin:

Link to comment
Share on other sites

ok next problem, I've got a fully working stand now that places everything in the right place using keywords like every other display rack in game only thing is certain helmets conflict as they have the same keywords e.g Daedric and Ancient Nord are both classed as Helmet, Daedric, Heavy, Vender Item so as Daedric is first in the code it places the Nordic helmet on the Daedric node as well. Now I could go through and add a new keyword to separate them but that means i have to add it to every enchanted version of that armor as well which is just impractical. So I've been strainin the old brain trying to figure out an easier way and what I've come up with is using the GetModelPath http://www.creationkit.com/GetModelPath_-_Armor function which in theory should cover the majority of the helmets that cant use keywords. Now this all works in my head but not being a code master I cant figure how to use this code the way I need it so any help would be great. Heres the code I'm working on.

	if PlayersDroppedHelmet.HasKeyword(ArmorMaterialIron)
		; Iron
		PlayersDroppedHelmet.MoveToNode(TriggerMarker, "IronPivot01")

	
	; Handle the placement of the helmet by cheking file path to avoid being placed on the wrong node

	elseif PlayersDroppedHelmet.(Game.GetForm(0x00056A9E) as Armor).GetModelPath(Armor\Draugr\DraugrHelmetMale_GO.nif)
		; Ancient Draugr
		PlayersDroppedHelmet.MoveToNode(TriggerMarker, "AncientDraugrPivot01")
Link to comment
Share on other sites

I think the problem is the last part of the code, (Game.GetForm(0x00056A9E) as Armor) is not necessary if you are looking for the model path of the dropped helmet.

It should be:

elseif PlayersDroppedHelmet.GetModelPath(Armor\Draugr\DraugrHelmetMale_GO.nif)
		; Ancient Draugr
		PlayersDroppedHelmet.MoveToNode(TriggerMarker, "AncientDraugrPivot01")
Link to comment
Share on other sites

I've looked at the Creation Kit page and it should be like this:

String FilePath = PlayersDroppedHelmet.GetModelPath(False)

if FilePath == "Armor\Draugr\DraugrHelmetMale_GO.nif"
		; Ancient Draugr
		PlayersDroppedHelmet.MoveToNode(TriggerMarker, "AncientDraugrPivot01")
endif

The problem is that using \ interrupts "" and that's why you receive the error.

You can try using / instead ("Armor/Draugr/DraugrHelmetMale_GO.nif"), maybe that will work.

 

Sorry, I've never used that function before

Edited by pauderek
Link to comment
Share on other sites

  • Recently Browsing   0 members

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