Example #1
0
async def mine(cmd):
    market_data = EwMarket(id_server=cmd.message.author.server.id)
    user_data = EwUser(member=cmd.message.author)

    # Kingpins can't mine.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant mine (anymore)
    if user_data.life_state == ewcfg.life_state_corpse:
        return await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                "You can't mine while you're dead. Try {}.".format(
                    ewcfg.cmd_revive)))

    # Enlisted players only mine at certain times.
    if user_data.life_state == ewcfg.life_state_enlisted:
        if user_data.faction == ewcfg.faction_rowdys and (
                market_data.clock < 8 or market_data.clock > 17):
            return await cmd.client.send_message(
                cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "Rowdies only mine in the daytime. Wait for full daylight at 8am."
                    .format(ewcfg.cmd_revive)))

        if user_data.faction == ewcfg.faction_killers and (
                market_data.clock < 20 and market_data.clock > 5):
            return await cmd.client.send_message(
                cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "Killers only mine under cover of darkness. Wait for nightfall at 8pm."
                    .format(ewcfg.cmd_revive)))

    # Mine only in the mines.
    if cmd.message.channel.name in [
            ewcfg.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines
    ]:
        if user_data.hunger >= ewutils.hunger_max_bylevel(
                user_data.slimelevel):
            return await cmd.client.send_message(
                cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "You've exhausted yourself from mining. You'll need some refreshment before getting back to work."
                ))
        else:
            # Determine if a poudrin is found.
            poudrin = False
            poudrinamount = 0

            # juvies get poudrins 4 times as often as enlisted players
            poudrin_rarity = ewcfg.poudrin_rarity / (
                2 if user_data.life_state == ewcfg.life_state_juvenile else 1)
            poudrin_mined = random.randint(1, poudrin_rarity)

            if poudrin_mined == 1:
                poudrin = True
                poudrinamount = 1 if random.randint(
                    1, 3) != 1 else 2  # 33% chance of extra drop

            user_initial_level = user_data.slimelevel

            # Add mined slime to the user.
            slime_bylevel = ewutils.slime_bylevel(user_data.slimelevel)

            mining_yield = math.floor((slime_bylevel / 10) + 1)
            alternate_yield = math.floor(200 + slime_bylevel**(1 / math.e))

            mining_yield = min(mining_yield, alternate_yield)

            user_data.change_slimes(n=mining_yield, source=ewcfg.source_mining)

            was_levelup = True if user_initial_level < user_data.slimelevel else False

            # Create and give slime poudrins
            for pdx in range(poudrinamount):
                item_id = ewitem.item_create(
                    item_type=ewcfg.it_slimepoudrin,
                    id_user=cmd.message.author.id,
                    id_server=cmd.message.server.id,
                )
                ewutils.logMsg(
                    'Created poudrin (item {}) for user (id {})'.format(
                        item_id, cmd.message.author.id))

            # Fatigue the miner.
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(
                hunger_cost_mod
            )  # extra is the fractional part of hunger_cost_mod

            user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_permine

            user_data.persist()

            # Tell the player their slime level increased and/or a poudrin was found.
            if was_levelup or poudrin:
                response = ""

                if poudrin:
                    if poudrinamount == 1:
                        response += "You unearthed a slime poudrin! "
                    elif poudrinamount == 2:
                        response += "You unearthed two slime poudrins! "

                    ewstats.change_stat(user=user_data,
                                        metric=ewcfg.stat_lifetime_poudrins,
                                        n=poudrinamount)

                    ewutils.logMsg('{} has found {} poudrin(s)!'.format(
                        cmd.message.author.display_name, poudrinamount))

                if was_levelup:
                    response += "You have been empowered by slime and are now a level {} slimeboi!".format(
                        user_data.slimelevel)

                await cmd.client.send_message(
                    cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
    else:
        return await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author,
                                  "You can't mine here. Go to the mines."))
Example #2
0
async def cast(cmd):
	time_now = round(time.time())
	has_reeled = False
	user_data = EwUser(member = cmd.message.author)
	market_data = EwMarket(id_server = cmd.message.author.server.id)
	statuses = user_data.getStatusEffects()

	if cmd.message.author.id not in fishers.keys():
		fishers[cmd.message.author.id] = EwFisher()

	fisher = fishers[cmd.message.author.id]

	# Ghosts cannot fish.
	if user_data.life_state == ewcfg.life_state_corpse:
		response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive)

	# Players who are already cast a line cannot cast another one.
	elif fisher.fishing == True:
		response = "You've already cast a line."

	# Only fish at The Pier
	elif cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]:
		if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel):
			response = "You're too hungry to fish right now."

		else:
			has_fishingrod = False

			if user_data.weapon >= 0:
				weapon_item = EwItem(id_item = user_data.weapon)
				weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type"))
				if weapon.id_weapon == "fishingrod":
					has_fishingrod = True

			if ewcfg.status_high_id in statuses:
				fisher.high = True
			fisher.current_fish = gen_fish(market_data, cmd, has_fishingrod)
			fisher.fishing = True
			fisher.bait = False
			fisher.pier = user_data.poi
			item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
			author = cmd.message.author
			server = cmd.message.server

			item_sought = ewitem.find_item(item_search = item_search, id_user = author.id, id_server = server.id)

			if item_sought:
				item = EwItem(id_item = item_sought.get('id_item'))

				if item.item_type == ewcfg.it_food:

					str_name = item.item_props['food_name']
					id_food = item.item_props.get('id_food')
					fisher.bait = True

					if id_food in ewcfg.plebe_bait:
						fisher.current_fish = "plebefish"

					elif id_food == "doublestuffedcrust":
						if random.randrange(5) == 3:
							fisher.current_fish = "doublestuffedflounder"

					elif id_food in ["chickenbucket", "familymeal"]:
						if random.randrange(5) == 3:
							fisher.current_fish = "seacolonel"

					elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]:
						if random.randrange(5) == 3:
							fisher.current_fish = "marlinsupreme"

					elif id_food in ["blacklimes", "blacklimesour"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "blacklimesalmon"

					elif id_food in ["pinkrowddishes", "pinkrowdatouille"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "thrash"

					elif id_food in ["purplekilliflowercrustpizza", "purplekilliflower"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "dab"

					elif id_food == "kingpincrab":
						if random.randrange(5) == 1:
							fisher.current_fish = "uncookedkingpincrab"

					elif float(item.time_expir if item.time_expir is not None else 0) < time.time():
						if random.randrange(2) == 1:
							fisher.current_fish = "plebefish"
					ewitem.item_delete(item_sought.get('id_item'))

			if fisher.current_fish == "item":
				fisher.current_size = "item"

			else:
				fisher.current_size = gen_fish_size(has_fishingrod)

			if fisher.bait == False:
				response = "You cast your fishing line into the "
			else:
				response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name)


			if cmd.message.channel.name in [ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]:
				response += "vast Slime Sea."
			else:
				response += "glowing Slime Lake."

			user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
			user_data.persist()
			
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	
			bite_text = gen_bite_text(fisher.current_size)
			
			# User has a 1/10 chance to get a bite
			fun = 100

			if fisher.bait == True:
				# Bait attatched, user has a 1/7 chance to get a bite
				fun = 70
			bun = 0

			while not ewutils.TERMINATE:
				
				if fun <= 0:
					fun = 1
				else:
					damp = random.randrange(fun)

				if not fisher.high:
					await asyncio.sleep(60)
				else:
					await asyncio.sleep(30)
				user_data = EwUser(member=cmd.message.author)

				if user_data.poi != fisher.pier:
					fisher.fishing = False
					return
				if user_data.life_state == ewcfg.life_state_corpse:
					fisher.fishing = False
					return
				if fisher.fishing == False:
					return

				if damp > 10:
					await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text)))
					fun -= 2
					bun += 1
					if bun >= 5:
						fun -= 1
					if bun >= 15:
						fun -= 1
					continue
				else:
					break


			fisher.bite = True
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, bite_text))

			await asyncio.sleep(8)

			if fisher.bite != False:
				fisher.fishing = False
				fisher.bite = False
				fisher.current_fish = ""
				fisher.current_size = ""
				fisher.bait = False
				return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away..."))
			else:
				has_reeled = True

	else:
		response = "You can't fish here. Go to a pier."
	
	# Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead.
	if has_reeled == False:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Example #3
0
async def scavenge(cmd):
    market_data = EwMarket(id_server=cmd.message.author.server.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    time_now = int(time.time())
    response = ""

    time_since_last_scavenge = time_now - user_data.time_lastscavenge

    # Kingpins can't scavenge.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant scavenge
    if user_data.life_state == ewcfg.life_state_corpse:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                "What would you want to do that for? You're a ghost, you have no need for such lowly materialistic possessions like slime. You only engage in intellectual pursuits now. {} if you want to give into your base human desire to see numbers go up."
                .format(ewcfg.cmd_revive)))
    # currently not active - no cooldown
    if time_since_last_scavenge < ewcfg.cd_scavenge:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author,
                                  "Slow down, you filthy hyena."))

    # Scavenge only in location channels
    if ewmap.channel_name_is_poi(cmd.message.channel.name) == True:
        if user_data.hunger >= user_data.get_hunger_max():
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "You are too exhausted to scrounge up scraps of slime off the street! Go get some grub!"
                ))
        else:
            district_data = EwDistrict(district=user_data.poi,
                                       id_server=cmd.message.author.server.id)

            user_initial_level = user_data.slimelevel
            # add scavenged slime to user
            if ewcfg.mutation_id_trashmouth in mutations:
                time_since_last_scavenge *= 3

            time_since_last_scavenge = min(max(1, time_since_last_scavenge),
                                           30)

            scavenge_mod = 0.003 * (time_since_last_scavenge**0.9)

            if ewcfg.mutation_id_whitenationalist in mutations and market_data.weather == "snow":
                scavenge_mod *= 1.5

            if ewcfg.mutation_id_webbedfeet in mutations:
                district_slimelevel = len(str(district_data.slimes))
                scavenge_mod *= max(1, min(district_slimelevel - 3, 4))

            scavenge_yield = math.floor(scavenge_mod * district_data.slimes)

            levelup_response = user_data.change_slimes(
                n=scavenge_yield, source=ewcfg.source_scavenging)
            district_data.change_slimes(n=-1 * scavenge_yield,
                                        source=ewcfg.source_scavenging)
            district_data.persist()

            if levelup_response != "":
                response += levelup_response + "\n\n"
            #response += "You scrape together {} slime from the streets.\n\n".format(scavenge_yield)
            if cmd.tokens_count > 1:
                item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
                loot_resp = ewitem.item_lootspecific(
                    id_server=user_data.id_server,
                    id_user=user_data.id_user,
                    item_search=item_search)

                response += loot_resp

            else:
                loot_multiplier = 1.0 + ewitem.get_inventory_size(
                    owner=user_data.poi, id_server=user_data.id_server)
                loot_chance = loot_multiplier / ewcfg.scavenge_item_rarity
                if ewcfg.mutation_id_dumpsterdiver in mutations:
                    loot_chance *= 10
                if random.random() < loot_chance:
                    loot_resp = ewitem.item_lootrandom(
                        id_server=user_data.id_server,
                        id_user=user_data.id_user)
                    response += loot_resp

            # Fatigue the scavenger.
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(
                hunger_cost_mod
            )  # extra is the fractional part of hunger_cost_mod

            user_data.hunger += ewcfg.hunger_perscavenge * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_perscavenge

            user_data.time_lastscavenge = time_now

            user_data.persist()

            if not response == "":
                await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
    else:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                "You'll find no slime here, this place has been picked clean. Head into the city to try and scavenge some slime."
            ))
Example #4
0
async def mine(cmd):
    market_data = EwMarket(id_server=cmd.message.author.server.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    time_now = int(time.time())

    response = ""
    # Kingpins can't mine.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant mine (anymore)
    if user_data.life_state == ewcfg.life_state_corpse:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                "You can't mine while you're dead. Try {}.".format(
                    ewcfg.cmd_revive)))

    # Enlisted players only mine at certain times.
    if user_data.life_state == ewcfg.life_state_enlisted:
        if user_data.faction == ewcfg.faction_rowdys and (
                market_data.clock < 8 or market_data.clock > 17):
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "Rowdies only mine in the daytime. Wait for full daylight at 8am."
                    .format(ewcfg.cmd_revive)))

        if user_data.faction == ewcfg.faction_killers and (
                market_data.clock < 20 and market_data.clock > 5):
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "Killers only mine under cover of darkness. Wait for nightfall at 8pm."
                    .format(ewcfg.cmd_revive)))

    # Mine only in the mines.
    if cmd.message.channel.name in [
            ewcfg.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines
    ]:

        if user_data.hunger >= user_data.get_hunger_max():
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(
                    cmd.message.author,
                    "You've exhausted yourself from mining. You'll need some refreshment before getting back to work."
                ))

        else:
            printgrid = False
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(
                hunger_cost_mod
            )  # extra is the fractional part of hunger_cost_mod

            if user_data.poi not in mines_map:
                response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"
                return await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
            elif user_data.id_server not in mines_map.get(user_data.poi):
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True
            grid_cont = mines_map.get(user_data.poi).get(user_data.id_server)
            grid = grid_cont.grid

            #minesweeper = False
            if cmd.tokens_count < 2:
                response = "Please specify which vein to mine."
                await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
                return await print_grid(cmd)

            else:
                #minesweeper = True
                #grid_multiplier = grid_cont.cells_mined ** 0.4
                #flag = False
                row = -1
                col = -1
                for token in cmd.tokens[1:]:

                    if token.lower() == "reset":
                        user_data.hunger += ewcfg.hunger_perminereset * int(
                            hunger_cost_mod)
                        if random.random() < extra:
                            user_data.hunger += ewcfg.hunger_perminereset
                        user_data.persist()
                        init_grid(user_data.poi, user_data.id_server)
                        return await print_grid(cmd)

                    if row < 1 or col < 1:
                        coords = token.lower()

                        for char in coords:
                            if char in ewcfg.alphabet:
                                col = ewcfg.alphabet.index(char)
                                coords = coords.replace(char, "")

                        try:
                            row = int(coords)
                        except:
                            row = -1

                row -= 1

                if row not in range(len(grid)) or col not in range(
                        len(grid[row])):
                    response = "Invalid vein."
                    await ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response))
                    return await print_grid(cmd)

                mining_yield = 0
                mining_accident = False

                slimes_pertile = ewcfg.slimes_pertile
                for current_row in range(max(0, row - 1),
                                         min(row + 2, len(grid))):
                    for current_col in range(
                            max(0, col - 1),
                            min(col + 2, len(grid[current_row]))):
                        symbol_prev = get_cell_symbol(
                            grid[current_row][current_col])
                        slimes_fromtile = slimes_pertile
                        if current_row == row and current_col == col:
                            slimes_fromtile *= 2
                        mining_yield += max(
                            0,
                            min(slimes_fromtile,
                                grid[current_row][current_col]))
                        grid[current_row][current_col] -= slimes_fromtile
                        if grid[current_row][
                                current_col] < -60 * ewcfg.slimes_pertile:
                            mining_accident = True
                        if get_cell_symbol(
                                grid[current_row][current_col]) != symbol_prev:
                            printgrid = True

                if mining_accident:
                    user_data.change_slimes(n=-(user_data.slimes * 0.5))
                    user_data.persist()

                    init_grid(user_data.poi, user_data.id_server)
                    response = "You have lost an arm and a leg in a mining accident. Tis but a scratch."

                    await ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response))
                    return await print_grid(cmd)

                if mining_yield == 0:
                    user_data.hunger += ewcfg.hunger_permine * int(
                        hunger_cost_mod)
                    user_data.persist()
                    response = "This vein has already been mined dry."
                    await ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response))
                    if printgrid:
                        return await print_grid(cmd)
                    else:
                        return

            has_pickaxe = False

            if user_data.weapon >= 0:
                weapon_item = EwItem(id_item=user_data.weapon)
                weapon = ewcfg.weapon_map.get(
                    weapon_item.item_props.get("weapon_type"))
                if weapon.id_weapon == ewcfg.weapon_id_pickaxe:
                    has_pickaxe = True

            # Determine if an item is found.
            unearthed_item = False
            unearthed_item_amount = 0

            # juvies get items 4 times as often as enlisted players
            unearthed_item_chance = 1 / ewcfg.unearthed_item_rarity
            if user_data.life_state == ewcfg.life_state_juvenile:
                unearthed_item_chance *= 2
            if has_pickaxe == True:
                unearthed_item_chance *= 1.5
            if ewcfg.mutation_id_lucky in mutations:
                unearthed_item_chance *= 1.33

            if random.random() < unearthed_item_chance:
                unearthed_item = True
                unearthed_item_amount = 1 if random.randint(
                    1, 3) != 1 else 2  # 33% chance of extra drop

            if unearthed_item == True:
                # If there are multiple possible products, randomly select one.
                item = random.choice(ewcfg.mine_results)

                item_props = ewitem.gen_item_props(item)

                for creation in range(unearthed_item_amount):
                    ewitem.item_create(item_type=item.item_type,
                                       id_user=cmd.message.author.id,
                                       id_server=cmd.message.server.id,
                                       item_props=item_props)

                if unearthed_item_amount == 1:
                    response = "You unearthed a {}! ".format(item.str_name)
                elif unearthed_item_amount == 2:
                    response = "You unearthed two (2) {}! ".format(
                        item.str_name)

                ewstats.change_stat(user=user_data,
                                    metric=ewcfg.stat_lifetime_poudrins,
                                    n=unearthed_item_amount)

                ewutils.logMsg('{} has found {} {}(s)!'.format(
                    cmd.message.author.display_name, item.str_name,
                    unearthed_item_amount))

            user_initial_level = user_data.slimelevel

            # Add mined slime to the user.
            slime_bylevel = ewutils.slime_bylevel(user_data.slimelevel)

            #mining_yield = math.floor((slime_bylevel / 10) + 1)
            #alternate_yield = math.floor(200 + slime_bylevel ** (1 / math.e))

            #mining_yield = min(mining_yield, alternate_yield)

            if has_pickaxe == True:
                mining_yield *= 2

            # Fatigue the miner.

            user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_permine

            levelup_response = user_data.change_slimes(
                n=mining_yield, source=ewcfg.source_mining)

            was_levelup = True if user_initial_level < user_data.slimelevel else False

            # Tell the player their slime level increased and/or they unearthed an item.
            if was_levelup:
                response += levelup_response

            user_data.persist()

            if printgrid:
                await print_grid(cmd)

    else:
        response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"

    if len(response) > 0:
        await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
