Immobilizing Player! [SOLVED...for now MUWAHAHA!]

Anonynn
So I was wondering how I might go about immobilizing the player in one particular place. I noticed someone else created a thread on this a while back (like months/years ago) but it didn't really get answered. See I originally had a backpack item that you could store things in and it would separate that weight with the player weight, but I guess it never really worked properly because a lot of people have complained about it.

I went back and redesigned the way inventory works in my game. The player starts with...

Max Volume: 3

And then I created two different types of containers; wearable and not wearable. A wearable example is the backpack and an unwearable would be like a sack or something like that. When you "wear" the backpack it's inventory space gets automatically added to your own. So the backpack item would have a Max Volume of 13. So now the player's Max Volume is 16. Just having the "sack" in your inventory also boosts that number up to like "20". Yay! Right? Well, kind of.

See, each item the player gets subtracts their Max Volume carry amount. So if they have Max Volume 20, then taking an item might bring it down to 19 or 18. The system seems to work just fine. But I'm not sure how to go about "stopping player" movement if they are...let's say carrying 15 items and then drop the backpack or the sack which will reduce the Max Volume to "0" because their inventory carry amount is Maxed. I already set the code to return "0" if something like this happens meaning the player cannot pick up anything else, but I would also like to remove all possible exits no matter where they are if the volume of their inventory exceeds their max carry volume...so...

volume > player.maxvolume.

Anyone know how to make exits invisible until the volume < player.maxvolume?

:D Thanks!

XanMag
ive got a solution I think but I want to know first why you want the exits invisible? Instead of invisible, wouldn't you want the player to be able to see the exit and just not be able to go there? That seems more realistic. I can see the door but because I'm carrying too much I cannot move in any direction? Instead of the exit disappearing altogether?

If you want the player simply not to be able to move, I'd use a global command to check if the max volume is met or exceeded and then print a message telling the player whatever you want to tell them. I did something similar in X2 by typing n;ne;nw;north;northeast; etc. I still allowed other commands that they should be able to do under those circumstances.

Anonynn
That was essentially the idea! But I wasn't sure if the player could be "frozen" in place or not, so removing exits seemed like the next best idea. :P How do you remove player mobility then? I have the global message ready already, I just need to keep the player from moving now...and then add that to the scripting, me thinks.

R2T1
Another idea I have seen is to randomly remove an item/items in their inventory to allow for the new item to fit in. Then as they leave the location, let them proceed but with an extra message to the effect - "As you leave, something falls from your hands/backpack, etc. perhaps you shouldn't overload yourself too much in future."
This can then give rise to a further puzzle for the PC as they now have to determine what is important and what can be left behind for later.

XanMag
R2T1 has an interesting idea but then you'd have to randomly select an item to drop. It can't be that hard to do, right?

As for immobilizing, like I said, I would add a global command with an If script --> if player.maxvolume = 0, then print message "You're so bogged down with items, you can't move around very well. You'll need to drop something to carry forward." Leave the Else blank. As for the command, just type in any possible direction command. That'll prevent the player from moving regardless of the direction they try to go. There might be a more
Streamlined way to do this but it worked for me.

HegemonKhan
here's some links (maybe you already know of them):

http://docs.textadventures.co.uk/quest/ ... nexit.html (Invisible Exits)
http://docs.textadventures.co.uk/quest/ ... layer.html (Immobolizing the Player)

Anonynn
http://docs.textadventures.co.uk/quest/ ... layer.html (Immobolizing the Player)

^---- I tried this and all it does is print the exit directions now even when the player isn't immobilized. Here is my "Command" for it.

Command Pattern
north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d
Name: immobilized

if (player.maxvolume = 0) {
if (GetBoolean (player, "immobilized")) {
Print (player.immobilizedmessage)
}
else if (exit.locked) {
msg (exit.lockmessage)
}
else if (HasScript(exit, "script")) {
do (exit, "script")
}
else {
if (exit.lookonly) {
msg ("You can't go there.")
}
else {
player.parent = exit.to
}
}
}


Here is the original "Go" from the Filter.

if (exit.visible) {
if (exit.locked) {
msg (exit.lockmessage)
}
else if (exit.runscript) {
if (HasScript(exit, "script")) {
do (exit, "script")
}
}
else if (exit.lookonly) {
msg ("You can't go there.")
}
else {
game.pov.parent = exit.to
}
}
else {
msg ("You can't go there.")
}


