def calc_number(userid, monsterid, time): """Calculates the number of monsters that can be killed in a given time period.""" combat_level = users.xp_to_level(users.read_user(userid, key=users.COMBAT_XP_KEY)) equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_dam, player_acc, player_arm = users.get_equipment_stats(equipment) monster_arm = mon.get_attr(monsterid, key=mon.ARMOUR_KEY) monster_xp = mon.get_attr(monsterid, key=mon.XP_KEY) if mon.get_attr(monsterid, key=mon.DRAGON_KEY) and '266' not in equipment: if equipment['7'] == '266' or equipment['7'] == '293': monster_base = 1 else: monster_base = 100 else: monster_base = 1 player_potion = equipment['15'] if player_potion == '427' or player_potion == '430': player_acc = player_acc * 1.1 + 3 if player_potion == '428' or player_potion == '430': player_dam = player_dam * 1.1 + 3 if player_potion == '429' or player_potion == '430': player_arm = player_arm * 1.1 + 3 if player_potion == '431' or player_potion == '434': player_acc = player_acc * 1.15 + 5 if player_potion == '432' or player_potion == '434': player_dam = player_dam * 1.15 + 5 if player_potion == '433' or player_potion == '434': player_arm = player_arm * 1.15 + 5 dam_multiplier = 1 + player_acc / 200 number = math.floor((10 * time * (player_dam * dam_multiplier + combat_level)) / (monster_arm * monster_base * monster_xp)) return number
def print_chance(userid, monsterid, monster_dam=-1, monster_acc=-1, monster_arm=-1, monster_combat=-1, xp=-1, number=100, dragonfire=False): equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_dam, player_acc, player_arm = users.get_equipment_stats(equipment) player_combat = users.xp_to_level(users.read_user(userid, key=users.SLAYER_XP_KEY)) if monster_dam == -1: monster_dam = mon.get_attr(monsterid, key=mon.DAMAGE_KEY) monster_acc = mon.get_attr(monsterid, key=mon.ACCURACY_KEY) monster_arm = mon.get_attr(monsterid, key=mon.ARMOUR_KEY) xp = mon.get_attr(monsterid, key=mon.XP_KEY) monster_combat = mon.get_attr(monsterid, key=mon.LEVEL_KEY) if dragonfire: monster_base = 100 else: monster_base = 1 c = 1 + monster_combat / 200 d = 1 + player_combat / 99 dam_multiplier = monster_base + monster_acc / 200 chance = round(min(100 * max(0, (2 * d * player_arm) / (number / 50 * monster_dam * dam_multiplier + c)), 100)) # chance = round(min(100 * max(0, (player_arm / (monster_dam * dam_multiplier + 1 + monster_combat / 200)) / 2 + player_combat / 200), 100)) dam_multiplier = 1 + player_acc / 200 base_time = math.floor(number * xp / 10) time = round(base_time * (monster_arm * monster_base / (player_dam * dam_multiplier + player_combat))) out = f'level {monster_combat} monster with {monster_dam} dam {monster_acc} acc {monster_arm} arm giving {xp} xp: '\ f'chance: {chance}%, base time: {base_time}, time to kill {number}: {time}, time ratio: {time / base_time}.' return out
def calc_length(userid, monsterid, number): """Calculates the length of a task.""" combat_level = users.xp_to_level(users.read_user(userid, key=users.COMBAT_XP_KEY)) equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_dam, player_acc, player_arm = users.get_equipment_stats(equipment) monster_arm = mon.get_attr(monsterid, key=mon.ARMOUR_KEY) monster_xp = mon.get_attr(monsterid, key=mon.XP_KEY) if mon.get_attr(monsterid, key=mon.DRAGON_KEY) == 1: if equipment['7'] == '266' or equipment['7'] == '293': monster_base = 1 else: monster_base = 100 else: monster_base = 1 player_potion = equipment['15'] if player_potion == '427' or player_potion == '430': player_acc = player_acc * 1.1 + 3 if player_potion == '428' or player_potion == '430': player_dam = player_dam * 1.1 + 3 if player_potion == '429' or player_potion == '430': player_arm = player_arm * 1.1 + 3 if player_potion == '431' or player_potion == '434': player_acc = player_acc * 1.15 + 5 if player_potion == '432' or player_potion == '434': player_dam = player_dam * 1.15 + 5 if player_potion == '433' or player_potion == '434': player_arm = player_arm * 1.15 + 5 c = combat_level dam_multiplier = 1 + player_acc / 200 base_time = math.floor(number * monster_xp / 10) time = round(base_time * monster_arm * monster_base / (player_dam * dam_multiplier + c)) return base_time, time
def calc_chance(userid, monsterid, number): """Calculates the chance of success of a task.""" equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_arm = users.get_equipment_stats(equipment)[2] monster_acc = mon.get_attr(monsterid, key=mon.ACCURACY_KEY) monster_dam = mon.get_attr(monsterid, key=mon.DAMAGE_KEY) monster_combat = mon.get_attr(monsterid, key=mon.LEVEL_KEY) player_combat = users.xp_to_level(users.read_user(userid, key=users.SLAYER_XP_KEY)) number = int(number) if mon.get_attr(monsterid, key=mon.DRAGON_KEY): if equipment['7'] == '266' or equipment['7'] == '293': monster_base = 1 else: monster_base = 100 else: monster_base = 1 player_potion = equipment['15'] if player_potion == '429' or player_potion == '430': player_arm = player_arm * 1.1 + 3 if player_potion == '433' or player_potion == '434': player_arm = player_arm * 1.15 + 5 c = 1 + monster_combat / 200 d = 1 + player_combat / 99 dam_multiplier = monster_base + monster_acc / 200 chance = round(min(100 * max(0, (2 * d * player_arm) / (number / 50 * monster_dam * dam_multiplier + c)), 100)) return chance
def calc_number(userid, monsterid, time): """Calculates the number of monsters that can be killed in a given time period.""" combat_level = users.xp_to_level(users.read_user(userid, key=users.COMBAT_XP_KEY)) equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_dam, player_acc, player_arm = users.get_equipment_stats(equipment) monster_arm = mon.get_attr(monsterid, key=mon.ARMOUR_KEY) monster_xp = mon.get_attr(monsterid, key=mon.XP_KEY) if mon.get_attr(monsterid, key=mon.DRAGON_KEY) and '266' not in equipment: monster_base = 100 else: monster_base = 1 dam_multiplier = 1 + player_acc / 200 number = math.floor((10 * time * (player_dam * dam_multiplier + combat_level)) / (monster_arm * monster_base * monster_xp)) return number
def calc_length(userid, monsterid, number): """Calculates the length of a task.""" combat_level = users.xp_to_level(users.read_user(userid, key=users.COMBAT_XP_KEY)) equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_dam, player_acc, player_arm = users.get_equipment_stats(equipment) monster_arm = mon.get_attr(monsterid, key=mon.ARMOUR_KEY) monster_xp = mon.get_attr(monsterid, key=mon.XP_KEY) if mon.get_attr(monsterid, key=mon.DRAGON_KEY) and '266' not in equipment: monster_base = 100 else: monster_base = 1 c = combat_level dam_multiplier = 1 + player_acc / 200 base_time = math.floor(number * monster_xp / 10) time = round(base_time * (monster_arm * monster_base / (player_dam * dam_multiplier + c))) return base_time, time
def calc_length(userid, difficulty): """Calculates the time it takes to do a clue scroll.""" quests_completed = len(users.get_completed_quests(userid)) num_of_quests = len(list(quests.QUESTS.keys())) player_damage = users.get_equipment_stats( users.read_user(userid, key=users.EQUIPMENT_KEY))[0] + 1 quest_multiplier = min((6 - difficulty) * quests_completed / num_of_quests, 1) base_time = 450 * difficulty time = base_time / (quest_multiplier * player_damage / 200) if time / base_time < 0.8: time = 0.8 * base_time return round(time)
def calc_chance(userid, monsterid, monster_stats=None): """Calculates the chance of success of a task.""" equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_arm = users.get_equipment_stats(equipment)[2] monster_acc = mon.get_attr(monsterid, key=mon.ACCURACY_KEY) monster_dam = mon.get_attr(monsterid, key=mon.DAMAGE_KEY) monster_combat = mon.get_attr(monsterid, key=mon.LEVEL_KEY) player_combat = users.xp_to_level(users.read_user(userid, key=users.SLAYER_XP_KEY)) if mon.get_attr(monsterid, key=mon.DRAGON_KEY) and '266' not in equipment: monster_base = 100 else: monster_base = 1 c = 1 + monster_combat / 200 d = player_combat / 200 dam_multiplier = monster_base + monster_acc / 200 chance = round(min(100 * max(0, (player_arm / (monster_dam * dam_multiplier + c)) / 2 + d), 100)) return chance
def calc_length(userid, questid): """Calculates the length of success of a quest.""" combat_level = users.xp_to_level(users.read_user(userid, key=users.COMBAT_XP_KEY)) equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_dam, player_acc, player_arm = users.get_equipment_stats(equipment) monster_arm = get_attr(questid, key=ARMOUR_KEY) base_time = 60 * get_attr(questid, key=TIME_KEY) if get_attr(questid, key=DRAGON_KEY) and '266' not in equipment: monster_base = 100 else: monster_base = 1 c = combat_level dam_multiplier = 1 + player_acc / 200 time = round(base_time * (monster_arm * monster_base / (player_dam * dam_multiplier + c))) if time < 0.5 * base_time: time = round(0.5 * base_time) if time > 2 * base_time: time = 2 * base_time return time
def calc_chance(userid, questid): """Calculates the chance of success of a quest.""" equipment = users.read_user(userid, key=users.EQUIPMENT_KEY) player_arm = users.get_equipment_stats(equipment)[2] monster_acc = get_attr(questid, key=ACCURACY_KEY) monster_dam = get_attr(questid, key=DAMAGE_KEY) monster_combat = get_attr(questid, key=LEVEL_KEY) player_combat = users.xp_to_level(users.read_user(userid, key=users.SLAYER_XP_KEY)) if get_attr(questid, key=DRAGON_KEY): if equipment['7'] == '266' or equipment['7'] == '293': monster_base = 1 else: monster_base = 100 else: monster_base = 1 c = 1 + monster_combat / 200 d = player_combat / 200 dam_multiplier = monster_base + monster_acc / 200 chance = round(min(100 * max(0, (player_arm / (monster_dam * dam_multiplier + c)) / 2 + d), 100)) return chance