void affect_to_room(ROOM_INDEX_DATA *room, AFFECT_DATA *paf) { AFFECT_DATA *paf_new; void *vo; paf_new = new_affect(); *paf_new = *paf; paf_new->next = room->affected; room->affected = paf_new; vo = (void *) room; add_weave_list( vo, NODE_WEAVE_ROOM ); return; }
/* give an affect to an object */ void affect_to_obj(OBJ_DATA *obj, AFFECT_DATA *paf) { AFFECT_DATA *paf_new; void *vo; paf_new = new_affect(); *paf_new = *paf; paf_new->next = obj->affected; obj->affected = paf_new; vo = (void *) obj; add_weave_list( vo, NODE_WEAVE_OBJ ); return; }
/* * Give an affect to a char. */ void affect_to_char( CHAR_DATA *ch, AFFECT_DATA *paf ) { AFFECT_DATA *paf_new; void *vo; paf_new = new_affect(); *paf_new = *paf; paf_new->next = ch->affected; ch->affected = paf_new; vo = (void *) ch; add_weave_list( vo, NODE_WEAVE_CHAR ); affect_modify( ch, paf_new, TRUE ); return; }
void affect_from_index( OBJ_DATA *obj ) { AFFECT_DATA *paf, *af_new; obj->enchanted = TRUE; for ( paf = obj->pIndexData->affected; paf; paf = paf->next ) { af_new = new_affect( ); af_new->next = obj->affected; obj->affected = af_new; af_new->type = paf->type; af_new->strength = paf->strength; af_new->duration = paf->duration; af_new->location = paf->location; af_new->modifier = paf->modifier; af_new->bitvector = paf->bitvector; af_new->bitvector_2 = paf->bitvector_2; af_new->owner = NULL; af_new->flags = paf->flags; } return; }
void acid_effect(void *vo, int level, int dam, int target) { if (target == TARGET_ROOM) /* nail objects on the floor */ { ROOM_INDEX_DATA *room = (ROOM_INDEX_DATA *) vo; OBJ_DATA *obj, *obj_next; for (obj = room->contents; obj != NULL; obj = obj_next) { obj_next = obj->next_content; acid_effect(obj,level,dam,TARGET_OBJ); } return; } if (target == TARGET_CHAR) /* do the effect on a victim */ { CHAR_DATA *victim = (CHAR_DATA *) vo; OBJ_DATA *obj, *obj_next; /* let's toast some gear */ for (obj = victim->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; acid_effect(obj,level,dam,TARGET_OBJ); } return; } if (target == TARGET_OBJ) /* toast an object */ { OBJ_DATA *obj = (OBJ_DATA *) vo; OBJ_DATA *t_obj,*n_obj; int chance = level / 4 + dam / 10; char *msg; if (IS_OBJ_STAT(obj,ITEM_BURN_PROOF) || IS_OBJ_STAT(obj,ITEM_NOPURGE) || number_range(0,4) == 0) return; if (chance > 25) chance = (chance - 25) / 2 + 25; if (chance > 50) chance = (chance - 50) / 2 + 50; if (IS_OBJ_STAT(obj,ITEM_BLESS)) chance -= 5; chance -= obj->level * 2; switch (obj->item_type) { default: return; case ITEM_CONTAINER: case ITEM_CORPSE_PC: case ITEM_CORPSE_NPC: msg = "$p fumes and dissolves."; break; case ITEM_ARMOR: msg = "$p is pitted and etched."; break; case ITEM_CLOTHING: msg = "$p is corroded into scrap."; break; case ITEM_STAFF: case ITEM_WAND: chance -= 10; msg = "$p corrodes and breaks."; break; case ITEM_SCROLL: chance += 10; msg = "$p is burned into waste."; break; } chance = URANGE(5,chance,95); if (number_percent() > chance) return; if (obj->carried_by != NULL) act(msg,obj->carried_by,obj,NULL,TO_ALL); else if (obj->in_room != NULL && obj->in_room->people != NULL) act(msg,obj->in_room->people,obj,NULL,TO_ALL); if (obj->item_type == ITEM_ARMOR) /* etch it */ { AFFECT_DATA *paf; bool af_found = FALSE; int i; affect_enchant(obj); for ( paf = obj->affected; paf != NULL; paf = paf->next) { if ( paf->location == APPLY_AC) { af_found = TRUE; paf->type = -1; paf->modifier += 1; paf->level = UMAX(paf->level,level); break; } } if (!af_found) /* needs a new affect */ { paf = new_affect(); paf->type = -1; paf->level = level; paf->duration = -1; paf->location = APPLY_AC; paf->modifier = 1; paf->bitvector = 0; paf->next = obj->affected; obj->affected = paf; } if (obj->carried_by != NULL && obj->wear_loc != WEAR_NONE) for (i = 0; i < 4; i++) obj->carried_by->armor[i] += 1; return; } /* get rid of the object */ if (obj->contains) /* dump contents */ { for (t_obj = obj->contains; t_obj != NULL; t_obj = n_obj) { n_obj = t_obj->next_content; obj_from_obj(t_obj); if (obj->in_room != NULL) obj_to_room(t_obj,obj->in_room); else if (obj->carried_by != NULL) obj_to_room(t_obj,obj->carried_by->in_room); else { extract_obj(t_obj); continue; } acid_effect(t_obj,level/2,dam/2,TARGET_OBJ); } } extract_obj(obj); return; } }
/* * Snarf an obj section. old style */ void load_obj_circle( FILE *fp ) { OBJ_INDEX_DATA *pObjIndex; char *word; log_stringf(" OBJECTS"); if ( !area_last ) { /* OLC */ bug( "Load_obj_circle: no #AREA seen yet."); exit( 1 ); } for ( ; ; ) { int vnum; char letter; int iHash; int x1, x2, x3, x4, x5, x6; letter = fread_letter( fp ); if ( letter != '#' ) { bug( "Load_obj_circle: # not found."); exit( 1 ); } vnum = fread_number( fp ); if ( vnum == 0 ) break; fBootDb = FALSE; if ( get_obj_index( vnum ) != NULL ) { bug( "Load_obj_circle: vnum %d duplicated.", vnum ); exit( 1 ); } fBootDb = TRUE; pObjIndex = new_obj_index(); pObjIndex->vnum = vnum; pObjIndex->area = area_last; /* OLC */ pObjIndex->new_format = FALSE; pObjIndex->reset_num = 0; newobjs++; pObjIndex->name = fread_string( fp ); pObjIndex->short_descr = fread_string_lower( fp ); pObjIndex->description = fread_string_upper( fp ); fread_string( fp ); // unused: action desc pObjIndex->material = 0; pObjIndex->item_type = fread_number( fp ); pObjIndex->extra_flags = fread_flag_circle( fp ); pObjIndex->wear_flags = fread_flag_circle( fp ); fread_flag_circle(fp); // unused ? pObjIndex->size = SIZE_NOSIZE; pObjIndex->value[0] = fread_number(fp); pObjIndex->value[1] = fread_number(fp); pObjIndex->value[2] = fread_number(fp); pObjIndex->value[3] = fread_number(fp); pObjIndex->weight = UMAX( 1, fread_number( fp ) ); pObjIndex->cost = fread_number( fp ); fread_number( fp ); // unused: rent/day fread_number(fp); // unused ? pObjIndex->condition = 100; pObjIndex->level = 1; for ( ; ; ) { letter = fread_letter( fp ); if ( letter == 'A' ) { AFFECT_DATA *paf; paf = new_affect(); createaff(*paf,-1,20,-1,0,AFFECT_INHERENT); addaff2(*paf,AFTO_CHAR,fread_number( fp ),AFOP_ADD,fread_number( fp )); //paf->where = AFTO_CHAR; //paf->op = AFOP_ADD; //paf->type = -1; //paf->level = 20; /* RT temp fix */ //paf->duration = -1; //paf->location = fread_number( fp ); //paf->modifier = fread_number( fp ); convert_af_circle( paf ); paf->next = pObjIndex->affected; pObjIndex->affected = paf; } else if ( letter == 'E' ) { EXTRA_DESCR_DATA *ed; // ed = (EXTRA_DESCR_DATA *) alloc_perm( sizeof(*ed) ); ed = new_extra_descr(); ed->keyword = fread_string( fp ); ed->description = fread_string( fp ); ed->next = pObjIndex->extra_descr; pObjIndex->extra_descr = ed; } else if ( letter == 'T' ) { // script int scriptVnum = fread_number( fp ); char buf[MAX_STRING_LENGTH]; sprintf( buf, "obj%d", scriptVnum ); pObjIndex->program = hash_get_prog(buf); if (!pObjIndex->program) bug("Can't find program for obj vnum %d.", pObjIndex->vnum); else { if ( get_root_class( pObjIndex->program ) != default_obj_class ) { bug("program for obj vnum %d is not a mob program." ,pObjIndex->vnum); pObjIndex->program = NULL; } else if ( pObjIndex->program->isAbstract ) bug("program for Obj vnum %d is an ABSTRACT class.", pObjIndex->vnum ); } } else { ungetc( letter, fp ); break; } } switch ( pObjIndex->item_type ) { case CIRCLE_ITEM_POTION: case CIRCLE_ITEM_SCROLL: pObjIndex->value[1] = slot_lookup( pObjIndex->value[1] ); pObjIndex->value[2] = slot_lookup( pObjIndex->value[2] ); pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] ); break; case CIRCLE_ITEM_STAFF: case CIRCLE_ITEM_WAND: pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] ); break; } convert_obj_circle( pObjIndex ); iHash = vnum % MAX_KEY_HASH; pObjIndex->next = obj_index_hash[iHash]; obj_index_hash[iHash] = pObjIndex; top_vnum_obj = top_vnum_obj < vnum ? vnum : top_vnum_obj; /* OLC */ assign_area_vnum( vnum ); /* OLC */ } return; }
/* the main engine of charm spell, and similar */ void effect_charm(struct char_data *ch, struct char_data *victim, int spellnum) { struct affected_type af; int elf_bonus = 0; if (!IS_NPC(victim) && (GET_RACE(victim) == RACE_ELF || //elven enchantment resistance GET_RACE(victim) == RACE_H_ELF)) // added check for IS_NPC because NPCRACE_HUMAN == RACE_ELF and NPCRACE_ABERRATION == RACE_H_ELF elf_bonus += 2; if (victim == ch) send_to_char(ch, "You like yourself even better!\r\n"); else if (MOB_FLAGGED(victim, MOB_NOCHARM)) { send_to_char(ch, "Your victim doesn't seem vulnerable to this " "enchantments!\r\n"); if (IS_NPC(victim)) hit(victim, ch, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE); } else if (IS_AFFECTED(victim, AFF_MIND_BLANK)) { send_to_char(ch, "Your victim is protected from this " "enchantment!\r\n"); if (IS_NPC(victim)) hit(victim, ch, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE); } else if (AFF_FLAGGED(ch, AFF_CHARM)) send_to_char(ch, "You can't have any followers of your own!\r\n"); else if (AFF_FLAGGED(victim, AFF_CHARM)) send_to_char(ch, "Your victim is already charmed.\r\n"); else if (spellnum == SPELL_CHARM && (CASTER_LEVEL(ch) < GET_LEVEL(victim) || GET_LEVEL(victim) >= 8)) send_to_char(ch, "Your victim is too powerful.\r\n"); else if ((spellnum == SPELL_DOMINATE_PERSON || spellnum == SPELL_MASS_DOMINATION) && CASTER_LEVEL(ch) < GET_LEVEL(victim)) send_to_char(ch, "Your victim is too powerful.\r\n"); /* player charming another player - no legal reason for this */ else if (!CONFIG_PK_ALLOWED && !IS_NPC(victim)) send_to_char(ch, "You fail - shouldn't be doing it anyway.\r\n"); else if (circle_follow(victim, ch)) send_to_char(ch, "Sorry, following in circles is not allowed.\r\n"); else if (mag_resistance(ch, victim, 0)) { send_to_char(ch, "You failed to penetrate the spell resistance!"); if (IS_NPC(victim)) hit(victim, ch, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE); } else if (mag_savingthrow(ch, victim, SAVING_WILL, elf_bonus)) { send_to_char(ch, "Your victim resists!\r\n"); if (IS_NPC(victim)) hit(victim, ch, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE); } else { /* slippery mind gives a second save */ if (!IS_NPC(victim) && GET_SKILL(victim, SKILL_SLIPPERY_MIND)) { increase_skill(victim, SKILL_SLIPPERY_MIND); send_to_char(victim, "\tW*Slippery Mind*\tn "); if (mag_savingthrow(ch, victim, SAVING_WILL, 0)) { return; } } if (victim->master) stop_follower(victim); add_follower(victim, ch); new_affect(&af); if (spellnum == SPELL_CHARM) af.spell = SPELL_CHARM; if (spellnum == SPELL_CHARM_ANIMAL) af.spell = SPELL_CHARM_ANIMAL; else if (spellnum == SPELL_DOMINATE_PERSON) af.spell = SPELL_DOMINATE_PERSON; else if (spellnum == SPELL_MASS_DOMINATION) af.spell = SPELL_MASS_DOMINATION; af.duration = 100; if (GET_CHA_BONUS(ch)) af.duration += GET_CHA_BONUS(ch) * 4; SET_BIT_AR(af.bitvector, AFF_CHARM); affect_to_char(victim, &af); act("Isn't $n just such a nice fellow?", FALSE, ch, 0, victim, TO_VICT); // if (IS_NPC(victim)) // REMOVE_BIT_AR(MOB_FLAGS(victim), MOB_SPEC); } // should never get here }