Jump to content

Scripting Noob in Need of Help from The Pros


Recommended Posts

Yes, it would be for one particular trophy.

Yes, you would make a form list of the items that you require the player to have in order to "build" the trophy.

Yes, the integer array would contain the quantities of each item in the form list. The object in list at index 0 would use the quantity value in the array at index 0

Yes, it is the object that you will actually use as the trophy once "built".

 

If you want a single trophy base that the player can decide from a selection of trophies to have displayed on that base, well that would be more complicated. Possible, but more complicated. Each possible trophy would have to be pre-placed and disabled. The work moved off into custom functions using parameters to import the data to work with. And a menu system for the player to choose which trophy. The choice dictates what data gets sent into the custom function(s).

 

Another route would be to do something similar to Hearthfires. Create a workstation with custom keyword, create recipes with the custom keyword so only those will appear at the workstation. Then a player alias script would listen for the crafted tokens to be added, remove them and enable the correct pre-placed display. That would save having to make the ingredient form lists and quantity arrays as the recipes would handle that.

Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

:laugh: That makes me feel good that I got all yes's from you. I am learning! I did it all and it worked! But I have questions.

 

Let me ask you, what if I was to place one of every trophy on a stand, initially disable everyone of them, and then adapt the script you provided to pull up a crafting menu with choices to "enable" the trophy of your choice based on a list of required items? Maybe an elseif statement?

 

To that extent: What if I put one of each trophy on a base and initially disable them all and then made the trophy base a container? A container with a script that says If the player puts in these 2 items, enable bear, elseif the player puts in THESE 2 items, enable wolf, elseif.......etc. Would that be to "heavy" for the game? And If the player removes the items from the container, it would disable the trophy and then they can start again making a different trophy. Of course you wouldn't want to be able to enable another trophy once one was up until you remove it. This style would have a trophy book for players to read to know what items will trigger what trophy. But books are easy to make and set next to the trophy base.

Edited by Chris20201986
Link to comment
Share on other sites

A menu system would be possible as well as the container idea you mentioned. Both are doable and neither would be taxing on Papyrus in the long run. Complication comes in the code writing.

 

For an idea of the container idea take a look at the Atronach Forge. It is basically a container that the player puts items into and when the lever is activated the first possible thing using the items inside the container is spawned.

Link to comment
Share on other sites

2 scripts found:

Sigil Stone

 

Scriptname AtrFrgSigilStoneScript extends ObjectReference

miscObject property sigilStone auto
objectReference property sigilStoneREF auto
AtronachForgeSCRIPT property Forge auto
message property defaultLackTheItemMSG auto
EVENT onActivate(objectReference actronaut)
if Forge.sigilStoneInstalled == FALSE
if actronaut.getItemCount(SigilStone) >= 1
Forge.sigilStoneInstalled = TRUE
sigilStoneREF.enable()
(actronaut as actor).removeItem(sigilStone, 1)
else
; player must not have the sigil stone to install
defaultLackTheItemMSG.show()
endif
else
; if the sigilstone is installed, then let the player get it back
Forge.sigilStoneInstalled = FALSE
sigilStoneREF.disable()
(actronaut as actor).addItem(sigilStone, 1)
endif
endEVENT

Pull Lever

