/* manapoint gain per game hour */ int mana_gain(CharData * ch) { int malnourishCount = 0; struct affected_type *hjp, *next; if (IN_ROOM(ch) == -1) return 0; if(!IS_NPC(ch) && ((GET_COND(ch, HUNGER) == 0 && !IS_VAMPIRE(ch)) || GET_COND(ch, THIRST) == 0)) { if(ch->desc && percentSuccess(2)) { if(!affected_by_spell(ch, SKILL_EMACIATED)) add_affect( ch, ch, SKILL_EMACIATED, GET_LEVEL(ch), 0, 0, -1, 0, FALSE, FALSE, FALSE, FALSE); for (hjp = ch->affected; hjp; hjp = next) { next = hjp->next; if (hjp->type == SKILL_EMACIATED_MANA) malnourishCount++; } if(malnourishCount < 18) add_affect( ch, ch, SKILL_EMACIATED_MANA, GET_LEVEL(ch), APPLY_MANA, -MIN(50, GET_MANA(ch)/20), -1, 0, FALSE, FALSE, FALSE, FALSE); } } int base = calcManaBase(ch); int multiplier = calcManaMulti(ch); int bonus = calcManaBonus(ch); int gain = base*multiplier/100 + bonus; if (affected_by_spell(ch, SKILL_POTENCY)) gain *= 5; return (gain); }
/* ** doPoison */ void doPoison(CharData* vict) { int poisonDamage = aff_level(vict, AFF_POISON) + number(1,10); if (affected_by_spell(vict, SPELL_RESIST_POISON)) { switch (number(1,10)) { case 1: case 2: case 3: case 4: case 5: poisonDamage = 1; break; case 6: if (affected_by_spell(vict, SPELL_POISON)) { sendChar(vict, "You fight off the poison and recover.\r\n"); affect_from_char(vict, SPELL_POISON); return; } break; case 7: case 8: case 9: case 10: break; } } damage(vict, vict, poisonDamage/3, SPELL_POISON); }
void cast_detect_magic( byte level, struct char_data *ch, char *arg, int type, struct char_data *tar_ch, struct obj_data *tar_obj ) { switch (type) { case SPELL_TYPE_SPELL: if ( affected_by_spell(tar_ch, SPELL_DETECT_MAGIC) ){ send_to_char("Nothing seems to happen.\r\n", tar_ch); return; } spell_detect_magic(level,ch,tar_ch,0); break; case SPELL_TYPE_POTION: if ( affected_by_spell(ch, SPELL_DETECT_MAGIC) ) return; spell_detect_magic(level,ch,ch,0); break; case SPELL_TYPE_STAFF: for (tar_ch = world[ch->in_room].people ; tar_ch ; tar_ch = tar_ch->next_in_room) if (tar_ch != ch) if (!(IS_AFFECTED(tar_ch, SPELL_DETECT_MAGIC))) spell_detect_magic(level,ch,tar_ch,0); break; default : log("Serious screw-up in detect magic!"); break; } }
/* nb, also mess up anyone affected by AFF_POISON */ void pulse_heal(void) { CharData *ch; int gain = number(18,24); for (ch = character_list; ch; ch = ch->next) { if(ch->in_room == NOWHERE) continue; if(!(pvpFactor() > 1)) { if( GET_POS(ch) == POS_INCAP ) damage(ch, ch, 1, TYPE_SUFFERING); else if( GET_POS(ch) == POS_MORTALLYW ) damage(ch, ch, 2, TYPE_SUFFERING); else if( GET_POS(ch) == POS_DEAD) { if(IN_ARENA(ch) || IN_QUEST_FIELD(ch) || ZONE_FLAGGED(world[ch->in_room].zone, ZONE_ARENA) || ZONE_FLAGGED(world[ch->in_room].zone, ZONE_SLEEPTAG)) // If they're dying in the arena, they eventually get better (or killed by someone) { GET_HIT(ch) = number(GET_HIT(ch), 1); sendChar(ch, "You slowly recover.\r\n"); update_pos(ch); } else { raw_kill(ch, NULL); continue; } } } if (IS_AFFECTED(ch, AFF_PULSE_HIT)) if (GET_HIT(ch) < GET_MAX_HIT(ch)) GET_HIT(ch) += gain; if (IS_AFFECTED(ch, AFF_PULSE_MANA)) if (GET_MANA(ch) < GET_MAX_MANA(ch)) GET_MANA(ch) += gain; if (IS_AFFECTED(ch, AFF_POISON)) doPoison(ch); if (IS_AFFECTED(ch, AFF_DISEASE)) doDisease(ch); if (affected_by_spell(ch, SKILL_INVIGORATE)) doInvigorate(ch); if (IS_BOUNTY_HUNTER(ch) && GET_ADVANCE_LEVEL(ch) >= 1 && IS_AFFECTED(ch, AFF_HIDE)) GET_MOVE(ch) = MIN(GET_MOVE(ch) + 3*gain, GET_MAX_MOVE(ch)); if (IS_PRESTIDIGITATOR(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + GET_ADVANCE_LEVEL(ch) * 2, GET_MAX_MANA(ch)); if (affected_by_spell(ch, SPELL_HIPPOCRATIC_OATH)) GET_MANA(ch) = MIN(GET_MANA(ch) + 25, GET_MAX_MANA(ch)); if (affected_by_spell(ch, SKILL_PET_MEND)) GET_HIT(ch) = MIN(GET_HIT(ch) * 115 / 100, GET_MAX_HIT(ch)); if (IS_HOLY_PRIEST(ch)) GET_MANA(ch) = MIN(GET_MANA(ch) + 10 + 2*GET_ADVANCE_LEVEL(ch), GET_MAX_MANA(ch)); /* The room might be poisoned! (Or later, otherwise dangerous) */ if (ch->in_room != NOWHERE) { if (ROOM_FLAGGED(ch->in_room, ROOM_POISONED)) { if (!mag_savingthrow(ch, SAVING_SPELL)) { act("$n chokes and gags!", TRUE, ch, 0, 0, TO_ROOM); act("You choke and gag!", TRUE, ch, 0, 0, TO_CHAR); add_affect( ch, ch, SPELL_POISON, 30, APPLY_NONE, 0, 5 TICKS, AFF_POISON, FALSE, FALSE, FALSE, FALSE); } } } if(IS_DEFENDER(ch) && !affected_by_spell(ch, SKILL_DEFENDER_HEALTH)) add_affect(ch, ch, SKILL_DEFENDER_HEALTH, GET_LEVEL(ch), APPLY_HIT, GET_ADVANCE_LEVEL(ch)*5, -1, FALSE, FALSE, FALSE, FALSE, FALSE); } }
void sun_blind(struct char_data *ch) { struct affected_type af; if (get_max_level(ch) >= LOW_IMMORTAL) return; if (IS_AFFECTED2(ch, AFF2_SUN_BLIND)) return; if (IS_AFFECTED(ch, AFF_BLIND)) return; if (affected_by_spell(ch, SPELL_SUN_BLIND)) affect_from_char(ch, SPELL_SUN_BLIND); send_to_char("Aaarrrggghh! The sun burns your eyes!\n\r", ch); af.type = SPELL_SUN_BLIND; af.location = APPLY_HITROLL; af.modifier = -4; af.duration = (number(1, 2) + (5 - get_max_level(ch) / 10)); af.bitvector = 0; affect_to_char(ch, &af); af.location = APPLY_AC; af.modifier = +20; affect_to_char(ch, &af); af.modifier = 0; af.location = APPLY_BV2; af.bitvector = AFF2_SUN_BLIND; affect_to_char(ch, &af); }
// Returns true if a creature can see an object bool check_sight_object(struct creature * self, struct obj_data * obj) { if (PRF_FLAGGED(self, PRF_HOLYLIGHT)) return true; if (!OBJ_APPROVED(obj) && !NPC2_FLAGGED(self, NPC2_UNAPPROVED) && !IS_IMMORT(self) && !is_authorized(self, TESTER, NULL)) return false; if (IS_OBJ_STAT(obj, ITEM_TRANSPARENT) && !(AFF3_FLAGGED(self, AFF3_SONIC_IMAGERY) || AFF_FLAGGED(self, AFF_RETINA) || affected_by_spell(self, ZEN_AWARENESS))) return false; if (AFF_FLAGGED(self, AFF_DETECT_INVIS) || AFF2_FLAGGED(self, AFF2_TRUE_SEEING)) return true; if (IS_OBJ_STAT(obj, ITEM_INVISIBLE)) return false; return true; }
void spell_feeblemind(byte level, struct char_data *ch, struct char_data *victim, struct obj_data *obj) { struct affected_type af; int t,i; if (!saves_spell(victim, SAVING_SPELL)) { /* eld - I took the liberty of adding this little dandy.. In my opinion, */ /* this spell should not be accumulative. */ if(affected_by_spell(victim, SPELL_FEEBLEMIND)) { send_to_char("They are already dumb enough as it is!\n\r", ch); return; } send_to_char("You feel really really dumb\n\r", victim); af.type = SPELL_FEEBLEMIND; af.duration = 24; af.modifier = -5; af.location = APPLY_INT; af.bitvector = 0; affect_to_char(victim, &af); af.type = SPELL_FEEBLEMIND; af.duration = 24; af.modifier = 70; af.location = APPLY_SPELLFAIL; af.bitvector = 0; affect_to_char(victim, &af); /* last, but certainly not least */ if (!victim->skills) return; t = number(1,100); while (1) { for (i=0;i<MAX_SKILLS;i++) { if (victim->skills[i].learned) t--; if (t==0) { victim->skills[i].learned = 0; victim->skills[i].flags = 0; break; } /* eld - what happens if you get outside the for loop? Yer screwed... */ /* this fixes it by giving the function something to do (return) */ } return; } } }
int calcMoveBonus(CharData *ch) { int bonus = 0; if (affected_by_spell(ch, SKILL_ADRENALINE)) bonus += GET_LEVEL(ch); if(GET_RACE(ch) == RACE_STROLL) bonus += 20 + GET_LEVEL(ch)/2; if( GET_DEX(ch) > 18 ) bonus += (GET_DEX(ch) - 18)*3; if(affected_by_spell(ch, SPELL_REGENERATE)) bonus += spell_level(ch, SPELL_REGENERATE)/3 + GET_MAX_MOVE(ch)/6; return bonus; }
void appear(struct char_data *ch) { act("$n slowly fade into existence.", FALSE, ch,0,0,TO_ROOM); if (affected_by_spell(ch, SPELL_INVISIBLE)) affect_from_char(ch, SPELL_INVISIBLE); REMOVE_BIT(ch->specials.affected_by, AFF_INVISIBLE); }
struct obj_data *unequip_char(struct char_data * ch, int pos) { int j; struct obj_data *obj; assert(pos >= 0 && pos < NUM_WEARS); assert(GET_EQ(ch, pos)); obj = GET_EQ(ch, pos); obj->worn_by = NULL; obj->worn_on = -1; if (GET_OBJ_TYPE(obj) == ITEM_ARMOR) GET_AC(ch) += apply_ac(ch, pos); if (ch->in_room != NOWHERE) { if (pos == WEAR_LIGHT && GET_OBJ_TYPE(obj) == ITEM_LIGHT) if (GET_OBJ_VAL(obj, 2)) /* if light is ON */ world[ch->in_room].light--; } else { log("SYSERR: ch->in_room = NOWHERE when un-equipping char."); } GET_EQ(ch, pos) = NULL; for (j = 0; j < MAX_OBJ_AFFECT; j++) affect_modify(ch, obj->affected[j].location, obj->affected[j].modifier, obj->obj_flags.bitvector, FALSE); if (affected_by_spell(ch, SKILL_ENVENOM) && (pos == WEAR_WIELD)) { send_to_char("As your weapon leaves your hand, the venom on it dissipates.\r\n", ch); affect_from_char(ch, SKILL_ENVENOM); } if (affected_by_spell(ch, SPELL_ADAMANT_MACE) && (pos == WEAR_WIELD)) affect_from_char(ch, SPELL_ADAMANT_MACE); affect_total(ch); return (obj); }
void psionic_activity(struct creature *ch) { if (room_is_dark(ch->in_room) && !has_dark_sight(ch) && can_cast_spell(ch, SPELL_RETINA)) cast_spell(ch, ch, NULL, NULL, SPELL_RETINA); else if (GET_HIT(ch) < GET_MAX_HIT(ch) * 0.80) { if (can_cast_spell(ch, SPELL_CELL_REGEN)) cast_spell(ch, ch, NULL, NULL, SPELL_CELL_REGEN); else if (can_cast_spell(ch, SPELL_WOUND_CLOSURE)) cast_spell(ch, ch, NULL, NULL, SPELL_WOUND_CLOSURE); } else if (!AFF_FLAGGED(ch, AFF_NOPAIN) && !AFF_FLAGGED(ch, AFF_SANCTUARY) && can_cast_spell(ch, SPELL_NOPAIN)) cast_spell(ch, ch, NULL, NULL, SPELL_NOPAIN); else if (!room_has_air(ch->in_room) && !can_travel_sector(ch, ch->in_room->sector_type, 0) && can_cast_spell(ch, SPELL_BREATHING_STASIS) && !AFF3_FLAGGED(ch, AFF3_NOBREATHE)) cast_spell(ch, ch, NULL, NULL, SPELL_BREATHING_STASIS); else if (!AFF2_FLAGGED(ch, AFF2_TELEKINESIS) && can_cast_spell(ch, SPELL_TELEKINESIS)) cast_spell(ch, ch, NULL, NULL, SPELL_TELEKINESIS); else if (!affected_by_spell(ch, SPELL_DERMAL_HARDENING) && can_cast_spell(ch, SPELL_DERMAL_HARDENING)) cast_spell(ch, ch, NULL, NULL, SPELL_DERMAL_HARDENING); else if (!AFF3_FLAGGED(ch, AFF3_PSISHIELD) && can_cast_spell(ch, SPELL_PSISHIELD)) cast_spell(ch, ch, NULL, NULL, SPELL_PSISHIELD); else if (can_cast_spell(ch, SPELL_PSYCHIC_RESISTANCE) && !affected_by_spell(ch, SPELL_PSYCHIC_RESISTANCE)) cast_spell(ch, ch, NULL, NULL, SPELL_PSYCHIC_RESISTANCE); else if (can_cast_spell(ch, SPELL_POWER) && !affected_by_spell(ch, SPELL_POWER)) cast_spell(ch, ch, NULL, NULL, SPELL_POWER); else if (!AFF_FLAGGED(ch, AFF_CONFIDENCE) && can_cast_spell(ch, SPELL_CONFIDENCE)) cast_spell(ch, ch, NULL, NULL, SPELL_CONFIDENCE); }
void mage_activity(struct creature *ch) { if (room_is_dark(ch->in_room) && can_cast_spell(ch, SPELL_INFRAVISION) && !has_dark_sight(ch)) { cast_spell(ch, ch, NULL, NULL, SPELL_INFRAVISION); } else if (room_is_dark(ch->in_room) && can_cast_spell(ch, SPELL_GLOWLIGHT) && !has_dark_sight(ch)) { cast_spell(ch, ch, NULL, NULL, SPELL_GLOWLIGHT); } else if (can_cast_spell(ch, SPELL_PRISMATIC_SPHERE) && !AFF3_FLAGGED(ch, AFF3_PRISMATIC_SPHERE)) { cast_spell(ch, ch, NULL, NULL, SPELL_PRISMATIC_SPHERE); } else if (can_cast_spell(ch, SPELL_ANTI_MAGIC_SHELL) && !affected_by_spell(ch, SPELL_ANTI_MAGIC_SHELL)) { cast_spell(ch, ch, NULL, NULL, SPELL_ANTI_MAGIC_SHELL); } else if (can_cast_spell(ch, SPELL_HASTE) && !AFF2_FLAGGED(ch, AFF2_HASTE)) { cast_spell(ch, ch, NULL, NULL, SPELL_HASTE); } else if (can_cast_spell(ch, SPELL_DISPLACEMENT) && !AFF2_FLAGGED(ch, AFF2_DISPLACEMENT)) { cast_spell(ch, ch, NULL, NULL, SPELL_DISPLACEMENT); } else if (can_cast_spell(ch, SPELL_TRUE_SEEING) && !AFF2_FLAGGED(ch, AFF2_TRUE_SEEING)) { cast_spell(ch, ch, NULL, NULL, SPELL_TRUE_SEEING); } else if (can_cast_spell(ch, SPELL_REGENERATE) && !AFF_FLAGGED(ch, AFF_REGEN)) { cast_spell(ch, ch, NULL, NULL, SPELL_REGENERATE); } else if (can_cast_spell(ch, SPELL_FIRE_SHIELD) && !AFF2_FLAGGED(ch, AFF2_FIRE_SHIELD)) { cast_spell(ch, ch, NULL, NULL, SPELL_FIRE_SHIELD); } else if (can_cast_spell(ch, SPELL_STRENGTH) && !affected_by_spell(ch, SPELL_STRENGTH)) { cast_spell(ch, ch, NULL, NULL, SPELL_STRENGTH); } else if (can_cast_spell(ch, SPELL_BLUR) && !AFF_FLAGGED(ch, AFF_BLUR)) { cast_spell(ch, ch, NULL, NULL, SPELL_BLUR); } else if (can_cast_spell(ch, SPELL_ARMOR) && !affected_by_spell(ch, SPELL_ARMOR)) { cast_spell(ch, ch, NULL, NULL, SPELL_ARMOR); } }
// Returns true if a creature can see another creature bool check_sight_vict(struct creature * self, struct creature * vict) { // Immortals players can always see non-immortal players if (IS_IMMORT(self) && !IS_IMMORT(vict)) return true; // Nothing at all gets through immort invis if (IS_PC(self) && IS_IMMORT(vict) && GET_LEVEL(self) < GET_INVIS_LVL(vict)) return false; // Mortals can't see unapproved mobs if (!NPC2_FLAGGED(self, NPC2_UNAPPROVED) && NPC2_FLAGGED(vict, NPC2_UNAPPROVED) && !IS_IMMORT(self) && !is_authorized(self, TESTER, NULL)) return false; // Non-tester mortal players can't see testers if (!IS_IMMORT(self) && !IS_NPC(self) && !IS_IMMORT(vict) && !is_authorized(self, TESTER, NULL) && is_authorized(vict, TESTER, NULL)) return false; // Holy is the light that shines on the chosen if (PRF_FLAGGED(self, PRF_HOLYLIGHT)) return true; // Sonic imagery and retina detects transparent creatures if (AFF2_FLAGGED(vict, AFF2_TRANSPARENT) && !(AFF3_FLAGGED(self, AFF3_SONIC_IMAGERY) || AFF_FLAGGED(self, AFF_RETINA) || affected_by_spell(self, ZEN_AWARENESS))) return false; // True seeing and detect invisibility counteract all magical invis if (AFF2_FLAGGED(self, AFF2_TRUE_SEEING) || AFF_FLAGGED(self, AFF_DETECT_INVIS)) return true; // Invis/Transparent if (AFF_FLAGGED(vict, AFF_INVISIBLE)) return false; // Invis to Undead if (IS_UNDEAD(self) && AFF2_FLAGGED(vict, AFF2_INVIS_TO_UNDEAD)) return false; return true; }
/* place a character in a room */ void char_to_room(struct char_data * ch, room_rnum room) { if (ch == NULL || room < 0 || room > top_of_world) log("SYSERR: Illegal value(s) passed to char_to_room"); else { ch->next_in_room = world[room].people; world[room].people = ch; ch->in_room = room; if ( affected_by_spell(ch, SPELL_LIGHT) ) { world[ch->in_room].light += 10; } if ( affected_by_spell(ch, SPELL_DARKNESS) ) { world[ch->in_room].light -= 10; } if (GET_EQ(ch, WEAR_LIGHT)) if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2)) /* Light ON */ world[room].light++; } }
/* move a player out of a room */ void char_from_room(struct char_data * ch) { struct char_data *temp; if (ch == NULL || ch->in_room == NOWHERE) { log("SYSERR: NULL or NOWHERE in handler.c, char_from_room"); exit(1); } if (FIGHTING(ch) != NULL) { stop_fighting(ch); } if ( affected_by_spell(ch, SPELL_LIGHT) ) { world[ch->in_room].light -= 10; } if ( affected_by_spell(ch, SPELL_DARKNESS) ) { world[ch->in_room].light += 10; } if (GET_EQ(ch, WEAR_LIGHT) != NULL) { if (GET_OBJ_TYPE(GET_EQ(ch, WEAR_LIGHT)) == ITEM_LIGHT) { if (GET_OBJ_VAL(GET_EQ(ch, WEAR_LIGHT), 2)) { /* Light is ON */ world[ch->in_room].light--; } } } /* if (affected_by_spell(ch, SPELL_ENTANGLE)) affect_from_char(ch, SPELL_ENTANGLE); if (affected_by_spell(ch, SPELL_MIRE)) affect_from_char(ch, SPELL_MIRE); */ REMOVE_FROM_LIST(ch, world[ch->in_room].people, next_in_room); ch->in_room = NOWHERE; ch->next_in_room = NULL; }
void appear(struct char_data *ch) { if (affected_by_spell(ch, SPELL_INVISIBLE)) affect_from_char(ch, SPELL_INVISIBLE); REMOVE_BIT(AFF_FLAGS(ch), AFF_INVISIBLE | AFF_HIDE); if (GET_LEVEL(ch) < LVL_IMMORT) act("$n slowly fades into existence.", FALSE, ch, 0, 0, CommTarget::TO_ROOM); else act("You feel a strange presence as $n appears, seemingly from nowhere.", FALSE, ch, 0, 0, CommTarget::TO_ROOM); }
int calcHitBonus(CharData *ch) { int bonus = 0; if(GET_CON(ch) > 18) bonus += (GET_CON(ch) - 18)*5; if(affected_by_spell(ch, SPELL_REGENERATE)) bonus += spell_level(ch, SPELL_REGENERATE) + GET_MAX_HIT(ch)/8; if(IS_DEFENDER(ch)) bonus += 30 + 10*GET_ADVANCE_LEVEL(ch); return bonus; }
void cast_armor( byte level, struct char_data *ch, char *arg, int type, struct char_data *tar_ch, struct obj_data *tar_obj ) { switch (type) { case SPELL_TYPE_SPELL: if ( affected_by_spell(tar_ch, SPELL_ARMOR) ){ send_to_char("Nothing seems to happen.\r\n", ch); return; } if (ch != tar_ch) act("$N is protected by your deity.", FALSE, ch, 0, tar_ch, TO_CHAR); spell_armor(level,ch,tar_ch,0); break; case SPELL_TYPE_POTION: if ( affected_by_spell(ch, SPELL_ARMOR) ) return; spell_armor(level,ch,ch,0); break; case SPELL_TYPE_SCROLL: if (tar_obj) return; if (!tar_ch) tar_ch = ch; if ( affected_by_spell(tar_ch, SPELL_ARMOR) ) return; spell_armor(level,ch,ch,0); break; case SPELL_TYPE_WAND: if (tar_obj) return; if ( affected_by_spell(tar_ch, SPELL_ARMOR) ) return; spell_armor(level,ch,ch,0); break; default : log("Serious screw-up in armor!"); break; } }
void mag_unaffects(int level, struct char_data *ch, struct char_data *victim, int spellnum, int type) { int spell = 0, msg_not_affected = TRUE; const char *to_vict = NULL, *to_room = NULL; if (victim == NULL) return; switch (spellnum) { case SPELL_HEAL: /* * Heal also restores health, so don't give the "no effect" message * if the target isn't afflicted by the 'blindness' spell. */ msg_not_affected = FALSE; /* fall-through */ case SPELL_CURE_BLIND: spell = SPELL_BLINDNESS; to_vict = "Your vision returns!"; to_room = "There's a momentary gleam in $n's eyes."; break; case SPELL_REMOVE_POISON: spell = SPELL_POISON; to_vict = "A warm feeling runs through your body!"; to_room = "$n looks better."; break; case SPELL_REMOVE_CURSE: spell = SPELL_CURSE; to_vict = "You don't feel so unlucky."; break; default: log("SYSERR: unknown spellnum %d passed to mag_unaffects.", spellnum); return; } if (!affected_by_spell(victim, spell)) { if (msg_not_affected) send_to_char(ch, "%s", NOEFFECT); return; } affect_from_char(victim, spell); if (to_vict != NULL) act(to_vict, FALSE, victim, 0, ch, TO_CHAR); if (to_room != NULL) act(to_room, TRUE, victim, 0, ch, TO_ROOM); }
void check_berserk(CHAR_DATA * ch) { AFFECT_DATA af; struct timed_type timed; int prob; if (affected_by_spell(ch, SPELL_BERSERK) && (GET_HIT(ch) > GET_REAL_MAX_HIT(ch) / 2)) { affect_from_char(ch, SPELL_BERSERK); send_to_char("Предсмертное исступление оставило Вас.\r\n", ch); } //!IS_NPC(ch) && if (can_use_feat(ch, BERSERK_FEAT) && ch->get_fighting() && !timed_by_feat(ch, BERSERK_FEAT) && !AFF_FLAGGED(ch, AFF_BERSERK) && (GET_HIT(ch) < GET_REAL_MAX_HIT(ch) / 4)) { // if (!IS_NPC(ch)) { //Gorrah: вроде бы у мобов скиллы тикают так же, так что глюков быть не должно timed.skill = BERSERK_FEAT; timed.time = 4; timed_feat_to_char(ch, &timed); // } af.type = SPELL_BERSERK; af.duration = pc_duration(ch, 1, 60, 30, 0, 0); af.modifier = 0; af.location = APPLY_NONE; af.battleflag = 0; prob = IS_NPC(ch) ? 601 : (751 - GET_LEVEL(ch) * 5); if (number(1, 1000) < prob) { af.bitvector = AFF_BERSERK; act("Вас обуяла предсмертная ярость!", FALSE, ch, 0, 0, TO_CHAR); act("$n0 исступленно взвыл$g и бросил$u на противника!", FALSE, ch, 0, 0, TO_ROOM); } else { af.bitvector = 0; act("Вы истошно завопили, пытаясь напугать противника. Без толку.", FALSE, ch, 0, 0, TO_CHAR); act("$n0 истошно завопил$g, пытаясь напугать противника. Забавно...", FALSE, ch, 0, 0, TO_ROOM); } affect_join(ch, &af, TRUE, FALSE, TRUE, FALSE); } }
/* Hitpoint gain per game hour */ int hit_gain(CharData * ch) { // Character is messed if (IN_ROOM(ch) == -1) return 0; // Delusion health deflates fairly quickly if(affected_by_spell(ch, SKILL_DELUSION)) return -(GET_MAX_HIT(ch) * spell_level(ch, SKILL_DELUSION) / 9); /* Are they rotting away ? */ if (!IS_NPC(ch) && IS_UNDEAD(ch)) { return ( (GET_LEVEL(ch) < 50) && (ch->desc) ) ? -GET_LEVEL(ch) : 0; } /* Race calculations */ /* vampires don't regenerate in sunlight, unless they're shadow sphered */ if (!IS_NPC(ch) && IS_VAMPIRE(ch) && IS_SUNLIGHT(IN_ROOM(ch)) && !IS_AFFECTED(ch, AFF_SHADOW_SPHERE)) return 0; if(!IS_NPC(ch)) { int suffer = 0; if(ROOM_FLAGGED(ch->in_room, ROOM_SUFFER) && ( GET_LEVEL(ch) < LVL_IMMORT )) suffer = 1; else if(!GET_COND(ch, THIRST) && IS_AMARA(ch)) suffer = 1; else if (IS_IZARTI(ch) && IS_EVIL(ch)) suffer = 1; else if (IS_DEMON(ch) && IS_GOOD(ch)) suffer = 1; if(suffer == 1) { if(percentSuccess(2)) damage(ch, ch, -SUFFER_RATE, TYPE_ROOM_SUFFER); return 0; } } int base = calcHitBase(ch); int multiplier = calcHitMulti(ch); int bonus = calcHitBonus(ch); int gain = base*multiplier/100 + bonus; return (gain); }/* hit_gain */
void cast_bless( byte level, struct char_data *ch, char *arg, int type, struct char_data *tar_ch, struct obj_data *tar_obj ) { struct affected_type af; switch (type) { case SPELL_TYPE_SPELL: if (tar_obj) { /* It's an object */ if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_BLESS) ) { send_to_char("Nothing seems to happen.\r\n", ch); return; } spell_bless(level,ch,0,tar_obj); } else { /* Then it is a PC | NPC */ if ( affected_by_spell(tar_ch, SPELL_BLESS) || (GET_POS(tar_ch) == POSITION_FIGHTING)) { send_to_char("Nothing seems to happen.\r\n", ch); return; } spell_bless(level,ch,tar_ch,0); } break; case SPELL_TYPE_POTION: if ( affected_by_spell(ch, SPELL_BLESS) || (GET_POS(ch) == POSITION_FIGHTING)) return; spell_bless(level,ch,ch,0); break; case SPELL_TYPE_SCROLL: if (tar_obj) { /* It's an object */ if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_BLESS) ) return; spell_bless(level,ch,0,tar_obj); } else { /* Then it is a PC | NPC */ if (!tar_ch) tar_ch = ch; if ( affected_by_spell(tar_ch, SPELL_BLESS) || (GET_POS(tar_ch) == POSITION_FIGHTING)) return; spell_bless(level,ch,tar_ch,0); } break; case SPELL_TYPE_WAND: if (tar_obj) { /* It's an object */ if ( IS_SET(tar_obj->obj_flags.extra_flags, ITEM_BLESS) ) return; spell_bless(level,ch,0,tar_obj); } else { /* Then it is a PC | NPC */ if ( affected_by_spell(tar_ch, SPELL_BLESS) || (GET_POS(tar_ch) == POSITION_FIGHTING)) return; spell_bless(level,ch,tar_ch,0); } break; default : log("Serious screw-up in bless!"); break; } }
int calcHitBase(CharData *ch) { int base = 0; if(IS_NPC(ch)) base += 18; else { base += graf(age(ch).year, 37, 38, 43, 46, 40, 34, 32); } /* Level/Class bonuses */ switch(GET_CLASS(ch)) { case CLASS_WARRIOR: base += GET_LEVEL(ch)*5/3; break; case CLASS_RANGER: case CLASS_SOLAMNIC_KNIGHT: case CLASS_DEATH_KNIGHT: base += GET_LEVEL(ch)*4/3; break; case CLASS_THIEF: case CLASS_ASSASSIN: base += GET_LEVEL(ch); break; case CLASS_SHOU_LIN: case CLASS_CLERIC: case CLASS_SHADOW_DANCER: base += GET_LEVEL(ch)*2/3; break; case CLASS_MAGIC_USER: case CLASS_NECROMANCER: base += GET_LEVEL(ch)/3; break; default: mudlog(NRM, LVL_IMMORT, TRUE, "ERROR calcManaBase: %s's class not recognized!", GET_NAME(ch)); break; } if(affected_by_spell(ch, SKILL_ADRENALINE)) { struct affected_type *af; for (af = ch->affected; af; af = af->next) { if(af->type == SKILL_ADRENALINE) base += af->modifier; } } /* Position calculations */ switch (GET_POS(ch)) { case POS_MEDITATING: if(IS_CHI_WARRIOR(ch) && GET_ADVANCE_LEVEL(ch) >= SECOND_ADVANCE_SKILL) base += GET_LEVEL(ch)/10; case POS_SLEEPING: base += 20; /* Divide by 2 */ break; case POS_RESTING: base += 12; /* Divide by 4 */ break; } // Naturalist hunters get 1% bonus regen to pets per advance level. if (affected_by_spell(ch, SPELL_CALL_OF_THE_WILD) && ch->master && IS_NATURALIST(ch->master)) base += GET_MAX_HIT(ch)*GET_ADVANCE_LEVEL(ch->master)/100; return base; }
void perform_smoke(struct creature *ch, int type) { const char *to_vict = NULL; struct affected_type af; int hp_mod = 0, mana_mod = 0, move_mod = 0, spell = 0; uint8_t lev = 0; int accum_dur = 0, accum_affect = 0; init_affect(&af); af.type = SMOKE_EFFECTS; af.level = 30; af.owner = GET_IDNUM(ch); switch (type) { case SMOKE_DIRTWEED: to_vict = "Your head hurts."; af.duration = 3; af.modifier = -2; af.location = APPLY_INT; af.bitvector = AFF_CONFUSION; af.aff_index = 1; accum_dur = 1; accum_affect = 1; move_mod = -number(3, 10); mana_mod = -number(1, 2); break; case SMOKE_DESERTWEED: af.location = APPLY_MOVE; af.duration = 4; af.modifier = 10; mana_mod = dice(1, 4); move_mod = dice(3, 4); break; case SMOKE_INDICA: to_vict = "Your mind is elevated to another plane."; af.location = APPLY_WIS; af.duration = 5; af.modifier = number(1, 2); mana_mod = dice(6, 4); move_mod = -number(1, 3); break; case SMOKE_UNHOLY_REEFER: af.location = APPLY_WIS; af.duration = 5; af.modifier = number(0, 2); mana_mod = number(1, 4); move_mod = -number(1, 3); spell = SPELL_ESSENCE_OF_EVIL; lev = 20; break; case SMOKE_MARIJUANA: to_vict = "You feel stoned."; af.location = APPLY_INT; af.duration = 3; af.modifier = -1; mana_mod = dice(4, 4); break; case SMOKE_TOBACCO: af.location = APPLY_MOVE; af.duration = 3; af.modifier = -number(10, 20); accum_dur = 1; mana_mod = dice(3, 3); break; case SMOKE_HEMLOCK: to_vict = "The smoke burns your lungs!"; af.location = APPLY_HIT; af.duration = number(3, 6); af.modifier = -number(30, 60); accum_affect = 1; hp_mod = -number(10, 16); mana_mod = -10; move_mod = -10; spell = SPELL_POISON; lev = LVL_AMBASSADOR; break; case SMOKE_PEYOTE: to_vict = "You feel a strange sensation."; spell = SPELL_ASTRAL_SPELL; lev = LVL_GRIMP; af.location = APPLY_MANA; af.modifier = number(10, 20); af.duration = number(1, 3); move_mod = number(6, 12); break; case SMOKE_HOMEGROWN: to_vict = "There's no place like home..."; spell = SPELL_WORD_OF_RECALL; lev = number(30, 60); mana_mod = number(20, 40); move_mod = number(2, 10); break; default: af.type = 0; break; } if (to_vict) act(to_vict, false, ch, NULL, NULL, TO_CHAR); GET_HIT(ch) = MIN(MAX(GET_HIT(ch) + hp_mod, 0), GET_MAX_HIT(ch)); GET_MANA(ch) = MIN(MAX(GET_MANA(ch) + mana_mod, 0), GET_MAX_MANA(ch)); GET_MOVE(ch) = MIN(MAX(GET_MOVE(ch) + move_mod, 0), GET_MAX_MOVE(ch)); if (af.type && (!affected_by_spell(ch, af.type) || accum_affect || accum_dur)) affect_join(ch, &af, accum_dur, true, accum_affect, true); if (spell && lev) call_magic(ch, ch, NULL, NULL, spell, (int)lev, CAST_CHEM); WAIT_STATE(ch, 6); }
void psionic_best_attack(struct creature *ch, struct creature *vict) { int aggression = calculate_mob_aggression(ch, vict); // Psions can't really do anything when there's a psishield in place if (AFF3_FLAGGED(vict, AFF3_PSISHIELD) && can_cast_spell(ch, SPELL_PSIONIC_SHATTER)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSIONIC_SHATTER); return; } if (aggression > 75) { // extremely aggressive - just attack hard if (!affected_by_spell(vict, SPELL_PSYCHIC_SURGE) && can_cast_spell(ch, SPELL_PSYCHIC_SURGE)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_SURGE); return; } else if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return; } else if (GET_POSITION(vict) > POS_SITTING && can_cast_spell(ch, SPELL_EGO_WHIP)) { cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP); return; } } if (aggression > 50) { // somewhat aggressive - balance attacking with crippling if (!affected_by_spell(vict, SPELL_PSYCHIC_CRUSH) && can_cast_spell(ch, SPELL_PSYCHIC_CRUSH)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_CRUSH); return; } else if (!affected_by_spell(vict, SPELL_MOTOR_SPASM) && can_cast_spell(ch, SPELL_MOTOR_SPASM)) { cast_spell(ch, vict, NULL, NULL, SPELL_MOTOR_SPASM); return; } else if (GET_POSITION(vict) > POS_SITTING && can_cast_spell(ch, SPELL_EGO_WHIP)) { cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP); return; } else if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return; } } if (aggression > 25) { // not very aggressive - play more defensively if (!IS_CONFUSED(vict) && can_cast_spell(ch, SPELL_CONFUSION) && (IS_MAGE(vict) || IS_PSIONIC(vict) || IS_CLERIC(vict) || IS_KNIGHT(vict) || IS_PHYSIC(vict))) { cast_spell(ch, vict, NULL, NULL, SPELL_CONFUSION); return; } else if (!AFF2_FLAGGED(ch, AFF2_VERTIGO) && can_cast_spell(ch, SPELL_VERTIGO)) { cast_spell(ch, vict, NULL, NULL, SPELL_VERTIGO); return; } else if (!affected_by_spell(vict, SPELL_PSYCHIC_FEEDBACK) && can_cast_spell(ch, SPELL_PSYCHIC_FEEDBACK)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_FEEDBACK); return; } else if (nullpsi_is_advisable(vict) && can_cast_spell(ch, SPELL_NULLPSI)) { cast_spell(ch, vict, NULL, NULL, SPELL_NULLPSI); return; } else if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return; } } if (aggression > 5) { // attempt to neutralize or get away if (GET_POSITION(vict) > POS_SLEEPING && can_cast_spell(ch, SPELL_MELATONIC_FLOOD)) { cast_spell(ch, vict, NULL, NULL, SPELL_MELATONIC_FLOOD); return; } else if (can_cast_spell(ch, SPELL_ASTRAL_SPELL)) { cast_spell(ch, vict, NULL, NULL, SPELL_ASTRAL_SPELL); return; } else if (can_cast_spell(ch, SPELL_AMNESIA)) { cast_spell(ch, vict, NULL, NULL, SPELL_AMNESIA); return; } else if (can_cast_spell(ch, SPELL_FEAR)) { cast_spell(ch, vict, NULL, NULL, SPELL_FEAR); return; } } // desperation - just attack full force, as hard as possible if (!affected_by_spell(vict, SPELL_PSYCHIC_SURGE) && can_cast_spell(ch, SPELL_PSYCHIC_SURGE)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_SURGE); return; } else if (!affected_by_spell(vict, SPELL_PSYCHIC_CRUSH) && can_cast_spell(ch, SPELL_PSYCHIC_CRUSH)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_CRUSH); return; } else if (!affected_by_spell(vict, SPELL_MOTOR_SPASM) && can_cast_spell(ch, SPELL_MOTOR_SPASM)) { cast_spell(ch, vict, NULL, NULL, SPELL_MOTOR_SPASM); return; } else if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return; } else if (GET_POSITION(vict) > POS_SITTING && can_cast_spell(ch, SPELL_EGO_WHIP)) { cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP); return; } else if (GET_POSITION(vict) > POS_SLEEPING && can_cast_spell(ch, SPELL_MELATONIC_FLOOD)) { cast_spell(ch, vict, NULL, NULL, SPELL_MELATONIC_FLOOD); return; } else if (can_cast_spell(ch, SPELL_ASTRAL_SPELL)) { cast_spell(ch, vict, NULL, NULL, SPELL_ASTRAL_SPELL); return; } else if (can_cast_spell(ch, SPELL_AMNESIA)) { cast_spell(ch, vict, NULL, NULL, SPELL_AMNESIA); return; } else if (can_cast_spell(ch, SPELL_FEAR)) { cast_spell(ch, vict, NULL, NULL, SPELL_FEAR); return; } else { hit(ch, vict, TYPE_UNDEFINED); } }
void mag_affects(int level, struct char_data *ch, struct char_data *victim, int spellnum, int savetype) { struct affected_type af[MAX_SPELL_AFFECTS]; bool accum_affect = FALSE, accum_duration = FALSE; const char *to_vict = NULL, *to_room = NULL; int i; if (victim == NULL || ch == NULL) return; for (i = 0; i < MAX_SPELL_AFFECTS; i++) { af[i].type = spellnum; af[i].bitvector = 0; af[i].modifier = 0; af[i].location = APPLY_NONE; } switch (spellnum) { case SPELL_CHILL_TOUCH: af[0].location = APPLY_STR; if (mag_savingthrow(victim, savetype, 0)) af[0].duration = 1; else af[0].duration = 4; af[0].modifier = -1; accum_duration = TRUE; to_vict = "You feel your strength wither!"; break; case SPELL_ARMOR: af[0].location = APPLY_AC; af[0].modifier = -20; af[0].duration = 24; accum_duration = TRUE; to_vict = "You feel someone protecting you."; break; case SPELL_BLESS: af[0].location = APPLY_HITROLL; af[0].modifier = 2; af[0].duration = 6; af[1].location = APPLY_SAVING_SPELL; af[1].modifier = -1; af[1].duration = 6; accum_duration = TRUE; to_vict = "You feel righteous."; break; case SPELL_BLINDNESS: if (MOB_FLAGGED(victim,MOB_NOBLIND) || mag_savingthrow(victim, savetype, 0)) { send_to_char(ch, "You fail.\r\n"); return; } af[0].location = APPLY_HITROLL; af[0].modifier = -4; af[0].duration = 2; af[0].bitvector = AFF_BLIND; af[1].location = APPLY_AC; af[1].modifier = 40; af[1].duration = 2; af[1].bitvector = AFF_BLIND; to_room = "$n seems to be blinded!"; to_vict = "You have been blinded!"; break; case SPELL_CURSE: if (mag_savingthrow(victim, savetype, 0)) { send_to_char(ch, "%s", NOEFFECT); return; } af[0].location = APPLY_HITROLL; af[0].duration = 1 + (GET_LEVEL(ch) / 2); af[0].modifier = -1; af[0].bitvector = AFF_CURSE; af[1].location = APPLY_DAMROLL; af[1].duration = 1 + (GET_LEVEL(ch) / 2); af[1].modifier = -1; af[1].bitvector = AFF_CURSE; accum_duration = TRUE; accum_affect = TRUE; to_room = "$n briefly glows red!"; to_vict = "You feel very uncomfortable."; break; case SPELL_DETECT_ALIGN: af[0].duration = 12 + level; af[0].bitvector = AFF_DETECT_ALIGN; accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_DETECT_INVIS: af[0].duration = 12 + level; af[0].bitvector = AFF_DETECT_INVIS; accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_DETECT_MAGIC: af[0].duration = 12 + level; af[0].bitvector = AFF_DETECT_MAGIC; accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_INFRAVISION: af[0].duration = 12 + level; af[0].bitvector = AFF_INFRAVISION; accum_duration = TRUE; to_vict = "Your eyes glow red."; to_room = "$n's eyes glow red."; break; case SPELL_INVISIBLE: if (!victim) victim = ch; af[0].duration = 12 + (GET_LEVEL(ch) / 4); af[0].modifier = -40; af[0].location = APPLY_AC; af[0].bitvector = AFF_INVISIBLE; accum_duration = TRUE; to_vict = "You vanish."; to_room = "$n slowly fades out of existence."; break; case SPELL_POISON: if (mag_savingthrow(victim, savetype, 0)) { send_to_char(ch, "%s", NOEFFECT); return; } af[0].location = APPLY_STR; af[0].duration = GET_LEVEL(ch); af[0].modifier = -2; af[0].bitvector = AFF_POISON; to_vict = "You feel very sick."; to_room = "$n gets violently ill!"; break; case SPELL_PROT_FROM_EVIL: af[0].duration = 24; af[0].bitvector = AFF_PROTECT_EVIL; accum_duration = TRUE; to_vict = "You feel invulnerable!"; break; case SPELL_SANCTUARY: af[0].duration = 4; af[0].bitvector = AFF_SANCTUARY; accum_duration = TRUE; to_vict = "A white aura momentarily surrounds you."; to_room = "$n is surrounded by a white aura."; break; case SPELL_SLEEP: if (!pk_allowed && !IS_NPC(ch) && !IS_NPC(victim)) return; if (MOB_FLAGGED(victim, MOB_NOSLEEP)) return; if (mag_savingthrow(victim, savetype, 0)) return; af[0].duration = 4 + (GET_LEVEL(ch) / 4); af[0].bitvector = AFF_SLEEP; if (GET_POS(victim) > POS_SLEEPING) { send_to_char(victim, "You feel very sleepy... Zzzz......\r\n"); act("$n goes to sleep.", TRUE, victim, 0, 0, TO_ROOM); GET_POS(victim) = POS_SLEEPING; } break; case SPELL_STRENGTH: if (GET_ADD(victim) == 100) return; af[0].location = APPLY_STR; af[0].duration = (GET_LEVEL(ch) / 2) + 4; af[0].modifier = 1 + (level > 18); accum_duration = TRUE; accum_affect = TRUE; to_vict = "You feel stronger!"; break; case SPELL_SENSE_LIFE: to_vict = "Your feel your awareness improve."; af[0].duration = GET_LEVEL(ch); af[0].bitvector = AFF_SENSE_LIFE; accum_duration = TRUE; break; case SPELL_WATERWALK: af[0].duration = 24; af[0].bitvector = AFF_WATERWALK; accum_duration = TRUE; to_vict = "You feel webbing between your toes."; break; } /* * If this is a mob that has this affect set in its mob file, do not * perform the affect. This prevents people from un-sancting mobs * by sancting them and waiting for it to fade, for example. */ if (IS_NPC(victim) && !affected_by_spell(victim, spellnum)) for (i = 0; i < MAX_SPELL_AFFECTS; i++) if (AFF_FLAGGED(victim, af[i].bitvector)) { send_to_char(ch, "%s", NOEFFECT); return; } /* * If the victim is already affected by this spell, and the spell does * not have an accumulative effect, then fail the spell. */ if (affected_by_spell(victim,spellnum) && !(accum_duration||accum_affect)) { send_to_char(ch, "%s", NOEFFECT); return; } for (i = 0; i < MAX_SPELL_AFFECTS; i++) if (af[i].bitvector || (af[i].location != APPLY_NONE)) affect_join(victim, af+i, accum_duration, FALSE, accum_affect, FALSE); if (to_vict != NULL) act(to_vict, FALSE, victim, 0, ch, TO_CHAR); if (to_room != NULL) act(to_room, TRUE, victim, 0, ch, TO_ROOM); }
void affect_from_char_II(struct char_data * ch, int skill, int type, int action) { struct affected_type *aff, *next; struct affected_type *temp; struct affected_type af[3]; int i, k; bool accum_affect = FALSE, accum_duration = FALSE; for (aff = ch->affected; aff; aff = next) { next = aff->next; if (aff->type == type) { affect_modify(ch, aff->location, aff->modifier, aff->bitvector, FALSE); REMOVE_FROM_LIST(aff, ch->affected, next); free(aff); affect_total(ch); } } if (action == 2) { switch (skill) { case SPELL_POLYMORPH: if (PLR_FLAGGED(ch, PLR_RABBIT)){ REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel yourself growing, and your ears shrinking. You no longer feel like a rabbit.\r\n", ch); act("$n's body grows, $s ears shrinking. $n no longer looks like a rabbit.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_BIRD)) { REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel yourself growing and your feathers falling away. You no longer feel like a bird.\r\n", ch); act("$n's body grows, $s feathers falling away as it expands. $n no longer looks like a bird.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_WOLF)) { REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel your your fur shed and your teeth shrink. You no longer feel like a wolf.\r\n", ch); act("$n's teeth shrink, $s fur shedding. $n no longer looks like a wolf.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_BEAR)) { REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("Your claws shrink as does the rest of your body. You no longer feel like a bear.\r\n", ch); act("$n's claws shrink as does the rest of $s body. $n no longer looks like a bear.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_CAT)){ REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel your body growing, and your fur shedding. You no longer feel like a cat.\r\n", ch); act("$n's body slowly grows, $s fur shedding. $n no longer looks like a cat.\r\n", 0, ch, 0, 0, TO_ROOM); } for (k = 0; k < NUM_WEARS; k++) if (GET_EQ(ch, k)){ GET_OBJ_DISGUISE(GET_EQ(ch, k)) = 0; } if (affected_by_spell(ch, SPELL_FLIGHT)) affect_from_char_II(ch, SPELL_FLIGHT, SPELL_FLIGHT, 1); if (affected_by_spell(ch, SPELL_HASTE)) affect_from_char_II(ch, SPELL_HASTE, SPELL_HASTE, 1); break; case SKILL_STANCE: if (!AFF_FLAGGED(ch, AFF_TIRED)) { for (i = 0; i < 3; i++) { af[0].type = SPELL_DONTUSEME; af[0].location = APPLY_HITROLL; af[0].modifier = 2; af[0].duration = 7; af[0].bitvector = AFF_STANCE; af[1].type = SPELL_DONTUSEME; af[1].location = APPLY_AC; af[1].modifier = -50; af[1].duration = 7; af[1].bitvector = AFF_STANCE; af[2].type = SPELL_DONTUSEME; af[2].location = APPLY_STR; af[2].modifier = 2; af[2].duration = 7; af[2].bitvector = AFF_STANCE; if (af[i].bitvector || (af[i].location != APPLY_NONE)) { affect_join(ch, af+i, accum_duration, FALSE, accum_affect, FALSE); } } } break; default: break; } } }
bool psionic_mob_fight(struct creature *ch, struct creature *precious_vict) { struct creature *vict = NULL; if (!is_fighting(ch)) return false; // pick an enemy if (!(vict = choose_opponent(ch, precious_vict))) return false; int aggression = calculate_mob_aggression(ch, vict); // Psions can't really do anything when there's a psishield in place if (AFF3_FLAGGED(vict, AFF3_PSISHIELD) && can_cast_spell(ch, SPELL_PSIONIC_SHATTER)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSIONIC_SHATTER); return true; } // Prioritize healing with aggression if (GET_HIT(ch) < (GET_MAX_HIT(ch) * MIN(20, MAX(80, aggression)) / 100) && can_cast_spell(ch, SPELL_WOUND_CLOSURE)) { cast_spell(ch, ch, NULL, NULL, SPELL_WOUND_CLOSURE); return true; } if (aggression > 75) { // extremely aggressive - just attack hard if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return true; } else if (GET_POSITION(vict) > POS_SITTING && can_cast_spell(ch, SPELL_EGO_WHIP)) { cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP); return true; } } if (aggression > 50) { // somewhat aggressive - balance attacking with crippling if (GET_MANA(ch) < GET_MAX_MANA(ch) / 2 && can_cast_spell(ch, SKILL_PSIDRAIN) && can_psidrain(ch, vict, NULL, false)) { perform_psidrain(ch, vict); return true; } else if (!affected_by_spell(vict, SPELL_PSYCHIC_CRUSH) && can_cast_spell(ch, SPELL_PSYCHIC_CRUSH)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_CRUSH); return true; } else if (!affected_by_spell(vict, SPELL_MOTOR_SPASM) && can_cast_spell(ch, SPELL_MOTOR_SPASM)) { cast_spell(ch, vict, NULL, NULL, SPELL_MOTOR_SPASM); return true; } else if (!affected_by_spell(ch, SPELL_ADRENALINE) && can_cast_spell(ch, SPELL_ADRENALINE)) { cast_spell(ch, ch, NULL, NULL, SPELL_ADRENALINE); return true; } else if (GET_POSITION(vict) > POS_SITTING && can_cast_spell(ch, SPELL_EGO_WHIP)) { cast_spell(ch, vict, NULL, NULL, SPELL_EGO_WHIP); return true; } else if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return true; } } if (aggression > 25) { // not very aggressive - play more defensively if (IS_PSIONIC(vict) && !affected_by_spell(ch, SPELL_PSYCHIC_RESISTANCE) && can_cast_spell(ch, SPELL_PSYCHIC_RESISTANCE)) { cast_spell(ch, ch, NULL, NULL, SPELL_PSYCHIC_RESISTANCE); return true; } else if (!IS_CONFUSED(vict) && can_cast_spell(ch, SPELL_CONFUSION) && (IS_MAGE(vict) || IS_PSIONIC(vict) || IS_CLERIC(vict) || IS_KNIGHT(vict) || IS_PHYSIC(vict))) { cast_spell(ch, vict, NULL, NULL, SPELL_CONFUSION); return true; } else if (GET_MOVE(ch) < GET_MAX_MOVE(ch) / 4 && can_cast_spell(ch, SPELL_ENDURANCE)) { cast_spell(ch, ch, NULL, NULL, SPELL_ENDURANCE); return true; } else if (GET_MOVE(ch) < GET_MAX_MOVE(ch) / 4 && can_cast_spell(ch, SPELL_DERMAL_HARDENING)) { cast_spell(ch, ch, NULL, NULL, SPELL_DERMAL_HARDENING); return true; } else if (!AFF2_FLAGGED(ch, AFF2_VERTIGO) && can_cast_spell(ch, SPELL_VERTIGO)) { cast_spell(ch, vict, NULL, NULL, SPELL_VERTIGO); return true; } else if (!affected_by_spell(vict, SPELL_PSYCHIC_FEEDBACK) && can_cast_spell(ch, SPELL_PSYCHIC_FEEDBACK)) { cast_spell(ch, vict, NULL, NULL, SPELL_PSYCHIC_FEEDBACK); return true; } else if (!affected_by_spell(vict, SPELL_WEAKNESS) && can_cast_spell(ch, SPELL_WEAKNESS)) { cast_spell(ch, vict, NULL, NULL, SPELL_WEAKNESS); return true; } else if (!affected_by_spell(vict, SPELL_CLUMSINESS) && can_cast_spell(ch, SPELL_CLUMSINESS)) { cast_spell(ch, vict, NULL, NULL, SPELL_CLUMSINESS); return true; } else if (can_cast_spell(ch, SKILL_PSIBLAST)) { perform_offensive_skill(ch, vict, SKILL_PSIBLAST); return true; } } if (aggression > 5) { // attempt to neutralize or get away if (GET_POSITION(vict) > POS_SLEEPING && can_cast_spell(ch, SPELL_MELATONIC_FLOOD)) { cast_spell(ch, vict, NULL, NULL, SPELL_MELATONIC_FLOOD); return true; } else if (can_cast_spell(ch, SPELL_ASTRAL_SPELL)) { cast_spell(ch, vict, NULL, NULL, SPELL_ASTRAL_SPELL); return true; } else if (can_cast_spell(ch, SPELL_AMNESIA)) { cast_spell(ch, vict, NULL, NULL, SPELL_AMNESIA); return true; } else if (can_cast_spell(ch, SPELL_FEAR)) { cast_spell(ch, vict, NULL, NULL, SPELL_FEAR); return true; } } return false; }
void regen_update( void ) { CharData *i, *next_char; int hit, mana, move; int vivify_level; for( i = character_list; i; i = next_char ) { next_char = i->next; if(affected_by_spell(i, SKILL_EMACIATED) && (GET_COND(i, HUNGER) != 0 || IS_VAMPIRE(i)) && GET_COND(i, THIRST) != 0) { if(!affected_by_spell(i, SKILL_EMACIATED_MANA) && !affected_by_spell(i, SKILL_EMACIATED_HIT)) affect_from_char(i, SKILL_EMACIATED); else if(percentSuccess(4)) { affect_from_char(i, SKILL_EMACIATED_MANA); affect_from_char(i, SKILL_EMACIATED_HIT); } } // Dwarves sober up 3x faster than most races (unless they drink more...) if(IS_DWARF(i) && !number(0, 35)) gain_condition(i, DRUNK, -1); vivify_level = spell_level(i, SPELL_VIVIFY); affect_from_char(i, SPELL_VIVIFY); if(GET_POS(i) <= POS_MEDITATING) { add_affect(i, i, SPELL_VIVIFY, MIN(vivify_level + 1, 100), APPLY_NONE, 0, -1, 0, FALSE, FALSE, FALSE, FALSE); } if(GET_POS(i) >= POS_MORTALLYW) { hit = hit_gain(i); mana = mana_gain(i); move = move_gain(i); if(affected_by_spell(i, SPELL_VIVIFY)) { if(hit > 0) hit += spell_level(i, SPELL_VIVIFY) * GET_MAX_HIT(i)/600; if(mana > 0) mana += spell_level(i, SPELL_VIVIFY) * GET_MAX_MANA(i)/600; if(move > 0) move += spell_level(i, SPELL_VIVIFY) * GET_MAX_MOVE(i)/600; } // Regeneration is increased on pvp holidays. If you're incapactitated, you will // eventually recover. if(pvpHoliday(i)) { if (GET_POS(i) < POS_SLEEPING) hit = 20; else { hit = (hit > 0) ? hit *3 : 20; mana = (mana > 0) ? mana*2 : 40; move = (move > 0) ? move*2 : 40; } } // 72 seconds per tick... if(hit < 0 || GET_HIT(i) < GET_MAX_HIT(i)) { if(hit>0) GET_HIT(i) += hit/72 + (hit % 72 > number(0, 71)? 1:0); else GET_HIT(i) = MAX(GET_HIT(i) + hit/72 + (-hit % 72 > number(0, 71)?-1:0), -9); } else { int surplus = (GET_HIT(i) - GET_MAX_HIT(i)); GET_HIT(i) -= surplus / 72 + (surplus % 72 > number(0, 71)? 1:0); } if(mana>0) GET_MANA(i) = MAX(MIN(GET_MANA(i) + mana/72 + (mana % 72 > number(0, 71)?1:0), GET_MAX_MANA(i)), 0); else GET_MANA(i) = MIN(GET_MANA(i) + mana/72 + (-mana % 72 > number(0, 71)?-1:0), GET_MAX_MANA(i)); if(move>0) GET_MOVE(i) = MIN(GET_MOVE(i) + move/72 + (move % 72 > number(0, 71)?1:0), GET_MAX_MOVE(i)); else GET_MOVE(i) = MAX(MIN(GET_MOVE(i) + move/72 + (-move % 72 > number(0, 71)?-1:0), GET_MAX_MOVE(i)), 0); update_pos(i); } } }
int mag_affect_char(struct spell_info_type *sinfo, int affect_flag, struct char_data *caster, struct char_data *vict, int level) { struct affected_type af; int i; int spell = 0; int unaffect = 0; int circle = (level + 4) / 5; /* innate */ if (level == -1) { SET_BIT(AFF_FLAGS(vict), affect_flag); return 1; } if (sinfo->unaffect) { spell = spells[find_spell_num(sinfo->unaffect)].spellindex; unaffect = 1; } if (!unaffect) { af.type = sinfo->spellindex; af.bitvector = sinfo->spell_plr_bit; af.bitvector2 = sinfo->spell_plr_bit2; af.bitvector3 = sinfo->spell_plr_bit3; if (sinfo->spell_duration) af.duration = sinfo->spell_duration * 12; else af.duration = (SECS_PER_MUD_HOUR * level) / 15; /* level/3 mud hours duration */ af.duration = modBySpecialization(caster, sinfo, af.duration); gain_exp(caster, af.duration * 2); if (strcmp(sinfo->command, "stoneskin") == 0) af.duration = level * 5; for (i = 0; i < NUM_MODIFY; i++) { af.modifier[i] = 0; af.location[i] = 0; } for (i = 0; i < NUM_MODIFY; i++) { if (sinfo->plr_aff[i].location) { if (strcmp(sinfo->command, "vitality") == 0 || strcmp(sinfo->command, "vigorize") == 0) af.modifier[i] = (sinfo->plr_aff[i].modifier * level); else if (strcmp(sinfo->command, "barkskin") == 0) { af.modifier[i] = (sinfo->plr_aff[i].modifier - (3.5 * circle)); } else af.modifier[i] = sinfo->plr_aff[i].modifier; af.location[i] = sinfo->plr_aff[i].location; } } if (IS_NPC(vict) && IS_AFFECTED(vict, sinfo->spell_plr_bit) && IS_AFFECTED2(vict, sinfo->spell_plr_bit2) && IS_AFFECTED3(vict, sinfo->spell_plr_bit3) && !affected_by_spell(vict, sinfo->spellindex)) return 0; if (affected_by_spell(vict, sinfo->spellindex) && !(sinfo->accum_duration || sinfo->accum_affect)) return 0; affect_join(vict, &af, sinfo->accum_duration, sinfo->avg_duration, sinfo->accum_affect, sinfo->avg_affect); } else { if (affected_by_spell(vict, sinfo->spellindex) && !(sinfo->accum_duration || sinfo->accum_affect)) return 0; affect_from_char(vict, spell); } return 1; }