From ddddfe4b7b9543403b2c143cd341010e0bdd27c0 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Sat, 26 Apr 2025 09:32:14 -0700 Subject: [PATCH] Magically create sticks for throwing to the BHB --- typeclasses/objects.py | 2 + typeclasses/scripts.py | 32 ++++++-- typeclasses/tutorial.py | 2 +- world/version1.ev | 157 +++++++++++++++++++++++++++++++--------- 4 files changed, 154 insertions(+), 39 deletions(-) diff --git a/typeclasses/objects.py b/typeclasses/objects.py index 83b9261..8edbff2 100755 --- a/typeclasses/objects.py +++ b/typeclasses/objects.py @@ -8,6 +8,7 @@ Use the ObjectParent class to implement common features for *all* entities with a location in the game world (like Characters, Rooms, Exits). """ +# from evennia.objects.objects import DefaultObject from evennia.contrib.rpg.rpsystem.rpsystem import ContribRPObject from evennia.utils import delay # from evennia.utils import delay, logger, search @@ -27,6 +28,7 @@ class ObjectParent: return "\n" +# class Object(ObjectParent, DefaultObject): class Object(ObjectParent, ContribRPObject): """ This is the root Object typeclass, representing all entities that diff --git a/typeclasses/scripts.py b/typeclasses/scripts.py index 6d74ba1..da64177 100644 --- a/typeclasses/scripts.py +++ b/typeclasses/scripts.py @@ -11,10 +11,11 @@ Rather, each script tends to inherit from the base Script class and just overloads its hooks to have it perform its function. """ -from evennia.scripts.scripts import DefaultScript -from evennia.utils import logger +from enum import Enum -from typeclasses.characters import Character +from evennia.scripts.scripts import DefaultScript +from evennia.prototypes.spawner import spawn +from evennia.utils import logger class Script(DefaultScript): @@ -107,7 +108,7 @@ class KnockScript(Script): """ A script to wake the dead. """ - def at_start(self): + def at_start(self, **kwargs): knocker = self.attributes.get("knocker") if knocker: room = knocker.global_search(self.attributes.get("room")) @@ -118,8 +119,29 @@ class KnockScript(Script): if god: god.msg(f"With your seer stone, you see the knocker is {knocker.key}.") - def at_repeat(self): + def at_repeat(self, **kwargs): waker = self.attributes.get("waker") if waker: waker.knocked_timed_out() self.stop() + + +class CreateSticks(Script): + """ + Script to create sticks. + """ + def at_repeat(self, **kwargs): + woods = self.attributes.get("destination") + results = woods.search('stick') + if results and len(results) > 0 and results[0].location == woods: + pass + else: + stick = spawn({ + "typeclass": "typeclasses.things.Stick", + "key": "stick", + "desc": """Its brown and sticky. + +Well, by sticky, we mean, wizardly-sticky...an absolutely amazing looking stick...definitely a wizardly stick.""", + })[0] + stick.location = woods + diff --git a/typeclasses/tutorial.py b/typeclasses/tutorial.py index 0ab1a46..02ea708 100755 --- a/typeclasses/tutorial.py +++ b/typeclasses/tutorial.py @@ -32,7 +32,7 @@ MSGS = { "\"You can also |glook trees|n, |glook moss|n, or … well, you get the idea,\" it says.", ], "LOOKAT": [ - "\"You seem to be getting the hang of this game,\" chirps the bird. \"When you typed |glook|n before, you noticed exits. These are directions or places you can go. For instance, if you type |gsouth|n (or just |gs|n as a shortcut), you can check out our pond where you can catch obnoxious fish.\"", + "\"You seem to be getting the hang of this game,\" chirps the bird. \"When you typed |glook|n before, you noticed exits. These are directions or places you can go. For instance, if you type |gsouth|n (or just |gs|n as a shortcut), you can check out the sea where you can catch obnoxious fish.\"", "\"The path to the |geast|n is the meadow of the BHB, the Big Hairy Beast,\" the little bird on your shoulder says. \"It's adorable if you can find it. The path to the |gwest|n leads to Dabbler's place.\"", "\"Yes, I could fly myself,\" warbles the little bird, \"but I'm trying to help you get around.\"", "The bird looks at you expectantly.", diff --git a/world/version1.ev b/world/version1.ev index c527427..8f88182 100644 --- a/world/version1.ev +++ b/world/version1.ev @@ -124,7 +124,7 @@ nick meadow = ^fly Frog Meadow # [[file:../../../projects/mud.org::*The Forest][The Forest:2]] -@desc here = A giant, moss-covered boulder stands among immense trees that etch the sky and slice the clouds in the darkening twilightawakening dawnlazy afternoonnight sky. Since it is morning, you can hear the dawn chorus of birdsafternoon, you can hear the buzzing of insects around giant colorful flowersevening, you can hear much as most of the forest creatures are settling down for the nightnight, you can hear crickets and an occassional owl. A footpath winds around the giant, moss-covered tree roots to the East and West. To the south, a dock lounges on a large pond. +@desc here = A giant, moss-covered boulder stands among immense trees that etch the sky and slice the clouds in the darkening twilightawakening dawnlazy afternoonnight sky. As morning, you can hear the dawn chorus of birdsafternoon, you can hear the buzzing of insects around giant colorful flowersevening, you can't hear much as most of the forest creatures are settling down for the nightnight, you can hear crickets and an occassional owl. A footpath winds around the giant, moss-covered tree roots to the East and West. To the south, a dock juts into a lavender sea. # The Forest:2 ends here @@ -167,7 +167,7 @@ nick meadow = ^fly Frog Meadow # [[file:../../../projects/mud.org::*Puddles][Puddles:2]] -@desc puddle = A large puddle formed from a recent rainshower, invites you to shed your years and jump in and splash around to reconnect with your youth. +@desc puddle = A large puddle, formed from a recent rain shower, invites you to shed your years and jump in and splash around to reconnect with your youth. # Puddles:2 ends here @@ -186,22 +186,14 @@ nick meadow = ^fly Frog Meadow # [[file:../../../projects/mud.org::*Sticks][Sticks:1]] -@create/drop stick : typeclasses.things.Stick +py timed_script = evennia.create_script(key="Create Sticks", + typeclass='typeclasses.scripts.CreateSticks', + interval=86800, # more than a day + start_delay=False, # wait interval before first call + autostart=True, + attributes=[("destination", here)] ) # Sticks:1 ends here - - -# And the description … perhaps this could change for every stick? - - -# [[file:../../../projects/mud.org::*Sticks][Sticks:2]] -@desc stick = Its brown and sticky. - -Well, by sticky, we mean, stick-like. - -Maybe, by sticky, we mean, wizardly-sticky...an absolutely amazing looking stick...definitely a wizardly stick. -# Sticks:2 ends here - # Boulder # More details about the room that describes aspects of the boulder in the =desc= above. First, the symbol: @@ -393,7 +385,7 @@ Wait! You notice a foot hold, and then another. You can |gclimb|n this boulder! # [[file:../../../projects/mud.org::*Field][Field:6]] -@desc here = A large waterfall cascades on the far side of this meadow creating a stream that meanders through the tall grass and large yellow flowers. They nod their heads to you as you pass by in the darkening twilightawakening dawnlazy afternoonnight sky. A gap in the trees show how you can return to the footpath in the forest. +@desc here = A large waterfall cascades on the far side of this meadow creating a stream that meanders through the tall grass and large yellow flowers. They nod their sleepy heads to you as you pass by in the darkening twilightawakening dawnlazy afternoondark night. A gap in the trees show how you can return to the footpath in the forest. # Field:6 ends here @@ -427,7 +419,7 @@ Wait! You notice a foot hold, and then another. You can |gclimb|n this boulder! # [[file:../../../projects/mud.org::*Field][Field:10]] -@detail frog;frogs = Cute little guys with their big black eyes. Too quick to catch. +@detail frog;frogs = Cute little guys with their big black eyes and tiny gold crowns. Too quick to catch. # Field:10 ends here # Waterfall @@ -457,6 +449,10 @@ Wait! Is there a large cave entrance hidden behind the water? @set waterfall/hidden_tag = "hidden_cave" # Waterfall:3 ends here +# [[file:../../../projects/mud.org::*Waterfall][Waterfall:4]] +@detail pool = A pool of cool, clear water. +# Waterfall:4 ends here + # The Lair of the Beast # To create a place for our big, hairy beast to sleep, first jump to the Meadow: @@ -742,16 +738,13 @@ Nope. Too tall, and just as well. It does not smell very good. # @set beast/pet_interested_response = "It keeps its distance, but seems curious about ." # -@set beast/pet_friendly_response = " - pet the << big, hairy ^ >> beast. -" +@set beast/pet_friendly_response = "The << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> << flops ^ rolls >> over << in the grass ^>> as <(you ^ {0} )> <( give ^ gives )> it belly rubs.. ;; The << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> << flops ^ rolls >> over << in the grass ^>> as <(you ^ {0} )> <( rub ^ rubs )> its belly.. ;; <(You ^ {0} )> <( pet ^ pets )> the << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> .. ;; <(You ^ {0} )> <( scratch ^ scratches )> the << nose ^ ears >> of the << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> .. ;; The << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> leans forward as <(you ^ {0} )> <( scratch ^ scratches )> its nose.." # -@set beast/pet_scared_response = " -" +@set beast/pet_ecstatic_response = "While << excited ^ ecstatic ^ squirmy >>, the << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> << lays ^ gets >> down so you can << pet ^ scratch >> << the top of its head ^ the back of its neck ^ its nose ^ the sides of its face >>. It closes its eyes and purrs.. ;; << The squirmy little devil. ^ >> <( You ^ {0} )> << can ^ >> << barely ^ hardly >> scratch the << nose ^ ears ^ neck ^ top of the head >> of the << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> as it << squirms around ^ wriggles it backend >>. It << can hardly ^ can't >> contain its excitement. ;; The << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> wriggles around before << flopping ^ rolling >> over << in the grass ^>> as <(you ^ {0} )> <( give ^ gives )> it belly rubs. ;; The << big, ^ huge, ^ large, ^ tremendous, ^ >> << hairy ^ slobbery ^ horned ^ clawed ^ >> << brute ^ beast ^ monster>> wriggles and squirms excitedly before it << flops ^ rolls >> over << in the grass ^>> as <(you ^ {0} )> <( rub ^ rubs )> its belly." # Beast:21 ends here # The Dock -# The dock leads out into the large pond. The break in the trees lets you see the sky. Looks like a nice place to relax. +# The dock leads out into a strange sea. The break in the trees lets you see the sky. Looks like a nice place to relax. # Return to the Forest: @@ -760,13 +753,15 @@ Nope. Too tall, and just as well. It does not smell very good. # The Dock:1 ends here -# And tunnel to the pond: + +# And tunnel to the dock: # [[file:../../../projects/mud.org::*The Dock][The Dock:2]] @dig Lazy Dock;mp06 :typeclasses.rooms_weather.TimeWeatherRoom = south;s,north,n,footpath # The Dock:2 ends here + # With a mesage about leaving the trees so that I don’t have to repeat that in the room description: # [[file:../../../projects/mud.org::*The Dock][The Dock:3]] @@ -777,7 +772,7 @@ Nope. Too tall, and just as well. It does not smell very good. # And a description: # [[file:../../../projects/mud.org::*The Dock][The Dock:4]] -@desc south = You see a dock on a large pond... Is that a comfortable-looking chair you can |gsit|n on? +@desc south = You see a dock on a lavender sea... Is that a comfortable-looking chair you can |gsit|n on? # The Dock:4 ends here @@ -793,15 +788,21 @@ Nope. Too tall, and just as well. It does not smell very good. # And describe this. # [[file:../../../projects/mud.org::*The Dock][The Dock:6]] -@desc here = The dock you stand on juts into an immense pond. Someone has set a nice chair for viewing. +@desc here = The dock you stand on juts into a bay of water the color of lavender flowers. Mesmorizing and calming the way the sound of the waves lap along the shore. +Someone has set a nice chair for viewing. # The Dock:6 ends here -# Since we use the =tunnel= command, we need to update the weather system: +# And details? + # [[file:../../../projects/mud.org::*The Dock][The Dock:7]] -@update here = typeclasses.rooms_weather.TimeWeatherRoom +@detail water;waves = Despite the inclement weather, the waves ripple softly against the shore. Seems nice for fishing. +# +@detail lavender;flowers;flower = The water is the |wcolor|n of lavender, not actually lavender. Hrm. Could it possibly be |wlavender tea|n? +# +@detail shore = The roots of trees make most of the bay's shoreline. # The Dock:7 ends here @@ -813,6 +814,7 @@ Nope. Too tall, and just as well. It does not smell very good. # The Dock:8 ends here + # And a description: # [[file:../../../projects/mud.org::*The Dock][The Dock:9]] @@ -879,10 +881,6 @@ Looks good for being out in the weather. # [[file:../../../projects/mud.org::*Fishing Pole][Fishing Pole:4]] @detail hook;bait = One of those shiny lures, made from gold coins. Curiouser. Seems you don't need to bait this hook. -# -@detail water;waves = Despite the weather, the water looks nice...well, nice for fishing. -# -# @detail dock = Sturdy and well made. Bobs a little with the waves. # Fishing Pole:4 ends here @@ -920,6 +918,99 @@ Looks good for being out in the weather. @set sign/get_err_msg = "This granny knot holding the sign to the chair is serious. You can't take it." # Fishing Pole:8 ends here +# The Boat + +# A boat on the sea is a separate room. + + +# [[file:../../../projects/mud.org::*The Boat][The Boat:1]] +@dig/teleport Leaf Boat;mp08:typeclasses.rooms_weather.TimeWeatherRoom +# The Boat:1 ends here + + + +# And describe sailing on it.: + + +# [[file:../../../projects/mud.org::*The Boat][The Boat:2]] +@desc here = The lavender sea is tranquil as the giant leaf floats along an invisible current. +The morning sun peaks above the collosal trees and the snowcapped mountains beyond. +The afternoon sun peaks out briefly from misty clouds. +The evening sun begins to set on a watery horizon. +The moon peaks out from behind wispy clouds. +# The Boat:2 ends here + +# The Island +# The boat should land on a distant island. + + +# [[file:../../../projects/mud.org::*The Island][The Island:1]] +@dig/teleport Lonely Island;mp09:typeclasses.rooms_weather.TimeWeatherRoom +# The Island:1 ends here + + + +# And describe it: + + +# [[file:../../../projects/mud.org::*The Island][The Island:2]] +@teleport mp09 +# +@desc here = Vibrant green moss covers the island's gray rock. Wandering around the conifers you encounter giant statues of armored knights surrounding a huge, empty throne. An inscription at the base reads, ᚦ ᚮ ᚱ +# The Island:2 ends here + +# Connecting +# Create an exit for getting /into/ the boat: + + +# [[file:../../../projects/mud.org::*Connecting][Connecting:1]] +@teleport mp06 +# +@open leaf-like boat;leaf boat;boat;leaf = mp08 +# Connecting:1 ends here + + + +# And describe the boat first: + + +# [[file:../../../projects/mud.org::*Connecting][Connecting:2]] +@desc boat = A giant leaf, tipped on all sides look like it could be a boat. Doesn't seem to be an oar, or even a rudder, but... +# Connecting:2 ends here + +# [[file:../../../projects/mud.org::*Connecting][Connecting:3]] +@set boat/traverse_msg = "You step into the large leaf shaped like a boat, and push off from the shore into the sea..." +# Connecting:3 ends here + + + +# Now jump into the boat, + + +# [[file:../../../projects/mud.org::*Connecting][Connecting:4]] +@teleport mp08 +# +@open shore;island;dock = mp09 +# Connecting:4 ends here + + + +# And exiting the boat: + + +# [[file:../../../projects/mud.org::*Connecting][Connecting:5]] +@set shore/traverse_msg = "When the boat stops, you step off..." +# Connecting:5 ends here + + + +# Are they going to look before getting off? + + +# [[file:../../../projects/mud.org::*Connecting][Connecting:6]] +@desc shore = You seem to have arrived at some island. +# Connecting:6 ends here + # Forest Path # Return to the forest: