示例#1
0
 def die(self, cause=None):
     if cause == ewcfg.cause_busted:
         self.busted = True
     else:
         self.busted = False  # reset busted state on normal death; potentially move this to ewspooky.revive
         self.life_state = ewcfg.life_state_corpse
         ewstats.increment_stat(user=self,
                                metric=ewcfg.stat_lifetime_deaths)
         ewstats.change_stat(user=self,
                             metric=ewcfg.stat_lifetime_slimeloss,
                             n=self.slimes)
         if cause != ewcfg.cause_killing and cause != ewcfg.cause_suicide:
             ewstats.increment_stat(user=self,
                                    metric=ewcfg.stat_lifetime_pve_deaths)
     self.slimes = 0
     self.poi = ewcfg.poi_id_thesewers
     self.bounty = 0
     self.totaldamage = 0
     self.slimelevel = 1
     self.hunger = 0
     self.inebriation = 0
     self.ghostbust = False
     # Clear weapon and weaponskill.
     self.weapon = ""
     self.weaponskill = 0
     ewutils.weaponskills_clear(id_server=self.id_server,
                                id_user=self.id_user)
     ewstats.clear_on_death(id_server=self.id_server, id_user=self.id_user)
     ewitem.item_destroyall(id_server=self.id_server, id_user=self.id_user)
示例#2
0
def process_pve_kills(id_server=None, id_user=None, value=None):
    ewstats.track_maximum(id_server=id_server,
                          id_user=id_user,
                          metric=ewcfg.stat_max_pve_kills,
                          value=value)
    ewstats.increment_stat(id_server=id_server,
                           id_user=id_user,
                           metric=ewcfg.stat_lifetime_pve_kills)
示例#3
0
def process_ghostbusts(id_server=None, id_user=None, value=None):
    ewstats.track_maximum(id_server=id_server,
                          id_user=id_user,
                          metric=ewcfg.stat_max_ghostbusts,
                          value=value)
    ewstats.increment_stat(id_server=id_server,
                           id_user=id_user,
                           metric=ewcfg.stat_lifetime_ghostbusts)
示例#4
0
async def burnSlimes(id_server = None):
	if id_server != None:
		time_now = int(time.time())
		client = get_client()
		server = client.get_server(id_server)

		results = {}

		# Get users with burning effect
		data = execute_sql_query("SELECT {id_user}, {value}, {source} from status_effects WHERE {id_status} = %s and {id_server} = %s".format(
			id_user = ewcfg.col_id_user,
			value = ewcfg.col_value,
			id_status = ewcfg.col_id_status,
			id_server = ewcfg.col_id_server,
			source = ewcfg.col_source
		), (
			ewcfg.status_burning_id,
			id_server
		))

		deathreport = ""
		resp_cont = EwResponseContainer(id_server = id_server)
		for result in data:
			user_data = EwUser(id_user = result[0], id_server = id_server)

			slimes_dropped = user_data.totaldamage + user_data.slimes

			# Deal 10% of total slime to burn every second
			slimes_to_burn = math.ceil(int(float(result[1])) * ewcfg.burn_tick_length / ewcfg.time_expire_burn)

			killer_data = EwUser(id_server = id_server, id_user=result[2])

			# Damage stats
			ewstats.change_stat(user = killer_data, metric = ewcfg.stat_lifetime_damagedealt, n = slimes_to_burn)

			# Player died
			if user_data.slimes - slimes_to_burn < 0:	
				weapon = ewcfg.weapon_map.get(ewcfg.weapon_id_molotov)

				player_data = EwPlayer(id_server = user_data.id_server, id_user = user_data.id_user)
				killer = EwPlayer(id_server = id_server, id_user=killer_data.id_user)

				# Kill stats
				ewstats.increment_stat(user = killer_data, metric = ewcfg.stat_kills)
				ewstats.track_maximum(user = killer_data, metric = ewcfg.stat_biggest_kill, value = int(slimes_dropped))

				if killer_data.slimelevel > user_data.slimelevel:
					ewstats.increment_stat(user = killer_data, metric = ewcfg.stat_lifetime_ganks)
				elif killer_data.slimelevel < user_data.slimelevel:
					ewstats.increment_stat(user = killer_data, metric = ewcfg.stat_lifetime_takedowns)

				# Collect bounty
				coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate)  # 100 slime per coin
				
				if user_data.slimes >= 0:
					killer_data.change_slimecoin(n = coinbounty, coinsource = ewcfg.coinsource_bounty)

				# Kill player
				user_data.id_killer = killer_data.id_user
				user_data.die(cause = ewcfg.cause_burning)
				#user_data.change_slimes(n = -slimes_dropped / 10, source = ewcfg.source_ghostification)
			
				deathreport = "You were {} by {}. {}".format(weapon.str_killdescriptor, killer.display_name, ewcfg.emote_slimeskull)
				deathreport = "{} ".format(ewcfg.emote_slimeskull) + formatMessage(server.get_member(user_data.id_user), deathreport)
				resp_cont.add_channel_response(ewcfg.channel_sewers, deathreport)

				user_data.trauma = weapon.id_weapon

				user_data.persist()
				await ewrolemgr.updateRoles(client = client, member = server.get_member(user_data.id_user))
			else:
				user_data.change_slimes(n = -slimes_to_burn, source = ewcfg.source_damage)
				user_data.persist()
				

		await resp_cont.post()	
示例#5
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)
示例#6
0
	def die(self, cause = None):
		time_now = int(time.time())

		ewutils.end_trade(self.id_user)

		resp_cont = ewutils.EwResponseContainer(id_server = self.id_server)

		client = ewcfg.get_client()
		server = client.get_server(self.id_server)

		deathreport = ''
		
		# remove ghosts inhabiting player
		self.remove_inhabitation()

		# Make The death report
		deathreport = ewutils.create_death_report(cause = cause, user_data = self)
		resp_cont.add_channel_response(ewcfg.channel_sewers, deathreport)

		poi = ewcfg.id_to_poi.get(self.poi)
		if cause == ewcfg.cause_weather:
			resp_cont.add_channel_response(poi.channel, deathreport)

		# Grab necessary data for spontaneous combustion before stat reset
		explosion_block_list = [ewcfg.cause_leftserver, ewcfg.cause_cliff]
		user_hasCombustion = False
		if (cause not in explosion_block_list) and (poi.pvp):
			if ewcfg.mutation_id_spontaneouscombustion in self.get_mutations():
				user_hasCombustion = True
				explode_damage = ewutils.slime_bylevel(self.slimelevel) / 5
				explode_district = ewdistrict.EwDistrict(district = self.poi, id_server = self.id_server)
				explode_poi_channel = ewcfg.id_to_poi.get(self.poi).channel

		if cause == ewcfg.cause_busted:
			self.busted = True
			self.poi = ewcfg.poi_id_thesewers
			#self.slimes = int(self.slimes * 0.9)
		else:
			self.busted = False  # reset busted state on normal death; potentially move this to ewspooky.revive
			self.slimes = 0
			self.slimelevel = 1
			self.clear_mutations()
			self.clear_allstatuses()
			self.totaldamage = 0
			self.bleed_storage = 0
			self.hunger = 0
			self.inebriation = 0
			self.bounty = 0
			self.time_lastdeath = time_now		
	
			# if self.life_state == ewcfg.life_state_shambler:
			# 	self.degradation += 1
			# else:
			# 	self.degradation += 5

			ewstats.increment_stat(user = self, metric = ewcfg.stat_lifetime_deaths)
			ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimeloss, n = self.slimes)

			if cause == ewcfg.cause_cliff:
				pass
			else:
				if self.life_state == ewcfg.life_state_juvenile: # If you were a Juvenile.
					item_fraction = 4
					food_fraction = 4
					cosmetic_fraction = 4

				else:  # If you were a Gangster.
					item_fraction = 2
					food_fraction = 2
					cosmetic_fraction = 2
					self.slimecoin = int(self.slimecoin) - (int(self.slimecoin) / 10)

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_item, fraction = item_fraction) # Drop a random fraction of your items on the ground.
				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_food, fraction = food_fraction) # Drop a random fraction of your food on the ground.

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_cosmetic, fraction = cosmetic_fraction) # Drop a random fraction of your unadorned cosmetics on the ground.
				ewitem.item_dedorn_cosmetics(id_server = self.id_server, id_user = self.id_user) # Unadorn all of your adorned hats.
				self.freshness = 0

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_weapon, fraction = 1) # Drop random fraction of your unequipped weapons on the ground.
				ewutils.weaponskills_clear(id_server = self.id_server, id_user = self.id_user, weaponskill = ewcfg.weaponskill_max_onrevive)

			self.life_state = ewcfg.life_state_corpse
			self.poi_death = self.poi
			self.poi = ewcfg.poi_id_thesewers
			self.weapon = -1
			self.time_expirpvp = 0

		if cause == ewcfg.cause_killing_enemy:  # If your killer was an Enemy. Duh.
			ewstats.increment_stat(user = self, metric = ewcfg.stat_lifetime_pve_deaths)

		if cause == ewcfg.cause_leftserver:
			ewitem.item_dropall(id_server=self.id_server, id_user=self.id_user)

		self.sap = 0
		self.hardened_sap = 0
		self.attack = 0
		self.defense = 0
		self.speed = 0

		ewutils.moves_active[self.id_user] = 0
		ewutils.active_target_map[self.id_user] = ""
		ewutils.active_restrictions[self.id_user] = 0
		ewstats.clear_on_death(id_server = self.id_server, id_user = self.id_user)

		self.persist()

		if cause not in explosion_block_list: # Run explosion after location/stat reset, to prevent looping onto self
			if user_hasCombustion:
				explode_resp = "\n{} spontaneously combusts, horribly dying in a fiery explosion of slime and shrapnel!! Oh, the humanity!\n".format(server.get_member(self.id_user).display_name)
				ewutils.logMsg("")
				resp_cont.add_channel_response(explode_poi_channel, explode_resp)

				explosion = ewutils.explode(damage = explode_damage, district_data = explode_district)
				resp_cont.add_response_container(explosion)

		#ewitem.item_destroyall(id_server = self.id_server, id_user = self.id_user)

		ewutils.logMsg('server {}: {} was killed by {} - cause was {}'.format(self.id_server, self.id_user, self.id_killer, cause))

		return(resp_cont)
