Jump to content

Scripting questions


casma164

Recommended Posts

I worked on this script a little bit more.

This is where I am now..

 

Scriptname enlargementray extends ActiveMagicEffect

int Property kSlotMask30 = 0x00000001 AutoReadOnly ; HEAD
int Property kSlotMask31 = 0x00000002 AutoReadOnly ; Hair
int Property kSlotMask32 = 0x00000004 AutoReadOnly ; BODY
int Property kSlotMask33 = 0x00000008 AutoReadOnly ; Hands
int Property kSlotMask34 = 0x00000010 AutoReadOnly ; Forearms
int Property kSlotMask35 = 0x00000020 AutoReadOnly ; Amulet
int Property kSlotMask36 = 0x00000040 AutoReadOnly ; Ring
int Property kSlotMask37 = 0x00000080 AutoReadOnly ; Feet
int Property kSlotMask38 = 0x00000100 AutoReadOnly ; Calves
int Property kSlotMask39 = 0x00000200 AutoReadOnly ; SHIELD
int Property kSlotMask40 = 0x00000400 AutoReadOnly ; TAIL
int Property kSlotMask41 = 0x00000800 AutoReadOnly ; LongHair
int Property kSlotMask42 = 0x00001000 AutoReadOnly ; Circlet
int Property kSlotMask43 = 0x00002000 AutoReadOnly ; Ears
int Property kSlotMask44 = 0x00004000 AutoReadOnly ; Unnamed
int Property kSlotMask45 = 0x00008000 AutoReadOnly ; Unnamed
int Property kSlotMask46 = 0x00010000 AutoReadOnly ; Unnamed
int Property kSlotMask47 = 0x00020000 AutoReadOnly ; Unnamed
int Property kSlotMask48 = 0x00040000 AutoReadOnly ; Unnamed
int Property kSlotMask49 = 0x00080000 AutoReadOnly ; Unnamed
int Property kSlotMask50 = 0x00100000 AutoReadOnly ; DecapitateHead
int Property kSlotMask51 = 0x00200000 AutoReadOnly ; Decapitate
int Property kSlotMask52 = 0x00400000 AutoReadOnly ; Unnamed
int Property kSlotMask53 = 0x00800000 AutoReadOnly ; Unnamed
int Property kSlotMask54 = 0x01000000 AutoReadOnly ; Unnamed
int Property kSlotMask55 = 0x02000000 AutoReadOnly ; Unnamed
int Property kSlotMask56 = 0x04000000 AutoReadOnly ; Unnamed
int Property kSlotMask57 = 0x08000000 AutoReadOnly ; Unnamed
int Property kSlotMask58 = 0x10000000 AutoReadOnly ; Unnamed
int Property kSlotMask59 = 0x20000000 AutoReadOnly ; Unnamed
int Property kSlotMask60 = 0x40000000 AutoReadOnly ; Unnamed
int Property kSlotMask61 = 0x80000000 AutoReadOnly ; FX01

Event OnEffectStart(Actor akTarget, Actor akCaster)
akTarget.GetEquippedObject(kSlotMask32)
akTarget.Unequipall()
akTarget.SetScale(2.0)
akTarget.SetScale(3.0)
akTarget.SetScale(4.0)
akTarget.SetScale(5.0)
akTarget.SetScale(6.0)
akTarget.SetScale(7.0)
akTarget.SetScale(8.0)
akTarget.SetScale(9.0)
akTarget.SetScale(10.0)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
akTarget.SetScale(9.0)
akTarget.SetScale(8.0)
akTarget.SetScale(7.0)
akTarget.SetScale(6.0)
akTarget.SetScale(5.0)
akTarget.SetScale(4.0)
akTarget.SetScale(3.0)
akTarget.SetScale(2.0)
akTarget.SetScale(1.0)
akTarget.EquipItem(kSlotMask32)
EndEvent

 

Yes, I realize I have GetEquippedObject for slot32 only, I'm only testing right now to see if the code will work correctly.

 

Now, the wall I'm hitting now is how to get the EquipItem function working without using an ObjectID.

 

Is there a way by using a Property to allow the EquipItem function to use a different parameter(IE not an ObjectID)?

 

BTW, the script compiles successfully until it hits the EquipItem function, the error is "type mismatch on parameter 1 (did you forget a cast?)"

Edited by casma164
Link to comment
Share on other sites

First, GetWornForm uses the slot masks to determine what is equipped. GetEquippedObject is for weapons, spells & shouts and does not use the slot masks.

 

Second, you are trying to equip an integer rather than a form, armor, weapon or objectreference

 

Third, I took the liberty and tinkered with your script. I've tested compilation and it compiles but I have not tested whether or not it functions. If you want to test it, feel free. It should (knock on wood) unequip all armors & weapons, do the size change then re-equip all the removed stuff.

 

 

