async def hogtie(cmd): if not cmd.message.author.guild_permissions.administrator: return await cmd_utils.fake_failed_command(cmd) else: if cmd.mentions_count == 1: target_data = EwUser(member=cmd.mentions[0]) target_status = target_data.getStatusEffects() if ewcfg.status_hogtied_id in target_status: target_data.clear_status(id_status=ewcfg.status_hogtied_id) response = "Whew-whee! She's buckin' so we gotta let 'er go." await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) else: target_data.applyStatus(ewcfg.status_hogtied_id) response = "Boy howdy! Looks like we lasso'd up a real heifer there! A dang ol' big'un." await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = EwResponseContainer(id_server=cmd.guild.id) if cmd.mentions_count > 1: response = "You can only spook one person at a time. Who do you think you are, the Lord of Ghosts?" else: haunted_data = None member = None if cmd.mentions_count == 0 and cmd.tokens_count > 1: server = cmd.guild member = server.get_member(ewutils.getIntToken(cmd.tokens)) haunted_data = EwUser(member=member) elif cmd.mentions_count == 1: member = cmd.mentions[0] haunted_data = EwUser(member=member) if member: # Get the user and target data from the database. user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server=cmd.guild.id) target_mutations = haunted_data.get_mutations() target_poi = poi_static.id_to_poi.get(haunted_data.poi) target_is_shambler = haunted_data.life_state == ewcfg.life_state_shambler target_is_inhabitted = haunted_data.id_user == user_data.get_inhabitee( ) if user_data.life_state != ewcfg.life_state_corpse: # Only dead players can haunt. response = "You can't haunt now. Try {}.".format( ewcfg.cmd_suicide) elif haunted_data.life_state == ewcfg.life_state_kingpin: # Disallow haunting of generals. response = "He is too far from the sewers in his ivory tower, and thus cannot be haunted." elif (time_now - user_data.time_lasthaunt) < ewcfg.cd_haunt: # Disallow haunting if the user has haunted too recently. response = "You're being a little TOO spooky lately, don't you think? Try again in {} seconds.".format( int(ewcfg.cd_haunt - (time_now - user_data.time_lasthaunt))) elif ewutils.channel_name_is_poi( cmd.message.channel.name) == False: response = "You can't commit violence from here." elif target_poi.pvp == False: # Require the target to be in a PvP area, and flagged if it's a remote haunt response = "{} is not mired in the ENDLESS WAR right now.".format( member.display_name) elif haunted_data.life_state == ewcfg.life_state_corpse: # Dead players can't be haunted. response = "{} is already dead.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_grandfoe: # Grand foes can't be haunted. response = "{} is invulnerable to ghosts.".format( member.display_name) elif haunted_data.life_state == ewcfg.life_state_enlisted or haunted_data.life_state == ewcfg.life_state_juvenile or haunted_data.life_state == ewcfg.life_state_shambler: haunt_power_multiplier = 1 # power to the ancients ghost_age = time_now - user_data.time_lastdeath if ghost_age > 60 * 60 * 24 * 7: # dead for longer than if ghost_age > 60 * 60 * 24 * 365: # one friggin year haunt_power_multiplier *= 2.5 if ghost_age > 60 * 60 * 24 * 90: # three months haunt_power_multiplier *= 2 elif ghost_age > 60 * 60 * 24 * 30: # one month haunt_power_multiplier *= 1.5 else: # one week haunt_power_multiplier *= 1.25 # vitriol as virtue list_ids = [] for quadrant in ewcfg.quadrant_ids: quadrant_data = EwQuadrant(id_server=cmd.guild.id, id_user=cmd.message.author.id, quadrant=quadrant) if quadrant_data.id_target != -1 and quadrant_data.check_if_onesided( ) is False: list_ids.append(quadrant_data.id_target) if quadrant_data.id_target2 != -1 and quadrant_data.check_if_onesided( ) is False: list_ids.append(quadrant_data.id_target2) if haunted_data.id_user in list_ids: # any mutual quadrants haunt_power_multiplier *= 1.2 if haunted_data.faction and ( (not user_data.faction) or (user_data.faction != haunted_data.faction) ): # opposite faction (or no faction at all) haunt_power_multiplier *= 1.2 if user_data.id_killer == haunted_data.id_user: # haunting your murderer/buster haunt_power_multiplier *= 1.2 # places of power. if haunted_data.poi in [ ewcfg.poi_id_thevoid, ewcfg.poi_id_wafflehouse, ewcfg.poi_id_blackpond ]: haunt_power_multiplier *= 2 elif haunted_data.poi in get_void_connection_pois( cmd.guild.id): haunt_power_multiplier *= 1.25 # glory to the vanquished target_kills = ewstats.get_stat(user=haunted_data, metric=ewcfg.stat_kills) if target_kills > 5: haunt_power_multiplier *= 1.25 + ( (target_kills - 5) / 100) # 1% per kill after 5 else: haunt_power_multiplier *= 1 + (target_kills * 5 / 100 ) # 5% per kill if time_now - haunted_data.time_lastkill < (60 * 15): haunt_power_multiplier *= 1.5 # wet hands # misc if weather_static.weather_map.get( market_data.weather) == ewcfg.weather_foggy: haunt_power_multiplier *= 1.1 if not haunted_data.has_soul: haunt_power_multiplier *= 1.2 # uncomment this after moon mechanics update # if (market_data.day % 31 == 15 and market_data.clock >= 20) or (market_data.day % 31 == 16 and market_data.clock <= 6): # haunt_power_multiplier *= 2 # divide haunt power by 2 if not in same area if user_data.poi != haunted_data.poi: haunt_power_multiplier /= 2 # Double Halloween if ewcfg.dh_active: haunt_power_multiplier *= 4 haunted_slimes = int( (haunted_data.slimes / ewcfg.slimes_hauntratio) * haunt_power_multiplier) slimes_lost = int( haunted_slimes / 5 ) # hauntee only loses 1/5th of what the ghost gets as antislime if ewcfg.mutation_id_coleblooded in target_mutations: haunted_slimes = -10000 if user_data.slimes > haunted_slimes: haunted_slimes = user_data.slimes haunted_data.change_slimes(n=-slimes_lost, source=ewcfg.source_haunted) user_data.change_slimes(n=-haunted_slimes, source=ewcfg.source_haunter) market_data.negaslime -= haunted_slimes user_data.time_lasthaunt = time_now user_data.clear_status(id_status=ewcfg.status_busted_id) resp_cont.add_member_to_update(cmd.message.author) # Persist changes to the database. user_data.persist() haunted_data.persist() market_data.persist() response = "{} has been haunted by the ghost of {}! Slime has been lost! {} antislime congeals within you.".format( member.display_name, cmd.message.author.display_name, haunted_slimes) if ewcfg.mutation_id_coleblooded in target_mutations: response = "{} has been haunted by the ghost of {}! Their exorcising coleslaw blood purges {} antislime from your being! Better not do that again.".format( member.display_name, cmd.message.author.display_name, -haunted_slimes) haunted_channel = poi_static.id_to_poi.get( haunted_data.poi).channel haunt_message = "You feel a cold shiver run down your spine" if cmd.tokens_count > 2: haunt_message_content = re.sub( "<.+>" if cmd.mentions_count == 1 else "\d{17,}", "", cmd.message.content[(len(cmd.tokens[0])):]).strip() # Cut down really big messages so discord doesn't crash if len(haunt_message_content) > 500: haunt_message_content = haunt_message_content[:-500] haunt_message += " and faintly hear the words \"{}\"".format( haunt_message_content) haunt_message += ". {} slime evaporates from your body.".format( slimes_lost) if ewcfg.mutation_id_coleblooded in target_mutations: haunt_message += " The ghost that did it wails in agony as their ectoplasm boils in your coleslaw blood!" haunt_message = fe_utils.formatMessage(member, haunt_message) resp_cont.add_channel_response(haunted_channel, haunt_message) else: # No mentions, or mentions we didn't understand. response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name." # Send the response to the player. resp_cont.add_channel_response(cmd.message.channel.name, response) await resp_cont.post()