Ok Heres what i'm trying to do.  I want to make it so that magic users
spells have a chance of doing a second and third hit.  This is because I
have uped the number of attacks done by other class skills such at circle to
go off of second/third/fourth attack etc... I actually think I know how to
write the skill (pretty much copy all the instances of second attack leaving
out most of the parts in fight.c) however i will need to write 2 new
functions to process this.  The best way to ask for help i think was to
snippet up what i have done so far.  and ask if anyone could help me where I
am falling short.

A problem that I forsee is the fact that spells don't have gsn's so am stuck
having to make a gsn for every spell i have or is there a better way to do
this.  Again thanks in advance for your help

Mallek

------------------Code for multi casting begins here Don't try to install
------------------ this as it will almost indoubtably not work

--pertinant information--
ROM 2.4b6
Lopes Color
OLC
Running on linux box
201 mortal levels
--end pertinant information (if you need more just ask)--

--tables.c-- (give this to mobs)
in (const struct flag_type off_flags[] =) add

    {   "second_cast",          Z,      TRUE    },
    {   "third_cast",           aa,      TRUE    },

--merc.h-- (OFF defines)
under declerations in fight.c section add prototypes for new functions

void    multi_cast      args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );
void    single_cast     args( ( CHAR_DATA *ch, CHAR_DATA *victim, int dt ) );

under /* OFF bits for mobiles */ add

#define OFF_SECOND_CAST         (Z)
#define OFF_THIRD_CAST          (aa)

in other gsn's add

extern  sh_int  gsn_second_cast;
extern  sh_int  gsn_third_cast;

--handler.c--
Not sure this is needed however I wanted all mobs to be able to do all
skills
so I changed the skill returns in get_skill for mobs to this

    else /* mobiles */
    {
        if(ch->level < 1)
        skill = 80;
        else
        skill = number_range(80 + (ch->level/20), 90 + (ch->level/20)); }

    }
        else
        skill = 0;
    }

--const.c--
Add entry for the skills in the skill_table
only giving it to mage for testing

    {
    "second cast",
    { 50, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203  },
    { 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  },
    spell_null,             TAR_IGNORE,             POS_FIGHTING,
    &gsn_second_cast,      SLOT( 0),        0,     0,
    "",                    "!Second cast!",     "",
    },

    {
    "third cast",
    { 100, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203  },
    { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    spell_null,             TAR_IGNORE,      POS_FIGHTING,
    &gsn_third_cast,        SLOT( 0),        0,     0,
    "",                     "!Third Cast!",      "",
    },

--db.c--
Add on gsn's here

sh_int                  gsn_second_cast;
sh_int                  gsn_third_cast;

--fight.c--
Now's the hard part. here I am lost hehe however here is what I have so far
multi_cast i think is ok it's the single cast that needs alot/alittle work

void multi_cast( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{
    int     chance;

    /* decrement the wait */
    if (ch->desc == NULL)
        ch->wait = UMAX(0,ch->wait - PULSE_VIOLENCE);

    if (ch->desc == NULL)
        ch->daze = UMAX(0,ch->daze - PULSE_VIOLENCE);


    /* no attacks for stunnies -- just a check */
    if (ch->position < POS_RESTING)
        return;


        /*  comented this out because I don't know if i need a mob_cast
function
         *  if needed code it and this is how i should call it
         *  reason for this is because of change in handler.c to get_skill
for mobs
    if (IS_NPC(ch))
    {
        mob_cast(ch,victim,dt);
        return;
    }   */

    single_cast( ch, victim, dt, FALSE );


    if (ch->fighting != victim)
        return;

    chance = get_skill(ch,gsn_second_cast)/2;

    if ( number_percent( ) < chance )
    {
        single_cast( ch, victim, dt, FALSE );
        check_improve(ch,gsn_second_cast,TRUE,2);
        if ( ch->fighting != victim )
        return;
    }

    chance = get_skill(ch,gsn_third_cast)/3;

    if ( number_percent( ) < chance )
    {
        single_cast( ch, victim, dt, FALSE );
        check_improve(ch,gsn_third_cast,TRUE,6);
        if ( ch->fighting != victim )
        return;
    }

    return;
}


/* Ok this part here is very incomplete so please no ridicule :P
 * this is the part where i think i need the help (unless you see something
else)
 */

void single_cast( CHAR_DATA *ch, CHAR_DATA *victim, int dt )
{

    int dam;
    int diceroll;
    int sn,skill;
    int dam_type;
    bool result;

    sn = -1;


    /* just in case */
    if (victim == ch || ch == NULL || victim == NULL)
        return;

    /*
     * Can't beat a dead char!
     * Guard against weird room-leavings.
     */
    if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
        return;

    /*
     * The moment of excitement!
     */

        /* Miss. */
    chance = get_skill(ch,sn)

    if(chance > 75)
    chance = number_range(80 + (ch->level/20), 90 + (ch->level/20);

    if (number_percent() > chance)
    {
        damage( ch, victim, 0, dt, dam_type, TRUE );
        tail_chain( );
        return;
    }

    /*
     * Hit.
     * Calc damage.
     */

     dam = number_range( ch->level / 2, ch->level * 3 / 2 );

     /* How would i add in bonuses for damage doen from spells
        * would you think it better to calc the damage in the spell
        * then just do the damage here? or should i calc it here like
        * in one_hit
        */


     if (get_eq_char(ch,WEAR_SHIELD) == NULL)  /* no shield = more */
         dam = dam * 11/10;


    /*
     * Bonuses.
     */


    if ( get_skill(ch,gsn_enhanced_damage) > 0 )
    {
        diceroll = number_percent();
        if (diceroll <= get_skill(ch,gsn_enhanced_damage))
        {
            check_improve(ch,gsn_enhanced_damage,TRUE,6);
            dam += 2 * ( dam * diceroll/300);
        }
    }


    if ( !IS_AWAKE(victim) )
        dam *= 2;
     else if (victim->position < POS_FIGHTING)
        dam = dam * 3 / 2;

    }

    damage( ch, victim, dam, dt, dam_type, TRUE );

    tail_chain( );
    return;
}



Reply via email to