Muazen Posted March 20, 2012 Share Posted March 20, 2012 (edited) Hi, Forgive my dumb question, but I wanted to give this Papyrus script a try. Unfortunately I'm failing at my first baby step: I want to fire up my script on specific player events. Its always frustrating to start on a new thing but if I could get this working I could try to learn something through trial and error. Preferably I'd like to have a script run when the player gains a skill level. So how do I do that? Do I find the ID: Player, Name: Prisoner object and add a script to it directly? If yes, do I write it a property to fire up skill level ups, and how would that happen? Sorry, this is probably stupid easy, but all the tutorials seem to be about dropping pots into maps and at best firing script on looting and npc death. How about a sample code that just calls Debug.MessageBox on player gaining a skill or something like that? Edited March 20, 2012 by Muazen Link to comment Share on other sites More sharing options...
fg109 Posted March 20, 2012 Share Posted March 20, 2012 (edited) This is a script for a magic effect of an ability on the player: Scriptname fg109TestME02 extends ActiveMagicEffect Event OnEffectStart(Actor akTarget, Actor akCaster) RegisterForTrackedStatsEvent() EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) UnregisterForTrackedStatsEvent() EndEvent Event OnTrackedStatsEvent(string asStat, int aiStatValue) if (asStat == "Skill Increases") Debug.MessageBox(asStat + ": " + aiStatValue) endif EndEvent Edited March 20, 2012 by fg109 Link to comment Share on other sites More sharing options...
Muazen Posted March 20, 2012 Author Share Posted March 20, 2012 Thanks! Err, a magic effect... right... wouldn't have figured that one out. Link to comment Share on other sites More sharing options...
fg109 Posted March 20, 2012 Share Posted March 20, 2012 I just used a magic effect because I prefer it. Lots of people use magic effects or reference aliases to attach scripts to the player. Of course, you can also attach a script to the player directly. I feel like it might lead to save game corruption or something if you later remove the mod though. But that's just a feeling, I don't know whether it will or not. Bottom line, I use magic effects because that's what everybody else does. Link to comment Share on other sites More sharing options...
Muazen Posted March 20, 2012 Author Share Posted March 20, 2012 So... Back to my original question... I take it that I don't just put it in Player / Scripts?Cause that's just about only thing I can think of and it does less than goggles in this situation. :( Link to comment Share on other sites More sharing options...
fg109 Posted March 21, 2012 Share Posted March 21, 2012 Well... you could create a start game enabled quest, add a quest script to it, add a spell property to the script, then script it to add the spell to the player in the OnInit() block. Link to comment Share on other sites More sharing options...
elseagoat Posted March 21, 2012 Share Posted March 21, 2012 Well... you could create a start game enabled quest, add a quest script to it, add a spell property to the script, then script it to add the spell to the player in the OnInit() block. This sounds interesting. Wonderful idea I will have to use that. Link to comment Share on other sites More sharing options...
fg109 Posted March 21, 2012 Share Posted March 21, 2012 Just a warning though, the OnInit() block runs twice in a row. So it's fine with spells (you can't have more than a single copy of a spell) but you end up with double the items unless you add a check to see if you already have the items. It runs twice in a row because it runs once when the quest is started, and once when it is reset, but starting a quest causes it to reset (which also resets all the variables)... Link to comment Share on other sites More sharing options...
elseagoat Posted March 21, 2012 Share Posted March 21, 2012 Just a warning though, the OnInit() block runs twice in a row. So it's fine with spells (you can't have more than a single copy of a spell) but you end up with double the items unless you add a check to see if you already have the items. It runs twice in a row because it runs once when the quest is started, and once when it is reset, but starting a quest causes it to reset (which also resets all the variables)... Interesting. I would probably only use this for spells and perks and stuff, to apply scaling scripts, so I don't see it being a problem. I don't even plan on messing with making quests, homes, or dungeons or anything I am more interested in gameplay mechanics. Link to comment Share on other sites More sharing options...
Muazen Posted March 21, 2012 Author Share Posted March 21, 2012 Thanks again, this seems perfectly fine for what I was plotting. Link to comment Share on other sites More sharing options...
Recommended Posts