Add fake exit (solved; opinions are still welcomed)

Gng

heyall

So, normally there is a series of rooms (which are part of a big jungle) have say 2 or 3 exits, but when a specific situation happens, like being chased by an enemy and the player should run away, all the exit directions on the compass activate, which means the player has to memorize the right pathway not to get lost in the vast jungle.

The problem is when the chasing begins, how do I add exits that have scripts for failure or getting lost? the exit will transport the player to another room, and they have to find a way to get out.

Also the exits must be added in directions that don't originally have exits. For example, if the room has South and NorthWest directions, new "wrong" exits will be added to 6 remaining directions.

And in the end, I need a function that will destroy the fake exits.


Gng

EDIT 1:

I fixed it to a degree.

player.parent = run forest
z = ScopeExitsForRoom (run forest)
x = Settings.exitstringnames
m = NewStringList()
while (ListCount(z) > 0) {
  exi = PickOneObject (z)
  list remove (z, exi)
  exi = exi.alias
  list add (m, exi)
}
y = ListExclude (x, m)
msg (y)
while (ListCount(y) > 0) {
  n = PickOneString(y)
  list remove (y, n)
  create exit (n, run forest, run forest)
  n.runscript = true
  n.script => {
    
  }
}

the lines:
n.runscript = true
n.script => {

}
seem to be wrong. Somehow I have to get the name of the created exit

other opinions are welcomed is always

EDIT 2:

player.parent = run forest
z = ScopeExitsForRoom (run forest)
c = ScopeExitsForRoom (run forest)
x = Settings.exitstringnames
m = NewStringList()
while (ListCount(z) > 0) {
  exi = PickOneObject (z)
  list remove (z, exi)
  exi = exi.alias
  list add (m, exi)
}
y = ListExclude (x, m)
while (ListCount(y) > 0) {
  n = PickOneString(y)
  list remove (y, n)
  create exit (n, player.parent, run forest)
}
a = ScopeExitsForRoom (run forest)
forest b.fakeexits = ListExclude (a, c)
msg (forest b.fakeexits)
SetTimeout (3) {
  while (ListCount(forest b.fakeexits) > 0) {
    exi = PickOneObject (forest b.fakeexits)
    list remove (forest b.fakeexits, exi)
    exi.name = "fakeexit " + forest b.exitnum
    forest b.exitnum = forest b.exitnum + 1
    list add (Settings.todestroy, exi)
  }
  msg (Settings.todestroy)
  SetTimeout (3) {
    while (ListCount(Settings.todestroy) > 0) {
      objectname = PickOneString(Settings.todestroy)
      list remove (Settings.todestroy, objectname)
      destroy (objectname)
    }
    msg (Settings.todestroy)
  }
}

however the destroy won't destroy. It says error: Exit: exit59; not found

EDIT 3:

everything is fixed. The only thing that remains is adding script to the exits.

player.parent = run forest
z = ScopeExitsForRoom (run forest)
c = ScopeExitsForRoom (run forest)
x = Settings.exitstringnames
m = NewStringList()
while (ListCount(z) > 0) {
  exi = PickOneObject (z)
  list remove (z, exi)
  exi = exi.alias
  list add (m, exi)
}
y = ListExclude (x, m)
while (ListCount(y) > 0) {
  n = PickOneString(y)
  list remove (y, n)
  create exit (n, player.parent, run forest)
}
a = ScopeExitsForRoom (run forest)
forest b.fakeexits = ListExclude (a, c)
msg (forest b.fakeexits)
SetTimeout (3) {
  while (ListCount(forest b.fakeexits) > 0) {
    exi = PickOneObject (forest b.fakeexits)
    list remove (forest b.fakeexits, exi)
    exi.isfake = true
  }
  SetTimeout (3) {
    fakers = FilterByAttribute (AllExits(), "isfake", true)
    while (ListCount(fakers) > 0) {
      x = PickOneObject (fakers)
      list remove (fakers, x)
      destroy (x.name)
    }
    msg (Settings.todestroy)
  }
}