示例#7
0
	def die(self, cause = None):
		time_now = int(time.time())

		ewutils.end_trade(self.id_user)

		if cause == ewcfg.cause_busted:
			self.busted = True
			self.poi = ewcfg.poi_id_thesewers
			#self.slimes = int(self.slimes * 0.9)
		else:
			self.busted = False  # reset busted state on normal death; potentially move this to ewspooky.revive
			self.slimes = 0
			self.slimelevel = 1
			self.clear_mutations()
			self.clear_allstatuses()
			self.totaldamage = 0
			self.bleed_storage = 0
			self.hunger = 0
			self.inebriation = 0
			self.bounty = 0

			ewstats.increment_stat(user = self, metric = ewcfg.stat_lifetime_deaths)
			ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimeloss, n = self.slimes)


			if self.time_expirpvp >= time_now: # If you were Wanted.
				if cause != ewcfg.cause_cliff:
					ewitem.item_dropall(id_server = self.id_server, id_user = self.id_user)

				ewutils.weaponskills_clear(id_server = self.id_server, id_user = self.id_user, weaponskill = ewcfg.weaponskill_min_onrevive)
				self.slimecoin = 0
				self.weaponmarried = False

			if cause == ewcfg.cause_cliff:
				pass
			else:
				if self.life_state == ewcfg.life_state_juvenile: # If you were a Juvenile.
					item_fraction = 4
					food_fraction = 4
					cosmetic_fraction = 4

				else:  # If you were mired in normal Gang Violence, meaning if you were a Rowdy and your killer was a Killer, or vice versa.
					item_fraction = 2
					food_fraction = 2
					cosmetic_fraction = 2
					self.slimecoin = int(self.slimecoin) - (int(self.slimecoin) / 10)

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_item, fraction = item_fraction) # Drop a random fraction of your items on the ground.
				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_food, fraction = food_fraction) # Drop a random fraction of your food on the ground.

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_cosmetic, fraction = cosmetic_fraction) # Drop a random fraction of your unadorned cosmetics on the ground.
				ewitem.item_dedorn_cosmetics(id_server = self.id_server, id_user = self.id_user) # Unadorn all of your adorned hats.

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_weapon, fraction = 1) # Drop random fraction of your unequipped weapons on the ground.
				ewutils.weaponskills_clear(id_server = self.id_server, id_user = self.id_user, weaponskill = ewcfg.weaponskill_max_onrevive)

			self.life_state = ewcfg.life_state_corpse
			self.poi_death = self.poi
			self.poi = ewcfg.poi_id_thesewers
			self.weapon = -1
			self.time_expirpvp = 0

		if cause == ewcfg.cause_killing_enemy:  # If your killer was an Enemy. Duh.
			ewstats.increment_stat(user = self, metric = ewcfg.stat_lifetime_pve_deaths)

		if cause == ewcfg.cause_leftserver:
			ewitem.item_dropall(id_server=self.id_server, id_user=self.id_user)

		self.sap = 0
		self.hardened_sap = 0
		ewutils.moves_active[self.id_user] = 0
		ewstats.clear_on_death(id_server = self.id_server, id_user = self.id_user)

		#ewitem.item_destroyall(id_server = self.id_server, id_user = self.id_user)

		ewutils.logMsg('server {}: {} was killed by {} - cause was {}'.format(self.id_server, self.id_user, self.id_killer, cause))