[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Character Age

Character Age

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Sun 04 Jun 2006 07:25 AM (UTC)
Message
I'm looking to make characters age based on the time they log in, the current time, then each game year it will set them 1 year older, any way to do this? Any suggestions? Any methods that would be best?

Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Sun 04 Jun 2006 10:35 AM (UTC)
Message
Do you mean:

- players log on at time T
- for every game year after T, increment age by 1

Or do you mean:

- players log on at time T
- every time a game year ticks, increment age by 1
(This is different from the first option; every ages at the same time)

Or do you mean:

- keep track of total log in time
- divide log in time by game year time to obtain age

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #2 on Mon 05 Jun 2006 12:59 AM (UTC)
Message
They create their character then are given a birthday, 18 years or so earlier from the current game time, then every game year that the birthday arrives they advance 1 year in age. so if they were born on the first of said month, the next year on the first of said month they age by 1 year.

Everything turns around in the end
[Go to top] top

Posted by Conner   USA  (381 posts)  [Biography] bio
Date Reply #3 on Mon 05 Jun 2006 01:53 AM (UTC)
Message
You do know that unless you drastically change how game time ticks by, you're going to have some very ancient characters that way...

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #4 on Mon 05 Jun 2006 02:08 AM (UTC)
Message
I'm using SmaugFUSS right now and I have players who login for 12-15 hours at a time, and they are already 100-200+ in age... because age is done by hours played. I just feel like this would be a slightly better way to do this, instead of aging over a 100 years, in less the a year via game time.

Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #5 on Mon 05 Jun 2006 02:23 AM (UTC)

Amended on Mon 05 Jun 2006 02:24 AM (UTC) by David Haley

Message
Sounds like what you really want is to leave age exactly as it is, except that you divide the ticks differently; instead of dividing by real-time hour, you divide by game-time year.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #6 on Mon 05 Jun 2006 02:27 AM (UTC)
Message
short get_age( CHAR_DATA * ch )
{
   return 17 + ( ch->played + ( current_time - ch->logon ) ) / 7200;
}


Here age is based on hours played, I dont want that, I want to make age based on in game "birthdays" then every time their birthday comes to be, they age 1 year.


Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #7 on Mon 05 Jun 2006 05:31 AM (UTC)
Message
If you really, really want it to be incremented every "birthday" then you are creating extra trouble for yourself. If your goal, in the end of the day, is to make people age only according to game years, then simply don't divide by 7200 (which is two real-time hours). Find out how many seconds a game year is, and divide by that. Make sure you also adjust save/load.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #8 on Thu 08 Jun 2006 02:48 PM (UTC)

Amended on Thu 08 Jun 2006 03:03 PM (UTC) by Metsuro

Message
short get_age( CHAR_DATA * ch )
{
   int age;

   if( ch->pcdata->cdate[0] == 0 )
    ch->pcdata->cdate[0] = (time_info.year - 17 );
   if( ch->pcdata->cdate[1] == 0 )
    ch->pcdata->cdate[1] = time_info.month + 1;
   if( ch->pcdata->cdate[2] == 0 )
    ch->pcdata->cdate[2] = time_info.day + 1;

   age = (time_info.year - ch->pcdata->cdate[0]);
   if ((time_info.month - (ch->pcdata->cdate[1] - 1) ) >= 0 && (time_info.day - (ch->pcdata->cdate[2] - 1) ) >= 0)
    age += 1;
   return age;
}


this is what I came up with, you'll see that cdate[1] and cdate[2] have + 1 and - 1, I did this because month and day start at 0 not 1 and it would screw with my setting portion on the top, only way I could figure to do this. It seems to work for me now, but I havn't had much testing done with it yet... If I did something that seems really stupid or could be improved on, please say so, so I can make things work more... effiencetly?

Note: the orginal code made the player a year to old, so I lowered the 18 to 17 *shrug*

Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #9 on Thu 08 Jun 2006 08:34 PM (UTC)
Message
I don't think this will work because, if I'm not mistaken, time_info.year is reset to zero every time the game reboots, and is not a continuous value. So your players will only age during one game.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #10 on Fri 09 Jun 2006 12:09 AM (UTC)
Message
time_info.year is currently set to 499. I thought that was the case too, but after hotbooting and rebooting a few times its remained 499. So I'm waiting a few more days, because there is 18 or so months a game year, so if it does I'll have to rework things but untill then it seems to be working decently.

Everything turns around in the end
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #11 on Fri 09 Jun 2006 01:11 AM (UTC)
Message
It does indeed seem that the current game time is set at boot by calculating how much time has passed since a certain constant (which looks like it's about 1989 sometime). So looks like I misremembered that bit.

Instead of doing -17 for the creation date, it would be safer to set the creation date correctly, but then for the age, getting current year - creation year + base character age you want (in this case, that appears to be 17).

But, if you are storing this creation date with their pfiles, you should know that your characters will be aging even if they are offline...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Metsuro   USA  (389 posts)  [Biography] bio
Date Reply #12 on Fri 09 Jun 2006 01:30 AM (UTC)
Message
right thats how it should be, the game moves on, even if they arn't in the realms. But I store the creation dates as is. However I dont really see how it would be safer to store the dates as is, and have the age portion in the actual check, but I could be missing something? and the actual age is 18, because when they create its their birthday already, making them get +1 from the way I've done it.

Everything turns around in the end
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


26,314 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]