mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Re-implemented a modern version of the Tutorial mob. Removed the tutorial scripts completely.
This commit is contained in:
parent
32fd9d2a4d
commit
be482c31e7
4 changed files with 706 additions and 458 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -89,6 +89,19 @@ class TutorialRoom(DefaultRoom):
|
|||
self.db.tutorial_info = "This is a tutorial room. It allows you to use the 'tutorial' command."
|
||||
self.cmdset.add_default(TutorialRoomCmdSet)
|
||||
|
||||
def at_object_receive(self, new_arrival, source_location):
|
||||
"""
|
||||
When an object enter a tutorial room we tell other objects in
|
||||
the room about it by trying to call a hook on them. The Mob object
|
||||
uses this to cheaply get notified of enemies without having
|
||||
to constantly scan for them.
|
||||
"""
|
||||
if new_arrival.has_player and not new_arrival.is_superuser:
|
||||
# this is a character
|
||||
for obj in self.content_get(exclude=new_arrival):
|
||||
if hasattr(obj, "at_new_arrival"):
|
||||
obj.at_new_arrival(new_arrival)
|
||||
|
||||
def reset(self):
|
||||
"Can be called by the tutorial runner."
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
"""
|
||||
This defines some generally useful scripts for the tutorial world.
|
||||
"""
|
||||
|
||||
import random
|
||||
from evennia import DefaultScript
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
#
|
||||
# IrregularEvent - script firing at random intervals
|
||||
#
|
||||
# This is a generally useful script for updating
|
||||
# objects at irregular intervals. This is used by as diverse
|
||||
# entities as Weather rooms and mobs.
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
|
||||
class IrregularEvent(DefaultScript):
|
||||
"""
|
||||
This script, which should be tied to a particular object upon
|
||||
instantiation, calls update_irregular on the object at random
|
||||
intervals.
|
||||
"""
|
||||
def at_script_creation(self):
|
||||
"This setups the script"
|
||||
|
||||
self.key = "update_irregular"
|
||||
self.desc = "Updates at irregular intervals"
|
||||
self.interval = random.randint(30, 70) # interval to call.
|
||||
self.start_delay = True # wait at least self.interval seconds before
|
||||
# calling at_repeat the first time
|
||||
self.persistent = True
|
||||
|
||||
# this attribute determines how likely it is the
|
||||
# 'update_irregular' method gets called on self.obj (value is
|
||||
# 0.0-1.0 with 1.0 meaning it being called every time.)
|
||||
self.db.random_chance = 0.2
|
||||
|
||||
def at_repeat(self):
|
||||
"This gets called every self.interval seconds."
|
||||
rand = random.random()
|
||||
if rand <= self.db.random_chance:
|
||||
try:
|
||||
#self.obj.msg_contents("irregular event for %s(#%i)" % (self.obj, self.obj.id))
|
||||
self.obj.update_irregular()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
class FastIrregularEvent(IrregularEvent):
|
||||
"A faster updating irregular event"
|
||||
def at_script_creation(self):
|
||||
"Called at initial script creation"
|
||||
super(FastIrregularEvent, self).at_script_creation()
|
||||
self.interval = 5 # every 5 seconds, 1/5 chance of firing
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
#
|
||||
# Tutorial world Runner - root reset timer for TutorialWorld
|
||||
#
|
||||
# This is a runner that resets the world
|
||||
#
|
||||
#------------------------------------------------------------
|
||||
|
||||
# #
|
||||
# # This sets up a reset system -- it resets the entire tutorial_world domain
|
||||
# # and all objects inheriting from it back to an initial state, MORPG style.
|
||||
# This is useful in order for different players to explore it without finding
|
||||
# # things missing.
|
||||
# #
|
||||
# # Note that this will of course allow a single player to end up with
|
||||
# # multiple versions of objects if they just wait around between resets;
|
||||
# # In a real game environment this would have to be resolved e.g.
|
||||
# # with custom versions of the 'get' command not accepting doublets.
|
||||
# #
|
||||
|
||||
# # setting up an event for reseting the world.
|
||||
|
||||
# UPDATE_INTERVAL = 60 * 10 # Measured in seconds
|
||||
|
||||
|
||||
# #This is a list of script parent objects that subscribe to the reset
|
||||
# functionality.
|
||||
# RESET_SUBSCRIBERS = ["examples.tutorial_world.p_weapon_rack",
|
||||
# "examples.tutorial_world.p_mob"]
|
||||
|
||||
# class EventResetTutorialWorld(DefaultScript):
|
||||
# """
|
||||
# This calls the reset function on all subscribed objects
|
||||
# """
|
||||
# def __init__(self):
|
||||
# super(EventResetTutorialWorld, self).__init__()
|
||||
# self.name = 'reset_tutorial_world'
|
||||
# #this you see when running @ps in game:
|
||||
# self.description = 'Reset the tutorial world .'
|
||||
# self.interval = UPDATE_INTERVAL
|
||||
# self.persistent = True
|
||||
|
||||
# def event_function(self):
|
||||
# """
|
||||
# This is called every self.interval seconds.
|
||||
# """
|
||||
# #find all objects inheriting the subscribing parents
|
||||
# for parent in RESET_SUBSCRIBERS:
|
||||
# objects = Object.objects.global_object_script_parent_search(parent)
|
||||
# for obj in objects:
|
||||
# try:
|
||||
# obj.scriptlink.reset()
|
||||
# except:
|
||||
# logger.log_errmsg(traceback.print_exc())
|
||||
|
|
@ -495,6 +495,15 @@ def superuser(*args, **kwargs):
|
|||
"""
|
||||
return False
|
||||
|
||||
def has_player(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
"""
|
||||
Only returns true if accessing_obj has_player is true, that is,
|
||||
this is a player-controlled object. T
|
||||
|
||||
This is a useful lock for traverse-locking Exits to restrain NPC
|
||||
mobiles from moving outside their areas.
|
||||
"""
|
||||
return hasattr(accessing_obj, "has_player") and accessing_obj.has_player
|
||||
|
||||
def serversetting(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue