Author Topic: How to make the Beggar take up itens automatically on the ground?  (Read 996 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #30 on: March 13, 2014, 12:50:04 am »


               

Lots in the same area.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #31 on: March 13, 2014, 02:06:51 am »


               

Pstemarie says "Lots in the same area" OK


 


Good job, henesua! EDITED and removed "GetObjectType(GetNearestObject(OBJECT_TYPE_ITEM)) && GetObjectType(oItem) &&"


 


(add inside void of OnHeartBeat Event beggar userdefinided)



//////////////////////////////////////////////////////////////
///////////////SCRIPT By WhiteTiger and henesua///////////////
//////////////////////////////////////////////////////////////

    //START - Beggar Pick Up Item
            object oItem = GetFirstObjectInShape(SHAPE_SPHERE, 25.0, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_ITEM);
            if (oItem!=OBJECT_INVALID)
    {
        ClearAllActions();
        ActionPickUpItem(oItem);
        return;
    }
    //END

//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////


               
               

               


                     Modifié par WhiteTiger, 13 mars 2014 - 10:28 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #32 on: March 13, 2014, 02:17:31 am »


               

You could set a local on any dropped item too.  This way if the original distance between the beggar and the dropped was too great say > 15 meters or so, the item could be flagged for pick up later with a local droppeditem set to 1 when the beggar gets closer to it, he would fire the pick up item code. Or as is, the beggar would just cover whatever distance there is to pick up said item.


Someone mentioned earlier this should only fire if PC and beggar are in the same area.


Sure on perception works for seeing an item.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #33 on: March 13, 2014, 04:34:24 am »


               

Get rid of this



GetObjectType(GetNearestObject(OBJECT_TYPE_ITEM)) && GetObjectType(oItem) &&

in the line



if (GetObjectType(GetNearestObject(OBJECT_TYPE_ITEM)) && GetObjectType(oItem) && oItem!=OBJECT_INVALID)

neither of those are giving you any meaningful information.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #34 on: March 13, 2014, 10:35:05 am »


               

henesua,


OK, I've edited and removed then.


 


I didn't understand the condition check... 


 


Could you explain what's oItem!=OBJECT_INVALID ?



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #35 on: March 13, 2014, 03:24:09 pm »


               oItem  --  is the item that we found near the beggar within the beggar's line of sight


OBJECT_INVALID  --  is a constant for a null object reference, meaning that it is a kind of "nothing" object.


!= is an operator used in making comparisons. This particular operator means "is not equal to"



So with all three together we have

The item near the beggar is not a null object


In plain English the entire if statement:

If oItem is valid execute the code between the curly braces
               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #36 on: March 13, 2014, 06:10:08 pm »


               


oItem -- is the item that we found near the beggar within the beggar's line of sight


OBJECT_INVALID -- is a constant for a null object reference, meaning that it is a kind of "nothing" object.


!= is an operator used in making comparisons. This particular operator means "is not equal to"



So with all three together we have

The item near the beggar is not a null object


In plain English the entire if statement:

If oItem is valid execute the code between the curly braces




 


I have no more doubt.


 


謝謝。



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
How to make the Beggar take up itens automatically on the ground?
« Reply #37 on: March 13, 2014, 07:00:48 pm »


               

I hope that helps unlock some doors for you as a scripter.