void do_plantbug( CHAR_DATA * ch, char *argument ) { CHAR_DATA *victim; BUG_DATA *pbug; BUG_DATA *cbug; OBJ_DATA *obj; bool checkbug = FALSE; int schance; if( IS_NPC( ch ) ) return; if( ( victim = get_char_room( ch, argument ) ) == NULL ) { send_to_char( "They aren't here.\n\r", ch ); return; } if( IS_NPC( victim ) ) { send_to_char( "You can't bug NPC's!\n\r", ch ); return; } if( IS_IMMORTAL( victim ) ) { send_to_char( "Don't try to plant bugs on immortals.\n\r", ch ); return; } if( in_arena( ch ) ) { send_to_char( "You're here to FIGHT, not spy.\n\r", ch ); return; } if( ch == victim ) { send_to_char( "You can't bug yourself!\n\r", ch ); return; } for( obj = ch->last_carrying; obj; obj = obj->prev_content ) if( obj->item_type == ITEM_BUG ) checkbug = TRUE; if( checkbug == FALSE ) { send_to_char( "You don't have any bugs to plant.\n\r", ch ); return; } for( cbug = victim->first_bug; cbug; cbug = cbug->next_in_bug ) if( !str_cmp( ch->name, cbug->name ) ) { send_to_char( "You have already planted a bug on this person.\n\r", ch ); return; } schance = number_percent( ) - UMIN( 0, ( get_curr_lck( ch ) - 14 ) ) + UMIN( 0, ( get_curr_lck( victim ) - 13 ) ); if( schance < ch->pcdata->learned[gsn_plantbug] ) { act( AT_WHITE, "You carefully reach into $N's pocket and place a bug.", ch, NULL, victim, TO_CHAR ); CREATE( pbug, BUG_DATA, 1 ); pbug->name = ch->name; LINK( pbug, victim->first_bug, victim->last_bug, next_in_bug, prev_in_bug ); learn_from_success( ch, gsn_plantbug ); for( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if( obj->item_type == ITEM_BUG ) { separate_obj( obj ); obj_from_char( obj ); extract_obj( obj ); break; } } return; } else { send_to_char( "&RYou try to find a pocket to plant the bug in but fail!\n\r", ch ); learn_from_failure( ch, gsn_plantbug ); if( number_bits( 0 ) == 0 ) ch_printf( victim, "You feel a slight brush against your pocket to find %s's hand there.\n\r", PERS( ch, victim ) ); return; } }
void do_sharpen( CHAR_DATA * ch, char *argument ) { OBJ_DATA *obj; OBJ_DATA *pobj; char arg[MAX_INPUT_LENGTH]; AFFECT_DATA *paf; int percent; int level; one_argument( argument, arg ); if( arg[0] == '\0' ) { send_to_char( "What do you wish to sharpen?\r\n", ch ); return; } if( ms_find_obj( ch ) ) return; if( !( obj = get_obj_carry( ch, arg ) ) ) { send_to_char( "You do not have that weapon.\r\n", ch ); return; } if( obj->item_type != ITEM_WEAPON ) { send_to_char( "You can't sharpen something that's not a weapon.\r\n", ch ); return; } /* * Let's not allow people to sharpen bludgeons and the like ;) */ /* * small mods to make it more generic.. --Cronel */ if( obj->value[3] != DAM_HIT && obj->value[3] != DAM_SLICE && obj->value[3] != DAM_STAB && obj->value[3] != DAM_SLASH && obj->value[3] != DAM_CLAW && obj->value[3] != DAM_BITE && obj->value[3] != DAM_PIERCE ) { send_to_char( "You can't sharpen that type of weapon!\r\n", ch ); return; } if( obj->value[5] == 1 ) /* see reason below when setting */ { send_to_char( "It is already as sharp as it's going to get.\r\n", ch ); return; } for( pobj = ch->first_carrying; pobj; pobj = pobj->next_content ) { if( pobj->pIndexData->vnum == OBJ_VNUM_SHARPEN ) break; } if( !pobj ) { send_to_char( "You do not have a sharpening stone.\r\n", ch ); return; } WAIT_STATE( ch, skill_table[gsn_sharpen]->beats ); /* * Character must have the dexterity to sharpen the weapon nicely, * * if not, damage weapon */ if( !IS_NPC( ch ) && get_curr_dex( ch ) < 17 ) { separate_obj( obj ); if( obj->value[0] <= 1 ) { act( AT_OBJECT, "$p breaks apart and falls to the ground in pieces!.", ch, obj, NULL, TO_CHAR ); extract_obj( obj ); learn_from_failure( ch, gsn_sharpen ); return; } else { obj->value[0]--; act( AT_GREEN, "You clumsily slip and damage $p!", ch, obj, NULL, TO_CHAR ); return; } } percent = ( number_percent( ) - get_curr_lck( ch ) - 15 ); /* too low a chance to damage? */ separate_obj( pobj ); if( !IS_NPC( ch ) && percent > ch->pcdata->learned[gsn_sharpen] ) { act( AT_OBJECT, "You fail to sharpen $p correctly, damaging the stone.", ch, obj, NULL, TO_CHAR ); if( pobj->value[0] <= 1 ) { act( AT_OBJECT, "The sharpening stone crumbles apart from misuse.", ch, pobj, NULL, TO_CHAR ); extract_obj( pobj ); learn_from_failure( ch, gsn_sharpen ); return; } pobj->value[0]--; learn_from_failure( ch, gsn_sharpen ); return; } level = ch->level; separate_obj( obj ); act( AT_SKILL, "With skill and precision, you sharpen $p to a fine edge.", ch, obj, NULL, TO_CHAR ); act( AT_SKILL, "With skill and precision, $n sharpens $p.", ch, obj, NULL, TO_ROOM ); CREATE( paf, AFFECT_DATA, 1 ); paf->type = -1; paf->duration = -1; paf->location = APPLY_DAMROLL; paf->modifier = level / 10; xCLEAR_BITS( paf->bitvector ); /* changed to ext BVs in upgrade --Cronel */ LINK( paf, obj->first_affect, obj->last_affect, next, prev ); obj->value[5] = 1; /* * originaly a sharpened object flag was used, but took up a BV, * * so I switched to giving it a value5, which is not used in weapons * * besides to check for this */ learn_from_success( ch, gsn_sharpen ); return; }
void do_bind( CHAR_DATA * ch, char *argument ) { OBJ_DATA *obj; OBJ_DATA *tobj; int schance; CHAR_DATA *victim; bool checkbinders = FALSE; if( argument[0] == '\0' ) { send_to_char( "Syntax: Bind <victim>\n\r", ch ); return; } if( ( victim = get_char_room( ch, argument ) ) == NULL ) { send_to_char( "They are not here.\n\r", ch ); return; } if( victim == ch ) { send_to_char( "You can not bind yourself!\n\r", ch ); return; } if( IS_NPC( victim ) ) { send_to_char( "You can only bind players.\n\r", ch ); return; } if( IS_SET( victim->pcdata->act2, ACT_BOUND ) ) { send_to_char( "They've already been bound!\n\r", ch ); return; } for( obj = ch->last_carrying; obj; obj = obj->prev_content ) if( obj->item_type == ITEM_BINDERS ) { checkbinders = TRUE; break; } if( checkbinders == FALSE ) { send_to_char( "You don't have any binders to bind them with.\n\r", ch ); return; } if( victim->position != POS_STUNNED && victim->position != POS_SLEEPING ) { send_to_char( "They need to be stunned or asleep.\n\r", ch ); return; } schance = ( int )( ch->pcdata->learned[gsn_bind] ); if( number_percent( ) < schance ) { separate_obj( obj ); obj_from_char( obj ); obj_to_char( obj, victim ); act( AT_WHITE, "You quickly bind $N's wrists.", ch, NULL, victim, TO_CHAR ); act( AT_WHITE, "$n quickly binds your wrists.", ch, NULL, victim, TO_VICT ); act( AT_WHITE, "$n quickly binds $N's wrists.", ch, NULL, victim, TO_NOTVICT ); tobj = get_eq_char( ch, WEAR_BOTH_WRISTS ); if( tobj ) unequip_char( ch, tobj ); equip_char( victim, obj, WEAR_BOTH_WRISTS ); SET_BIT( victim->pcdata->act2, ACT_BOUND ); learn_from_success( ch, gsn_bind ); } else { send_to_char( "You peer at the binders, curious upon how to use them.\n\r", ch ); learn_from_failure( ch, gsn_bind ); } return; }
void do_unbind( CHAR_DATA * ch, char *argument ) { OBJ_DATA *obj; bool checkbinders = FALSE; char buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; if( IS_NPC( ch ) ) { send_to_char( "You're a mob.\n\r", ch ); return; } if( argument[0] == '\0' ) { send_to_char( "Syntax: Unbind <victim>\n\r", ch ); return; } if( ( victim = get_char_room( ch, argument ) ) == NULL ) { send_to_char( "They aren't here.\n\r", ch ); return; } if( victim == ch ) { send_to_char( "You can not unbind yourself!\n\r", ch ); return; } if( IS_NPC( victim ) ) { send_to_char( "You can only unbind players.\n\r", ch ); return; } if( IS_SET( ch->pcdata->act2, ACT_BOUND ) ) { send_to_char( "Nice try. You're bound yourself!\n\r", ch ); return; } if( !IS_SET( victim->pcdata->act2, ACT_BOUND ) ) { send_to_char( "But they're not bound.\n\r", ch ); return; } obj = get_eq_char( victim, WEAR_BOTH_WRISTS ); if( obj ) unequip_char( victim, obj ); else { send_to_char( "Something went wrong. get an imm.\n\r", ch ); sprintf( buf, "%s unbinding %s: has no bothwrists object!", ch->name, victim->name ); bug( buf ); return; } for( obj = victim->last_carrying; obj; obj = obj->prev_content ) if( obj->item_type == ITEM_BINDERS ) { checkbinders = TRUE; break; } if( checkbinders == FALSE ) { bug( "Unbind: no binders in victims inventory." ); send_to_char( "Something went wrong. get an imm.\n\r", ch ); return; } separate_obj( obj ); obj_from_char( obj ); obj_to_char( obj, ch ); act( AT_WHITE, "You quickly unbind $N's wrists.", ch, NULL, victim, TO_CHAR ); act( AT_WHITE, "$n quickly unbinds your wrists.", ch, NULL, victim, TO_VICT ); act( AT_WHITE, "$n quickly unbinds $N's wrists.", ch, NULL, victim, TO_NOTVICT ); REMOVE_BIT( victim->pcdata->act2, ACT_BOUND ); }
void do_buy( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; int maxgold; bool debit; OBJ_DATA *obj; argument = one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Buy what?\n\r", ch ); return; } if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) ) { char buf[MAX_STRING_LENGTH]; CHAR_DATA *pet; ROOM_INDEX_DATA *pRoomIndexNext; ROOM_INDEX_DATA *in_room; if ( argument[0] == '\0' ) debit = FALSE; else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) ) { bool has_card = FALSE; for ( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if ( obj->item_type == ITEM_DEBIT_CARD ) has_card = TRUE; } if ( has_card == TRUE ) debit = TRUE; else { send_to_char( "You don't even have your card with you!\n\r", ch ); return; } } if ( IS_NPC(ch) ) return; pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 ); if ( !pRoomIndexNext ) { bug( "Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum ); send_to_char( "Sorry, you can't buy that here.\n\r", ch ); return; } in_room = ch->in_room; ch->in_room = pRoomIndexNext; pet = get_char_room( ch, arg ); ch->in_room = in_room; if ( pet == NULL || !IS_NPC( pet ) || !IS_SET(pet->act, ACT_PET) ) { send_to_char( "Sorry, you can't buy that here.\n\r", ch ); return; } if (( ch->gold < 10 * pet->top_level * pet->top_level ) && debit == FALSE) { send_to_char( "You can't afford it.\n\r", ch ); return; } else if ( (ch->pcdata->bank < 10 * pet->top_level * pet->top_level) && debit == TRUE ) { send_to_char( "You dont have enough money in your bank account for it.\n\r", ch ); return; } maxgold = 10 * pet->top_level * pet->top_level; if ( debit == FALSE ) ch->gold -= maxgold; /* this was already here, btw */ else ch->pcdata->bank -= maxgold; boost_economy( ch->in_room->area, maxgold ); pet = create_mobile( pet->pIndexData ); SET_BIT(pet->act, ACT_PET); SET_BIT(pet->affected_by, AFF_CHARM); argument = one_argument( argument, arg ); if ( arg[0] != '\0' ) { sprintf( buf, "%s %s", pet->name, arg ); STRFREE( pet->name ); pet->name = STRALLOC( buf ); } sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r", pet->description, ch->name ); STRFREE( pet->description ); pet->description = STRALLOC( buf ); char_to_room( pet, ch->in_room ); add_follower( pet, ch ); send_to_char( "Enjoy your pet.\n\r", ch ); act( AT_ACTION, "$n bought $N as a pet.", ch, NULL, pet, TO_ROOM ); return; } else { CHAR_DATA *keeper; int cost; int noi = 1; /* Number of items */ sh_int mnoi = 20; /* Max number of items to be bought at once */ if ( ( keeper = find_keeper( ch ) ) == NULL ) return; maxgold = keeper->top_level * 10; if ( is_number( arg ) ) { noi = atoi( arg ); argument = one_argument( argument, arg ); if ( noi > mnoi ) { act( AT_TELL, "$n tells you 'I don't sell that many items at" " once.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } } if ( argument[0] == '\0' ) debit = FALSE; else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) ) { bool has_card = FALSE; for ( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if ( obj->item_type == ITEM_DEBIT_CARD ) has_card = TRUE; } if ( has_card == TRUE ) debit = TRUE; else { send_to_char( "You don't even have your card with you!\n\r", ch ); return; } } obj = get_obj_carry( keeper, arg ); if ( !obj && arg[0] == '#' ) { int onum, oref; bool ofound = FALSE; onum =0; oref = atoi(arg+1); for ( obj = keeper->last_carrying; obj; obj = obj->prev_content ) { if ( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) ) onum++; if ( onum == oref ) { ofound = TRUE; break; } else if ( onum > oref ) break; } if (!ofound) obj = NULL; } if (keeper->home != NULL && obj->cost > 0) cost= obj->cost; cost = ( get_cost( ch, keeper, obj, TRUE ) * noi ); if( !IS_NPC(ch) && ch->pcdata->learned[gsn_bargain] > 0 && ch->pcdata->learned[gsn_bargain] > number_percent()) { ch_printf(ch,"You are able to bargain from %d credits to %d credits!\n\r", cost, (cost/3)+(cost/2)); cost = (cost/3) + (cost/2); if(number_percent() > 50) learn_from_success(ch, gsn_bargain); } if ( cost <= 0 || !can_see_obj( ch, obj ) ) { act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) ) { interpret( keeper, "laugh" ); act( AT_TELL, "$n tells you 'I don't have enough of those in stock" " to sell more than one at a time.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if ( ch->gold < cost && debit == FALSE) { act( AT_TELL, "$n tells you 'You can't afford to buy $p.'", keeper, obj, ch, TO_VICT ); ch->reply = keeper; return; } if ( ch->pcdata->bank < cost && debit == TRUE) { send_to_char( "You are almost slide your card through, but you remember you don't have enough money!\n\r", ch ); return; } if ( IS_SET(obj->extra_flags, ITEM_PROTOTYPE) && get_trust( ch ) < LEVEL_IMMORTAL ) { act( AT_TELL, "$n tells you 'This is a only a prototype! I can't sell you that...'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if ( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) ) { send_to_char( "You can't carry that many items.\n\r", ch ); return; } if ( ch->carry_weight + ( get_obj_weight( obj ) * noi ) + (noi > 1 ? 2 : 0) > can_carry_w( ch ) ) { send_to_char( "You can't carry that much weight.\n\r", ch ); return; } if ( noi == 1 ) { if ( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) ) separate_obj( obj ); act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM ); act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR ); } else { sprintf( arg, "$n buys %d $p%s.", noi, ( obj->short_descr[strlen(obj->short_descr)-1] == 's' ? "" : "s" ) ); act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM ); sprintf( arg, "You buy %d $p%s.", noi, ( obj->short_descr[strlen(obj->short_descr)-1] == 's' ? "" : "s" ) ); act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR ); act( AT_ACTION, "$N puts them into a bag and hands it to you.", ch, NULL, keeper, TO_CHAR ); } if ( debit == FALSE ) ch->gold -= cost; /* this line was already here, btw */ else if ( debit == TRUE ) ch->pcdata->bank -= cost; keeper->gold += cost; if ( keeper->gold > maxgold ) { boost_economy( keeper->in_room->area, keeper->gold - maxgold/2 ); keeper->gold = maxgold/2; act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM ); } if ( IS_OBJ_STAT( obj, ITEM_INVENTORY ) ) { OBJ_DATA *buy_obj, *bag; buy_obj = create_object( obj->pIndexData, obj->level ); /* * Due to grouped objects and carry limitations in SMAUG * The shopkeeper gives you a bag with multiple-buy, * and also, only one object needs be created with a count * set to the number bought. -Thoric */ if ( noi > 1 ) { bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ), 1 ); /* perfect size bag ;) */ bag->value[0] = bag->weight + (buy_obj->weight * noi); buy_obj->count = noi; obj->pIndexData->count += (noi - 1); numobjsloaded += (noi - 1); obj_to_obj( buy_obj, bag ); obj_to_char( bag, ch ); } else obj_to_char( buy_obj, ch ); } else { obj_from_char( obj ); obj_to_char( obj, ch ); } return; } }
void do_sell( CHAR_DATA *ch, char *argument ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; CHAR_DATA *keeper; OBJ_DATA *obj; int cost; one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char( "Sell what?\n\r", ch ); return; } if ( ( keeper = find_keeper( ch ) ) == NULL ) return; if ( ( obj = get_obj_carry( ch, arg ) ) == NULL ) { act( AT_TELL, "$n tells you 'You don't have that item.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } /* Bug report and solution thanks to [email protected] */ if ( !can_see_obj( keeper, obj) ) { send_to_char("What are you trying to sell me? I don't buy thin air!\n\r", ch ); return; } if ( !can_drop_obj( ch, obj ) ) { send_to_char( "You can't let go of it!\n\r", ch ); return; } if ( obj->timer > 0 ) { act( AT_TELL, "$n tells you, '$p is depreciating in value too quickly...'", keeper, obj, ch, TO_VICT ); return; } if ( ( cost = get_cost( ch, keeper, obj, FALSE ) ) <= 0 ) { act( AT_ACTION, "$n looks uninterested in $p.", keeper, obj, ch, TO_VICT ); return; } if ( cost > keeper->gold ) { act( AT_TELL, "$n makes a credit transaction.", keeper, obj, ch, TO_VICT ); lower_economy( ch->in_room->area, cost-keeper->gold ); } separate_obj( obj ); act( AT_ACTION, "$n sells $p.", ch, obj, NULL, TO_ROOM ); sprintf( buf, "You sell $p for %d credit%s.", cost, cost == 1 ? "" : "s" ); act( AT_ACTION, buf, ch, obj, NULL, TO_CHAR ); ch->gold += cost; keeper->gold -= cost; if ( keeper->gold < 0 ) keeper->gold = 0; if ( obj->item_type == ITEM_TRASH ) extract_obj( obj ); else if ( IS_SET( obj->extra_flags , ITEM_CONTRABAND) ) { long ch_exp; ch_exp = UMIN( obj->cost*10 , ( exp_level( ch->skill_level[SMUGGLING_ABILITY]+1) - exp_level( ch->skill_level[SMUGGLING_ABILITY]) ) / 10 ); ch_printf( ch, "You receive %ld smuggling experience for unloading your contraband.\n\r " , ch_exp ); gain_exp( ch, ch_exp , SMUGGLING_ABILITY ); if ( obj->item_type == ITEM_SPICE || obj->item_type == ITEM_RAWSPICE ) extract_obj( obj ); else { REMOVE_BIT( obj->extra_flags , ITEM_CONTRABAND ); obj_from_char( obj ); obj_to_char( obj, keeper ); } } else if ( obj->item_type == ITEM_SPICE || obj->item_type == ITEM_RAWSPICE ) extract_obj( obj ); else { obj_from_char( obj ); obj_to_char( obj, keeper ); } return; }
bool spec_customs_spice(CHAR_DATA * ch) { CHAR_DATA *victim; CHAR_DATA *v_next; OBJ_DATA *obj; char buf[MAX_STRING_LENGTH]; long ch_exp; if (!IS_AWAKE(ch) || ch->position == POS_FIGHTING) return FALSE; for (victim = ch->in_room->first_person; victim; victim = v_next) { v_next = victim->next_in_room; if (IS_NPC(victim) || victim->position == POS_FIGHTING) continue; for (obj = victim->last_carrying; obj; obj = obj->prev_content) { if (obj->pIndexData->item_type == ITEM_SPICE || obj->pIndexData->item_type == ITEM_RAWSPICE) { if (victim != ch && can_see(ch, victim) && can_see_obj(ch, obj)) { sprintf(buf, "%s is illegal contraband. I'm going to have to confiscate that.", obj->short_descr); do_say(ch, buf); if (obj->wear_loc != WEAR_NONE) remove_obj(victim, obj->wear_loc, TRUE); separate_obj(obj); obj_from_char(obj); act(AT_ACTION, "$n confiscates $p from $N.", ch, obj, victim, TO_NOTVICT); act(AT_ACTION, "$n takes $p from you.", ch, obj, victim, TO_VICT); obj = obj_to_char(obj, ch); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You lose %ld experience. \n\r", ch_exp); gain_exp(victim, 0 - ch_exp, SMUGGLING_ABILITY); return TRUE; } else if (can_see(ch, victim) && !IS_SET(obj->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s. \n\r", ch_exp, obj->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); act(AT_ACTION, "$n looks at $N suspiciously.", ch, NULL, victim, TO_NOTVICT); act(AT_ACTION, "$n look at you suspiciously.", ch, NULL, victim, TO_VICT); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); return TRUE; } else if (!IS_SET (obj->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(obj->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s. \n\r", ch_exp, obj->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); SET_BIT(obj->extra_flags, ITEM_CONTRABAND); return TRUE; } } else if (obj->item_type == ITEM_CONTAINER) { OBJ_DATA *content; for (content = obj->first_content; content; content = content->next_content) { if (content->pIndexData->item_type == ITEM_SPICE && !IS_SET(content->extra_flags, ITEM_CONTRABAND)) { ch_exp = UMIN(content->cost * 10, (exp_level (victim-> skill_level [SMUGGLING_ABILITY] + 1) - exp_level(victim-> skill_level [SMUGGLING_ABILITY]))); ch_printf(victim, "You receive %ld experience for smuggling %s.\n\r ", ch_exp, content->short_descr); gain_exp(victim, ch_exp, SMUGGLING_ABILITY); SET_BIT(content->extra_flags, ITEM_CONTRABAND); return TRUE; } } } } } return FALSE; }
void do_mposet( CHAR_DATA * ch, const char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; OBJ_DATA *obj; char outbuf[MAX_STRING_LENGTH]; int value, tmp; /* * A desc means switched.. too many loopholes if we allow that.. */ if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc ) { send_to_char( "Huh?\r\n", ch ); return; } smash_tilde( argument ); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH ); if ( !*arg1 ) { progbug( "MpOset: no args", ch ); return; } if ( ( obj = get_obj_here( ch, arg1 ) ) == NULL ) { progbug( "MpOset: no object", ch ); return; } if ( IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) ) { progbug( "MpOset: can't set prototype items", ch ); return; } separate_obj( obj ); value = atoi( arg3 ); if ( !str_cmp( arg2, "value0" ) || !str_cmp( arg2, "v0" ) ) { obj->value[0] = value; return; } if ( !str_cmp( arg2, "value1" ) || !str_cmp( arg2, "v1" ) ) { obj->value[1] = value; return; } if ( !str_cmp( arg2, "value2" ) || !str_cmp( arg2, "v2" ) ) { obj->value[2] = value; return; } if ( !str_cmp( arg2, "value3" ) || !str_cmp( arg2, "v3" ) ) { obj->value[3] = value; return; } if ( !str_cmp( arg2, "value4" ) || !str_cmp( arg2, "v4" ) ) { obj->value[4] = value; return; } if ( !str_cmp( arg2, "value5" ) || !str_cmp( arg2, "v5" ) ) { obj->value[5] = value; return; } if ( !str_cmp( arg2, "type" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no type", ch ); return; } value = get_otype( argument ); if ( value < 1 ) { progbug( "MpOset: Invalid type", ch ); return; } obj->item_type = ( short ) value; return; } if ( !str_cmp( arg2, "flags" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no flags", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_oflag( arg3 ); if ( value < 0 || value >= MAX_BITS ) progbug( "MpOset: Invalid flag", ch ); else { if ( value == ITEM_PROTOTYPE ) progbug( "MpOset: can't set prototype flag", ch ); else xTOGGLE_BIT( obj->extra_flags, value ); } } return; } if ( !str_cmp( arg2, "wear" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no wear", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_wflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpOset: Invalid wear", ch ); else TOGGLE_BIT( obj->wear_flags, 1 << value ); } return; } if ( !str_cmp( arg2, "level" ) ) { obj->level = value; return; } if ( !str_cmp( arg2, "weight" ) ) { obj->weight = value; return; } if ( !str_cmp( arg2, "cost" ) ) { obj->cost = value; return; } if ( !str_cmp( arg2, "timer" ) ) { obj->timer = value; return; } if ( !str_cmp( arg2, "name" ) ) { STRFREE( obj->name ); obj->name = STRALLOC( arg3 ); return; } if ( !str_cmp( arg2, "short" ) ) { STRFREE( obj->short_descr ); obj->short_descr = STRALLOC( arg3 ); if ( obj == supermob_obj ) { STRFREE( supermob->short_descr ); supermob->short_descr = QUICKLINK( obj->short_descr ); } /* * Feature added by Narn, Apr/96 * * If the item is not proto, add the word 'rename' to the keywords * * if it is not already there. */ if ( str_infix( "mprename", obj->name ) ) { snprintf( buf, MAX_STRING_LENGTH, "%s %s", obj->name, "mprename" ); STRFREE( obj->name ); obj->name = STRALLOC( buf ); } return; } if ( !str_cmp( arg2, "long" ) ) { STRFREE( obj->description ); mudstrlcpy( buf, arg3, MAX_STRING_LENGTH ); obj->description = STRALLOC( buf ); return; } if ( !str_cmp( arg2, "actiondesc" ) ) { if ( strstr( arg3, "%n" ) || strstr( arg3, "%d" ) || strstr( arg3, "%l" ) ) { progbug( "MpOset: Illegal actiondesc", ch ); return; } STRFREE( obj->action_desc ); obj->action_desc = STRALLOC( arg3 ); return; } if ( !str_cmp( arg2, "affect" ) ) { AFFECT_DATA *paf; short loc; int bitv; argument = one_argument( argument, arg2 ); if ( arg2[0] == '\0' || !argument || argument[0] == 0 ) { progbug( "MpOset: Bad affect syntax", ch ); send_to_char( "Usage: oset <object> affect <field> <value>\r\n", ch ); return; } loc = get_atype( arg2 ); if ( loc < 1 ) { progbug( "MpOset: Invalid affect field", ch ); return; } if ( loc >= APPLY_AFFECT && loc < APPLY_WEAPONSPELL ) { bitv = 0; while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); if ( loc == APPLY_AFFECT ) value = get_aflag( arg3 ); else value = get_risflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpOset: bad affect flag", ch ); else SET_BIT( bitv, 1 << value ); } if ( !bitv ) return; value = bitv; } else { argument = one_argument( argument, arg3 ); value = atoi( arg3 ); } CREATE( paf, AFFECT_DATA, 1 ); paf->type = -1; paf->duration = -1; paf->location = loc; paf->modifier = value; xCLEAR_BITS( paf->bitvector ); paf->next = NULL; LINK( paf, obj->first_affect, obj->last_affect, next, prev ); ++top_affect; return; } if ( !str_cmp( arg2, "rmaffect" ) ) { AFFECT_DATA *paf; short loc, count; if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no rmaffect", ch ); return; } loc = atoi( argument ); if ( loc < 1 ) { progbug( "MpOset: Invalid rmaffect", ch ); return; } count = 0; for ( paf = obj->first_affect; paf; paf = paf->next ) { if ( ++count == loc ) { UNLINK( paf, obj->first_affect, obj->last_affect, next, prev ); DISPOSE( paf ); send_to_char( "Removed.\r\n", ch ); --top_affect; return; } } progbug( "MpOset: rmaffect not found", ch ); return; } /* * save some finger-leather */ if ( !str_cmp( arg2, "ris" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "r" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "i" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "s" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "ri" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "rs" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "is" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } /* * Make it easier to set special object values by name than number * -Thoric */ tmp = -1; switch ( obj->item_type ) { case ITEM_WEAPON: if ( !str_cmp( arg2, "weapontype" ) ) { unsigned int x; value = -1; for ( x = 0; x < sizeof( attack_table ) / sizeof( attack_table[0] ); x++ ) if ( !str_cmp( arg3, attack_table[x] ) ) value = x; if ( value < 0 ) { progbug( "MpOset: Invalid weapon type", ch ); return; } tmp = 3; break; } if ( !str_cmp( arg2, "condition" ) ) tmp = 0; break; case ITEM_ARMOR: if ( !str_cmp( arg2, "condition" ) ) tmp = 3; if ( !str_cmp( arg2, "ac" ) ) tmp = 1; break; case ITEM_SALVE: if ( !str_cmp( arg2, "slevel" ) ) tmp = 0; if ( !str_cmp( arg2, "maxdoses" ) ) tmp = 1; if ( !str_cmp( arg2, "doses" ) ) tmp = 2; if ( !str_cmp( arg2, "delay" ) ) tmp = 3; if ( !str_cmp( arg2, "spell1" ) ) tmp = 4; if ( !str_cmp( arg2, "spell2" ) ) tmp = 5; if ( tmp >= 4 && tmp <= 5 ) value = skill_lookup( arg3 ); break; case ITEM_SCROLL: case ITEM_POTION: case ITEM_PILL: if ( !str_cmp( arg2, "slevel" ) ) tmp = 0; if ( !str_cmp( arg2, "spell1" ) ) tmp = 1; if ( !str_cmp( arg2, "spell2" ) ) tmp = 2; if ( !str_cmp( arg2, "spell3" ) ) tmp = 3; if ( tmp >= 1 && tmp <= 3 ) value = skill_lookup( arg3 ); break; case ITEM_STAFF: case ITEM_WAND: if ( !str_cmp( arg2, "slevel" ) ) tmp = 0; if ( !str_cmp( arg2, "spell" ) ) { tmp = 3; value = skill_lookup( arg3 ); } if ( !str_cmp( arg2, "maxcharges" ) ) tmp = 1; if ( !str_cmp( arg2, "charges" ) ) tmp = 2; break; case ITEM_CONTAINER: if ( !str_cmp( arg2, "capacity" ) ) tmp = 0; if ( !str_cmp( arg2, "cflags" ) ) tmp = 1; if ( !str_cmp( arg2, "key" ) ) tmp = 2; break; case ITEM_SWITCH: case ITEM_LEVER: case ITEM_PULLCHAIN: case ITEM_BUTTON: if ( !str_cmp( arg2, "tflags" ) ) { tmp = 0; value = get_trigflag( arg3 ); } break; } if ( tmp >= 0 && tmp <= 3 ) { obj->value[tmp] = value; return; } progbug( "MpOset: Invalid field", ch ); return; }
void do_sell( CHAR_DATA * ch, char *argument ) { char buf[MAX_STRING_LENGTH]; char arg[MAX_INPUT_LENGTH]; CHAR_DATA *keeper = NULL; OBJ_DATA *obj = NULL; int cost = 0; one_argument( argument, arg ); if( arg[0] == '\0' ) { send_to_char( "Sell what?\r\n", ch ); return; } if( ( keeper = find_keeper( ch ) ) == NULL ) return; if( ( obj = get_obj_carry( ch, arg ) ) == NULL ) { act( AT_TELL, "$n tells you 'You don't have that item.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if( !can_drop_obj( ch, obj ) ) { send_to_char( "You can't let go of it!\r\n", ch ); return; } if( obj->timer > 0 ) { act( AT_TELL, "$n tells you, '$p is depreciating in value too quickly...'", keeper, obj, ch, TO_VICT ); return; } if( ( cost = get_cost( ch, keeper, obj, FALSE ) ) <= 0 ) { act( AT_ACTION, "$n looks uninterested in $p.", keeper, obj, ch, TO_VICT ); return; } if( cost > keeper->gold ) { act( AT_TELL, "$n makes a credit transaction.", keeper, obj, ch, TO_VICT ); } separate_obj( obj ); act( AT_ACTION, "$n sells $p.", ch, obj, NULL, TO_ROOM ); sprintf( buf, "You sell $p for %d credit%s.", cost, cost == 1 ? "" : "s" ); act( AT_ACTION, buf, ch, obj, NULL, TO_CHAR ); ch->gold += cost; keeper->gold -= cost; if( keeper->gold < 0 ) keeper->gold = 0; if( obj->item_type == ITEM_TRASH ) extract_obj( obj ); else { obj_from_char( obj ); obj_to_char( obj, keeper ); } return; }
bool spec_wanderer( CHAR_DATA *ch ) { OBJ_DATA *trash; OBJ_DATA *trash_next; OBJ_DATA *obj2; ROOM_INDEX_DATA *was_in_room; EXIT_DATA *pexit = NULL; CHAR_DATA *vch; int door; int chance=50; bool found = FALSE; /* Valid direction */ bool thrown = FALSE;/* Whether to be thrown or not */ bool noexit = TRUE; /* Assume there is no valid exits */ was_in_room = ch->in_room; if ( !IS_AWAKE(ch) ) return FALSE; if((pexit = ch->in_room->first_exit) !=NULL) noexit=FALSE; if(chance>number_percent()){ /**** * Look for objects on the ground and pick it up ****/ for ( trash = ch->in_room->first_content; trash; trash = trash_next ) { trash_next = trash->next_content; if ( !IS_SET( trash->wear_flags, ITEM_TAKE ) || IS_OBJ_STAT( trash, ITEM_BURIED ) ) continue; if ( trash->item_type == ITEM_WEAPON || trash->item_type == ITEM_ARMOR || trash->item_type == ITEM_LIGHT ) { separate_obj( trash ); /* So there is no 'sword <6>' gets only one object off ground */ act( AT_ACTION, "$n leans over and gets $p.", ch, trash, NULL, TO_ROOM ); obj_from_room( trash ); trash = obj_to_char( trash, ch ); /***** * If object is too high a level throw it away. *****/ if ( ch->level < trash->level ) { act( AT_ACTION, "$n tries to use $p, but is too inexperienced.",ch, trash, NULL, TO_ROOM ); thrown = TRUE; } /***** * Wear the object if it is not to be thrown. The FALSE is passed * so that the mob wont remove a piece of armor already there * if it is not worn it is assumed that they can't use it or * they already are wearing something. *****/ if(!thrown) wear_obj( ch, trash, FALSE, -1 ); /***** * Look for an object in the inventory that is not being worn * then throw it away... *****/ found=FALSE; if(!thrown) for ( obj2 = ch->first_carrying; obj2; obj2 = obj2->next_content ){ if (obj2->wear_loc == WEAR_NONE){ do_say(ch,"Hmm, I can't use this."); trash=obj2; thrown=TRUE; } } /***** * Ugly bit of code.. * Checks if the object is to be thrown & there is a valid exit, * randomly pick a direction to throw it, and check to make sure no other * spec_wanderer mobs are in that room. *****/ if(thrown && !noexit) while(!found && !noexit){ door=number_door(); if((pexit = get_exit(ch->in_room,door) ) != NULL && pexit->to_room && !IS_SET(pexit->exit_info, EX_CLOSED) && !xIS_SET(pexit->to_room->room_flags, ROOM_NODROP)){ if( (vch = pexit->to_room->first_person) !=NULL) for( vch = pexit->to_room->first_person; vch; vch = vch->next_in_room){ if (!str_cmp(lookup_spec(vch->spec_fun), "spec_wanderer")){ noexit = TRUE; /*act( AT_CYAN,"$n spec_wanderer inroom $T", ch, NULL,dir_name[pexit->vdir], TO_ROOM);*/ return FALSE; } } found = TRUE; } } if (!noexit && thrown){ /*if (trash->value*/ set_cur_obj( trash ); if( damage_obj( trash ) != rOBJ_SCRAPPED){ separate_obj(trash); act( AT_ACTION, "$n growls and throws $p $T.", ch, trash, dir_name[pexit->vdir], TO_ROOM ); obj_from_char( trash ); obj_to_room( trash, pexit->to_room ); char_from_room(ch); char_to_room(ch, pexit->to_room); act( AT_CYAN,"$p thrown by $n lands in the room.",ch, trash, ch, TO_ROOM); char_from_room(ch); char_to_room(ch, was_in_room); } else{ do_say(ch,"This thing is junk!"); act( AT_ACTION, "$n growls and breaks $p.",ch, trash, NULL, TO_ROOM); } return TRUE; } return TRUE; } } /* get next obj */ return FALSE; /* No objects :< */ } return FALSE; }
void do_buy( CHAR_DATA * ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; int maxgold = 0; argument = one_argument( argument, arg ); if( arg[0] == '\0' ) { send_to_char( "Buy what?\r\n", ch ); return; } /* in case of different shop types */ { CHAR_DATA *keeper = NULL; OBJ_DATA *obj = NULL; int cost = 0; int noi = 1; /* Number of items */ short mnoi = 20; /* Max number of items to be bought at once */ if( ( keeper = find_keeper( ch ) ) == NULL ) return; maxgold = keeper->top_level * 10; if( is_number( arg ) ) { noi = atoi( arg ); argument = one_argument( argument, arg ); if( noi > mnoi ) { act( AT_TELL, "$n tells you 'I don't sell that many items at" " once.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } } obj = get_obj_carry( keeper, arg ); if( !obj && arg[0] == '#' ) { int onum = 0, oref = atoi( arg + 1 ); bool ofound = FALSE; for( obj = keeper->last_carrying; obj; obj = obj->prev_content ) { if( obj->wear_loc == WEAR_NONE && can_see_obj( ch, obj ) ) onum++; if( onum == oref ) { ofound = TRUE; break; } else if( onum > oref ) break; } if( !ofound ) obj = NULL; } cost = ( get_cost( ch, keeper, obj, TRUE ) * noi ); if( cost <= 0 || !can_see_obj( ch, obj ) ) { act( AT_TELL, "$n tells you 'I don't sell that -- try 'list'.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) && ( noi > 1 ) ) { char buf[MAX_STRING_LENGTH]; snprintf( buf, MAX_STRING_LENGTH, "%s", "laugh" ); interpret( keeper, buf ); act( AT_TELL, "$n tells you 'I don't have enough of those in stock" " to sell more than one at a time.'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if( ch->gold < cost ) { act( AT_TELL, "$n tells you 'You can't afford to buy $p.'", keeper, obj, ch, TO_VICT ); ch->reply = keeper; return; } if( IS_SET( obj->extra_flags, ITEM_PROTOTYPE ) && IS_IMMORTAL( ch ) ) { act( AT_TELL, "$n tells you 'This is a only a prototype! I can't sell you that...'", keeper, NULL, ch, TO_VICT ); ch->reply = keeper; return; } if( ch->carry_number + get_obj_number( obj ) > can_carry_n( ch ) ) { send_to_char( "You can't carry that many items.\r\n", ch ); return; } if( ch->carry_weight + ( get_obj_weight( obj ) * noi ) + ( noi > 1 ? 2 : 0 ) > can_carry_w( ch ) ) { send_to_char( "You can't carry that much weight.\r\n", ch ); return; } if( noi == 1 ) { if( !IS_OBJ_STAT( obj, ITEM_INVENTORY ) ) separate_obj( obj ); act( AT_ACTION, "$n buys $p.", ch, obj, NULL, TO_ROOM ); act( AT_ACTION, "You buy $p.", ch, obj, NULL, TO_CHAR ); } else { sprintf( arg, "$n buys %d $p%s.", noi, ( obj->short_descr[strlen( obj->short_descr ) - 1] == 's' ? "" : "s" ) ); act( AT_ACTION, arg, ch, obj, NULL, TO_ROOM ); sprintf( arg, "You buy %d $p%s.", noi, ( obj->short_descr[strlen( obj->short_descr ) - 1] == 's' ? "" : "s" ) ); act( AT_ACTION, arg, ch, obj, NULL, TO_CHAR ); act( AT_ACTION, "$N puts them into a bag and hands it to you.", ch, NULL, keeper, TO_CHAR ); } ch->gold -= cost; keeper->gold += cost; if( keeper->gold > maxgold ) { keeper->gold = maxgold / 2; act( AT_ACTION, "$n puts some credits into a large safe.", keeper, NULL, NULL, TO_ROOM ); } if( IS_OBJ_STAT( obj, ITEM_INVENTORY ) ) { OBJ_DATA *buy_obj = create_object( obj->pIndexData ); OBJ_DATA *bag = NULL; /* * Due to grouped objects and carry limitations in SMAUG * The shopkeeper gives you a bag with multiple-buy, * and also, only one object needs be created with a count * set to the number bought. -Thoric */ if( noi > 1 ) { bag = create_object( get_obj_index( OBJ_VNUM_SHOPPING_BAG ) ); /* perfect size bag ;) */ bag->value[0] = bag->weight + ( buy_obj->weight * noi ); buy_obj->count = noi; obj->pIndexData->count += ( noi - 1 ); numobjsloaded += ( noi - 1 ); obj_to_obj( buy_obj, bag ); obj_to_char( bag, ch ); } else obj_to_char( buy_obj, ch ); } else { obj_from_char( obj ); obj_to_char( obj, ch ); } return; } }
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 = 88; 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_BACK ); 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 ); }
/* The effectiveness of the modules can vary depending on the level of the technitian's makemodule skill */ void do_makemodule( CHAR_DATA *ch, char *argument ) { char arg[MAX_INPUT_LENGTH]; int affecttype, affectammount; char name[MAX_STRING_LENGTH]; int level, chance; bool checklens, checkbat, checksuper, checkcircuit, checktool; OBJ_DATA *obj; OBJ_INDEX_DATA *pObjIndex; argument = one_argument( argument, arg ); switch( ch->substate ) { default: if(str_cmp(arg, "hull") && str_cmp( arg, "slave") && str_cmp( arg, "tractor") && str_cmp(arg, "torpedo") && str_cmp(arg, "rocket") && str_cmp(arg, "missile") && str_cmp(arg, "primary") && str_cmp(arg, "secondary") && str_cmp(arg, "shield") && str_cmp(arg, "speed") && str_cmp(arg, "hyperspeed") && str_cmp(arg, "energy") && str_cmp(arg, "manuever") && str_cmp(arg, "chaff") && str_cmp(arg, "alarm")){ send_to_char("Modules may affect the following aspects of the ship:\n\rPrimary, Secondary, Missile, Rocket, Torpedo, Hull, Shield, Speed, Hyperspeed, Energy, Manuever, Slave, Tractor, Chaff, and Alarm.\n\r", ch); return; } checklens = FALSE; checkbat = FALSE; checksuper = FALSE; checkcircuit = FALSE; checktool = 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_LENS) checklens = TRUE; if (obj->item_type == ITEM_BATTERY) checkbat = TRUE; if (obj->item_type == ITEM_SUPERCONDUCTOR) checksuper = TRUE; if (obj->item_type == ITEM_CIRCUIT) checkcircuit = TRUE; if (obj->item_type == ITEM_TOOLKIT) checktool = TRUE; } if ( !checklens ) { send_to_char( "&RYou need a lens to control the energy.\n\r", ch); return; } if ( !checkbat ) { send_to_char( "&RYou need a battery to power the module.\n\r", ch); return; } if ( !checksuper ) { send_to_char( "&RYou need a superconductor to focus the energy.\n\r", ch); return; } if ( !checkcircuit ) { send_to_char( "&RYou need a circuit board to control the module.\n\r", ch); return; } if ( !checktool ) { send_to_char( "&RYou need a toolkit to build the module.\n\r", ch); return; } chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_makemodule]); if ( number_percent( ) < chance ) { send_to_char( "&GYou begin the long process of creating a module.\n\r", ch); act( AT_PLAIN, "$n takes $s tools and begins to work.", ch, NULL, argument , TO_ROOM ); add_timer ( ch , TIMER_DO_FUN , 10 , do_makemodule , 1 ); ch->dest_buf = str_dup(arg); return; } send_to_char("&RYou can't figure out what to do.\n\r",ch); learn_from_failure( ch, gsn_makemodule ); 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_makemodule]); if ( ( pObjIndex = get_obj_index( MODULE_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; } checklens = FALSE; checkbat = FALSE; checksuper = FALSE; checkcircuit = FALSE; checktool = FALSE; for ( obj = ch->last_carrying; obj; obj = obj->prev_content ) { if (obj->item_type == ITEM_TOOLKIT) checktool = TRUE; if (obj->item_type == ITEM_LENS && checklens == FALSE) { checklens = TRUE; separate_obj( obj ); obj_from_char( obj ); } if (obj->item_type == ITEM_BATTERY && checkbat == FALSE) { checkbat = TRUE; separate_obj( obj ); obj_from_char( obj ); } if (obj->item_type == ITEM_SUPERCONDUCTOR && checksuper == FALSE) { checksuper = TRUE; separate_obj( obj ); obj_from_char( obj ); } if (obj->item_type == ITEM_CIRCUIT && checkcircuit == FALSE) { checkcircuit = TRUE; separate_obj( obj ); obj_from_char( obj ); } } chance = IS_NPC(ch) ? ch->top_level : (int) (ch->pcdata->learned[gsn_makemodule]) ; if ( number_percent( ) > chance*2 || ( !checklens ) || ( !checktool ) || ( !checkbat ) || ( !checksuper ) || ( !checkcircuit ) ) { send_to_char( "&RYou hold up your newly created module.\n\r", ch); send_to_char( "&RThe module begins to shake violently turning red hot!\n\r", ch); send_to_char( "&RYou drop it as it begins to burn your hand and then.. It disintigrates!\n\r", ch); learn_from_failure( ch, gsn_makemodule ); return; } if(!str_cmp(arg, "primary")){ affecttype = AFFECT_PRIMARY; affectammount = 1; strcpy(name, "A Primary Weapons Module"); } if(!str_cmp(arg, "secondary")){ affecttype = AFFECT_SECONDARY; affectammount = 1; strcpy(name, "A Secondary Weapons Module"); } if(!str_cmp(arg, "slave")) { affecttype = AFFECT_SLAVE; affectammount = (level / 4); strcpy(name, "A Slave Module"); } if(!str_cmp(arg, "tractor")) { affecttype = AFFECT_TRACTOR; affectammount = 1; strcpy(name, "A Tractor Beam Module"); } if(!str_cmp(arg, "missile")){ affecttype = AFFECT_MISSILE; affectammount = (level / 20); strcpy(name, "A Missile Module"); } if(!str_cmp(arg, "rocket")){ affecttype = AFFECT_ROCKET; affectammount = (level / 20); strcpy(name, "A Rocket Module"); } if(!str_cmp(arg, "torpedo")){ affecttype = AFFECT_TORPEDO; affectammount = (level / 20); strcpy(name, "A Torpedo Module"); } if(!str_cmp(arg, "hull")){ affecttype = AFFECT_HULL; affectammount = (level / 2); strcpy(name, "A Hull Module"); } if(!str_cmp(arg, "shield")){ affecttype = AFFECT_SHIELD; affectammount = (level/5); strcpy(name, "A Shield Module"); } if(!str_cmp(arg, "speed")){ affecttype = AFFECT_SPEED; affectammount = (level / 10); strcpy(name, "A Speed Module"); } if(!str_cmp(arg, "hyperspeed")){ affecttype = AFFECT_HYPER; affectammount = 1; strcpy(name, "A Hyperspeed Module"); } if(!str_cmp(arg, "energy")){ affecttype = AFFECT_ENERGY; affectammount = (level * 5); strcpy(name, "An Energy Module"); } if(!str_cmp(arg, "manuever")){ affecttype = AFFECT_MANUEVER; affectammount = (level / 10); strcpy(name, "A Manuever Module"); } if(!str_cmp(arg, "alarm")) { affecttype = AFFECT_ALARM; affectammount = 1; strcpy(name, "An Alarm Module"); } if(!str_cmp(arg, "chaff")) { affecttype = AFFECT_CHAFF; affectammount = URANGE(1,(level / 33), 3); strcpy(name, "A Chaff Module"); } obj = create_object( pObjIndex, level ); obj->item_type = ITEM_MODULE; SET_BIT( obj->wear_flags, ITEM_TAKE ); obj->level = level; STRFREE( obj->name ); obj->name = STRALLOC( name ); STRFREE( obj->short_descr ); obj->short_descr = STRALLOC( name ); STRFREE( obj->description ); strcat( name, " was dropped here." ); obj->description = STRALLOC( name ); obj->value[0] = affecttype; obj->value[1] = affectammount; obj->value[2] = 0; obj->cost = (level * affecttype * affectammount); obj = obj_to_char( obj, ch ); send_to_char( "&GYou finish your work and hold up your newly created module.&w\n\r", ch); act( AT_PLAIN, "$n finishes creating a new module.", ch, NULL, argument , TO_ROOM ); { long xpgain; xpgain = ((ch->skill_level[TECHNICIAN_ABILITY]+1) * 200); gain_exp(ch, xpgain, TECHNICIAN_ABILITY); ch_printf( ch , "You gain %d technician experience.", xpgain ); } learn_from_success( ch, gsn_makemodule ); }
/* * Function finds out if a seed will grow into something else. */ void seed_grow_check(OBJ_DATA *obj) { OBJ_DATA *obj_temp; int chance = 0; int count = 0; // Initial checks to ditch out, object must exist, room must exist // and the seed must be buried. Also no growing in certain sectors // should an item somehow get buried there. if (obj == NULL || obj->in_room == NULL || obj->item_type != ITEM_SEED || !IS_OBJ_STAT(obj, ITEM_BURIED)) { return; } // Places it should never be buried. if (obj->in_room->sector_type == SECT_INSIDE || obj->in_room->sector_type == SECT_WATER_SWIM || obj->in_room->sector_type == SECT_WATER_NOSWIM || obj->in_room->sector_type == SECT_UNDERWATER || obj->in_room->sector_type == SECT_AIR) { bugf("Item buried in a sector_type (%d) it shouldn't be at room %d", obj->in_room->sector_type, obj->in_room->vnum); return; } // If the object doesn't have a vnum set to grow, report it, extract it. if (obj->value[0] == 0) { bugf("Seed vnum %d does not have a vnum set for the item to grow, extracting object.", obj->pIndexData->vnum); separate_obj(obj); extract_obj(obj); return; } // Setup the base chance based off of sector type of the room it's planted in. switch (obj->in_room->sector_type) { case SECT_DESERT: chance -= 75; break; case SECT_BEACH: chance -= 50; break; case SECT_FIELD: chance += 35; break; case SECT_MOUNTAIN: chance -= 15; break; case SECT_HILLS: case SECT_FOREST: chance += 25; break; default: chance = 0; break; } if (IS_OBJ_STAT(obj, ITEM_BLESS)) { chance += 5; } if (IS_OBJ_STAT(obj, ITEM_GLOW)) { chance += 5; } if (IS_OBJ_STAT(obj, ITEM_EVIL)) { chance -= 5; } // Add the immortal initial set chance plus randomness. chance += obj->value[1]; chance += number_range(1, 20); // Count any other seeds that might be buried in the room. for (obj_temp = obj->in_room->contents; obj_temp; obj_temp = obj_temp->next_content) { if (obj_temp->item_type == ITEM_SEED && IS_OBJ_STAT(obj_temp, ITEM_BURIED)) { count++; } } // The more seeds that are planted the less chance any will grow. if (count > 3) { chance -= (3 * count); } // Seeds have a greaater chance of growing during the day. if (IS_DAY()) { chance += 15; } else { chance -= 15; } // Always at least 1 percent chance, always a chance for failure chance = URANGE(1, chance, 95); // The moment of truth. if (!CHANCE(chance)) { return; } // Remove the buried bit, it's going to get extracted but we want people to be able // to see it's short description in the act message and they won't unless it's not buried. separate_obj(obj); REMOVE_BIT(obj->extra_flags, ITEM_BURIED); // Show the room that something has sprouted. if (obj->in_room != NULL && obj->in_room->people != NULL) { act("$p sprouts and grows from the ground!", obj->in_room->people, obj, NULL, TO_ALL); } // Create the new object that has been grown, set it's intiial values and // put it in the room. obj_temp = create_object(get_obj_index(obj->value[0])); obj_to_room(obj_temp, obj->in_room); obj_temp->cost = ((obj->cost * 3) / 2); obj_temp->timer = number_range(75, 200); // Life span of the grown item // Extract the seed (it's already been separated, it's job in this world is complete. extract_obj(obj); return; }
/* * Turn an object into scraps. -Thoric */ void make_scraps( OBJ_DATA * obj ) { char buf[MAX_STRING_LENGTH]; OBJ_DATA *scraps, *tmpobj; CHAR_DATA *ch = NULL; separate_obj( obj ); scraps = create_object( get_obj_index( OBJ_VNUM_SCRAPS ), 0 ); scraps->timer = number_range( 5, 15 ); /* * don't make scraps of scraps of scraps of ... */ if( obj->pIndexData->vnum == OBJ_VNUM_SCRAPS ) { STRFREE( scraps->short_descr ); scraps->short_descr = STRALLOC( "some debris" ); STRFREE( scraps->description ); scraps->description = STRALLOC( "Bits of debris lie on the ground here." ); } else { snprintf( buf, MAX_STRING_LENGTH, scraps->short_descr, obj->short_descr ); STRFREE( scraps->short_descr ); scraps->short_descr = STRALLOC( buf ); snprintf( buf, MAX_STRING_LENGTH, scraps->description, obj->short_descr ); STRFREE( scraps->description ); scraps->description = STRALLOC( buf ); } if( obj->carried_by ) { act( AT_OBJECT, "$p falls to the ground in scraps!", obj->carried_by, obj, NULL, TO_CHAR ); if( obj == get_eq_char( obj->carried_by, WEAR_WIELD ) && ( tmpobj = get_eq_char( obj->carried_by, WEAR_DUAL_WIELD ) ) != NULL ) tmpobj->wear_loc = WEAR_WIELD; obj_to_room( scraps, obj->carried_by->in_room ); } else if( obj->in_room ) { if( ( ch = obj->in_room->first_person ) != NULL ) { act( AT_OBJECT, "$p is reduced to little more than scraps.", ch, obj, NULL, TO_ROOM ); act( AT_OBJECT, "$p is reduced to little more than scraps.", ch, obj, NULL, TO_CHAR ); } obj_to_room( scraps, obj->in_room ); } if( ( obj->item_type == ITEM_CONTAINER || obj->item_type == ITEM_KEYRING || obj->item_type == ITEM_QUIVER || obj->item_type == ITEM_CORPSE_PC ) && obj->first_content ) { if( ch && ch->in_room ) { act( AT_OBJECT, "The contents of $p fall to the ground.", ch, obj, NULL, TO_ROOM ); act( AT_OBJECT, "The contents of $p fall to the ground.", ch, obj, NULL, TO_CHAR ); } if( obj->carried_by ) empty_obj( obj, NULL, obj->carried_by->in_room ); else if( obj->in_room ) empty_obj( obj, NULL, obj->in_room ); else if( obj->in_obj ) empty_obj( obj, obj->in_obj, NULL ); } extract_obj( obj ); }