Example #5
0
async def spar(cmd):
    time_now = int(time.time())
    response = ""

    if cmd.message.channel.name != ewcfg.channel_dojo:
        response = "You must go to the dojo to spar."

    elif cmd.mentions_count > 1:
        response = "One sparring partner at a time!"

    elif cmd.mentions_count == 1:
        member = cmd.mentions[0]

        if (member.id == cmd.message.author.id):
            response = "How do you expect to spar with yourself?"
        else:
            # Get killing player's info.
            user_data = EwUser(member=cmd.message.author)

            # Get target's info.
            sparred_data = EwUser(member=member)

            user_iskillers = user_data.life_state == ewcfg.life_state_enlisted and user_data.faction == ewcfg.faction_killers
            user_isrowdys = user_data.life_state == ewcfg.life_state_enlisted and user_data.faction == ewcfg.faction_rowdys
            user_isdead = user_data.life_state == ewcfg.life_state_corpse

            if user_data.hunger >= ewutils.hunger_max_bylevel(
                    user_data.slimelevel):
                response = "You are too exhausted to train right now. Go get some grub!"
            elif user_data.poi != ewcfg.poi_id_dojo or sparred_data.poi != ewcfg.poi_id_dojo:
                response = "Both players need to be in the dojo to spar."
            elif sparred_data.hunger >= ewutils.hunger_max_bylevel(
                    sparred_data.slimelevel):
                response = "{} is too exhausted to train right now. They need a snack!".format(
                    member.display_name)
            elif user_isdead == True:
                response = "The dead think they're too cool for conventional combat. Pricks."
            elif user_iskillers == False and user_isrowdys == False:
                # Only killers, rowdys, the cop killer, and the rowdy f****r can spar
                response = "Juveniles lack the backbone necessary for combat."
            else:
                was_juvenile = False
                was_sparred = False
                was_dead = False
                was_player_tired = False
                was_target_tired = False
                was_enemy = False
                duel = False

                #Determine if the !spar is a duel:
                weapon = None
                if user_data.weapon != None and user_data.weapon != "" and user_data.weapon == sparred_data.weapon:
                    weapon = ewcfg.weapon_map.get(user_data.weapon)
                    duel = True

                if sparred_data.life_state == ewcfg.life_state_corpse:
                    # Target is already dead.
                    was_dead = True
                elif (user_data.time_lastspar + ewcfg.cd_spar) > time_now:
                    # player sparred too recently
                    was_player_tired = True
                elif (sparred_data.time_lastspar + ewcfg.cd_spar) > time_now:
                    # taret sparred too recently
                    was_target_tired = True
                elif sparred_data.life_state == ewcfg.life_state_juvenile:
                    # Target is a juvenile.
                    was_juvenile = True

                elif (
                        user_iskillers and
                    (sparred_data.life_state == ewcfg.life_state_enlisted
                     and sparred_data.faction == ewcfg.faction_killers)) or (
                         user_isrowdys and
                         (sparred_data.life_state == ewcfg.life_state_enlisted
                          and sparred_data.faction == ewcfg.faction_rowdys)):
                    # User can be sparred.
                    was_sparred = True
                elif (
                        user_iskillers and
                    (sparred_data.life_state == ewcfg.life_state_enlisted
                     and sparred_data.faction == ewcfg.faction_rowdys)) or (
                         user_isrowdys and
                         (sparred_data.life_state == ewcfg.life_state_enlisted
                          and sparred_data.faction == ewcfg.faction_killers)):
                    # Target is a member of the opposing faction.
                    was_enemy = True

                #if the duel is successful
                if was_sparred:
                    weaker_player = sparred_data if sparred_data.slimes < user_data.slimes else user_data
                    stronger_player = sparred_data if user_data is weaker_player else user_data

                    # Weaker player gains slime based on the slime of the stronger player.
                    possiblegain = int(ewcfg.slimes_perspar_base *
                                       (2.2**weaker_player.slimelevel))
                    slimegain = min(possiblegain, stronger_player.slimes / 20)
                    weaker_player.change_slimes(n=slimegain)

                    #hunger drain for both players
                    user_data.hunger += ewcfg.hunger_perspar * ewutils.hunger_cost_mod(
                        user_data.slimelevel)
                    sparred_data.hunger += ewcfg.hunger_perspar * ewutils.hunger_cost_mod(
                        sparred_data.slimelevel)

                    # Bonus 50% slime to both players in a duel.
                    if duel:
                        weaker_player.change_slimes(n=slimegain / 2)
                        stronger_player.change_slimes(n=slimegain / 2)

                        if weaker_player.weaponskill < 5:
                            weaker_player.add_weaponskill(n=1)
                        elif (weaker_player.weaponskill +
                              1) < stronger_player.weaponskill:
                            weaker_player.add_weaponskill(n=1)

                        if stronger_player.weaponskill < 5:
                            stronger_player.add_weaponskill(n=1)

                    weaker_player.time_lastspar = time_now

                    user_data.persist()
                    sparred_data.persist()

                    # player was sparred with
                    if duel and weapon != None:
                        response = weapon.str_duel.format(
                            name_player=cmd.message.author.display_name,
                            name_target=member.display_name)
                    else:
                        response = '{} parries the attack. :knife: {}'.format(
                            member.display_name, ewcfg.emote_slime5)

                    #Notify if max skill is reached
                    if weapon != None:
                        if user_data.weaponskill >= 5:
                            response += ' {} is a master of the {}.'.format(
                                cmd.message.author.display_name,
                                weapon.id_weapon)
                        if sparred_data.weaponskill >= 5:
                            response += ' {} is a master of the {}.'.format(
                                member.display_name, weapon.id_weapon)

                else:
                    if was_dead:
                        # target is already dead
                        response = '{} is already dead.'.format(
                            member.display_name)
                    elif was_target_tired:
                        # target has sparred too recently
                        response = '{} is too tired to spar right now.'.format(
                            member.display_name)
                    elif was_player_tired:
                        # player has sparred too recently
                        response = 'You are too tired to spar right now.'
                    elif was_enemy:
                        # target and player are different factions
                        response = "You cannot spar with your enemies."
                    else:
                        #otherwise unkillable
                        response = '{} cannot spar now.'.format(
                            member.display_name)
    else:
        response = 'Your fighting spirit is appreciated, but ENDLESS WAR didn\'t understand that name.'

    # Send the response to the player.
    await cmd.client.send_message(
        cmd.message.channel, ewutils.formatMessage(cmd.message.author,
                                                   response))
