ID:150008
 
ok... heres my prob
every 2 strength you gain, u get a +1 str mod(modifier) thus my code:

mob
var
Str
strmod
proc/attbonus()
if(Str ==1)
strmod -= 5
if(Str == 2)
strmod -= 4
if(Str == 3)
strmod -= 4
if(Str == 4)
strmod -= 3
if(Str == 5)
strmod -= 3
if(Str == 6)
strmod -= 2
if(Str == 7)
strmod -= 2
if(Str == 8)
strmod -= 1
if(Str == 9)
strmod -= 1
if(Str == 10)
strmod = 0

and so on.....

i know there has got to be an easier way to write this to add the mod automatically any suggestions? Thanks
-Darien
According to your code, try :
strmod -= round((11 - Str)/2)

This will still subtract everytime you call attbonus(). Those subtractions would accumulate.

[Warning: Entering talking-out-of-my-butt-about-design-I-have-not-seen section.]

If that's bad use:
strmod = -round((11 - Str)/2)

This would set the value. If attbonus() is the only thing that affects strmod, then do this. However, any changes to strmod outside of attbonus() would be forgotten with the new strmod value.

If you have any other things that affect strmod and you know what Str was before the change, you could remove the former value and modify by the current Str. Something to the point of:
strmod += round((11 - oldStr)/2)
strmod -= round((11 - Str)/2)

Alternatively, you could use a separate variable to store what things outside of attbonus() do to strmod. The strmod in attbonus() would use strmod = -round((11 - Str)/2). Then you could add the two whenever you want the real value. This is what I'd use.

*shrug* I have not seen what you do with the code though so what do I know?
ACWraith's suggestion of using a formula is best. If you prefer to use something based more on a table than a formula, however, you also have this option:
var/list/_strmod_table=list(-5,-4,-4,-3,-3,....)

proc/attbonus()
if(str>_strmod_table.len) strmod=0
else strmod=_strmod_table[str]
return strmod

To my mind you're better off with a formula, which you can adjust more easily.

Lummox JR
In response to ACWraith
cool.. ill sit down and play with it and see what i come up with, it will end up bein for several things such as
the attackbonus formula is
Base attack bonus + Strength mod + size modifier

i realize once i sit down and actually want to get this done ill will have to change a few vars, but i think if i can get this formula figured out i "think" ill have enough to get the rest
same formula will also apply for Dex, Con, Wis, Int
its D&D 3rd edt. rules

thanks again :)
-Darien
In response to Darien41
o well..i finally got it to work lol ended up being

verb/show_Str()
if(Str <=11)
strmod = round(-((11-Str)/2)-(1/2)) // since 11 str = 0 mod, ill want to give the mod a negative # such as -4
else
strmod = round(((Str-11)/2)+(1/2)) // this is to give the mod a positive #

had to subtract the .5 to get the numbers to round right, thanks again bro :D

Here is another question... say you wanted like a 10x10 tile area to turn into a fighting turf, assuming i was using the eventloop.dm of daedron's would it be possible to make the area inside that cube to go into combat rounds (slow down time in the area and not the rest of the world)?

-Darien