Scriptname enlargementray extends ActiveMagicEffect

Form ItemSM ;stands for: Item in Slot Mask
Form ItemWeap ;stands for: Item as weapon

Form[] Property WeapArray Auto
Form[] Property SMArray Auto

Function GetEquippedWeaponForms(Actor TheTarget)
	WeapArray = new Form[2] ;shouts do not need be unequipped so skip checking for them
	int x = 0
	While x < 2
		ItemWeap = TheTarget.GetEquippedObject(x)
		If (ItemWeap as Weapon)
			WeapArray[x] = ItemWeap
		Else
			WeapArray[x] = None
		EndIf
		x += 1
	EndWhile
EndFunction

Function GetEquippedArmorForms(Actor TheTarget)
	SMArray = new Form[32]
	int x = 1
	int count = 0
	While x <= 2147483648
		ItemSM = TheTarget.GetWornForm(x)
		If (ItemSM as Armor)
			SMArray[count] = ItemSM
		Else
			SMArray[count] = None
		EndIf	
		count += 1
		x = x * 2
	EndWhile
EndFunction

Function EquipArmorForms(Actor TheTarget)
	int ArrayLength = SMArray.length
	int x = 0
	While x < ArrayLength
		Form Entry = SMArray[x]
		If (Entry as Armor)
			If !(TheTarget.IsEquipped(Entry))
				TheTarget.EquipItem(Entry)
			EndIf
		EndIf
		x += 1
	EndWhile
EndFunction

Function EquipWeaponForms(Actor TheTarget)
	int ArrayLength = WeapArray.length
	int x = 0
	While x < 2
		Form Entry = WeapArray[x]
		If (Entry as Weapon)
			If !(TheTarget.IsEquipped(Entry))
				TheTarget.EquipItemEX(Entry,x)
			EndIf
		EndIf
		x += 1
	EndWhile
EndFunction

Event OnEffectStart(Actor akTarget, Actor akCaster)
	GetEquippedArmorForms(akTarget)
	GetEquippedWeaponForms(akTarget)
	akTarget.UnequipAll()
	akTarget.SetScale(2.0)
	akTarget.SetScale(3.0)
	akTarget.SetScale(4.0)
	akTarget.SetScale(5.0)
	akTarget.SetScale(6.0)
	akTarget.SetScale(7.0)
	akTarget.SetScale(8.0)
	akTarget.SetScale(9.0)
	akTarget.SetScale(10.0)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	akTarget.SetScale(9.0)               
	akTarget.SetScale(8.0)        
	akTarget.SetScale(7.0)
	akTarget.SetScale(6.0)
	akTarget.SetScale(5.0)
	akTarget.SetScale(4.0)
	akTarget.SetScale(3.0)
	akTarget.SetScale(2.0)
	akTarget.SetScale(1.0)
	EquipArmorForms(akTarget)
	EquipWeaponForms(akTarget)
EndEvent 

 

 

FYI - there is no need to list out all of the slot mask int assignments as you did. Those are already coded in by SKSE. All that needs to be done is use the hex value or the decimal equivalent within the GetWornForm function in order to obtain the form of the worn object.

Link to comment
Share on other sites

Your script does work, however I have the mod series populated cities, towns, etc. and the mod doesn't remove their armor. It removes the weapon, enlarges them, then shrinks and equips the weapon.

Edited by casma164
Link to comment
Share on other sites

Hmm...

 

Probably a default outfit situation. The default outfit is not part of the NPC inventory but rather assigned directly to the actor record. It could be that the default outfit cannot be unequipped with the UnequipAll function.

 

But I'm just speculating at this point.

 

Have you tried to see if the armor unequips and equips when the player is the target? If not, try it. If it does not work with the player, then it may be in the scripting. If it does work for the player, then it boils down to an outfit situation on the NPC.

 

I remember some others wanting to strip NPCs for some bathing situations and they ended up needing to transfer the inventory to a hidden container and transfer back when they needed to get dressed. That would be the workaround if it comes down to it.

Link to comment
Share on other sites

Alright, I did what you asked and made another spell which had a delivery of self.

It mostly worked, so I cast the spell in first person view. It unequipped everything, but the player actor never "grew" in size. When I switched to third person, the player actor then changed in size.

After the spell expired, the size shrank as expected and *almost* everything was re-equipped. The enchanted ring I was wearing before was not re-equipped, instead another ring I had in my inventory was equipped in its place.

 

On a side note I have ImmersiveFP installed and the camera changed position with the change in size. It wasn't *quite* right in position, it appeared that the camera was inside the head.

 

