The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

Age based?

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Coding
View previous topic :: View next topic  
Author Message
Naylor



Joined: 03 Dec 2012
Posts: 95

PostPosted: Tue Apr 30, 2013 7:26 am    Post subject: Age based? Reply with quote

Okay so.. the way this handles age is totally baffling me. So I'm gonna tell you what I'm trying to do, and maybe someone who understands the age thing can help me figure out HOW to get it to work?

First off, I want to put in a check like this for certain skills:

If ch->age > 75
chance -10

Thus making it so old folk have a harder time accomplishing certain things (when was the last time you saw a 90yr old man effectively wield a greatsword for instance?)

Also, haven't seen this in and would love to be able to add it: age spells.
Drain Youth:

if caster->age =>7 && victim->age =<899
int drain = 5
caster->age =- drain
victim->age =+ drain

Restore Youth
if ch->age =>7
int restore
restore = number_range( 0, 5 );
ch->age =+ restore

Wither
if victim->age =<899
int wither
wither = number_range( 1, 100 );
victim->age =+ wither


See what I'm getting at? Also planning to add checks in update to do growth/shrink effects on certain races due to age (like dragons that start out young hatchlings and grow to massive serpents as they age) but my lack of knowing how to set up checks for and properly manipulate the age is blocking me.

I looked at setage but.. this is confusing me:

Code:


        ch->pcdata->birthyear_modifier=-value;
   ch->pcdata->birthyear_modifier++;
   ch->pcdata->birthdate-=ICTIME_IRLSECS_PER_YEAR;
   ch->println("Age set - see score to see your new age.");


It LOOKS like the value the user sets is subtracted.. and then if i understand the following line correctly one is added, making it a modification one less than the user actually selected (5 becoming 4, 7 becoming 6, etc)

Everywhere I look for the age related coding and try to read it i come away more confused than before


Back to top
View user's profile Send private message
myogaman



Joined: 16 May 2013
Posts: 16

PostPosted: Mon May 20, 2013 5:48 am    Post subject: Reply with quote

Unary minus (additive inverse) -a

So the -value is the additive inverse of the true value of ...value. What does this mean?! I dunno, I'm gonna have to dig into an old C++ book to find out.

Okay so it inverts the value of the variable

So what I'm thinking (since I don't know the value of any of these variables) is that it is taking the character's birth year (value?), making it negative (-value), incrementing it by one (so -value+1) and then subtracting this from the game's year.

So if Value = 1990.
-1990.
-1989.
2013 - - 1989.
So...4002? Wait, that's not right. Let's use logic instead of whatever C++ says,

you take the birth year and make it negative. Then you add the current year to the negative year. So...
-1990
2013 + -1990 = 23.

I would assume this is what it really does but damn, if I'm not terrible at reading blind methods.


Back to top
View user's profile Send private message
Naylor



Joined: 03 Dec 2012
Posts: 95

PostPosted: Mon May 20, 2013 9:46 am    Post subject: Reply with quote

so putting up a check for this and having it block any character who isn't over 100 yrs old would be similar to..

Code:

int birthyear
int currentyear
int age

birthyear = <wherever the birthyear is stored in playerfile>
currentyear = <wherever i can find the storage for current year>

age = (currentyear -=birthyear)

if (age <= 100)
return;


right? wrong? am i even close?


and with some of the above it would be simply modifying the birthyear (once i find where that is stored) right?


Back to top
View user's profile Send private message
myogaman



Joined: 16 May 2013
Posts: 16

PostPosted: Mon May 20, 2013 10:10 am    Post subject: Reply with quote

Sounds right though I don't know how exactly the program checks for age or set birth years or whatever.


Back to top
View user's profile Send private message
Kalahn
Codebase Developer


Joined: 18 Jan 2003
Posts: 710
Location: New Zealand

PostPosted: Fri May 24, 2013 1:03 am    Post subject: Reply with quote

a-=b; is shorthand for a=a-b;
just like a+=5, is short for a=a+5.
another thing the code does is use things like ++i%=5;
that is short hand for;
i=i+1; i=i%5;

- Kal


Back to top
View user's profile Send private message Visit poster's website
Naylor



Joined: 03 Dec 2012
Posts: 95

PostPosted: Fri May 24, 2013 12:03 pm    Post subject: Reply with quote

Helpful, thanks! I'll let you guys know if I get it working


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Coding All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin