How do I get this container to respawn gold daily?

Post » Mon Jan 11, 2010 6:33 pm

http://img88.imageshack.us/img88/554/86194705.jpg

I want this container to respawn different amounts of gold daily so that it simulates the shop owner buying and selling things. His money would fluctuate daily in real life. I made the container organic and respawn but it won't do it daily. I just want a random amount of gold between 0 and 2000 to appear daily, everyday, even after Player steals from it. Can anyone help me with this?
User avatar
Javier Borjas
 
Posts: 3392
Joined: Tue Nov 13, 2007 6:34 pm

Post » Mon Jan 11, 2010 8:11 am

I can think of 2 scripting solutions off the top of my head, the better one requires MWSE and the simpler one doesn't.

First the simple one:

Begin somescriptshort local_dayshort local_goldif ( CellChanged == 0 )	Returnendifif ( local_day == Day )	Returnendifset local_day to Dayif ( local_gold == 10 )	RemoveItem, "gold_001", 2000elseif ( local_gold == 9 )	RemoveItem, "gold_001", 1800elseif ( local_gold == 8 )	RemoveItem, "gold_001", 1600elseif ( local_gold == 7 )	RemoveItem, "gold_001", 1400elseif ( local_gold == 6 )	RemoveItem, "gold_001", 1200elseif ( local_gold == 5 )	RemoveItem, "gold_001", 1000elseif ( local_gold == 4 )	RemoveItem, "gold_001", 800elseif ( local_gold == 3 )	RemoveItem, "gold_001", 600elseif ( local_gold == 2 )	RemoveItem, "gold_001", 400elseif ( local_gold == 1 )	RemoveItem, "gold_001", 200endifset local_gold to Random, 11if ( local_gold == 10 )	AddItem, "gold_001", 2000elseif ( local_gold == 9 )	AddItem, "gold_001", 1800elseif ( local_gold == 8 )	AddItem, "gold_001", 1600elseif ( local_gold == 7 )	AddItem, "gold_001", 1400elseif ( local_gold == 6 )	AddItem, "gold_001", 1200elseif ( local_gold == 5 )	AddItem, "gold_001", 1000elseif ( local_gold == 4 )	AddItem, "gold_001", 800elseif ( local_gold == 3 )	AddItem, "gold_001", 600elseif ( local_gold == 2 )	AddItem, "gold_001", 400elseif ( local_gold == 1 )	AddItem, "gold_001", 200endifEnd

This is obviously not very elegant, considering there are only a number of different options for amounts of gold the container will spawn daily, and these options need to be set manually.

MWSE can get around this problem by introducing variables for AddItem and RemoveItem:

Begin somescriptshort local_dayshort local_stemplong local_goldlong local_tempset local_stemp to CellChangedif ( local_stemp == 0 )	Returnendifset local_stemp to Dayif ( local_day == local_stemp )	Returnendifset local_day to local_stempxRemoveItem, "gold_001", local_goldset local_gold to Random, 20set local_gold to ( local_gold * 100 )set local_temp to Random, 101set local_gold to ( local_gold + local_temp )xAddItem, "gold_001", local_goldEnd

This script will spawn an actual random amount of gold between 0 and 2000 daily.
User avatar
Bee Baby
 
Posts: 3450
Joined: Sun Jun 18, 2006 4:47 am

Post » Mon Jan 11, 2010 11:05 am

I'm pretty sure that last script doesn't need MWSE with a tiny tweak...
User avatar
Heather Stewart
 
Posts: 3525
Joined: Thu Aug 10, 2006 11:04 pm

Post » Mon Jan 11, 2010 2:12 pm

I'm pretty sure that last script doesn't need MWSE with a tiny tweak...


Well, you could instead use different variables for each digit. It would be a long script but definitely not impossible to do. Something like this:

