async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = ewutils.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 = ewcfg.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 = ewquadrants.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 ewmap.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 ewcfg.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 #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.busted = False 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 = ewcfg.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 = ewutils.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()
async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.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?" elif cmd.mentions_count == 1: # Get the user and target data from the database. user_data = EwUser(member=cmd.message.author) member = cmd.mentions[0] haunted_data = EwUser(member=member) market_data = EwMarket(id_server=cmd.message.server.id) target_isshambler = haunted_data.life_state == ewcfg.life_state_shambler 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 ewmap.channel_name_is_poi(cmd.message.channel.name) == False: response = "You can't commit violence from here." elif time_now > haunted_data.time_expirpvp and not target_isshambler: # Require the target to be flagged for PvP 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: # Target can be haunted by the player. haunted_slimes = int(haunted_data.slimes / ewcfg.slimes_hauntratio) # if user_data.poi == haunted_data.poi: # when haunting someone face to face, there is no cap and you get double the amount # haunted_slimes *= 2 if haunted_slimes > ewcfg.slimes_hauntmax: haunted_slimes = ewcfg.slimes_hauntmax #if -user_data.slimes < haunted_slimes: # cap on for how much you can haunt # haunted_slimes = -user_data.slimes haunted_data.change_slimes(n=-haunted_slimes, 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.busted = False user_data.time_expirpvp = ewutils.calculatePvpTimer( user_data.time_expirpvp, (int(time.time()) + ewcfg.time_pvp_attack)) 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!".format( member.display_name, cmd.message.author.display_name) haunted_channel = ewcfg.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( "<.+>", "", 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 += "." haunt_message = ewutils.formatMessage(member, haunt_message) resp_cont.add_channel_response(haunted_channel, haunt_message) else: # Some condition we didn't think of. response = "You cannot haunt {}.".format(member.display_name) 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()
async def revive(cmd): time_now = int(time.time()) response = "" if cmd.message.channel.name != ewcfg.channel_endlesswar and cmd.message.channel.name != ewcfg.channel_sewers: response = "Come to me. I hunger. #{}.".format(ewcfg.channel_sewers) else: player_data = EwUser(member = cmd.message.author) slimeoid = EwSlimeoid(member = cmd.message.author) if player_data.life_state == ewcfg.life_state_corpse: market_data = EwMarket(id_server = cmd.message.server.id) # Endless War collects his fee. fee = (player_data.slimecredit / 10) player_data.change_slimecredit(n = -fee, coinsource = ewcfg.coinsource_revival) market_data.slimes_revivefee += fee player_data.busted = False # Preserve negaslime if player_data.slimes < 0: market_data.negaslime += player_data.slimes player_data.change_slimes(n = -player_data.slimes) # set to 0 # Give player some initial slimes. player_data.slimelevel = 0 player_data.change_slimes(n = ewcfg.slimes_onrevive) # Set time of last revive. This used to provied spawn protection, but currently isn't used. player_data.time_lastrevive = time_now # Set life state. This is what determines whether the player is actually alive. player_data.life_state = ewcfg.life_state_juvenile # Get the player out of the sewers. Will be endless-war eventually. player_data.poi = ewcfg.poi_id_downtown player_data.persist() market_data.persist() # Give some slimes to every living player (currently online) for member in cmd.message.server.members: if member.id != cmd.message.author.id and member.id != cmd.client.user.id: member_data = EwUser(member = member) if member_data.life_state != ewcfg.life_state_corpse and member_data.life_state != ewcfg.life_state_grandfoe: member_data.change_slimes(n = ewcfg.slimes_onrevive_everyone) member_data.persist() await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) response = '{slime4} A geyser of fresh slime erupts, showering Rowdy, Killer, and Juvenile alike. {slime4} {name} has been reborn in slime. {slime4}'.format(slime4 = ewcfg.emote_slime4, name = cmd.message.author.display_name) else: response = 'You\'re not dead just yet.' # 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 slimeoid.life_state == ewcfg.slimeoid_state_active: reunite = "" brain = ewcfg.brain_map.get(slimeoid.ai) reunite += brain.str_revive.format( slimeoid_name = slimeoid.name ) downtownchannel = ewutils.get_channel(cmd.message.server, ewcfg.channel_downtown) reunite = ewutils.formatMessage(cmd.message.author, reunite) await cmd.client.send_message(downtownchannel, reunite) # Send the response to the player. await cmd.client.send_message(cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))