Respawning Plants

Post » Thu Jun 21, 2012 11:57 am

I was attempting to write a simple script that would force the respawning of plants on cell load if a certain number of days had passed since they were harvested.

At first I attempted Self.Reset() in a script attached to the plant itself. That didn't work, and neither did disabling and re-enabling.

Here is the general idea:

scriptName phiRespawnIngS extends ObjectReference{Respawns ingredients when entering a cell after a set time.} float xtime float ytime float Property phiRespawnDay auto Event OnActivate(ObjectReference akActionRef)    xtime = Utility.GetCurrentGameTime()EndEventEvent OnCellLoad()   if xtime <= 0      Self.Reset()      xtime = Utility.GetCurrentGameTime()   elseif xtime > 0      ytime = Utility.GetCurrentGameTime()      if ytime - xtime >= phiRespawnDay         Self.Reset()         xtime = Utility.GetCurrentGameTime()      endif   endifEndEvent

phiRespawnDay is a global I set with a default value, since I wanted to be able to change it easily from either another script or directly from the console. Basically you set this to the number of game days you want it to take for plants to respawn, then the script atatched to the plant object is supposed to check when the player enters the cell if that time has passed and reset them.

If the mod was just loaded any plants in the room should reset the first time they are loaded.

Unfortunately the above appears to do nothing, and nothing appears in my debug logs to indicate why.
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Thu Jun 21, 2012 3:51 pm

I realize I could just change the game setting for how often cells are respawned, however I would really prefer only to change plant respawns, which is why I was trying to do it this way.

EDIT: I tested replacing Self.Reset() with Self.Disable and the plants in question are gone on cell reload. It appears the problem is that Reset() doesn't work as it would seem.

Unfortunately I don't see a member function of ObjectReference or Form that would do this. Basically set the object in question back to it's original state, and in the case of a plant, it's unharvested state.
User avatar
Saul C
 
Posts: 3405
Joined: Wed Oct 17, 2007 12:41 pm

Post » Thu Jun 21, 2012 8:10 pm

Well, I realize now this is probably impossible since most of the plants aren't actually listed as Flora but as Trees and you can't manually add scripts to trees!

What a drag!

I was thinking of a conditional quest variable that patches object type tree in the current cell, but I don't know how effective that would be or if the quest variable search will even match multiple references as I would need it to.

A quick test shows no joy on the Tree objects getting the script. =(
User avatar
Travis
 
Posts: 3456
Joined: Wed Oct 24, 2007 1:57 am


Return to V - Skyrim