Start writing the twitch combat tutorial

This commit is contained in:
Griatch 2023-05-04 00:50:54 +02:00
parent 759776ff64
commit d2551aaaa7
5 changed files with 94 additions and 9 deletions

View file

@ -70,6 +70,9 @@ class EvAdventureCombatTwitchHandler(EvAdventureCombatHandlerBase):
"""
super().msg(message, combatant=self.obj, broadcast=broadcast, location=self.obj.location)
def at_init(self):
self.obj.cmdset.add(TwitchLookCmdSet, persistent=False)
def get_sides(self, combatant):
"""
Get a listing of the two 'sides' of this combat, from the perspective of the provided
@ -165,7 +168,6 @@ class EvAdventureCombatTwitchHandler(EvAdventureCombatHandlerBase):
action_dict (dict): The new action-dict to initialize.
"""
if action_dict["key"] not in self.action_classes:
self.obj.msg("This is an unkown action!")
return
@ -240,6 +242,8 @@ class EvAdventureCombatTwitchHandler(EvAdventureCombatHandlerBase):
Stop combat immediately.
"""
self.queue_action({"key": "hold", "dt": 0}) # make sure ticker is killed
del self.obj.ndb.combathandler
self.obj.cmdset.remove(TwitchLookCmdSet)
self.delete()
@ -546,8 +550,16 @@ class TwitchAttackCmdSet(CmdSet):
def at_cmdset_creation(self):
self.add(CmdAttack())
self.add(CmdLook())
self.add(CmdHold())
self.add(CmdStunt())
self.add(CmdUseItem())
self.add(CmdWield())
class TwitchLookCmdSet(CmdSet):
"""
This will be added/removed dynamically when in combat.
"""
def at_cmdset_creation(self):
self.add(CmdLook())

View file

@ -12,7 +12,7 @@ from evennia.utils.utils import make_iter
from .characters import LivingMixin
from .enums import Ability, WieldLocation
from .objects import WeaponEmptyHand
from .objects import BARE_HANDS
from .rules import dice
@ -51,7 +51,7 @@ class EvAdventureNPC(LivingMixin, DefaultCharacter):
is_idle = AttributeProperty(default=False, autocreate=False)
weapon = AttributeProperty(default=WeaponEmptyHand, autocreate=False) # instead of inventory
weapon = AttributeProperty(default=BARE_HANDS, autocreate=False) # instead of inventory
coins = AttributeProperty(default=1, autocreate=False) # coin loot
# if this npc is attacked, everyone with the same tag in the current location will also be pulled into combat.

View file

@ -355,6 +355,6 @@ class WeaponBareHands(EvAdventureWeapon):
quality = 100000 # let's assume fists are always available ...
BARE_HANDS = search_object("Bare hands", typeclass=WeaponBareHands)
BARE_HANDS = search_object("Bare hands", typeclass=WeaponBareHands).first()
if not BARE_HANDS:
BARE_HANDS = create_object(WeaponBareHands, key="Bare hands")