Jump to content

A few simple scripts for detecting equipped/unequipped armor


Recommended Posts

Posted (edited)

Join/Leave the Skyrim Unbound's Forsworn Faction by Equipping Forsworn Armor

This is a simple script for the mod Skyrim Unbound that lets you join or leave the Skyrim Unbound's Forsworn faction. You might be able to make it work for other mods as well.

The script requires a few modifications in the plugin file, some of which can be done by TES5Edit, however in order to attach the script to the magic effect you have to use Creation Kit.

Requirements

You must create the following in the plugin (ESP):

1. A magic effect with a script attached.
2. A spell that uses the magic effect
3. A perk that uses the spell (optional)
4. A form list that holds the form IDs of Forsworn armors (e.g. the standard one (Forsworn Armor) or the special one (Armor of the Old Gods))

Important: The magic effect script should at least be able to access a few things from the plugin as Properties, which you must add to the script in the Creation Kit. The form list, the SU's special Forsworn faction and the player as an actor.

Here are some screenshots from TES5Edit for reference:

The Armor Form List:

 

Spoiler

_formlist.thumb.jpg.843f30806c835a543f8d7731ab71482b.jpg

 

The Perk:

 

Spoiler

_perk.thumb.jpg.c36349d0937bb73d68af4de1a48efd82.jpg

 

The Spell:

 

Spoiler

_spell.thumb.jpg.d1835c7677e6cd4751fc970eac8ce492.jpg

 

The Magic Effect (in three parts):

Note: We won't be using everything seen in the VMAD section.

Spoiler

_magiceffect_a.thumb.jpg.1fc525c15c82868beb4e5a317a4d1866.jpg

_magiceffect_b.thumb.jpg.b416520dbee1d57f8fb657b088701139.jpg

_magiceffect_c.thumb.jpg.b29d87168351f79681d915a1245725a2.jpg

 

 

 

The Script:

Note that the three 'properties' of the script you see below must be added from the plugin using the Creation Kit.

ScriptName SU_ForswornPlayerEffect Extends ActiveMagicEffect  

FormList Property SU_ForswornArmorsList  Auto  
Faction Property SU_ForswornFaction  Auto  
Actor Property Player  Auto  

Bool Locked = False

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If SU_ForswornArmorsList.HasForm(akBaseObject As Armor)
		While(Locked)
			Utility.Wait(0.1)
		EndWhile
		Locked = True
		JoinForsworn()
		Locked = False
	EndIf
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If SU_ForswornArmorsList.HasForm(akBaseObject As Armor)
		While(Locked)
			Utility.Wait(0.1)
		EndWhile
		Locked = True
		LeaveForsworn()
		Locked = False
	EndIf
EndEvent

Function JoinForsworn()
	Player.AddToFaction(SU_ForswornFaction)
	Player.SetFactionRank(SU_ForswornFaction, 1)
EndFunction

Function LeaveForsworn()
	Player.RemoveFromFaction(SU_ForswornFaction)
EndFunction

 

How to use it:

In order to use this modification, you must add the perk or the spell to the player. As long as the player has this perk/spell, whenever the player equips a Forsworn armor he/she will join the Forsworn (i.e. guards etc. will be hostile) and will be removed from the faction when he/she take the armor off.

How to Uninstall:

Use Player.RemovePerk or Player.RemoveSpell before uninstalling/disabling it. Won't cause any harm even if you don't.


Discussion:

There are of course other ways to achieve the same thing, however there are always some tradeoffs. Another way may be to attach a similar spell to Forsworn armors but I find it inconvenient and it might create conflicts with other mods.

 

 

 

 

 

 

 

 

 

 

 

 

Edited by bjornk
Posted (edited)

A Pubic Hair Hiding Script

Now, while this script is quite similar to the one above, the use of it is a lot more specific. First of all, what you need is a mod that replaces or enables facial hair (beard) with pubic hair for female player characters. I have been using one although it's heavily modified and I can't remember where I found it. The plugin is named as PubicMeshColorRE.esp so if anyone knows which mod it's from let me know and I will update this post.

The usual way Bethesda handles armors and clothing in Skyrim is to replace the entire torso mesh (the body as well as the armor/clothing). However, I use a two piece underwear set on the body and when they are equipped, the torso (body) remains as it is and won't be replaced.

The Problem:

Since we don't/can't replace the torso with one doesn't have a pubic hair whenever the player wears underwear, the pubic hair sticking out from the underwear becomes a problem.

The Solution:

To fix the issue, we must detect the underwear and hide the pubic hair when the underwear is worn and when it's taken off, we must show the pubic hair again. We can do this using a magic effect (and a spell) with a script.