I also have a BBP skeleton installed and after shrinking, the breasts were distorted. It seems like they were being pulled upward. I saved the game and exited to desktop, came back and it was fixed.

This glitch also applies to NPCs as well.

Edited by casma164
Link to comment
Share on other sites

I do not know how to solve the camera issue. That has something to do with changing the player's size. But as I understand it, this is intended to be used on NPCs rather than the player. So the camera thing should be a non-issue

 

It works then with the player as the target. The reason the enchanted ring was not re-equipped is that the functions used obtain the base record and equip the first instance of that base record. The first instance in this case was the non-enchanted version of the ring.

 

I'm going to make a suggestion but I do not know if it will work.

This suggestion should resolve two things 1. the intended item will re-equip 2. make NPCs work correctly

 

Create an empty interior cell

Drag and drop two instances of PlayerHouseChest

Change the script as follows (which compiles)

 

 

Scriptname enlargementray extends ActiveMagicEffect

Form ItemSM ;stands for: Item in Slot Mask
Form ItemWeap ;stands for: Item as weapon

Form[] Property WeapArray Auto
Form[] Property SMArray Auto

ObjectReference Property EquipCont Auto
ObjectReference Property JunkCont Auto

Function GetEquippedWeaponForms(Actor TheTarget)
	WeapArray = new Form[2] ;shouts do not need be unequipped so skip checking for them
	int x = 0
	While x < 2
		ItemWeap = TheTarget.GetEquippedObject(x)
		If (ItemWeap as Weapon)
			WeapArray[x] = ItemWeap
			TheTarget.RemoveItem(ItemWeap,1,true,EquipCont)
		Else
			WeapArray[x] = None
		EndIf
		x += 1
	EndWhile
EndFunction

Function GetEquippedArmorForms(Actor TheTarget)
	SMArray = new Form[32]
	int x = 1
	int count = 0
	While x <= 2147483648
		ItemSM = TheTarget.GetWornForm(x)
		If (ItemSM as Armor)
			SMArray[count] = ItemSM
			TheTarget.RemoveItem(ItemSM,1,true,EquipCont)
		Else
			SMArray[count] = None
		EndIf	
		count += 1
		x = x * 2
	EndWhile
EndFunction

Function EquipArmorForms(Actor TheTarget)
	int ArrayLength = SMArray.length
	int x = 0
	While x < ArrayLength
		Form Entry = SMArray[x]
		If (Entry as Armor)
			If !(TheTarget.IsEquipped(Entry))
				EquipCont.RemoveItem(Entry,1,true,TheTarget)
				TheTarget.EquipItem(Entry)
			EndIf
		EndIf
		x += 1
	EndWhile
EndFunction

Function EquipWeaponForms(Actor TheTarget)
	int ArrayLength = WeapArray.length
	int x = 0
	While x < 2
		Form Entry = WeapArray[x]
		If (Entry as Weapon)
			If !(TheTarget.IsEquipped(Entry))
				EquipCont.RemoveItem(Entry,1,true,TheTarget)
				TheTarget.EquipItemEX(Entry,x)
			EndIf
		EndIf
		x += 1
	EndWhile
EndFunction

Event OnEffectStart(Actor akTarget, Actor akCaster)
	GetEquippedArmorForms(akTarget)
	GetEquippedWeaponForms(akTarget)
	akTarget.RemoveAllItems(JunkCont,true,true)
	akTarget.SetScale(2.0)
	akTarget.SetScale(3.0)
	akTarget.SetScale(4.0)
	akTarget.SetScale(5.0)
	akTarget.SetScale(6.0)
	akTarget.SetScale(7.0)
	akTarget.SetScale(8.0)
	akTarget.SetScale(9.0)
	akTarget.SetScale(10.0)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	akTarget.SetScale(9.0)               
	akTarget.SetScale(8.0)        
	akTarget.SetScale(7.0)
	akTarget.SetScale(6.0)
	akTarget.SetScale(5.0)
	akTarget.SetScale(4.0)
	akTarget.SetScale(3.0)
	akTarget.SetScale(2.0)
	akTarget.SetScale(1.0)
	EquipArmorForms(akTarget)
	EquipWeaponForms(akTarget)
	JunkCont.RemoveAllItems(akTarget,true,true)
EndEvent  

 

Be sure to assign the container references you placed earlier in the empty cell to the object reference properties

Test it out.

 

Regarding the skeleton & breasts. No idea how to resolve that other than exiting the game and restarting. You may want to do tests to see if it happens with the stock skeleton. Could be the physics of the modified skeleton get screwed up with the scale change.

Link to comment
Share on other sites

As far as the camera/skeleton issue, I knew that those glitches could not be fixed by what we are trying to accomplish. It was more for the benefit of other people who happen in on this thread.

 

About your request, I'll try to get to it today.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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