Add item to a leveled list via a script

Post » Mon Jun 18, 2012 11:26 am

I could've sworn I posted this topic this morning, but it's not under "My Content" anymore and I can't find it... and I didn't even say any naughty words...

Anyway, question.

I created a new spell.
I created a spell tome that teaches it.
Now I want the spell merchants to sell it.

I could jam it directly into an appropriate leveled list (i.e. LItemSpellTomes25AllAlteration), but then it would create conflicts with other mods that alter the same list. In Oblivion, you could either create a secondary merchant chest, or add an item to a leveled list via a script (I think OBSE had that functionality? Can't remember).

Is there a clean way to add an item to a leveled list in Skyrim so as to minimize conflict potential?
User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Tue Jun 19, 2012 1:06 am

perhaps with http://www.creationkit.com/AddForm_-_FormList ?

Function AddForm(Form apForm)
GemList.AddForm(Diamond)

I would be interested to know if it works out.
User avatar
Becky Palmer
 
Posts: 3387
Joined: Wed Oct 04, 2006 4:43 am

Post » Mon Jun 18, 2012 12:22 pm

well i had that working before the CK came out with a console script (bat scriptname)

AddformToLeveledList listID itemID level amount

but the syntax in payprus seems very very weird... i dont get it yet XD
User avatar
Bek Rideout
 
Posts: 3401
Joined: Fri Mar 02, 2007 7:00 pm

Post » Mon Jun 18, 2012 12:08 pm

OK, great. I'll give it a try. Papyrus makes my head hurt. I'm an administrator, not a programmer... hate programming in fact...
User avatar
Anthony Diaz
 
Posts: 3474
Joined: Thu Aug 09, 2007 11:24 pm

Post » Mon Jun 18, 2012 11:44 am

well im a modeller not a scripter so i feel with you XD

anyway the link above is false i think
you need that one:
http://www.creationkit.com/AddForm_-_LeveledItem

however i didnt get it to work either so far...

Scriptname JSwordsDistributionQuestScript extends Quest
{distributes swords in skyrim}
LItemBanditSword.AddForm(Jalbsword, 1, 1)

thats how mine looks and i get an error:
Compiling "JSwordsDistributionQuestScript"...
G:\Skyrim\Data\Scripts\Source\temp\JSwordsDistributionQuestScript.psc(3,16): no viable alternative at input '.'
No output generated for JSwordsDistributionQuestScript, compilation failed.

i guess you have to link that script to the "http://www.creationkit.com/LeveledItem_Script" somehow so it can make use of its functions but dont ask me how lol
User avatar
Trevi
 
Posts: 3404
Joined: Fri Apr 06, 2007 8:26 pm

Post » Mon Jun 18, 2012 5:25 pm

this here compiles, not sure if it works tho

Scriptname JSwordsDistributionQuestScript extends quest
{distributes swords in skyrim}

leveleditem property litembanditsword auto
weapon property Jalbsword auto
event OnBeginState()
LItemBanditSword.AddForm (Jalbsword, 5, 2)
endevent

well dunno if is has been an advancement at all but papyrus is weird... for one can you not simply use formids anymore, you have to declare each and everyone by that property line, then you need to start your function block like you did with somin like "begin gamemode" in the past, however there is nothing anymore like gamemode, im not sure what onbeginstate does or when it kicks in... i just want the script to run as soon as the mod gets loaded XD

but i think thats about how it works...
gotta test it i think lol...
User avatar
Miss K
 
Posts: 3458
Joined: Sat Jan 20, 2007 2:33 pm

Post » Mon Jun 18, 2012 9:05 pm

Function http://www.creationkit.com/AddForm_-_LeveledItem(Form apForm, int auiLevel, int auiCount)
  • Adds the given count of given form to the leveled list under the given level.
-> apForm is the object (base object I think) you want to add to the list

Define a property in the script:

LeveledItem Property aLeveledList Auto
OR...
LeveledItem Property Auto
OR...
Form Property Auto

After adding the script, (click Properties) you select the list you want aLeveledList to point to, using the actual name of the LeveledList should enable "Auto fill" to automatically select the proper list.

Now you can use aLeveledList.AddForm()
If you used then you do .AddForm()
If you used "Form Property..." then you do ( as LeveledItem).AddForm()

The trick is to link the target List by defining a Property in the script. The Property is a pointer to the object. "Auto fill" or manually selecting an object initializes that Property with a proper pointer.

NOTES: I've had trouble with the scripts not accepting all Property Types. You can usually use "Form Property Auto" and it will auto-fill properly.

In all of the above: replace with something meaningful without the brackets.
User avatar
Michelle davies
 
Posts: 3509
Joined: Wed Sep 27, 2006 3:59 am

Post » Mon Jun 18, 2012 8:41 pm

i honestly dont see the advancement in having to select the item 3 times instead of just telling the script the formid... but whatever lol...
did anyone find a way to have that script run on game start yet? im using it in combination with a quest but i didnt find the right event setup yet that auto starts the quest :/

i guess
event oninit
might work somehow

edit:
nvm, oninit works like a charm :)
you just gotta autofill the properties like zBog mentioned, only writing them donw in the script doesnt help... still gotta do that tho XD (gosh is that annoying)

