void make_corpse(struct char_data * ch) { struct obj_data *corpse, *o; struct obj_data *money; int i; corpse = create_obj(); corpse->item_number = NOTHING; IN_ROOM(corpse) = NOWHERE; corpse->name = str_dup("corpse"); sprintf(buf2, "The corpse of %s is lying here.", GET_NAME(ch)); corpse->description = str_dup(buf2); sprintf(buf2, "the corpse of %s", GET_NAME(ch)); corpse->short_description = str_dup(buf2); GET_OBJ_TYPE(corpse) = ITEM_CONTAINER; GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE; GET_OBJ_EXTRA(corpse) = ITEM_NODONATE; GET_OBJ_VAL(corpse, 0) = 0; /* You can't store stuff in a corpse */ GET_OBJ_VAL(corpse, 3) = 1; /* corpse identifier */ GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch); GET_OBJ_RENT(corpse) = 100000; if (IS_NPC(ch)) GET_OBJ_TIMER(corpse) = max_npc_corpse_time; else GET_OBJ_TIMER(corpse) = max_pc_corpse_time; /* transfer character's inventory to the corpse */ corpse->contains = ch->carrying; for (o = corpse->contains; o != NULL; o = o->next_content) o->in_obj = corpse; object_list_new_owner(corpse, NULL); /* transfer character's equipment to the corpse */ for (i = 0; i < NUM_WEARS; i++) if (GET_EQ(ch, i)) { remove_otrigger(GET_EQ(ch, i), ch); obj_to_obj(unequip_char(ch, i), corpse); } /* transfer gold */ if (GET_GOLD(ch) > 0) { /* following 'if' clause added to fix gold duplication loophole */ if (IS_NPC(ch) || (!IS_NPC(ch) && ch->desc)) { money = create_money(GET_GOLD(ch)); obj_to_obj(money, corpse); } GET_GOLD(ch) = 0; } ch->carrying = NULL; IS_CARRYING_N(ch) = 0; IS_CARRYING_W(ch) = 0; obj_to_room(corpse, IN_ROOM(ch)); }
static Money * reduce_mul( const Expression *exp, Currency to ){ Mul *mul = exp->value; Expression *multiplicand_exp = ( Expression * ) mul->multiplicand ; unsigned int multiplicand = ( ( MoneyProtected * ) reduce( multiplicand_exp, to ) )->amount; unsigned int multiplier = mul->multiplier; return create_money( multiplicand * multiplier, to ); }
static Money * reduce_sum( const Expression *exp, Currency to ){ Sum *sum = exp->value; Expression *augend_exp = ( Expression * ) sum->augend; Expression *addend_exp = ( Expression * ) sum->addend; unsigned int augend = ( ( MoneyProtected * ) reduce( augend_exp, to ) )->amount; unsigned int addend = ( ( MoneyProtected * ) reduce( addend_exp, to ) )->amount; return create_money( augend + addend, to ); }
static void event_scatter_goodies_zone(int rnum, struct room_data *rp, struct event_goodies *stuff) { int i = 0; int exit_found = 0; int gold = 0; struct char_data *monster = NULL; struct obj_data *object = NULL; struct obj_data *coins = NULL; if (DEBUG > 1) log_info("called %s with %d, %08zx, %08zx", __PRETTY_FUNCTION__, rnum, (size_t) rp, (size_t) stuff); if (!rp || rp->number < stuff->bottom || rp->number > stuff->top) return; if (IS_SET(rp->room_flags, (NO_MOB | PEACEFUL | PRIVATE))) return; exit_found = 0; for (i = 0; i < MAX_NUM_EXITS; i++) /* neswud */ if (rp->dir_option[i]) { exit_found = 1; break; } if (!exit_found) return; if (number(0, 99) >= stuff->chance) return; gold = dice(stuff->gold_dice, stuff->gold_die) + stuff->gold_mod; gold_count += gold; coins = create_money(gold); obj_to_room(coins, rnum); rprintf(rnum, "In a brilliant green flash, a pile of %s appears before you!\r\n", coins->short_description); if (number(0, 99) < stuff->mob_chance) { i = number(1, stuff->mob_count) - 1; if ((monster = read_mobile(stuff->mob_vnum[i], VIRTUAL))) { GET_GOLD(monster) = 0; mob_count++; char_to_room(monster, rnum); act("A rift of red light rips open and $N rushes out!", FALSE, monster, 0, monster, TO_ROOM); } } if (number(0, 99) < stuff->obj_chance) { i = number(1, stuff->obj_count) - 1; if ((object = read_object(stuff->obj_vnum[i], VIRTUAL))) { obj_count++; obj_to_room(object, rnum); rprintf(rnum, "In a shimmering of blue light, %s %s forms!\r\n", SANA(object), object->short_description); } } }
static Money * reduce_money( const struct Expression *exp, Currency to ) { MoneyProtected *money = exp->value; return create_money( money->amount / rate( money->currency, to ), to ); }
Expression * dollar( unsigned int amount ) { return expression_from( create_money( amount, USD ) ); }
Expression * franc( unsigned int amount ) { return expression_from( create_money( amount, CHF ) ); }
void make_corpse(struct char_data *ch) { char buf2[MAX_NAME_LENGTH + 64]; struct obj_data *corpse, *o; struct obj_data *money; int i; corpse = create_obj(); corpse->item_number = NOTHING; IN_ROOM(corpse) = NOWHERE; corpse->name = strdup("corpse"); snprintf(buf2, sizeof(buf2), "The corpse of %s is lying here.", GET_NAME(ch)); corpse->description = strdup(buf2); snprintf(buf2, sizeof(buf2), "the corpse of %s", GET_NAME(ch)); corpse->short_description = strdup(buf2); GET_OBJ_TYPE(corpse) = ITEM_CONTAINER; GET_OBJ_WEAR(corpse) = ITEM_WEAR_TAKE; GET_OBJ_EXTRA(corpse) = ITEM_NODONATE; GET_OBJ_VAL(corpse, 0) = 0; /* You can't store stuff in a corpse */ GET_OBJ_VAL(corpse, 3) = 1; /* corpse identifier */ GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch); GET_OBJ_RENT(corpse) = 100000; if (IS_NPC(ch)) GET_OBJ_TIMER(corpse) = max_npc_corpse_time; else GET_OBJ_TIMER(corpse) = max_pc_corpse_time; /* transfer character's inventory to the corpse */ corpse->contains = ch->carrying; for (o = corpse->contains; o != NULL; o = o->next_content) o->in_obj = corpse; object_list_new_owner(corpse, NULL); /* transfer character's equipment to the corpse */ for (i = 0; i < NUM_WEARS; i++) if (GET_EQ(ch, i)) obj_to_obj(unequip_char(ch, i), corpse); /* transfer gold */ if (GET_GOLD(ch) > 0) { /* * following 'if' clause added to fix gold duplication loophole * The above line apparently refers to the old "partially log in, * kill the game character, then finish login sequence" duping * bug. The duplication has been fixed (knock on wood) but the * test below shall live on, for a while. -gg 3/3/2002 */ if (IS_NPC(ch) || ch->desc) { money = create_money(GET_GOLD(ch)); obj_to_obj(money, corpse); } GET_GOLD(ch) = 0; } ch->carrying = NULL; IS_CARRYING_N(ch) = 0; IS_CARRYING_W(ch) = 0; obj_to_room(corpse, IN_ROOM(ch)); }
/* * Make a corpse out of a character. */ void make_corpse( CHAR_DATA *ch ) { char buf[MSL]={'\0'}; OBJ_DATA *corpse; OBJ_DATA *obj; OBJ_DATA *obj_next; char *name; if ( IS_NPC(ch) ) { name = ch->short_descr; corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_NPC)); corpse->timer = number_range( 3, 6 ); if ( ch->dollars > 0 ) { obj_to_obj( create_money( ch->dollars, ch->cents ), corpse ); ch->cents = 0; ch->dollars = 0; } corpse->cost = 0; } else { name = ch->name; corpse = create_object(get_obj_index(OBJ_VNUM_CORPSE_PC)); corpse->timer = number_range( 25, 40 ); corpse->owner = NULL; if (ch->dollars > 1 || ch->cents > 1) { obj_to_obj(create_money(ch->dollars / 2, ch->cents/2), corpse); ch->cents = 0; ch->dollars = 0; } corpse->cost = 0; } snprintf( buf, sizeof(buf), corpse->short_descr, name ); PURGE_DATA( corpse->short_descr ); corpse->short_descr = str_dup( buf ); snprintf( buf, sizeof(buf), corpse->description, name ); PURGE_DATA( corpse->description ); corpse->description = str_dup( buf ); PURGE_DATA( corpse->full_desc ); corpse->full_desc = str_dup( Format("The corpse of someone who in life looked like:\n\r%s", ch->description) ); if(!str_cmp(ch->material, "flesh") && !str_cmp(ch->material, "none") && (material_lookup(ch->material) != material_lookup("unknown"))) { PURGE_DATA( corpse->material ); corpse->material = str_dup(ch->material); } for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; obj_from_char( obj ); if (obj->item_type == ITEM_POTION) obj->timer = number_range(500,1000); if (obj->item_type == ITEM_SCROLL) obj->timer = number_range(1000,2500); if (IS_SET(obj->extra_flags,ITEM_ROT_DEATH)) { obj->timer = number_range(1,3); REMOVE_BIT(obj->extra_flags,ITEM_ROT_DEATH); } REMOVE_BIT(obj->extra_flags,ITEM_VIS_DEATH); if(obj != NULL) { if(IS_SET(ch->act, ACT_UMBRA)) obj_to_plane(obj, 1); if(IS_SET(ch->act, ACT_DREAMING)) obj_to_plane(obj, 2); } obj_to_obj( obj, corpse ); } if(IS_SET(ch->act, ACT_UMBRA)) obj_to_plane(corpse, 1); if(IS_SET(ch->act, ACT_DREAMING)) obj_to_plane(corpse, 2); obj_to_room( corpse, ch->in_room ); return; }
void make_corpse(struct char_data *ch) { struct obj_data *corpse, *o; struct obj_data *money; char buf[MAX_STRING_LENGTH]; int i; char *strdup(char *source); struct obj_data *create_money( int amount ); CREATE(corpse, struct obj_data, 1); clear_object(corpse); corpse->item_number = NOWHERE; corpse->in_room = NOWHERE; corpse->name = strdup("corpse"); sprintf(buf, "Corpse of %s is lying here.", (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch))); corpse->description = strdup(buf); sprintf(buf, "Corpse of %s", (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch))); corpse->short_description = strdup(buf); corpse->contains = ch->carrying; if ( (GET_GOLD(ch)>0) && ( IS_NPC(ch) || (ch->desc) ) ) { money = create_money(GET_GOLD(ch)); GET_GOLD(ch)=0; obj_to_obj(money,corpse); } corpse->obj_flags.type_flag = ITEM_CONTAINER; corpse->obj_flags.wear_flags = ITEM_TAKE; corpse->obj_flags.value[0] = 0; /* You can't store stuff in a corpse */ corpse->obj_flags.value[3] = 1; /* corpse identifyer */ corpse->obj_flags.weight = GET_WEIGHT(ch)+IS_CARRYING_W(ch); corpse->obj_flags.cost_per_day = 100000; if (IS_NPC(ch)) corpse->obj_flags.timer = MAX_NPC_CORPSE_TIME; else corpse->obj_flags.timer = MAX_PC_CORPSE_TIME; for (i=0; i<MAX_WEAR; i++) if (ch->equipment[i]) obj_to_obj(unequip_char(ch, i), corpse); ch->carrying = 0; IS_CARRYING_N(ch) = 0; IS_CARRYING_W(ch) = 0; corpse->next = object_list; object_list = corpse; for(o = corpse->contains; o; o->in_obj = corpse, o = o->next_content); object_list_new_owner(corpse, 0); obj_to_room(corpse, ch->in_room); }
/* * Make a corpse out of a character. */ OBJ_DATA *make_corpse( CHAR_DATA * ch, CHAR_DATA * killer ) { char buf[MAX_STRING_LENGTH]; OBJ_DATA *corpse; OBJ_DATA *obj; OBJ_DATA *obj_next; const char *name; if( IS_NPC( ch ) ) { name = ch->short_descr; corpse = create_object( get_obj_index( OBJ_VNUM_CORPSE_NPC ), 0 ); corpse->timer = 6; if( ch->gold > 0 ) { if( ch->in_room ) { ch->in_room->area->gold_looted += ch->gold; sysdata.global_looted += ch->gold / 100; } obj_to_obj( create_money( ch->gold ), corpse ); ch->gold = 0; } /* Cannot use these! They are used. corpse->value[0] = (int)ch->pIndexData->vnum; corpse->value[1] = (int)ch->max_hit; */ /* Using corpse cost to cheat, since corpses not sellable */ corpse->cost = ( -( int )ch->pIndexData->vnum ); corpse->value[2] = corpse->timer; } else { name = ch->name; corpse = create_object( get_obj_index( OBJ_VNUM_CORPSE_PC ), 0 ); if( in_arena( ch ) ) corpse->timer = 0; else corpse->timer = 40; corpse->value[2] = ( int )( corpse->timer / 8 ); corpse->value[4] = ch->level; if( CAN_PKILL( ch ) && sysdata.pk_loot ) xSET_BIT( corpse->extra_flags, ITEM_CLANCORPSE ); /* * Pkill corpses get save timers, in ticks (approx 70 seconds) * This should be anough for the killer to type 'get all corpse'. */ if( !IS_NPC( ch ) && !IS_NPC( killer ) ) corpse->value[3] = 1; else corpse->value[3] = 0; } if( CAN_PKILL( ch ) && CAN_PKILL( killer ) && ch != killer ) { snprintf( buf, MAX_STRING_LENGTH, "%s", killer->name ); STRFREE( corpse->action_desc ); corpse->action_desc = STRALLOC( buf ); } /* * Added corpse name - make locate easier , other skills */ snprintf( buf, MAX_STRING_LENGTH, "corpse %s", name ); STRFREE( corpse->name ); corpse->name = STRALLOC( buf ); snprintf( buf, MAX_STRING_LENGTH, corpse->short_descr, name ); STRFREE( corpse->short_descr ); corpse->short_descr = STRALLOC( buf ); snprintf( buf, MAX_STRING_LENGTH, corpse->description, name ); STRFREE( corpse->description ); corpse->description = STRALLOC( buf ); for( obj = ch->first_carrying; obj; obj = obj_next ) { obj_next = obj->next_content; obj_from_char( obj ); if( IS_OBJ_STAT( obj, ITEM_INVENTORY ) || IS_OBJ_STAT( obj, ITEM_DEATHROT ) ) extract_obj( obj ); else obj_to_obj( obj, corpse ); } return obj_to_room( corpse, ch->in_room ); }