Author - Famine <admin@malicex.org> <AOL/AIM : ifamiinie>
Codebase - Rogue25b2 <http://www.mudmagic.com>
Date - Tuesday, October 26th 2004
Type - Snippet: RP Blackjack Skill
 
-----Desc-----
This is a snippet for a skill called "Blackjack".
So you might be asking yourself what a "Blackjack" is?
A "Blackjack" is sorta like sock with a rock in it.
More advance types are cloth with a hard iron ball or even lead-filled sack.
This type of weapon is used for knocking people out. I think it works well =)
This snippet is a function that will sleep your victims.
Unlike some blackjack skills ive seen, this one uses the item in the skill.
So in this snippet you will be adding the skill_function "Blackjack", the AFF_BLACKJACK,
and the ITEM_BLACKJACK to your roguebase. This will help give  you an
idea on what most of these tables hold and how you can use them for other
nifty skills/systems. 

The skill itself uses "Dex", "Level you/victim", "Blackjack Held", and "Sneak"
to function. I made it this way for rogue classes to be able to sleep and use
steal. If the class has low DEX and not sneaking when they try to blackjack
then they will fail and enter battle. The cost of the skill is 50 move on
sucess and 20 move on fail. Hope you enjoy!


-----Installing-----
Hint - Do not copy the " " in the code. This is used to highlight the line.
Hint - If for example a defined number is taken (#define ITEM_PORTAL            40) then use 41 for "#define ITEM_BLACKJACK          41"

Part 1 - merc.h
Step 1: Open file "merc.h"
Step 2: Find this line "#define ITEM_V_WINDOW           39"
Step 3: Insert this line after it "#define ITEM_BLACKJACK          40"
Step 4: Find this line "extern sh_int  gsn_watch;"
Step 5: Insert this line after it "extern sh_int  gsn_blackjack;"
Step 6: Find this line "#define AFF_DRUNK       (1 << 1)        // Fool is seriously intoxicated!"
Step 7: Insert this line after it "#define AFF_BLACKJACK   (1 << 2)"
Step 8: Close merc.h

Part 2 - db.cpp <So OLC will save it>
Step 1: Open file "db.cpp"
Step 2: Find the line "ITEM_JEWELRY"
Step 3: Insert this line under it "    case ITEM_BLACKJACK:"
Step 4: Find the line "gsn_watch"
Step 5: Inster this under it "sh_int                  gsn_blackjack"
Step 6: Close db.cpp

Part 3 - const.cpp <Defining what class gets this skill>
Step 1: Find the line "ITEM_V_WINDOW"
Step 2: Insert this under it "    {   ITEM_BLACKJACK, "blackjack"     },"
Step 3: Find "do_backstab".
Step 4: Insert this under the backstab define.

    {
        "blackjack",        {51, 51, 51, 51, 51, 51, 51, 51}, {4, 4, 4, 4, 4, 4, 4, 4},
        spell_null,     TAR_IGNORE,     POS_STANDING,
        &gsn_blackjack,     SLOT(0),        0,      12,
        "",             "You feel less sleepy",   ""
    },

Step 5: Edit the coloums to set levels per class and creation points per class.
Step 6: Close const.cpp

Part 3 - tables.cpp
Step 1: Open tables.cpp
Step 2: Find the line "    {   "v_window",             ITEM_V_WINDOW,          TRUE    },"
Step 3: Insert this under it "    {   ITEM_BLACKJACK, "blackjack"     },"
Step 4: Find this line "    {   "drunk",                AFF_DRUNK,              TRUE    },"
Step 5: Insert this under it "    {   "blackjack",            AFF_BLACKJACK,          TRUE    },"
Step 4: Close tables.cpp

Part 4 - act_move.cpp
Step 1: Open act_move.cpp
Step 2: Find "do_wake" function
Step 3: Add this somewhere in the function


    if (IS_AFFECTED(ch, AFF_BLACKJACK))
    { send_to_char("YOU ARE STILL BLACKJACKED!\n\r",ch); return; }

Step 4: Close act_move.cpp



Part 5 - fight.cpp <Main code>
Step 1: Open fight.cpp
Step 2: Goto the end of this file.
Step 3: Copy and paste this in.


ACMD(do_blackjack) {
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    OBJ_DATA *obj, *blackjack;
    int chance, level;

    one_argument( argument, arg );

    if (arg[0] == '\0')
    {
        send_to_char("Blackjack who?\n\r",ch);
        return;
    }

    if ((chance = get_skill(ch,gsn_blackjack)) == 0)
    {
        send_to_char( "Blackjack? What!?\n\r", ch );
        return;
    }

    if (is_safe(ch,victim))
        return;

    if (victim == ch)
    {
        send_to_char("You can not blackjack yourself!\n\r",ch);
        return;
    }

    if (IS_AFFECTED(ch,AFF_CHARM) && ch->master == victim)
    {
        act("But $N is your friend!",ch,NULL,victim,TO_CHAR);
        return;
    }

    blackjack = get_eq_char(ch, WEAR_HOLD);

    if (blackjack == NULL || blackjack->item_type !=ITEM_BLACKJACK)
    {
      send_to_char("Must use a blackjack\n\r",ch);
      return;
    }

    if (ch->fighting != NULL)
    {
        send_to_char("You can't do that right now!\n\r",ch);
        return;
    }
    else if ((victim = get_char_room(ch,arg)) == NULL)
    {
        send_to_char("They aren't here.\n\r",ch);
        return;
    }


    if ( IS_AFFECTED(victim, AFF_BLACKJACK))
    {
        send_to_char( "They are already knocked out!\n\r", ch);
        return;
    }

    if (ch->move < 50)
    {
        send_to_char("You do not have enoug movement!\n\r", ch);
        return;
    }

    if (blackjack != NULL && blackjack->item_type == ITEM_BLACKJACK)
    {

        chance += get_curr_stat(ch,STAT_DEX);
        chance -= 2 * get_curr_stat(victim,STAT_DEX);


        chance += (ch->level - victim->level) * 2;

        if(IS_AFFECTED(ch,AFF_SNEAK))
                chance += 3;
        else
                chance -= 5;




       if(number_percent() < chance)
      {
        AFFECT_DATA af;
        ch->move -=50;

        WAIT_STATE( ch, skill_table[gsn_blackjack].beats );
        act("$N is knocked out cold!",ch,NULL,victim,TO_CHAR);
        act("$n runs behind you and knocks you out with a blackjack!",ch,NULL,victim,TO_VICT);
        act("$n runs behind $N and knocks him out cold!",ch,NULL,victim,TO_NOTVICT);
        check_improve(ch,gsn_blackjack,TRUE,1);

        af.where        = TO_AFFECTS;
        af.type         = gsn_blackjack;
        af.level        = level;
        af.duration     = 0;
        af.location     = APPLY_AC;
        af.modifier     = -20;
        af.bitvector    = AFF_BLACKJACK;
        affect_join( victim, &af );

        victim->position = POS_SLEEPING;


      }
      else
      {
        ch->move -=20;
        WAIT_STATE( ch, skill_table[gsn_blackjack].beats );
        act("Your blackjack is resisted by $N.",ch,NULL,victim,TO_CHAR);
        act("$n tries to blackjack you but you resist it.",ch,NULL,victim,TO_VICT);
        act("$n blackjack is resisted by $N",ch,NULL,victim,TO_NOTVICT);
        check_improve(ch,gsn_blackjack,FALSE,1);
        damage(ch,victim,0,gsn_blackjack,DAM_BASH,FALSE);
      }
   }

    check_killer(ch,victim);
    return;

}



Step 4: Close fight.cpp

Part 6 - command.h
Step 1: Open command.h
Step 2: Add in the do_blackjack function at the bottom.
Step 3: Close command.h
Step 4: Type make clean
Step 5: Go in your mud and copyover
Step 6: Type "cmdedit create blackjack"
Step 7: Type fun "do_blackjack" and set the settings to your prefrence.




All should compile clean unless I missed something or you screwed up :)
When this compiles you should be able to use "ITEM_BLACKJACK" in OLC for OBJECT_TYPES.
SO don't forget to make the blackjacks. I have player tested this and it works good.

To go over this simple. The math might not be what you want. So please review it and change if needed.
I hope you enjoy this code and if there is any problems please let me know. Im only human!

CheerS!
-Famine