so if you click on the properties and autofill them the followng script works:

Scriptname JSwordsDistributionQuestScript extends quest
{distributes swords in skyrim}

miscobject property gold001 auto
actor property playerRef auto
leveleditem property litembanditsword auto
weapon property Jalbsword auto

event OnInit()
LItemBanditSword.AddForm (Jalbsword, 5, 2) ;; adds 2 albswords to the lvli litembanditsword at level 5
playerRef.additem (Gold001, 100) ;; just to see if it kicks in, you get the gold and it works, you dont and it doesnt work...
endevent
User avatar
Haley Cooper
 
Posts: 3490
Joined: Wed Jun 14, 2006 11:30 am

Post » Mon Jun 18, 2012 5:18 pm

i honestly dont see the advancement in having to select the item 3 times instead of just telling the script the formid... but whatever lol...
We have to do this now because scripts are no an internal part of data files. Instead, they and the compiler are entirely separate, and the compiler doesn't look inside any data files (even if you run it from the Creation Kit), so it can't recognise editorIDs.

The advantage comes when you want to make a script that defines behaviour that can be reusable by a different set of forms. For example, the script for the transmute spell is set up in such a way that it could be used for a different spell to transmute a different set of items into one another.

Cipscis
User avatar
Smokey
 
Posts: 3378
Joined: Mon May 07, 2007 11:35 pm

Post » Mon Jun 18, 2012 8:13 pm

btw @Cipscis
is there a way to add a bunch of properties at once?
dragn dropping objects into that window doesnt seem to work... gotta add like 50 of those and dont wanna have to make up each individually -.-

could use a lvl list maybe instead of 50 individual objects but thats not really what i need... i need em individually more or less
User avatar
Samantha Mitchell
 
Posts: 3459
Joined: Mon Nov 13, 2006 8:33 pm

Post » Mon Jun 18, 2012 6:13 pm

Type one out and copypasta*50, then fill in the duplicate property names with the EditorIDs of the forms. So long as the property names match the EditorIDs, "Autofill all" should point the whole lot of 'em to the correct forms with one click. Properties don't need to be added with the CK, but the record(s) the scripts are glued to do need to have the properties pointed (filled) so the plugin knows what to do with the script.
User avatar
Tha King o Geekz
 
Posts: 3556
Joined: Mon May 07, 2007 9:14 pm

Post » Mon Jun 18, 2012 10:12 am

darn... just what i feared :D
btw youre blinking red lol...
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am

Post » Mon Jun 18, 2012 12:50 pm

Christ on a bike. Talk about overcomplexity. I shudder at the thought of scripting something that's actually complex.

This is all very cool though, I'll see if I can get it to work for my case.
User avatar
Bird
 
Posts: 3492
Joined: Fri Nov 30, 2007 12:45 am

Post » Mon Jun 18, 2012 4:27 pm

well it seems to be working but distributing my 50+ swords that way is bloody ridiculous... my script is yet as long as my old FO3 ones that did the same trick and im still defining properties -.-
for the last 2 hours...
User avatar
Ashley Clifft
 
Posts: 3468
Joined: Thu Jul 26, 2007 5:56 am

Post » Tue Jun 19, 2012 12:50 am

Christ on a bike. Talk about overcomplexity. I shudder at the thought of scripting something that's actually complex.

This is all very cool though, I'll see if I can get it to work for my case.