set local_gold_a to Random, 20if ( local_gold_a == 19 )	Additem, "gold_001", 1900elseif ( local_gold_a == 18 )	Additem, "gold_001", 1800elseif ( ... )	; etc.endifset local_gold_b to Random, 10if ( local_gold_b == 9 )	Additem, "gold_001", 90elseif ( local_gold_b == 8 )	Additem, "gold_001", 80elseif ( ... )	; etc.endifset local_gold_c to Random, 11if ( local_gold_c == 10 )	Additem, "gold_001", 10elseif ( local_gold_c == 9 )	Additem, "gold_001", 9elseif ( ... )	; etc.endif


Otherwise no, you cannot AddItem or RemoveItem dynamic amounts, only via MWSE.
User avatar
AnDres MeZa
 
Posts: 3349
Joined: Thu Aug 16, 2007 1:39 pm

Post » Mon Jan 11, 2010 12:53 pm

I don't know anything about Morrowind scripting, but could you not achieve this without MWSE by using a loop?
Check to see if the actual amount of gold matches the intended value, and add gold if it doesn't? Similar system for removing it, obviously.
User avatar
Dustin Brown
 
Posts: 3307
Joined: Sun Sep 30, 2007 6:55 am

Post » Mon Jan 11, 2010 10:43 am

I don't know anything about Morrowind scripting, but could you not achieve this without MWSE by using a loop?
Check to see if the actual amount of gold matches the intended value, and add gold if it doesn't? Similar system for removing it, obviously.


That would make the script very cumbersome by comparison to adul's solution:
begin NI_random_gold_addershort   targetAmountshort   nowAmountshort   tempAmountfloat    lastDayif ( cellChanged == 1 )   if ( lastDay == Day )      return   else      set lastDay to Day   endIf   set nowAmount to PE_Llavam_gold_chest->getItemCound gold_001   set targetAmount to random 2001   if ( nowAmount > targetAmount )      set tempAmount to targetAmount - nowAmount   elseIf ( nowAmount < targetAmount )      set tempAmount to nowAmount - targetAmount   else      ; the random number and the amount in the chest is the same      return   endIfendIfif ( menuMode == 1 )   returnendIfif  ( tempAmount > 1 )   if ( tempAmount > 625 )      if ( nowAmount > targetAmount )         PE_Llavam_gold_chest->removeItem gold_001, 625         set tempAmount to tempAmount - 625      elseIf ( nowAmount < targetAmount )         PE_Llavam_gold_chest->addItem gold_001, 625         set tempAmount to tempAmount - 625      endIf   endIf   if ( tempAmount > 125 )      if ( nowAmount > targetAmount )         PE_Llavam_gold_chest->removeItem gold_001, 125         set tempAmount to tempAmount - 125      elseIf ( nowAmount < targetAmount )         PE_Llavam_gold_chest->addItem gold_001, 125         set tempAmount to tempAmount - 125      endIf   endIf   if ( tempAmount > 25 )      if ( nowAmount > targetAmount )         PE_Llavam_gold_chest->removeItem gold_001, 25         set tempAmount to tempAmount - 25      elseIf ( nowAmount < targetAmount )         PE_Llavam_gold_chest->addItem gold_001, 25         set tempAmount to tempAmount - 25      endIf   endIf   if ( tempAmount > 5 )      if ( nowAmount > targetAmount )         PE_Llavam_gold_chest->removeItem gold_001, 5         set tempAmount to tempAmount - 5      elseIf ( nowAmount < targetAmount )         PE_Llavam_gold_chest->addItem gold_001, 5         set tempAmount to tempAmount - 5      endIf   endIf   if ( tempAmount > 1 )      if ( nowAmount > targetAmount )         PE_Llavam_gold_chest->removeItem gold_001, 1         set tempAmount to tempAmount - 1      elseIf ( nowAmount < targetAmount )         PE_Llavam_gold_chest->addItem gold_001, 1         set tempAmount to tempAmount - 1      endIf   endIfendIfend


