Take gold from a PC in a conversation and make sure he has enough to Pay[edit | edit source]

This is fairly simple to do, the harder part seems to be getting the Conversation right. One thing to keep in mind when doing a conversation is that the line you don’t want displayed unless a certain condition is met comes before, lets call it the Default line. Take a look at the example.

+Root 
NPC – Hello, it will be 50 gold for a slap in the face.
PC – Ok. Pay 50 gold.
NPC – You don’t have enough money.
PC – [End Dialog]
NPC – Great! <Slap>
PC – Thanks! [End Dialog]
PC – No Way![End Dialog]

We don’t want the line NPC – You don’t have enough money. to appear unless he has enough gold to pay. So that’s were we will put the check, in the "Starting Condition" of the text node.

Place this script in the "Text Appears When" hook of the text line you don’t want to show unless the PC don’t have enough money to pay.

int StartingConditional()
{
    object oPC = GetPCSpeaker();
    if(GetGold(oPC) < 50) // Set the gold amount you want.
        {
        return TRUE; // Return TRUE if he has less than expected amount
        }
    return FALSE; // return FALSE otherwise. (do not display text)
}

If the above script is TRUE then that text node will show to the PC instead of the one below it. If it is FALSE, then the next text line will appear.

Now we need to take the gold, if he has enough. In the “Actions Taken” script handle of the NPC – Greate! <Slap> text node place the following script.

////////////////////////////////////////////////////////
// Take Gold from PC
////////////////////////////////////////////////////////
void main()
{
   TakeGoldFromCreature(50, GetPCSpeaker(), TRUE);
}
//End

This is a simple script from the script wizard. It takes 50 gold from the PC speaking to the NPC and then destroys it. If you want the NPC to keep the gold then change the TRUE to FALSE.

Community content is available under CC-BY-SA unless otherwise noted.