Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # GAME'S OUTPUT WITH TRACEBACKS
- https://i.imgur.com/rBSpTAj.png
- '''
- Server restart initiated ...
- ... Server restarted.
- [Success: 16 Roll: 21] Using the center of a quarterstave as a fulcrum, you swat at dum with one end
- of the weapon, It suffers a small bruise to its head.
- dum has 80 health remaining!
- You are no longer busy.
- Traceback (most recent call last):
- File "d:\muddev\evennia\evennia\commands\cmdhandler.py", line 591, in _run_command
- ret = cmd.func()
- File ".\commands\combat_cmds.py", line 71, in func
- self.caller.combat.attack(target, damage_type, 'staves', 'swat')
- File "d:\muddev\hecate\world\combat_handler.py", line 131, in attack
- attacker_desc, target_desc, others_desc = build_skill_str.create_attack_desc(attacker, target,
- skillset, skill, damage_type, damage_tier, body_part, hit)
- File "d:\muddev\hecate\world\build_skill_str.py", line 29, in create_attack_desc
- skillsets = {'staves': {'leg sweep': {'attack_desc': {'attacker': f"You sweep your {weapon} at
- {t_name}\'s legs, {a_outcome}.",
- UnboundLocalError: local variable 'a_outcome' referenced before assignment
- An untrapped error occurred.
- (Traceback was logged 19-08-15 07:53:47-04).
- [Success: 16 Roll: 78] Using the center of a quarterstave as a fulcrum, you swat at dum with one end
- of the weapon, It suffers a small bruise to its head.
- dum has 60 health remaining!
- You are no longer busy.
- [Success: 16 Roll: 18] Using the center of a quarterstave as a fulcrum, you swat at dum with one end
- of the weapon, It suffers a small bruise to its head.
- dum has 40 health remaining!
- You are no longer busy.
- Traceback (most recent call last):
- File "d:\muddev\evennia\evennia\commands\cmdhandler.py", line 591, in _run_command
- ret = cmd.func()
- File ".\commands\combat_cmds.py", line 71, in func
- self.caller.combat.attack(target, damage_type, 'staves', 'swat')
- File "d:\muddev\hecate\world\combat_handler.py", line 131, in attack
- attacker_desc, target_desc, others_desc = build_skill_str.create_attack_desc(attacker, target,
- skillset, skill, damage_type, damage_tier, body_part, hit)
- File "d:\muddev\hecate\world\build_skill_str.py", line 29, in create_attack_desc
- skillsets = {'staves': {'leg sweep': {'attack_desc': {'attacker': f"You sweep your {weapon} at
- {t_name}\'s legs, {a_outcome}.",
- UnboundLocalError: local variable 'a_outcome' referenced before assignment
- An untrapped error occurred.
- (Traceback was logged 19-08-15 07:55:20-04).
- '''
- # CREATE ATTACK DESCRIPTION MODULE
- from world import generic_str
- article = generic_str.article
- pronoun = generic_str.pronoun
- def create_attack_desc(attacker, target, skillset, skill, damage_type, damage_tier, body_part, hit):
- # Temp Values
- weapon = 'quarterstave'
- wound_tier = {'slash': ['shallow cut', 'cut', 'deep cut', 'severe cut', 'devastating cut'],
- 'pierce': ['faint wound', 'puncture', 'deep puncture', 'severe puncture', 'gaping wound'],
- 'bruise': ['small bruise', 'bruise', 'ugly bruise', 'major bruise', 'fracture']}
- attack_wound = wound_tier[damage_type][damage_tier]
- # Attacker and target pronouns. Possessive (its, his, her), Singular Subject (it, he, she), Singular Object (it, him, her)
- a_poss, a_sin_sub, a_sin_obj = pronoun(attacker)
- t_poss, t_sin_sub, t_sin_obj = pronoun(target)
- a_name = attacker.key
- t_name = target.key
- # Weapon's article. 'a' or 'an'
- art_weap = article(weapon)
- if hit:
- a_outcome = str.capitalize(f"{t_sin_sub} suffers {article(attack_wound)} {attack_wound} to {t_poss} {body_part}.")
- t_outcome = f"you suffer {article(attack_wound)} {attack_wound} to your {body_part}."
- o_outcome = f"{t_name} suffers {article(attack_wound)} {attack_wound} to {t_poss} {body_part}."
- skillsets = {'staves': {'leg sweep': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'feint': {'attack_desc': {'attacker': f"You sweep your {weapon} at {target}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'end jab': {'attack_desc': {'attacker': f"You sweep your {weapon} at {target}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'swat': {'attack_desc': {'attacker': f"Using the center of a {weapon} as a fulcrum, you swat at {t_name} with one end of the weapon, {a_outcome}",
- 'target': f"Using the center of a {weapon} as a fulcrum, {attacker} swats at you with one end of the weapon, {t_outcome}",
- 'others': f"Using the center of a {weapon} as a fulcrum, {attacker} swats at {t_name} with one end of the weapon, {o_outcome}"}},
- 'simple strike': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'side strike': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'pivot smash': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'longarm strike': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'simple block': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'cross block': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'overhead block': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'parting jab': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'parting swat': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'parting smash': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'defensive sweep': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'stepping spin': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'snapstrike': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'sweep strike': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'spinstrike': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'tbash': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'whirling block': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}},
- 'pivoting longarm': {'attack_desc': {'attacker': f"You sweep your {weapon} at {t_name}\'s legs, {a_outcome}.",
- 'others': f"{a_name} sweeps {art_weap} {weapon} at {t_name}\'s legs, {o_outcome}."}}}}
- attacker_desc = skillsets[skillset][skill]['attack_desc']['attacker']
- target_desc = skillsets[skillset][skill]['attack_desc']['target']
- others_desc = skillsets[skillset][skill]['attack_desc']['others']
- return attacker_desc, target_desc, others_desc
- # GENERIC STRING HANDLER FOR PRONOUNS AND SUCH (NOT REALLY NEEDED, BUT JUST IN CASE)
- vowels = ['a', 'e', 'i', 'o', 'u']
- consonant_vowels = ['amazigh', 'euboean', 'eucharist', 'eumenides', 'eurasian', 'euro-american', 'europe',
- 'european', 'eusebius', 'oaxaca', 'ouija', 'ucalegon', 'uclaf', 'udale',
- 'udall', 'udy', 'ueberroth', 'uganda', 'uinita', 'ukase', 'ukie', 'ukraine', 'ukrainian', 'ullyses', 'unakas',
- 'uniate', 'unix', 'uranus', 'usanian', 'usonian', 'utah', 'utahn', 'utonian', 'esclop', 'eucalyptus', 'eucatastrophe',
- 'euchologion', 'euchre', 'euclidianness', 'eudaemon', 'eudemonia', 'eugarie', 'eugenesis', 'eugenics', 'eugenist',
- 'eugeny', 'euglena', 'eukaryote', 'eulachon', 'eulogy', 'eunoia', 'eunuch', 'euouae', 'euphemism', 'euphoria',
- 'euphoriant', 'eureka', 'euro', 'eustasy', 'eustress', 'eutectic', 'euth', 'euthanasia', 'eutripsia', 'ewe', 'ewer',
- 'latmul', 'once', 'oncer', 'one', 'onesie', 'ouabain', 'ubac', 'uberty', 'ubication', 'ubicity', 'ubiety', 'ubiquity',
- 'udometer', 'uey', 'ufo', 'ufologist', 'ufology', 'uke', 'ukelele', 'ukulele', 'ululate', 'ululation', 'unanimity',
- 'unanimous', 'unary', 'uni', 'unicameral', 'unicorn', 'unicycle', 'unidirection', 'unidirectional', 'unidirectionality',
- 'uniform', 'uniformitarianism', 'unify', 'unigeniture', 'union', 'unique', 'uniquity', 'unisex', 'unison', 'unit', 'unite',
- 'unity', 'univalence', 'univalent', 'universalism', 'universe', 'university', 'univocal', 'upas', 'upsilon', 'uraeus',
- 'ural', 'uranism', 'uranist', 'uranium', 'uranophobia', 'urea', 'ureter', 'ureteroureterostomy', 'urethra', 'uridine',
- 'urinal', 'urinalysis', 'urine', 'urology', 'uropygium', 'urus', 'usability', 'usage', 'use', 'user', 'using', 'usual',
- 'usufruct', 'usufruction', 'usufructuary', 'usurer', 'usuress', 'usurp', 'usurper', 'usurping', 'usury', 'ute', 'utensil',
- 'uterus', 'utile', 'utilitarian', 'utility', 'utopia', 'utopographer', 'utricle', 'uvarovite', 'uvas', 'uvea', 'uvula',
- 'uvular', 'zzxjoanw']
- def article(word):
- word.lower()
- if word[0] in vowels:
- article = 'an'
- elif word in consonant_vowels:
- article = 'a'
- else:
- article = 'a'
- return article
- def pronoun(char):
- if not char.attributes.has('figure'):
- possessive = 'its'
- singular_subject = 'it'
- singular_object = 'it'
- elif char.db.figure['gender'] == 'male':
- possessive = 'his'
- singular_subject = 'he'
- singular_object = 'him'
- elif char.db.figure['gender'] == 'female':
- possessive = 'hers'
- singular_subject = 'she'
- singular_object = 'her'
- return possessive, singular_subject, singular_object
- # COMBAT HANDLER MODULE (NOT NEEDED REALLY, BUT JUST IN CASE)
- from evennia import utils
- from world import skillsets
- from world import build_skill_str
- import time
- import random
- class CombatHandler:
- def __init__(self, owner):
- self.owner = owner
- def approach(self, attacker, target):
- a_app = attacker.attributes.get('approached')
- t_app = target.attributes.get('approached')
- a_name = attacker.key
- t_name = target.key
- if target in a_app:
- attacker.msg(f"You are already approached to {t_name}!")
- return
- if len(a_app) >= 1:
- attacker.msg(f"You are already approached to {a_app}!")
- target.msg(f"{a_name} attempts to approach you, but fails.")
- return
- if len(t_app) >= 3:
- attacker.msg(f"{t_app} are already approached to that target!")
- return
- a_app.append(target)
- t_app.append(attacker)
- attacker.msg(f"You approach {t_name}.")
- target.msg(f"{a_name} approaches you.")
- return
- def retreat(self, attacker):
- a_app = attacker.attributes.get('approached')
- a_name = attacker.key
- if len(a_app) == 0:
- attacker.msg(f"You are not approached to anything.")
- return
- for t in a_app:
- t.db.approached.remove(attacker)
- t.msg(f"{a_name} retreats from you.")
- attacker.msg(f"You retreat.")
- a_app.clear()
- def success_calc(self, target, skillset, skill):
- a_skillset = self.owner.attributes.get(skillset)
- a_skill = a_skillset.get(skill)
- a_rb = a_skill.get('rb')
- t_rb = 0
- if a_rb > t_rb:
- bonus = a_rb - t_rb
- success = 50 - bonus
- elif t_rb > a_rb:
- loss = t_rb - a_rb
- success = 50 + loss
- else:
- success = 50
- return success
- def attack(self, target, damage_type, skillset, skill):
- attacker = self.owner
- if self.owner.db.ko == True:
- self.owner.msg("You can't do that while unconscious!")
- return
- damage = 20
- # Create cooldown attribute if non-existent.
- if not self.owner.attributes.has('attack_cd'):
- self.owner.db.attack_cd = 0
- # Calculate current time, total cooldown, and remaining time.
- now = time.time()
- lastcast = self.owner.attributes.get('attack_cd')
- cooldown = lastcast + 3
- time_remaining = cooldown - now
- # Inform the attacker that they are in cooldown and exit the function.
- if time_remaining > 0:
- if time_remaining >= 2:
- message = f"You need to wait {int(time_remaining)} more seconds."
- elif time_remaining >= 1 and time_remaining < 2:
- message = f"You need to wait {int(time_remaining)} more second."
- elif time_remaining < 1:
- message = f"You are in the middle of something."
- self.owner.msg(message)
- return
- roll = random.randint(1, 100)
- success = self.success_calc(target, skillset, skill)
- # Make sure that the success is never below 5 or above 95 and always 5 if the target is unconscious.
- if success < 5 or target.db.ko == True:
- success = 5
- elif success > 95:
- success = 95
- #temp values
- damage_tier = 0
- body_part = 'head'
- # a_desc, t_desc = build_skill_str.create_attack_desc(self.owner, target, damage_type, damage_tier, body_part)
- # outcome = a_desc
- # weapon = 'quarterstave'
- if roll > success:
- hit = True
- # create_attack_desc(attacker, target, skillset, skill, damage_type, damage_tier, body_part, hit)
- attacker_desc, target_desc, others_desc = build_skill_str.create_attack_desc(attacker, target, skillset, skill, damage_type, damage_tier, body_part, hit)
- self.owner.msg(f"|430[Success: {success} Roll: {roll}] {attacker_desc}|n")
- target.msg(f"|r[Success: {success} Roll: {roll}] {target_desc}|n")
- self.owner.location.msg_contents(f"{others_desc}", exclude=(self.owner, target))
- self.take_damage(target, damage)
- else:
- hit = False
- # create_attack_desc(attacker, target, skillset, skill, damage_type, damage_tier, body_part, hit)
- attacker_desc, target_desc, others_desc = build_skill_str.create_attack_desc(attacker, target, skillset, skill, damage_type, damage_tier, body_part, hit)
- self.owner.msg(f"|430[Success: {success} Roll: {roll}] {attacker_desc}|n")
- target.msg(f"|r[Success: {success} Roll: {roll}] {target_desc}|n")
- self.owner.location.msg_contents(f"{others_desc}", exclude=(self.owner, target))
- utils.delay(3, self.unbusy)
- self.owner.db.attack_cd = now
- def take_damage(self, target, damage):
- t_name = target.key
- location = target.location
- targ_app = target.attributes.get('approached')
- hp = target.attributes.get('hp')
- current_hp = hp['current_hp']
- current_hp -= damage
- target.db.hp['current_hp'] = current_hp
- location.msg_contents(f'{t_name} has {current_hp} health remaining!')
- if current_hp >= 1:
- target.db.ko = False
- elif current_hp <= 0 and target.db.ko != True:
- target.db.ko = True
- location.msg_contents(f'{t_name} falls unconscious!')
- if current_hp <= -100:
- # Check for
- for a in targ_app:
- ap_list = a.attributes.get('approached')
- ap_list.remove(target)
- if not target.has_account:
- okay = target.delete()
- if not okay:
- location.msg_contents(f'\nERROR: {t_name} not deleted, probably because delete() returned False.')
- else:
- location.msg_contents(f'{t_name} breathes a final breath and expires.')
- else:
- target.db.hp['current_hp'] = target.db.hp['max_hp']
- location.msg_contents(f"{t_name} dies and is resurrected to max HP.", exclude=target)
- target.msg("You die and are resurrected to full HP.")
- target.db.ko = False
- def unbusy(self):
- self.owner.msg('|yYou are no longer busy.|n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement