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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ponfyr
Beginner


Joined: 15 Feb 2003
Posts: 14
Location: USA

PostPosted: Mon May 19, 2003 10:44 pm   

Aborting Speedwalk
 
Let say you have given a room the short name of ‘guild’ in the properties of that room in the map screen. And your player is somewhere distant. If You type ‘#walk guild’ everything works as expected except if someone has lets say erected a wall of fire and you earnestly wanted to avoid getting char broiled. Could a trigger be written that either aborted the speedwalk upon detecting the wall of fire is blocking next exit or marking that direction unusable or raising the cost to max and then searching for an alternate route.

Room with Wall of Fire looks like this:

Elfin Forest: Among the many trees

The trees in this part of the forest are tall and majestic and their trunks are light shades of silver and brown and very smooth to the touch. There is the fresh smell of wild flowers in the air. Some brown speckled birds are singing softly in the branches overhead. There seems to be a small clearing in the trees to the south.


Reasonably hot day in The Season of Magic with very thin complete cloud cover.

There are five obvious exits : west, east, southeast, south and southwest.
Wall of fire blocking the east exit.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue May 20, 2003 12:51 am   
 
If the blocked-exit is actual mud-output, you might try looking at the %room() functions to see if you can set the do-not-enter flag or otherwise redirect the walk. If not, or you can't do it early enough, you probably will have to pause the walk and #step around the wall.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue May 20, 2003 4:08 am   
 
The first step to doing this is to use slow-walking mode.

Next to start scripting it you have to override when the mapper sends the next movement command. This done by triggering on the last consistent line after a movement. Usually that is your prompt. Since you don't show one I will assume you don't have one and instead trigger off the exits line. However this is much harder because what we want to find out comes after and might not be there.

Then you have to check the next direction againt your detected walls. Once checked you may either step or recompute the path. This is where you run into a slight problem, there is no function to tell the script the destination. To get around this problem you must change your habit and use an alias that stores the destination.

So heres your script:
#CLASS {WallDetector}
#ALIAS walk {#IF (%1) {WalkDest=%roomnum(%1);#IF (@WalkDest) {#WALK @WalkDest} { #ECHO Unknown vnum or short}} { #ECHO Usage: walk destination}}
#VAR Walls {} {}
#VAR WalkDest {}
#VAR AdjustedRooms {}
#TRIGGER "ExitLine" {^There {are|is} %w obvious exit{s|} : *.$} {#STATE CaptureWalls 0;#SET CaptureWalls 0 1}
#COND {} {#IF (%begins(%line,"Wall of fire blocking the")) { #ADDITEM Walls %word(%line,6)} {#STATE CaptureWalls 2;#SET CaptureWalls 2 1}} {looplines|param=99}
#TRIGGER "CaptureWalls" {^^$Impossible pattern} {Walls=""} "" {manual}
#COND {*1} {#IF (%begins(%line,"Wall of fire blocking the")) { #ADDITEM Walls %word(%line,6)} { #SET CaptureWalls 2 1}} {alarm}
#COND {} {#STATE ExitLine 0;#IF (@WasWalking) { #IF (@Walls) { #IF (%ismember(%nextdir,@Walls)) {#ADDKEY AdjustedRooms %roomlink(,%nextdir) %roomcost(%roomlink(,%nextdir));#NOOP %roomcost(%roomlink(,%nextdir),300000);#ECHOP "Wall encountered, walk route ";#IF (@WalkDest) {#ECHO automatically adjusted.;#WALK @WalkDest} { #ECHO aborted, destination was unknown}}} {#SET CaptureWalls 2 0;#STATE CaptureWalls 0;#STEP}} {#SET CaptureWalls 2 0;#STATE CaptureWalls 0}} {manual}
#CLASS 0

And to make it thoroughly integrate with the mapper remeber to set the walking mode to slow, and just a few more lines:
#AL ./System/onwalkend {WalkDest=""}
#AL ./System/onroomenter {#IF (%inwalk) {WasWalking=1;#STOP} {WasWalking=0};#LOOPDB @AdjustedRooms {#NOOP %roomcost(%key,%val)}}
#VAR ./System/WasWalking 0
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion 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