Jump to content

Growing Flora


lrh9

Recommended Posts

My quest script works, I just did not give the game time to update the variable. Quests scripts have a priority that affect how often they execute. I may experiment with the priority to see if I can get the variable to update faster.
Link to comment
Share on other sites

I have written what I thought was a correct script to make flora grow. I am encountering bugs. Flora will not grow.

 

This is an OBSE script.

 

scn GrowingFlora

short dayOfYear
float seasonFactor
float newScale
ref flora

short init
float seed
float growthFactor
float springFactor
float summerFactor
float fallFactor
float winterFactor
float timeScaleFactor

begin GameMode
if Season == 0
	set seasonFactor to springFactor
elseif Season == 1
	set seasonFactor to summerFactor
elseif Season == 2
	set seasonFactor to fallFactor
else
	set seasonFactor to winterFactor
endif
set newScale to (flora.GetScale * GetSecondsPassed * growthFactor * seasonFactor * TimeScale * timeScaleFactor)
if newScale < 0.5 || newScale > 3
	flora.SetScaleEX newScale
	disable
	enable
else
	flora.SetScale newScale
endif	
end

begin OnLoad
if init == 0
	set seed to Rand 1 2
	set flora to GetSelf
	set newScale to (flora.GetScale * seed)
	if newScale < 0.5 || newScale > 3
		flora.SetScaleEX newScale
		disable
		enable
	else
		flora.SetScale newScale
	endif	
	set growthFactor to Rand 1 2
	set springFactor to Rand 1 2
	set summerFactor to Rand 1 2
	set fallFactor to Rand 1 2
	set winterFactor to Rand 1 2
	set timeScaleFactor to Rand 1 2
	set init to 1
endif
end

Edited by lrh9
Link to comment
Share on other sites

If you wanted to find out exactly when the game considers season to be, you could test it with 'SetIngredientChance'; make four custom ingredients that each have 100% harvest in one season, and 0% in the others, then test for different gamedayspasseds.

 

EDIT: Oh, and you can't have an OnLoad block on a quest script. You'll need a 'if GetGameLoaded' condition in your gamemode block.

Edited by PrettyMurky
Link to comment
Share on other sites

I would say that you Disable-Enable approach should not work, but as you have a demo video I am really confused.

 

Loong time ago I played with this concept (see video) and could not find a simple solution. The code with the complex solution may be checked in my Conceptuals collection - check the Realistic Farming file (I, myself, dont remember what I did anymore, I only remember it was not easy to solve)

 

 

 

Link to comment
Share on other sites

Thank you for giving me a link to your solution.

 

I based my use of disable/enable on the CS Wiki's information about the OBSE command SetScaleEx.

 

http://cs.elderscrolls.com/index.php/SetScaleEX

 

Notes state that the reference should be disabled and then enabled after calling the function in order to update the scale and collision properties. (Flora don't have collision though.)

 

There is no limit to the scale on SetScaleEX. The range on SetScale is 0.5 to 2.0. I need to correct my script. (Range 0.5 to 3.0.) Maybe that will fix an issue.

 

http://cs.elderscrolls.com/index.php/SetScale

 

P.S. My video was made using the dumbest script I could possibly write. It might look like a timelapse video, but I really just kept setting the scale to the amount of seconds that had passed. :)

 

scn GrowingFlora

float seconds
ref flora

begin GameMode
set seconds to seconds + GetSecondsPassed
set flora to GetSelf
flora.SetScale seconds
end

Edited by lrh9
Link to comment
Share on other sites

I devised a simple script similar to my dumb script to see if the SetScaleEX command was at least working. The script didn't work.

 

scn GrowingFlora

float seconds
ref flora

begin GameMode
set seconds to seconds + GetSecondsPassed
set flora to GetSelf
flora.SetScaleEX seconds
disable
enable
end

 

I think it is a problem with trying to disable and then enable the object so quickly. If I open the console and disable the flora, then the script will enable it and it will be rescaled. So at least the SetScaleEX command and enable command works. I even tried this script:

 

scn GrowingFlora

float seconds
ref flora

begin GameMode
set seconds to seconds + GetSecondsPassed
set flora to GetSelf
flora.SetScaleEX seconds
if GetDisabled == 1
enable
else
disable
endif
end

 

I have even changed the order of the enable and disable commands. Nothing seems to work.

Link to comment
Share on other sites

As far as I know disabling and enabling within the same script (or within the same frame, I guess) will not do anything. These commands just turn a flag on and off somewhere in the reference's attributes.

 

I mean, if an object is enabled when rendered in a given frame, script(s) enable it and disable it at will but it ends up enabled when rendered in the next frame, the game does not do anything, really. So any glitches in the game engine (like collision boxes left behind) carry over from frame to frame.

 

In order to reset these glitches you have to disable in one frame and enable in the next frame.

 

In the past, I have found at least one scenario where even this did not work (cant remember the circumstances), and I had to throw in a Reset3Dstate.

 

So, today, my 'standard procedure' is: Frame 1: Disable , Frame 2: Reset3Dstate, Frame 3 Enable.

This works for me 100% of the time.

 

Problem is that the object flickers.

If memory serves, in the farm POC I used two objects so one is visible while the other is disabled.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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