Example #6
0
async def attack(cmd):
    time_now = int(time.time())
    response = ""
    deathreport = ""
    coinbounty = 0

    user_data = EwUser(member=cmd.message.author)
    slimeoid = EwSlimeoid(member=cmd.message.author)
    weapon = ewcfg.weapon_map.get(user_data.weapon)

    if ewmap.channel_name_is_poi(cmd.message.channel.name) == False:
        response = "You can't commit violence from here."
    elif ewmap.poi_is_pvp(user_data.poi) == False:
        response = "You must go elsewhere to commit gang violence."
    elif cmd.mentions_count > 1:
        response = "One shot at a time!"
    elif cmd.mentions_count <= 0:
        response = "Your bloodlust is appreciated, but ENDLESS WAR didn't understand that name."
    elif user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel):
        response = "You are too exhausted for gang violence right now. Go get some grub!"
    elif cmd.mentions_count == 1:
        # Get shooting player's info
        if user_data.slimelevel <= 0:
            user_data.slimelevel = 1
            user_data.persist()

        # Get target's info.
        member = cmd.mentions[0]
        shootee_data = EwUser(member=member)
        shootee_slimeoid = EwSlimeoid(member=member)

        miss = False
        crit = False
        strikes = 0

        slimes_spent = int(ewutils.slime_bylevel(user_data.slimelevel) / 20)
        slimes_damage = int(
            (slimes_spent * 4) * (100 + (user_data.weaponskill * 10)) / 100.0)

        if weapon is None:
            slimes_damage /= 2  # penalty for not using a weapon, otherwise fists would be on par with other weapons
        slimes_dropped = shootee_data.totaldamage + shootee_data.slimes

        #fumble_chance = (random.randrange(10) - 4)
        #if fumble_chance > user_data.weaponskill:
        #miss = True

        user_iskillers = user_data.life_state == ewcfg.life_state_enlisted and user_data.faction == ewcfg.faction_killers
        user_isrowdys = user_data.life_state == ewcfg.life_state_enlisted and user_data.faction == ewcfg.faction_rowdys

        if shootee_data.life_state == ewcfg.life_state_kingpin:
            # Disallow killing generals.
            response = "He is hiding in his ivory tower and playing video games like a retard."

        elif (slimes_spent > user_data.slimes):
            # Not enough slime to shoot.
            response = "You don't have enough slime to attack. ({:,}/{:,})".format(
                user_data.slimes, slimes_spent)

        elif (time_now - user_data.time_lastkill) < ewcfg.cd_kill:
            # disallow kill if the player has killed recently
            response = "Take a moment to appreciate your last slaughter."

        elif shootee_data.poi != user_data.poi:
            response = "You can't reach them from where you are."

        elif ewmap.poi_is_pvp(shootee_data.poi) == False:
            response = "{} is not mired in the ENDLESS WAR right now.".format(
                member.display_name)

        elif user_iskillers == False and user_isrowdys == False:
            # Only killers, rowdys, the cop killer, and rowdy f****r can shoot people.
            if user_data.life_state == ewcfg.life_state_juvenile:
                response = "Juveniles lack the moral fiber necessary for violence."
            else:
                response = "You lack the moral fiber necessary for violence."

        elif (time_now - shootee_data.time_lastrevive) < ewcfg.invuln_onrevive:
            # User is currently invulnerable.
            response = "{} has died too recently and is immune.".format(
                member.display_name)

        elif shootee_data.life_state == ewcfg.life_state_corpse and user_data.ghostbust == True:
            # Attack a ghostly target
            was_busted = False

            #hunger drain
            user_data.hunger += ewcfg.hunger_pershot * ewutils.hunger_cost_mod(
                user_data.slimelevel)

            # Weaponized flavor text.
            randombodypart = ewcfg.hitzone_list[random.randrange(
                len(ewcfg.hitzone_list))]

            # Weapon-specific adjustments
            if weapon != None and weapon.fn_effect != None:
                # Build effect container
                ctn = EwEffectContainer(miss=miss,
                                        crit=crit,
                                        slimes_damage=slimes_damage,
                                        slimes_spent=slimes_spent,
                                        user_data=user_data,
                                        shootee_data=shootee_data)

                # Make adjustments
                weapon.fn_effect(ctn)

                # Apply effects for non-reference values
                miss = ctn.miss
                crit = ctn.crit
                slimes_damage = ctn.slimes_damage
                slimes_spent = ctn.slimes_spent
                strikes = ctn.strikes
                # user_data and shootee_data should be passed by reference, so there's no need to assign them back from the effect container.

                if miss:
                    slimes_damage = 0

            # Remove !revive invulnerability.
            user_data.time_lastrevive = 0

            # Spend slimes, to a minimum of zero
            user_data.change_slimes(
                n=(-user_data.slimes
                   if slimes_spent >= user_data.slimes else -slimes_spent),
                source=ewcfg.source_spending)

            # Damage stats
            ewstats.track_maximum(user=user_data,
                                  metric=ewcfg.stat_max_hitdealt,
                                  value=slimes_damage)
            ewstats.change_stat(user=user_data,
                                metric=ewcfg.stat_lifetime_damagedealt,
                                n=slimes_damage)

            # Remove repeat killing protection if.
            if user_data.id_killer == shootee_data.id_user:
                user_data.id_killer = ""

            if slimes_damage >= -shootee_data.slimes:
                was_busted = True

            if was_busted:
                # Move around slime as a result of the shot.
                user_data.change_slimes(n=ewutils.slime_bylevel(
                    shootee_data.slimelevel),
                                        source=ewcfg.source_busting)
                coinbounty = int(shootee_data.bounty /
                                 ewcfg.slimecoin_exchangerate)
                user_data.change_slimecredit(
                    n=coinbounty, coinsource=ewcfg.coinsource_bounty)

                ewstats.track_maximum(user=user_data,
                                      metric=ewcfg.stat_biggest_bust_level,
                                      value=shootee_data.slimelevel)

                # Player was busted.
                shootee_data.die(cause=ewcfg.cause_busted)

                response = "{name_target}\'s ghost has been **BUSTED**!!".format(
                    name_target=member.display_name)

                deathreport = "Your ghost has been busted by {}. {}".format(
                    cmd.message.author.display_name, ewcfg.emote_bustin)
                deathreport = "{} ".format(
                    ewcfg.emote_bustin) + ewutils.formatMessage(
                        member, deathreport)

                if coinbounty > 0:
                    response += "\n\n SlimeCorp transfers {} SlimeCoin to {}\'s account.".format(
                        str(coinbounty), cmd.message.author.display_name)

                #adjust busts
                ewstats.increment_stat(user=user_data,
                                       metric=ewcfg.stat_ghostbusts)

            else:
                # A non-lethal blow!
                shootee_data.change_slimes(n=slimes_damage,
                                           source=ewcfg.source_busting)
                damage = str(slimes_damage)

                if weapon != None:
                    if miss:
                        response = "{}".format(
                            weapon.str_miss.format(
                                name_player=cmd.message.author.display_name,
                                name_target=member.display_name + "\'s ghost"))
                    else:
                        response = weapon.str_damage.format(
                            name_player=cmd.message.author.display_name,
                            name_target=member.display_name + "\'s ghost",
                            hitzone=randombodypart,
                            strikes=strikes)
                        if crit:
                            response += " {}".format(
                                weapon.str_crit.format(
                                    name_player=cmd.message.author.
                                    display_name,
                                    name_target=member.display_name +
                                    "\'s ghost"))
                        response += " {target_name} loses {damage} antislime!".format(
                            target_name=(member.display_name + "\'s ghost"),
                            damage=damage)
                else:
                    if miss:
                        response = "{}\'s ghost is unharmed.".format(
                            member.display_name)
                    else:
                        response = "{target_name} is hit!! {target_name} loses {damage} antislime!".format(
                            target_name=(member.display_name + "\'s ghost"),
                            damage=damage)

            # Persist every users' data.
            user_data.persist()
            shootee_data.persist()

            await ewrolemgr.updateRoles(client=cmd.client,
                                        member=cmd.message.server.get_member(
                                            shootee_data.id_user))

        elif shootee_data.life_state == ewcfg.life_state_corpse and shootee_data.busted == True:
            # Target is already dead and not a ghost.
            response = "{} is already dead.".format(member.display_name)

        elif shootee_data.life_state == ewcfg.life_state_corpse and user_data.ghostbust == False:
            # Target is a ghost but user is not able to bust
            response = "You don't know how to fight a ghost."

        else:
            # Slimes from this shot might be awarded to the boss.
            role_boss = (ewcfg.role_copkiller
                         if user_iskillers else ewcfg.role_rowdyfucker)
            boss_slimes = 0
            user_inital_level = user_data.slimelevel

            was_juvenile = False
            was_killed = False
            was_shot = False

            if (shootee_data.life_state == ewcfg.life_state_enlisted) or (
                    shootee_data.life_state == ewcfg.life_state_juvenile):
                # User can be shot.
                if shootee_data.life_state == ewcfg.life_state_juvenile:
                    was_juvenile = True

                was_shot = True

            if was_shot:
                #hunger drain
                user_data.hunger += ewcfg.hunger_pershot * ewutils.hunger_cost_mod(
                    user_data.slimelevel)

                # Weaponized flavor text.
                randombodypart = ewcfg.hitzone_list[random.randrange(
                    len(ewcfg.hitzone_list))]

                # Weapon-specific adjustments
                if weapon != None and weapon.fn_effect != None:
                    # Build effect container
                    ctn = EwEffectContainer(miss=miss,
                                            crit=crit,
                                            slimes_damage=slimes_damage,
                                            slimes_spent=slimes_spent,
                                            user_data=user_data,
                                            shootee_data=shootee_data)

                    # Make adjustments
                    weapon.fn_effect(ctn)

                    # Apply effects for non-reference values
                    miss = ctn.miss
                    crit = ctn.crit
                    slimes_damage = ctn.slimes_damage
                    slimes_spent = ctn.slimes_spent
                    strikes = ctn.strikes
                    # user_data and shootee_data should be passed by reference, so there's no need to assign them back from the effect container.

                    if miss:
                        slimes_damage = 0

                # Remove !revive invulnerability.
                user_data.time_lastrevive = 0

                # Spend slimes, to a minimum of zero
                user_data.change_slimes(
                    n=(-user_data.slimes
                       if slimes_spent >= user_data.slimes else -slimes_spent),
                    source=ewcfg.source_spending)

                # Damage stats
                ewstats.track_maximum(user=user_data,
                                      metric=ewcfg.stat_max_hitdealt,
                                      value=slimes_damage)
                ewstats.change_stat(user=user_data,
                                    metric=ewcfg.stat_lifetime_damagedealt,
                                    n=slimes_damage)

                # Remove repeat killing protection if.
                if user_data.id_killer == shootee_data.id_user:
                    user_data.id_killer = ""

                if slimes_damage >= shootee_data.slimes:
                    was_killed = True

                if was_killed:
                    #adjust statistics
                    ewstats.increment_stat(user=user_data,
                                           metric=ewcfg.stat_kills)
                    ewstats.track_maximum(user=user_data,
                                          metric=ewcfg.stat_biggest_kill,
                                          value=int(slimes_dropped))
                    if user_data.slimelevel > shootee_data.slimelevel:
                        ewstats.increment_stat(
                            user=user_data, metric=ewcfg.stat_lifetime_ganks)
                    elif user_data.slimelevel < shootee_data.slimelevel:
                        ewstats.increment_stat(
                            user=user_data,
                            metric=ewcfg.stat_lifetime_takedowns)

                    # Collect bounty
                    coinbounty = int(
                        shootee_data.bounty /
                        ewcfg.slimecoin_exchangerate)  # 100 slime per coin

                    # Move around slime as a result of the shot.
                    if shootee_data.slimes >= 0:
                        if was_juvenile:
                            user_data.change_slimes(
                                n=slimes_dropped, source=ewcfg.source_killing)
                        else:
                            user_data.change_slimecredit(
                                n=coinbounty,
                                coinsource=ewcfg.coinsource_bounty)
                            user_data.change_slimes(
                                n=slimes_dropped / 2,
                                source=ewcfg.source_killing)
                            boss_slimes += int(slimes_dropped / 2)

                    # Steal items
                    ewitem.item_loot(member=member,
                                     id_user_target=cmd.message.author.id)

                    #add bounty
                    user_data.add_bounty(n=(shootee_data.bounty / 2) +
                                         (slimes_dropped / 4))

                    # Give a bonus to the player's weapon skill for killing a stronger player.
                    if shootee_data.slimelevel >= user_data.slimelevel:
                        user_data.add_weaponskill(n=1)

                    # Player was killed.
                    shootee_data.id_killer = user_data.id_user
                    shootee_data.die(cause=ewcfg.cause_killing)
                    shootee_data.change_slimes(
                        n=-slimes_dropped / 10,
                        source=ewcfg.source_ghostification)

                    kill_descriptor = "beaten to death"
                    if weapon != None:
                        response = weapon.str_damage.format(
                            name_player=cmd.message.author.display_name,
                            name_target=member.display_name,
                            hitzone=randombodypart,
                            strikes=strikes)
                        kill_descriptor = weapon.str_killdescriptor
                        if crit:
                            response += " {}".format(
                                weapon.str_crit.format(
                                    name_player=cmd.message.author.
                                    display_name,
                                    name_target=member.display_name))

                        response += "\n\n{}".format(
                            weapon.str_kill.format(
                                name_player=cmd.message.author.display_name,
                                name_target=member.display_name,
                                emote_skull=ewcfg.emote_slimeskull))
                        shootee_data.trauma = weapon.id_weapon

                        if slimeoid.level == ewcfg.slimeoid_state_active:
                            brain = ewcfg.brain_map.get(slimeoid.ai)
                            response += "\n\n{}" + brain.str_kill.format(
                                slimeoid_name=shootee_slimeoid.name)

                        if shootee_slimeoid.level == ewcfg.slimeoid_state_active:
                            brain = ewcfg.brain_map.get(shootee_slimeoid.ai)
                            response += "\n\n{}" + brain.str_death.format(
                                slimeoid_name=shootee_slimeoid.name)

                    else:
                        response = "{name_target} is hit!!\n\n{name_target} has died.".format(
                            name_target=member.display_name)

                        shootee_data.trauma = ""

                        if slimeoid.life_state == ewcfg.slimeoid_state_active:
                            brain = ewcfg.brain_map.get(slimeoid.ai)
                            response += "\n\n" + brain.str_kill.format(
                                slimeoid_name=shootee_slimeoid.name)

                        if shootee_slimeoid.life_state == ewcfg.slimeoid_state_active:
                            brain = ewcfg.brain_map.get(shootee_slimeoid.ai)
                            response += "\n\n" + brain.str_death.format(
                                slimeoid_name=shootee_slimeoid.name)

                    deathreport = "You were {} by {}. {}".format(
                        kill_descriptor, cmd.message.author.display_name,
                        ewcfg.emote_slimeskull)
                    deathreport = "{} ".format(
                        ewcfg.emote_slimeskull) + ewutils.formatMessage(
                            member, deathreport)

                    if coinbounty > 0:
                        response += "\n\n SlimeCorp transfers {} SlimeCoin to {}\'s account.".format(
                            str(coinbounty), cmd.message.author.display_name)
                else:
                    # A non-lethal blow!
                    shootee_data.change_slimes(n=-slimes_damage,
                                               source=ewcfg.source_damage)
                    damage = str(slimes_damage)

                    if weapon != None:
                        if miss:
                            response = "{}".format(
                                weapon.str_miss.format(
                                    name_player=cmd.message.author.
                                    display_name,
                                    name_target=member.display_name))
                        else:
                            response = weapon.str_damage.format(
                                name_player=cmd.message.author.display_name,
                                name_target=member.display_name,
                                hitzone=randombodypart,
                                strikes=strikes)
                            if crit:
                                response += " {}".format(
                                    weapon.str_crit.format(
                                        name_player=cmd.message.author.
                                        display_name,
                                        name_target=member.display_name))
                            response += " {target_name} loses {damage} slime!".format(
                                target_name=member.display_name, damage=damage)
                    else:
                        # unarmed attacks have no miss or crit chance
                        response = "{target_name} is hit!! {target_name} loses {damage} slime!".format(
                            target_name=member.display_name, damage=damage)
            else:
                response = 'You are unable to attack {}.'.format(
                    member.display_name)

            # Add level up text to response if appropriate
            if user_inital_level < user_data.slimelevel:
                response += "\n\n{} has been empowered by slime and is now a level {} slimeboi!".format(
                    cmd.message.author.display_name, user_data.slimelevel)

            # # Give slimes to the boss if possible.
            # boss_member = None
            # if boss_slimes > 0:
            # 	for member_search in cmd.message.server.members:
            # 		if role_boss in ewutils.getRoleMap(member_search.roles):
            # 			boss_member = member_search
            # 			break

            # if boss_member != None:
            # 	boss_data = EwUser(member = boss_member)
            # 	boss_data.change_slimes(n = boss_slimes)
            # 	boss_data.persist()

            kingpin = ewutils.find_kingpin(id_server=cmd.message.server.id,
                                           kingpin_role=role_boss)

            if kingpin:
                kingpin.change_slimes(n=boss_slimes)
                kingpin.persist()

            # Persist every users' data.
            user_data.persist()
            shootee_data.persist()

            # Assign the corpse role to the newly dead player.
            if was_killed:
                await ewrolemgr.updateRoles(client=cmd.client, member=member)

    # Send the response to the player.
    await cmd.client.send_message(
        cmd.message.channel, ewutils.formatMessage(cmd.message.author,
                                                   response))
    if deathreport != "":
        sewerchannel = ewutils.get_channel(cmd.message.server,
                                           ewcfg.channel_sewers)
        await cmd.client.send_message(sewerchannel, deathreport)