This takes 1 to 5 frames to change the amount in the chest to a new random amount. It will take an average of 4.26 frames to update the chest. Actually it looks a bit more efficient than I'd initially thought it would.
User avatar
Steve Bates
 
Posts: 3447
Joined: Sun Aug 26, 2007 2:51 pm

Post » Mon Jan 11, 2010 7:43 pm

Well, you could instead use different variables for each digit. It would be a long script but definitely not impossible to do. Something like this:

Otherwise no, you cannot AddItem or RemoveItem dynamic amounts, only via MWSE.


I've been using randomised floats/variables in my add/remove item scripts since.. a long time and I don't use MWSE. Just tested it this moment.
User avatar
Brian LeHury
 
Posts: 3416
Joined: Tue May 22, 2007 6:54 am

Post » Mon Jan 11, 2010 10:11 am

I've been using randomised floats/variables in my add/remove item scripts since.. a long time and I don't use MWSE. Just tested it this moment.


Ah, my bad. I've never heard of that being a viable solution. I guess I'll go check that out sometime.
User avatar
Marquis T
 
Posts: 3425
Joined: Fri Aug 31, 2007 4:39 pm

Post » Mon Jan 11, 2010 10:47 am

I can think of 2 scripting solutions off the top of my head, the better one requires MWSE and the simpler one doesn't.

First the simple one:

Begin somescriptshort local_dayshort local_goldif ( CellChanged == 0 )	Returnendifif ( local_day == Day )	Returnendifset local_day to Dayif ( local_gold == 10 )	RemoveItem, "gold_001", 2000elseif ( local_gold == 9 )	RemoveItem, "gold_001", 1800elseif ( local_gold == 8 )	RemoveItem, "gold_001", 1600elseif ( local_gold == 7 )	RemoveItem, "gold_001", 1400elseif ( local_gold == 6 )	RemoveItem, "gold_001", 1200elseif ( local_gold == 5 )	RemoveItem, "gold_001", 1000elseif ( local_gold == 4 )	RemoveItem, "gold_001", 800elseif ( local_gold == 3 )	RemoveItem, "gold_001", 600elseif ( local_gold == 2 )	RemoveItem, "gold_001", 400elseif ( local_gold == 1 )	RemoveItem, "gold_001", 200endifset local_gold to Random, 11if ( local_gold == 10 )	AddItem, "gold_001", 2000elseif ( local_gold == 9 )	AddItem, "gold_001", 1800elseif ( local_gold == 8 )	AddItem, "gold_001", 1600elseif ( local_gold == 7 )	AddItem, "gold_001", 1400elseif ( local_gold == 6 )	AddItem, "gold_001", 1200elseif ( local_gold == 5 )	AddItem, "gold_001", 1000elseif ( local_gold == 4 )	AddItem, "gold_001", 800elseif ( local_gold == 3 )	AddItem, "gold_001", 600elseif ( local_gold == 2 )	AddItem, "gold_001", 400elseif ( local_gold == 1 )	AddItem, "gold_001", 200endifEnd

This is obviously not very elegant, considering there are only a number of different options for amounts of gold the container will spawn daily, and these options need to be set manually.



I like this one a lot. It's simple and the Player really isn't going to be checking this chest every single day to see if the gold is different numbers. So what I did was change the values to make it seem like they are random numbers. It works great as each day, the number is different. The only thing I would like to add is when Player takes the gold, I want the gold to still respawn with these numbers the next day and thereafter. How would you add that in? Thanks Adul.


Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( CellChanged == 0 )        Returnendifif ( local_day == Day )        Returnendifset local_day to Dayif ( local_gold == 10 )        RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )        AddItem, "gold_001", 2147elseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript





