def spl_acid_breath(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_ACIDSHIELD): return if game_utils.number_percent() < 2 * level and not handler_magic.saves_spell(level, victim): for loc in victim.equipped.keys(): obj = victim.get_eq(loc) if not obj or game_utils.number_bits(2) != 0 or obj.flags.spellproof: continue if obj.item_type == merc.ITEM_ARMOR: if obj.value[0] > 0: handler_game.act("$p is pitted and etched!", victim, obj, None, merc.TO_CHAR) victim.armor -= obj.apply_ac() obj.value[0] -= 1 obj.cost = 0 victim.armor += obj.apply_ac() elif obj.item_type == merc.ITEM_CONTAINER: handler_game.act("$p fumes and dissolves!", victim, obj, None, merc.TO_CHAR) obj.extract() hpch = max(10, ch.hit) dam = game_utils.number_range(hpch // 16 + 1, hpch // 8) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_ACID)) else dam, sn)
def spell_chill_touch(sn, level, ch, victim, target): dam_each = [ 0, 0, 0, 6, 7, 8, 9, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if not handler_magic.saves_spell(level, victim, merc.DAM_COLD): handler_game.act("$n turns blue and shivers.", victim, None, None, merc.TO_ROOM) af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level af.duration = 6 af.location = merc.APPLY_STR af.modifier = -1 af.bitvector = 0 victim.affect_join(af) else: dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_COLD, True)
def spell_holy_word(sn, level, ch, victim, target): # RT really nasty high-level attack spell */ handler_game.act("$n utters a word of divine power! ", ch, None, None, merc.TO_ROOM) ch.send("You utter a word of divine power.\n") for vch_id in ch.in_room.people: vch = instance.characters[vch_id] if (ch.is_good() and vch.is_good()) or ( ch.is_evil() and vch.is_evil()) or ( ch.is_neutral() and vch.is_neutral()): vch.send("You feel full more powerful.\n") const.skill_table['frenzy'].spell_fun('frenzy', level, ch, vch, merc.TARGET_CHAR) const.skill_table['bless'].spell_fun('bless', level, ch, vch, merc.TARGET_CHAR) elif (ch.is_good() and state_checks.IS_EVIL(vch)) or ( ch.is_evil() and state_checks.IS_GOOD(vch)): if not fight.is_safe_spell(ch, vch, True): const.skill_table['curse'].spell_fun('curse', level, ch, vch, merc.TARGET_CHAR) vch.send("You are struck down! \n") dam = game_utils.dice(level, 6) fight.damage(ch, vch, dam, sn, merc.DAM_ENERGY, True) elif state_checks.IS_NEUTRAL(ch): if not fight.is_safe_spell(ch, vch, True): const.skill_table['curse'].spell_fun('curse', level // 2, ch, vch, merc.TARGET_CHAR) vch.send("You are struck down! \n") dam = game_utils.dice(level, 4) fight.damage(ch, vch, dam, sn, merc.DAM_ENERGY, True) ch.send("You feel drained.\n") ch.move = 0 ch.hit = ch.hit // 2
def spell_ray_of_truth(sn, level, ch, victim, target): if ch.is_evil(): victim = ch ch.send("The energy explodes inside you! \n") if victim != ch: handler_game.act("$n raises $s hand, and a blinding ray of light shoots forth! ", ch, None, None, merc.TO_ROOM) ch.send("You raise your hand and a blinding ray of light shoots forth! \n") if state_checks.IS_GOOD(victim): handler_game.act("$n seems unharmed by the light.", victim, None, victim, merc.TO_ROOM) victim.send("The light seems powerless to affect you.\n") return dam = game_utils.dice(level, 10) if handler_magic.saves_spell(level, victim, merc.DAM_HOLY): dam = dam // 2 align = victim.alignment align -= 350 if align < -1000: align = -1000 + (align + 1000) // 3 dam = (dam * align * align) // 1000000 fight.damage(ch, victim, dam, sn, merc.DAM_HOLY, True) const.skill_table['blindness'].spell_fun('blindness', 3 * level // 4, ch, victim, merc.TARGET_CHAR)
def spl_frost_breath(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_ICESHIELD): return if game_utils.number_percent( ) < 2 * level and not handler_magic.saves_spell(level, victim): for loc in victim.equipped.keys(): obj = victim.get_eq(loc) if not obj or game_utils.number_bits( 2) != 0 or obj.flags.spellproof: continue if obj.item_type == [ merc.ITEM_CONTAINER, merc.ITEM_DRINK_CON, merc.ITEM_POTION ]: handler_game.act("$p freezes and shatters!", victim, obj, None, merc.TO_CHAR) obj.extract() hpch = max(10, ch.hit) dam = game_utils.number_range(hpch // 16 + 1, hpch // 8) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage( ch, victim, dam * 0.5 if (not victim.is_npc() and victim.is_vampire()) else 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_COLD)) else 1, sn)
def spell_ray_of_truth(sn, level, ch, victim, target): if ch.is_evil(): victim = ch ch.send("The energy explodes inside you! \n") if victim != ch: handler_game.act( "$n raises $s hand, and a blinding ray of light shoots forth! ", ch, None, None, merc.TO_ROOM) ch.send( "You raise your hand and a blinding ray of light shoots forth! \n") if state_checks.IS_GOOD(victim): handler_game.act("$n seems unharmed by the light.", victim, None, victim, merc.TO_ROOM) victim.send("The light seems powerless to affect you.\n") return dam = game_utils.dice(level, 10) if handler_magic.saves_spell(level, victim, merc.DAM_HOLY): dam = dam // 2 align = victim.alignment align -= 350 if align < -1000: align = -1000 + (align + 1000) // 3 dam = (dam * align * align) // 1000000 fight.damage(ch, victim, dam, sn, merc.DAM_HOLY, True) const.skill_table['blindness'].spell_fun('blindness', 3 * level // 4, ch, victim, merc.TARGET_CHAR)
def spell_gas_breath(sn, level, ch, victim, target): handler_game.act("$n breathes out a cloud of poisonous gas! ", ch, None, None, merc.TO_ROOM) handler_game.act("You breath out a cloud of poisonous gas.", ch, None, None, merc.TO_CHAR) hpch = max(16, ch.hit) hp_dam = random.randint(hpch // 15 + 1, 8) dice_dam = game_utils.dice(level, 12) dam = max(hp_dam + dice_dam // 10, dice_dam + hp_dam // 10) effects.poison_effect(ch.in_room, level, dam, merc.TARGET_ROOM) for vch_id in ch.in_room.people: vch = instance.characters[vch_id] if fight.is_safe_spell( ch, vch, True) or (ch.is_npc() and vch.is_npc() and (ch.fighting == vch or vch.fighting == ch)): continue if handler_magic.saves_spell(level, vch, merc.DAM_POISON): effects.poison_effect(vch, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 2, sn, merc.DAM_POISON, True) else: effects.poison_effect(vch, level, dam, merc.TARGET_CHAR) fight.damage(ch, vch, dam, sn, merc.DAM_POISON, True)
def spl_general_purpose(sn, level, ch, victim, target): dam = game_utils.number_range(25, 100) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, dam, sn)
def spell_chill_touch(sn, level, ch, victim, target): dam_each = [0, 0, 0, 6, 7, 8, 9, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if not handler_magic.saves_spell(level, victim, merc.DAM_COLD): handler_game.act("$n turns blue and shivers.", victim, None, None, merc.TO_ROOM) af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = sn af.level = level af.duration = 6 af.location = merc.APPLY_STR af.modifier = -1 af.bitvector = 0 victim.affect_join(af) else: dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_COLD, True)
def spl_energy_drain(sn, level, ch, victim, target): if handler_magic.saves_spell(level, victim): return if not ch.is_hero(): ch.alignment = max(-1000, ch.alignment - 200) if victim.level <= 2: dam = ch.hit + 1 else: dam = game_utils.dice(1, level) if victim.is_npc() or not victim.immune.is_set(merc.IMM_DRAIN): victim.mana //= 2 victim.move //= 2 ch.hit += dam if ch.hit > (2 * ch.max_hit): ch.hit = (2 * ch.max_hit) fight.damage( ch, victim, 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_DRAIN)) else dam, sn) if not ch.is_npc() and ch != victim: ch.beastlike()
def spell_call_lightning(sn, level, ch, victim, target): if not state_checks.IS_OUTSIDE(ch): ch.send("You must be out of doors.\n") return if handler_game.weather_info.sky < merc.SKY_RAINING: ch.send("You need bad weather.\n") return dam = game_utils.dice(level // 2, 8) ch.send("Mota's lightning strikes your foes! \n") handler_game.act("$n calls Mota's lightning to strike $s foes! ", ch, None, None, merc.TO_ROOM) for vch in instance.characters.values(): if vch.in_room == None: continue if vch.in_room == ch.in_room: if vch is not ch and (not vch.is_npc() if ch.is_npc() else vch.is_npc()): fight.damage( ch, vch, dam // 2 if handler_magic.saves_spell( level, vch, merc.DAM_LIGHTNING) else dam, sn, merc.DAM_LIGHTNING, True) continue if vch.in_room.area == ch.in_room.area and state_checks.IS_OUTSIDE( vch) and vch.is_awake(): vch.send("Lightning flashes in the sky.\n")
def spl_fire_breath(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_FIRESHIELD): return if game_utils.number_percent() < 2 * level and not handler_magic.saves_spell(level, victim): for loc in victim.equipped.keys(): obj = victim.get_eq(loc) if not obj or game_utils.number_bits(2) != 0 or obj.flags.spellproof: continue item_list = [(merc.ITEM_CONTAINER, "$p ignites and burns!"), (merc.ITEM_POTION, "$p bubbles and boils!"), (merc.ITEM_SCROLL, "$p crackles and burns!"), (merc.ITEM_STAFF, "$p smokes and chars!"), (merc.ITEM_WAND, "$p sparks and sputters!"), (merc.ITEM_FOOD, "$p blackens and crisps!"), (merc.ITEM_PILL, "$p melts and drips!")] for (aa, bb) in item_list: if obj.item_type == aa: msg = bb break else: continue handler_game.act(msg, victim, obj, None, merc.TO_CHAR) obj.extract() hpch = max(10, ch.hit) dam = game_utils.number_range(hpch // 16 + 1, hpch // 8) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, dam * 2 if (not victim.is_npc() and victim.is_vampire()) else 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_HEAT)) else 1, sn)
def spl_call_lightning(sn, level, ch, victim, target): if not ch.is_outside(): ch.send("You must be out of doors.\n") return if handler_game.weather_info.sky < merc.SKY_RAINING: ch.send("You need bad weather.\n") return dam = game_utils.dice(level // 2, 8) ch.send("God's lightning strikes your foes!\n") handler_game.act("$n calls God's lightning to strike $s foes!", ch, None, None, merc.TO_ROOM) for vch in list(instance.characters.values()): if not vch.in_room: continue if vch.in_room == ch.in_room and vch != ch and (not vch.is_npc() if ch.is_npc() else vch.is_npc()): if vch.itemaff.is_set(merc.ITEMA_SHOCKSHIELD): continue if handler_magic.saves_spell(level, vch): dam //= 2 fight.damage(ch, vch, 0 if (not vch.is_npc() and vch.immune.is_set(merc.IMM_LIGHTNING)) else dam, sn) continue if vch.in_room.area == ch.in_room.area and vch.is_outside() and vch.is_awake(): vch.send("Lightning flashes in the sky.\n")
def spl_chaos_blast(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_CHAOSSHIELD): return dam = game_utils.dice(level, 6) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, dam, sn)
def spl_gas_breath(sn, level, ch, victim, target): for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if not vch.is_npc() if ch.is_npc() else vch.is_npc(): hpch = max(10, ch.hit) dam = game_utils.number_range(hpch // 16 + 1, hpch // 8) if handler_magic.saves_spell(level, vch): dam //= 2 fight.damage(ch, vch, 0 if (not vch.is_npc() and vch.is_vampire()) else dam, sn)
def spell_fireball(sn, level, ch, victim, target): dam_each = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_FIRE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_FIRE, True)
def spell_shocking_grasp(sn, level, ch, victim, target): dam_each = [ 0, 0, 0, 0, 0, 0, 0, 20, 25, 29, 33, 36, 39, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_LIGHTNING): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_LIGHTNING, True)
def spl_acid_blast(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_ACIDSHIELD): return dam = game_utils.dice(level, 6) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage( ch, victim, 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_ACID)) else dam, sn)
def spell_burning_hands(sn, level, ch, victim, target): dam_each = [ 0, 0, 0, 0, 0, 14, 17, 20, 23, 26, 29, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_FIRE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_FIRE, True)
def spell_magic_missile(sn, level, ch, victim, target): dam_each = [ 0, 3, 3, 4, 4, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_ENERGY): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_ENERGY, True)
def spell_lightning_bolt(sn, level, ch, victim, target): dam_each = [0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 28, 31, 34, 37, 40, 40, 41, 42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 50, 50, 51, 52, 52, 53, 54, 54, 55, 56, 56, 57, 58, 58, 59, 60, 60, 61, 62, 62, 63, 64] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_LIGHTNING): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_LIGHTNING, True)
def spell_burning_hands(sn, level, ch, victim, target): dam_each = [0, 0, 0, 0, 0, 14, 17, 20, 23, 26, 29, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_FIRE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_FIRE, True)
def spl_flamestrike(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_FIRESHIELD): return dam = game_utils.dice(6, 8) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage( ch, victim, dam * 2 if (not victim.is_npc() and victim.is_vampire()) else 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_HEAT)) else 0, sn)
def spl_lightning_breath(sn, level, ch, victim, target): if victim.itemaff.is_set(merc.ITEMA_SHOCKSHIELD): return hpch = max(10, ch.hit) dam = game_utils.number_range(hpch // 16 + 1, hpch // 8) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage( ch, victim, 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_LIGHTNING)) else dam, sn)
def spell_frost_breath(sn, level, ch, victim, target): handler_game.act("$n breathes out a freezing cone of frost! ", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n breathes a freezing cone of frost over you! ", ch, None, victim, merc.TO_VICT) handler_game.act("You breath out a cone of frost.", ch, None, None, merc.TO_CHAR) hpch = max(12, ch.hit) hp_dam = random.randint(hpch // 11 + 1, hpch // 6) dice_dam = game_utils.dice(level, 16) dam = max(hp_dam + dice_dam // 10, dice_dam + hp_dam // 10) effects.cold_effect(victim.in_room, level, dam // 2, merc.TARGET_ROOM) for vch in victim.in_room.people[:]: if fight.is_safe_spell(ch, vch, True) or (vch.is_npc() and ch.is_npc() and (ch.fighting != vch or vch.fighting != ch)): continue if vch == victim: # full damage */ if handler_magic.saves_spell(level, vch, merc.DAM_COLD): effects.cold_effect(vch, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 2, sn, merc.DAM_COLD, True) else: effects.cold_effect(vch, level, dam, merc.TARGET_CHAR) fight.damage(ch, vch, dam, sn, merc.DAM_COLD, True) else: if handler_magic.saves_spell(level - 2, vch, merc.DAM_COLD): effects.cold_effect(vch, level // 4, dam // 8, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 4, sn, merc.DAM_COLD, True) else: effects.cold_effect(vch, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 2, sn, merc.DAM_COLD, True)
def spl_magic_missile(sn, level, ch, victim, target): dam_each = [ 0, 3, 3, 4, 4, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 20, 25, 30, 35, 40, 45, 55, 65, 75 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = game_utils.number_range(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, dam, sn)
def spl_chill_touch(sn, level, ch, victim, target): dam_each = [9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120] level = min(level, len(dam_each) - 1) level = max(0, level) dam = game_utils.number_range(dam_each[level] // 2, dam_each[level] * 2) no_dam = (not victim.is_npc() and victim.immune.is_set(merc.IMM_COLD)) if not no_dam and (not handler_magic.saves_spell(level, victim) or victim.is_npc() or not victim.is_vampire()): aff = handler_game.AffectData(type=sn, duration=6, location=merc.APPLY_STR, modifier=-1) victim.affect_add(aff) else: dam //= 2 fight.damage(ch, victim, 0 if no_dam else dam, sn)
def spl_colour_spray(sn, level, ch, victim, target): dam_each = [ 10, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20, 30, 35, 40, 45, 50, 55, 55, 55, 56, 57, 58, 58, 59, 60, 61, 61, 62, 63, 64, 64, 65, 66, 67, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 75, 76, 76, 77, 78, 79, 79, 85, 95, 110, 125, 150, 175, 200, 250, 300, 350 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = game_utils.number_range(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, dam, sn)
def spell_lightning_breath(sn, level, ch, victim, target): handler_game.act("$n breathes a bolt of lightning at $N.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n breathes a bolt of lightning at you! ", ch, None, victim, merc.TO_VICT) handler_game.act("You breathe a bolt of lightning at $N.", ch, None, victim, merc.TO_CHAR) hpch = max(10, ch.hit) hp_dam = random.randint(hpch // 9 + 1, hpch // 5) dice_dam = game_utils.dice(level, 20) dam = max(hp_dam + dice_dam // 10, dice_dam + hp_dam // 10) if handler_magic.saves_spell(level, victim, merc.DAM_LIGHTNING): effects.shock_effect(victim, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, victim, dam // 2, sn, merc.DAM_LIGHTNING, True) else: effects.shock_effect(victim, level, dam, merc.TARGET_CHAR) fight.damage(ch, victim, dam, sn, merc.DAM_LIGHTNING, True)
def spell_colour_spray(sn, level, ch, victim, target): dam_each = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 35, 40, 45, 50, 55, 55, 55, 56, 57, 58, 58, 59, 60, 61, 61, 62, 63, 64, 64, 65, 66, 67, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 75, 76, 76, 77, 78, 79, 79] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_LIGHT): dam //= 2 else: const.skill_table["blindness"].spell_fun('blindness', level // 2, ch, victim, merc.TARGET_CHAR) fight.damage(ch, victim, dam, sn, merc.DAM_LIGHT, True)
def spell_demonfire(sn, level, ch, victim, target): # RT replacement demonfire spell */ if not ch.is_npc() and not ch.is_evil(): victim = ch ch.send("The demons turn upon you! \n") ch.alignment = max(-1000, ch.alignment - 50) if victim != ch: handler_game.act("$n calls forth the demons of Hell upon $N! ", ch, None, victim, merc.TO_ROOM) handler_game.act("$n has assailed you with the demons of Hell! ", ch, None, victim, merc.TO_VICT) ch.send("You conjure forth the demons of hell! \n") dam = game_utils.dice(level, 10) if handler_magic.saves_spell(level, victim, merc.DAM_NEGATIVE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_NEGATIVE, True) const.skill_table['curse'].spell_fun('curse', 3 * level // 4, ch, victim, merc.TARGET_CHAR)
def spl_shocking_grasp(sn, level, ch, victim, target): dam_each = [10, 10, 10, 15, 15, 15, 20, 20, 25, 29, 33, 36, 39, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 60, 70, 85, 100, 125, 150, 175, 200, 225, 300] if victim.itemaff.is_set(merc.ITEMA_SHOCKSHIELD): return level = min(level, len(dam_each) - 1) level = max(0, level) dam = game_utils.number_range(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, 0 if (not victim.is_npc() and victim.immune.is_set(merc.IMM_LIGHTNING)) else dam, sn)
def spell_colour_spray(sn, level, ch, victim, target): dam_each = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 35, 40, 45, 50, 55, 55, 55, 56, 57, 58, 58, 59, 60, 61, 61, 62, 63, 64, 64, 65, 66, 67, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 75, 76, 76, 77, 78, 79, 79 ] level = min(level, len(dam_each) - 1) level = max(0, level) dam = random.randint(dam_each[level] // 2, dam_each[level] * 2) if handler_magic.saves_spell(level, victim, merc.DAM_LIGHT): dam //= 2 else: const.skill_table["blindness"].spell_fun('blindness', level // 2, ch, victim, merc.TARGET_CHAR) fight.damage(ch, victim, dam, sn, merc.DAM_LIGHT, True)
def spell_earthquake(sn, level, ch, victim, target): ch.send("The earth trembles beneath your feet! \n") handler_game.act("$n makes the earth tremble and shiver.", ch, None, None, merc.TO_ROOM) for vch in instance.characters.values(): if not vch.in_room: continue if vch.in_room == ch.in_room: if vch != ch and not fight.is_safe_spell(ch, vch, True): if state_checks.IS_AFFECTED(vch, merc.AFF_FLYING): fight.damage(ch, vch, 0, sn, merc.DAM_BASH, True) else: fight.damage(ch, vch, level + game_utils.dice(2, 8), sn, merc.DAM_BASH, True) continue if vch.in_room.area == ch.in_room.area: vch.send("The earth trembles and shivers.\n")
def spl_earthquake(sn, level, ch, victim, target): ch.send("The earth trembles beneath your feet!\n") handler_game.act("$n makes the earth tremble and shiver.", ch, None, None, merc.TO_ROOM) for vch in list(instance.characters.values()): if not vch.in_room: continue if vch.in_room == ch.in_room: if vch != ch and (not vch.is_npc() if ch.is_npc() else vch.is_npc()): fight.damage(ch, vch, level + game_utils.dice(2, 8), sn) continue if vch.in_room.area == ch.in_room.area: vch.send("The earth trembles and shivers.\n")
def cmd_backstab(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Backstab whom?\n") return victim = ch.get_char_room(arg) if not victim: ch.not_here(arg) return if victim == ch: ch.not_self() return if fight.is_safe(ch, victim): return item = ch.get_eq("right_hand") if not item or item.value[3] != 11: item = ch.get_eq("left_hand") if not item or item.value[3] != 11: ch.send("You need to wield a piercing weapon.\n") return if victim.fighting: ch.send("You can't backstab a fighting person.\n") return if victim.hit < victim.max_hit: handler_game.act("$N is hurt and suspicious ... you can't sneak up.", ch, None, victim, merc.TO_CHAR) return fight.check_killer(ch, victim) ch.wait_state(const.skill_table["backstab"].beats) if not victim.is_npc() and victim.immune.is_set(merc.IMM_BACKSTAB): fight.damage(ch, victim, 0, "backstab") elif not victim.is_npc() or ch.is_npc( ) or game_utils.number_percent() < ch.learned["backstab"]: fight.multi_hit(ch, victim, "backstab") else: fight.damage(ch, victim, 0, "backstab")
def spell_acid_breath(sn, level, ch, victim, target): # NPC spells. handler_game.act("$n spits acid at $N.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n spits a stream of corrosive acid at you.", ch, None, victim, merc.TO_VICT) handler_game.act("You spit acid at $N.", ch, None, victim, merc.TO_CHAR) hpch = max(12, ch.hit) hp_dam = random.randint(hpch // 11 + 1, hpch // 6) dice_dam = game_utils.dice(level, 16) dam = max(hp_dam + dice_dam // 10, dice_dam + hp_dam // 10) if handler_magic.saves_spell(level, victim, merc.DAM_ACID): effects.acid_effect(victim, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, victim, dam // 2, sn, merc.DAM_ACID, True) else: effects.acid_effect(victim, level, dam, merc.TARGET_CHAR) fight.damage(ch, victim, dam, sn, merc.DAM_ACID, True)
def spell_dispel_good(sn, level, ch, victim, target): if not ch.is_npc() and ch.is_good(): victim = ch if state_checks.IS_EVIL(victim): handler_game.act("$N is protected by $S evil.", ch, None, victim, merc.TO_ROOM) return if state_checks.IS_NEUTRAL(victim): handler_game.act("$N does not seem to be affected.", ch, None, victim, merc.TO_CHAR) return if victim.hit > (ch.level * 4): dam = game_utils.dice(level, 4) else: dam = max(victim.hit, game_utils.dice(level, 4)) if handler_magic.saves_spell(level, victim, merc.DAM_NEGATIVE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_NEGATIVE, True)
def do_backstab(ch, argument): argument, arg = game_utils.read_word(argument) if not arg: ch.send("Backstab whom?\n") return victim = None if ch.fighting: ch.send("You're facing the wrong end.\n") return else: victim = ch.get_char_room(arg) if not victim: ch.send("They aren't here.\n") return if victim == ch: ch.send("How can you sneak up on yourself?\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.fighting and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n") return item = ch.get_eq('main_hand') if not item: ch.send("You need to wield a weapon to backstab.\n") return if victim.hit < victim.max_hit // 3: handler_game.act("$N is hurt and suspicious ... you can't sneak up.", ch, None, victim, merc.TO_CHAR) return fight.check_killer(ch, victim) state_checks.WAIT_STATE(ch, const.skill_table['backstab'].beats ) if random.randint(1, 99) < ch.get_skill('backstab') \ or (ch.get_skill('backstab') >= 2 and not state_checks.IS_AWAKE(victim)): if ch.is_pc(): ch.check_improve('backstab',True,1) fight.multi_hit(ch, victim, 'backstab') else: if ch.is_pc(): ch.check_improve('backstab', False, 1) fight.damage(ch, victim, 0, 'backstab', merc.DAM_NONE, True) return
def spell_energy_drain(sn, level, ch, victim, target): # Drain XP, MANA, HP. # Caster gains HP. if victim != ch: ch.alignment = max(-1000, ch.alignment - 50) if handler_magic.saves_spell(level, victim, merc.DAM_NEGATIVE): victim.send("You feel a momentary chill.\n") return if victim.level <= 2: dam = ch.hit + 1 else: update.gain_exp(victim, 0 - random.randint(level // 2, 3 * level // 2)) victim.mana //= 2 victim.move //= 2 dam = game_utils.dice(1, level) ch.hit += dam victim.send("You feel your life slipping away! \n") ch.send("Wow....what a rush! \n") fight.damage(ch, victim, dam, sn, merc.DAM_NEGATIVE, True)
def spell_gas_breath(sn, level, ch, victim, target): handler_game.act("$n breathes out a cloud of poisonous gas! ", ch, None, None, merc.TO_ROOM) handler_game.act("You breath out a cloud of poisonous gas.", ch, None, None, merc.TO_CHAR) hpch = max(16, ch.hit) hp_dam = random.randint(hpch // 15 + 1, 8) dice_dam = game_utils.dice(level, 12) dam = max(hp_dam + dice_dam // 10, dice_dam + hp_dam // 10) effects.poison_effect(ch.in_room, level, dam, merc.TARGET_ROOM) for vch_id in ch.in_room.people: vch = instance.characters[vch_id] if fight.is_safe_spell(ch, vch, True) or (ch.is_npc() and vch.is_npc() and (ch.fighting == vch or vch.fighting == ch)): continue if handler_magic.saves_spell(level, vch, merc.DAM_POISON): effects.poison_effect(vch, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 2, sn, merc.DAM_POISON, True) else: effects.poison_effect(vch, level, dam, merc.TARGET_CHAR) fight.damage(ch, vch, dam, sn, merc.DAM_POISON, True)
def spell_chain_lightning(sn, level, ch, victim, target): # H first strike */ handler_game.act("A lightning bolt leaps from $n's hand and arcs to $N.", ch, None, victim, merc.TO_ROOM) handler_game.act("A lightning bolt leaps from your hand and arcs to $N.", ch, None, victim, merc.TO_CHAR) handler_game.act("A lightning bolt leaps from $n's hand and hits you! ", ch, None, victim, merc.TO_VICT) dam = game_utils.dice(level, 6) if handler_magic.saves_spell(level, victim, merc.DAM_LIGHTNING): dam = dam // 3 fight.damage(ch, victim, dam, sn, merc.DAM_LIGHTNING, True) last_vict = victim level = level - 4 # decrement damage */ # new targets */ while level > 0: found = False for tmp_vict_id in ch.in_room.people: tmp_vict = instance.characters[tmp_vict_id] if not fight.is_safe_spell(ch, tmp_vict, True) and tmp_vict is not last_vict: found = True last_vict = tmp_vict handler_game.act("The bolt arcs to $n! ", tmp_vict, None, None, merc.TO_ROOM) handler_game.act("The bolt hits you! ", tmp_vict, None, None, merc.TO_CHAR) dam = game_utils.dice(level, 6) if handler_magic.saves_spell(level, tmp_vict, merc.DAM_LIGHTNING): dam = dam // 3 fight.damage(ch, tmp_vict, dam, sn, merc.DAM_LIGHTNING, True) level = level - 4 # decrement damage */ if not found: # no target found, hit the caster */ if ch == None: return if last_vict == ch: # no double hits */ handler_game.act("The bolt seems to have fizzled out.", ch, None, None, merc.TO_ROOM) handler_game.act("The bolt grounds out through your body.", ch, None, None, merc.TO_CHAR) return last_vict = ch handler_game.act("The bolt arcs to $n...whoops! ", ch, None, None, merc.TO_ROOM) ch.send("You are struck by your own lightning! \n") dam = game_utils.dice(level, 6) if handler_magic.saves_spell(level, ch, merc.DAM_LIGHTNING): dam = dam // 3 fight.damage(ch, ch, dam, sn, merc.DAM_LIGHTNING, True) level = level - 4 # decrement damage */ if ch == None: return
def spell_harm(sn, level, ch, victim, target): dam = max(20, victim.hit - game_utils.dice(1, 4)) if handler_magic.saves_spell(level, victim, merc.DAM_HARM): dam = min(50, dam // 2) dam = min(100, dam) fight.damage(ch, victim, dam, sn, merc.DAM_HARM, True)
def spell_cause_serious(sn, level, ch, victim, target): fight.damage(ch, victim, game_utils.dice(2, 8) + level // 2, sn, merc.DAM_HARM, True) return
def spell_flamestrike(sn, level, ch, victim, target): dam = game_utils.dice(6 + level // 2, 8) if handler_magic.saves_spell(level, victim, merc.DAM_FIRE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_FIRE, True)
def spell_high_explosive(sn, level, ch, victim, target): dam = random.randint(30, 120) if handler_magic.saves_spell(level, victim, merc.DAM_PIERCE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_PIERCE, True)
def spell_heat_metal(sn, level, ch, victim, target): fail = True if not handler_magic.saves_spell(level + 2, victim, merc.DAM_FIRE) \ and not state_checks.IS_SET(victim.imm_flags, merc.IMM_FIRE): total_items = set({}) total_items.update([an_item for an_item in victim.equipped.values()]) total_items.update(victim.contents) for item_id in total_items: item = instance.items[item_id] if random.randint(1, 2 * level) > item.level \ and not handler_magic.saves_spell(level, victim, merc.DAM_FIRE) \ and not item.flags.no_n_metal and not item.flags.burn_proof: if item.item_type == merc.ITEM_ARMOR: if item.equipped_to: # remove the item */ if victim.can_drop_item(item) \ and (item.weight // 10) < random.randint(1, 2 * victim.stat(merc.STAT_DEX)) \ and victim.unequip(item.equipped_to, True): handler_game.act("$n yelps and throws $p to the ground! ", victim, item, None, merc.TO_ROOM) handler_game.act("You remove and drop $p before it burns you.", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 3) victim.get(item) victim.in_room.put(item) fail = False else: # stuck on the body! ouch! */ handler_game.act("Your skin is seared by $p! ", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level)) fail = False else: # drop it if we can */ if victim.can_drop_item(item): handler_game.act("$n yelps and throws $p to the ground! ", victim, item, None, merc.TO_ROOM) handler_game.act("You and drop $p before it burns you.", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 6) victim.get(item) victim.in_room.put(item) fail = False else: # can! drop */ handler_game.act("Your skin is seared by $p! ", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 2) fail = False if item.item_type == merc.ITEM_WEAPON: if item.equipped_to: # try to drop it */ if item.flags.flaming: continue if victim.can_drop_item(item) and victim.unequip(item.equipped_to, True): handler_game.act("$n is burned by $p, and throws it to the ground.", victim, item, None, merc.TO_ROOM) victim.send("You throw your red-hot weapon to the ground! \n") dam += 1 victim.get(item) victim.in_room.put(item) fail = False else: # YOWCH! */ victim.send("Your weapon sears your flesh! \n") dam += random.randint(1, item.level) fail = False else: # drop it if we can */ if victim.can_drop_item(item): handler_game.act("$n throws a burning hot $p to the ground! ", victim, item, None, merc.TO_ROOM) handler_game.act("You and drop $p before it burns you.", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 6) victim.get(item) victim.in_room.put(item) fail = False else: # can! drop */ handler_game.act("Your skin is seared by $p! ", victim, item, None, merc.TO_CHAR) dam += (random.randint(1, item.level) // 2) fail = False if fail: ch.send("Your spell had no effect.\n") victim.send("You feel momentarily warmer.\n") else: # damage! */ if handler_magic.saves_spell(level, victim, merc.DAM_FIRE): dam = 2 * dam // 3 fight.damage(ch, victim, dam, sn, merc.DAM_FIRE, True)
def spell_cause_critical(sn, level, ch, victim, target): fight.damage(ch, victim, game_utils.dice(3, 8) + level - 6, sn, merc.DAM_HARM, True) return
def do_trip(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('trip') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_TRIP)) \ or ( not ch.is_npc() and ch.level < const.skill_table['trip'].skill_level[ch.guild.name]): ch.send("Tripping? What's that?\n\r") return if not arg: victim = ch.fighting if victim is None: ch.send("But you aren't fighting anyone!\n\r") return else: victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n\r") return if fight.is_safe(ch,victim): return if victim.is_npc() and victim.fighting and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n\r") return if victim.is_affected( merc.AFF_FLYING): handler_game.act("$S feet aren't on the ground.",ch,None,victim, merc.TO_CHAR) return if victim.position < merc.POS_FIGHTING: handler_game.act("$N is already down.",ch,None,victim, merc.TO_CHAR) return if victim == ch: ch.send("You fall flat on your face!\n\r") state_checks.WAIT_STATE(ch,2 * const.skill_table['trip'].beats) handler_game.act("$n trips over $s own feet!",ch,None,None, merc.TO_ROOM) return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: handler_game.act("$N is your beloved master.",ch,None,victim, merc.TO_CHAR) return # modifiers */ # size */ if ch.size < victim.size: chance += (ch.size - victim.size) * 10 # bigger = harder to trip */ # dex */ chance += ch.stat(merc.STAT_DEX) chance -= victim.stat(merc.STAT_DEX) * 3 // 2 # speed */ if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected(merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 20 # level */ chance += (ch.level - victim.level) * 2 # now the attack */ if random.randint(1,99) < chance: handler_game.act("$n trips you and you go down!",ch,None,victim, merc.TO_VICT) handler_game.act("You trip $N and $N goes down!",ch,None,victim, merc.TO_CHAR) handler_game.act("$n trips $N, sending $M to the ground.",ch,None,victim, merc.TO_NOTVICT) if ch.is_pc(): ch.check_improve('trip', True, 1) state_checks.DAZE_STATE(victim,2 * merc.PULSE_VIOLENCE) state_checks.WAIT_STATE(ch,const.skill_table['trip'].beats) victim.position = merc.POS_RESTING fight.damage(ch,victim,random.randint(2, 2 + 2 * victim.size),'trip', merc.DAM_BASH,True) else: fight.damage(ch,victim,0,'trip', merc.DAM_BASH,True) state_checks.WAIT_STATE(ch,const.skill_table['trip'].beats*2 // 3) if ch.is_pc(): ch.check_improve('trip', False, 1) fight.check_killer(ch,victim)
def char_update(): # update save counter */ global save_number save_number += 1 if save_number > 29: save_number = 0 ch_quit = [] id_list = [instance_id for instance_id in instance.characters.keys()] for character_id in id_list: ch = instance.characters[character_id] if ch.timer > 30: ch_quit.append(ch) if ch.position >= merc.POS_STUNNED: # check to see if we need to go home */ if ch.is_npc() and ch.zone and ch.zone != instance.area_templates[ch.zone] \ and not ch.desc and not ch.fighting\ and not ch.is_affected(merc.AFF_CHARM) and random.randint(1, 99) < 5: handler_game.act("$n wanders on home.", ch, None, None, merc.TO_ROOM) ch.extract(True) id_list.remove(character_id) continue if ch.hit < ch.max_hit: ch.hit += hit_gain(ch) else: ch.hit = ch.max_hit if ch.mana < ch.max_mana: ch.mana += mana_gain(ch) else: ch.mana = ch.max_mana if ch.move < ch.max_move: ch.move += move_gain(ch) else: ch.move = ch.max_move if ch.position == merc.POS_STUNNED: fight.update_pos(ch) if not ch.is_npc() and ch.level < merc.LEVEL_IMMORTAL: item = ch.get_eq('light') if item and item.item_type == merc.ITEM_LIGHT and item.value[2] > 0: item.value[2] -= 1 if item.value[2] == 0 and ch.in_room is not None: ch.in_room.available_light -= 1 handler_game.act("$p goes out.", ch, item, None, merc.TO_ROOM) handler_game.act("$p flickers and goes out.", ch, item, None, merc.TO_CHAR) item.extract() elif item.value[2] <= 5 and ch.in_room: handler_game.act("$p flickers.", ch, item, None, merc.TO_CHAR) if ch.is_immortal(): ch.timer = 0 ch.timer += 1 if ch.timer >= 12: if not ch.was_in_room and ch.in_room: ch.was_in_room = ch.in_room if ch.fighting: fight.stop_fighting(ch, True) handler_game.act("$n disappears into the void.", ch, None, None, merc.TO_ROOM) ch.send("You disappear into the void.\n") if ch.level > 1: ch.save() limbo_id = instance.instances_by_room[merc.ROOM_VNUM_LIMBO][0] limbo = instance.rooms[limbo_id] ch.in_room.get(ch) limbo.put(ch) gain_condition(ch, merc.COND_DRUNK, -1) gain_condition(ch, merc.COND_FULL, -4 if ch.size > merc.SIZE_MEDIUM else -2) gain_condition(ch, merc.COND_THIRST, -1) gain_condition(ch, merc.COND_HUNGER, -2 if ch.size > merc.SIZE_MEDIUM else -1) for paf in ch.affected[:]: if paf.duration > 0: paf.duration -= 1 if random.randint(0, 4) == 0 and paf.level > 0: paf.level -= 1 # spell strength fades with time */ elif paf.duration < 0: pass else: # multiple affects. don't send the spelldown msg multi = [a for a in ch.affected if a.type == paf.type and a is not paf and a.duration > 0] if not multi and paf.type and const.skill_table[paf.type].msg_off: ch.send(const.skill_table[paf.type].msg_off + "\n") ch.affect_remove(paf) # # * Careful with the damages here, # * MUST NOT refer to ch after damage taken, # * as it may be lethal damage (on NPC). # */ if state_checks.is_affected(ch, 'plague') and ch: if ch.in_room is None: continue handler_game.act("$n writhes in agony as plague sores erupt from $s skin.", ch, None, None, merc.TO_ROOM) ch.send("You writhe in agony from the plague.\n") af = [a for a in ch.affected if af.type == 'plague'][:1] if not af: ch.affected_by.rem_bit(merc.AFF_PLAGUE) continue if af.level == 1: continue plague = handler_game.AFFECT_DATA() plague.where = merc.TO_AFFECTS plague.type = 'plague' plague.level = af.level - 1 plague.duration = random.randint(1, 2 * plague.level) plague.location = merc.APPLY_STR plague.modifier = -5 plague.bitvector = merc.AFF_PLAGUE for vch_id in ch.in_room.people[:]: vch = instance.characters[vch_id] if not handler_magic.saves_spell(plague.level - 2, vch, merc.DAM_DISEASE) and not vch.is_immmortal() \ and not vch.is_affected(merc.AFF_PLAGUE) and random.randint(0, 4) == 0: vch.send("You feel hot and feverish.\n") handler_game.act("$n shivers and looks very ill.", vch, None, None, merc.TO_ROOM) vch.affect_join(plague) dam = min(ch.level, af.level // 5 + 1) ch.mana -= dam ch.move -= dam fight.damage(ch, ch, dam, 'plague', merc.DAM_DISEASE, False) elif ch.is_affected(merc.AFF_POISON) and ch and not ch.is_affected(merc.AFF_SLOW): poison = state_checks.affect_find(ch.affected, 'poison') if poison: handler_game.act("$n shivers and suffers.", ch, None, None, merc.TO_ROOM) ch.send("You shiver and suffer.\n") fight.damage(ch, ch, poison.level // 10 + 1, 'poison', merc.DAM_POISON, False) elif ch.position == merc.POS_INCAP and random.randint(0, 1) == 0: fight.damage(ch, ch, 1, merc.TYPE_UNDEFINED, merc.DAM_NONE, False) elif ch.position == merc.POS_MORTAL: fight.damage(ch, ch, 1, merc.TYPE_UNDEFINED, merc.DAM_NONE, False) # # * Autosave and autoquit. # * Check that these chars still exist. # */ for ch in instance.characters.values(): if not ch.is_npc() and ch.desc and save_number == 28: ch.save() for ch in ch_quit[:]: ch.do_quit("")
def spell_acid_blast(sn, level, ch, victim, target): dam = game_utils.dice(level, 12) if handler_magic.saves_spell(level, victim, merc.DAM_ACID): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_ACID, True)
def do_dirt(ch, argument): arghold, arg = game_utils.read_word(argument) chance = ch.get_skill('dirt kicking') if chance == 0 or (ch.is_npc() and not ch.off_flags.is_set(merc.OFF_KICK_DIRT)) \ or ( not ch.is_npc() and ch.level < const.skill_table['dirt kicking'].skill_level[ch.guild.name]): ch.send("You get your feet dirty.\n") return if not arg: victim = ch.fighting if victim is None: ch.send("But you aren't in combat!\n") return else: victim = ch.get_char_room(arg) if victim is None: ch.send("They aren't here.\n") return if victim.is_affected( merc.AFF_BLIND): handler_game.act("$E's already been blinded.", ch, None, victim, merc.TO_CHAR) return if victim == ch: ch.send("Very funny.\n") return if fight.is_safe(ch, victim): return if victim.is_npc() and victim.fighting is not None and not ch.is_same_group(victim.fighting): ch.send("Kill stealing is not permitted.\n") return if ch.is_affected(merc.AFF_CHARM) and ch.master == victim: handler_game.act("But $N is such a good friend!", ch, None, victim, merc.TO_CHAR) return # modifiers # dexterity chance += ch.stat(merc.STAT_DEX) chance -= 2 * victim.stat(merc.STAT_DEX) # speed if (ch.is_npc() and ch.off_flags.is_set(merc.OFF_FAST)) or ch.is_affected(merc.AFF_HASTE): chance += 10 if (victim.is_npc() and victim.off_flags.is_set(merc.OFF_FAST)) or victim.is_affected( merc.AFF_HASTE): chance -= 25 # level chance += (ch.level - victim.level) * 2 # sloppy hack to prevent false zeroes if chance % 5 == 0: chance += 1 # terrain nochance = [merc.SECT_WATER_SWIM, merc.SECT_WATER_NOSWIM, merc.SECT_AIR] modifiers = {merc.SECT_INSIDE: -20, merc.SECT_CITY: -10, merc.SECT_FIELD: 5, merc.SECT_MOUNTAIN: -10, merc.SECT_DESERT: 10 } if ch.in_room.sector_type in nochance: chance = 0 elif ch.in_room.sector_type in modifiers: chance += modifiers[ch.in_room.sector_type] if chance == 0: ch.send("There isn't any dirt to kick.\n") return # now the attack if random.randint(1, 99) < chance: handler_game.act("$n is blinded by the dirt in $s eyes!", victim, None, None, merc.TO_ROOM) handler_game.act("$n kicks dirt in your eyes!", ch, None, victim, merc.TO_VICT) fight.damage(ch, victim, random.randint(2, 5), 'dirt kicking', merc.DAM_NONE, False) victim.send("You can't see a thing!\n") if ch.is_pc(): ch.check_improve( 'dirt kicking', True, 2) state_checks.WAIT_STATE(ch, const.skill_table['dirt kicking'].beats) af = handler_game.AFFECT_DATA() af.where = merc.TO_AFFECTS af.type = 'dirt kicking' af.level = ch.level af.duration = 0 af.location = merc.APPLY_HITROLL af.modifier = -4 af.bitvector = merc.AFF_BLIND victim.affect_add(af) else: fight.damage(ch, victim, 0, 'dirt kicking', merc.DAM_NONE, True) if ch.is_pc(): ch.check_improve( 'dirt kicking', False, 2) state_checks.WAIT_STATE(ch, const.skill_table['dirt kicking'].beats) fight.check_killer(ch, victim)
def spell_general_purpose(sn, level, ch, victim, target): dam = random.randint(25, 100) if handler_magic.saves_spell(level, victim, merc.DAM_PIERCE): dam = dam // 2 fight.damage(ch, victim, dam, sn, merc.DAM_PIERCE, True) return
def spell_cause_light(sn, level, ch, victim, target): fight.damage(ch, victim, game_utils.dice(1, 8) + level // 3, sn, merc.DAM_HARM, True) fight.check_killer return