Jump to content

Mystery Box Style Shop


ajhakra

Recommended Posts

Hey there,

 

I had an idea of a weapon shop that works similar to the mystery box in CoD Zombies. The player would activate lets say a button connected to a chest, which would take a certain amount of caps from the players inventory and then output a weapon into the chest. Could someone guide me in writing a script for this?

 

Thanks!

Link to comment
Share on other sites

Scriptname MysteryBoxExample extends ObjectReference


MiscObject Property Caps001 auto

Weapon Property Gun auto

Weapon Property Item2 auto




Event Onactivate(objectreference akactionref)


Utility.RandomInt(0,100)




if (Game.GetPlayer().GetItemCount(Caps001) == 0)




RandomLottery()


Endif

Endevent



Function RandomLottery()




if Utility.RandomInt(1)


Game.Getplayer().additem(gun)


Elseif Utility.RandomInt(2)


Game.GetPlayer().additem(item2)



Endif

Endfunction



Heres something I just wrote up no idea if its correct or works but maybe somebody else can expand off it to help you, gl.

Link to comment
Share on other sites

 

Scriptname MysteryBoxExample extends ObjectReference
MiscObject Property Caps001 auto
Weapon Property Gun auto
Weapon Property Item2 auto
Event Onactivate(objectreference akactionref)
Utility.RandomInt(0,100)
if (Game.GetPlayer().GetItemCount(Caps001) == 0)
RandomLottery()
Endif
Endevent
Function RandomLottery()
if Utility.RandomInt(1)
Game.Getplayer().additem(gun)
Elseif Utility.RandomInt(2)
Game.GetPlayer().additem(item2)
Endif
Endfunction
Heres something I just wrote up no idea if its correct or works but maybe somebody else can expand off it to help you, gl.

 

Thanks! I will give it a test and see if it works.

 

I'm assuming I should change the integer from 0,100 to whatever amount of weapons I'll be adding? e.g. 0,5?

 

For the Caps001 part would I change it to Caps050 == 0 or Caps001 == 50?

 

 

Link to comment
Share on other sites

 

 

Scriptname MysteryBoxExample extends ObjectReference
MiscObject Property Caps001 auto
Weapon Property Gun auto
Weapon Property Item2 auto
Event Onactivate(objectreference akactionref)
Utility.RandomInt(0,100)
if (Game.GetPlayer().GetItemCount(Caps001) == 0)
RandomLottery()
Endif
Endevent
Function RandomLottery()
if Utility.RandomInt(1)
Game.Getplayer().additem(gun)
Elseif Utility.RandomInt(2)
Game.GetPlayer().additem(item2)
Endif
Endfunction
Heres something I just wrote up no idea if its correct or works but maybe somebody else can expand off it to help you, gl.

 

Thanks! I will give it a test and see if it works.

 

I'm assuming I should change the integer from 0,100 to whatever amount of weapons I'll be adding? e.g. 0,5?

 

For the Caps001 part would I change it to Caps050 == 0 or Caps001 == 50?

 

 

 

 

The 0 , 100 is part of] randomint , and indicates the range of vales that will be output. So you'd change that depending on what values you set to output what weapons. What you're talking about would be down in additem.

Link to comment
Share on other sites

 

Scriptname MysteryBoxExample extends ObjectReference
MiscObject Property Caps001 auto
Weapon Property Gun auto
Weapon Property Item2 auto
Event Onactivate(objectreference akactionref)
Utility.RandomInt(0,100)
if (Game.GetPlayer().GetItemCount(Caps001) == 0)
RandomLottery()
Endif
Endevent
Function RandomLottery()
if Utility.RandomInt(1)
Game.Getplayer().additem(gun)
Elseif Utility.RandomInt(2)
Game.GetPlayer().additem(item2)
Endif
Endfunction
Heres something I just wrote up no idea if its correct or works but maybe somebody else can expand off it to help you, gl.

 

Doesn't seem to be working. Attached it to a container and tried to activate the container with a button and by opening it's inventory.

Link to comment
Share on other sites

 

 

Scriptname MysteryBoxExample extends ObjectReference
MiscObject Property Caps001 auto
Weapon Property Gun auto
Weapon Property Item2 auto
Event Onactivate(objectreference akactionref)
Utility.RandomInt(0,100)
if (Game.GetPlayer().GetItemCount(Caps001) == 0)
RandomLottery()
Endif
Endevent
Function RandomLottery()
if Utility.RandomInt(1)
Game.Getplayer().additem(gun)
Elseif Utility.RandomInt(2)
Game.GetPlayer().additem(item2)
Endif
Endfunction
Heres something I just wrote up no idea if its correct or works but maybe somebody else can expand off it to help you, gl.

 

Doesn't seem to be working. Attached it to a container and tried to activate the container with a button and by opening it's inventory.

 

 

Hmm. From the look of it, the button will add the weapon to the player's inventory, not the container. T do that, I think you'll need to change the GetPlayer value. Make a new reference variable with the unique ref of the container, put it up at the top (Should be able to make that all in the property editor itself, so you don't have to do the manual coding), then replace the GetPlayer value with that.

Link to comment
Share on other sites

I just wrote that script for something to go off of,no idea if it works,im also a noob myself :tongue: it also doesn't include and dialog boxes or anything its just simply click box if player has caps roll dice give random item, you probably would want to use http://www.creationkit.com/fallout4/index.php?title=Message_Script to add some message boxes, the first tutorial of the video below goes into messages if you don't know how.

 

 

Heres some videos and information I used to learn what I know

 

This guy has great videos, watch all of them, I was recommended these myself

 

 

Heres some sources for events and functions.

 

Functions : http://www.creationkit.com/fallout4/index.php?title=Category:Papyrus

 

Events : http://www.creationkit.com/fallout4/index.php?title=Category:Events

Edited by ajs52698
Link to comment
Share on other sites

  • Recently Browsing   0 members

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