David Brasher Posted February 19, 2012 Share Posted February 19, 2012 (edited) Okay. So we have this nice little article in the Wiki on SetFactionRank. Link. It gives an example script I want to copy because I want to change the faction of an NPC. SetFactionRank - Actor Member of: Actor Script Sets this actor's rank in the specified faction. Adds the actor to the faction if necessary.Contents [hide] 1 Syntax 2 Parameters 3 Return Value 4 Examples 5 See Also Syntax Function SetFactionRank(Faction akFaction, int aiRank) native Parameters akFaction: The Faction to set this actor's rank in. aiRank: The rank in the faction the actor should be. Return Value None.Examples ; Set the empire faction rank for Luke to 0Luke.SetFactionRank(EmpireFaction, 0) Of course it does not work with my NPC and my Faction. So I grab the first NPC at the top of the list in the CK. I also grab the first faction on the list in the CK. I would think they would be genuine things that the game would recognize. I type in my script: Abelone.SetFactionRank(AlduinFaction, 0) It fails and the program gives me this error message: Starting 1 compile threads for 1 files...Compiling "TIF__01001D9C"...c:\games\skyrim\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01001D9C.psc(9,0): variable Abelone is undefinedc:\games\skyrim\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01001D9C.psc(9,23): variable AlduinFaction is undefinedc:\games\skyrim\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01001D9C.psc(9,8 ): none is not a known user-defined type No output generated for TIF__01001D9C, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on TIF__01001D9C What is going on here? I thought that the information in the wiki was supposed to be accurate. Edited February 19, 2012 by David Brasher Link to comment Share on other sites More sharing options...
MofoMojo Posted February 19, 2012 Share Posted February 19, 2012 (edited) What is going on here? I thought that the information in the wiki was supposed to be accurate. This is something the wiki just doesn't explain on each sample. You have to define the form/function/spells/etc,. properties at the top of the script. In your case, Form Property Abelone Auto Faction Property AlduinFaction AutoOnce that's done. You need to go into the properties of the script and make sure those two properties are associated with the correct NPC/FORM and FACTION. Try the auto fill button on the lower left. As long as your property name matches the same as the editor ID of the item, it should resolve as long as you have the correct TYPE of property defined. Oh, and shameless plug. For better samples, use my Skyrim Script Dumper Indexes and look at Scripts that use AddToFaction and SetFactionRank function. You can find it here. Just download the index unless you want to customize your own search indexes, then grab the utility. Find it under optional files. -MM Edited February 19, 2012 by MofoMojo Link to comment Share on other sites More sharing options...
David Brasher Posted February 19, 2012 Author Share Posted February 19, 2012 This script will not compile and I get an even longer error message: Form Property Abelone Auto Faction Property AlduinFaction Auto Abelone.SetFactionRank(AlduinFaction, 0) Are some of the words in the lines of code that you gave me placeholders that are supposed to be changed according to where they are used? Is this supposed to fail to compile and then you go change the properties, and then the second time around it is supposed to compile? How do you delete a property that you make a mistake on? Link to comment Share on other sites More sharing options...
Cipscis Posted February 19, 2012 Share Posted February 19, 2012 I talk a little more about using properties like this in my EditorIDs in Papyrus tutorial, if you're interested. What is the compiler error you're now seeing? Sometimes solving one problem only allows the compiler to see past it into a problem that gives a longer message, so seeing a longer error message doesn't mean you're not getting your script closer to a state in which it will compile. Cipscis Link to comment Share on other sites More sharing options...
scrivener07 Posted February 19, 2012 Share Posted February 19, 2012 To remove a property delete its declaration from your script. Sounds like you found the properties window but I throw this up anyway Link to comment Share on other sites More sharing options...
MofoMojo Posted February 19, 2012 Share Posted February 19, 2012 This script will not compile and I get an even longer error message: Form Property Abelone Auto Faction Property AlduinFaction Auto Abelone.SetFactionRank(AlduinFaction, 0) Are some of the words in the lines of code that you gave me placeholders that are supposed to be changed according to where they are used? Is this supposed to fail to compile and then you go change the properties, and then the second time around it is supposed to compile? How do you delete a property that you make a mistake on? Here's a sample script in its entirety: Scriptname SvenScript extends ReferenceAlias Faction Property BardSingerFaction Auto Event OnLocationChange(Location ExitLocation, Location EnterLocation) If EnterLocation == SleepingGiantInn GetActorRef().SetFactionRank(BardSingerFaction, 1) Else GetActorRef().SetFactionRank(BardSingerFaction, -1) EndIf EndEvent Location Property SleepingGiantInn Auto To remove a property you can quite literally just delete the line from the script. Alternatively you can delete it from the properties of the script as well. Note: If you leave any references to the property in the script, it'll error out on compile. In this case you can see that there are two properties being used. A Faction property, BardSingerFaction and a Location property, SleepingGiantInn. Your script needs to have function declarations or event declarations. I would also recommend looking at the script tutorials previously posted. -MM Link to comment Share on other sites More sharing options...
David Brasher Posted February 19, 2012 Author Share Posted February 19, 2012 (edited) I have been reading tutorials previously posted and I can't comprehend them at all. They make very great assumptions about what the user already knows. The wiki tutorials are written by professional programmers, but in truth, most modders are just hobbyists who don't have anywhere near as much background as the professional programmers who think that their tutorials are comprehensible. I keep on reading tutorials, performing experiments in the CK, trying to reverse engineer things, and asking questions on the forums. (Nothing really brings much progress.) Scriptname SvenScript extends ReferenceAlias Faction Property BardSingerFaction Auto Event OnLocationChange(Location ExitLocation, Location EnterLocation) If EnterLocation == SleepingGiantInn GetActorRef().SetFactionRank(BardSingerFaction, 1) Else GetActorRef().SetFactionRank(BardSingerFaction, -1) EndIf EndEvent Location Property SleepingGiantInn Auto This script looks bigger than the average Papyrus fragment. I am trying to build a Papyrus fragment that does the job of an Oblivion result script placed on a dialog info. I want to talk to the NPC and say "Wait" or "Follow" or some other command and have the Papyrus fragment change their faction so that the condition on their AI packages will make them use a different behavior. Am I really allowed to put something as big as your bard script into a Papyrus fragment? Edited February 19, 2012 by David Brasher Link to comment Share on other sites More sharing options...
MofoMojo Posted February 19, 2012 Share Posted February 19, 2012 Am I really allowed to put something as big as your bard script into a Papyrus fragment? In truth, I haven't worked with Papyrus Fragments at all yet, but once I get into some quest dialog, etc,. I may very well, but for now I cannot answer that. Hopefully someone can. -MM Link to comment Share on other sites More sharing options...
Mansh00ter Posted February 19, 2012 Share Posted February 19, 2012 (edited) Am I really allowed to put something as big as your bard script into a Papyrus fragment? This is a Papyrus fragment script I use for a number of objects in my Basic Needs mod: Scriptname TRO_bnFoodStaleScript extends activemagiceffect GlobalVariable Property TRO_Hunger Auto Idle Property pukeIdle Auto Idle Property IdleStop Auto Message Property staleFoodMessage Auto Message Property weaponDrawnMessage Auto float ccalPerc = 0.0 float cHunger = 0.0 Event OnEffectStart(Actor target, Actor caster) cHunger = TRO_Hunger.getValue() ;get global hunger value ;calculate hunger restore perc if (!Game.getPlayer().IsWeaponDrawn()) if (cHunger>=0 && cHunger<=1.23) ;stuffed ccalPerc = 0.8; elseIf (cHunger>=1.24 && cHunger<=6.75) ;not hungry ccalPerc = 0.8 elseIf (cHunger>=6.76 && cHunger<=9.61) ;peckish ccalPerc = 0.4 elseIf (cHunger>=9.62 && cHunger<=42.73) ;hungry ccalPerc = 0.2 elseIf (cHunger>=42.74 && cHunger<=90.0) ;starving ccalPerc = 0.1 elseIf (cHunger>=90.01 && cHunger<=100.00) ;dying from starvation ccalPerc = 0.1 endIf else ccalPerc = 0.05 endIf cHunger -=(ccalPerc * cHunger) if cHunger<0 cHunger = 0 endIf if (!Game.getPlayer().IsWeaponDrawn()) ;10% chance eating this will make the player sick and puke if (Utility.randomInt(0,100)>=90) ;set cHunger to hungry state cHunger = TRO_Hunger.getValue() if (cHunger<10.0) cHunger = 10.0 endIf ;if player is not already playing an idle, play it game.getPlayer().playIdle(pukeIdle) staleFoodMessage.show() Utility.wait(7) Game.getPlayer().playIdle(IdleStop) endIf else weaponDrawnMessage.show() if (Utility.randomInt(0,100)>90) staleFoodMessage.show() cHunger = TRO_Hunger.getValue() if (cHunger<10.0) cHunger = 10.0 endIf Game.disablePlayerControls(true, true, false, false, false, false, false) Game.getPlayer().playIdle(pukeIdle) Utility.wait(7) Game.getPlayer().playIdle(IdleStop) Game.enablePlayerControls() endIf endIf ;set global TRO_Hunger.setValue(cHunger) endEvent As you can see, it is even bigger. It works fine. In fact, it doesn't matter how big the script is, it matters what it does. You could have a very short script which could take up a lot of processing power, or a really long one which would have a negligible load. As long as you program it properly, meaning it doesn't end up doing anything it isn't supposed to do, you should be just fine. Also, you cannot delete properties directly in the properties panel. It won't let you. You have to delete them in code. Edited February 19, 2012 by Mansh00ter Link to comment Share on other sites More sharing options...
tunaisafish Posted February 20, 2012 Share Posted February 20, 2012 @David, I've no idea how to delete those Properties in the CK UI once you Add them :/ (on Quest Stage Fragments)That may be a job that can be done in one of the user-created tools. It does seem to be an oversight in the CK. I think there's some misunderstandings in the thread that you are talking about Fragments (in this case Topic Info Fragments. So no you don't need the scriptname, Properties, or OnEvent sections in the script body.I'm not familiar with the Topic Info fragments, but I've just tried to do what you are trying and understand your frustration. The UI seems broken... or it's just very limited in what you can do. I worked around that by declaring the Faction in a script attached to the main quest. ScriptName YourQuestMainScriptName extends Quest Faction Property FactionPropertyName Auto Then in your Fragment... Faction foo foo = (GetOwningQuest() as YourQuestMainScriptName).FactionPropertyName akSpeaker.SetFactionRank(foo, 0) That will now compile OK, but I didn't test it ingame. I'm not sure if that is the right actor you wanted (the magic akSpeaker object variable), but the wiki page linked above shows you how to get the other actor of the dialog. Hope that helps. Link to comment Share on other sites More sharing options...
Recommended Posts