Changing mob hitnodice

Posted by Orik on Sun 15 Jul 2007 12:31 AM — 3 posts, 14,545 views.

USA #0
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?
USA #1
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);
USA #2
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.