Random Code snippet

Talks that may or may not have anything to do with Hala or NWN

Moderator: Top Team

Post Reply
Sable
Honor Guard: Holy Church of Big Mouths
Posts: 387
Joined: Thu Jul 29, 2004 2:44 pm
Location: Leeds

Random Code snippet

Post by Sable »

Came across the halfling ****** *** quest today, at the end it enables you to turn in quest objects. You have to hand each one in separately, which can be a pain if you have a lot. On one hand this could have been done in a hurry and so is in that form, on the other because no one has had time to work out the code to do it in a smoother way. Just in case its the latter, heres the code. Use it or not, its up to you :)


the below code allowed for the posibility that the player could bargin with the quest giver for a higher pay out (trying to get the persuade skill to be relivant as much as possible) should be easy to chop it out if not needed. The successful check gave set a variable on the characer of 1, a failure set a 0

Code: Select all

#include "nw_i0_tool"

void main()
{
    int     nQuestObjectCount = 0;
    object  oPC = GetPCSpeaker ();

    object oItem = GetFirstItemInInventory (oPC);
    while (GetIsObjectValid (oItem)) {
        if (GetTag (oItem) == "[insert quest object tag]") {
            nQuestObjectCount++;
            DestroyObject (oItem);
        }
        oItem = GetNextItemInInventory (oPC);
    }
    if (GetLocalInt(oPC, "[Insert Quest Variable name") == 1) {
        GiveGoldToCreature (oPC, (15 * nQuestObjectCount));
        GiveXPToCreature (oPC,  15 * nQuestObjectCount);
        }
    else {
        GiveGoldToCreature (oPC, (10 * nQuestObjectCount));
        GiveXPToCreature (oPC,  10 * nQuestObjectCount);
        }
}
Post Reply