Making a "steal" command.

jaktube
I am currently working on a game in which you are a theif. I would like to make a command that let's you take something from another character. Like this:

>Steal sword from guard

You would get either:
You grab the item.

Or:

You are spotted attempting to steal.

I would like it to be able to increase the chance of successfully stealing by putting on different items of clothing (ie put on thieves hood, gain 10% better chance of stealing successfully). Please help as this seems like a lot of work. Also, if possible please tell me how to do it in the GUI editor. Thanks.

Edit 1: If it cant be done in the GUI editor, go ahead and give me the coding anyway.

Silver
I really have no idea how to give actions a percentage of success, I don't think it can be done in the interface though. Expect the coders to be along shortly for that. In terms of implementing items that can be worn there's a wearable library that can be added to a game and it works.

Download file from opening post

viewtopic.php?f=10&t=2901

Copy the file wearable.aslx into your gamedirectory and add it to 'Advanced/Included Libraries'.



http://docs.textadventures.co.uk/quest/ ... rary2.html

Avantar
I am no coder, but you can create a command with a pattern.
Below is a snippet from the top of my head that I would try. You will have to define your conditions to your liking - below is just an example.
For the 50% chance there is a Boolean statement for percentage, but I can't remember it. You might use GetRandomInt(1,2) for a 50% chance being either a 1 or a 2.
If the random number is 1 - do this or if it is 2 do that....
Hopefully this is putting you on the right path.

<command name="steal_stuff">
<pattern>steal #text# from #text2#</pattern>

object_x = GetObject (text)
if (object_x = null) {
foreach (obj, GetAllChildObjects(game.pov.parent)) {
if (LCase(GetDisplayAlias(obj)) = text) {
texts = obj.name
object_x = GetObject (texts)
}
}
}
foreach (obj, GetDirectChildren(game.pov.parent)) {
if (LCase(GetDisplayAlias(obj)) = text2 or LCase(GetDisplayName(obj)) = text2) {
text2 = obj.name
object_stealing = GetObject (text2)
}
}
if (not IsDefined("object_stealing")) {
msg ("There is no-one here by that name to steal from.")
}
else if (object_x = null) {
msg ("The guard is not carrying that item.")
}
else {
msg ("You steal a " + object_x.alias + " from the guard.")
MoveObject (object_x, game.pov)
}
}

HegemonKhan
the hardest part is the equipment and implementing it with your stealing

as the stealing check itself is pretty simple:

GUI~Editor: run as script -> add a script -> scripts -> if -> [EXPRESSION] -> (type in the below)

RandomChance (percent value): so the range of values is 0 to 100

if (RandomChance (player.steal_integer) = true) {
// take items scripting: so the 'player' now has them
}

---------

conceptually of what you need to do via code or GUI~Editor:

(this example is based upon using an object list to define what equipment is equipped upon you: if it's in, added to, the object list, then it is 'equipped', and all other items aren't 'equipped', and also I'm just using equipment as an example, but obviously you should steal from the target's full 'item' object list, and usually too you wouldn't steal from what is equipped... I just realized this now, after I've already gave this example, laughs. if you need help, I'll craft a full code for you, but when I can find the time to do so... sighs)

you need to put all your (to be equipped) equipment into your 'equipped' object list (Object List, because, then you can do a 'foreach' script to add their 'XXX' (stealing) Integer Attributes together, which you would then use for the 'RandomChance' code line:

http://docs.textadventures.co.uk/quest/ ... hance.html
~and~
http://docs.textadventures.co.uk/quest/ ... reach.html
http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... aries.html

to get your steal integer:

steal_x = ToInt (0)
foreach (item_x, player.equipped_objectlist) {
if (HasInt (item_x, "steal_integer") = true) {
steal_x = ToInt (steal_x) + ToInt (item_x.steal_integer)
}
}
player.steal_integer = ToInt (steal_x)
if (player.steal_integer > 100) {
player.steal_integer = 100
} else if (player.steal_integer < 0) {
player.steal_integer = 0
}


'steal' Verb:

(this = your target character object that you're trying to steal from, use the 'this' word, don't change it to something else)

(the 'this' is a special thing that will get the object, whatever or no matter what it is, be it an 'orc' or a 'rogue' npc~enemy Object)

foreach (item_x, this.equipment_objectlist) {
if (RandomChance (player.steal_integer) = true) {
item_x.parent = player
}
}

The Pixie
I think you would need to do this as a command, as you are wanting to reference two objects.

The pattern as a regular expression would look like this (using the "useon" command as a guide):

^(steal|lift|pinch) (?<object1>.*) from (?<object2>.*)$

Then object1 is a variable that holds the item to steal, object2 the target.

jaynabonne
The main problem (and difficulty) with using "object" in your pattern is that (presumably) the object in question will belong to the one you're stealing it from... which means it won't be found when doing the pattern match in either the current room scope or your inventory scope. In other words, it's not visible as such in the world model.

You'd have to use "text" in the pattern and then do an object lookup based on that text - and handle the case where the target doesn't have the object!

The Pixie
Good point. So the pattern would be

^(steal|lift|pinch) (?<text>.*) from (?<object>.*)$

And you would have to search through the children of object for a match with text (remembering to check the alternative names too).

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

Support

Forums