Requirements in the plugin:

1. A spell
2. A magic effect
3. Two form lists (list of all available pubic hairs, list of underwear that need to detected)

Note that the pubic hair plugin must use all available underwear mods in your load order as "masters" in order to access the underwear form IDs.

Here are some screenshots from my custom plugin:

The Spell:

Spoiler

_pubhaircspell.thumb.jpg.5ba54b1803315613ce962a5a7aefa958.jpg


The Magic Effect (in two parts):

Spoiler

_pubhaircsme_a.thumb.jpg.947002f2555659fb649ee1a1c78b085b.jpg

_pubhaircsme_b.thumb.jpg.c964e83e880ccab8ce93fde7911bfde0.jpg

 

 

The Pubic Hair Form List:

Spoiler

_pubhairlist.thumb.jpg.c4dafd6554813e6ec402f3b2426d2be1.jpg

The Underwear Form List:

Spoiler

_pubhairhidingclotheslist.thumb.jpg.92c949f085f86ebfbabc639b72308109.jpg

 

The Script:

This script also requires three properties from the plugin (you will need the CK for that):

PlayerRef
A reference to the player character as an Actor

PubicHairHidingClothesList
A formlist to hold the list of underwear (from other mods) that we need to detect.

PubicHairList
The list of all available pubic hair styles. Note that the very first element of it must be the "no pubic hair" option.

Here's the code from the script:

ScriptName PubicHairControl Extends ActiveMagicEffect 

Actor Property PlayerRef Auto
FormList Property PubicHairHidingClothesList  Auto  
FormList Property PubicHairList  Auto  

HeadPart StoredPubicHair = None
Bool Locked = False

; Procedure:
; 1. Check if the akBaseObject is valid (i.e. a panty etc) (valid if it is in the PubicHairBlockingClothesList)
; 2. If valid, then find and store the current pubic hair as pubichair. 
; 3. Then switch it to the pubic hair #0 i.e. the one doesn't have a mesh.
Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If	PubicHairHidingClothesList.HasForm(akBaseObject As Armor)
		While Locked
			Utility.Wait(0.1)
		EndWhile
		Locked = True
		HidePubicHair(True)
		Locked = False
	EndIf
EndEvent

; Procedure:
; 1. Change the pubic hair from 0 to previously stored PubicHair.
Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If	PubicHairHidingClothesList.HasForm(akBaseObject As Armor)
		While Locked
			Utility.Wait(0.1)
		EndWhile
		Locked = True
		HidePubicHair(False)
		Locked = False
	EndIf
EndEvent

Function HidePubicHair(Bool Hide)

	HeadPart NoPubicHair = PubicHairList.GetAt(0) As HeadPart
	HeadPart TempHP = None
	ActorBase ab = PlayerRef.GetActorBase()

	Int i = 0

	If Hide
		i = ab.GetIndexOfHeadPartByType(4) ; <- gets the index of 4: Beard/Pubic Hair 
		If i > 0
			TempHP = ab.GetNthHeadPart(i) ; <- gets the head part at that index
			If TempHP != NoPubicHair ; <- if it is not the same as NoPubicHair, in which case we don't need to hide anything
				StoredPubicHair = TempHP ; <- stores the current pubic hair that we found
			EndIf
		EndIf

		If StoredPubicHair != None && StoredPubicHair != NoPubicHair
			ab.SetNthHeadPart(NoPubicHair, i) ; <- Pubic Hair with no mesh/texture
			PlayerRef.QueueNiNodeUpdate()
		EndIf
	Else
		If StoredPubicHair != None && StoredPubicHair != NoPubicHair
			i = ab.GetIndexOfHeadPartByType(4) ; <- gets index of NoPubicHair
			If i > 0
				ab.SetNthHeadPart(StoredPubicHair, i) ; <- nopubichair is replaced by what we previously stored
			EndIf
			PlayerRef.QueueNiNodeUpdate()
		EndIf
	EndIf

EndFunction


How to use in the game:

I manually add the spell to the player character using Player.AddSpell.

Uninstalling:

You can remove the spell if you wish but not doing so shouldn't cause any issues.

Discussion:

Again, I'm sure there are other ways to do this, but this method works for me. Been using it for the past couple of years and haven't had any issues with it.

Update:

As I've mentioned, of the four pubic hair types in the plugin, the first one MUST BE the one with NO MESH, which is used for NO PUBIC HAIR. You can see that in the screenshot below.

_pubhairs.thumb.jpg.c561274acf17ade6c0c3c10b5c752f7e.jpg

 

 

Edited by bjornk

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...