EDIT: Nevermind, it works. Cell change isn't really 100% reliable in this script, but it's okay because I just want this to simulate Llavam, the shop owner, having money come in and out. So even if Gold doesn't respawn every single day, you could say he just put the rest of it in the bank. And besides, the only reason Player would check this container every single day and take the gold is to cheat to make themselves richer. And that's not what I'm trying to accomplish.

But like Elaura said, you can control the mod, but you can't control the Player.

But can you alter the script to make it to where cell change is 100% reliable, Adul? Or someone?
User avatar
Emzy Baby!
 
Posts: 3416
Joined: Wed Oct 18, 2006 5:02 pm

Post » Mon Jan 11, 2010 8:31 am

CellChanged is not a very good solution as it has trouble detecting teleportation and scripted travel. It usually works for exterior cell changes and load door cell changes. A reliable way to detect other types of cell change is to run a global script that checks the player's cell constantly, until it's changed.


To do that, first I'd create a global short variable, for this example I'll call it PE_LlavamGoldChestChange to keep faithful to the naming convention.


Then I'd create a new script that checks if the player is in the container's cell and changes the global variable if he isn't (you'll need to save this twice because the first time it will produce an error):

Begin PE_LlavamGoldChestscript_gif ( GetPCCell, "REPLACE WITH CELL NAME" == 1 )	Returnendifset PE_LlavamGoldChestChange to 1StopScript, "PE_LlavamGoldChestscript_g"End


Now all that needs doing is to replace CellChanged in the original script and integrate the new script into it:

Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( PE_LlavamGoldChestChange == 0 )	Returnendifif ( local_day == Day )	Returnendifset local_day to Dayset PE_LlavamGoldChestChange to 0StartScript, "PE_LlavamGoldChestscript_g"if ( local_gold == 10 )	RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )	RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )	RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )	RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )	RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )	RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )	RemoveItem, "gold_001", 891elseif ( local_gold == 3 )	RemoveItem, "gold_001", 653elseif ( local_gold == 2 )	RemoveItem, "gold_001", 424elseif ( local_gold == 1 )	RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )	AddItem, "gold_001", 2147elseif ( local_gold == 9 )	AddItem, "gold_001", 1836elseif ( local_gold == 8 )	AddItem, "gold_001", 1705elseif ( local_gold == 7 )	AddItem, "gold_001", 1589elseif ( local_gold == 6 )	AddItem, "gold_001", 1262elseif ( local_gold == 5 )	AddItem, "gold_001", 1018elseif ( local_gold == 4 )	AddItem, "gold_001", 891elseif ( local_gold == 3 )	AddItem, "gold_001", 653elseif ( local_gold == 2 )	AddItem, "gold_001", 424elseif ( local_gold == 1 )	AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript



Also note that Random may return 0 so in it's current form the script has 10% chance each day to produce no gold at all. If you want to change that, you may replace this:

set local_gold to Random, 11

With this:

set local_gold to Random, 10set local_gold to ( local_gold + 1 )

User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Mon Jan 11, 2010 3:18 pm

That new script looks the same as the old one. Where did you write CellChanged? I don't see it anywhere.
I'll keep the set local_gold to Random, 11 since I would like to have his chest empty every now and then. I mean, my wallet is empty at times, so I'm sure Llavam would have an empty gold chest as well.
User avatar
Gaelle Courant
 
Posts: 3465
Joined: Fri Apr 06, 2007 11:06 pm

Post » Mon Jan 11, 2010 6:09 pm

That new script looks the same as the old one. Where did you write CellChanged? I don't see it anywhere.


I've changed this part:

if ( CellChanged == 0 )	Returnendifif ( local_day == Day )	Returnendifset local_day to Day

To this:

if ( PE_LlavamGoldChestChange == 0 )	Returnendifif ( local_day == Day )	Returnendifset local_day to Dayset PE_LlavamGoldChestChange to 0StartScript, "PE_LlavamGoldChestscript_g"


