Vanilla script won't compile?

Post » Fri Nov 16, 2012 8:25 pm

Hey,

For the past few weeks I have struggled to figure out why some of my users were having compatibility issues regarding Mannequins and others were not. For some, running Vanilla Mannequin Script Fix with my mod causes CTDs on entering a home, with Mannequins that are enabled/disabled depending on whether or not the user has "built" that section of the home.

I fixed it on my end by removing the enable parents the Mannequins Shared, and instead switch to enabling/disabling them via scripting. After doing that the CTDs totally stopped for me, other users had no such luck, and it wasn't just people who updated the mod, but fresh installs as well.

SO, I decided to nip it in the bud by not using vanilla mannequins at all, but instead duplicating their base scripting and setup, and slightly altering my already existing enable/disable script to also take care of the wandering Mannequins issue. The new script worked perfect for keeping them still, but when trying to duplicate the vanilla script I simply cannot get it to compile. Here is the vanilla script:

Spoiler
Scriptname BB_BYOH_CustomMannequinScript extends Actorimport debugimport utilityidle Property Pose01 Autoidle Property Pose02 Autoidle Property Pose03 AutoForm Property ArmorSlot01 auto hiddenForm Property ArmorSlot02 auto hiddenForm Property ArmorSlot03 auto hiddenForm Property ArmorSlot04 auto hiddenForm Property ArmorSlot05 auto hiddenForm Property ArmorSlot06 auto hiddenForm Property ArmorSlot07 auto hiddenForm Property ArmorSlot08 auto hiddenForm Property ArmorSlot09 auto hiddenForm Property ArmorSlot10 auto hiddenForm Property EmptySlot auto hiddenMessage Property MannequinActivateMESSAGE Auto{Message that appears upon activating the mannequin}Message Property MannequinArmorWeaponsMESSAGE Auto{Message that appears when you attempt to place a non-armor item}int Property CurrentPose =1 Auto{The pose the Mannequin starts in, and is currently in. DEFAULT = 1}EVENT OnCellLoad();Trace("DARYL - " + self + " Waiting a bit because it's the only way to get code to run in OnCellLoad it seems")wait(0.25);Trace("DARYL - " + self + " Cell is loaded so running OnCellLoad()");Trace("DARYL - " + self + " Enabling my AI so I can play an idle"); self.EnableAI(TRUE); While(Is3DLoaded() == FALSE); ;Trace("DARYL - " + self + " Waiting for my 3d to load"); wait(0.25); EndWhile;Trace("DARYL - " + self + " Calling EquipCurrentArmor() Function")EquipCurrentArmor();Trace("DARYL - " + self + " Blocking actors activation")self.BlockActivation();Trace("DARYL - " + self + " Moving to my linked ref")self.EnableAI(TRUE)MoveTo(GetLinkedRef());Trace("DARYL - " + self + " Checking what pose I should be in and playing the idle"); PlayCurrentPose();Trace("DARYL - " + self + " Waiting for a bit to give myself time to animate to the pose"); wait(0.5);Trace("DARYL - " + self + " Disabling my AI so I'll freeze in place")self.EnableAI(FALSE)EndEVENTEVENT OnEnable();Trace("DARYL - " + self + " Running OnEnable() EVENT")EquipCurrentArmor()endEVENTEVENT OnActivate(ObjectReference TriggerRef);Trace("DARYL - " + self + " Showing the acivate menu");int buttonpressed = MannequinActivateMESSAGE.Show(); if buttonpressed == 0;Trace("DARYL - " + self + " Player chose to Place Armor"); Player selected to open the Mannequin's InventoryPlayCurrentPose()self.OpenInventory(TRUE);Trace("DARYL - " + self + " Enabling AI since we are adding an item to the mannequin"); self.EnableAI(TRUE); elseif buttonpressed == 1;Trace("DARYL - " + self + " Player chose to Pose the Mannequin"); Player selected to change the pose;Trace("DARYL - " + self + " Enabling AI since we are about to play an idle"); self.EnableAI(TRUE);Trace("DARYL - " + self + " Checking which pose i'm in and playing the next idle/pose"); if CurrentPose == 1; PlayIdle(Pose02); CurrentPose = 2; elseif CurrentPose == 2; PlayIdle(Pose03); CurrentPose = 3; elseif CurrentPose == 3; PlayIdle(Pose01); CurrentPose = 1; endif; elseif buttonpressed == 2;Trace("DARYL - " + self + " Player chose to do nothing");do nothing; endif;Trace("DARYL - " + self + " Moving to my linked ref")MoveTo(GetLinkedRef());Trace("DARYL - " + self + " Waiting a second to give me some time to animate to my pose")wait(0.1);Trace("DARYL - " + self + " Disabling my AI so i'll freeze in place")self.EnableAI(FALSE)EndEVENTEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer);Trace("DARYL - " + self + " Adding " + akBaseItem + " to the Mannequin")if (akBaseItem as Armor);Trace("DARYL - " + self + " Form " + akBaseItem + " is armor!")[b][color=#ff0000]AddToArmorSlot(akBaseItem)[/color][/b]self.EquipItem(akBaseItem)else;Trace("DARYL - " + self + " Form " + akBaseItem + " is NOT armor!");MessageBox("You can only place armor on the Mannequin.")MannequinArmorWeaponsMESSAGE.Show();WaitMenuMode(0.1)self.RemoveItem(akBaseItem, aiItemCount, true, Game.GetPlayer());Game.GetPlayer().AddItem(akBaseItem, aiItemCount, TRUE)endifendEventEvent OnObjectUnequipped(Form akBaseObject, ObjectReference akReference);Trace("DARYL - " + self + akBaseObject + " was unequipped by the Mannequin")if (akBaseObject as Armor);Trace("DARYL - " + self + " Form " + akBaseObject + " is armor!")[color=#ff0000][b]RemoveFromArmorSlot(akBaseObject)[/b][/color]else;Trace("DARYL - " + self + " Form " + akBaseObject + " is NOT armor!")endifendEventFunction PlayCurrentPose()if CurrentPose == 1PlayIdle(Pose01)elseif CurrentPose == 2PlayIdle(Pose02)elseif CurrentPose == 3PlayIdle(Pose03)endifendFunctionFunction EquipCurrentArmor();Trace("DARYL - " + self + " Attempting to equip current armor")if (ArmorSlot01 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 01")self.EquipItem(ArmorSlot01)endifif (ArmorSlot02 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 02")self.EquipItem(ArmorSlot02)endifif (ArmorSlot03 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 03")self.EquipItem(ArmorSlot03)endifif (ArmorSlot04 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 04")self.EquipItem(ArmorSlot04)endifif (ArmorSlot05 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 05")self.EquipItem(ArmorSlot05)endifif (ArmorSlot06 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 06")self.EquipItem(ArmorSlot06)endifif (ArmorSlot07 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 07")self.EquipItem(ArmorSlot07)endifif (ArmorSlot08 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 08")self.EquipItem(ArmorSlot08)endifif (ArmorSlot09 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 09")self.EquipItem(ArmorSlot09)endifif (ArmorSlot10 != EmptySlot);Trace("DARYL - " + self + " Equipping " + ArmorSlot01 + " from Slot 10")self.EquipItem(ArmorSlot10)endifendFunction

When I compile it, I receive an error telling me that "RemoveFromArmorSlot(akBaseObject) and AddToArmorSlot(akBaseItem) are not functions or do not exist"

Since I couldn't get the script to compile I thought I'd just ; those lines and saw what happened. Well, now every time I exit the area and return on cell reset the Mannequins remove their clothing. I tried fiddling around to see what may be causing it, whether it was my scripting for enabling/disabling, whether the encounter zone was set to No Respawn. Everything checks out, and the only visible issue is the two functions that don't compile.

I tried reading the script but can't make heads nor tales what those functions are for, how I can replace them, get them to compile, or why they may cause the mannequins to go commando on me.

Long story short: Why will this vanilla script not compile?
User avatar
Danielle Brown
 
Posts: 3380
Joined: Wed Sep 27, 2006 6:03 am

Post » Fri Nov 16, 2012 8:33 pm

the script you posted doesnt contain all of the original functions, which is why your script wont compile

if all you are doing is duplicating the original script, your custom script can just extend mannequinactivatorscript instead of actor

and then you can run it without writing anything in the code at all (but you will still have to fill the properties if any)


however, i don't recommend using the vanilla script as is because it simply doesnt work very well. the worst bug is the infinite duping glitch.

also btw, the mannequin wandering thing cannot entirely be fixed by scripting (at least not by individual scripts). it is at the mercy of how many OnLoad calls your cell has (which can be alieviated with script optimization, but requires custom scripts for everything - weapon racks, book cases, mannequins and any other reference with an OnCellAttach or OnCellLoad). also note that even disabled items will still run an OnLoad call if in the same cell

the mannequin script can be rewritten very efficiently but things like weapon racks and to some degree book cases cannot be fixed at all (if being applied to vanilla context) and they use too many unnecessary persistent refs. i had to rewrite those from scratch.

if you want, you are more then welcome to send me a PM, i can help you either write new source code or give you my existing source code which solves pretty much every problem related to mannequins/bookcases/weaponracks
User avatar
Rachel Eloise Getoutofmyface
 
Posts: 3445
Joined: Mon Oct 09, 2006 5:20 pm

Post » Sat Nov 17, 2012 4:48 am

Thanks a ton, I'll still take a stab at it to see if I can't get it working with what you suggested, but with my luck today I'm not too hopeful ~_~;.

Thanks again.
User avatar
asako
 
Posts: 3296
Joined: Wed Oct 04, 2006 7:16 am

Post » Sat Nov 17, 2012 6:25 am

Thanks for posting this.. I was getting ready to update my Vanilla Mannequin Script Fix for v1.6. A lot of people have been complaining about CTD using it - but only after the 1.6 update (using the pre1.6 mod version), and usually in certain places/times. The script is very basic and I saw no reason why it wouldn't work, and worse.. cause CTD.

It sounds like they changed the game engine a little. My guess is that certain functions cannot be done on things that aren't activated or enabled anymore. I'll put a check in it to prevent some things from happening if that's the case.. but I can't replicate the problem people have been having, so I won't know if it's fixed for a little while (unless you/others test it for me).

I'll post a dropbox link to the test-script in the Nex comment section of the Vanilla Mannequin Script Fix... just give me a few minutes to compile and upload it. If you want to use it in your mod, you can - just change the name to something unique so it doesn't conflict with Vanilla.


But the script you have above causes nakedness because when you FIRST add an item, that event auto-equips the item. The 'naked bug' happens upon returning to the area; and without the items being assigned to slots and forced to re-equip.. that's why they're naked (the game-engine unequips things for no apparent reason). They need to be re-equipped quite frequently actually; like when changing poses or accessing the inventory.

By the way, the 'wandering bug' can be fixed by changing the onCellLoad to onCellAttach. If you have a ton of things in a single area which use this event, you may need to place a small wait at the beginning... or tone down the number of things using it.
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Sat Nov 17, 2012 4:36 am

the game-engine unequips things for no apparent reason
its because skyrim now uses Outfits instead of inventory. the manequin's outfit by default is None (so the game will always revert to None regardless of inventory). same reason why followers will always wear their default outfits when they are not following you (even if the armor you give them and they still carry in their inventory is superior, and even if you remove their default clothing from their inventory)
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am

Post » Sat Nov 17, 2012 11:48 am

AHA! That makes a lot of sense now. It's still a glitch though.. if it's set to 'none' it shouldn't revert to nudity, but keep whatever is equipped on.

As for outfits in general, I think they should implement a little check box to selectively disable outfits in the CK. An example would be to have the default outfit; but if this box is checked and Player gives items to the actor in-game then the outfit isn't worn (or if User adds items in the CK, which can then be removed/lost.. defaulting back to the outfit). Another option might be if the outfit is worn by default, but then items are added, the outfit equips first then the extra items are subbed in - so at least part of the outfit remains worn. Do you know if any of this can be done through scripting (without polling every item and storing them in variables)? (I haven't messed with outfits at all, except to cloth generic NPCs in my mods.. but they aren't mannequins)

This is yet another example of new aspects to TES that weren't thought through entirely well enough; and/or not geared for modding.
User avatar
jennie xhx
 
Posts: 3429
Joined: Wed Jun 21, 2006 10:28 am

Post » Fri Nov 16, 2012 7:47 pm

glitch or not, i really dislike the hard-wired outfit system. it would be awesome to be able to disable it for actors

