Can someone help me with this?

Posted by Toy on Fri 27 Aug 2004 11:06 PM — 5 posts, 23,801 views.

#0
I'm just looking over some of the stock smaug spells and I ran into a question:

ch_ret spell_fireball( int sn, int level, CHAR_DATA *ch, void *vo )
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    static const sh_int dam_each[] =
    {
	  0,
	  0,   0,   0,   0,   0,	  0,   0,   0,   0,   0,
	  0,   0,   0,   0,  30,	 35,  40,  45,  50,  55,
	 60,  65,  70,  75,  80,	 82,  84,  86,  88,  90,
	 92,  94,  96,  98, 100,	102, 104, 106, 108, 110,
    112, 114, 116, 118, 120,    122, 124, 126, 128, 130,
    132, 134, 136, 138, 140,    142, 144, 146, 148, 150,
    152, 154, 156, 158, 160,    162, 164, 166, 168, 170
    };
    int dam;

    level	= UMIN(level, sizeof(dam_each)/sizeof(dam_each[0]) - 1);
    level	= UMAX(0, level);
    dam		= number_range( dam_each[level] / 2, dam_each[level] * 2 );
    if ( saves_spell_staff( level, victim ) )
	dam /= 2;
    return damage( ch, victim, dam, sn );
}


What are the static constants for the dam_each based on? Levels or just random numbers are picked.

Toy
Canada #1
As far as I know, its just random numbers, it seems kinda wasteful to m.
#2
That's what I thought. Thanks. :)

-Toy
#3
*laughs* bet you can't tell that'd I've basically tough myself how to code by this question.. :p

dam = dice( level, 6 );

Ok, for this, it means the dice rolled is the character's level rolled by 6-sided die? I'm getting a bit confused with the stock coded spells and the way the stock help files are written.

Toy

PS- I got accepted into a technical institute for Software and Application Programmin! Finally will learn how to code right. :)
USA #4
Yes, dice(level,6) is saying "roll 6 sided dice equal to casters level". As for the fireball spell, I've always hated stuff like that because it's seriously over complicated.