My problems:
-> Gatherers (sometimes) get stuck in the resources when trying to go back to the base
-> Gatherers do not continue to next nearest resource when the current is finished
my [step] event for the Gatheres (objCitizen1)
//CLICKING ON ROCKS
if selected==1 then
{
if mouse_check_button_pressed(mb_right) then
{ //gathering: 0=none 1=wood 2=food 3=rock
if instance_place(mouse_x,mouse_y,objRock) then
{
i=instance_place(mouse_x,mouse_y,objRock);
gathering=3;
}
else
{ if (!gathering==0) then {gathering=0}
else
{
movepointx=mouse_x;
movepointy=mouse_y;
alarm[0]+=distance_to_point(movepointx,movepointy)+30;
if movingtopoint==0 then
{ movingtopoint=1; }
}
}
}
}
if movingtopoint=1 then
{ //MOVE TO MOUSE CLICK POINT
mp_potential_step(movepointx,movepointy,1,false);
}
if (gathering==3) then
{
if instance_exists(i) then
{
ib=instance_nearest(x,y,objBase);
if rock>=rockmax then
{ mp_potential_step(ib.x,ib.y,1,false); } //go to resouce
else
{ mp_potential_step(i.x,i.y,1,false); } //return to base
if (!movingtopoint==0) then { movingtopoint=0; }
if
( place_meeting(x+1,y ,i) //left
or place_meeting(x+1,y-1,i) //topleft
or place_meeting(x ,y-1,i) //top
or place_meeting(x+1,y-1,i) //topright
or place_meeting(x-1,y ,i) //right
or place_meeting(x+1,y+1,i) //bottomright
or place_meeting(x ,y+1,i) //bottom
or place_meeting(x-1,y+1,i) //bottomleft
) then
{
x=xprevious; y=yprevious;
if gatherable=1 then
{
alarm[1]=rocktime;
gatherable=0;
if rock<rockmax
{
rock+=1;
if i.rock>0 then
{ i.rock-=1 } else { i=instance_nearest(x,y,objRock); }
}
}
}
}
}
if
( place_meeting(x+1,y ,objBase) //left
or place_meeting(x+1,y-1,objBase) //topleft
or place_meeting(x ,y-1,objBase) //top
or place_meeting(x+1,y-1,objBase) //topright
or place_meeting(x-1,y ,objBase) //right
or place_meeting(x+1,y+1,objBase) //bottomright
or place_meeting(x ,y+1,objBase) //bottom
or place_meeting(x-1,y+1,objBase) //bottomleft
) then
{
if rock>=0 then
{
global.rock+=rock;
rock=0;
}
}
Any available help is appreciated.
Edited by SlipknLov, 05 March 2012 - 03:01 AM.











