Mar 212009
Achaea MUD ZMud script for room mapping.
#CLASS {Triggers|Room} #ALIAS _RoomEnter { #OK ;#EXEC _Debug "_RoomEnter" ;Blank RoomObjects if there is no Objects in this new room RoomObjects = %if( %null( @sRoomObjects), "") #IF ((@Personal.Mapping or @Personal.Hunting or %eval( %bitand( %roomload, 2) = 2)) and not %null( @sRoomObjects)) { ;If mapping or Hunting or desc needs updating and there are objects then IH #EXEC _SendCommandOnPrompt "ih" } { #IF (%eval( %bitand( %roomload, 2)=2)) { ; Else if desc needs updating #IF (%null( @sRoomObjects) and %eval( %if( %null( %roomdesc), "null", %roomdesc) = {%if( %null( @sRoomDesc), "null", @sRoomDesc)})) { ; If there are no objects and the description matches the description then remove desc update #NOOP %roomload( , %bitxor( %roomload, 2)) } } #IF (%walkactive) {#ALARM {+@Mud.SlowWalkSpeed} {#STEP}} } #IF (%class( _MakeNewRoom)) {#EXEC _MakeNewRoom} } #ALIAS onroomenter { ;#EXEC _Debug {onroomenter: Starting %bitand( %roomload, 2)=2} RoomDenizenEnimies = "" ;RoomObjects = "" ;#EXEC _FormatRoomObjects #IF (@Personal.MapLastRoom <> %roomnum) { #ADDKEY Personal MapLastRoom @Personal.MapThisRoom #ADDKEY Personal MapThisRoom %roomnum } ;#IF (%match( @sExits, " in%p") and %roomlink( , in) = -2) {#ECHO Follow In Link} ;#IF (%match( @sExits, " out%p") and %roomlink( , out) = -2) {#ECHO Follow Out Link} #IF (@Personal.Mapping) { #NOOP %maplocked( 0) #IF (%bitand( %roomload, 1)=1) { #NOOP %roomname( %roomnum, @sRoomName) #NOOP %roomload( %roomnum, %bitxor( %roomload, 1)) } #IF (%bitand( %roomload, 2)=2) { #NOOP %roomdesc( %roomnum, @sRoomDesc) #NOOP %roomload( %roomnum, %bitxor( %roomload, 2)) } #IF (%bitand( %roomload, 4)=4) { #EXEC _UpdateExits #NOOP %roomload( %roomnum, %bitxor( %roomload, 4)) } #NOOP %roomflags( %roomnum, @sRoomWWH) #IF (%pos( "You see a sign here indicating there are WARES for sale here.", @sRoomWWH) > 0) {#NOOP %roomcol( ,16744703)} #IF (%pos( "You may enter the wilderness map from here.", @sRoomWWH) > 0) {#NOOP %roomcol( ,33023)} #IF (%pos( "You may ENTER SUBDIVISION from here.", @sRoomWWH) > 0) {#NOOP %roomcol( ,33023)} #IF (@sRoomName <> %roomname) {#EXEC "_Debug RoomEnter : Roomname Does Not Match! ID:%roomnum"} } } #ALIAS _MakeNewRoom { #T- _MakeNewRoom #EXEC _Debug "Making New Room" #PRIORITY { #ADDKEY SearchForObjects MapLocked %maplocked #NOOP %maplocked( 0) #IF ((@Mud.CommandLast = in) or (@Mud.CommandLast = out)) { #IF (@Mud.CommandLast = out) { #ADDKEY Personal MapLastRoom %roomnum #MAKEROOM {out|down|in} {@sRoomName} {@sRoomDesc} #NOOP %roomlink( @Personal.MapLastRoom, out, %roomnum) ; #NOOP %roomlink( , in, @Personal.MapLastRoom) #EXEC _Debug {Lastroom: @Personal.MapLastRoom ThisRoom :%roomnum} } #IF (@Mud.CommandLast = in) { #ADDKEY Personal MapLastRoom %roomnum #MAKEROOM {in|up|out} {@sRoomName} {@sRoomDesc} #NOOP %roomlink( @Personal.MapLastRoom, in, %roomnum) #EXEC _Debug {Lastroom: @Personal.MapLastRoom ThisRoom :%roomnum} } } {#MAKEROOM @Mud.CommandLast {@sRoomName} {@sRoomDesc}} #IF (%numitems( %mapquery( {[Name] = '@sRoomName'}))>1) {#EXEC _Debug {Same Name: @sRoomName Room Numbers: %mapquery( {[Name] = '@sRoomName'})}} #VAR RoomExits "" _nodef Room #EXEC _UpdateExits #NOOP %maplocked( @SearchForObjects.MapLocked) } ;#EXEC onroomenter ;#ECHO %ismember("",%roomexit) } #ALIAS _SearchObjects { #PRIORITY { #STATE TrigIH 0 #ADDKEY SearchForObjects FoundObject "" #ADDKEY SearchForObjects Reload 0 RoomDenizenEnimies = "" #IF (not %null( @RoomObjects)) { #LOOPDB @RoomObjects { #IF (not %null( @DBFIND({Items}, {DenizenTargets}, {Name}, {%val}))) {#ADDKEY RoomDenizenEnimies %key %val} #ADDKEY SearchForObjects Temp @DBFIND({Items}, {All}, {Name}, {%val}) #IF (%null( @SearchForObjects.Temp) and not %match( %val, "{@ObjectIgnoreList}")) { #EXEC _Debug String(>%val~< Not Found) #ADDKEY SearchForObjects Confirm 1 #IF (@SearchForObjects.Confirm) { #NEW "All|it" {Name=%val|ZoneId=%zonenum|RoomId=%roomnum} #ADDKEY SearchForObjects FoundObject %additem( &Num, @SearchForObjects.FoundObject) } {#ADDITEM ObjectIgnoreList {%val}} } {#ADDKEY SearchForObjects FoundObject %additem( %db( @SearchForObjects.Temp, Num), @SearchForObjects.FoundObject)} } } } #IF (@Personal.Mapping or %eval( %bitand( %roomload, 2)=2) or %eval( %numkeys( @RoomObjects) > %numitems( %roomcontents))) { #ADDKEY SearchForObjects MapLocked %maplocked #NOOP %maplocked( 0) #NOOP %roomcontents( , @SearchForObjects.FoundObject) #IF ((%bitand( %roomload, 2)=2) and not (%null( @sRoomDesc))) { #NOOP %roomdesc( ,@sRoomDesc) #NOOP %roomload( ,%bitxor( %roomload, 2)) } #NOOP %maplocked( @SearchForObjects.MapLocked) } #IF (%walkactive) {#ALARM +@Mud.SlowWalkSpeed {#STEP}} #EXEC _FormatRoomObjects } #ALIAS _UpdateExits { #PRIORITY { #VAR InOutUnknown 0 _nodef Room #FORALL @DirectionsFull { ; #ECHO Trying %i #IF ((%roomlink( ,%i) = -1) and (%match( @sExits, " %i%p") > 0)) { ; Creates New Links to Unknown Rooms ; #ECHO Hit on %i #IF ((%i=in) or (%i=out)) { #ADD InOutUnknown 1 #IF (@InOutUnknown > @CountNull(%roomexit)) {#NOOP %roomlink( ,%i, -2)} } {#NOOP %roomlink( ,%i, -2)} } #IF ((%roomlink( ,%i) > 0) and not (%match( @sExits, " %i%p") > 0)) { ; Deleted Links to Unlisted Exits #NOOP %roomlink( ,%i, -1) } } } } #VAR sRoomAll {Thousands of petals have been scattered around this stunning sculpture of the Goddess Selene in honour of Her. A brass-bound spyglass rolls about on its side. There are 2 red king crabs here.} #VAR sRoomDesc {} #VAR sRoomPeople {} #VAR sRoomWWH {} #VAR sRoomName {Shore along the cliff's base.} #VAR sRoomObjects {Thousands of petals have been scattered around this stunning sculpture of the Goddess Selene in honour of Her. A brass-bound spyglass rolls about on its side. There are 2 red king crabs here.} #VAR sExits { leading east, southeast, and southwest.} #VAR SearchForObjects {FoundObject1823itTemp(Num1823itNamea red king crabLevel0KindAlignmentTargetNoAgressiveNoCommentQuestItemNoRoomId1395ZoneIdVashnar MountainsTalksNoSellsNoUpdateNo)MapLocked1Reload0Confirm1} #VAR TempExits {} #VAR AllExits {} #VAR RoomExits {} #VAR ObjectIgnoreList {a black Mayaween|a Logosmas |a pike with the head of|a pine-fresh Logosmas|a sprig of mistletoe|an evergreen Logosmas|the corpse of} #VAR SQLQuery {_noddef} {_noddef} #VAR sWhoHere {Trilion} #VAR InOutUnknown {0} #ONINPUT "TrigIH" {^ih$} { RoomObjects = "" #TEMP {^Number of objects:%s%d$} { #EXEC _AddCommand {_SearchObjects} #STATE TrigIH 0 } } #COND {^(%w%d)%s(*)} {#ADDKEY RoomObjects {%1} {%2}} {looplines|param=100} #TRIGGER "TrigRoomInfo" {^%e[1;35m(*)} { sRoomName = %stripansi( "%1") #TAG Name @sRoomName } "" {color} #COND {(*)} { ;_debug Hit #PRIORITY { sRoomAll = %subregex( "%1", "\e\[0m", "") #IF (%regex( @sRoomAll, "\e\[1;34m.+")) { sRoomObjects = "" sExits = %stripansi( @sRoomAll) #TAG Exit @sExits #STATE TrigRoomInfo 0 #EXEC _RoomEnter } { #IF (%regex( @sRoomAll, "\e\[1;37mA blizzard rages around you.+")) { #NOMAP #STATE TrigRoomInfo 0 #EXEC _RoomEnter } { sRoomDesc="" sRoomObjects="" sRoomPeople="" ; If Room Description #IF (%regex( @sRoomAll, "\e\[37m.+") > 0) { ; RoomDescription SingleLine Only with no objects #NOOP %regex( @sRoomAll, "(\e\[37m.+$)", @sRoomDesc) ; RoomDescription SingleLine Only #NOOP %regex( @sRoomAll, "(\e\[37m.+?\e)", @sRoomDesc) ; RoomDescription Multiline to fullstop #NOOP %regex( @sRoomAll, "(\e\[37m.+\e\[37m.+?\e)", @sRoomDesc) sRoomDesc = %stripansi( @sRoomDesc) } ; If Room Objects #IF (%regex( @sRoomAll, "\e\[36m.+") > 0) { ; Room Objects SingleLine #NOOP %regex( @sRoomAll, "(\e\[36m.+$)", @sRoomObjects) ; Room Objects MultiLine to fullstop #NOOP %regex( @sRoomAll, "(\e\[[0;]*?36m.+\e\[36m.+?\.)", @sRoomObjects) sRoomObjects = %stripansi( @sRoomObjects) } ; If Room People #IF (%regex( @sRoomAll, "\e\[1;33m.+") > 0) { ; Room People SingleLine #NOOP %regex( @sRoomAll, "(\e\[1;33m.+$)", @sRoomObjects) ; Room People MultiLine to fullstop #NOOP %regex( @sRoomAll, "(\e\[1;33m.+\e\[1;33m.+?\.)", @sRoomObjects) sRoomObjects = %stripansi( @sRoomObjects) } } } } } {within|param=1|color} #COND {^%e[1;34m{You see|There are no obvious} {a single exit|exits}(*.)} { sExits = %stripansi( "%1") #EXEC _RoomEnter } {within|param=1|color} #TRIGGER {^Now now, don't be so hasty!$} { #COLOR bright,red #SEND %lastdir( ) } #TRIGGER {^There is no exit in that direction.$} { #IF (%inwalk) {_TelMe} #NODIR } #TRIGGER {^There's water ahead of you. You'll have to SWIM %w to make it through.$} { #NODIR #STOP } #TRIGGER {^You follow *,* ({@DirectionsFull}) to (*)} { sRoomName = %1 #MOVE %1 #IF (@Personal.PartyHunt) {_SendCommandOnPrompt ql} ;_Debug Mapper Moving %1 } "" {case} #TRIGGER {^There is a door in the way, to the (%w).$} { #IF (not %maplocked) { #IF (%class( _MakeNewRoom)) {#T- _MakeNewRoom} #IF ((%1=in) or (%1=out)) {#IF ((%roomlink( ,%1) = -1) and (@CountNull(%roomexit)=0)) {#DOOR %1}} {#DOOR %1} } } #ONINPUT {^{map|look|l}$} {#NOMAP} #ONINPUT {^who here$} {} #COND {^You see the following people here:$} {} #COND {(*)} {#VAR sWhoHere %replace( "%1", ",", "|") _nodef Room} #ONINPUT {^({@Directions})$} { #IF (%roomlink( ,%1)<0) { #IF (%1=in) {#T+ TrigBlankDescption} #IF %inwalk {#STOP} #T+ _MakeNewRoom } } #TRIGGER "TrigBlankDescption" {^$} { ;#ECHO %state( TrigRoomInfo) #IF (%state( TrigRoomInfo)=0) {#STATE TrigRoomInfo 2} #T- TrigBlankDescption } "" {skip|param=2|disable} #TRIGGER {^This door has been magically locked shut.$} {#NODIR} #CLASS 0 #CLASS {Triggers|Room|EnterExit} #TRIGGER {^%w arrives from the %w.$} {#ECHO Someone Arrived} #TRIGGER {^%w descends from above.$} {#ECHO Someone Arrived} #TRIGGER {^%w leaves to the %w} {#ECHO Someone Left} #CLASS 0 #CLASS {Triggers|Room|Denizen} #ALIAS _RemoveLastTarget { #IF (%iskey( @RoomObjects, @Combat.LastTarget)) {#DELKEY RoomObjects @Combat.LastTarget} #IF (%iskey( @RoomDenizenEnimies, @Combat.LastTarget)) {#DELKEY RoomDenizenEnimies @Combat.LastTarget} #EXEC _FormatRoomObjects } #TRIGGER {^You have slain *, retrieving the corpse.$} { #EXEC _RemoveLastTarget #IF (@Personal.AutoHuntStop and %null( @RoomDenizenEnimies)) { #ALARM +1 { #BUTTON bHunt #IF (@Personal.HuntOnRefLoss) {#EXEC _ActionAdd Reflection me} } } } #TRIGGER {^You detect nothing here by that name.$} { #EXEC _RemoveLastTarget #ADDKEY Personal EQ 1 } #TRIGGER {^I do not recognise anything called that here.$} { #EXEC _RemoveLastTarget #ADDKEY Personal EQ 1 } #TRIGGER {^Ahh, I am truly sorry, but I do not see anyone by that name here.$} { #EXEC _RemoveLastTarget #ADDKEY Personal EQ 1 } #TRIGGER {^Nothing can be seen here by that name.$} { #EXEC _RemoveLastTarget #ADDKEY Personal EQ 1 } #TRIGGER {^You cannot see that being here.$} { #EXEC _RemoveLastTarget #ADDKEY Personal EQ 1 } #TRIGGER {^You will now notice the movement of rats. Happy hunting!$} { #T+ Rats #ADDKEY Personal RatsSeen 1 } #TRIGGER {^You will no longer take notice of the movement of rats.$} { #T- Rats #ADDKEY Personal RatsSeen 0 } #CLASS 0 #CLASS {Triggers|Room|Denizen|Rats} #VAR Rats {a rat|a young rat|an old rat|a black rat|a baby rat} #ONINPUT {rats} {} "" {disable} #TRIGGER {^{@Rats} noses its way cautiously out of the shadows.$} {_SendCommandOnPrompt ih} #TRIGGER {^{@Rats} wanders into view, nosing about for food.$} {_SendCommandOnPrompt ih} #TRIGGER {^With a squeak, {@Rats} darts into the room, looking about wildly.$} {_SendCommandOnPrompt ih} #TRIGGER {^Your eyes are drawn to {@Rats} that darts suddenly into view.$} {_SendCommandOnPrompt ih} #TRIGGER {^{@Rats} wanders back into its warren where you may not follow.$} {_SendCommandOnPrompt ih} #TRIGGER {^{@Rats} darts into the shadows and disappears.$} {_SendCommandOnPrompt ih} #TRIGGER {^With a flick of its small whiskers, a*rat dashes out of view.$} {_SendCommandOnPrompt ih} #CLASS 0 #CLASS {Triggers|Room|Denizen|tDangerousEnters} #TRIGGER {^On the hunt for its next meal, a shark enters from the %w.$} {_SendCommandOnPrompt ih} #CLASS 0 #CLASS {Triggers|Room|tPlayers} #TRIGGER {^A beam of prismatic light shoots into the room.$} { #ECHO Hit #IF (@Personal.InHalls) { #EXEC _SendCommandOnPrompt "ht Prysm to me in Halls" #PRIORITY {#EXEC _ActionAdd Move} #IF (@Mud.PromptWaiting) {#EXEC _ProcessActions} } } #CLASS 0 #CLASS {Triggers|Room|Old} #ALIAS _SearchForObjectsOld2 { #PRIORITY { #ADDKEY SearchForObjects FoundObject "" #ADDKEY SearchForObjects Reload 0 RoomDenizenEnimies = "" #IF (not %null( @RoomObjects)) { #LOOPDB @RoomObjects { #IF (not %null( %query( (&Name=%val), DenizenTargets|it))) {#ADDKEY RoomDenizenEnimies %key %val} #IF (@Personal.Mapping) { #ADDKEY SearchForObjects Temp %find( %val, All|it, Name) #IF (not %null( @SearchForObjects.Temp)) {#ADDKEY SearchForObjects FoundObject %additem( @SearchForObjects.Temp, @SearchForObjects.FoundObject)} { #IF (not %match( %val, "{@ObjectIgnoreList}")) { #EXEC _Debug String(>%val> Not Found) #ADDKEY SearchForObjects Confirm %yesno( Enter %val) #IF (@SearchForObjects.Confirm) { #NEW "All|it" {Name=%val|ZoneId=%zonenum|RoomId=%roomnum} #ADDKEY SearchForObjects Reload 1 } {#ADDITEM ObjectIgnoreList {%val}} } } } } } } #EXEC _FormatRoomObjects } #ALIAS _RoomEnterOld { #OK RoomObjects = "" #IF ((@Personal.Mapping or @Personal.Hunting) and not %null( @sRoomObjects)) {_SendCommandOnPrompt ih} {#ALARM {+@Mud.SlowWalkSpeed} {#IF (%walkactive) {#STEP}}} #IF (@Personal.Mapping) { #ALARM +0.2 { #ADDKEY Mud LastRoomNum @Mud.ThisRoomNum #ADDKEY Mud ThisRoomNum %roomnum #IF (%ismember( @Mud.CommandLast, @Directions) and (@Mud.LastRoomNum=@Mud.ThisRoomNum)) { ;%eval( %roomlink( ,@Mud.CommandLast)=-2) #EXEC _Debug "Making New Room" #IF (not %null( %mapquery( {[Name] = '@sRoomName'}))) {#EXEC _Debug {Same Name: @sRoomName Room Numbers: %mapquery( @SQLQuery)}} #MAKE @Mud.CommandLast {@sRoomName} {@sRoomDesc} #VAR RoomExits "" _nodef Room #FORALL @DirectionsFull {#IF (%match( @sExits, "[ ]%i[ .,]")) {#ADDITEM RoomExits %i}} #FORALL @RoomExits {#IF (%roomlink( ,%i)<0) {#NOOP %roomlink( ,%i, -2)}} #STOP } } } } #ALIAS _UpdateExitsOld { #FORALL @DirectionsFull {#IF (%match( @sExits, "[ ]%i[ .,]")) { #ADDITEM RoomExits %i #IF (%roomlink( ,%i) < 0) {#NOOP %roomlink( ,%i, -2)} } {#IF (%roomlink( ,%i) <> @Personal.LastRoom) {#NOOP %roomlink( ,%i, -1)}}} ;#FORALL @RoomExits {#IF (%roomlink( ,%i)<0) {#NOOP %roomlink( ,%i, -2)}} } #ALIAS _SearchObjectsOld { #PRIORITY { #STATE TrigIH 0 #ADDKEY SearchForObjects FoundObject "" #ADDKEY SearchForObjects Reload 0 RoomDenizenEnimies = "" #IF (not %null( @RoomObjects)) { #LOOPDB @RoomObjects { #IF (%not %null( @DBQuery(Items,(%literal(&Name)=%string(%val))~&(~&Type="Denizen")~&(~&Target="Yes")))) {#ADDKEY RoomDenizenEnimies %key %val} #ADDKEY SearchForObjects Temp %find( %val, All|it, Name) #IF (not %null( @SearchForObjects.Temp)) {#ADDKEY SearchForObjects FoundObject %additem( @SearchForObjects.Temp, @SearchForObjects.FoundObject)} { #IF (not %match( %val, "{@ObjectIgnoreList}")) { #EXEC _Debug String(>%val~< Not Found) #ADDKEY SearchForObjects Confirm 1 ;%yesno( Enter %val) #IF (@SearchForObjects.Confirm) { #NEW "All|it" {Name=%val|ZoneId=%zonenum|RoomId=%roomnum} #ADDKEY SearchForObjects FoundObject %additem( &Num, @SearchForObjects.FoundObject) } {#ADDITEM ObjectIgnoreList {%val}} } } } } } #IF (@Personal.Mapping or %eval( %bitand( %roomload, 2)=2) or %eval( %numkeys( @RoomObjects)>%numitems( %roomcontents))) { #ADDKEY SearchForObjects MapLocked %maplocked #NOOP %maplocked( 0) #NOOP %roomcontents( , @SearchForObjects.FoundObject) ; #IF (%bitand( %roomload, 2)=2) {#NOOP %roomload( ,%bitxor( %roomload, 2))} #NOOP %maplocked( @SearchForObjects.MapLocked) } #ALARM +@Mud.SlowWalkSpeed {#IF (%walkactive) {#STEP}} #EXEC _FormatRoomObjects } #ALIAS _UpdateExitsOld2 { #FORALL @DirectionsFull { ; Creates New Links to Unknown Rooms #IF ((%roomlink( ,%i) = -1) and (%match( @sExits, "[ ]%i[ .,]") > 0)) {#NOOP %roomlink( ,%i, -2)} #IF ((%roomlink( ,%i) > 0) and not (%match( @sExits, "[ ]%i[ .,]") > 0)) {#NOOP %roomlink( ,%i, -1)} } ;#FORALL @RoomExits {#IF (%roomlink( ,%i)<0) {#NOOP %roomlink( ,%i, -2)}} } #VAR IsDenizenTarget {%eval( not %null( %query( (&Name="%1"), DenizenTargets|it)))} #TRIGGER "TrigRoomInfo" {^%e[1;35m(*)} { sRoomName = %stripansi( "%1") #TAG Name @sRoomName } "" {color|disable} #COND {(*)} { #PRIORITY { sRoomAll = %subregex( "%1", "\e\[0m", "") #IF (%regex( @sRoomAll, "\e\[1;34m.+")) { sRoomObjects = "" sExits = %stripansi( @sRoomAll) #TAG Exit @sExits #STATE TrigRoomInfo 0 #EXEC _RoomEnter } { #IF (%regex( @sRoomAll, "\e\[1;37mA blizzard rages around you.+")) { #NOMAP #STATE TrigRoomInfo 0 #EXEC _RoomEnter } { sRoomDesc="" sRoomObjects="" sRoomPeople="" sRoomWWH="" #IF (%regex( @sRoomAll, "(\e\[[0;]*?37m.+$)", @sRoomDesc) > 0) { #NOOP %regex( @sRoomAll, "(\e\[[0;]*?37m.+\e\[37m.+?\.)", @sRoomDesc) sRoomDesc = %stripansi( @sRoomDesc) } #IF (%regex( @sRoomAll, "(\e\[[0;]*?36m.+$)", @sRoomObjects)) {#NOOP %regex( @sRoomAll, "(\e\[[0;]*?36m.+\e\[36m.+?\.)", @sRoomObjects)} #NOOP %regex( @sRoomAll, "(\e\[1;36m.+?\.+$)", @sRoomPeople) #IF (%regex( @sRoomAll, "(\e\[[0;]*?33m.+$)", @sRoomWWH)) { #NOOP %regex( @sRoomAll, "(\e\[[0;]*?33m.+\e\[33m.+?\.)", @sRoomWWH) sRoomWWH = %stripansi( @sRoomWWH) } } } } } {within|param=1|color|disable} #COND {^%e[1;34m{You see|There are no obvious} {a single exit|exits}(*.)} { sExits = %stripansi( "%1") #EXEC _RoomEnter } {within|param=1|color|disable} #CLASS 0