Well the supposid advantage of such a scripting system is that it makes it so complex stuff is not only possible but flexible, as well as being easier to design. It does have the disadvantage of making simple tasks fairly complicated though. Reminds me how in the Crysis editor, if you simply wanted a guy to enter a jeep and drive somewhere it required a fiarly complex script for the task (though scripting in Crysis is super easy as it's all visual and you just plug+play nodes, instead of having to type everything out and follow a syntax)
User avatar
Ladymorphine
 
Posts: 3441
Joined: Wed Nov 08, 2006 2:22 pm

Post » Mon Jun 18, 2012 3:42 pm

You could use an array property for your swords, and then loop through that array - but that only works if you want to put them in the same leveled list.

Alternately, you could use two arrays, with the same number of elements in each - array 1 is filled with the base objects to add, array 2 is the leveled list to put each item in array 1 into.

Then a simple while loop could do the adding.

weapon[] Property Array1 auto

leveledItem[] Property Array2 auto

int arrayIndex = 0
while arrayIndex < Array1.Length
Array2[arrayIndex].AddForm(Array1[arrayIndex])
arrayIndex = arrayIndex + 1
endWhile

(more or less)
User avatar
Jose ordaz
 
Posts: 3552
Joined: Mon Aug 27, 2007 10:14 pm

Post » Mon Jun 18, 2012 8:07 pm

Nice this, been looking for this info. Now a question in FNV there were 2 diff script commands one for items and one for creatures (actors) does this AddForm cover both items and actors addint to a list or is there a separate command, have been looking at the wiki but have yet to find what hunting there ... would be nice to add new actor/creatures to existing LVLN this way vice the bad way of mod'n existing lists. Any info would be appreciated and thanx for this discussion.

nvm .. found it was looking for actor and they left it as creature .. my bad, thought would change to conform to new naming, oh well now to see if can get it to work .... AddCreatureToLeveledList
User avatar
Nina Mccormick
 
Posts: 3507
Joined: Mon Sep 18, 2006 5:38 pm

Post » Mon Jun 18, 2012 8:19 pm

mmh not sure but there seem to be some problems with quest scripts or at least i didnt find explanations for the behavior:

-quest only starts autmaticly if "start game enabled" is checked --- good

===================================

-quest script starts even without the quest running as long as no
if (JSwordsDistributionQuest.IsRunning())
has been called before its functions --- weird!

===================================

-quest scripts run more than once even if they can only run once O.o
explanation:
my script functions have the condition:
if (JSwordsDistributionQuest.IsRunning())
and the last function is
Debug.MessageBox("JaySuS Swords have succsesfully been distributed in Skyrim")

JSwordsDistributionQuest.CompleteQuest()
endif
endEvent
hence it should only be able to run once since the quest that has to run as a condition gets shut down at the end, yet i get the message box twice! ----- O.o

====================================

full current script (that basicly works but results in CTDs on loading another save or going back to main menu and i assume thats due to the fact that the messagebox appears twice and hence the script prolly spams itself to death or somin):
Scriptname JSwordsDistributionQuestScript extends quest
{distributes swords in skyrim}

quest property JSwordsDistributionQuest auto ;; the token quest that gets everything running

leveleditem property JSwordsAlbswordLVLI auto ;; my lvl lists full of swords
leveleditem property JSwordsBandits1HAxeLVLI auto
leveleditem property JSwordsBandits1HSwordLVLI auto
leveleditem property JSwordsBandits2HAxeLVLI auto
leveleditem property JSwordsBandits2HSwordLVLI auto
leveleditem property JSwordsBanditsDaggerLVLI auto
leveleditem property JSwordsDibellaLVLI auto
leveleditem property JSwordsDragonbrandLVLI auto
leveleditem property JSwordsDragonstingLVLI auto
leveleditem property JSwordsFencing1HSwordLVLI auto
leveleditem property JSwordsGouJiAnLVLI auto
leveleditem property JSwordsImperial1HSwordLVLI auto
leveleditem property JSwordsJianLVLI auto
leveleditem property JSwordsKhajit1HSwordLVLI auto
leveleditem property JSwordsKnight1HSwordLVLI auto
leveleditem property JSwordsKnight2HSwordLVLI auto
leveleditem property JSwordsMeansowrdLVLI auto
leveleditem property JSwordsStormcloak1HAxeLVLI auto
leveleditem property JSwordsStormcloak2HAxeLVLI auto
leveleditem property JSwordsStormcloak1HSwordLVLI auto
leveleditem property JSwordsStormcloak2HSwordLVLI auto
leveleditem property JSwordsGungnirLVLI auto

leveleditem property LItemThalmorWeapon1H auto ;; lvl lists i want my swords to add to
leveleditem property CWSoldierImperialGear auto
leveleditem property CWSoldierImperialGearNoTorch auto
leveleditem property LItemBanditSword auto
leveleditem property LItemBanditWarAxe auto
leveleditem property LItemBanditBattleaxe auto
leveleditem property LItemBanditGreatsword auto
leveleditem property LItemWarlockDagger auto
leveleditem property LItemWeaponDaggerTown auto
leveleditem property LItemWeaponDagger auto
leveleditem property LItemWeaponDaggerForsworn auto
leveleditem property LItemWeaponSword auto
leveleditem property LItemWeaponGreatSword auto
leveleditem property LItemSoldierSonsSword auto
leveleditem property LItemSoldierSonsWaraxe auto
leveleditem property LItemSoldierSonsBattleaxe auto
leveleditem property LItemSoldierSonsGreatsword auto
leveleditem property DeathItemDragonPriest auto

actor property Risaad auto ;; those race specific actors could probably be combined in a form list or somin tho im not sure if addform can put items in actors inside a form list atm
actor property Madran auto
actor property Ahkari auto
actor property Atahba auto
actor property Marandrujo auto
actor property Majhad auto
actor property Zaynabi auto
actor property Khayla auto
actor property Razhinda auto
actor property Dromarash auto
actor property Grushnag auto

event OnInit() ;;script get initialized and the following happens
if (JSwordsDistributionQuest.IsRunning()) ;;in case the quest runs do the following

LItemThalmorWeapon1H.AddForm (JSwordsAlbswordLVLI, 25, 1) ;; not sure if this works, adds 1 albswordLVLI at lvl 25 to a ThalmoorLVLI, what if player is not at lvl 25? or does it add it anyway but only makes it available at lvl 25 like in the lvl list window?
CWSoldierImperialGear.AddForm (JSwordsImperial1HSwordLVLI, 1, 1) ;; works like a charm, items get added
CWSoldierImperialGearNoTorch.AddForm (JSwordsImperial1HSwordLVLI, 1, 1)
LItemBanditSword.AddForm (JSwordsBandits1HSwordLVLI, 1, 5)
LItemBanditWarAxe.AddForm (JSwordsBandits2HAxeLVLI, 1, 5)
LItemBanditBattleaxe.AddForm (JSwordsBandits2HAxeLVLI, 1, 5)
LItemBanditGreatsword.AddForm (JSwordsBandits2HSwordLVLI, 1, 5)
LItemWarlockDagger.AddForm (JSwordsBanditsDaggerLVLI, 1, 5)
LItemWeaponDaggerTown.AddForm (JSwordsBanditsDaggerLVLI, 1, 5)
LItemWeaponDagger.AddForm (JSwordsBanditsDaggerLVLI, 1, 5)
LItemWeaponSword.AddForm (JSwordsBandits1HSwordLVLI, 1, 5)
LItemWeaponGreatSword.AddForm (JSwordsBandits2HSwordLVLI, 1, 5)
LItemSoldierSonsSword.AddForm (JSwordsStormcloak1HSwordLVLI, 1, 5)
LItemSoldierSonsWaraxe.AddForm (JSwordsStormcloak1HAxeLVLI, 1, 5)
LItemSoldierSonsBattleaxe.AddForm (JSwordsStormcloak2HAxeLVLI, 1, 5)
LItemSoldierSonsGreatsword.AddForm (JSwordsStormcloak2HSwordLVLI, 1, 5)
DeathItemDragonPriest.AddForm (JSwordsDragonstingLVLI, 1, 1)

Risaad.additem (JSwordsKhajit1HSwordLVLI, 1, 1) ;;didnt check it yet but should work, not sure what happens if they respawn tho, i guess as long as the current save is a derivate of one that had this script run on it the item should get burned into the inventory of that actor, could be that it only works with lvl lists tho which would kinda svck as khajit caravan dudes dont have one
Madran.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Ahkari.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Atahba.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Marandrujo.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Majhad.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Zaynabi.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Khayla.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Razhinda.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Dromarash.additem (JSwordsKhajit1HSwordLVLI, 1, 1)
Grushnag.additem (JSwordsKhajit1HSwordLVLI, 1, 1)

Debug.MessageBox("JaySuS Swords have succsesfully been distributed in Skyrim")

JSwordsDistributionQuest.CompleteQuest()

endif
endEvent


way to go.... :D
gosh i want my vertices and polygons back... damn properties and functions and whatnot lol, dont you have trainees or somin for that, or a guy in the basemant? (kidding, utmost respect of coding folk ^_^)
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Mon Jun 18, 2012 1:58 pm

reduced the script on bug hunt...

the quest only has an ID and "start game enabled checked" aswell as the script attached with all properties autofilled

Scriptname JSwordsDistributionQuestScript extends quest
{distributes swords in skyrim}

quest property JSwordsDistributionQuest auto

event OnInit()
if (JSwordsDistributionQuest.IsRunning())

Debug.MessageBox("JaySuS Swords have succsesfully been distributed in Skyrim")

JSwordsDistributionQuest.CompleteQuest()
endif
endEvent

tried adding another variable that gets switched off additional to the isrunning condition but didnt change anything at all

the messagebox still appears twice... or at least i have to click ok twice, no matter how long i wait in between clicking...
but it doesnt crash anymore on loading another save...

i assume the script gets spammed somehow still
the CTD probably occurs due to the lvl lists of too many actors getting overflowed by that spam if i re-add the distribution part

something about the quest script interaction with the quest doesnt seem to work...
maybe a timer before the script starts could help to normalize behavior and prevent errors in the scripting engine due to possibly too many scripts being loaded at once when a game gets loaded that didnt have the questscript run yet
User avatar
CHangohh BOyy
 
Posts: 3462
Joined: Mon Aug 20, 2007 12:12 pm

Post » Mon Jun 18, 2012 7:45 pm

Probably a dumb question, as I have yet to try the new quest system, but can you break it up into multiple quests .. to avoid the overflow? Seems like a cumbersome sol'n to what worked so nice in the old scripting system and no idea if will work if all run at same time may still get the problem having with one.
User avatar
Claire Jackson
 
Posts: 3422
Joined: Thu Jul 20, 2006 11:38 pm

Post » Mon Jun 18, 2012 1:23 pm

turned of "start game enabled" in the quest and now it only runs once... O.o
doesnt crash on loading a savegame which didnt have it run yet

however, re-adding those lines:
DeathItemDragonPriest.AddForm (JSwordsDragonstingLVLI, 1, 1)
leads to a crash on loading a save game again which didnt have the script yet run on it

does AddForm add items not only in savegames anymore? O.o
User avatar
James Wilson
 
Posts: 3457
Joined: Mon Nov 12, 2007 12:51 pm

Post » Tue Jun 19, 2012 1:00 am

DeathItemDragonPriest.AddForm (JSwordsDragonstingLVLI, 1, 2)

the 2 does not add DragonstingLVLI as two seperate items but as one item on the lvl list that gets added twice to the target, meaning you dont get a higher chance of finding it but you will find 2 of the items
therefore this would be correct to increase loot chance:

DeathItemDragonPriest.AddForm (JSwordsDragonstingLVLI, 1, 1)
DeathItemDragonPriest.AddForm (JSwordsDragonstingLVLI, 1, 1)

however none of that fixes the CTD on loading another save -.-
User avatar
Ben sutton
 
Posts: 3427
Joined: Sun Jun 10, 2007 4:01 am

Post » Mon Jun 18, 2012 11:49 pm

the CTD does not happen because of the Quest, i turned the questscript into an objectscript for a book and the same problem when loading an old savegame appears... CTD! ...so much about my friday afternoon lol :swear:
User avatar
Cash n Class
 
Posts: 3430
Joined: Wed Jun 28, 2006 10:01 am

Post » Mon Jun 18, 2012 7:50 pm

@AddForm

first load after init:

-works - enemies have new weapons in their leveled lists
-saving
-loading another savegame -> CTD
-restarting
-loading new save after init of AddForm
-ok
-loading different save
-ok
-loading new save
-ok
-does not work - enemies do not have the new swords in their leveled lists

----------
seems like restarting the game does revert the AddForm script and it is being burned into the current session of Skyrim instead of the savegame like in FO3 and FONV

i dont get it!!!!
HEEEELLLPP :unsure:
User avatar
asako
 
Posts: 3296
Joined: Wed Oct 04, 2006 7:16 am

Post » Mon Jun 18, 2012 8:49 am

from the wiki @ AddForm(Leveled Item):

seems to be either broken or working differently than additemtoleveledlist and addformtoformlist in FO3 and FONV, it used to store the changed data inside the savegame, yet now, when you load an old save that had this function called the changes will be gone, loading a savegame that did not have this function called after having this function called on a savegame or newgame leads to a CTD

anybody got an explanation for that? :wacko:
User avatar
El Goose
 
Posts: 3368
Joined: Sun Dec 02, 2007 12:02 am

Next

Return to V - Skyrim