Help with script and setup for replenishing safe

Post » Tue May 17, 2011 12:23 pm

OK, so I'm wanting to set up a safe that replenishes a leveled amount of caps for the player every 7 days exactly like the Thieves Den/Dunbarrow pirates DLC for Oblivion. I picked apart how that was set up, and using their script as a template have come up with the following basic script. I don't think this is 100% right yet, and I would like your help figuring this out. Here's what I have so far:

ScriptName LuckyCasinoSafeScriptshort 	LastPickupshort 	GiveLootBEGIN GameMode;Timer for reloading safe        if GetQC BucksGrandOpeningQuest ;my quest has to be completed for this to add money to safe		Set GiveLoot to 1 ;this is a total guess on my part			if ( GameDaysPassed >= LastPickup + 7 ) ;how does it know when the last pickup was				ShowMessage BucksPlayerSafeMessage ;my message tells the player they have a new deposit in their safe				Set GiveLoot to 1			endif	    endif;Puts level caps into the safe and will have levels up to 30 when completed	if ( GiveLoot == 1 )		if ( Player.GetLevel == 1 )			LuckyCasinoPlayerSafe.AddItem Caps001 100			Set GiveLoot to 0			Set LastPickup to 1 ;does this need to be here to tell it when the last pickup was again i am guessing at this		endifEND


I'm not sure, but I don't know if that first "Set GiveLoot to 1" after the getQC is right. But I'm not a skilled enough scripter to know better, lol. (What else is new, right?)

I have a handle on all of the levels except for the "Set LastPickup to 1". Is that what it needs to be there? Again, I'm just guessing on most of this.

Thanks!

Oh yeah, one last thing. Could I just add my safe to the casino, set persistent and attach this script to it and it will work? Or is there more to it than that?
User avatar
hannaH
 
Posts: 3513
Joined: Tue Aug 15, 2006 4:50 am

Post » Tue May 17, 2011 5:02 am

I have a handle on all of the levels except for the "Set LastPickup to 1". Is that what it needs to be there? Again, I'm just guessing on most of this.


Whenever a variable would seem to indicate a TIME, it usually means that it's holding information to work as a timer.

I'm looking at the DLC and the LastPickup is set in Conversation when you send out your pirates.

Set DLC06ThievesDen.LastPickup to GameDaysPassed


So "if ( GameDaysPassed >= LastPickup + 7 )" will only fire if one week has passed since LastPickup was set.
User avatar
chloe hampson
 
Posts: 3493
Joined: Sun Jun 25, 2006 12:15 pm

Post » Tue May 17, 2011 9:54 am

Whenever a variable would seem to indicate a TIME, it usually means that it's holding information to work as a timer.

I'm looking at the DLC and the LastPickup is set in Conversation when you send out your pirates.

Set DLC06ThievesDen.LastPickup to GameDaysPassed


So "if ( GameDaysPassed >= LastPickup + 7 )" will only fire if one week has passed since LastPickup was set.

Aha! I see that now! I knew it had to be set somewhere. lol. Would this work then?

ScriptName LuckyCasinoSafeScriptshort   LastPickupshort   GiveLootBEGIN GameMode;Timer for reloading safe        if GetQC BucksGrandOpeningQuest ;my quest has to be completed for this to add money to safe                Set GiveLoot to 1 ;this is a total guess on my part                        if ( GameDaysPassed >= LastPickup + 7 ) ;how does it know when the last pickup was                                ShowMessage BucksPlayerSafeMessage ;my message tells the player they have a new deposit in their safe                        endif            endif;Puts level caps into the safe and will have levels up to 30 when completed        if ( GiveLoot == 1 )                if ( Player.GetLevel == 1 )                        LuckyCasinoPlayerSafe.AddItem Caps001 100                        Set GiveLoot to 0                        Set LastPickup to GameDaysPassed                endifEND

User avatar
Alex Blacke
 
Posts: 3460
Joined: Sun Feb 18, 2007 10:46 pm

Post » Tue May 17, 2011 1:57 pm

Aha! I see that now! I knew it had to be set somewhere. lol. Would this work then?

ScriptName LuckyCasinoSafeScriptshort   LastPickupshort   GiveLootBEGIN GameMode;Timer for reloading safe        if GetQC BucksGrandOpeningQuest ;my quest has to be completed for this to add money to safe                Set GiveLoot to 1 ;this is a total guess on my part                        if ( GameDaysPassed >= LastPickup + 7 ) ;how does it know when the last pickup was                                ShowMessage BucksPlayerSafeMessage ;my message tells the player they have a new deposit in their safe                        endif            endif;Puts level caps into the safe and will have levels up to 30 when completed        if ( GiveLoot == 1 )                if ( Player.GetLevel == 1 )                        LuckyCasinoPlayerSafe.AddItem Caps001 100                        Set GiveLoot to 0                        Set LastPickup to GameDaysPassed                endifEND




