Author Topic: nwnx_funcs ActionUseItem()  (Read 385 times)

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
nwnx_funcs ActionUseItem()
« on: September 26, 2012, 05:59:05 pm »


               i fear that the nwnx boards aren't as frequented here, so i'm reposting my question to them to this audience, to see if i can pick up additional answers here:

i had a question about ActionUseItem().  from the .nss file:

void ActionUseItem (object oItem, object oTarget, location lTarget, int nProp) {
    object oArea = GetAreaFromLocation(lTarget);
    vector vVec = GetPositionFromLocation(lTarget);

    if (!GetIsObjectValid(oArea))
        return;
    SetLocalString(OBJECT_SELF, "NWNX!FUNCS!ACTIONUSEITEM",
        ObjectToString(oItem) + "¬" + ObjectToString(oTarget) + "¬" +
        ObjectToString(oArea) + "¬" + FloatToString(vVec.x)   + "¬" +
        FloatToString(vVec.y) + "¬" + FloatToString(vVec.z)   + "¬" +
        IntToString(nProp));
}

void ActionUseItemAtLocation (object oItem, location lTarget, int nProp=0) {
    ActionUseItem(oItem, OBJECT_INVALID, lTarget, nProp);
}

void ActionUseItemOnObject (object oItem, object oTarget, int nProp=0) {
    ActionUseItem(oItem, OBJECT_INVALID, GetLocation(oTarget), nProp);
}

the ActionUseItemOnObject() just seems wrong.  it doesn't actually use the item on the object, it obviously just uses the item at the location of the object.  i have to think that this was intentional because i don't think virusman would make a mistake like this.  is it a limitation of the function/engine to not allow for it?

when i get a chance, i want to check what would happen if the function were instead:

void ActionUseItemOnObject (object oItem, object oTarget, int nProp=0) {
    ActionUseItem(oItem, oTarget, GetLocation(oTarget), nProp);
}
i'm also curious about what it's doing behind the scenes.  like if it will still default to the location and ignore the object altogether.  i guess i have the source code for the plugin to answer that question for me. 
               
               

               


                     Modifié par acomputerdood, 26 septembre 2012 - 05:00 .
                     
                  


            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
nwnx_funcs ActionUseItem()
« Reply #1 on: September 27, 2012, 01:44:27 am »


               just to follow up, the original ActionUseItemOnObject() does not target the object you call it on, as the code suggests.  luckily, the update i posted does correctly use the item on the object.
               
               

               
            

Legacy_nwnsmith

  • Full Member
  • ***
  • Posts: 125
  • Karma: +0/-0
nwnx_funcs ActionUseItem()
« Reply #2 on: September 28, 2012, 05:25:29 pm »


               Great thread, I would love to see more support for nwnx_funcs here. There are regular questions asked in those forums by beginners (our future experts) but the project is not targeted towards them and thus most of the experienced individuals are working on new content. This is valuable but again, this forum might serve as a better place for beginners to find help and utilization for the product.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
nwnx_funcs ActionUseItem()
« Reply #3 on: January 09, 2016, 12:10:01 am »


               

I was curious about this as well. Was looking to use this instead of hackery such as SignalEvent -> EventActivateItem