CellChanged has been omitted because it is a rather unreliable function. Instead, I'm using a global script (StartScript, "PE_LlavamGoldChestscript_g") to check when the player leaves the cell. When this happens, the global variable PE_LlavamGoldChestChange is set to the value of 1. The container's script checks this variable when you return to its cell, and rerolls the random gold if at least one day has passed.

The global script actually only runs until you leave the cell, so it doesn't eat away valuable system resources throughout the game. :)
User avatar
Darian Ennels
 
Posts: 3406
Joined: Mon Aug 20, 2007 2:00 pm

Post » Mon Jan 11, 2010 12:22 pm

The chest is not spawning any gold at all, even when I exit cell and go into a different cell and then exit that one and come back into this one. I did that 3 or 4 times and it was still empty.

These are the scripts again:

Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( PE_LlavamGoldChestChange == 0 )        Returnendifif ( local_day == Day )        Returnendifset local_day to Dayset PE_LlavamGoldChestChange to 0StartScript, "PE_LlavamGoldChestscript_g"if ( local_gold == 10 )        RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )        AddItem, "gold_001", 2147elseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript



AND


Begin PE_LlavamGoldChestscript_g; script by Adulif ( GetPCCell, "Pelagiad, The Ascadian Anvil" == 1 )        Returnendifset PE_LlavamGoldChestChange to 1StopScript, "PE_LlavamGoldChestscript_g"End PE_LlavamGoldChestscript_g


with the PE_LlavamGoldChestChange short 0 global variable.

It was working fine with the previous script but this one isn't working. :(
User avatar
Sarah Kim
 
Posts: 3407
Joined: Tue Aug 29, 2006 2:24 pm

Post » Mon Jan 11, 2010 6:17 pm

Were you able to ascertain what the problem in the new script is, Adul?
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Mon Jan 11, 2010 2:30 pm

Oh yes, sorry I overlooked something. The whole script won't function unless the global variable is already set to 1. :rolleyes:

Here's the fixed version:

Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( PE_LlavamGoldChestChange == 1 )        Returnendifif ( local_day == Day )        Returnendifset local_day to Dayset PE_LlavamGoldChestChange to 1StartScript, "PE_LlavamGoldChestscript_g"if ( local_gold == 10 )        RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )        AddItem, "gold_001", 2147elseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript


Begin PE_LlavamGoldChestscript_g; script by Adulif ( GetPCCell, "Pelagiad, The Ascadian Anvil" == 1 )        Returnendifset PE_LlavamGoldChestChange to 0StopScript, "PE_LlavamGoldChestscript_g"End PE_LlavamGoldChestscript_g

User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Mon Jan 11, 2010 4:44 am

Awesome, now it works! Thank you, Adul. I gave you credit for it.

Just so I know, if I wanted to add more variables, would I do it like this? And set the "set local_gold to Random" part to a number that isn't listed? I mean, I could set "set local_gold to Random, 85393" if I wanted, and the script would still function fine, right?

Also, I like how after Player takes all the gold from the chest it doesn't respawn anymore after that. But is there a way to check if it the gold is removed, that a note can be added inside the container instead? I was thinking maybe variable 15, where if ( local_gold == 0 ), additem "warning_note_thief". Or would that be an ElseIf command?



if ( local_gold == 13 )        RemoveItem, "gold_001", value aelseif ( local_gold == 12 )        RemoveItem, "gold_001", value belseif ( local_gold == 11 )        RemoveItem, "gold_001", value celseif ( local_gold == 10 )        RemoveItem, "gold_001", value delseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 14if ( local_gold == 13 )        AddItem, "gold_001", value aelseif ( local_gold == 12 )        AddItem, "gold_001", value belseif ( local_gold == 11 )        AddItem, "gold_001", value celseif ( local_gold == 10 )        AddItem, "gold_001", value delseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endif

User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm

Post » Mon Jan 11, 2010 5:36 pm

