Page 1 of 1
Lockpick
Posted: September 12th, 2011, 4:08 pm
by wildflower
I'm trying to make a lockpick script in the svn version of PAS-rpg.
I have a animated chest that should open if players stealth is more than 1, and I have tried this:
Code: Select all
r_script_signal interact [
if (< (r_get_attr player $SKILL_STEALTH) 1) [
echo "You do not have the skill to open this lock"
] [
r_trigger self
]
]
Shouldn't this work? and if not... why not?
It works if I test it on a quest-related variable and I can see that a similar solution is used on the "ifdumb" function, althou I must admit that I can't wrap my brain around the whole "combine bitwise values" thing

Re: Lockpick
Posted: September 13th, 2011, 1:28 am
by Hirato
that should be r_get_skill, not r_get_attr.
all your script will do is trigger the "trigger" animation of the model though if the condition is met.
I assume I don't have to mention that trading isn't implemented and that you'd need to transfer items either through dialogue or dropping them to the floor
Re: Lockpick
Posted: September 13th, 2011, 3:09 am
by wildflower
Hirato wrote:that should be r_get_skill, not r_get_attr.
Of course... silly me
Hirato wrote:all your script will do is trigger the "trigger" animation of the model though if the condition is met.
I assume I don't have to mention that trading isn't implemented and that you'd need to transfer items either through dialogue or dropping them to the floor
I intend to just transfer the items of the chest to player inventory (r_remove talker/r_additem player) and make an echo "you found a healthpotion and 2 silver" or some thing like that.
For now the trading system I just use -2 like you use in the default game, and look forward to implementing trading so I can sell all my loot.
I have some thoughts on how to build a trading system, but for now I'll just leave the coding to someone who actually knows what they are doing
EDIT:
This is how the script looks now:
Code: Select all
r_script_signal interact [
if (< (r_get_skill player $SKILL_STEALTH) 1) [
echo "Raise your stealth skill to open this lock"
] [
r_trigger self
r_additem player 1 2
echo "You found two healthpotions"
]
]
Re: Lockpick
Posted: September 13th, 2011, 6:29 am
by wildflower
Here is the final script for a locked chest if anyone else should be interested.
Code: Select all
r_script_signal interact [
if ( = ($mychest_empty) 0) [ // mychest_empty is defined in variables.cfg
lockdificulty = 2 // dificulty 1
stealthskill = ( + (r_get_skill player $SKILL_STEALTH) 2)
lockpickresult = ( - (rnd ( * $stealthskill $stealthskill)) (rnd ( * $lockdificulty $lockdificulty)))
echo "lockpickresult = " $lockpickresult
if ( >= $lockpickresult 0) [
r_trigger self // open/close chest animation
r_additem player 1 2 // add two item 1 to player inventory
mychest_empty = 1
echo "You found two healthpotions"
] [
echo "Your lockpicking fail"
]
] [
r_trigger self // open/close chest animation
]
]
With some help from my husband, I added a difficulty option.
I also made a variable in variables.cfg so you can't loot the same chest twice

Re: Lockpick
Posted: September 13th, 2011, 8:58 am
by Hirato
wildflower wrote:Here is the final script for a locked chest if anyone else should be interested.
Code: Select all
r_script_signal interact [
if ( = ($mychest_empty) 0) [ // mychest_empty is defined in variables.cfg
lockdificulty = 2 // dificulty 1
stealthskill = ( + (r_get_skill player $SKILL_STEALTH) 2)
lockpickresult = ( - (rnd ( * $stealthskill $stealthskill)) (rnd ( * $lockdificulty $lockdificulty)))
echo "lockpickresult = " $lockpickresult
if ( >= $lockpickresult 0) [
r_trigger self // open/close chest animation
r_additem player 1 2 // add two item 1 to player inventory
mychest_empty = 1
echo "You found two healthpotions"
] [
echo "Your lockpicking fail"
]
] [
r_trigger self // open/close chest animation
]
]
With some help from my husband, I added a difficulty option.
I also made a variable in variables.cfg so you can't loot the same chest twice

Like that you'd need to define a new variable for every chest.
I'd suggest using r_remove on the chest and r_additem on the player.
Though this means you can loot in multiple times, but you'll only get the items once. (
Apples Trees )
Also the global RPG variables don't work that way, there are plenty of examples in the demo and there are a few dummies (look near ifdumb) which do bitwise checks and toggles
Re: Lockpick
Posted: September 13th, 2011, 4:41 pm
by wildflower
Hirato wrote:Like that you'd need to define a new variable for every chest.
I'd suggest using r_remove on the chest and r_additem on the player.
Though this means you can loot in multiple times, but you'll only get the items once. (
Apples Trees )
Also the global RPG variables don't work that way, there are plenty of examples in the demo and there are a few dummies (look near ifdumb) which do bitwise checks and toggles
I see what you mean, and I like the idea of spawning a random number of items in a chest, but I wanted to implement a lockpick system (like they use in Morowind) where your lockpick's break (or maybe just wear out) if your attempt fail, and would need to store the status of the individual chests, otherwise you could use all your lockpick's on an empty chest.
I must admit that I don't really understand the bitwise checks and toggles, I understand the concept but can't figure out how to actually use it.
Re: Lockpick
Posted: September 13th, 2011, 10:32 pm
by Hirato
wildflower wrote:I must admit that I don't really understand the bitwise checks and toggles, I understand the concept but can't figure out how to actually use it.
I'm only using them as an example of how you're supposed to query and set them.
lock wise, there is a "lock" value on the containers you can check for and set to 0 after a successful lockpick
Code: Select all
r_script_signal interact [
r_select_container self [ //selects the container for configuration commands
if (r_container_lock_get) [ //retrieves the value of the lock
// attempt to unlock here
r_container_lock 0 // what to do on success
]
if (! (r_container_lock_get)) [
//remove items here and add them to actor inventory; r_loop_inv may come in handy here
]
]
]