Okay, after countless hours of searching just this... I still don't get it. I'm learning the basics of scripting and can only do certain things I've seen done before (Generally, I know something works, I have no idea why it works.)
Well anyway, I'm building my own module and using the script generators which mostly get my basic needs filled, BUT this is something it can't do. It steals the whole damn stack of items if I use the DestroyObject functions. And whatever I've tried and how I've modified it, I just can't get it to remove 1 item from a stack.
What I'm doing, is I made my custom lock picking and trap disarming system, and I have "Lockpick" items that you can stack (Because failure to open, breaks one, and if I used non-stackables it'd soon populate all of your inventory to carry enough picks.) and that's where I need this.
This is what I've got so far to work with, it's a modified (and non working) version of Lightfoot8's nice script to remove all the stacked items and pass rewards per stack. So I thought I could reverse it so it removes only 1 item of all the stacks... but of course my skills aren't good enough. If someone would give me a ready script with everything that it needs, and some simple explanations (not necessary, but it would be great
'>) as to why and how it works so I can learn this myself, that'd be seriously appreciated. (Attached is what I tried to do, turns out this is only a more complicated "destroy every item in stack with this tag" script, lol.)
#include "nw_i0_plot"
void main()
{
string sTag = "jer_rg_lockpick"; // Tag of items to take.
object oPC = GetPCSpeaker();
int nToTake = 1; // Number of items to take.
if ( nToTake)
{
TakeNumItems(oPC,sTag,nToTake);
}
}
Basicly, what I got under work, is a custom treasure chest system (for locked chests) that, once you "use" the chest, it brings up a conversation. On the conversation, you can pick: Try to pick the lock, try to force the lock and see if it is trapped. I've got the chest have variables (IsLocked) and (IsTrapped) Where "IsLocked" is 1 and "IsTrapped" is 0. So when the convo gets up, it rolls a dice for the trap (currently 36% possibility for the chest to be trapped) and if it does hit the precent, it sets IsTrapped to 1, which means that you will trigger the trap (1d100 dmg) if you try to force or pick the lock without seeing the trap and disarming it (This has tools too. A probe for Search and a Trap Toolkit for disarming, without them, you can't do it.) To see the trap, you must pass a DC (depends on the chest) for search. (All this done in conversation) and you can't see the roll and if it's successfull
'> But if you can't see it, and if there is no trap to see, you get "You spot no trap". Or if you see it, "You spot a trap" and then you can disarm it if you pass the check and have the toolkit. If you fail, it explodes on your face.
'>
Similar checks and all for the lockpicking, if you fail, you should lose 1 pick because it breaks. When the trap is disarmed or the lock is picked, those variables are set to 0 (And the chest will reset after a time to locked state after you close it. and sets the variable to 1 again) I think this idea I have is a fun one, and everything else seems to work except this lockpick breaking script. I hope I provided enough info for you guys to help me, heh. I'm looking for an "On actions taken" from conversation script that takes just 1 item from the stack of lockpicks. Thanks in advance.
Modifié par JerrodAmolyan, 10 juillet 2013 - 07:59 .