mob_actions.py 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import random
  2. from evennia import gametime
  3. from typeclasses.objects import Object
  4. class Action(Object):
  5. def at_object_creation(self):
  6. super().at_object_creation()
  7. self.db.action_time = 0
  8. self.db.action_completion_time = 0
  9. def prepare(self, actor):
  10. #set duration of action
  11. self.db.action_completion_time = gametime.gametime() + self.db.action_time
  12. def update(self, actor):
  13. pass
  14. def complete(self, actor):
  15. pass
  16. def completion_time(self):
  17. return self.db.action_completion_time
  18. class ActionIdle(Action):
  19. def at_object_creation(self):
  20. super().at_object_creation()
  21. self.db.action_time = 10
  22. def update(self, actor):
  23. pass
  24. def complete(self, actor):
  25. roll = random.randrange(100)
  26. if roll < 10:
  27. actor.emote()
  28. #TEST
  29. actor.db.energy = 0 if actor.db.energy == 0 else actor.db.energy - 1