Special exits as normal exits

Post Reply
Tagon
Posts: 24
Joined: Thu Sep 19, 2013 8:38 pm

Special exits as normal exits

Post by Tagon »

Okay, next roadblock in my quest...

I haven't had chance to test this code yet so I'm more asking if I'm doing this the hard way or if there's a better way to achieve the same aim. The plan is to have special exits (e.g. "leap through window") to be activated by a standard numpad direction. The reason being, I want to be able to numpad all over the map, into camps, towns, quest areas etc without typing out the special commands (the fun is in working them out, not retyping them every time!). I'm also wary that this has to work with speed walking, otherwise I'm asking for trouble!

So imagine this scenario. A map with 2 rooms. Room 1 has a single exit "east" which takes you east to room 2. Room 2 has a single special exit "leap through window" which takes you west into room 1. In this scenario I want to be able to move between rooms 1 and 2 using just "east" and "west". I have intentions on removing "in" and "out" from the exitmap and making those into special exits too (which would solve the problem of where to position them).

Currently I'm doing the following in a function called by "sysDataSendRequest":
Code: [show] | [select all] lua
if shortdir[command]~=null then lastCommand=shortdir[command]
	else lastCommand=command end
	if mapStatus>0 and currentRoom~=0 then
		local tmp = getRoomExits(currentRoom)
		if tmp[lastCommand]~=null then --if exit exists
			currentRoom=tmp[lastCommand]
			currentArea=getRoomArea(currentRoom)
			centerview(currentRoom) --update location
		end
	end
shortdir is just a lookup table for "e"="east" etc
mapStatus is a series of levels (0 = ignore the map, 1 = follow on map, 2 = write map is appropriate)

Going back to the example my plan is to have 2 exits from room 2, both going to room 1. The first would be a special exit with the command "leap through window", the second would be a standard exit west and locked. I would then, after checking the exit exists, check if the exit is locked. If it's not locked, proceed as normal. If it's locked I would fetch the list of special exits from the current room and look for one with the same destination as the exit matching the command. I know, that's convoluted to write! Let me try to code it.. replace the code above with this:
Code: [show] | [select all] lua
if shortdir[command]~=null then lastCommand=shortdir[command]
	else lastCommand=command end
	if mapStatus>0 and currentRoom~=0 then
		local tmp = getRoomExits(currentRoom)
		if tmp[lastCommand]~=null then --if exit exists
			if hasExitLock(currentRoom,exitmap[lastCommand]) then
				tmp2 = getSpecialExits(currentRoom)
				if tmp2[tmp[lastCommand]]~=null then
					denyCurrentSend() --cancel the fake direction
					expandAlias(tmp2[tmp[lastCommand]],true) --send replacement command
					currentRoom=tmp[lastCommand]
					currentArea=getRoomArea(currentRoom)
					centerview(currentRoom) --update location
				else
					-- give in, you just can't go that way, accept it!
				end
			else
				currentRoom=tmp[lastCommand]
				currentArea=getRoomArea(currentRoom)
				centerview(currentRoom) --update location
			end
		end
	end
I'm fairly certain I could clean the logic up a bit more, and I plan to later, but for now what do you think? Can you see any potential pitfalls (other than me becoming mapper reliant to navigate, I can live with that)?

visionok
Posts: 22
Joined: Thu Mar 04, 2021 8:50 am

Re: Special exits as normal exits

Post by visionok »

IIRC zmud allowed for something like, ie map a special exit to one of the standard compass directions and hence use the number keypad to walk around. Did you/anyone implement this, if so how is it working? I'm going to have a try to see if I can get it to work.

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Special exits as normal exits

Post by SlySven »

TinTin++ does this as well - normal and special exits are handled quite similarly - it is just that the name i.e. "e" is directly mapped to the "e" command inherently - but it can be changed there (you can get really confused if you swap the commands with the one for the opposite direction IIRC! :) ).

Mudlet doesn't quite offer that (yet) - though I do have medium-ling term plans to separate the name/identifier for a special exit from the command that it sends to the Game Server, sort of like an "alias" for the exit - you see the exit as "climb out" (or even "e" or "east") but it actually sends something like "open window; tie rope to ring; lower rope out of window; climb down rope" or whatever...

Post Reply