Example #7
0
async def cast(cmd):
	time_now = round(time.time())
	has_reeled = False
	user_data = EwUser(member = cmd.message.author)
	if user_data.life_state == ewcfg.life_state_shambler:
		response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))
	
	market_data = EwMarket(id_server = cmd.message.author.guild.id)
	statuses = user_data.getStatusEffects()

	if cmd.message.author.id not in fishers.keys():
		fishers[cmd.message.author.id] = EwFisher()

	fisher = fishers[cmd.message.author.id]

	# Ghosts cannot fish.
	if user_data.life_state == ewcfg.life_state_corpse:
		response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive)

	# Players who are already cast a line cannot cast another one.
	elif fisher.fishing == True:
		response = "You've already cast a line."

	# Only fish at The Pier
	elif user_data.poi in ewcfg.piers:
		poi = ewcfg.id_to_poi.get(user_data.poi)
		district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server)

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel):
			response = "You're too hungry to fish right now."

		else:
			has_fishingrod = False

			if user_data.weapon >= 0:
				weapon_item = EwItem(id_item = user_data.weapon)
				weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type"))
				if weapon.id_weapon == "fishingrod":
					has_fishingrod = True

			#if user_data.sidearm >= 0:
			#	sidearm_item = EwItem(id_item=user_data.sidearm)
			#	sidearm = ewcfg.weapon_map.get(sidearm_item.item_props.get("weapon_type"))
			#	if sidearm.id_weapon == "fishingrod":
			#		has_fishingrod = True

			if ewcfg.status_high_id in statuses:
				fisher.high = True
			fisher.fishing = True
			fisher.bait = False
			fisher.pier = ewcfg.id_to_poi.get(user_data.poi)
			fisher.current_fish = gen_fish(market_data, fisher, has_fishingrod)
			
			high_value_bait_used = False

			global fishing_counter
			fishing_counter += 1
			current_fishing_id = fisher.fishing_id = fishing_counter

			item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
			author = cmd.message.author
			server = cmd.guild

			item_sought = ewitem.find_item(item_search = item_search, id_user = author.id, id_server = server.id)

			if item_sought:
				item = EwItem(id_item = item_sought.get('id_item'))

				if item.item_type == ewcfg.it_food:

					str_name = item.item_props['food_name']
					id_food = item.item_props.get('id_food')
					fisher.bait = True

					if id_food in ewcfg.plebe_bait:
						fisher.current_fish = "plebefish"

					elif id_food == "doublestuffedcrust":
						if random.randrange(5) == 3:
							fisher.current_fish = "doublestuffedflounder"

					elif id_food in ["chickenbucket", "familymeal"]:
						if random.randrange(5) == 3:
							fisher.current_fish = "seacolonel"

					elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]:
						if random.randrange(5) == 3:
							fisher.current_fish = "marlinsupreme"

					elif id_food in ["blacklimes", "blacklimesour"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "blacklimesalmon"

					elif id_food in ["pinkrowddishes", "pinkrowdatouille"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "thrash"

					elif id_food in ["purplekilliflowercrustpizza", "purplekilliflower"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "dab"

					elif id_food == "kingpincrab":
						if random.randrange(5) == 1:
							fisher.current_fish = "uncookedkingpincrab"
							
					elif id_food == "masterbait":
						high_value_bait_used = True

					elif float(item.time_expir if item.time_expir is not None else 0) < time.time():
						if random.randrange(2) == 1:
							fisher.current_fish = "plebefish"
					ewitem.item_delete(item_sought.get('id_item'))

			if fisher.current_fish == "item":
				fisher.current_size = "item"

			else:
				fisher.current_size = gen_fish_size(has_fishingrod)

			if fisher.bait == False:
				response = "You cast your fishing line into the "
			else:
				response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name)


			if fisher.pier.pier_type == ewcfg.fish_slime_saltwater:
				response += "vast Slime Sea."
			else:
				response += "glowing Slime Lake."

			user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
			user_data.persist()
			
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	
			bite_text = gen_bite_text(fisher.current_size)
			
			# User has a 1/10 chance to get a bite
			fun = 100

			if fisher.bait == True:
				# Bait attatched, chance to get a bite increases from 1/10 to 1/7
				fun -= 30
			if fisher.pier == ewcfg.poi_id_ferry:
				# Fisher is on the ferry, chance to get a bite increases from 1/10 to 1/8
				fun -= 20
			if high_value_bait_used:
				fun = 5
				
			bun = 0

			while not ewutils.TERMINATE:
				
				if fun <= 0:
					fun = 1
				else:
					damp = random.randrange(fun)
				
				if fisher.high:
					await asyncio.sleep(30)
				elif high_value_bait_used:
					await asyncio.sleep(5)
				else:
					await asyncio.sleep(60)

				# Cancel if fishing was interrupted
				if current_fishing_id != fisher.fishing_id:
					return
				if fisher.fishing == False:
					return

				user_data = EwUser(member=cmd.message.author)

				if fisher.pier == "" or user_data.poi != fisher.pier.id_poi:
					fisher.stop()
					return
				if user_data.life_state == ewcfg.life_state_corpse:
					fisher.stop()
					return

				if damp > 10:
					await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text)))
					fun -= 2
					bun += 1
					if bun >= 5:
						fun -= 1
					if bun >= 15:
						fun -= 1
					continue
				else:
					break


			fisher.bite = True
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, bite_text))

			await asyncio.sleep(8)

			if fisher.bite != False:
				fisher.stop()
				return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away..."))
			else:
				has_reeled = True

	else:
		response = "You can't fish here. Go to a pier."
	
	# Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead.
	if has_reeled == False:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))