scriptname AtronachForgeSCRIPT extends objectReference
formlist property RecipeList auto
{Master list of valid recipes. Most Complex should be first}
formlist property ResultList auto
{Master list of recipe results. Indices of Rewards MUST MATCH those of the recipe list}
formlist property SigilRecipeList auto
{Recipes that are only available when sigil stone is installed}
formlist property SigilResultList auto
{Items attainable only with sigil stone installed}
objectReference property createPoint auto
{Marker where we place created items}
objectReference property DropBox auto
{where the player places items to be crafted}
activator property summonFX auto
{Point to a fake summoning cloud activator}
objectReference property summonFXpoint auto
{Where we place the summoning FX cloud}
bool property sigilStoneInstalled auto hidden
{has the sigil stone been installed?}
objectReference property lastSummonedObject auto hidden
; store whatever we summoned last time to help clean up dead references.
STATE busy
EVENT onActivate(objectReference actronaut)
; debug.trace("Atronach Forge is currently busy. Try again later")
endEVENT
endSTATE
auto STATE ready
EVENT onActivate(objectReference actronaut)
gotoState("busy")
bool DaedricItemCrafted
; first attempt to craft Daedric items if the Sigil Stone is installed
; debug.trace("Atronach Forge checking for Sigil Stone")
if sigilStoneInstalled == TRUE
; debug.trace("Atronach Forge detected Sigil Stone, attempt Daedric Combines first")
DaedricItemCrafted = scanForRecipes(SigilRecipeList, SigilResultList)
utility.wait(0.1)
endif
; if no sigil stone, or if we checked and found no valid Daedric recipes...
if sigilStoneInstalled == FALSE || DaedricItemCrafted == FALSE
; debug.trace("Atronach Forge Either did not detect Sigil Stone, or no deadric combines were found")
ScanForRecipes(RecipeList, ResultList)
endif
gotoState("ready")
endEVENT
endSTATE
bool FUNCTION ScanForRecipes(formlist Recipes, formList Results)
; set up our counter vars
int i = 0
int t = Recipes.getSize()
bool foundCombine = FALSE
bool checking = TRUE
;========================================================
While checking == TRUE && i < t
formlist currentRecipe = (Recipes.getAt(i)) as formList
if currentRecipe == NONE
; debug.trace("ERROR: Atronach Forge trying to check a NONE recipe")
else
if scanSubList(currentRecipe) == TRUE
; I have found a valid recipe
; debug.trace("Atronach Forge found ingredients for "+currentRecipe)
removeIngredients(currentRecipe)
foundCombine = TRUE
checking = FALSE
else
; found nothing
endif
endif
if foundCombine == FALSE
; only increment if we are continuing to loop
i += 1
endif
endWhile
if foundCombine == TRUE
; we found a valid item, so create it!
; debug.trace("Attempting to spawn a "+Results.getAt(i))
summonFXpoint.placeatme(summonFX);summonFX.playGamebryoAnimation("mIdle")
utility.wait(0.33)
objectReference newREF = createPoint.placeAtMe(Results.getAt(i))
; if the last thing I summoned is a dead actor, just get rid of it.
if (lastSummonedObject)
if ((lastSummonedObject as actor).isDead())
; transfer any items to the offering box (just in case I had anything valuable on me!)
lastSummonedObject.RemoveAllItems(DropBox, FALSE, TRUE)
lastSummonedObject.disable()
lastSummonedObject.delete()
endif
endif
; now store whatever we just created as the current/last summoned object
lastSummonedObject = newREF
if (newREF as actor) != NONE
(newREF as actor).startCombat(game.getPlayer())
endif
return TRUE
else
; did not find any valid combines - choose a "failure" scenario
return FALSE
endif
endFUNCTION
;========================================================
;========================================================
;========================================================
bool FUNCTION scanSubList(formList recipe)
int size = recipe.getSize()
int cnt = 0
while cnt < size
form toCheck = recipe.getAt(cnt)
if dropBox.getItemCount(toCheck) < 1
; ;debug.trace("Did not have item "+toCheck+" ("+cnt+") for recipe #"+recipe)
return FALSE
else
; ;debug.trace("I Have item "+toCheck+" ("+cnt+") for recipe #"+recipe)
; we have the item in cnt
endif
cnt += 1
endWhile
return TRUE
endFUNCTION
FUNCTION removeIngredients(formlist recipe)
int size = recipe.getSize()
int cnt = 0
while cnt < size
form toCheck = recipe.getAt(cnt)
dropBox.removeItem(toCheck, 1)
; debug.trace("Atronach Forge is consuming "+toCheck)
cnt += 1
endWhile
endFUNCTION

Edited by Chris20201986
Link to comment
Share on other sites

  • 2 weeks later...

As the title says, I am here again. Let me set up the scenario.

 

I built a house. This house has a back porch with a railing overlooking a cliff. I would like to make an extension mod to the house for a pool. I do not want the house to come with the pool unless you want the pool, you can download the extension mod. I have already made the pool extension using the original house as a plugin. However, the railing on the backporch of the main mod will be in the way not allowing access to the pool area. I assume there is a way to reference all the railing parts I want moved in lieu of the pool mod being installed in the player LO. Am I correct in my assumption?

Link to comment
Share on other sites

If the pool mod will be present from the beginning of the game, you can link all the railing pieces not needed for the pool to an xMarker. Set the xMarker as an enable state parent. Then disable the xMarker in game and all those railing pieces will become disabled too. This is pretty much how all the room purchases for player homes are handled. A collection of objects which get enabled when the linked marker is enabled or disabled.

 

But, if the pool mod is added later, the railings might not recognize the linked marker due to having already been loaded. In that scenario you might need to create a formlist or array that contains each of the railing references to be disabled. Then loop through the list and disable each piece one at a time.

Link to comment
Share on other sites

So the main reason I am doing it is for the players that already reside in my home. Rather than remove their entire collection of weapons, armor and collectibles and install the version with a pool, they can simply download the add-on. So I may need to do the form list way.

 

So in that case how would I use the form list? I will make a form list called: JLS_Railing_Removal and name each rail component JLS_Rail_1, 2, etc and each rail post JLS_Post_1, 2 etc. Add each rail piece to the form list. Now what? I would need a script to call upon the form list that way it knows what to do with said formlist?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...