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_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_control_weather(sn, level, ch, victim, target): if victim.lower() == "better": handler_game.weather_info.change += game_utils.dice(level // 3, 4) elif victim.lower() == "worse": handler_game.weather_info.change -= game_utils.dice(level // 3, 4) else: ch.send("Do you want it to get better or worse?\n") ch.send("Ok.\n") return
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_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_cure_critical(sn, level, ch, victim, target): heal = game_utils.dice(3, 8) + level - 6 victim.hit = min(victim.hit + heal, victim.max_hit) fight.update_pos(victim) victim.send("You feel better! \n") if ch != victim: ch.send("Ok.\n")
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 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_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_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_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 spell_cure_serious(sn, level, ch, victim, target): heal = game_utils.dice(2, 8) + level // 2 victim.hit = min(victim.hit + heal, victim.max_hit) fight.update_pos(victim) victim.send("You feel better! \n") if ch != victim: ch.send("Ok.\n")
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 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_cure_critical(sn, level, ch, victim, target): heal = game_utils.dice(3, 8) + level - 6 victim.hit = min(victim.hit + heal, victim.max_hit) fight.update_pos(victim) victim.send("You feel better!\n") if ch != victim: ch.send("Ok.\n") if not ch.is_npc(): ch.humanity()
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 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 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_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 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 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_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 spl_dispel_evil(sn, level, ch, victim, target): if not ch.is_npc() and ch.is_evil(): victim = ch if victim.is_good(): handler_game.act("God protects $N.", ch, None, victim, merc.TO_ROOM) return if victim.is_neutral(): handler_game.act("$N does not seem to be affected.", ch, None, victim, merc.TO_CHAR) return dam = game_utils.dice(level, 4) if handler_magic.saves_spell(level, victim): dam //= 2 fight.damage(ch, victim, dam, sn) if not ch.is_npc() and ch != victim: ch.humanity()
def spell_fire_breath(sn, level, ch, victim, target): handler_game.act("$n breathes forth a cone of fire.", ch, None, victim, merc.TO_NOTVICT) handler_game.act("$n breathes a cone of hot fire over you! ", ch, None, victim, merc.TO_VICT) handler_game.act("You breath forth a cone of fire.", ch, None, None, 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) effects.fire_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_FIRE): effects.fire_effect(vch, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 2, sn, merc.DAM_FIRE, True) else: effects.fire_effect(vch, level, dam, merc.TARGET_CHAR) fight.damage(ch, vch, dam, sn, merc.DAM_FIRE, True) else: # partial damage */ if handler_magic.saves_spell(level - 2, vch, merc.DAM_FIRE): effects.fire_effect(vch, level // 4, dam // 8, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 4, sn, merc.DAM_FIRE, True) else: effects.fire_effect(vch, level // 2, dam // 4, merc.TARGET_CHAR) fight.damage(ch, vch, dam // 2, sn, merc.DAM_FIRE, True)
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 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_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 create_mobile(npc_template): if npc_template is None: logger.critical("Create_mobile: None pMobIndex.") sys.exit(1) npc = handler_npc.Npc(npc_template) npc.id = game_utils.get_mob_id() if npc_template.spec_fun: npc.spec_fun = special.spec_table[npc_template.spec_fun] npc.prompt = None if npc_template.wealth == 0: npc.silver = 0 npc.gold = 0 else: wealth = random.randint(npc_template.wealth // 2, 3 * npc_template.wealth // 2) npc.gold = random.randint(wealth // 200, wealth // 100) npc.silver = wealth - (npc.gold * 100) if npc_template.new_format: # load in new style */ # read from prototype */ #npc.group = npc_template.group #npc.act.bits = npc_template.act.bits npc.comm.set_bit(merc.COMM_NOCHANNELS | merc.COMM_NOSHOUT | merc.COMM_NOTELL) #npc.affected_by.bits = npc_template.affected_by.bits #npc.alignment = npc_template.alignment #npc.level = npc_template.level #npc.hitroll = npc_template.hitroll #npc.damroll = npc_template.dam_dice[merc.DICE_BONUS] npc.max_hit = game_utils.dice(npc_template.hit_dice[merc.DICE_NUMBER], npc_template.hit_dice[merc.DICE_TYPE]) + npc_template.hit_dice[merc.DICE_BONUS] npc.hit = npc.max_hit npc.max_mana = game_utils.dice(npc_template.mana_dice[merc.DICE_NUMBER], npc_template.mana_dice[merc.DICE_TYPE]) + npc_template.mana_dice[merc.DICE_BONUS] npc.mana = npc.max_mana npc.damage[merc.DICE_NUMBER] = npc_template.dam_dice[merc.DICE_NUMBER] npc.damage[merc.DICE_TYPE] = npc_template.dam_dice[merc.DICE_TYPE] #npc.dam_type = npc_template.dam_type if npc.dam_type == 0: num = random.randint(1, 3) if num == 1: npc.dam_type = 3 # slash */ elif num == 2: npc.dam_type = 7 # pound */ elif num == 3: npc.dam_type = 11 # pierce */ for i in range(4): npc.armor[i] = npc_template.armor[i] #npc.off_flags.bits = npc_template.off_flags.bits #npc.imm_flags.bits = npc_template.imm_flags.bits #npc.res_flags.bits = npc_template.res_flags.bits #npc.vuln_flags.bits = npc_template.vuln_flags.bits #npc.start_pos = npc_template.start_pos #npc.default_pos = npc_template.default_pos #npc.sex = npc_template.sex if type(npc_template.sex) != int or npc.sex == 3: # random sex */ npc.sex = random.randint(1, 2) #npc.race = npc_template.race #npc.form.bits = npc_template.form.bits #npc.parts.bits = npc_template.parts.bits #npc.size = int(npc_template.size) #npc.material = npc_template.material # computed on the spot */ for i in range(merc.MAX_STATS): npc.perm_stat[i] = min(25, 11 + npc.level // 4) if npc.act.is_set(merc.ACT_WARRIOR): npc.perm_stat[merc.STAT_STR] += 3 npc.perm_stat[merc.STAT_INT] -= 1 npc.perm_stat[merc.STAT_CON] += 2 if npc.act.is_set(merc.ACT_THIEF): npc.perm_stat[merc.STAT_DEX] += 3 npc.perm_stat[merc.STAT_INT] += 1 npc.perm_stat[merc.STAT_WIS] -= 1 if npc.act.is_set(merc.ACT_CLERIC): npc.perm_stat[merc.STAT_WIS] += 3 npc.perm_stat[merc.STAT_DEX] -= 1 npc.perm_stat[merc.STAT_STR] += 1 if npc.act.is_set(merc.ACT_MAGE): npc.perm_stat[merc.STAT_INT] += 3 npc.perm_stat[merc.STAT_STR] -= 1 npc.perm_stat[merc.STAT_DEX] += 1 if npc.is_npc() and npc.off_flags.is_set(merc.OFF_FAST): npc.perm_stat[merc.STAT_DEX] += 2 npc.perm_stat[merc.STAT_STR] += npc.size - merc.SIZE_MEDIUM npc.perm_stat[merc.STAT_CON] += (npc.size - merc.SIZE_MEDIUM) // 2 af = handler_game.AFFECT_DATA() # let's get some spell action */ if npc.is_affected(merc.AFF_SANCTUARY): af.where = merc.TO_AFFECTS af.type = "sanctuary" af.level = npc.level af.duration = -1 af.location = merc.APPLY_NONE af.modifier = 0 af.bitvector = merc.AFF_SANCTUARY npc.affect_add(af) if npc.is_affected(merc.AFF_HASTE): af.where = merc.TO_AFFECTS af.type = "haste" af.level = npc.level af.duration = -1 af.location = merc.APPLY_DEX af.modifier = 1 + (npc.level >= 18) + (npc.level >= 25) + (npc.level >= 32) af.bitvector = merc.AFF_HASTE npc.affect_add(af) if npc.is_affected(merc.AFF_PROTECT_EVIL): af.where = merc.TO_AFFECTS af.type = "protection evil" af.level = npc.level af.duration = -1 af.location = merc.APPLY_SAVES af.modifier = -1 af.bitvector = merc.AFF_PROTECT_EVIL npc.affect_add(af) if npc.is_affected(merc.AFF_PROTECT_GOOD): af.where = merc.TO_AFFECTS af.type = "protection good" af.level = npc.level af.duration = -1 af.location = merc.APPLY_SAVES af.modifier = -1 af.bitvector = merc.AFF_PROTECT_GOOD npc.affect_add(af) else: # read in old format and convert */ #npc.act.bits = npc_template.act.bits #npc.affected_by.bits = npc_template.affected_by.bits #npc.alignment = npc_template.alignment #npc.level = npc_template.level #npc.hitroll = npc_template.hitroll npc.damroll = 0 npc.max_hit = npc.level * 8 + random.randint(npc.level * npc.level // 4, npc.level * npc.level) npc.max_hit *= .9 npc.hit = npc.max_hit npc.max_mana = 100 + game_utils.dice(npc.level, 10) npc.mana = npc.max_mana num = random.randint(1, 3) if num == 1: npc.dam_type = 3 # slash */ elif num == 2: npc.dam_type = 7 # pound */ elif num == 3: npc.dam_type = 11 # pierce */ for i in range(3): npc.armor[i] = game_utils.interpolate(npc.level, 100, -100) npc.armor[3] = game_utils.interpolate(npc.level, 100, 0) #npc.race = npc_template.race #npc.off_flags.bits = npc_template.off_flags.bits #npc.imm_flags.bits = npc_template.imm_flags.bits #npc.res_flags.bits = npc_template.res_flags.bits #npc.vuln_flags.bits = npc_template.vuln_flags.bits #npc.start_pos = npc_template.start_pos #npc.default_pos = npc_template.default_pos #npc.sex = npc_template.sex #npc.form.bits = npc_template.form.bits #npc.parts.bits = npc_template.parts.bits npc.size = merc.SIZE_MEDIUM npc.material = "" for i in merc.MAX_STATS: npc.perm_stat[i] = 11 + npc.level // 4 npc.position = npc.start_pos # link the mob to the world list */ return npc
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
def weather_update(): buf = "" handler_game.time_info.hour += 1 if handler_game.time_info.hour == 5: handler_game.weather_info.sunlight = merc.SUN_LIGHT buf = "The day has begun.\n" elif handler_game.time_info.hour == 6: handler_game.weather_info.sunlight = merc.SUN_RISE buf = "The sun rises in the east.\n" elif handler_game.time_info.hour == 19: handler_game.weather_info.sunlight = merc.SUN_SET buf = "The sun slowly disappears in the west.\n" elif handler_game.time_info.hour == 20: handler_game.weather_info.sunlight = merc.SUN_DARK buf = "The night has begun.\n" elif handler_game.time_info.hour == 24: handler_game.time_info.hour = 0 handler_game.time_info.day += 1 if handler_game.time_info.day >= 35: handler_game.time_info.day = 0 handler_game.time_info.month += 1 if handler_game.time_info.month >= 17: handler_game.time_info.month = 0 handler_game.time_info.year += 1 # # * Weather change. if 9 <= handler_game.time_info.month <= 16: diff = -2 if handler_game.weather_info.mmhg > 985 else 2 else: diff = -2 if handler_game.weather_info.mmhg > 1015 else 2 handler_game.weather_info.change += diff * game_utils.dice( 1, 4) + game_utils.dice(2, 6) - game_utils.dice(2, 6) handler_game.weather_info.change = max(handler_game.weather_info.change, -12) handler_game.weather_info.change = min(handler_game.weather_info.change, 12) handler_game.weather_info.mmhg += handler_game.weather_info.change handler_game.weather_info.mmhg = max(handler_game.weather_info.mmhg, 960) handler_game.weather_info.mmhg = min(handler_game.weather_info.mmhg, 1040) if handler_game.weather_info.sky == merc.SKY_CLOUDLESS: if handler_game.weather_info.mmhg < 990 or ( handler_game.weather_info.mmhg < 1010 and random.randint(0, 2) == 0): buf += "The sky is getting cloudy.\n" handler_game.weather_info.sky = merc.SKY_CLOUDY elif handler_game.weather_info.sky == merc.SKY_CLOUDY: if handler_game.weather_info.mmhg < 970 or ( handler_game.weather_info.mmhg < 990 and random.randint(0, 2) == 0): buf += "It starts to rain.\n" handler_game.weather_info.sky = merc.SKY_RAINING if handler_game.weather_info.mmhg > 1030 and random.randint(0, 2) == 0: buf += "The clouds disappear.\n" handler_game.weather_info.sky = merc.SKY_CLOUDLESS elif handler_game.weather_info.sky == merc.SKY_RAINING: if handler_game.weather_info.mmhg < 970 and number_bits(2) == 0: buf += "Lightning flashes in the sky.\n" handler_game.weather_info.sky = merc.SKY_LIGHTNING if handler_game.weather_info.mmhg > 1030 or ( handler_game.weather_info.mmhg > 1010 and random.randint(0, 2) == 0): buf += "The rain stopped.\n" handler_game.weather_info.sky = merc.SKY_CLOUDY elif handler_game.weather_info.sky == merc.SKY_LIGHTNING: if handler_game.weather_info.mmhg > 1010 or ( handler_game.weather_info.mmhg > 990 and random.randint(0, 2) == 0): buf += "The lightning has stopped.\n" handler_game.weather_info.sky = merc.SKY_RAINING else: print("Bug: Weather_update: bad sky %d." % handler_game.weather_info.sky) handler_game.weather_info.sky = merc.SKY_CLOUDLESS if buf: import nanny for char in instance.players.items(): if char.desc.is_connected( nanny.con_playing) and state_checks.IS_OUTSIDE( char) and state_checks.IS_AWAKE(char): char.send(buf) return
def weather_update(): buf = "" handler_game.time_info.hour += 1 if handler_game.time_info.hour == 5: handler_game.weather_info.sunlight = merc.SUN_LIGHT buf = "The day has begun.\n" elif handler_game.time_info.hour == 6: handler_game.weather_info.sunlight = merc.SUN_RISE buf = "The sun rises in the east.\n" elif handler_game.time_info.hour == 19: handler_game.weather_info.sunlight = merc.SUN_SET buf = "The sun slowly disappears in the west.\n" elif handler_game.time_info.hour == 20: handler_game.weather_info.sunlight = merc.SUN_DARK buf = "The night has begun.\n" elif handler_game.time_info.hour == 24: handler_game.time_info.hour = 0 handler_game.time_info.day += 1 buf = "You hear a clock in the distance strike midnight.\n" import nanny for wch in list(instance.players.values()): char_up = False if wch.desc.is_connected(nanny.con_playing) and wch.is_vampire(): if wch.hit < wch.max_hit: wch.hit = wch.max_hit char_up = True if wch.mana < wch.max_mana: wch.mana = wch.max_mana char_up = True if wch.move < wch.max_move: wch.move = wch.max_move char_up = True if char_up: wch.send( "You feel the strength of the kindred flow through your veins!\n" ) if handler_game.time_info.day >= 35: handler_game.time_info.day = 0 handler_game.time_info.month += 1 if handler_game.time_info.month >= 17: handler_game.time_info.month = 0 handler_game.time_info.year += 1 # Weather change. if 9 <= handler_game.time_info.month <= 16: diff = -2 if handler_game.weather_info.mmhg > 985 else 2 else: diff = -2 if handler_game.weather_info.mmhg > 1015 else 2 handler_game.weather_info.change += diff * game_utils.dice( 1, 4) + game_utils.dice(2, 6) - game_utils.dice(2, 6) handler_game.weather_info.change = max(handler_game.weather_info.change, -12) handler_game.weather_info.change = min(handler_game.weather_info.change, 12) handler_game.weather_info.mmhg += handler_game.weather_info.change handler_game.weather_info.mmhg = max(handler_game.weather_info.mmhg, 960) handler_game.weather_info.mmhg = min(handler_game.weather_info.mmhg, 1040) if handler_game.weather_info.sky == merc.SKY_CLOUDLESS: if handler_game.weather_info.mmhg < 990 or ( handler_game.weather_info.mmhg < 1010 and game_utils.number_bits(2) == 0): buf += "The sky is getting cloudy.\n" handler_game.weather_info.sky = merc.SKY_CLOUDY elif handler_game.weather_info.sky == merc.SKY_CLOUDY: if handler_game.weather_info.mmhg < 970 or ( handler_game.weather_info.mmhg < 990 and game_utils.number_bits(2) == 0): buf += "It starts to rain.\n" handler_game.weather_info.sky = merc.SKY_RAINING if handler_game.weather_info.mmhg > 1030 and game_utils.number_bits( 2) == 0: buf += "The clouds disappear.\n" handler_game.weather_info.sky = merc.SKY_CLOUDLESS elif handler_game.weather_info.sky == merc.SKY_RAINING: if handler_game.weather_info.mmhg < 970 and game_utils.number_bits( 2) == 0: buf += "Lightning flashes in the sky.\n" handler_game.weather_info.sky = merc.SKY_LIGHTNING if handler_game.weather_info.mmhg > 1030 or ( handler_game.weather_info.mmhg > 1010 and game_utils.number_bits(2) == 0): buf += "The rain stopped.\n" handler_game.weather_info.sky = merc.SKY_CLOUDY elif handler_game.weather_info.sky == merc.SKY_LIGHTNING: if handler_game.weather_info.mmhg > 1010 or ( handler_game.weather_info.mmhg > 990 and game_utils.number_bits(2) == 0): buf += "The lightning has stopped.\n" handler_game.weather_info.sky = merc.SKY_RAINING else: comm.notify( "weather_update: bad sky {}".format(handler_game.weather_info.sky), merc.CONSOLE_WARNING) handler_game.weather_info.sky = merc.SKY_CLOUDLESS if buf: import nanny for wch in list(instance.players.values()): if wch.desc.is_connected( nanny.con_playing) and wch.is_outside() and wch.is_awake(): wch.send(buf)
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_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 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 spl_cause_critical(sn, level, ch, victim, target): fight.damage(ch, victim, game_utils.dice(3, 8) + level - 6, sn)
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_heal(ch, argument): # check for healer for mob_id in ch.in_room.people[:]: healer = instance.characters[mob_id] if healer.is_npc() and healer.act.is_set(merc.ACT_IS_HEALER): mob = healer if not mob: ch.send("You can't do that here.\n") return argument, arg = game_utils.read_word(argument) if not arg: # display price list handler_game.act("$N says 'I offer the following spells:'", ch, None, mob, merc.TO_CHAR) ch.send(" light: cure light wounds 10 gold\n") ch.send(" serious: cure serious wounds 15 gold\n") ch.send(" critic: cure critical wounds 25 gold\n") ch.send(" heal: healing spell 50 gold\n") ch.send(" blind: cure blindness 20 gold\n") ch.send(" disease: cure disease 15 gold\n") ch.send(" poison: cure poison 25 gold\n") ch.send(" uncurse: remove curse 50 gold\n") ch.send(" refresh: restore movement 5 gold\n") ch.send(" mana: restore mana 10 gold\n") ch.send(" Type heal <type> to be healed.\n") return spell = None sn = None words = None cost = 0 if "light".startswith(arg): sn = const.skill_table["cure light"] spell = sn.spell_fun words = "judicandus dies" cost = 1000 elif "serious".startswith(arg): sn = const.skill_table["cure serious"] spell = sn.spell_fun words = "judicandus gzfuajg" cost = 1600 elif "critical".startswith(arg): sn = const.skill_table["cure critical"] spell = sn.spell_fun words = "judicandus qfuhuqar" cost = 2500 elif "heal".startswith(arg): sn = const.skill_table["heal"] spell = sn.spell_fun words = "pzar" cost = 5000 elif "blindness".startswith(arg): sn = const.skill_table["cure blindness"] spell = sn.spell_fun words = "judicandus noselacri" cost = 2000 elif "disease".startswith(arg): sn = const.skill_table["cure disease"] spell = sn.spell_fun words = "judicandus eugzagz" cost = 1500 elif "poison".startswith(arg): sn = const.skill_table["cure poison"] spell = sn.spell_fun words = "judicandus sausabru" cost = 2500 elif "uncurse".startswith(arg) or "curse".startswith(arg): sn = const.skill_table["remove curse"] spell = sn.spell_fun words = "candussido judifgz" cost = 5000 elif "mana".startswith(arg) or "energize".startswith(arg): spell = None sn = None words = "energizer" cost = 1000 elif "refresh".startswith(arg) or "moves".startswith(arg): sn = const.skill_table["refresh"] spell = sn.spell_fun words = "candusima" cost = 500 else: handler_game.act("$N says 'Type 'heal' for a list of spells.'", ch, None, mob, merc.TO_CHAR) return if cost > (ch.gold * 100 + ch.silver): handler_game.act("$N says 'You do not have enough gold for my services.'", ch, None, mob, merc.TO_CHAR) return state_checks.WAIT_STATE(ch, merc.PULSE_VIOLENCE) ch.deduct_cost(cost) mob.gold += cost // 100 mob.silver += cost % 100 handler_game.act("$n utters the words '$T'.", mob, None, words, merc.TO_ROOM) if spell is None: # restore mana trap... kinda hackish... kinda? ch.mana += game_utils.dice(2, 8) + mob.level // 3 ch.mana = min(ch.mana, ch.max_mana) ch.send("A warm glow passes through you.\n") return if sn == -1: return spell(sn, mob.level, mob, ch, merc.TARGET_CHAR)
def weather_update(): buf = "" handler_game.time_info.hour += 1 if handler_game.time_info.hour == 5: handler_game.weather_info.sunlight = merc.SUN_LIGHT buf = "The day has begun.\n" elif handler_game.time_info.hour == 6: handler_game.weather_info.sunlight = merc.SUN_RISE buf = "The sun rises in the east.\n" elif handler_game.time_info.hour == 19: handler_game.weather_info.sunlight = merc.SUN_SET buf = "The sun slowly disappears in the west.\n" elif handler_game.time_info.hour == 20: handler_game.weather_info.sunlight = merc.SUN_DARK buf = "The night has begun.\n" elif handler_game.time_info.hour == 24: handler_game.time_info.hour = 0 handler_game.time_info.day += 1 if handler_game.time_info.day >= 35: handler_game.time_info.day = 0 handler_game.time_info.month += 1 if handler_game.time_info.month >= 17: handler_game.time_info.month = 0 handler_game.time_info.year += 1 # # * Weather change. if 9 <= handler_game.time_info.month <= 16: diff = -2 if handler_game.weather_info.mmhg > 985 else 2 else: diff = -2 if handler_game.weather_info.mmhg > 1015 else 2 handler_game.weather_info.change += diff * game_utils.dice(1, 4) + game_utils.dice(2, 6) - game_utils.dice(2, 6) handler_game.weather_info.change = max(handler_game.weather_info.change, -12) handler_game.weather_info.change = min(handler_game.weather_info.change, 12) handler_game.weather_info.mmhg += handler_game.weather_info.change handler_game.weather_info.mmhg = max(handler_game.weather_info.mmhg, 960) handler_game.weather_info.mmhg = min(handler_game.weather_info.mmhg, 1040) if handler_game.weather_info.sky == merc.SKY_CLOUDLESS: if handler_game.weather_info.mmhg < 990 or ( handler_game.weather_info.mmhg < 1010 and random.randint(0, 2) == 0 ): buf += "The sky is getting cloudy.\n" handler_game.weather_info.sky = merc.SKY_CLOUDY elif handler_game.weather_info.sky == merc.SKY_CLOUDY: if handler_game.weather_info.mmhg < 970 or ( handler_game.weather_info.mmhg < 990 and random.randint(0, 2) == 0 ): buf += "It starts to rain.\n" handler_game.weather_info.sky = merc.SKY_RAINING if handler_game.weather_info.mmhg > 1030 and random.randint(0, 2) == 0: buf += "The clouds disappear.\n" handler_game.weather_info.sky = merc.SKY_CLOUDLESS elif handler_game.weather_info.sky == merc.SKY_RAINING: if handler_game.weather_info.mmhg < 970 and number_bits(2) == 0: buf += "Lightning flashes in the sky.\n" handler_game.weather_info.sky = merc.SKY_LIGHTNING if handler_game.weather_info.mmhg > 1030 or ( handler_game.weather_info.mmhg > 1010 and random.randint(0, 2) == 0 ): buf += "The rain stopped.\n" handler_game.weather_info.sky = merc.SKY_CLOUDY elif handler_game.weather_info.sky == merc.SKY_LIGHTNING: if handler_game.weather_info.mmhg > 1010 or ( handler_game.weather_info.mmhg > 990 and random.randint(0, 2) == 0 ): buf += "The lightning has stopped.\n" handler_game.weather_info.sky = merc.SKY_RAINING else: print("Bug: Weather_update: bad sky %d." % handler_game.weather_info.sky) handler_game.weather_info.sky = merc.SKY_CLOUDLESS if buf: import nanny for char in instance.players.items(): if char.desc.is_connected(nanny.con_playing) and state_checks.IS_OUTSIDE(char) and state_checks.IS_AWAKE( char): char.send(buf) return