the outfit system also makes for even less mod compatibility. if you change any outfits via scripting, it is hardwired into the base NPC_ record for that actor and is permenently embedded in the save game unless you re-script it back to another outfit. if you remove the mod that had the original outfit, the actor will default to and remain naked like the mannequins.

i really cant see any advantage of the outfit system over the "wear whats in your inventory" like before

regarding your example, you can probably script this the same way as a "living mannequin" but using ref aliases with the script attached to the alias and not the actor (and using the same slot array/force-equip oncellattach). the problem i mention above still remains though (unless you keep the default outfit, but in which case the actor wont wear anything you give it unless it is an armor-value upgrade)

i'm using this ref alias system for my guild-recruiting so that i dont have to change the npc's base outfit. the main problem is iterating through inventory and removing the "default" clothing so that it doesnt screw up the slots since the game will re-add these to the inventory every time
User avatar
Katie Louise Ingram
 
Posts: 3437
Joined: Sat Nov 18, 2006 2:10 am

Post » Sat Nov 17, 2012 10:04 am

SuperNast: I just uploaded a test version of the new VanMann Script Fix... https://dl.dropbox.com/u/67168394/MannequinActivatorSCRIPT.pex

I could never replicate the CTD issues; but I found something that may have been causing it. Before the Skyrm update v1.6, we could do a check on an array to see if it is 'none'. We can't do that anymore, it returns the error "error: Cannot cast from None to Form[]". So what I tried was to replace that check with a simple integer variable (which got rid of the errors)... the whole point of that check is to see if the original Vanilla mannequin scripting has been converted to the Script Fix's. Now, that integer is set in the onInit event (which has always converted orig to fix, if the array was 'none'); and in the onCellAttach, the none-check is replaced with a check on that integer.

If the integer is whatever, it runs the onInit again... which would have run when the game first began (then stored in the saveGame data i believe). Rerunning the onInit is needed for people who have mannequins already (added my fix after having played the game a little).. and this may be what causes CTD for some as they seem to think it only happens for existing mannequins.

So lemme know if this works or not... I also posted the link on the Nex comment section - but noone's posted back yet.


Amethyst: SKSE has outfit related functions, but are only for 'getting' the outfit's pieces so far - hopefully in the future we can SET.. which would make outfits worthwhile (even BETTER if we can make CUSTOM outfits, instead of forced to only default and sleep). They're "GetNumParts()" and "GetNthPart(int n)", where the 'part' is a piece of the outfit.

As far as doing mannequin-like behavior... that's what I wanted to avoid, but I guess it'd have to do until SKSE evolves. I was hoping to avoid having an array, then filling slots with objects - which gets pretty slow and buggy if the actor has TONS of objects (unless limited, like the quins are). But using the current SKSE commands above, we should be able to poll the current outfit, create instances of the actual items in that outfit, equip those instances, then equip whatever objects are in inventory (which would replace the outfit's body part-object). I don't really have a use for this just yet, and I avoid using SKSE since it's so early in the development; but if you or someone else tries this - lemme know if it works!

(of course, SKSE may already have the 'set' functions... it's hard to find documentation on it, though I suppose I could just download the newest version and check the sources)
User avatar
WYatt REed
 
Posts: 3409
Joined: Mon Jun 18, 2007 3:06 pm

Post » Sat Nov 17, 2012 2:35 am

@slucky - the arryr loop takes the same amount of time regardless of how many items they have in the inventory.

my array uses 30 slots (so that i can account for the maximum possible equippable items in skyrim, which comes out to like 27 or 28 simultaneous items) - but the actor can have 100 items in their inventory, and the loop will still only cycle through the 30 slots and skipping the ones which are not filled). i think this will only be a problem if you use a mod that lets you have 100 followers. but like i mentioned i am only using this for my guild (maximum of 12 members) so that i can "set" a specific outfit without editing the base NPC_ record.

using a 30-slot array, i have concluded the magic number is 12 max in a single cell, to allow for enough overhead for other running scripts and cellLoad events (it would also be even smoother to run a "dynamite fuse" before running the cellAttach function block for the living actors, so that all of the static mannequins can have priority firing their cellAttach events and not wander)).

