[Help] Script StartingConditional, if TRUE then..
Krazenpox
Member Posts: 12
Hello, I need some help with a script, during a dialog I'd like to check if the player has an item in his inventory, if TRUE then destroy it and reward the player. With the script wizard I have created the simple conditional script:
PS: Is there an active community or forum about scripting help for newbies like me?
#include "nw_i0_tool" int StartingConditional() { // Make sure the PC speaker has these items in their inventory if(!HasItem(GetPCSpeaker(), "teteproprio")) return FALSE; return TRUE; }I don't know how to add the fact that if the player has the item, it will destroy it and give him reward. Is it possible? Thanks for your help
PS: Is there an active community or forum about scripting help for newbies like me?
0
Comments
It looks like you only checked take from the player to make that script.
(Sorry for my approximative english ).
Simple Version
Your goal is: if the condition is true then reward and destroy object, if false then nothing happens. For this we'll use the actions taken condition (aka, this happens when you trigger this part of the conversation).
First, our "pseudocode"...
if PC has item then
reward PC
destroy item
else
nothing
Now, our real code... Now let's get fancier.
Complicated Version
What if we don't want the reward script to fire UNLESS the PC has the item? We're going to use the "Text Appears When" tab for this and make a new script there: We put this script on a line (in the Text Appears When section) the PC gets like "Hey, I found that thing for you" and it won't appear as an option unless the PC has actually done so. Then put the first script on the Actions Taken to strip the item from the PC and reward the PC appropriately.
If you'd like a clearer example, I can whip up a simple module showing a basic conversation like this if you want to poke around in it (though probably not tonight, busy rewriting the Aielund Saga's weapon enchanted scripts to be cleaner and work with up to four henchmen).
should be
int nHasItem = GetIsObjectValid(GetItemPossessedBy(oPC, "teteproprio"));
A way around this would be to make the script that does the item removal and reward actually be placed on the Text Appears When node for the NPC:
int StartingConditional() { object oPC = GetPCSpeaker(); object oItem = GetItemPossessedBy(oPC, "teteproprio"); if (GetIsObjectValid(oItem)) { GiveGoldToCreature(oPC, 10000); GiveXPToCreature(oPC, 500); CreateItemOnObject("awesomereward", oPC); DestroyObject(oItem); return TRUE; } return FALSE; }
So you're looking at:
That said, unless this is for a PW (which wasn't said) I wouldn't worry too much about a deliberate exploit like this. If someone is determined to cheat, DebugMode is a hell of a lot easier. So if it's a major pain to fix a deliberate exploit, better to spend your time being productive. This isn't too bad of a case, though, and I wasn't thinking with security in mind since it seemed unnecessary.
TR