Need some Scripting Help! Simple Script, I think?

Post » Wed Jun 20, 2012 7:18 pm

I would like to make a simple script to do some specific actions, if anyone can help me it'd be extremely appreciated!

I got the idea original from: http://www.gamesas.com/user/140486-herko-ter-horst/'s follower mod. Thanks so much for the idea!

I want to put this script on various NPCs in the game, namely non-respawning npcs.

When the player enters a cell, and NPC(s), with this script attached to them are present and are loaded/loading, an iron dagger will be added and then removed from their inventory.
The purpose of this being to force them to re-evaluate their inventory/outfits and equip their best gear. I don't know if it will work for non-follower NPCs though, but I want to try anyway.

Can anyone help me write the script? I'd be really appreciative!
User avatar
Amy Melissa
 
Posts: 3390
Joined: Fri Jun 23, 2006 2:35 pm

Post » Wed Jun 20, 2012 8:41 pm

This should work, but I haven't tried it.

Scriptname ExampleScript extends ActorWeapon Property IronDagger AutoEvent OnCellAttach()    AddItem(IronDagger, 1)    RemoveItem(IronDagger, 1)EndEvent
User avatar
Mackenzie
 
Posts: 3404
Joined: Tue Jan 23, 2007 9:18 pm

Post » Wed Jun 20, 2012 8:39 pm

This should work, but I haven't tried it.

Scriptname ExampleScript extends ActorWeapon Property IronDagger AutoEvent OnCellAttach()	AddItem(IronDagger, 1)	RemoveItem(IronDagger, 1)EndEvent


Thanks! I'll test it today!
User avatar
Lady Shocka
 
Posts: 3452
Joined: Mon Aug 21, 2006 10:59 pm

Post » Thu Jun 21, 2012 3:33 am

I did already that (with a coin instead) and it didn't work with nonfollowing NPCs being companions or not. They need to be set as playerteammate. Besides, there is no need to put a script on an NPC to add an object to it's inventory and adding scripts to various vanilla NPCs is a very bad idea (scripts will persist even after the uninstalment of your mod).
User avatar
Brandon Wilson
 
Posts: 3487
Joined: Sat Oct 13, 2007 1:31 am

Post » Wed Jun 20, 2012 8:12 pm

I did already that (with a coin instead) and it didn't work with nonfollowing NPCs being companions or not. They need to be set as playerteammate. Besides, there is no need to put a script on an NPC to add an object to it's inventory and adding scripts to various vanilla NPCs is a very bad idea (scripts will persist even after the uninstalment of your mod).

Why though? I tested it just now, and it worked fine. It didn't work for their outfit though.

Also, why would a script persist after the mod is uninstalled? If they remove the script, it wouldn't make any sense why it would keep existing after the script is gone...would it?
User avatar
TIhIsmc L Griot
 
Posts: 3405
Joined: Fri Aug 03, 2007 6:59 pm

Post » Wed Jun 20, 2012 4:03 pm

Why though? I tested it just now, and it worked fine. It didn't work for their outfit though.

Also, why would a script persist after the mod is uninstalled? If they remove the script, it wouldn't make any sense why it would keep existing after the script is gone...would it?
I only tested this system for changing clothes and didn't work for that purpose for non following NPCs, as in your case. You could set them as playerteammate, give the dagger and set them to their original state though (but you would need to check if they were originaly set as followerteammate, in order to ensure that you didn't put follower out of that state).

When you save your game, scripts are saved in your saved game. Even removing the script from the scripts folder won't eliminate them from your save. The functions will continue running untill their process is complete. Obviously in the case of neverending functions that won't happen.
User avatar
Solina971
 
Posts: 3421
Joined: Thu Mar 29, 2007 6:40 am

Post » Wed Jun 20, 2012 1:46 pm

I only tested this system for changing clothes and didn't work for that purpose for non following NPCs, as in your case. You could set them as playerteammate, give the dagger and set them to their original state though (but you would need to check if they were originaly set as followerteammate, in order to ensure that you didn't put follower out of that state).

When you save your game, scripts are saved in your saved game. Even removing the script from the scripts folder won't eliminate them from your save. The functions will continue running untill their process is complete. Obviously in the case of neverending functions that won't happen.

So how would I set up the script to not stay baked in the save game?
User avatar
Melis Hristina
 
