Unreachable objects

Avantar
03 Nov 2013, 15:17
I was wondering:
When would ScopeReachable() declare an object seen but unreachable?
For restoring my health from a health potion (script I got from HK), I used ScopeReachable() rather than ScopeInventory() so that I do not need to have it in my inventory to drink it if it is reachable.

But say you have the following:

You can see a health potion on a ledge, but it is not reachable - is it something you can impliment with ScopeReachable()?

Thank you for any help in this regard.

george
03 Nov 2013, 17:41
If an object is in a transparent container, then it's seen but not reachable. You can see how it works in the internal functions ContainsReachable, CanReachThrough, etcetera (which ScopeReachable defers to). So you don't exactly implement it with ScopeReachable -- ScopeReachable tells you if it is reachable, but you would set it up with other code.

What you basically want to do is make a different kind of surface whose objects aren't reachable. Maybe a new type? Like UnreachableSurface. Or I guess you could modify just that one surface (the ledge) if it's the only one in the game. I can imagine a few ways to go about it but I'll wait a minute to see if a more experienced Quester has some ideas.

george
04 Nov 2013, 00:13
So I've thought about this a bit, and I'm wondering if there's any reason you can't handle this with the default take logic? If you create a ledge and a potion, both are not takeable by default. If you make the potion takeable, of course you can then get it from the ledge. But you also could run a script when you take the potion, and just deny the take if the potion is on the ledge. Sure it's not a general solution, but perhaps it's good enough? As long as players can't put more stuff on the ledge you won't have to worry about coding that take behavior for every object.

HegemonKhan
04 Nov 2013, 02:09
Just add an "if" script + "boolean_or_string_or_integer" script (or "call upon" a "checking" function) to your action script (Verb, Command, Function, etc), here's an example of mine though with my combat function (using a "checking" function):

for an example, maybe you can see the enemy on the other side of the river, but neither of you can swim, nor do either of you have projectile weapons, and thus you can't fight each other, yet.

// this is just a single part of my "checking" script block function for whether you can fight it or not:

else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
}

// parameters' transfering: enemy -> object_x

<function name="npc_reachable" parameters="object_x" type="boolean">
value = false
foreach (item_x,ScopeReachableNotHeld ()) {
if (item_x=object_x) {
value = true
}
}
return (value)
</function>


you can add in more script lines into the "npc_reachable" function if you have more conditions~factors involved to "check for", such as seen in the below with the "if + boolean" scripting.

----------------------------

if + boolean scripting:

let's say there's a key high up in the air (or on a ledge high off the ground ~ whatever)

<object name="key">
<inherit name="editor_object" />
<take_x type="script">
if (player.flying=true) {
key.parent=player
msg ("you fly up to the key and take it")
} else {
msg ("what!, did you think you could just fly up into the air, to get the key?!")
}
</take_x>
</object>

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<flying type="boolean">false</flying>
</object>

<object name="flying_potion">
<inherit name="editor_object" />
<alias>mysterious potion</alias>
<drink_x type="script">
player.flying=true
msg ("you drink the mysterious potion, and now you can fly!")
</drink_x>
</object>


---------------------------------

ScopeVisible is what you can see, ScopeReachable is what you can interact with (act upon),

***IGNORE THIS***
so you'll have to add in your own scripting to create the effect of something (an Object or Exit) being (initially) "unreachable" (or an actual "ScopeUnreachable" function).
***IGNORE THIS***

--------------------------------

HK Edit:

err... I should have kept reading... lol:

ScopeVisibleNotReachable ()

http://quest5.net/wiki/ScopeVisibleNotReachable

Returns an objectlist containing all the objects which the player can see but cannot reach.

All objects in this scope can be seen, but can't be interacted with as they are either "far away" or inside a transparent container.

ScopeVisibleNotReachableForRoom (room)

http://quest5.net/wiki/ScopeVisibleNotReachableForRoom

Returns an objectlist containing all the objects in the specified room which the player can see but cannot reach.

All objects in this scope can be seen, but can't be interacted with as they are either "far away" or inside a transparent container.

Avantar
04 Nov 2013, 18:06
Thank you guys for the replies!

Maybe I am over complicating things:

George:
Your first post was quite helpful - thx.
The reason why making a potion not takeable won't work is for the fact that I didn't want to have a potion in my inventory to be able to drink it - it should just be reachable.

HK:
Helpful script as always. :) I think I should maybe just stick to ScopeInventory() after all - it will alleviate the headache :lol:

Say - do you guys have any playable games out? With all the scripts you provide, HK - it seems you have some mean game going or done?

HegemonKhan
05 Nov 2013, 03:29
no game, still chunking away at learning more coding~scripting stuff ~ though I haven't been able to do anything, due to school. I'm currently working on getting time+date coding understood and crafted... if~when I ever get the time to do so again, lol.

Coding I got to learn:

(basically, the aspects of the TES:The Elder Scrolls ~Arena, Daggerfall, Morrowind, Oblivion, Skyrim~ RPG computer games)
( http://www.uesp.net/wiki/Main_Page )

Time+Date System
Magic System
Equipment (beyond just equipping~unequipping) System
Thievery-Stealth System
Diplomacy~Hostility~Dialogue System
Shopping System (connected to equipment obviously)
Party~Team Members System
"String" (?Parsing?) Coding
Journal~Missions+Records~Notes System
"Pedia"~Info System
and etc (whatever I'm forgetting, lol)

--------------------------

just add an "If + Boolean", nice and simple:

Create a custom Boolean on your Objects: <reachable_flag type="boolean">false</reachable_flag>

Object: whatever you want
"take_x" Verb:
if (reachable_flag=true) {
-> Object.parent = player
} else {
-> ("you can't take that")

The Pixie
07 Nov 2013, 09:01
After reading this thread I realised transparent containers is a good way to implement something too high to reach. I created a quick game to see how it worked, and put it in the libraries and sample codes forum:

viewtopic.php?f=18&t=3997

Avantar
08 Nov 2013, 16:12
Thank you Pixie! Much appreciated.