Jump to content
IGNORED

SOS-AS, SOS Armor Swapper


Recommended Posts

Hi everyon o/

 

I'm in the process of making a mod for futa lovers, to not derail much more the Futa content thread in LE subforum, I'm continuing it here.

 

Mod Purpose:

Switch armor to revealing or normal ones depending if the, female, actor has a shlong or not, thus permitting something like undies with shlong model with it.

 

and since @Holzfrau asked me to, tagging @Targultoon too.

Link to comment
18 minutes ago, LeFlemard said:

would something like that works for checking type of shlong equipped?


  Int iFaction          = factionList.GetSize()   ; initialize faction index
  bool hasCorrectShlong = False                   ; initialize bool
  While iFaction                                  ; until equal zero
      iFaction -= 1
      Faction testingFaction = factionList.GetAt(iFaction) as Faction   ; put in testingFaction currently tested faction
      if npc.IsInFaction(testingFaction)                              ; check if in faction
          hasCorrectShlong = True                                       ; declare being in correct faction to apply
      EndIf
  EndWhile

with factionList being a formidList containing every valid sos faction (by example "SOS_Addon_BDFemaleSheath_Faction", which is a bad example, as it is sheathed)

It looks like you are creating an awful lot of dependencies doing it this way.  Here's a way to do it more generically:

 

Start by adding a new property that references SOS's main script: SOS_SetupQuest_Script Property SOS_Main Auto.  The value you need to set this to will be coming out of Schlongs of Skyrim - Core.esm, so you will need to make that required by your armor swapper plugin, if you haven't already.

 

Then, you can use that to query which addon the actor is using and deal with the faction that way:

bool hasCorrectSchlong = false
Faction schlongFaction = SOS_Data.GetFaction(SOS_Main.GetActiveAddon(npc))

if (schlongFaction)
	string addonName = schlongFaction.GetName()

	if ((StringUtil.Find(addonName, "No Schlong") == -1) && (StringUtil.Find(addonName, "Pubic Hair") == -1))
		hasCorrectSchlong = true
	endIf
endIf

All this does is check the addon name to see if it contains "No Schlong" or "Pubic Hair", which is the same thing Gender Bender does to determine how to handle addons.  SOS_Data is SOS's global function library, so you don't need to make a property for it.

Link to comment

Took me awhile to be able to compile properly (skyui is a pain and I forgot to unpack racemenu scripts), but here the result (which do compile)

Scriptname SOS_Armor_Swapper_Main extends Quest  

SOS_SetupQuest_Script Property SOS_Main Auto
GlobalVariable Property ScannerInterval  Auto  
Quest Property ScannerQuest  Auto  
FormList Property StandardArmors  Auto  
FormList Property RevealingArmors  Auto  

event OnInit()
    RegisterForSingleUpdate(ScannerInterval.GetValue())
endEvent

 

event OnUpdate()
    ScannerQuest.Start()
    int curAlias = ScannerQuest.GetNumAliases()
    while (curAlias > 0)
        curAlias -= 1
        Actor myActor = (ScannerQuest.GetNthAlias(curAlias) as ReferenceAlias).GetActorRef()
        bool hasCorrectSchlong = false
        Faction schlongFaction = SOS_Data.GetFaction(SOS_Main.GetActiveAddon(myActor))
        if (schlongFaction)
            string addonName = schlongFaction.GetName()
            if ((StringUtil.Find(addonName, "No Schlong") == -1) && (StringUtil.Find(addonName, "Pubic Hair") == -1))
                hasCorrectSchlong = true
            endIf
        endIf
        if (hasCorrectSchlong)
            Form oldArmor = myActor.GetWornForm(0x00000004)
            int index = StandardArmors.Find(oldArmor)
            if (index > -1)
                Armor newArmor = RevealingArmors.GetAt(index) as Armor
                myActor.RemoveItem(oldArmor, 255, true)
                myActor.AddItem(newArmor, 1, true)
                myActor.EquipItem(newArmor, false, true)
             endIf
        Else
            Form oldArmor = myActor.GetWornForm(0x00000004)
            int index = RevealingArmors.Find(oldArmor)
            if (index > -1)
                Armor newArmor = StandardArmors.GetAt(index) as Armor
                myActor.RemoveItem(oldArmor, 255, true)
                myActor.AddItem(newArmor, 1, true)
                myActor.EquipItem(newArmor, false, true)
             endIf
        endIf
    endWhile
    ScannerQuest.Stop()
     RegisterForSingleUpdate(ScannerInterval.GetValue())
endEvent

 

The part in the Else is for actor that have revealing armor while not having a shlong addon shlong.

 

Now for quest alias for the scanner, should be isgender AND isinfaction AND getequip(revealingarmor) OR getequip(standardarmor)...

Link to comment

You should put `curAlias -= 1` at the end of the loop. Also if you check all aliases, you should put a sanity check to check if the alias is actually filled. Just adding a guard clause after the GetActorRef() line should be enough, like this

Actor myActor = (ScannerQuest.GetNthAlias(curAlias) as ReferenceAlias).GetActorRef()
If myActor == None
  Return;
EndIf

 

Link to comment
4 hours ago, Targultoon said:

You should put `curAlias -= 1` at the end of the loop.

Nope, this loop is going backwards.  Decrementing at the beginning is correct.  Remember, these are 0 based indexes.  curAlias will start at 20, and we need to bump it down to 19 immediately or it will be out of bounds.

Quote

Also if you check all aliases, you should put a sanity check to check if the alias is actually filled. Just adding a guard clause after the GetActorRef() line should be enough, like this


Actor myActor = (ScannerQuest.GetNthAlias(curAlias) as ReferenceAlias).GetActorRef()
If myActor == None
  Return;
EndIf

 

Nope again.  Remember, the alias fill is only going to pick up actors in the area, it will be coming up with empty aliases pretty often (i.e. interiors).  Dropping out of OnUpdate for this would be very bad.

Link to comment
5 hours ago, LeFlemard said:

Took me awhile to be able to compile properly (skyui is a pain and I forgot to unpack racemenu scripts), but here the result (which do compile)


Scriptname SOS_Armor_Swapper_Main extends Quest  

SOS_SetupQuest_Script Property SOS_Main Auto
GlobalVariable Property ScannerInterval  Auto  
Quest Property ScannerQuest  Auto  
FormList Property StandardArmors  Auto  
FormList Property RevealingArmors  Auto  

event OnInit()
    RegisterForSingleUpdate(ScannerInterval.GetValue())
endEvent

 

event OnUpdate()
    ScannerQuest.Start()
    int curAlias = ScannerQuest.GetNumAliases()
    while (curAlias > 0)
        curAlias -= 1
        Actor myActor = (ScannerQuest.GetNthAlias(curAlias) as ReferenceAlias).GetActorRef()
        bool hasCorrectSchlong = false

	if (myActor)
        	Faction schlongFaction = SOS_Data.GetFaction(SOS_Main.GetActiveAddon(myActor))
        	if (schlongFaction)
            	string addonName = schlongFaction.GetName()
	            if ((StringUtil.Find(addonName, "No Schlong") == -1) && (StringUtil.Find(addonName, "Pubic Hair") == -1))
    	            hasCorrectSchlong = true
        	    endIf
	        endIf
    	    if (hasCorrectSchlong)
        	    Form oldArmor = myActor.GetWornForm(0x00000004)
	            int index = StandardArmors.Find(oldArmor)
    	        if (index > -1)
	                Armor newArmor = RevealingArmors.GetAt(index) as Armor
    	            myActor.RemoveItem(oldArmor, 255, true)
        	        myActor.AddItem(newArmor, 1, true)
            	    myActor.EquipItem(newArmor, false, true)
	             endIf
    	    Else
	            Form oldArmor = myActor.GetWornForm(0x00000004)
    	        int index = RevealingArmors.Find(oldArmor)
        	    if (index > -1)
            	    Armor newArmor = StandardArmors.GetAt(index) as Armor
                	myActor.RemoveItem(oldArmor, 255, true)
	                myActor.AddItem(newArmor, 1, true)
    	            myActor.EquipItem(newArmor, false, true)
        	     endIf
        endIf
		endIf
    endWhile
    ScannerQuest.Stop()
     RegisterForSingleUpdate(ScannerInterval.GetValue())
endEvent

 

The part in the Else is for actor that have revealing armor while not having a shlong addon shlong.

 

Now for quest alias for the scanner, should be isgender AND isinfaction AND getequip(revealingarmor) OR getequip(standardarmor)...

You will need to make sure myActor actually has something before doing stuff with it.  Otherwise, it will bomb out of OnUpdate with an error and won't fire RegisterForSingleUpdate, breaking your mod.  (I've changed your provided code accordingly)

 

Also, do NPCs spawn with the revealing armor in your game?  If not, I don't see a need to police the ones that have it.

Link to comment
2 hours ago, Holzfrau said:

You will need to make sure myActor actually has something before doing stuff with it.  Otherwise, it will bomb out of OnUpdate with an error and won't fire RegisterForSingleUpdate, breaking your mod.  (I've changed your provided code accordingly)

 

Also, do NPCs spawn with the revealing armor in your game?  If not, I don't see a need to police the ones that have it.

That's in cased the pc is not futa and equip one or give revealing armor version to non futa follower. Thanks for the corrections :3

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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