Just so I know, if I wanted to add more variables, would I do it like this? And set the "set local_gold to Random" part to a number that isn't listed? I mean, I could set "set local_gold to Random, 85393" if I wanted, and the script would still function fine, right?

Yes, you can add more values like that. You can use random with any natural number but it's been suggested that Morrowind random doesn't function correctly with values over 100.


Also, I like how after Player takes all the gold from the chest it doesn't respawn anymore after that.

Now that one confuses me because the script shouldn't stop generating gold after the player takes it. It should resume generating it normally. Are you sure it works like that?


But is there a way to check if it the gold is removed, that a note can be added inside the container instead? I was thinking maybe variable 15, where if ( local_gold == 0 ), additem "warning_note_thief". Or would that be an ElseIf command?

It would be possible to check if the player stole all gold from the container and add a note. It could look something like this:

Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( local_gold == -1 )        Returnendifif ( PE_LlavamGoldChestChange == 1 )        Returnendifif ( local_day == Day )        Returnendifif ( GetItemCount, "gold_001" == 0 )        if ( local_gold != 0 )                AddItem, "steal_note_id", 1                set local_gold to -1                Return        endifendifset local_day to Dayset PE_LlavamGoldChestChange to 1StartScript, "PE_LlavamGoldChestscript_g"if ( local_gold == 10 )        RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )        AddItem, "gold_001", 2147elseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript

This way, if the player removes all gold from the container, then a note is added (rename "steal_note_id" to the ID of your choice) and the script is placed into a disabled state. So no gold will be generated after that happens.

Details are fun, that's my modding philosophy too. :hehe:
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm

Post » Mon Jan 11, 2010 6:42 am

There must be something that we're missing, because after I take all the gold, nothing spawns back in the chest. What's funny though is that if I take part of the gold, or even 99% of it and just leave one gold coin, it'll will respawn through the numbers as it should. But if I take all the gold, no more gold respawns and the note doesn't show up the next day either. And I waited about 3 days and still nothing. What do you think could be the problem?



Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( local_gold == -1 )        Returnendifif ( PE_LlavamGoldChestChange == 1 )        Returnendifif ( local_day == Day )        Returnendifif ( GetItemCount, "gold_001" == 0 )        if ( local_gold != 0 )                AddItem, "PE_Llavam_chest_steal_note", 1                set local_gold to -1                Return        endifendifset local_day to Dayset PE_LlavamGoldChestChange to 1StartScript, "PE_LlavamGoldChestscript_g"if ( local_gold == 10 )        RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )        AddItem, "gold_001", 2147elseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript

User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Mon Jan 11, 2010 5:24 pm

Strange indeed. :confused: I'll give it some testing and let you know what I come up with.
User avatar
Lance Vannortwick
 
Posts: 3479
Joined: Thu Sep 27, 2007 5:30 pm

Post » Mon Jan 11, 2010 8:00 pm

Ah okay, I got it now! Turns out there is an error in Morrowind where AddItem doesn't always work on empty containers. This is apparently a well known issue (which I've never heard of before lol), and it's descriped http://www.uesp.net/wiki/Tes3Mod:AddItem in detail.

So this is why the chest just stopped functioning after the player took all gold from it, because it was empty. The script was still running and completing everything it was supposed to, but AddItem didn't work so no new gold could be added to the chest.

The way I've come up with to get around this issue is to disable the chest entirely after the player steals all gold from it, and replace it with another identical chest that only contains the steal note.


There are 3 scripts, now. The first one is attached to the chest itself:

