Shoot Gun
Overcat
05 May 2009, 20:58I'm having a bit of a scripting issue, as regards the millionth iteration of the world model I'm attempting to build. Here's the problem:
'shoot gun'
The reason this command is a problem for me is because, unlike most one-verb/one-noun commands, 'shoot gun' is ambiguous. Does the player want to 'shoot at the gun', or 'shoot the gun itself'? I want to avoid prompting the player for information about this, if possible.
My world library is set up so that verbs that operate on a noun will only work if the noun-object has an action for that verb, as is no doubt reasonable.
Okay, so far so good. My question is, how should I write the following command?
'shoot gun'
The reason this command is a problem for me is because, unlike most one-verb/one-noun commands, 'shoot gun' is ambiguous. Does the player want to 'shoot at the gun', or 'shoot the gun itself'? I want to avoid prompting the player for information about this, if possible.
My world library is set up so that verbs that operate on a noun will only work if the noun-object has an action for that verb, as is no doubt reasonable.
'an object with this type may be shot
define type <shootable>
action <BeforeShoot> doaction <$thisobject$; OnShoot>
action <OnShoot> {
'default functionality
doaction <$thisobject$; AfterShoot>
}
define action <AfterShoot> {
}
end define
define object <target>
type <shootable>
end define
'an object with this type may shoot
define type <shooting>
action <BeforeShooting> doaction <$thisobject$; OnShooting>
action <OnShooting> {
'default functionality
doaction <$thisobject$; AfterShooting>
}
define action <AfterShooting> {
}
end define
define object <gun>
type <shooting>
type <shootable>
end define
Okay, so far so good. My question is, how should I write the following command?
command <shoot #@noun#> {
'Hmmmm?
}
paul_one
05 May 2009, 23:20In this situation there needs to be a clear "what are you shooting at?" message.
Either that or go with the default message for the object type - the default would then decide if the gun CAN be shot by itself or needs to be pointed at an object.
Remember that if there is no question - there is no answer (that's what we learn from the H2G2).
Either that or go with the default message for the object type - the default would then decide if the gun CAN be shot by itself or needs to be pointed at an object.
Remember that if there is no question - there is no answer (that's what we learn from the H2G2).
Overcat
06 May 2009, 00:54Right, but if the player has a gun in their hand they can type (for instance) 'shoot robber'. (They shouldn't have to type 'shoot robber with gun'.) In that case I just check to make sure they've got a 'shooting' type item in their hands. (If they don't, I check the inventory and the room for an accessible 'shooting' type object: if one is found, the appropriate actions are added to the player's "action queue" to make it possible to commit the original action. The player enacts each action in their action queue sequentially - one action per firing of the afterturn script - which allows them to be "interrupted" by other actors or events. If no accessible 'shooting' type object is found, a message similar to "You have nothing to shoot the robber with..." is printed.)
So it follows that they should be able to type 'shoot gun' when they want to shoot another gun with the gun in their hand. I need to disambiguate whether the player means 'shoot with the gun I've got' (at nothing, in which case the message would print that they need to choose a target) or 'shoot the other gun with the gun I've got'. I can't default to interpreting that the player should shoot the other gun with their own gun - Quest will force the player to disambiguate with its popup.
Also, I have the feeling that if the player has a single gun, and they type 'shoot gun', that I'm going to receive a "You can't shoot the gun with itself..." (since I need to code for attempts like that) rather than "You need to pick a target..."
So it follows that they should be able to type 'shoot gun' when they want to shoot another gun with the gun in their hand. I need to disambiguate whether the player means 'shoot with the gun I've got' (at nothing, in which case the message would print that they need to choose a target) or 'shoot the other gun with the gun I've got'. I can't default to interpreting that the player should shoot the other gun with their own gun - Quest will force the player to disambiguate with its popup.
Also, I have the feeling that if the player has a single gun, and they type 'shoot gun', that I'm going to receive a "You can't shoot the gun with itself..." (since I need to code for attempts like that) rather than "You need to pick a target..."
paul_one
06 May 2009, 20:13Well "shoot robber" and "shoot gun" seem like the same command to me.
... Meaning.. 'shoot gun' should search for objects in the room which are a "gun".
As far as I know you can't do that properly since the #object:alt# tag is ";" separated - so you'd probably use a "gun" type/property and check for that.
If there is no object, say that you need to aim at a specific thing in the room.
So there are only two forms:
shoot #object# with gun
shoot #object# (..with gun is implied here)
SO, I see something like:
So the second command would only get kicked off if they did not type "with gun", and would kick off the first one.
... Meaning.. 'shoot gun' should search for objects in the room which are a "gun".
As far as I know you can't do that properly since the #object:alt# tag is ";" separated - so you'd probably use a "gun" type/property and check for that.
If there is no object, say that you need to aim at a specific thing in the room.
So there are only two forms:
shoot #object# with gun
shoot #object# (..with gun is implied here)
SO, I see something like:
command <shoot #object# with gun> {
# Step 1: search for a gun in your inventory etc... so sort out what your GUN is
# Step 2: search for your #object# that is going to be shot.. Make sure it isn't the gun from Step 1
}
command <shoot #object#> exec command <shoot #object# with gun>
So the second command would only get kicked off if they did not type "with gun", and would kick off the first one.
Overcat
09 May 2009, 18:34command <shoot #object# with gun> {
Are you purposefully leaving out the @ symbol?
By doing it that way the player could still type 'shoot gun' thinking that they are going to aimlessly shoot the gun, rather than shoot at the gun with another shooting type item. They would receive a message like 'You cannot shoot the gun with the gun!' or some such, rather than "What do you want to shoot at?"
paul_one
10 May 2009, 14:22They would receive the "there doesn't seem to be any 'gun' in the room".
Yes, #@object# is purposefully left out since you are doing your own parsing... As you said - you don't want the user to get prompted for "which gun do you mean" type stuff.
Yes, #@object# is purposefully left out since you are doing your own parsing... As you said - you don't want the user to get prompted for "which gun do you mean" type stuff.
Overcat
10 May 2009, 15:00Yes, #@object# is purposefully left out since you are doing your own parsing... As you said - you don't want the user to get prompted for "which gun do you mean" type stuff.
I went that route before, but I found there was just too much work involved. I would prefer to keep the @ symbol and the built-in object discovery. I think it's faster, too. I'd like to avoid as much "loop lag" as possible. In this case, can you think of a solution?
paul_one
10 May 2009, 22:54Well, I think in that case it's sorted out for you.
... As long as you use the "shoot #@object# with #@object#" model...
.. Which has "shoot #@object#" kicking off "shoot #object# with gun"
So, for instance, they only have 1 gun:
> shoot cat with gun
Quest will recognize the gun etc.
> shoot cat
Kicks off "with gun" as above.
> shoot gun
Kicks off "with gun"..
The object you're trying to shoot is ITSELF - so you should be able to check this and return what you'd like "you can't shoot the gun you're firing!".
You can even compare the #quest.originalcommand# to see what the player typed and see if he WAS typing the first or second type (or use flags if you wish).
Meaning you CAN make him see "you shoot the gun into the air! YEE-HAH!" or "you can't make the gun shoot itself fool!".
The player has TWO guns:
> shoot cat with gun
should prompt for which gun to use
> shoot gun with gun
should prompt for which gun TWICE
> shoot gun
prompted twice again as above
... as long as you make it CLEAR to the player that "shoot #@object#" is basically the short version of "shoot#@object# with gun", then I see no problem.
.. Is there anything I missed?
... As long as you use the "shoot #@object# with #@object#" model...
.. Which has "shoot #@object#" kicking off "shoot #object# with gun"
So, for instance, they only have 1 gun:
> shoot cat with gun
Quest will recognize the gun etc.
> shoot cat
Kicks off "with gun" as above.
> shoot gun
Kicks off "with gun"..
The object you're trying to shoot is ITSELF - so you should be able to check this and return what you'd like "you can't shoot the gun you're firing!".
You can even compare the #quest.originalcommand# to see what the player typed and see if he WAS typing the first or second type (or use flags if you wish).
Meaning you CAN make him see "you shoot the gun into the air! YEE-HAH!" or "you can't make the gun shoot itself fool!".
The player has TWO guns:
> shoot cat with gun
should prompt for which gun to use
> shoot gun with gun
should prompt for which gun TWICE
> shoot gun
prompted twice again as above
... as long as you make it CLEAR to the player that "shoot #@object#" is basically the short version of "shoot#@object# with gun", then I see no problem.
.. Is there anything I missed?
paul_one
10 May 2009, 23:03So to answer your question:
command <shoot #@object1# with #@object2#> {
' checks to make sure objects are shootable / firable
' check to see if object1 = object2 - if so bail out
' kick off the shooting actions
}
command <shoot #@object#> exec <shoot #object# with gun>
Overcat
12 May 2009, 15:31So...
...has dissolved into:
I must tell the player in advance. Thought so. (Had already coded 'shoot #@object#' to execute 'shoot #@object# with shooting item', but that didn't resolve my issue.)
Thanks, Paul.
I want to avoid prompting the player for information about this, if possible.
...has dissolved into:
... as long as you make it CLEAR to the player that "shoot #@object#" is basically the short version of "shoot#@object# with gun", then I see no problem.
I must tell the player in advance. Thought so. (Had already coded 'shoot #@object#' to execute 'shoot #@object# with shooting item', but that didn't resolve my issue.)
Thanks, Paul.

paul_one
12 May 2009, 20:42Well, the only way to not prompt the user is to do your own disambiguation - and even then there's no garuntee that you won't prompt him.
"as little as possible" is "as little as possible depending on what objects are around at the time".
"as little as possible" is "as little as possible depending on what objects are around at the time".