Here is the complete code "untested" which works on a timer to support up to 5 simutaneous items seen by the mob as well as with a 120 second delay on picking up the item. It also deletes the item after it is picked up.
Should work in theory, just needs to be tested. Waypoint code also included
Code:
EventHandler SEE_ITEM(item)
{
if (debug == 1) { Say("SEE_ITEM Handler Fired");}
if (myself.c_ai0 <= 0)
{
myself.c_ai0 = item;
AddTimerEx(100002, 120000);
}
else if (myself.c_ai1 <= 0)
{
myself.c_ai1 = item;
AddTimerEx(100003, 120000);
}
else if (myself.c_ai2 <= 0)
{
myself.c_ai2 = item;
AddTimerEx(100004, 120000);
}
else if (myself.c_ai3 <= 0)
{
myself.c_ai3 = item;
AddTimerEx(100005, 120000);
}
else if (myself.c_ai4 <= 0)
{
myself.c_ai4 = item;
AddTimerEx(100006, 120000);
}
else
{// just pick it up
AddGetItemDesire(item, 10);
}
}
EventHandler GET_ITEM_FINISHED(item)
{
if (debug == 1) { Say("GET_ITEM_FINISHED Handler Fired");}
Say("The item belongs to me now!");
if (myself.c_ai0 == item)
{
myself.c_ai0 = 0;
}
else if (myself.c_ai1 == item)
{
myself.c_ai1 = 0;
}
else if (myself.c_ai2 == item)
{
myself.c_ai2 = 0;
}
else if (myself.c_ai3 == item)
{
myself.c_ai3 = 0;
}
else if (myself.c_ai4 == item)
{
myself.c_ai4 = 0;
}
DeleteItem1(myself, item, (OwnItemCount(myself, item)));
}
EventHandler MOVE_TO_WAY_POINT_FINISHED(way_point_index, next_way_point_index)
{
if (debug == 1) { Say("MOVE_TO_WAY_POINT_FINISHED Handler Fired");}
myself.i_ai4 = next_way_point_index;
AddTimerEx(100001, (GetWayPointDelay(varWayPointDelays, way_point_index)*1000));
}
EventHandler TIMER_FIRED_EX(timer_id)
{
if (debug == 1) { Say("TIMER_FIRED_EX Handler Fired");}
if (timer_id == 100001)
{
if (myself.i_ai4 > 0)
{
AddMoveToWayPointDesire(varWayPoints, varWayPointDelays, myself.i_ai4, 10);
}
else
{
AddMoveToWayPointDesire(varWayPoints, varWayPointDelays, 1, 10);
}
}
else if (timer_id == 100002)
{
AddGetItemDesire(myself.c_ai0, 10);
}
else if (timer_id == 100003)
{
AddGetItemDesire(myself.c_ai1, 10);
}
else if (timer_id == 100004)
{
AddGetItemDesire(myself.c_ai2, 10);
}
else if (timer_id == 100005)
{
AddGetItemDesire(myself.c_ai3, 10);
}
else if (timer_id == 100006)
{
AddGetItemDesire(myself.c_ai4, 10);
}
}