This is what your script is doing:

If BucksGrandOpeningQuest is complete do
Set GiveLoot to 1 <--- this will always be Set to 1 if the quest is finished
Only show message when GameDaysPassed is more than a week after LastPickup is set

If GiveLoot is 1 (which it will always be in your script)
{do stuff that sets GiveLoot to 0 and LastPickup to current day}

... Script continues running... GiveLoot is always set to 1... Chest gets another 100 caps... Repeat as fast as the script runs...
Basically your chest will never do anything BUT add 100 caps

Try something like this instead

ScriptName LuckyCasinoSafeScriptshort  LastCashDayshort  GiveLootshort  ActiveBEGIN GameModeif GetQC BucksGrandOpeningQuest ;only do this stuff if the quest is completed	if (Active == 0)	;this will set all the variables up the first time the script can run		set GiveLoot to 0	;begins with no reward. Change to 1 for immediate gains.		set LastCashDay to GameDaysPassed		set Active to 1	endif		if ( GameDaysPassed >= LastCashDay + 7 )	;if a week has passed, make sure loot is added		set GiveLoot to 1		set LastCashDay to GameDaysPassed	;sets the timer	endif	if ( GiveLoot == 1)	;will run whenever the previous if block is true		set GiveLoot to 0	;resets the reward tracker		; DO STUFF HERE	endif	endifEND

User avatar
Jay Baby
 
Posts: 3369
Joined: Sat Sep 15, 2007 12:43 pm

Post » Tue May 17, 2011 12:30 pm

Looks like this can all be done with an OnActivate block or even an OnLoad block.
User avatar
KRistina Karlsson
 
Posts: 3383
Joined: Tue Jun 20, 2006 9:22 pm

Post » Tue May 17, 2011 9:12 am

This is what your script is doing:

If BucksGrandOpeningQuest is complete do
Set GiveLoot to 1 <--- this will always be Set to 1 if the quest is finished
Only show message when GameDaysPassed is more than a week after LastPickup is set

If GiveLoot is 1 (which it will always be in your script)
{do stuff that sets GiveLoot to 0 and LastPickup to current day}

... Script continues running... GiveLoot is always set to 1... Chest gets another 100 caps... Repeat as fast as the script runs...
Basically your chest will never do anything BUT add 100 caps

Try something like this instead

ScriptName LuckyCasinoSafeScriptshort  LastCashDayshort  GiveLootshort  ActiveBEGIN GameModeif GetQC BucksGrandOpeningQuest ;only do this stuff if the quest is completed	if (Active == 0)	;this will set all the variables up the first time the script can run		set GiveLoot to 0	;begins with no reward. Change to 1 for immediate gains.		set LastCashDay to GameDaysPassed		set Active to 1	endif		if ( GameDaysPassed >= LastCashDay + 7 )	;if a week has passed, make sure loot is added		set GiveLoot to 1		set LastCashDay to GameDaysPassed	;sets the timer	endif	if ( GiveLoot == 1)	;will run whenever the previous if block is true		set GiveLoot to 0	;resets the reward tracker		; DO STUFF HERE	endif	endifEND



That is awesome, thank you so much! Only 2 more questions and I think I'll have it, lol. (Sorry for being such a noob, but I'm a noob!)