Begin PE_LlavamGoldChestscript; script by Adulshort local_dayshort local_goldif ( PE_LlavamGoldChestChange >= 1 )	Returnendifset PE_LlavamGoldChestChange to 1StartScript, "PE_LlavamGoldChestscript_g"if ( local_day == Day )	Returnendifset local_day to Dayif ( GetItemCount, "gold_001" == 0 )	if ( local_gold != 0 )		set PE_LlavamGoldChestChange to 2		Disable		Return	endifendifif ( local_gold == 10 )        RemoveItem, "gold_001", 2147elseif ( local_gold == 9 )        RemoveItem, "gold_001", 1836elseif ( local_gold == 8 )        RemoveItem, "gold_001", 1705elseif ( local_gold == 7 )        RemoveItem, "gold_001", 1589elseif ( local_gold == 6 )        RemoveItem, "gold_001", 1262elseif ( local_gold == 5 )        RemoveItem, "gold_001", 1018elseif ( local_gold == 4 )        RemoveItem, "gold_001", 891elseif ( local_gold == 3 )        RemoveItem, "gold_001", 653elseif ( local_gold == 2 )        RemoveItem, "gold_001", 424elseif ( local_gold == 1 )        RemoveItem, "gold_001", 177endifset local_gold to Random, 11if ( local_gold == 10 )        AddItem, "gold_001", 2147elseif ( local_gold == 9 )        AddItem, "gold_001", 1836elseif ( local_gold == 8 )        AddItem, "gold_001", 1705elseif ( local_gold == 7 )        AddItem, "gold_001", 1589elseif ( local_gold == 6 )        AddItem, "gold_001", 1262elseif ( local_gold == 5 )        AddItem, "gold_001", 1018elseif ( local_gold == 4 )        AddItem, "gold_001", 891elseif ( local_gold == 3 )        AddItem, "gold_001", 653elseif ( local_gold == 2 )        AddItem, "gold_001", 424elseif ( local_gold == 1 )        AddItem, "gold_001", 177endifEnd PE_LlavamGoldChestscript

I've made a few adjustments to the respawn system as well, so now gold respawn is more consistent with the player waiting/leaving/returning.


The second script is the global script, it's not attached to anything:

Begin PE_LlavamGoldChestscript_g; script by Adulif ( GetPCCell, "Pelagiad, The Ascadian Anvil" == 1 )	Returnendifif ( PE_LlavamGoldChestChange == 1 )	set PE_LlavamGoldChestChange to 0endifStopScript, "PE_LlavamGoldChestscript_g"End PE_LlavamGoldChestscript_g


And the third script is the one attached to the clone chest. This chest should look identical to the original and should be in the exact same place (copy/paste the coordinates). Here's the script:

Begin PE_LlavamGoldChestscript_b; script by Adulif ( PE_LlavamGoldChestChange != 2 )	if ( GetDisabled == 0 )		Disable	endifelseif ( GetDisabled == 1 )	EnableendifEnd PE_LlavamGoldChestscript_b

User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm

Post » Mon Jan 11, 2010 9:48 am

Thank you. I'm very familiar with enable/disable scripts so this will be easy. I'll let you know how it works in-game.
User avatar
Nauty
 
Posts: 3410
Joined: Wed Jan 24, 2007 6:58 pm

Post » Mon Jan 11, 2010 7:06 am

It works perfectly now! Thank you Adul! I added your name to the Readme for credit. :)
User avatar
GRAEME
 
Posts: 3363
Joined: Sat May 19, 2007 2:48 am

Post » Mon Jan 11, 2010 7:16 am

Glad to help. :)
User avatar
Jaylene Brower
 
Posts: 3347
Joined: Tue Aug 15, 2006 12:24 pm

Post » Mon Jan 11, 2010 1:53 pm

I've been using randomised floats/variables in my add/remove item scripts since.. a long time and I don't use MWSE. Just tested it this moment.

Wait. How, exactly? My understanding that Add/RemoveItem only accepts variables in dialogue. I've tried it in regular scripts, and it always gives errors. I've never seen anything about it accepting floats, and I can't see how that could work anyway. If you actually got this to work, then I would like to know how.
User avatar
Britta Gronkowski
 
Posts: 3475
Joined: Mon Apr 09, 2007 3:14 pm


Return to III - Morrowind