Author Topic: Identifying Items script  (Read 398 times)

Legacy_LordLestat

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Identifying Items script
« on: December 16, 2010, 02:22:08 pm »


               I am trying to develope a script that goes on a placeable to identify all unidentified items in a PC's inventory at a cost per item. I got it identifying all items but am having a problem getting the cost to apply.

void IdentifyAll(object oObject, object oPC);
int GetNumIDItems(object oPC);
void main()
{
    object oPC = GetLastUsedBy();
    int nNumItems;
    int nGold = 250;
    int nGoldAmt = nNumItems * nGold;
    int nPCGold = GetGold(oPC);
    if(nPCGold >= nGoldAmt)
    {
        TakeGoldFromCreature(nGoldAmt, oPC, TRUE);
        IdentifyAll(oPC, oPC);
        IdentifyAll(OBJECT_SELF, oPC);
        SendMessageToPC(oPC, "Your items are all Identified!");
    }
    else
    {
        SendMessageToPC(oPC, "You don't have enough gold to identify all of the items!");
    }
}
void IdentifyAll(object oObject, object oPC)
{
    object oItem = GetFirstItemInInventory(oObject);
    while(oItem != OBJECT_INVALID)
    {
        if(!GetIdentified(oItem))
        {
            SetIdentified(oItem, TRUE);
        }
        oItem = GetNextItemInInventory(oObject);
    }
}
int GetNumIDItems(object oPC)
{
    int nNumItems = 0;
    object oItem = GetFirstItemInInventory(oPC);
    while(oItem != OBJECT_INVALID)
    {
        if(!GetIdentified(oItem))
        {
            nNumItems ++;
        }
        oItem = GetNextItemInInventory(oPC);
    }
   return nNumItems;
}

Thats what I got so far. Can anyone help a bit?
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Identifying Items script
« Reply #1 on: December 16, 2010, 02:38:37 pm »


               The solution is simple, you never call your GetNumIDItems() function in your void main() section of the script.

Just change the line:

int nNumItems;

to:

int nNumItems = GetNumIDItems(oPC);

And it should work.
               
               

               


                     Modifié par _Knightmare_, 16 décembre 2010 - 02:39 .
                     
                  


            

Legacy_LordLestat

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Identifying Items script
« Reply #2 on: December 16, 2010, 02:47:56 pm »


               Thanks I will try that. I knew it had to something simple I was just missing it.
               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Identifying Items script
« Reply #3 on: January 28, 2013, 10:21:04 pm »


               Howdy,
I am trying to come up with a StartConditional, Convo script that checks to see if a PC has a item and if the item is identified. Lots of did not compiles. I took the standard has item and tried adding
if(GetIdentified(oItem))
return FALSE;
return TRUE;
Also Tried adding it to the origanal if statement. Nope.
I got several scripts that made sense to me, unfotunately the compiler did not agree.
Any help out there ?
               
               

               
            

Legacy_LoA_Tristan

  • Jr. Member
  • **
  • Posts: 64
  • Karma: +0/-0
Identifying Items script
« Reply #4 on: January 28, 2013, 11:56:45 pm »


               

Ed Venture wrote...

Howdy,
I am trying to come up with a StartConditional, Convo script that checks to see if a PC has a item and if the item is identified. Lots of did not compiles. I took the standard has item and tried adding
if(GetIdentified(oItem))
return FALSE;
return TRUE;
Also Tried adding it to the origanal if statement. Nope.
I got several scripts that made sense to me, unfotunately the compiler did not agree.
Any help out there ?


HasItem() returns true or false so it doesn't actually save you an object that the script can start querying.  Maybe try the object function, GetItemPossessedBy(), instead?

ex:


int StartingConditional()
{
    object oItem = GetItemPossessedBy(GetPCSpeaker(), "TAG_OF_THE_ITEM");
    if (GetIsObjectValid(oItem)) if (!GetIdentified(oItem)) return TRUE;
    return FALSE;
}

               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Identifying Items script
« Reply #5 on: January 29, 2013, 04:28:48 pm »


               Here's the mass identifier script we use. It's pretty simple, and doesn't use a convo, but it may be of help to you regardless.


void main() {
    object oPC = GetLastUsedBy();
    object oCheck = GetFirstItemInInventory(oPC);
    int nCheck = 0;
    while (GetIsObjectValid(oCheck)) {
        if (!GetIdentified(oCheck))
            nCheck++;

        oCheck = GetNextItemInInventory(oPC);
    }
    if (nCheck == 0)
        FloatingTextStringOnCreature("You have no items in need of identification", oPC);
    else {
        int nGold = GetGold(oPC);
        int nCost = 120*nCheck;
        if (nGold < nCost)
            FloatingTextStringOnCreature("There is a 120gp charge per item. You are trying to identify " + IntToString(nCheck) + " items, costing " + IntToString(nCost) + "gp, and you only have " + IntToString(nGold) + "gp.", oPC);
        else {
            object oItem = GetFirstItemInInventory(oPC);
            int nCount = 0;
            while (GetIsObjectValid(oItem)) {
                if (!GetIdentified(oItem))
                    SetIdentified(oItem, TRUE);

                oItem = GetNextItemInInventory(oPC);
            }
            TakeGoldFromCreature(nCost, oPC, TRUE);
            FloatingTextStringOnCreature("Identifed " + IntToString(nCheck) + " items for " + IntToString(nCost) + " gold. Come again!", oPC);
            effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
        }
    }
}

Funky