Would the script below be the correct way to add in all the levels from 1 to 30, or is that what the line you have ;DO STUFF HERE is for? (Don't the levels need to be right after the GiveLoot is set to 1?) And the last thing hopefully, is do I simply need to attach this script to my safe for it to work, or do I need to set it up some other way to run?

Thanks so much again!

ScriptName LuckyCasinoSafeScriptshort  LastCashDayshort  GiveLootshort  ActiveBEGIN GameModeif GetQC BucksGrandOpeningQuest ;only do this stuff if the quest is completed        if (Active == 0)        ;this will set all the variables up the first time the script can run                set GiveLoot to 0       ;begins with no reward. Change to 1 for immediate gains.                set LastCashDay to GameDaysPassed                set Active to 1        endif                if ( GameDaysPassed >= LastCashDay + 7 )        ;if a week has passed, make sure loot is added                set GiveLoot to 1                set LastCashDay to GameDaysPassed       ;sets the timer        endif    if ( GiveLoot == 1)     ;will run whenever the previous if block is true		if ( Player.GetLevel == 1 )			LuckyCasinoPlayerSafe.AddItem Caps001 100 ;continue this progression all the way to level 30		endif                set GiveLoot to 0       ;resets the reward tracker                ; DO STUFF HERE    endifEND

User avatar
Stephy Beck
 
Posts: 3492
Joined: Mon Apr 16, 2007 12:33 pm

Post » Mon May 16, 2011 11:21 pm

;DO STUFF HERE was for your code. The placement of your additem code compared to GiveLoot being assigned 0 shouldn't matter, but place it at the end if you're more comfortable with it there.

If you plan to do a flat 100 caps per level addition then you may want to instead create an integer variable which will store (PlayerLevel * 100) and then use that for the number of caps being added to the chest.

I haven't touched modding for a while but I believe an Object Script on the safe itself would run just fine.
User avatar
Sasha Brown
 
Posts: 3426
Joined: Sat Jan 20, 2007 4:46 pm

Post » Tue May 17, 2011 3:16 am



If you plan to do a flat 100 caps per level addition then you may want to instead create an integer variable which will store (PlayerLevel * 100) and then use that for the number of caps being added to the chest.



I think you are right. I set it all up and at level 30 it gave me 27500 caps, lol! How exactly would I set it up like you are suggesting? (Sorry to be a pain.)

But the good news is that it's at least working as it should except for the amount of money it's putting in there. Thanks again for the help!
User avatar
Ana
 
Posts: 3445
Joined: Sat Jul 01, 2006 4:29 am

Post » Mon May 16, 2011 11:36 pm

I think you are right. I set it all up and at level 30 it gave me 27500 caps, lol! How exactly would I set it up like you are suggesting? (Sorry to be a pain.)

But the good news is that it's at least working as it should except for the amount of money it's putting in there. Thanks again for the help!


Hmm, don't know why you'd have problems with cap amount.

The cap assignment thing is as easy as I said. Create another variable to store an integer (short type would be best) and set that to (PCLevel * caps) or whatever calculation you want to use.
Then when you add the Caps001 to the chest use LuckyCasinoPlayerSafe.AddItem Caps001 YourVariableHere
This will add whatever value is stored in your variable as caps to the chest.

You could also improve the mod by adding a ShowMessage MessageObject YourVariableHere where the Message object uses %.0f to display the number of caps added to the chest. It may also help with the debugging process as you'll see how many caps are added and when.
User avatar
Elizabeth Lysons
 
Posts: 3474
Joined: Fri Feb 02, 2007 7:16 am

Post » Tue May 17, 2011 8:40 am

Asylumer, again I can't thank you enough for your help. I'm at the office right now and can't do much, but after a good night's sleep and looking at this again I have a guess as to what might be causing the amount of caps to be off. But as you've probably already figured out, I'm an absolute noob with scripting. I'm just beginning to scratch the surface of learning how to read certain scripts and get a vague understanding of how they are working and what actually does what. But I'll admit I'm still struggling with the ability to actually write something that works like it should.

Anyway, I'll post up my script for you and maybe you can see why the caps are off or you can tell me if I'm correct in what I think might be the problem.

As I said earlier, the entire first part is working properly, and my message is popping up as it is supposed to. I'm wondering in the bits that add the proper amount of caps to the safe if I didn't need to have the “set GiveLoot to 0” after each level? Right now I have it like this:

if ( Player.GetLevel == 1 )                LuckyCasinoPlayerSafe.AddItem Caps001 100endif                if ( Player.GetLevel == 2 )                LuckyCasinoPlayerSafe.AddItem Caps001 200endif			if ( Player.GetLevel == 3 )                LuckyCasinoPlayerSafe.AddItem Caps001 300  ;this continues to level 30endifset GiveLoot to 0


Does just having the one “set GiveLoot to 0” at the end of all the levels do the trick, or do I need it in there for every level like so:

if ( Player.GetLevel == 1 )                LuckyCasinoPlayerSafe.AddItem Caps001 100                set GiveLoot to 0endif                if ( Player.GetLevel == 2 )                LuckyCasinoPlayerSafe.AddItem Caps001 200                set GiveLoot to 0endif			if ( Player.GetLevel == 3 )                LuckyCasinoPlayerSafe.AddItem Caps001 300  ;this continues to level 30               set GiveLoot to 0endif



BTW, I really like the idea about the message telling the player how much money they have waiting and your “integer” suggestion. But I may as well be writing Chinese as I basically can't write anything I don't have an example of to try and figure it out, lol. I'm not being lazy in the least as I've worked my azz off for over 2 months on this mod, I simply am having to learn every single thing I do as I do them because I've never ever done this before. If you want to take the time to add it in here's my full script minus all the levels to level 30.

Thanks again, and here's my script:

ScriptName LuckyCasinoSafeScriptshort  LastCashDayshort  GiveLootshort  ActiveBEGIN GameModeif GetQC BucksGrandOpeningQuest ;only do this stuff if the quest is completed        if (Active == 0)        ;this will set all the variables up the first time the script can run                set GiveLoot to 0       ;begins with no reward. Change to 1 for immediate gains.                set LastCashDay to GameDaysPassed                set Active to 1        endif                if ( GameDaysPassed >= LastCashDay + 7 )        ;if a week has passed, make sure loot is added                set GiveLoot to 1				ShowMessage LuckyCasinoDepositMessage   ;working perfectly                set LastCashDay to GameDaysPassed       ;sets the timer        endif        if ( GiveLoot == 1)     ;will run whenever the previous if block is true		    			if ( Player.GetLevel == 1 )                LuckyCasinoPlayerSafe.AddItem Caps001 100            endif                			if ( Player.GetLevel == 2 )                LuckyCasinoPlayerSafe.AddItem Caps001 200            endif						if ( Player.GetLevel == 3 )                LuckyCasinoPlayerSafe.AddItem Caps001 300  ;this continues to level 30            endif							set GiveLoot to 0       ;resets the reward tracker                ; DO STUFF HERE        endif        endifEND

User avatar
Betsy Humpledink
 
Posts: 3443
Joined: Wed Jun 28, 2006 11:56 am

Post » Tue May 17, 2011 9:06 am

Here is a modified version which removes the need for if blocks, adds the ShowMessage function properly, and includes some simple notation to help you understand what each variable is used for.
You may also be able to shorten "LuckyCasinoPlayerSafe.AddItem Caps001 nCashAmount" to "AddItem Caps001 nCashAmount" as I seem to remember there being an implicit this when calling functions from an Object Script, where this is the in-game instance of the object the script is attached to.

For the ShowMessage argument usage see: http://geck.gamesas.com/index.php/ShowMessage

You'll need to insert "%.0f" in the text line of your message, which is a parameter that takes in a single non-float (integer) value such as nCashAmount. So if you type "This week you've earned %.0f caps from the casino. Return to the safe and enjoy your reward!" into the message text, and nCashAmount is 200, in-game you'll see "This week you've earned 200 caps from the casino. Return to the safe and enjoy your reward!"

ScriptName LuckyCasinoSafeScriptshort nLastCashDay	;last day money was added to the chestshort bGiveLoot		;boolean which determines if the container is eligible to receive money todayshort bActive		;boolean that marks whether this quest has been initialized or notshort nCashAmount	;the amount of caps added to the containerBEGIN GameModeif GetQC BucksGrandOpeningQuest ;only do this stuff if the quest is completed       	 if (bActive == 0)        ;this will set all the variables up the first time the script can run                set bGiveLoot to 0       ;begins with no reward. Change to 1 for immediate gains.                set nLastCashDay to GameDaysPassed                set bActive to 1        endif                if ( GameDaysPassed >= nLastCashDay + 7 )        ;if a week has passed, make sure loot is added                set bGiveLoot to 1                set nLastCashDay to GameDaysPassed       ;sets the timer        endif        if ( bGiveLoot == 1)     ;will run whenever the previous if block is true		set nCashAmount to (player.GetLevel * 100)	;adds 100 caps per player level		LuckyCasinoPlayerSafe.AddItem Caps001 nCashAmount		ShowMessage LuckyCasinoDepositMessage nCashAmount;display message with int argument                set bGiveLoot to 0        endif        endifEND

User avatar
Austin England
 
Posts: 3528
Joined: Thu Oct 11, 2007 7:16 pm

Post » Tue May 17, 2011 4:34 am

Here is a modified version...


That is freakin awesome! Thank you again! I can't wait to get out of this dang office and get home to try this out! :celebration: :foodndrink:
User avatar
Micah Judaeah
 
Posts: 3443
Joined: Tue Oct 24, 2006 6:22 pm

Post » Tue May 17, 2011 7:01 am

UPDATE: WOOT! :celebration:

I just got home and switched up the script and message and it worked perfectly the first time!!! And just out of morbid curiosity before I changed to the new script and message I tried the other setup out with a different test character, and it worked like it should have as well. The one I tested it with last night was another test character I've been using the whole time I've been working on this mod. But I got tired of having to slog through all the level ups time after time and I forgot I used the console to force him to level 30. My guess is that had something to do with the weird amount of caps it gave me last night, but I was too tired and ready to crash to realize it.

Asylumer, again I cannot thank you enough for your patience, knowledge and effort you offered me! I wish I could buy you a round of drinks or offer you a nice dinner somewhere. You are a true credit to the community!

Cheers! :foodndrink:
User avatar
Laurenn Doylee
 
Posts: 3427
Joined: Sun Dec 03, 2006 11:48 am


Return to Fallout: New Vegas