Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Thu Jun 08, 2006 10:20 pm   

Discworld - Relational Directions
 
Discworld uses mostly cardinal direction for movement however there are several areas (most notable the Unseen University library). This code will automatically send the appropriate relational direction in these rooms after the rooms are flagged with "RelationalDirections" (User defined string on the Other tab of the room properties) which works well if there are only a few rooms (player houses). If you have an entire zone with rooms that you want to use relational directions in then right click the zones name within the mapper and add "#var TravelMode {Relational}" in the Always Active: window of the Zone script.

Once the modifications to your map (as mentioned above) have been made it is very simple to navigate these relational direction rooms. Simply disregard the obvious exits given by the mud and use your zMud map as a guide. eg: Numpad 8 will always move you north on the zMud map sending the appropriate relational direction to the mud, Numpad 4 will always move you west on the zMud map sending the appropriate relational direction to the mud, etc.
Code:
#CLASS {Movement}
#TRIGGER {RoomExit} {#VARIABLE CurrentOrientation {@PendingOrientation}
     #IF (%roomflags( )="RelationalDirections" OR @TravelMode="Relational") {#MAP %pop( CardinalDirection)}} "" {mxp}
#CLASS 0
#CLASS {Movement|Orientation}
#ALIAS Orientation {;Processing if input was "turn"
     #IF (@FWOninput="turn") {#VARIABLE PendingDirection {@SWOninput @TWOninput}
          #IF (%ismember( %eval( @PendingDirection), %eval( @TurnDirections))) {#VARIABLE TempOrientation %eval( %ismember( %eval( @PendingDirection), %eval( @TurnDirections)) + %ismember( %eval( @CurrentOrientation), %eval( @ShortDirections)) - 5)
               #IF (@TempOrientation>8) {#ADD TempOrientation {-8}} {}
               #IF (@TempOrientation<1) {#ADD TempOrientation {8}} {}
               #VARIABLE TempOrientation %item( @ShortDirections, @TempOrientation)
               #VARIABLE CurrentOrientation {@TempOrientation}
               :1:#SAY @FWOninput @SWOninput @TWOninput
               #SEND {@FWOninput @SWOninput @TWOninput}} {#VARIABLE PendingDirection {%null}
               :1:#SAY %ansi( bold, red)Invalid turn command!%ansi( default)}} {#VARIABLE PendingDirection {@FWOninput}}
;Converting long cardinal directions to short if necessary
     #IF (%ismember( @PendingDirection, @Directions)) {#VARIABLE CardinalDirection { %item( @ShortDirections, %ismember( @PendingDirection, @Directions))}} {#IF (%ismember( @PendingDirection, @ShortDirections)) {#VARIABLE CardinalDirection {@PendingDirection}} {#VARIABLE CardinalDirection {%null}}}
;Converting long relational directions to short if necessary
     #IF (%ismember( @PendingDirection, @RelationalDirections)) {#VARIABLE RelationalDirection { %item( @ShortRelationalDirections, %ismember( @PendingDirection, @RelationalDirections))}} {#IF (%ismember( @PendingDirection, @ShortRelationalDirections)) {#VARIABLE RelationalDirection {@PendingDirection}} {#VARIABLE RelationalDirection {%null}}}
;Processing if input was a cardinal direction
     #IF (%ismember( @CardinalDirection, @ShortDirections)) {#VARIABLE TempOrientation %eval( %ismember( %eval( @CardinalDirection), %eval( @ShortDirections)) - %ismember( %eval( @CurrentOrientation), %eval( @ShortDirections)) - 3)
          #IF (%eval( @TempOrientation)<1) {#ADD TempOrientation {8}} {}
          #IF (%eval( @TempOrientation)<1) {#ADD TempOrientation {8}} {}
          #IF (%eval( @TempOrientation)>8) {#ADD TempOrientation {-8}} {}
          #VARIABLE RelationalDirection {%item( @ShortRelationalDirections, @TempOrientation)}
          #VARIABLE PendingOrientation {@CardinalDirection}} {;Processing if input was a relational direction.
          #IF (%ismember( @RelationalDirection, @ShortRelationalDirections)) {#VARIABLE TempOrientation %eval( %ismember( %eval( @RelationalDirection), %eval( @ShortRelationalDirections)) + %ismember( %eval( @CurrentOrientation), %eval( @ShortDirections)) - 5)
               #IF (@TempOrientation>8) {#ADD TempOrientation {-8}} {}
               #IF (@TempOrientation<1) {#ADD TempOrientation {8}} {}
               #VARIABLE CardinalDirection {%item( @ShortDirections, @TempOrientation)}
               #VARIABLE PendingOrientation {@CardinalDirection}} {}}
     #IF (%roomflags( )="RelationalDirections" OR @TravelMode="Relational") {:1:#SAY @RelationalDirection
          #SEND {@RelationalDirection}} {:1:#SAY @CardinalDirection
          #SEND {@CardinalDirection}}}
#VARIABLE CurrentOrientation {w}
#VARIABLE PendingOrientation {w}
#VARIABLE TempOrientation {3}
#VARIABLE PendingDirection {w}
#VARIABLE RelationalDirection {lt}
#VARIABLE CardinalDirection {}
#STATUS {Orientation: %proper( %item( @Directions, %ismember( @CurrentOrientation, @ShortDirections))) Pending Orientation: %proper( %item( @Directions, %ismember( @PendingOrientation, @ShortDirections)))} "" "Orientation"
#CLASS 0
#CLASS {Movement|Orientation|ReferenceVariables}
#VARIABLE Directions {north|northeast|east|southeast|south|southwest|west|northwest}
#VARIABLE ShortDirections {n|ne|e|se|s|sw|w|nw}
#VARIABLE RelationalDirections {backward|backward-left|left|forward-left|forward|forward-right|right|backward-left}
#VARIABLE ShortRelationalDirections {bw|bl|lt|fl|fw|fr|rt|br}
#VARIABLE TurnDirections {around|UNUSED 1|left|half left|UNUSED 2|half right|right|UNUSED 3}
#CLASS 0
#CLASS {Movement|Oninput}
#VARIABLE Oninput {w}
#VARIABLE FWOninput {w}
#VARIABLE SWOninput {}
#VARIABLE TWOninput {}
#ONINPUT {^(*)} {#VARIABLE Oninput {%1}
     #VARIABLE FWOninput {%word( @Oninput, 1, " ")}
     #VARIABLE SWOninput {%word( @Oninput, 2, " ")}
     #VARIABLE TWOninput {%word( @Oninput, 3, " ")}
     #IF (%roomflags( )="RelationalDirections" OR @TravelMode="Relational") {#IF (%ismember( @FWOninput, @Directions) OR %ismember( @FWOninput, @ShortDirections) OR %ismember( @FWOninput, @RelationalDirections) OR %ismember( @FWOninput, @ShortRelationalDirections) OR @FWOninput="turn") {#GAG
          Orientation} {#VARIABLE PendingDirection {%null}}}} "" {notrig}
#CLASS 0

The only thing I am not happy with about this script is I can find no way to add the cardinal direction to the mapper queue without it causing zMud to go into an endless loop therefore I have had to kludge movement onto the MXP trigger for RoomExit (ironicaly this trigger seems to always work on Discworld as long as your term is NOT set to MXP).

Needless to say that this script has not been designed to be used whilst speedwalking as it relies upon movement confirmation to reset the appropriate orientation of the character, therefore step one room at a time and keep an eye out for those distortions.

Credit where credit is due: this script was inspired by this thread written by itsr0y

Edited to add code which prevented normal movement when not in rooms with relational exits.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net