An alternative could be to create your "big" jungle with all the "wrong" exits, then just hide them till later when they are needed.
A simple variable player.lost=True will make the exits visible, and when player.lost=False, then hide those exits.
You could also make it so that the player can only find the hidden jungle temple IF they find it while they are lost.
Yes, I come from a Basic programming background and see 75% of the Quest coding as being "Why would you need to do it THAT way???"
As in... why make a look to list every exit when you already know that "Jungle trail 145" only has 2 exits???
But, that just me...


Gng

The most probable reason is laziness; Adding fake exits manually to 15 rooms is time-consuming and will use space in the interface. My Objects interface is crowded as it is even though I have organized the rooms into several groups. When I boot up the editor, I have to first close each unrelated group until I can figure out what the hell I'm looking at. I wish Quest had a nicer UI, or it started with every group collapsed instead of having to manually do so.

(hidden temple is a neat idea)


I would probably have made 8 fake exits, and store them outside any room. Then once the player is lost, move them all to the current room; and have the room enter script (the one on the game object, which runs whenever the player enters a room) check whether the player is lost, and if so, move fake exits to the current room if there isn't a real exit pointing in that direction.


Gng

How can I check if a real exit exists? With the direction alias?


Hello.

https://docs.textadventures.co.uk/quest/functions/getexitbyname.html

GetExitByName (object from room, string direction name)

Returns a string containing the name of the exit going from the specified room in the specified direction, if it exists. If it does not exist, null is returned instead.


The only other one is this one: https://docs.textadventures.co.uk/quest/functions/getexitbylink.html

GetExitByLink (object from room, object to room)

Looking at all your code, this might be more helpful?


How can I check if a real exit exists? With the direction alias?

I was thinking that if you have a bunch of fake exits named, for example, fake_exit_north, you could have a roomenter script like:

foreach (direction, Split("north;northeast;east;southeast;south;southwest;west;northwest")) {
  fake_exit = GetObject ("fake_exit_" + direction)
  RemoveObject (fake_exit)
  existing_exit = GetExitByName (game.pov.parent, direction)
  if (player is lost and Equal (existing_exit, null)) {
    MoveObjectHere (fake_exit)
  }
}

(the player is lost should be replaced with a boolean attribute, or whatever other condition you might use to determine whether the fake exits should be displayed)

This would move the fake exits into the current room if they're needed, and leave them outside reachable space otherwise.


Gng

Looking at all your code, this might be more helpful?

I see. However I think using ScopeExits type would be more suitable. There are many rooms with exits that I don't know their direction or name at the time when the chase trigger happens.
So I'll just Scope the room the player is at and check for real and fake exits and add additional ones if necessary.
Here's another example I've made:

x = ScopeExitsForRoom(player.parent)
y = NewStringList()
// real exit
while (ListCount(x) > 0) {
  z = PickOneObject(x)
  create exit (z.alias, semi run forest, z.to)
  list remove (x, z)
  list add (y, z.alias)
}
r = ListExclude(Settings.exitstringnames, y)
repli = 0
// fake exit
while (ListCount(r) > 0 and repli < 2) {
  exi = PickOneString(r)
  list remove (r, exi)
  repli = repli + 1
  create exit (exi, semi run forest, run forest)
}
player.parent = semi run forest
exitfromroom.parent = spawn

Explanation is: this is the code for the verb "run away" for the object "exitfromroom". There's a timer that will lock the real exits. (the enemy won't let you use them) and another timer that transports this object to player.parent and another timer that hides this object. So even when the exits got blocked, there's a chance that the player can use this object to escape.

To find the real exits, I use the Scope function before the player is transported to a fake forest room and I'll create the real exits in that room (semi run forest)

while also creating the fake exits.

Settings.exitstringnames is a string list that contains all the aliases for exits, i.e. north, south etc.


Gng

This would move the fake exits into the current room if they're needed, and leave them outside reachable space otherwise.

The premade 8 fake exits are also a very good idea. Alas, I've already coded the exits.

existing_exit = GetExitByName (game.pov.parent, direction)

I see. What I did instead of checking to see if the exit was null, I used the Scope functions. They came in very handy.


Gng

When I boot up the editor, I have to first close each unrelated group until I can figure out what the hell I'm looking at. I wish Quest had a nicer UI, or it started with every group collapsed instead of having to manually do so.

There's a simple way to do that. Just right click on a object/room in the list of objects/rooms in the left side of the screen and click Collapse All. I feel stupid.


This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums