/* TODO: add strength/etc to affection struct, that'd help a lot especially here */ void perform_dispel(struct char_data *ch, struct char_data *vict, int spellnum) { int i = 0, attempt = 0, challenge = 0, num_dispels = 0, msg = FALSE; if (vict == ch) { send_to_char(ch, "You dispel all your own magic!\r\n"); act("$n dispels all $s magic!", FALSE, ch, 0, 0, TO_ROOM); if (ch->affected || AFF_FLAGS(ch)) { while (ch->affected) { if (spell_info[ch->affected->spell].wear_off_msg) send_to_char(ch, "%s\r\n", spell_info[ch->affected->spell].wear_off_msg); affect_remove(ch, ch->affected); } for (i = 0; i < AF_ARRAY_MAX; i++) AFF_FLAGS(ch)[i] = 0; } return; } else { attempt = dice(1, 20) + CASTER_LEVEL(ch); challenge = dice(1, 20) + CASTER_LEVEL(vict); if (spellnum == SPELL_GREATER_DISPELLING) { num_dispels = dice(2, 2); for (i = 0; i < num_dispels; i++) { if (attempt >= challenge) { //successful if (vict->affected) { msg = TRUE; affect_remove(vict, vict->affected); } } attempt = dice(1, 20) + CASTER_LEVEL(ch); challenge = dice(1, 20) + CASTER_LEVEL(vict); } if (msg) { send_to_char(ch, "You successfully dispel some magic!\r\n"); act("$n dispels some of $N's magic!", FALSE, ch, 0, vict, TO_ROOM); } else { send_to_char(ch, "You fail your dispel magic attempt!\r\n"); act("$n fails to dispel some of $N's magic!", FALSE, ch, 0, vict, TO_ROOM); } return; } if (spellnum == SPELL_DISPEL_MAGIC) { if (attempt >= challenge) { //successful send_to_char(ch, "You successfuly dispel some magic!\r\n"); act("$n dispels some of $N's magic!", FALSE, ch, 0, vict, TO_ROOM); if (vict->affected) affect_remove(vict, vict->affected); } else { //failed send_to_char(ch, "You fail your dispel magic attempt!\r\n"); act("$n fails to dispel some of $N's magic!", FALSE, ch, 0, vict, TO_ROOM); } } } }
void affect_join(struct char_data *ch, struct affected_type *af, bool add_dur, bool avg_dur, bool add_mod, bool avg_mod) { struct affected_type *hjp, *next; bool found = FALSE; for (hjp = ch->affected; !found && hjp; hjp = next) { next = hjp->next; if ((hjp->spell == af->spell) && (hjp->location == af->location)) { if (add_dur) af->duration += hjp->duration; else if (avg_dur) af->duration = (af->duration+hjp->duration)/2; if (add_mod) af->modifier += hjp->modifier; else if (avg_mod) af->modifier = (af->modifier+hjp->modifier)/2; affect_remove(ch, hjp); affect_to_char(ch, af); found = TRUE; } } if (!found) affect_to_char(ch, af); }
/* affect_update: called from comm.c (causes spells to wear off) */ void affect_update(void) { static struct affected_type *af, *next; static struct char_data *i; for (i = character_list; i; i = i->next) for (af = i->affected; af; af = next) { next = af->next; if (af->duration >= 1) af->duration--; else if (af->duration == -1) /* No action */ af->duration = -1; /* GODs only! unlimited */ else { if ((af->type > 0) && (af->type <= MAX_SPELLS)) if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) if (spells[find_skill_num_def(af->type)].wear_off) { send_to_char(spells[find_skill_num_def(af->type)].wear_off, i); send_to_char("\r\n", i); } if (strcmp(spells[find_skill_num_def(af->type)].command, "wraith form") == 0) { die(i, NULL); } else affect_remove(i, af); } } }
/* affect_update: called from comm.c (causes spells to wear off) */ void affect_update(void) { struct affected_type *af, *next; struct char_data *i; for (i = character_list; i; i = i->next) { for (af = i->affected; af; af = next) { next = af->next; if (af->duration >= 1) af->duration--; else if (af->duration == -1) /* No action */ af->duration = -1; /* GODs only! unlimited */ else { if ((af->type > 0) && (af->type <= MAX_SPELLS)) if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) if (spell_info[af->type].wear_off_msg) send_to_char(i, "%s\r\n", spell_info[af->type].wear_off_msg); affect_remove(i, af); /** Add Fatigue if coming down from berserk */ if(af->type == SKILL_BERSERK){ //|| af->type == adrenaline shot){ af->type = 1; //Banankick: not sure if this works. af->duration = 10; af->modifier = -10; af->location = APPLY_EVASION; //APPLY_NONE? af->bitvector = AFF_FATIGUED; affect_to_char(i, &af); } } } } }
char_data::~char_data() { is_free = true; while ( first_carry != NULL ) extract_obj(first_carry); while ( first_affect != NULL ) affect_remove(this, first_affect); imc_freechardata(this); delete bank_money; if ( current_brand ) delete current_brand; delete email; delete money; if ( pnote ) delete pnote; delete casting; delete quest_info; delete records; delete super; aggro_list.remove(this); }
void do_pre_test(struct creature *ch) { struct obj_data *obj = NULL, *next_obj = NULL; for (obj = ch->carrying; obj; obj = next_obj) { next_obj = obj->next_content; extract_obj(obj); } for (int i = 0; i < NUM_WEARS; i++) { if ((obj = GET_EQ(ch, i))) { extract_obj(GET_EQ(ch, i)); } } while (ch->affected) affect_remove(ch, ch->affected); for (obj = ch->in_room->contents; obj; obj = next_obj) { next_obj = obj->next_content; extract_obj(obj); } if (GET_COND(ch, FULL) >= 0) GET_COND(ch, FULL) = 24; if (GET_COND(ch, THIRST) >= 0) GET_COND(ch, THIRST) = 24; SET_BIT(ch->in_room->room_flags, ROOM_NORECALL); }
/* * Free a mobile structure that has been edited. * Take care of existing mobiles and their mob_proto! */ int free_mobile(struct char_data *mob) { int i; if (mob == NULL) return FALSE; /* * Non-prototyped mobile. Also known as new mobiles. */ if ((i = GET_MOB_RNUM(mob)) == NOBODY) free_mobile_strings(mob); else { /* Prototyped mobile. */ if (mob->player.name && mob->player.name != mob_proto[i].player.name) free(mob->player.name); if (mob->player.title && mob->player.title != mob_proto[i].player.title) free(mob->player.title); if (mob->player.short_descr && mob->player.short_descr != mob_proto[i].player.short_descr) free(mob->player.short_descr); if (mob->player.long_descr && mob->player.long_descr != mob_proto[i].player.long_descr) free(mob->player.long_descr); if (mob->player.description && mob->player.description != mob_proto[i].player.description) free(mob->player.description); } while (mob->affected) affect_remove(mob, mob->affected); free(mob); return TRUE; }
Character::~Character() { OBJ_DATA *obj_next; AFFECT_DATA *paf_next; if ( this->short_descr ) free_string( this->short_descr ); if ( this->long_descr ) free_string( this->long_descr ); if ( this->prompt ) free_string( this->prompt ); if ( this->prefix ) free_string( this->prefix ); if ( this->material ) free_string( this->material ); for (OBJ_DATA *obj = this->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; extract_obj(obj); } for (AFFECT_DATA *paf = this->affected; paf != NULL; paf = paf_next) { paf_next = paf->next; affect_remove(this,paf); } if (this->pcdata != NULL) { delete this->pcdata; this->pcdata = NULL; } INVALIDATE(this); }
void affect_join( struct char_data *ch, struct affected_type *af, bool avg_dur, bool avg_mod ) { struct affected_type *hjp; bool found = FALSE; for (hjp = ch->affected; !found && hjp; hjp = hjp->next) { if ( hjp->type == af->type ) { af->duration += hjp->duration; if (avg_dur) af->duration /= 2; af->modifier += hjp->modifier; if (avg_mod) af->modifier /= 2; affect_remove(ch, hjp); affect_to_char(ch, af); found = TRUE; } } if (!found) affect_to_char(ch, af); }
bool check_si_reflect_spell( CHAR_DATA *ch, CHAR_DATA *victim, int type, int spell ) { AFFECT_DATA * paf, *reflect = NULL; sh_int sn = si_spell_info[type][spell].sn; sh_int circle = spell_circle( ch, sn ); if ( !IS_AFFECTED( victim, AFF_REFLECT_SPELL ) ) return FALSE; for ( paf = victim->affected; paf != NULL; paf = paf->next ) if ( paf->bitvector == &AFF_REFLECT_SPELL ) { reflect = paf; break; } if ( !reflect ) return FALSE; /* ok to jesli jest to na pewno odbije * jesli modifier < 0 to jest na stale * w przeciwnym razie zmniejszamy modifier o circle */ circle = UMAX( 0, circle ); /* na stale */ if ( reflect->modifier < circle ) { send_to_char( skill_table[ gsn_reflect_spell ].msg_off, victim ); send_to_char( "\n\r", victim ); affect_remove( victim, reflect ); return FALSE; } else { reflect->modifier -= circle; if ( reflect->modifier <= 0 ) { send_to_char( skill_table[ gsn_reflect_spell ].msg_off, victim ); send_to_char( "\n\r", victim ); affect_remove( victim, reflect ); } } return TRUE; }
/* Call affect_remove with every spell of spelltype "skill" */ void affect_from_char( struct char_data *ch, short skill) { struct affected_type *hjp; for(hjp = ch->affected; hjp; hjp = hjp->next) if (hjp->type == skill) affect_remove( ch, hjp ); }
/* Call affect_remove with every spell of spelltype "skill" */ void affect_from_char(struct char_data * ch, int type) { struct affected_type *hjp, *next; int message = 0; for (hjp = ch->affected; hjp; hjp = next) { next = hjp->next; if (hjp->type == type) { if (message) affect_remove(ch, hjp, 0); else affect_remove(ch, hjp, 1); message = 1; } } }
void free_char (CHAR_DATA *ch) { OBJ_DATA *obj; OBJ_DATA *obj_next; AFFECT_DATA *paf; AFFECT_DATA *paf_next; if (!IS_VALID(ch)) return; if (IS_NPC(ch)) mobile_count--; for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; extract_obj(obj); } for (paf = ch->affected; paf != NULL; paf = paf_next) { paf_next = paf->next; affect_remove(ch,paf); } free_string(ch->name); free_string(ch->wkname); free_string(ch->real_name); free_string(ch->short_descr); free_string(ch->long_descr); free_string(ch->description); free_string(ch->hood_description); free_string(ch->veil_description); free_string(ch->wolf_description); free_string(ch->wound_description); free_string(ch->aura_description); free_string(ch->prompt); free_string(ch->prefix); free_string(ch->gtitle); free_string(ch->sguild_title); free_string(ch->tguild_title); free_string(ch->mtitle); free_string(ch->mname); /* free_note (ch->pnote); */ free_pcdata(ch->pcdata); ch->next = char_free; char_free = ch; INVALIDATE(ch); return; }
void show_to_watchers (CHAR_DATA * ch, char *command) { CHAR_DATA *tch; AFFECTED_TYPE *af; char buf[MAX_STRING_LENGTH]; if ((af = get_affect (ch, MAGIC_WATCH1))) { if (!is_he_somewhere ((CHAR_DATA *) af->a.spell.t)) affect_remove (ch, af); else { tch = (CHAR_DATA *) af->a.spell.t; sprintf (buf, "%s: %s\n", GET_NAME (ch), command); send_to_char (buf, tch); } } if ((af = get_affect (ch, MAGIC_WATCH2))) { if (!is_he_somewhere ((CHAR_DATA *) af->a.spell.t)) affect_remove (ch, af); else { tch = (CHAR_DATA *) af->a.spell.t; sprintf (buf, "%s: %s\n", GET_NAME (ch), command); send_to_char (buf, tch); } } if ((af = get_affect (ch, MAGIC_WATCH3))) { if (!is_he_somewhere ((CHAR_DATA *) af->a.spell.t)) affect_remove (ch, af); else { tch = (CHAR_DATA *) af->a.spell.t; sprintf (buf, "%s: %s\n", GET_NAME (ch), command); send_to_char (buf, tch); } } }
/* Call affect_remove with every affect from the spell "type" */ void affect_from_char(struct char_data *ch, int type) { struct affected_type *hjp, *next; for (hjp = ch->affected; hjp; hjp = next) { next = hjp->next; if (hjp->spell == type) affect_remove(ch, hjp); } }
void affect_remove_nonperm_II(struct char_data * ch, int type) { struct affected_type *hjp, *next; for (hjp = ch->affected; hjp; hjp = hjp->next) { next = hjp->next; if (hjp->type == type) affect_remove(ch, hjp, 1); } }
void raw_kill(struct char_data *ch) { if (FIGHTING(ch)) stop_fighting(ch); while (ch->affected) affect_remove(ch, ch->affected); death_cry(ch); make_corpse(ch); extract_char(ch); }
void free_char (CHAR_DATA *ch) { OBJ_DATA *obj; OBJ_DATA *obj_next; AFFECT_DATA *paf; AFFECT_DATA *paf_next; if (!IS_VALID(ch)) return; if (IS_NPC(ch)) mobile_count--; for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; extract_obj(obj); } for (paf = ch->affected; paf != NULL; paf = paf_next) { paf_next = paf->next; affect_remove(ch,paf); } free_string(ch->name); free_string(ch->short_descr); free_string(ch->long_descr); free_string(ch->description); free_string(ch->prompt); free_string(ch->prefix); /* if ( ch->die_descr[0] != '\0') free_string(ch->die_descr); if ( ch->say_descr[0] != '\0') free_string(ch->say_descr); */ /* 24hr bug fix */ if ( ch->die_descr != NULL && ch->die_descr[0] != '\0') free_string(ch->die_descr); if ( ch->say_descr != NULL && ch->say_descr[0] != '\0') free_string(ch->say_descr); if (ch->pcdata != NULL) free_pcdata(ch->pcdata); ch->next = char_free; char_free = ch; INVALIDATE(ch); return; }
/* * Strip all affects of a given sn. */ void affect_strip( CHAR_DATA *ch, int sn ) { AFFECT_DATA *paf; AFFECT_DATA *paf_next; for ( paf = ch->affected; paf != NULL; paf = paf_next ) { paf_next = paf->next; if ( paf->type == sn ) affect_remove( ch, paf ); } return; }
void raw_kill(struct char_data * ch, struct char_data * killer) { if (FIGHTING(ch)) stop_fighting(ch); while (ch->affected) affect_remove(ch, ch->affected); if (killer) { if (death_mtrigger(ch, killer)) death_cry(ch); } else death_cry(ch); make_corpse(ch); extract_char(ch); }
void Forge::NameWeapon(CHAR_DATA & ch, const char * argument) { // Check for name effect AFFECT_DATA * paf(FindNameEffect(ch)); if (paf == NULL) { send_to_char("You have no weapon waiting to receive a Name.\n", &ch); return; } // Verify the object OBJ_DATA * obj(FindNameableObject(ch, *paf)); affect_remove(&ch, paf); if (obj == NULL) { send_to_char("You are no longer carrying the weapon you empowered to receive a Name.\n", &ch); return; } // Object exists and is carried by the char, so name it according to the argument act("You pass your hand over $p, willing the Name into it.", &ch, obj, NULL, TO_CHAR); act("$n passes $s hand over $p, murmuring softly.", &ch, obj, NULL, TO_ROOM); // Echo about the naming std::ostringstream mess; mess << "A deep rush of power sweeps over $p as it claims the Name \"" << argument << "\"!"; act(mess.str().c_str(), &ch, &obj, NULL, TO_ALL); // Add the name to the short desc std::string shortDesc(obj->short_descr); shortDesc += ", \""; shortDesc += argument; shortDesc += '"'; SetBasicDescs(*obj, shortDesc.c_str(), true); // Create lore static char *his_her [] = { "its", "his", "her" }; const char * ch_name(IS_NPC(&ch) ? ch.short_descr : ch.name); std::ostringstream lore; lore << "Forged by the " << race_table[ch.race].name << " smith " << ch_name; lore << ", this mighty " << flag_string(weapon_class, obj->value[0]) << " was given its Name by the same."; lore << "Imbuing it with " << his_her[ch.sex] << " own power, " << ch_name << " marked \"" << argument; lore << "\" as an extension of " << his_her[ch.sex] << " very being."; copy_string(obj->lore, lore.str().c_str()); obj->lore = format_string(obj->lore); }
void free_char( CHAR_DATA *ch ) { OBJ_DATA *obj; OBJ_DATA *obj_next; AFFECT_DATA *paf; AFFECT_DATA *paf_next; /*~~~~~~~~~~~~~~~~~~*/ if ( !IS_VALID(ch) ) return; if ( IS_MOB(ch) ) mobile_count--; ch->extracted = TRUE; for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; extract_obj_nocount( obj ); } for ( paf = ch->affected; paf != NULL; paf = paf_next ) { paf_next = paf->next; affect_remove( ch, paf ); } free_string( ch->name ); free_string( ch->short_descr ); free_string( ch->long_descr ); free_string( ch->description ); free_string( ch->prompt ); free_string( ch->prefix ); free_string( ch->material ); free_string( ch->in_mind ); if ( ch->pcdata != NULL ) free_pcdata( ch->pcdata ); ch->next = char_free; char_free = ch; ch->extracted = FALSE; INVALIDATE( ch ); }
void unaffect_one(struct char_data * ch, int type) { struct affected_type *hjp, *next; for (hjp = ch->affected; hjp; hjp = next) { next = hjp->next; if (hjp->type == type) { affect_remove(ch, hjp, 0); return; } } GET_NAME(ch, chname); sprintf(buf, "SYSERR: Couldn't unaffect_one spellnum %d from %s!", type, chname); FREE_NAME(chname); mudlog(buf, BRF, LVL_GRGOD, TRUE); }
void handle_waterwheel_crystal_destroyed(CHAR_DATA & ch, OBJ_DATA & obj) { // Look for the effect AFFECT_DATA * paf(get_obj_affect(&obj, gsn_constructwaterwheel)); if (paf == NULL) return; // Echoes act("As you destroy $p, a surge of energy rushes from it and into you!", &ch, &obj, NULL, TO_CHAR); act("As $n destroys $p, a flash of blue light shines out from it, focused on $m!", &ch, &obj, NULL, TO_ROOM); // Strip the effect from the char if present for (AFFECT_DATA * waf(get_affect(&ch, gsn_constructwaterwheel)); waf != NULL; waf = get_affect(&ch, gsn_constructwaterwheel, waf)) { if (waf->location == APPLY_MANA) { affect_remove(&ch, waf); break; } } // Determine modifier int modifier(paf->duration); if (number_percent() <= get_skill(&ch, gsn_stonecraft)) check_improve(&ch, NULL, gsn_stonecraft, true, 4); else { check_improve(&ch, NULL, gsn_stonecraft, false, 4); modifier /= 2; } // Grant the new effect AFFECT_DATA af = {0}; af.where = TO_AFFECTS; af.type = gsn_constructwaterwheel; af.level = paf->level; af.modifier = UMAX(1, modifier); af.duration = af.modifier; af.location = APPLY_MANA; affect_to_char(&ch, &af); }
/* * Add or enhance an affect. */ void affect_join( CHAR_DATA *ch, AFFECT_DATA *paf ) { AFFECT_DATA *paf_old; bool found; found = FALSE; for ( paf_old = ch->affected; paf_old != NULL; paf_old = paf_old->next ) { if ( paf_old->type == paf->type && paf_old->flags == paf->flags ) { paf->strength = (paf->strength += paf_old->strength) / 2; paf->duration += paf_old->duration; paf->modifier += paf_old->modifier; affect_remove( ch, paf_old ); break; } } affect_to_char( ch, paf ); return; }
void raw_kill(struct char_data * ch, struct char_data * killer) { if (FIGHTING(ch)) stop_fighting(ch); while (ch->affected) affect_remove(ch, ch->affected); /* To make ordinary commands work in scripts. welcor*/ GET_POS(ch) = POS_STANDING; if (killer) { if (check_hooks(HOOK_CONT_DIED, ch_script_cont(ch), killer, SNull, SNull )) death_cry(ch); } else death_cry(ch); update_pos(ch); make_corpse(ch); extract_char(ch); }
/* affect_update: called from comm.c (causes spells to wear off) */ void affect_update(void) { struct affected_type *af, *next; struct char_data *i; for (i = character_list; i; i = i->next) for (af = i->affected; af; af = next) { next = af->next; if (af->duration >= 1) af->duration--; else if (af->duration == -1) /* No action */ af->duration = -1; /* GODs only! unlimited */ else { if ((af->type > 0) && (af->type <= MAX_SPELLS)) if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) if (spell_info[af->type].wear_off_msg) send_to_char(i, "%s\r\n", spell_info[af->type].wear_off_msg); affect_remove(i, af); } } }
/* * Free a character. */ void free_char( CHAR_DATA *ch ) { OBJ_DATA *obj; OBJ_DATA *obj_next; AFFECT_DATA *paf; AFFECT_DATA *paf_next; for ( obj = ch->carrying; obj != NULL; obj = obj_next ) { obj_next = obj->next_content; extract_obj( obj ); } for ( paf = ch->affected; paf != NULL; paf = paf_next ) { paf_next = paf->next; affect_remove( ch, paf ); } free_string( ch->name ); free_string( ch->short_descr ); free_string( ch->long_descr ); free_string( ch->description ); if ( ch->pcdata != NULL ) { free_string( ch->pcdata->pwd ); free_string( ch->pcdata->bamfin ); free_string( ch->pcdata->bamfout ); free_string( ch->pcdata->title ); ch->pcdata->next = pcdata_free; pcdata_free = ch->pcdata; } ch->next = char_free; char_free = ch; return; }
void medit_free_mobile(struct char_data *mob) { int i; /* * Non-prototyped mobile. Also known as new mobiles. */ if (!mob) return; else if (GET_MOB_RNUM(mob) == -1) { if (mob->player.name) free(mob->player.name); if (mob->player.title) free(mob->player.title); if (mob->player.short_descr) free(mob->player.short_descr); if (mob->player.long_descr) free(mob->player.long_descr); if (mob->player.description) free(mob->player.description); } else if ((i = GET_MOB_RNUM(mob)) > -1) { /* Prototyped mobile. */ if (mob->player.name && mob->player.name != mob_proto[i].player.name) free(mob->player.name); if (mob->player.title && mob->player.title != mob_proto[i].player.title) free(mob->player.title); if (mob->player.short_descr && mob->player.short_descr != mob_proto[i].player.short_descr) free(mob->player.short_descr); if (mob->player.long_descr && mob->player.long_descr != mob_proto[i].player.long_descr) free(mob->player.long_descr); if (mob->player.description && mob->player.description != mob_proto[i].player.description) free(mob->player.description); } while (mob->affected) affect_remove(mob, mob->affected, 0); free(mob); }
void affect_join(struct char_data * ch, struct affected_type * af, bool add_dur, bool avg_dur, bool add_mod, bool avg_mod) { struct affected_type *hjp; bool found = FALSE; for (hjp = ch->affected; !found && hjp; hjp = hjp->next) { if ((hjp->type == af->type) && (hjp->location == af->location)) { if (add_dur) { af->duration += hjp->duration; } if (avg_dur) { af->duration >>= 1; } if (add_mod) { af->modifier += hjp->modifier; } if (avg_mod) { af->modifier >>= 1; } affect_remove(ch, hjp, 0); affect_to_char(ch, af); found = TRUE; } } if (!found) { affect_to_char(ch, af); } }