About attaching papyrus scripts to the player (and maybe oth

Post » Mon Jun 18, 2012 10:12 am

Ok, found something which other people might run into some time too...

My mod attaches a script to the player. Now I'm making a new version of the mod (new .esp file) which uses the same script file from the scripts folder, and it somehow stopped working in all saved games where I have used my previous version (even after making a clean save). Now what turns out to be the case?

After disabling the previous version of the mod, that same script is STILL attached to the player, even in a clean save with no version of my mod enabled. I changed the script to include a messagebox, and it even popped up with no version of my mod enabled. Because of this, the new version of the mod was probably unable to attach the script again (because it was already there), but it also stopped working (because the old version of the mod was disabled, and therefore properties are not defined anymore).

So a warning to everyone attaching scripts to objects and keeping the same script throughout different versions of the plugin: IT WILL PROBABLY BREAK. I think it will be fixable by renaming the script and using the renamed script instead of the old one (because then it will have a unique name and be able to be attached again), so I'll try that now.
User avatar
Paul Rice
 
Posts: 3430
Joined: Thu Jun 14, 2007 11:51 am

Post » Mon Jun 18, 2012 7:10 am

Yep, scripts are an oddity, they are independant files, not part of the ESP/plug-in.

There are quite a few posts about this ... Really needs a sticky here and some prominence on the wiki ... it is unexpected behaviour (not a bug) and should be highlighted, or many people are going to mess up their game (and/or end up losing a lot of work they have done)
User avatar
Rob Smith
 
Posts: 3424
Joined: Wed Oct 03, 2007 5:30 pm

Post » Mon Jun 18, 2012 10:46 am

Which is why should set a quest alias for the player and use that instead
User avatar
Lifee Mccaslin
 
Posts: 3369
Joined: Fri Jun 01, 2007 1:03 am

Post » Mon Jun 18, 2012 3:00 pm

Which is why should set a quest alias for the player and use that instead

Ok got quest alias working now.. are you sure that won't get the same problem though? :P
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Mon Jun 18, 2012 12:46 am

Which is why should set a quest alias for the player and use that instead

How does one do that?
User avatar
Janette Segura
 
Posts: 3512
Joined: Wed Aug 22, 2007 12:36 am

Post » Mon Jun 18, 2012 5:01 am

How does one do that?

1: Create a new quest (found in object window under Character --> Quest)
2: Generally for this kind of hidden quest you'll want to set Priority to 99 and tick Start Game Enabled
3: Go to the Quest Aliases tab, rightclick to create a new Reference Alias
4: Give the alias a unique name, under Fill Type tick ''Specific Reference'' and in the long gray box to the right of this checked button click, pick (any) for cell and find the Player reference
5: To the right, in the Scripts box, attach your Papyrus script (which will now need to extend ReferenceAlias instead of Actor, but can still use Actor functions and Events). If your script used ''Self'' somewhere you'll also have to change this into ''GetActorRef()''
6: Click OK. Now on many screens (including mine) the Reference Alias window is too big to fit on the screen entirely and cannot be move or resized in such a way to make the ''OK'' button appear. If you'd just click the top right cross your changes wouldn't get saved so that won't work either. Instead, I found that just clicking in for example the textfield where you can enter the Alias name and then pressing enter saves changes correctly and exits the window :P
User avatar
GPMG
 
Posts: 3507
Joined: Sat Sep 15, 2007 10:55 am

Post » Mon Jun 18, 2012 3:32 pm

Thank you Borgut.
User avatar
Honey Suckle
 
Posts: 3425
Joined: Wed Sep 27, 2006 4:22 pm

Post » Mon Jun 18, 2012 6:49 am

I am not positive if this will still cause problem in OP but please let me know! I'm currently using player alias (I don't know how else to detect when an NPC has hit the player).
User avatar
Naomi Ward
 
Posts: 3450
Joined: Fri Jul 14, 2006 8:37 pm

Post » Mon Jun 18, 2012 1:50 am

I am not positive if this will still cause problem in OP but please let me know! I'm currently using player alias (I don't know how else to detect when an NPC has hit the player).
PaladinRider (or anyone else with an answer), if you wouldn't mind, could you share how you're detecting when an NPC has hit the player? I'm trying to do just that, and having trouble. I have a reference alias set up, pointing to a Specific Reference of PlayerRef, and then a script applied to that alias:

Scriptname ESFAelaPlayerAliasFollowingScript extends ReferenceAlias  Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	Debug.MessageBox("Player Hit Event!")EndEvent

But no messagebox when the player is hit. :banghead:

(I also tried the "Player" entry in the Unique Actor drop-down, but that didn't work either.)


Edit:

Nevermind, it abruptly started working--must have been an old version of the script cached in my savegame, or something like that.
User avatar
Emilie Joseph
 
Posts: 3387
Joined: Thu Mar 15, 2007 6:28 am


Return to V - Skyrim