for now, i can use a smaller array and only loop through a finite list of given items (player cannot re-outfit the guild members) in order to circumvent the array slot offset caused by the game "giving" duplicates of their default outfit when the inventory items were removed by the script
User avatar
April
 
Posts: 3479
Joined: Tue Jun 20, 2006 1:33 am

Post » Sat Nov 17, 2012 7:21 am

@SLucky

Its really strange. I haven't had one issue with your mod since I did the one tweak, been using it the whole time. But some users report CTDs in very specific cases. Essentially, I have a small home that lets users add rooms with themes. All the themes share the same 4 Mannequins, 2 upstairs in one cell 2 down below in a basemant cell.

Some report that, with your mod installed, any attempt at entering the home before building furniture causes CTD, but if they build it and then enter the CTD ceases.

I also have some users saying they CTD only after building the furniture, but can enter fine before hand.

I have some saying they had no issue until they built the basemant and tried entering it.

And in all cases everyone tells me if they just uninstall your mod temporarily, enter the home and exit, then reinstall, that they are again compatible.

I was wondering if it wasn't due to having enable parents as XMarkers, so I switched to a simple script check to enable/disable. But apparently that wasn't it. I've tried replicating CTDs since then, by trying installing my mod and yours in various combos but haven't been able to cause CTD once, which is what made me believe there was no problem. Thats all the info I have about the CTDs. :blush:

@Amethyst

Thanks again for the help, I made the script extend the base script, and all my mannequins have sat put and not gone commando once, but I'm worried now I may have overdone it a tad with the OnCellAttach() Events, and a tad curious about this duplication o.O;, so if you don't mind I'll be PMing you, sorry ><;
User avatar
Erin S
 
Posts: 3416
Joined: Sat Jul 29, 2006 2:06 pm

Post » Sat Nov 17, 2012 7:59 am

About the dupe bug... I fixed it by changing the OnObjectUnequipped event to an OnItemRemoved event, end of story (though I have a basic integer counter set to count up and down just as a precaution.. I can probably remove it actually). Apparently there's something wrong with the Vanilla unequip event in that it won't fire during specific circumstance... though they may have fixed it in 1.6 - my limited tested suggests that's true.
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Sat Nov 17, 2012 12:28 am

About the dupe bug... I fixed it by changing the OnObjectUnequipped event to an OnItemRemoved event, end of story (though I have a basic integer counter set to count up and down just as a precaution.. I can probably remove it actually). Apparently there's something wrong with the Vanilla unequip event in that it won't fire during specific circumstance... though they may have fixed it in 1.6 - my limited tested suggests that's true.
i saw your script fix, and it works well, but it limits the npc's inventory so that it must match the slot array (which is generally not a problem with mannequins, but may be an minor issue with live actors). the problem the onUnequipped event is related to threading during inventory menu. going back to that earlier discussion regarding the register/update forcing a true real-time event, you can offset any onequipped bugginess by registering for a single update on all menu-based events such as equip, unequip add/remove etc (and running all of the array functions in the update block, guaranteed to run in real time), which fires once the inventory menu has closed (eliminates the possibility of an item not storing in the array, or leaving residue in the array as caused by cached threading during the menu time). this will let you have a pre-defined array size and an infinite inventory amount (no need to count items). the register kills 2 birds with 1 stone (eliminates the dupe glitch and naked glitch simultaneously, no need to reiterate the equip loop multiple times)
User avatar
Lloyd Muldowney
 
Posts: 3497
Joined: Wed May 23, 2007 2:08 pm

Post » Fri Nov 16, 2012 10:41 pm

SuperNast: I figured out what has been causing CTD.. I'll be fixing and uploading the new VanMann Script Fix shortly.
http://www.gamesas.com/topic/1395016-ctd-and-papyrus-errors-after-v16-update/
User avatar
Krista Belle Davis
 
Posts: 3405
Joined: Tue Aug 22, 2006 3:00 am

Post » Sat Nov 17, 2012 5:18 am

Great!

The compatibility was the only concern I had with over the mannequins, so I'll just revert back to the regular ones and let my users know of your update.

Also, thanks Amethyst for the assist as well, appreciate it!
User avatar
Undisclosed Desires
 
Posts: 3388
Joined: Fri Mar 02, 2007 4:10 pm


Return to V - Skyrim