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);
}
Take all my hides ya doofus, not just one!
Débuté par
Grieyls
, août 01 2010 06:02
#1
Posté 01 août 2010 - 06:02
#2
Posté 01 août 2010 - 06:21
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;
}
#3
Posté 01 août 2010 - 06:40
For the most part... What's the StartingConditional?... kinda confused about that bit.
#4
Posté 01 août 2010 - 06:46
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
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
#5
Posté 01 août 2010 - 06:59
Wow... Thanks heaps
Modifié par Grieyls, 01 août 2010 - 06:59 .
#6
Posté 09 août 2010 - 06:56
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.
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.





Retour en haut






