move char when?

Started by Nixxon, Thu 06/11/2003 09:58:08

Previous topic - Next topic

Nixxon

I want character 2 to move when character 1 has reached a certain loacation x/y.

How do i go about this?
sorry for the noob-ness :P
cheers

Gilbert

If you don't mind the script to be blocked, just do:
while((character[1].x!=BLAH)&&(character[1].y!=BLARGH)) Wait(1);
MoveCharacter(2, Blargh Blargh Blargh);

Otherwise you may need to set up something in the repeatedly execute and stuff (I'm to lazy to write these stuff, unless you really need it).

Nixxon

#2
Just thinking... would'nt it be somthing like "If" character 1 has reached as opposed to while? sorry again
basically just need the correct code for If (character is at location blah blah = 1) {

Gilbert

if would only execute once, but while would continue to execute when the expression in it is still true, so you need a while.

Nixxon

#4
Could I paste it in the repeated execute function?
e.g
if the expression is false (character 2 stays where he is and continues to run idle view)
if the expression is true (character 2 moves towards him)

just dont know how to correctly script it
thanks again

Edit - Tried this to test, sadly did not work. displays the speech as soon as you enter the room. not when player 1 finally recheases his xy co-ords (129,133).
any ideas?

 // script for room: Repeatedly execute
GetCharacterAt(129,133);
if (GetPlayerCharacter()==1)
DisplaySpeech(EGO , "My name is ego");

 // script for room: First time player enters screen
MoveCharacterDirect (EGO, 129, 133);  


SSH

#5
GetCharacterAt tells you which character is at that location, not whether the player has reached that location, and you would need to do something with the return value form it, anyway. GetPlayerCharacter is used for when you have more than one character than can be played with.  Just modify Gilbert's code a bit and put it in rep_ex:

// script for room: Repeatedly execute

if((character[EGO].x==129)&&(character[EGO].y==133) && (GetGlobalInt(99)==0)) {
SetGlobalInt(99, 1);
MoveCharacter(2, newx, newy);
}

12

Gilbert

Yes but for repeatedly execute (non blocking now), you may add some checking to it, otherwise, the same action would happen whenever the character 1 had reached that spot (worst of all, char 1 would stop at that pt, so the codes would be executed EVERY game loop from there).

And, my mistake, I wrongly used the &&, the following should work:

while((character[1].x!=BLAH)||(character[1].y!=BLARGH)) Wait(1);
MoveCharacter(2, Blargh Blargh Blargh);

Nixxon

Great, thanks for that guys :D

SMF spam blocked by CleanTalk