Why in the hell are those explained so badly? I can't look up a single thing about how to do something on Quest and follow it from those "guides" because they leave out steps and details that I guess they assume all programmers/game-makers already know. I dunno. Not once have they been helpful at all. @_@ If you're going to have a guide it needs to be severely dumbed down.

Why not just say...here is the original code. Here's where you paste the new code. Tada! Super simple.

Sorry, it's just that time of the month where everything is stressful. I apologize. Would someone mind pointing out how to combine these?

Pertex
if you don't use locked exits in your room you can lock all exits in that room. So when you check volume > player.maxvolume call this:

foreach (exit, AllExits()) {
if (exit.parent = player.parent and not GetBoolean(exit, "lookonly")) {
exit.locked = true
exit.lockmessage ="Your items are too heavy."
}
}

and if the player drops an item call this:

foreach (exit, AllExits()) {
if (exit.parent = player.parent and not GetBoolean(exit, "lookonly")) {
exit.locked = false
exit.lockmessage ="That way is locked."
}
}

The Pixie
Neonayon, the third line of your code has "Print", it should be "msg" (error in the documentation). In fact, I would suggest changing this:
Print (player.immobilisedmessage)

... to this:
if (HasString(player, "immobilisedmessage")) {
msg (player.immobilisedmessage)
}
else {
msg ("You cannot move!")
}

Anonynn
I might end up trying that Pertex if this "go" thing doesn't work, thank you very much for the secondary option! And I apologize for my bitchiness the other day.

So I inserted what Pixie mentioned. This is the new modified command, although movement doesn't work as of right now.

Pattern: Regular Expression (I tried switching it to a "Command Pattern" too and nothing changed)
^go to (?<exit>.*)$|^go (?<exit>.*)$|^(?<exit>north|east|south|west|northeast|northwest|southeast|southwest|in|out|up|down|n|e|s|w|ne|nw|se|sw|o|u|d)$
Name: go_modified
Unresolved object text: You can't go there.

Code:
if (player.maxvolume = 0) {
if (GetBoolean (player, "immobilized")) {
if (HasString(player, "immobilizedmessage")) {
msg (player.immobilizedmessage)
}
else {
msg ("<br/>{random:You're carrying too much to move!:You're juggling too many items!:You cannot move, things are literally dropping out of your arms with every motion you make!} {once:You'll need to find a container or to drop some of your current items.} <br/>")
}
}
else if (exit.locked) {
msg (exit.lockmessage)
}
else if (HasScript(exit, "script")) {
do (exit, "script")
}
else {
if (exit.lookonly) {
msg ("You can't go there.")
}
else {
player.parent = exit.to
}
}
}

The Pixie
I had forgotten this was about the carry capacity. That means Pertex's idea will only work if you have no locked doors in your games, as this needs to work in any room. Try this instead:
  if (GetBoolean (player, "immobilized")) {
if (HasString(player, "immobilizedmessage")) {
msg (player.immobilizedmessage)
}
else {
msg ("<br/>You cannot move! <br/>")
}
}
else if (player.maxvolume < ListCount(GetDirectChildren(player))) {
msg ("<br/>{random:You're carrying too much to move!:You're juggling too many items!:You cannot move, things are literally dropping out of your arms with every motion you make!} {once:You'll need to find a container or to drop some of your current items.} <br/>")
}
else if (exit.locked) {
msg (exit.lockmessage)
}
else if (HasScript(exit, "script")) {
do (exit, "script")
}
else {
if (exit.lookonly) {
msg ("You can't go there.")
}
else {
player.parent = exit.to
}
}

The important line is this:

else if (player.maxvolume < ListCount(GetDirectChildren(player))) {

It uses the number of direct children, so will include the backpack, but not anything in the backpack. It will also include anything worn. What you could do is create a new function, say called IsOverLaden, which returns a boolean, true if the player is carrying too much, false otherwise. That line then becomes:

else if (IsOverLaden()) {

You can then fine tune the function how you like. For example, this will include the backpack if it is not worn, but not itf it is, nor anything else worn:
count = 0
foreach (o, GetDirectChildren(player)) {
if (not GetBoolean(o, "worn")) {
count = count + 1
}
}
return (count > player.maxvolume)

Anonynn
Actually, I don't need to put things into the bags anymore. All they do is increase the player's inventory space and there are two types of these items.
Wearable.
Collectable.

To increase max inventory you must wear the wearables or have the collectables in your inventory :) Pretty nifty eh?

BTW the code worked beautifully! Thank you!

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

Support

Forums