Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: on Fri 31/10/2003 15:31:13

Title: SPECIAL MOVEMENTS
Post by: on Fri 31/10/2003 15:31:13
Hello guys,

I was hopping to know if everyone here can arrange a solution to my problem.
I know the MOVETOHOTSPOT function and MOVESTRAIGHT fuctions, etc... butthese functions do not allow me to make my HERO move to a HOTSPOT, CHARACTER or OBJECT in the background and, at the same time, allow the PLAYER to do anything else (interactions with the environment).

The MOVETOHOTSPOT function for example is a BLOCKING call. Any non-blocking calls for things like: MOVE to HOTSPOTS, MOVE to CHARACTERS and MOVE to OBJECTS?

Help!!
Thanks a lot in advance!
Title: Re:SPECIAL MOVEMENTS
Post by: Squinky on Fri 31/10/2003 15:39:23


MoveCharacterDirect should do ya....

Unless you need something else?
Title: Re:SPECIAL MOVEMENTS
Post by: Isegrim on Fri 31/10/2003 15:41:24
Could you use the "MoveCharacter function"? It's non-blocking.
If you have moving objects or characters you want to move to, you may have to get the appropriate coordinates in a "repeatedly execute" function btw.
Title: Re:SPECIAL MOVEMENTS
Post by: Ginny on Sat 01/11/2003 20:54:16
I though MoveCharater was blocking.. that's what MoveCharacterBackground is for, no?
Title: Re:SPECIAL MOVEMENTS
Post by: Ishmael on Sun 02/11/2003 10:26:11
MoveCharacter is not blocking. That's what's run when the walk mode is used, right?
Title: Re:SPECIAL MOVEMENTS
Post by: Timosity on Mon 03/11/2003 03:55:41
MoveCharacter might not be blocking but most of the time in script, after it, you use

while (character[EGO].walking) Wait(1);

which in turn makes it blocking anyway

you can get around it in rooms repeatedly execute if you use

if (character[EGO].walking==0) {

continue script here

}
Title: Re:SPECIAL MOVEMENTS
Post by: Mr Jake on Mon 03/11/2003 21:52:33
If you wanted this wouldnt you then want to disable the walk interaction for the player.. or he could just walk and cancel the interaction (Im guessing the hero is being pulled towards something andmust do something to stop it???).. How would you do that?
Title: Re:SPECIAL MOVEMENTS
Post by: on Wed 05/11/2003 00:18:52
Hello again, dear friends,

Regarding my first question... I think you all misunderstood me.
What I would like to obtain is a MOVETOHOTSPOT, MOVETOCHARACTER and MOVETOOBJECT function. However, AGS doesn't have these funtions in a non-blocking mode (Movetohotspot - is a blocking call). I want the HERO to respect the walkable areas, the hotspots, etc. I don't want a "move direct" function.

What I request will be very useful for when the player looks, for example, to a certain area in the screen (a hotspot, for example) - and we want the hero to walk to that THING (Character, Hotspot or Object) in the background, so if we want to cancel that action it can be cancelled. Got it? :)

So, how could I do such a thing, if the there is no AGS functions for MOVETOHOTSPOT, MOVETOCHARCATER and MOVETOOBJECT as non-blocking calls. Any bright ideas?

Thanks again, in advance.

PS: There is no MOVECHACATERBACKGROUND function, as one of the forum guy mentioned. :)
Title: Re:SPECIAL MOVEMENTS
Post by: Timosity on Wed 05/11/2003 04:01:45
I understood what you said, I think I just need to explain it a bit more, but I think you must mean a non player character moving, cause it's a bit confusing in your first post where you say 'Hero' and 'Player' (which one is your player character and which one is the non player character)

this is what I suggested with a bit more explanation.

// script for room: Repeatedly execute
if (GetGlobalInt(10)==1){ // you have to set globalint 10 to 1 for for this to happen

MoveCharacter(NPC,248, 147); // instead of a walk to point, just set the walk to coordinates in the movecharacter
SetGlobalInt(10,2); // for next stage (so it doesn't loop)
}



if (GetGlobalInt(10)==2){
if (character[NPC].walking == 0) {
//*****you can add more script here****eg. animate, or walk somewhere else
SetGlobalInt(10,3); // for next stage
}
}


etc, you can add more movements, animation whatever, using this method and still have control of your PLAYER character, eg. while NPC is walking to the spot, you can look at anything, walk anywhere, whatever you like.

I hope that is a bit clearer, but it works, I've used it a lot.

~Tim
Title: Re:SPECIAL MOVEMENTS
Post by: Scorpiorus on Wed 05/11/2003 07:24:39
What Timosity says. In addition this http://www.agsforums.com/yabb/index.php?board=6;action=display;threadid=6587;start=msg80512#msg80512 (http://www.agsforums.com/yabb/index.php?board=6;action=display;threadid=6587;start=msg80512#msg80512) thread about cancelling a blocking action.

~Cheers
Title: Re:SPECIAL MOVEMENTS
Post by: a-v-o on Wed 05/11/2003 18:17:09
Hello Phoenix,

it seems to me that you're still misunderstood. In fact your required nonblocking-functions don't exist. Maybe you can simulate a non-blocking MoveCharacterToHotspot with a combination of GetHotspotAt, GetHotspotPointX/Y and MoveCharacter.

Title: Re:SPECIAL MOVEMENTS
Post by: SSH on Wed 05/11/2003 18:57:05
function MoveCharacterToHotspotNB (int CHARID, int hotspot) {
MoveCharacter(CHARID, GetHotspotPointX(hotspot), GetHotspotPointY(hotspot));
}

function MoveCharacterToObjectNB(int CHARID, int object) {
MoveCharacter(CHARID, GetObjectX(object), GetObjectY(object));
}

and Moving to a character is maybe something less generic, as you wouldn't normally want to go to their exact location, maybe you would do:

MoveCharacter(CHARID, character[CHAR2].x-20, character[CHAR2].y);

Title: Re:SPECIAL MOVEMENTS
Post by: on Wed 05/11/2003 20:09:44
Hello again, friends...

I think we are getting there... almost getting there! :)
Let's make things a little bit less complicated.

The idea behind this post is that I want the HERO to move to something (OBJECT, CHARACTER or HOTSPOT) in the background (non-blocking mode) and then perform his action. For example, I LOOK at a tree, so the HERO will move to it and when he's there he will SAY SOMETHING. However, while walking to the tree, the player (us) can cancel that action to make another one - for example look at the sun in the sky.

Now, what is important is to make the HERO move to something (in the background) and once there he will perform an action, but only when there!! I need to check when "he's there" to perfor a certain action. What we must bear in mind is that a certain action can be cancelled with another one! :)

I hope this time things are clearer for everyone. Any help anyway? :)
Thanks a lot for your helps!!
Title: Re:SPECIAL MOVEMENTS
Post by: a-v-o on Wed 05/11/2003 21:14:00
a)
When you start the movement, then you can set a variable to an action value. When there is another click then the variable is either set to "no action" or to the new action.

You can use collide-functions, check coordinates, character.walking or whatever you want in repeatedly_execute to find out when the character is at the target.

b)
You use regions for the target position. Instead of setting a variable you switch on the target region. When the character enters the region then the action is started.
If the player clicks anywhere then all the regions are switched off. If he clicks on a new target then all regions are switched off, but the new target region is switched on.
Title: Re:SPECIAL MOVEMENTS
Post by: SSH on Thu 06/11/2003 12:16:27
Maybe something liek this would work:


int cancelflag=0;

function CancellableMoveCharacterToHotspot (int CHARID, int hotspot) {
cancelflag=1;
Wait(1);
cancelflag=0;
MoveCharacter(CHARID, GetHotspotPointX(hotspot), GetHotspotPointY(hotspot));
while(character[CHARID].walking && (cancelflag == 0)) {
Wait(1);
}
return (cancelflag==0);
}


Then where you use it (and import it, obviously)

if (CancellableMoveCharacterToHotspot(EGO, 2)) {
 // do your stuff
}