Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » HP/Mana/Move limitations?
Forum Rules | Mark all | Recent Posts

HP/Mana/Move limitations?
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Feb 21, 2009, 7:15 pm
Go to the top of the page
Go to the bottom of the page

Sanus Compleo
Magician
GroupMembers
Posts153
JoinedMar 25, 2008

Long story short, I want to make a mobile who spawns with 250,000,000 hp. There is no-where in the code that dictates that I cannot do so, but when it loads it has around -40k hp. Any idea how I can fix it so that I can have a rediculous amount of hitpoints on a mob?
       
Post is unread #2 Feb 21, 2009, 7:39 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Actually in a way, you kind of gave the answer in your post:
Long story short,


hp, mana, and moves are stored as short integers. meaning they're limited to 32k+change. I can't recall the exact limit on a short atm. You'll need to change them to be stored as int rather than short.
       
Post is unread #3 Feb 21, 2009, 7:59 pm   Last edited Feb 21, 2009, 8:06 pm by Sanus Compleo
Go to the top of the page
Go to the bottom of the page

Sanus Compleo
Magician
GroupMembers
Posts153
JoinedMar 25, 2008

Okay, cool, I set short to int, but now in the fprompt it sticks at -3%.
The code is " percent = ( 100 * victim->hit ) / victim->max_hit; " which I assume doesn't want to work because the number is outrageously high. Any ideas?

EDIT: Also for some reason, even though I added in bits in the right places for saving and loading mobiles, it will not save/load mobile height/weight.
       
Post is unread #4 Feb 21, 2009, 9:20 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

There may be several places where hitpoints/mana/movement are referred to that the code is setup to expect short int. You need to make sure ALL of those variables are declared as int instead so you don't end up with the same problem.

And FYI - the limits on them are -32768 to +32767. The limits on a regular integer are -2.1something billion to +2.1something billion.
       
Post is unread #5 Feb 22, 2009, 2:39 am   Last edited Feb 22, 2009, 2:48 am by Sanus Compleo
Go to the top of the page
Go to the bottom of the page

Sanus Compleo
Magician
GroupMembers
Posts153
JoinedMar 25, 2008

I did a crtl+f search for "hit" while all of the documents were open at once, and didn't find a time in which there appeared to be any form of dictation that continued to declare max_hit/hit as shorts, and I'm not sure how a block of code expecting a short would differ from a block of code expecting an int... In essence, I'm stuck.

EDIT: Also fixed the height/weight thing, there was nothing to set the index values in mset xD, so that fixed that problem.

By the way, it only seems to affect anything that's showing percentages of health, like fprompt and upon look it shows them as DYING.
       
Post is unread #6 Feb 22, 2009, 2:52 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

In the case of your particular statement:

percent = ( 100 * victim->hit ) / victim->max_hit;

You need to find where "percent" is declared. You'll likely find it's declared as a short because the values it worked with before were all shorts. Change it into an int and that will fix this particular problem. Similar issues are likely to exist elsewhere in the code that will need to be fixed the same way.
       
Post is unread #7 Feb 22, 2009, 2:53 am   Last edited Feb 22, 2009, 2:57 am by Sanus Compleo
Go to the top of the page
Go to the bottom of the page

Sanus Compleo
Magician
GroupMembers
Posts153
JoinedMar 25, 2008

Actually, Samson, I think you answered this in the AFKMud support a while back, I just didn't remember it until I said the Dying thing, I'm going to check that out and see if that fixes it for me.

EDIT: Fantastic, it was because those percent checks were still the same as they were in Stock Smaug, the fix you had in AFKMud Support did fix the problem.
       
Post is unread #8 Feb 22, 2009, 3:31 pm
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Just kinda curious here... was it because 250,000,000 x 100 = 250,000,000,000. Which is greater than what even an integer value can represent? So changing the forumla to:
percent = (  victim->hit / victim->max_hit ) *100;


Fixes the problem?

Like I said, just curious, and I wouldn't mind seeing the answer so if anyone else was following this post they'd know too.

Thanks,
KeB
       
Post is unread #9 Feb 22, 2009, 3:38 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

victim->hit / victim->max_hit

This will always be zero if both are integers due to integer division. What I would do is do double division, then multiply by 100, and only then come back to ints.
       
Post is unread #10 Feb 22, 2009, 10:23 pm
Go to the top of the page
Go to the bottom of the page

Kasji
Apprentice
GroupMembers
Posts62
JoinedDec 23, 2007

Yes do as David says. Like so:
percent = (int) ( ( (double) vict->hit ) / ( (double) vict->max_hit ) * 100.0 )

That should work out.
       
Pages:<< prev 1 next >>