Posts: 3509
Joined: Sat Jun 17, 2006 10:36 pm

Post » Wed Jun 20, 2012 9:34 pm

Even removing the script from the scripts folder won't eliminate them from your save. The functions will continue running untill their process is complete. Obviously in the case of neverending functions that won't happen.

A solution to that problem is adding a quest to the plugin and as a condition to all your scripts that this quest needs to be on a certain quest stage. Then add an easy way for the player to change this quest stage, and add to the Readme and description of your mod that they need to change the quest stage if they want to uninstall the mod. That way the scripts may still exist, but at least they stop executing the contents of Events. Or perhaps even better, make such a script put itself in another State if it detects the uninstall-quest-stage has been reached.

There may be better tricks, this is the first time I'm considering the problem... Perhaps even the existence of an item that is part of your mod can be used as the condition. Disabling the mod will make the item disappear, and hence the scripts turn themselves off... Or something like that. I'm rambling.
User avatar
Jerry Cox
 
Posts: 3409
Joined: Wed Oct 10, 2007 1:21 pm

Post » Wed Jun 20, 2012 1:49 pm

A solution to that problem is adding a quest to the plugin and as a condition to all your scripts that this quest needs to be on a certain quest stage. Then add an easy way for the player to change this quest stage, and add to the Readme and description of your mod that they need to change the quest stage if they want to uninstall the mod. That way the scripts may still exist, but at least they stop executing the contents of Events. Or perhaps even better, make such a script put itself in another State if it detects the uninstall-quest-stage has been reached.

There may be better tricks, this is the first time I'm considering the problem... Perhaps even the existence of an item that is part of your mod can be used as the condition. Disabling the mod will make the item disappear, and hence the scripts turn themselves off... Or something like that. I'm rambling.

No this is good. I'm a total newbie at Papyrus and even messing with quests so any help or ideas are very appreciated.

If you have more information, please please share. I'm kind of helpless at the moment.
User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm

Post » Wed Jun 20, 2012 1:29 pm

Alright can anyone give me a kind tutorial on how I might make my script dependent on a quest stage in order to run (so it doesnt keep running in people's savegames?) :smile:. I'd really appreciate any help on that because I"m totally clueless >_<

Edit: Also, does anyone know any way to have the game "reinitialze" the NPC outfit after I change it in my plugin?

For example, if I change an NPC's outfit from a Steel Armor Outfit, to a Farmer Outfit in my plugin, the NPC will be naked in game. How do I make the NPC notice that he no longer needs to use the Steel Armor Outfit, and to equip the Farmer Outfit instead?
User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Wed Jun 20, 2012 12:34 pm

Well pretty simple. At the first thing in your events (all of them) before anything else runs, wrap your whole event script in an if-statment, that checks for GetQuestStatge (or whatever it's called, don't remember the exact command) and have it check for say... quest stage 10 on your "UNINSTALL" quest.

By default, this quest you make (that would do nothing except have two different stages) would be on 10 (for example), so normally the script would just continue on as normal. But if you (in another script, or forced via a console command the player puts in) changes this quest to say.. quest stage 0 or 1 (that would be the 2nd stage in the uninstall quest), then any script event that has this GetQuestStage if-statmentwould fail, and thus not run the script anymore.
User avatar
sarah taylor
 
Posts: 3490
Joined: Thu Nov 16, 2006 3:36 pm

Post » Wed Jun 20, 2012 8:12 pm

Anyone know how to script an update to an NPC's current outfit?

Well pretty simple. At the first thing in your events (all of them) before anything else runs, wrap your whole event script in an if-statment, that checks for GetQuestStatge (or whatever it's called, don't remember the exact command) and have it check for say... quest stage 10 on your "UNINSTALL" quest.

By default, this quest you make (that would do nothing except have two different stages) would be on 10 (for example), so normally the script would just continue on as normal. But if you (in another script, or forced via a console command the player puts in) changes this quest to say.. quest stage 0 or 1 (that would be the 2nd stage in the uninstall quest), then any script event that has this GetQuestStage if-statmentwould fail, and thus not run the script anymore.

THanks! I'll try it!
User avatar
Celestine Stardust
 
Posts: 3390
Joined: Fri Dec 01, 2006 11:22 pm


Return to V - Skyrim