Aller au contenu

Photo

How to make the Beggar take up itens automatically on the ground?


  • Veuillez vous connecter pour répondre
37 réponses à ce sujet

#26
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Yeah, add 05 seconds of delay to start all actions with Beggar.

PC drop the item. 

Beggar Artificial Intelligence is disabled.So We have 5 seconds delay  of nothing action. After this 5 seconds, the beggar start MoveToObjectItem and PickUpItem Action. To finish Give default AI again. It's more realistic.



#27
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Well, now we have a perfect script for what we want. This works for any item that is on the ground and no matter how the item appeared on the ground.

 

Add this to Creature Beggar OnHeartBeat Event - specifically (save as a copy if you're using the original onheartbeat script).

//////////////////////////////////////////////////////////////
/////////////////////SCRIPT By WhiteTiger/////////////////////
//////////////////////////////////////////////////////////////

    //START Beggar - Pick Up Item System
            object oAllBeggar = OBJECT_SELF;
            if (GetObjectType(GetNearestObject(OBJECT_TYPE_ITEM)))
    {
        AssignCommand(oAllBeggar, ClearAllActions());
        AssignCommand(oAllBeggar, ActionPickUpItem(GetNearestObject(OBJECT_TYPE_ITEM)));
        return;
    }
    //END

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

Thanks all.



#28
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

If you have a lot of these beggars, that Heatbeat event is gonna eat up resources.


  • WhiteTiger aime ceci

#29
henesua

henesua
  • Members
  • 3 863 messages

I recommend you change the code to the following:

    //START Beggar (OBJECT_SELF) - Pick Up Item System
    object oItem    = GetFirstObjectInShape(SHAPE_SPHERE, 12.5, GetLocation(OBJECT_SELF), TRUE, OBJECT_TYPE_ITEM);

    if(oItem!=OBJECT_INVALID)
    {
        ClearAllActions();
        ActionPickUpItem(oItem);
    return;
    }
    //END

In addition that code snippet should probably execute in a userdefined heartbeat event unless this Beggar heartbeat event script, only executes on beggars.


  • WhiteTiger aime ceci

#30
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Pstemarie,

Are you saying about a lot of Beggars working in all game or area?



#31
Pstemarie

Pstemarie
  • Members
  • 2 745 messages

Lots in the same area.



#32
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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 .


#33
ffbj

ffbj
  • Members
  • 593 messages

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.



#34
henesua

henesua
  • Members
  • 3 863 messages

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.


  • WhiteTiger aime ceci

#35
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

henesua,

OK, I've edited and removed then.

 

I didn't understand the condition check... 

 

Could you explain what's oItem!=OBJECT_INVALID ?



#36
henesua

henesua
  • Members
  • 3 863 messages
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
  • WhiteTiger aime ceci

#37
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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.

 

謝謝。


  • henesua aime ceci

#38
henesua

henesua
  • Members
  • 3 863 messages

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


  • WhiteTiger aime ceci