Mod for Player Aging (Please revise)

Post » Tue Jun 19, 2012 8:52 pm

Scriptname HumanAging extends FormGlobalVariable property GameHour autoGlobalVariable property GameDaysPassed autoGlobalVariable property PlayerAge autoPerk property AgePerk1 autoPerk property AgePerk2 autoPerk property AgePerk3 autoint property Stage autoEvent OnInit()RegisterForUpdateGameTime(1)EndEventEvent OnUpdateGameTime()float TimeOfDay = (GameHour.Getvalue())float CurrentAge = (PlayerAge.Getvalue())float DaysPassed = (GameDaysPassed.Getvalue())if (TimeOfDay == 0)ActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBaseRace PlayerRace = PlayerBase.GetRace()float DayCount = (DaysPassed / 356)float Age = (CurrentAge + DayCount)PlayerAge.SetValue(Age)Debug.Notification("A new day has come. You are now " + PlayerAge.GetValue() + " years old.")			  If (PlayerRace == "Redguard" || "Imperial" || "Nord")	 	    If (Age <= 40) && (Stage == 0)	  	    Stage += 1		   			    elseif (Age  >= 41) && (Age <= 60) && (Stage  == 1)		  Stage   					    elseif (Age >= 61) && (Stage == 2)	  Stage += 1	 	   elseif (Age == 100) && (Stage == 3)	   UnregisterForUpdateGameTime()	  	   endif    endif		   endif	   EndEvent

What this script is intended to do is update the PlayerAge variable I created in the Global section every day at 0 (GameHour). It retrieves the game days passed and divides them by the amount of days in a year (in this instance, 365) and adds it to the PlayerAge.

The problem is simple. It doesn't update the Global Variable and doesn't update at 0 (GameHour).

Could someone that is quite familiar with Papyus take a quick peak at this code and give me some pointers.

All the best!
User avatar
Sabrina Steige
 
Posts: 3396
Joined: Mon Aug 20, 2007 9:51 pm

Post » Tue Jun 19, 2012 2:58 pm

I have tried many diffirent variations of this script and none of them work. I've come to the conclusion that the global variable I created, PlayerAge, is not being pulled by the script.

For instace:

TimeOfDay = GameHour.getValueint()

The code above seems to work just fine when retrieving the time of day. However, when trying the same with myGlobalVariable the result is null (0) even though it is set at 21.

CurrentAge = PlayerAge.getValueint()

If I type in "Show PlayerAge" in console it shows the value as 21... but still, the script wont retrieve it.

I have the script attached to a quest. I then went into properties and clicked auto-fill so. It then connected to the global variables I created and thus shouldn't have any problems retrieving their values. Alas, that is not the case and I am still unable to run this script.
User avatar
Rachel Tyson
 
Posts: 3434
Joined: Sat Oct 07, 2006 4:42 pm

Post » Wed Jun 20, 2012 2:51 am

Isn't enough just to create the GlobalVariable under Misc/Global in the CK? I made sure it is not constant. It is set as a short variable. Do I need to attach the variable to something before I set it as a property?
User avatar
vicki kitterman
 
Posts: 3494
Joined: Mon Aug 07, 2006 11:58 am

Post » Wed Jun 20, 2012 4:51 am

On first reading, it looks OK (it's obviously not, or it would be working!).

First off, there is some wiki wierdness to have a look at:



int newTime = 5
TimeOfDayGlobalProperty.SetValueInt(newTime)
http://www.creationkit.com/SetValueInt_-_GlobalVariable

SetValue appears to want to be a float.


See if SetValueInt works ...
User avatar
J.P loves
 
Posts: 3487
Joined: Thu Jun 21, 2007 9:03 am

Post » Tue Jun 19, 2012 9:05 pm

On first reading, it looks OK (it's obviously not, or it would be working!). First off, there is some wiki wierdness to have a look at:

int newTime = 5 TimeOfDayGlobalProperty.SetValueInt(newTime) SetValue appears to want to be a float.

See if SetValueInt works ...

Wont this set the value? I wish to retrieve it. I set to 21 by default.
User avatar
Jesus Sanchez
 
Posts: 3455
Joined: Sun Oct 21, 2007 11:15 am

Post » Tue Jun 19, 2012 6:50 pm

I'm sorry. I should stop reading and posting at that time of night :(

http://www.creationkit.com/GetValueInt_-_GlobalVariable

^^^ That's the Get Version ...
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Tue Jun 19, 2012 4:46 pm

I'm sorry. I should stop reading and posting at that time of night :(

http://www.creationkit.com/GetValueInt_-_GlobalVariable

^^^ That's the Get Version ...

Then the problem seems to be that I set the local integers as properties as aposed to retrieving them as int.

I will delete the this line:

int property CurrentAge autoCurrentAge = PlayerAge.getValueint()

Then rewrite the getvalue line to:

int CurrentAge = PlayerAge.getValueint()

Hopefully that should work. If it does, then I believe I've created the meat of a mod that the game can greatly benefit from.
User avatar
Nicole Kraus
 
Posts: 3432
Joined: Sat Apr 14, 2007 11:34 pm


Return to V - Skyrim