Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

Lockpick

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
Locked
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Lockpick

Post 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 :oops:
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: Lockpick

Post 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
This is not a url, clicking it is pointless
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Re: Lockpick

Post by wildflower »

Hirato wrote:that should be r_get_skill, not r_get_attr.
Of course... silly me :oops:
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"
	]
]
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Re: Lockpick

Post 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 ;)
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: Lockpick

Post 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
This is not a url, clicking it is pointless
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Re: Lockpick

Post 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.
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: Lockpick

Post 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
        ]
    ]
]
This is not a url, clicking it is pointless
Locked