Author Topic: Take all my hides ya doofus, not just one!  (Read 660 times)

Legacy_Grieyls

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
Take all my hides ya doofus, not just one!
« on: August 01, 2010, 07:02:17 pm »


               Ok, what I want to achieve here is have an NPC take all items of one type and reward the PC for each item. For instance, my PC may have 15 animal hides and goes to a leather worker and sells them. I did up a script that'll take one hide at a time. kinda tedious to keep opening the conversation over and over to sell each hide. Specially when you got a gazillion of them.

This is my script.... So what addition do I need to make the above happen?

void main()
{
    object oPC = GetPCSpeaker();
    object oItem;
    oItem = GetItemPossessedBy(oPC, "SH_MinkHide");
    if (GetIsObjectValid(oItem))
        DestroyObject(oItem);
        RewardPartyGP(5, oPC, FALSE);
}
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Take all my hides ya doofus, not just one!
« Reply #1 on: August 01, 2010, 07:21:07 pm »


               here is my code which does what you want, will you be able to modify it yourself?

int StartingConditional()
{
object oPC = GetPCSpeaker();
object oItem = GetFirstItemInInventory(oPC);
int nCount;
 while(oItem != OBJECT_INVALID)
 {
  if(GetResRef(oItem) == "sh_it_lovec005")
  {
  nCount+= GetItemStackSize(oItem);
  DestroyObject(oItem);
  }
 oItem = GetNextItemInInventory(oPC);
 }
 if(nCount)
 {
 SetCustomToken(902,IntToString(nCount));
 GiveGoldToCreature(oPC,nCount*20);
 SetXP(oPC,GetXP(oPC)+nCount*10);
 return FALSE;
 }
return TRUE;
}


               
               

               
            

Legacy_Grieyls

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
Take all my hides ya doofus, not just one!
« Reply #2 on: August 01, 2010, 07:40:45 pm »


               For the most part... What's the StartingConditional?... kinda confused about that bit.
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Take all my hides ya doofus, not just one!
« Reply #3 on: August 01, 2010, 07:46:29 pm »


               It is so the conversation node he has it on ONLY starts if he has the proper stuff.



Another one with some extra comments for you.



// This script goes in the "Actions Taken" tab of a

// conversation.  It will reward the PC 10 gold and

// 10 XP for every item they possess with the tag

// "goblin_ear".

void main()

{

  // First, get the PC being spoken to

  object oPC = GetPCSpeaker();

  // Now, find the first item in that PC's inventory

  object oItem = GetFirstItemInInventory(oPC);

  // Start the loop.  The next statement says to

  // stay in the loop until "oItem" no longer points

  // to a valid object. This will happen as soon as

  // we've looped through every one of the PC's items.

  while (GetIsObjectValid(oItem))

  {

     // Check the tag on the current item

     if (GetTag(oItem) == "goblin_ear")

     {

        // Statements within these brackets will

        // be run for each item that matches the

        // "goblin_ear" tag.

        // The next two lines give the rewards:

        // 10 gold and 10 XP.

        GiveGoldToCreature(oPC, 10);

        GiveXPToCreature(oPC, 10);

        // Now take the ear from the PC.  Note that

        // this doesn't really take the ear and give

        // it to the NPC; it just destroys it. Why

        // do NPCs give money for these things,

        // anyway? Who wants a bunch of rotting ears

        // in their pockets?

        DestroyObject(oItem);

     }

     // Now move on to the next item

     oItem = GetNextItemInInventory(oPC);

  } // End while loop

} // End script
               
               

               
            

Legacy_Grieyls

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
Take all my hides ya doofus, not just one!
« Reply #4 on: August 01, 2010, 07:59:16 pm »


               Wow... Thanks heaps 'Posted
               
               

               


                     Modifié par Grieyls, 01 août 2010 - 06:59 .
                     
                  


            

Legacy_Styxx42

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Take all my hides ya doofus, not just one!
« Reply #5 on: August 09, 2010, 07:56:15 pm »


               These are pretty neat.
Thanks to bothsolution posts and the original Question.

Not trying to highjack this thread.  Hope this is in line.

So would one then make a item called goblin_ear and tag it as much and then, add it as an item to inventory of an edited monster\\encounter?  Say create a BlueFaced Tribe.

Just picturing a way to have a leveling\\money generation area in a small PW my friends and I HACK on.

Just wondering really. 
Very neat.

Thanks again to all parties.