Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''The error.'''
- '''
- Traceback (most recent call last):
- File "d:\muddev\evennia\evennia\commands\cmdhandler.py", line 591, in _run_command
- ret = cmd.func()
- File ".\commands\combat.py", line 28, in func
- self.caller.db.combat_handler.attack(target)
- AttributeError: 'NoneType' object has no attribute 'attack'
- An untrapped error occurred.
- (Traceback was logged 19-08-04 10:34:32-04).
- '''
- '''The player's script creation.'''
- class Player_Character(DefaultCharacter):
- def at_object_creation(self):
- self.scripts.add(CombatHandler)
- '''The attacking command within commands\combat.py'''
- class CmdStaveBash(BaseCommand):
- '''
- Use your staff to bash an enemy.
- Usage:
- bash <target>
- '''
- key = 'bash'
- help_category = 'combat'
- def func(self):
- if not self.args:
- self.caller.msg('Usage: bash <target>')
- return
- target = self.caller.search(self.args)
- if not target:
- self.caller.msg('That target does not exist!')
- return
- if not target.attributes.has('hp'):
- self.caller.msg('You cannot attack that target!')
- return
- self.caller.db.combat_handler.attack(target) # LINE 28
- '''The combat handler script'''
- class CombatHandler(DefaultScript):
- key = 'combat_handler'
- def attack(self, target):
- damage = 20
- now = time.time()
- lastcast = self.db.stave_bash
- cooldown = lastcast + 3
- time_remaining = cooldown - now
- 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.obj.msg(message)
- return
- # roll = random.randint(1, 100)
- # success = random.randint(5, 95)
- roll = 100
- success = 0
- if roll > success:
- self.obj.msg(f'[Success: {success} Roll: {roll}] You bash {target} with your stave!')
- self.take_damage(target, damage)
- else:
- self.obj.msg(f'[Success: {success} Roll: {roll}] You miss {target} with your stave!')
- utils.delay(3, self.unbusy)
- self.db.stave_bash = now
- def take_damage(self, target, damage):
- mob = target.key
- location = target.location
- target.db.hp -= damage
- hp = target.db.hp
- location.msg_contents(f'{mob} has {hp} health remaining!')
- if hp >= 1:
- target.db.ko = False
- elif hp <= 0 and self.db.ko != True:
- target.db.ko = True
- location.msg_contents(f'{mob} falls unconscious!')
- if hp <= -100:
- okay = target.delete()
- if not okay:
- location.msg_contents(f'\nERROR: {mob} not deleted, probably because delete() returned False.')
- else:
- location.msg_contents(f'{mob} breathes a final breath and expires.')
- return
- def unbusy(self):
- self.obj.msg('|yYou are no longer busy.|n')
- '''Puppeted character's examine'''
- '''
- ------------------------------------------------------------------------------
- Name/key: Bobby (#25)
- Aliases: a bobby(#25),one bobby(#25)s
- Session id(s): #4
- Account: Kovitikus
- Account Perms: <Superuser>
- Typeclass: Player_Character (typeclasses.characters.Player_Character)
- Location: Hoff's Bar (#7)
- Home: Limbo (#2)
- Permissions: <None> [Superuser]
- Locks: call:false(); control:perm(Developer); delete:perm(Admin);
- edit:perm(Admin); examine:perm(Builder); get:false();
- puppet:pperm(Developer); tell:perm(Admin); view:all()
- Stored Cmdset(s):
- commands.default_cmdsets.CharacterCmdSet [DefaultCharacter] (Union, prio 0)
- Merged Cmdset(s):
- evennia.commands.cmdset.CmdSet [ChannelCmdSet] (Union, prio 101)
- commands.default_cmdsets.CharacterCmdSet [DefaultCharacter] (Union, prio 0)
- commands.default_cmdsets.AccountCmdSet [DefaultAccount] (Union, prio -10)
- commands.default_cmdsets.SessionCmdSet [DefaultSession] (Union, prio -20)
- Commands available to Bobby (result of Merged CmdSets):
- about, access, accounts, addcom, alias, allcom, ban, bash, batchcode,
- batchcommands, boot, cboot, ccreate, cdesc, cdestroy, cemit, channels,
- charcreate, chardelete, chargen, clock, cmdsets, color, copy, cpattr,
- create, cwho, delcom, desc, destroy, dig, drop, emit, examine, find, force,
- get, give, grapevine2chan, help, home, ic, inventory, irc2chan, ircstatus,
- link, lock, look, mudinfo, mvattr, name, nick, objects, open, option, page,
- password, perm, pose, public, py, quell, quit, reload, reset, rss2chan, say,
- script, scripts, server, service, sessions, set, setdesc, sethelp, sethome,
- shutdown, south, spawn, style, tag, tel, tickers, time, tunnel, typeclass,
- unban, unlink, userpassword, wall, whisper, who, wipe
- Scripts:
- 'combat_handler' (inf/inf, inf repeats):
- Persistent attributes:
- figure = {'gender': 'male', 'height': 'very tall', 'build': 'ample'}
- facial = {'face': 'freckled', 'eye_color': 'light grey', 'nose': 'hooked', 'lips':[...]
- hair = {'hair_color': None, 'texture': None, 'length': 'bald', 'style': None}
- prelogout_location = Hoff's Bar
- ------------------------------------------------------------------------------
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement