Jump to content

Small Script Request


Lagruej

Recommended Posts

I'm looking for somebody who can help whip me up a script. Looking through the game's base scripts I don't think it should be too hard, I just don't know how to make it happen.

Basically I have Misc Item "Card Pack"

I want Card Pack to have a script where when it's used;

1. Card Pack is removed from the inventory. (By default misc. items remain in inventory even when used)

2. "Leveled List" A is rolled for Item 1 (Common Card)

3. "Leveled List" A is rolled for Item 2 (Common Card)
4. "Leveled List" A is rolled for Item 3 (Common Card)
5. "Leveled List" A is rolled for Item 4 (Common Card)

6. "Leveled List" B is rolled for Item 5 (Uncommon Card)
7. "Leveled List" B is rolled for Item 6 (Uncommon Card)

8. "Leveled List" C is rolled for Item 7 (Rare Card)

9. All 7 rolled items are added to the player's inventory.

I would like all 7 Leveled Lists to be individually selectable in CK script editor - i.e. I don't want/need a "count" feature in case I change the rarity distribution or add new rarities.

I don't know if it's an automatic function of the engine or not, but I also want the deposited items to show in the 'feed' we get in the top left of the screen.

I'm good with adding the .psc myself and all that and compiling it, I just don't know how to write scripts myself.

Edited by Lagruej
Link to comment
Share on other sites

I also want the deposited items to show in the 'feed' we get in the top left of the screen.

It is Debug.Notification function.

 

I'm good with adding the .psc myself and all that and compiling it, I just don't know how to write scripts myself.

 

Did you read the official Papyrus docs?

Edited by shumkar
Link to comment
Share on other sites

Hey, this isn't too difficult. Although, I would use Formlists instead of leveled items, and I would make the card pack a book, instead of a misc item, that way you can use the event OnRead(). Here's a script that should work:

Scriptname LagruejCardPackScript extends ObjectReference 

Actor Property pPlayerRef Auto
Formlist Property LagruejCommonCards Auto 
FormList Property LagruejUnCommonCards Auto 
Formlist Property LagruejRareCards Auto

Event OnRead()
  Int A = Utility.RandomInt(0, (LagruejCommonCards.GetSize() - 1))
  Int B = Utility.RandomInt(0, (LagruejCommonCards.GetSize() - 1))
  Int C = Utility.RandomInt(0, (LagruejCommonCards.GetSize() - 1))
  Int D = Utility.RandomInt(0, (LagruejCommonCards.GetSize() - 1))

  Int E = Utility.RandomInt(0, (LagruejUnCommonCards.GetSize() - 1))
  Int F = Utility.RandomInt(0, (LagruejUnCommonCards.GetSize() - 1))

  Int G = Utility.RandomInt(0, (LagruejRareCards.GetSize() - 1))

  pPlayerRef.AddItem((LagruejCommonCards.GetAt(A) as MiscObject), 1)
  pPlayerRef.AddItem((LagruejCommonCards.GetAt(B) as MiscObject), 1)
  pPlayerRef.AddItem((LagruejCommonCards.GetAt(C) as MiscObject), 1)
  pPlayerRef.AddItem((LagruejCommonCards.GetAt(D) as MiscObject), 1)

  pPlayerRef.AddItem((LagruejUnCommonCards.GetAt(E) as MiscObject), 1)
  pPlayerRef.AddItem((LagruejUnCommonCards.GetAt(F) as MiscObject), 1)

  pPlayerRef.AddItem((LagruejRareCards.GetAt(G) as MiscObject), 1)
EndEvent

Attach this script to your card pack book, and it will run whenever you read the book. Make the formlists and add your cards to them, I assumed they would be misc items. Don't forget to fill properties in the creation kit after attaching the script.

Edited by dylbill
Link to comment
Share on other sites

If you still want to use leveled lists and a misc object card pack

 

 

Not tested for compilation or function

Scriptname CardPackScript Extends MiscObject

LeveledItem Property CommonCardsLL Auto 
LeveledItem Property UnCommonCardsLL Auto 
LeveledItem Property RareCardsLL Auto
Int Property NumCallsCommon = 4 Auto
Int Property NumCallsUnCommon = 2 Auto
Int Property NumCallsRare = 1 Auto
;set up as properties so that you can adjust how many entries will be pulled from the leveled list
;changes will only be reflected on new games or new instances of the object holding this script

Event OnEquipped(Actor akActor)
  If akActor == Game.GetPlayer()
    GetCardItem(CommonCardsLL, akActor, NumCallsCommon)
    GetCardItem(UnCommonCardsLL, akActor, NumCallsUnCommon)
    GetCardItem(RareCardsLL, akActor, NumCallsRare)
  EndIf
EndEvent

;below is a custom function which requires passing in a leveled list, the actor to receive the items and the number of times to get items from the list.
Function GetCardItem(LeveledItem TheLList, Actor TheDude, Int NumCalls)
  Int index = NumCalls
  While index > 0
    TheDude.AddItem(TheLList)
    index -= 1
  EndWhile
EndFunction

It should be noted that the OnEquipped event will still get triggered by a misc object when the Equip / Use button is pressed while in the inventory. However, The game may still state that the object cannot be equipped.

 

Also leveled items can be added with AddItem. The game will grab an item that meets the level criteria provided the percentage chance to obtain an item has been met first. Stock example: the gems sometimes received when mining.

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...