def limit_fix(self): if self.hunger > ewutils.hunger_max_bylevel(self.slimelevel): self.hunger = ewutils.hunger_max_bylevel(self.slimelevel) if self.inebriation < 0: self.inebriation = 0 if self.poi == '': self.poi = ewcfg.poi_id_downtown
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))
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."))
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))
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)
def get_hunger_max(self): return ewutils.hunger_max_bylevel(self.slimelevel)
async def data(cmd): response = "" user_data = None member = None if cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server=cmd.message.server.id) poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "You find yourself {} {}. ".format( poi.str_in, poi.str_name) # return my data if user_data.life_state == ewcfg.life_state_corpse: response += "You are a level {} deadboi.".format( user_data.slimelevel) else: response += "You are a level {} slimeboi.".format( user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon = ewcfg.weapon_map.get(user_data.weapon) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_wielding_self, ("" if len(user_data.weaponname) == 0 else "{}, ".format( user_data.weaponname)), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster_self.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma_self) user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) if user_kills > 0: response += " You have {:,} confirmed kills.".format(user_kills) if coinbounty != 0: response += " SlimeCorp offers a bounty of {:,} SlimeCoin for your death.".format( coinbounty) if user_data.hunger > 0: response += " You are {}% hungry.".format( round( user_data.hunger * 100.0 / ewutils.hunger_max_bylevel(user_data.slimelevel), 1)) if user_data.ghostbust: response += " The coleslaw in your stomach enables you to bust ghosts." if user_data.busted and user_data.life_state == ewcfg.life_state_corpse: response += " You are busted and therefore cannot leave the sewers without reviving." else: member = cmd.mentions[0] user_data = EwUser(member=member) market_data = EwMarket(id_server=cmd.message.server.id) if user_data.life_state == ewcfg.life_state_grandfoe: poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "{} is {} {}.".format(member.display_name, poi.str_in, poi.str_name) else: response = "You can't discern anything useful about {}.".format( member.display_name) else: # return somebody's score if user_data.life_state == ewcfg.life_state_corpse: response = "{} is a level {} deadboi.".format( member.display_name, user_data.slimelevel) else: response = "{} is a level {} slimeboi.".format( member.display_name, user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon = ewcfg.weapon_map.get(user_data.weapon) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_wielding, ("" if len(user_data.weaponname) == 0 else "{}, ".format( user_data.weaponname)), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma) user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) if user_kills > 0: response += " They have {:,} confirmed kills.".format( user_kills) if coinbounty != 0: response += " SlimeCorp offers a bounty of {:,} SlimeCoin for their death.".format( coinbounty) # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) if member != None: await ewrolemgr.updateRoles(client=cmd.client, member=member)
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))