Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Changing mob hitnodice

Changing mob hitnodice

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


Posted by Orik   USA  (182 posts)  Bio
Date Sun 15 Jul 2007 12:31 AM (UTC)
Message
Ok, so if a mob doesn't have hitnodice then it automatically creates its own hp pertaining to it's level. I'm trying to give it a different hp amount if it doesn't have it's own hitnodice. I've come up with a problem where when I make I get this warning:



db.c: In function `CHAR_DATA* create_mobile(MOB_INDEX_DATA*)':
db.c:2767: warning: converting to `short int' from `double'
db.c:2769: warning: converting to `short int' from `double'
make[1]: *** [o/db.o] Error 1
make: *** [all] Error 2


db.c in create_mobile
I put double x; at the top of the function.


   if( !pMobIndex->hitnodice )
   {
		  x = number_range(16, 18) + number_range (1, 3);
		  mob->max_hit =  mob->level * x; <----2767
		  x = (mob->level * .01) * 6;
		  mob->max_hit += (int) mob->max_hit * x; <-------2769
   }
   else
      mob->max_hit = pMobIndex->hitnodice * number_range( 1, pMobIndex->hitsizedice ) + pMobIndex->hitplus;
   mob->hit = mob->max_hit;   


Why is it trying to convert? and how would it be fixed?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Sun 15 Jul 2007 12:38 AM (UTC)
Message
For the first warning, the right-hand side is of type double (int * double --> double), so you need to cast it to short int.
mob->max_hit = (short) (mob->level * x);

For the second warning, you aren't actually casting the whole expression; the cast is very tight-binding so you just get the hp converted. You want to cast the whole thing:
mob->max_hit += (short) (mob->max_hit * x);

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Orik   USA  (182 posts)  Bio
Date Reply #2 on Sun 15 Jul 2007 12:42 AM (UTC)

Amended on Sun 15 Jul 2007 12:53 AM (UTC) by Orik

Message
I'm putting the shorts in there and still getting exact same warning.


***EDIT****

My bad, i forgot to put the Parentheses around the mob stuff. It's working now.
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.


11,801 views.

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

Go to topic:           Search the forum


[Go to top] top

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