Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: CB.. on Thu 23/10/2003 20:24:03

Title: Go to specific walkable areas?
Post by: CB.. on Thu 23/10/2003 20:24:03
is it possible to tell a character to go to a specific walkable area
im using quite a lot of switchable walkable areas and bringing in chracters to be randomly placed like this

character[GDTHREE].x=Random(320);
character[GDTHREE].y=Random(200);
MoveToWalkableArea(GDTHREE);

before fade in as i enter the rooms

it would be extremely handy if i could somtimes specify which walkable area the character
randomly appeared on..ie number 4 or 2 etc...

ive been getting round this by disable-ing certain areas then re-enabling them after the character has appeared..but it's messy stuff to write

allso is there by any chance a way to disable/enable ALL walkable areas (or regions ,hot spots etc) in one script

im using this approach at the moment

int ran=Random(5);
if (ran==0) GiveScore(-150) && SetObjectFrame(0,7,0,0);
else if (ran==1) RestoreWalkableArea(11) && RemoveWalkableArea(12) && RemoveWalkableArea(13) && RemoveWalkableArea(14) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,1);
else if (ran==2) RestoreWalkableArea(12) && RemoveWalkableArea(11) && RemoveWalkableArea(13) && RemoveWalkableArea(14) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,2);
else if (ran==3) RestoreWalkableArea(13) && RemoveWalkableArea(12) && RemoveWalkableArea(11) && RemoveWalkableArea(14) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,3);
else if (ran==4) RestoreWalkableArea(14) && RemoveWalkableArea(12) && RemoveWalkableArea(13) && RemoveWalkableArea(11) && RemoveWalkableArea(15) && SetObjectFrame(0,7,0,4);
else RestoreWalkableArea(15)&& RemoveWalkableArea(12) && RemoveWalkableArea(13) && RemoveWalkableArea(14) && RemoveWalkableArea(11) && SetObjectFrame(0,7,0,5);  


and it ain't pretty at all (excuse the word wrap)

would be so nice to be able to just script


RemoveWalkableArea(s)

and remove them all at one go..same with enable again etc.


or

RemoveWalkableArea(s)(2)(3)(4);  

to remove sets of areas etc

rather than naming them all one at a time?


Title: Re:Go to specific walkable areas?
Post by: scotch on Thu 23/10/2003 20:46:49
to place a character on a specific walkable area in a random position you could try something like


int xpos;
in ypos;
while(GetWalkableAreaAt (xpos, ypos)!=number of the area you want to place it at) {
xpos=Random(320);
ypos=Random(200);
}
character[GDTHREE].x=xpos;
character[GDTHREE].y=ypos;


You could disable all walkable areas with

int i=1;
while(i<16){
RemoveWalkableArea (i);i++;}

(Note I haven't tested either idea)

Title: Re:Go to specific walkable areas?
Post by: CB.. on Thu 23/10/2003 22:48:29
many thanks i'll try them out and see how i go on

plenty of food for thought there!

Title: Re:Go to specific walkable areas?
Post by: CB.. on Fri 24/10/2003 17:12:24
sorry for not having told yu how i got on with the areas on off script ,yu got me thinking and i have gottten distracted by using a dice throw for movement ,which simulates a board game type approach which is in the area of what i was doing with the walkable areas ;so it has me wondering which way to go on the script ..

this is a nice approach i think..

RestoreWalkableArea(11);

follwed by

int ran=Random(3);
if (ran==0) MoveCharacter(EGO,character[EGO].x,character[EGO].y+6);
else if (ran==1) MoveCharacter(EGO,character[EGO].x,character[EGO].y-6);
else if (ran==2) MoveCharacter(EGO,character[EGO].x+6,character[EGO].y);
else MoveCharacter(EGO,character[EGO].x-6,character[EGO].y);  

or to ignore walkable areas

int ran=Random(3);
if (ran==0) MoveCharacterDirect(EGO,character[EGO].x-6,character[EGO].y);
else if (ran==1) MoveCharacterDirect(EGO,character[EGO].x-12,character[EGO].y);
else if (ran==2) MoveCharacterDirect(EGO,character[EGO].x-18,character[EGO].y);
else MoveCharacterDirect(EGO,character[EGO].x-24,character[EGO].y);  

then

RemoveWalkableArea(11);



im' useing this sort of thing a lot  

if (AreCharactersColliding(EGO,GDOFF)==1){
int ran=Random(2);
if (ran==0) GiveScore(-10);
else if (ran==1) GiveScore(-0);
else GiveScore(-0);
}      

coupled with the random movemnet dice roll it can give me the sort of board game effect i was hankering after, so yu pointed at the problem form a different angle and really helped nice one!
Title: Re:Go to specific walkable areas?
Post by: CB.. on Sun 26/10/2003 13:12:16
hi again,
could yu advise me over using a timer to repeat a script ?

ive been experimenting with this

SetTimer(1,200);
if (IsTimerExpired(1)==1)
{int ran=Random(7);
if (ran==0) MoveCharacter(GDTWO,character[GDTWO].x-36,character[GDTWO].y);
else if (ran==1) MoveCharacter(GDTWO,character[GDTWO].x+34,character[GDTWO].y);
else if (ran==2) MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y-36);
else if (ran==3) MoveCharacter(GD,character[GD].x+34,character[GD].y);
else if (ran==4) MoveCharacter(GD,character[GD].x,character[GD].y-36);
else if (ran==5)MoveCharacter(GD,character[GD].x,character[GD].y+36);
else MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y+36);
}


i put it in the repeatedly execute section with a wait command
every five seconds the characters moved randonmly according to the script which was really usefull ..
but with the wait it disables the player interaction etc making the game unplayable;
is there an approach that does the same thing

would a counter do the same job but not pause the players control?
Title: Re:Go to specific walkable areas?
Post by: scotch on Sun 26/10/2003 13:56:37
Why is there a wait command? Where is it?
Title: Re:Go to specific walkable areas?
Post by: CB.. on Sun 26/10/2003 14:06:32
oh sorry like this

SetTimer(1,200);
if (IsTimerExpired(1)==1)
{int ran=Random(7);
if (ran==0) MoveCharacter(GDTWO,character[GDTWO].x-36,character[GDTWO].y);
else if (ran==1) MoveCharacter(GDTWO,character[GDTWO].x+34,character[GDTWO].y);
else if (ran==2) MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y-36);
else if (ran==3) MoveCharacter(GD,character[GD].x+34,character[GD].y);
else if (ran==4) MoveCharacter(GD,character[GD].x,character[GD].y-36);
else if (ran==5)MoveCharacter(GD,character[GD].x,character[GD].y+36);
else MoveCharacter(GDTWO,character[GDTWO].x,character[GDTWO].y+36);
Wait(200);
}



this worked exactly as i was hoping except of course that the player couldnt continue playing the game as he was pernamanetly in wait mode..
the NPC's behaved exactly as i was hoping..ie;they randomly moved round the screen every five seconds/

i have to find a way to make the script repeat every five seconds without putting the player in wait mode..