/*******************************************************
  Makejetpack snippet:
    The jetpack item must modify flying, and have
    everything you want. All that changes is the
    name.
*******************************************************/

---------------------------------------------------------------------------------
TECH.C
---------------------------------------------------------------------------------

void do_makejetpack( CHAR_DATA *ch, char *argument )
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    int level, chance, strength;
    bool checktool, checkbatt, checkchem, checkcirc, checkmetal;
    OBJ_DATA *obj;
    OBJ_INDEX_DATA *pObjIndex;
    int vnum;

    strcpy( arg , argument );

    switch( ch->substate )
    {
    	default:
    	        if ( arg[0] == '\0' )
                {
                  send_to_char( "&RUsage: Makejetpack <Name>\n\r&w", ch);
                  return;
                }

                checktool  = FALSE;
                checkbatt  = FALSE;
                checkchem  = FALSE;
                checkcirc  = FALSE;
                checkmetal = FALSE;

                if ( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
                {
                   send_to_char( "&RYou need to be in a factory or workshop to do that.\n\r", ch);
                   return;
                }

                for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
                {
                  if (obj->item_type == ITEM_TOOLKIT)
                    checktool = TRUE;
                  if (obj->item_type == ITEM_BATTERY)
                    checkbatt = TRUE;
                  if (obj->item_type == ITEM_CIRCUIT)
                    checkcirc = TRUE;
                  if (obj->item_type == ITEM_CHEMICAL)
                    checkchem = TRUE;
                  if (obj->item_type == ITEM_RARE_METAL)
                    checkmetal = TRUE;
                }

                if ( !checktool )
                {
                   send_to_char( "&RYou need toolkit to make the Jetpack\n\r", ch);
                   return;
                }

                if ( !checkmetal )
                {
                   send_to_char( "&RYou need a piece metal to craft the Jetpack.\n\r", ch);
                   return;
                }

                if ( !checkbatt )
                {
                   send_to_char( "&RYou need a battery for the mechanism to work.\n\r", ch);
                   return;
                }

                if ( !checkcirc )
                {
                   send_to_char( "&RYou need a small circuit.\n\r", ch);
                   return;
                }

                if ( !checkchem )
                {
                   send_to_char( "&RSome chemicals for the combustion.\n\r", ch);
                   return;
                }

                chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_makejetpack]);
                if ( number_percent( ) < chance )
                {
                   send_to_char( "&GYou begin the long process of crafting a Jetpack\n\r", ch);
                   act( AT_PLAIN, "$n takes $s tools and begins to work on something.", ch, NULL, argument , TO_ROOM );
                   add_timer ( ch , TIMER_DO_FUN , 15 , do_makejetpack , 1 );
                   ch->dest_buf   = str_dup(arg);
                   return;
                }
                send_to_char("&RYou can't figure out how to fit the parts together.\n\r",ch);
                learn_from_failure( ch, gsn_makejetpack );
                return;

        case 1:
                if ( !ch->dest_buf )
                 return;
                strcpy(arg, ch->dest_buf);
                DISPOSE( ch->dest_buf);
                break;

        case SUB_TIMER_DO_ABORT:
                DISPOSE( ch->dest_buf );
                ch->substate = SUB_NONE;
                send_to_char("&RYou are interupted and fail to finish your work.\n\r", ch);
                return;
    }

    ch->substate = SUB_NONE;

    level = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_makejetpack]);
    vnum = 97;

    if ( ( pObjIndex = get_obj_index( vnum ) ) == NULL )
    {
         send_to_char( "&RThe item you are trying to create is missing from the database.\n\rPlease inform the administration of this error.\n\r", ch );
         return;
    }

    checktool = FALSE;
    checkmetal = FALSE;
    checkbatt = FALSE;
    checkchem = FALSE;
    checkcirc = FALSE;

    for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
    {
       if (obj->item_type == ITEM_TOOLKIT)
          checktool = TRUE;
       if (obj->item_type == ITEM_BATTERY && checkbatt == FALSE)
       {
          strength = obj->value[0];
          separate_obj( obj );
          obj_from_char( obj );
          extract_obj( obj );
          checkbatt = TRUE;
       }
       if (obj->item_type == ITEM_CHEMICAL)
       {
          separate_obj( obj );
          obj_from_char( obj );
          extract_obj( obj );
          checkchem = TRUE;
       }
       if (obj->item_type == ITEM_CIRCUIT && checkcirc == FALSE)
       {
          separate_obj( obj );
          obj_from_char( obj );
          extract_obj( obj );
          checkcirc = TRUE;
       }
       if (obj->item_type == ITEM_RARE_METAL && checkmetal == FALSE)
       {
          separate_obj( obj );
          obj_from_char( obj );
          extract_obj( obj );
          checkmetal = TRUE;
       }
    }

    chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_makejetpack]) ;

    if ( number_percent( ) > chance*2  || ( !checktool ) || ( !checkmetal )
         || ( !checkbatt ) || ( !checkchem ) || ( !checkcirc) )
    {
       send_to_char( "You hit the 'on' switch and watch the Jetpack explode into pieces.", ch);
       learn_from_failure( ch, gsn_makejetpack );
       return;
    }

    obj = create_object( pObjIndex, level );

    obj->item_type = ITEM_ARMOR;
    SET_BIT( obj->wear_flags, ITEM_TAKE );
    SET_BIT( obj->wear_flags, ITEM_WEAR_OBACK );
    obj->level = level;
    obj->weight = 1;
    STRFREE( obj->name );
    strcpy( buf , arg );
    obj->name = STRALLOC( buf );
    strcpy( buf, arg );
    STRFREE( obj->short_descr );
    obj->short_descr = STRALLOC( buf );
    STRFREE( obj->description );
    strcat( buf, " was left behind here." );
    obj->description = STRALLOC( buf );

    obj->value[0] = 0;
    obj->value[0] = 0;
    obj->value[0] = 0;
    obj->cost = 5000;

    obj = obj_to_char( obj, ch );

    send_to_char( "&GYou finish your work and hold up your newly created Jetpack.&w\n\r", ch);
    act( AT_PLAIN, "$n finishes making $s new Jetpack.", ch,
         NULL, argument , TO_ROOM );

    {
         long xpgain;

         xpgain = UMIN( obj->cost*100 ,
            ( exp_level(ch->skill_level[ENGINEERING_ABILITY]+1) -
              exp_level(ch->skill_level[ENGINEERING_ABILITY]) ) );
         gain_exp(ch, xpgain, ENGINEERING_ABILITY);
         ch_printf( ch , "You gain %d engineering experience.", xpgain );
    }
        learn_from_success( ch, gsn_makejetpack );
}

---------------------------------------------------------------------------------
DB.C
---------------------------------------------------------------------------------
Before:
sh_int   gsn_makejetpack;
Add:
sh_int	 gsn_makemodule;
---------------------------------------------------------------------------------
Before:
ASSIGN_GSN( gsn_makemodule   , "makemodule" );
Add:
ASSIGN_GSN( gsn_makejetpack  , "makejetpack" );
---------------------------------------------------------------------------------
MUD.H
---------------------------------------------------------------------------------
Before: extern sh_int	gsn_makemodule;
Add:    extern sh_int   gsn_makejetpack;
---------------------------------------------------------------------------------
Add where it goes: DECLARE_DO_FUN( do_makejetpack );
---------------------------------------------------------------------------------
Create an obj vnum 97 of the jetpack.



Theres two ways of doing this. Create a new wear flag of oback (over your
back)
Or just set the makejetpack to do WEAR_BACK. IF your going to use oback. Add
the following code.

---------------------------------------------------------------------------------
MUD.H
---------------------------------------------------------------------------------

After:
#define	ITEM_WEAR_BACK		BV19
#define	ITEM_WEAR_HOLSTER1	BV20
#define	ITEM_WEAR_HOLSTER2	BV21
#define	ITEM_WEAR_BOTHWRISTS	BV22

Add:
#define ITEM_OBACK              BV23
------------------------------------------------------------------
After:
WEAR_BOTH_WRISTS,
Add:
WEAR_OBACK
------------------------------------------------------------------
BUILD.C
------------------------------------------------------------------
Inside: char *	const	w_flags	[] =
After: "holster1","holster2","bothwrists",
Add:   "oback",
------------------------------------------------------------------
Inside: char *	const	wear_locs [] =
After: "missile_wield",
Add: "oback",
------------------------------------------------------------------
ACT_INFO.C
------------------------------------------------------------------
Inside: char *	const	where_name	[] =
After:  "&G&b[&wworn both wrists &b]&G&w ",
Add:    "&G&b[&wworn over back   &b]&G&w ",

------------------------------------------------------------------
ACT_OBJ.C
------------------------------------------------------------------
Inside: void wear_obj( CHAR_DATA *ch, OBJ_DATA *obj, bool fReplace, sh_int
wear_bit )
After: One of the cases.
Add:
        case ITEM_OBACK:
            if ( !remove_obj( ch, WEAR_OBACK, fReplace ) )
              return;
            if ( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
            {
             if ( !obj->action_desc || obj->action_desc[0]=='\0' )
             {
              act( AT_ACTION, "$n wears $p over $s back.",   ch, obj, NULL, TO_ROOM );
              act( AT_ACTION, "You wear $p over your back.", ch, obj, NULL, TO_CHAR );
             }
             else
              actiondesc( ch, obj, NULL );
            }
            equip_char( ch, obj, WEAR_OBACK );
            oprog_wear_trigger( ch, obj );
            return;
------------------------------------------------------------------
/system/SKILLS.DAT
------------------------------------------------------------------
After: makegrenade
Add:

#SKILL
Name         makejetpack~
Type         Skill
Flags        0
Guild        9
Code         do_makejetpack
Dammsg       ~
Wearoff      !done!~
Teachers     1097~
Minlevel     30
End
------------------------------------------------------------------
Make Clean
Make
Copyover, and your done.