Quote Originally Posted by Majora View Post
Code:
ffc script Patrol{
    void run(){
    while(true){
        if (this->X == Link->X+8 || Link->X-8) {
            this->Vx = 0;
            }
        if (this->X != Link->X+8 || Link->X-8) {
            this->Vx = 1;
            }
            
       Waitframe(); 
}
}
}
What this is supposed to do is move the FFC at a constant speed, stopping if it bumps into link. I have a vague idea of what i'm doing but naturally, it's not working. The FFC moves, sure, but it just zooms right by link. Before I made some edits the FFC would stop if it was completely overlapped with link. It was odd. I put link against a corner (of solid combos) and the FFC would stop. but it wouldn't stop no matter what otherwise. The lack of intuition to this backwoods game engine will be the aneurysm of me.

This is a WIP script, taking it one step at a time. I don't want this to turn into a 300-line block of code for something as simple as moving a FFC between two points and being wary of link. However, the following behavior is what I'd like to achieve after working on this script some more:

FFC moving between two points (specified with those scripting combo flags).
------ When it reaches that point, the FFC switches combos or tiles. They will be consecutive either way.

Stops moving when Link bumps into the FFC. Resumes moving after he moves away.

I think that's it. I would love to be able to have guards that move between more than 2 points but I don't want to incur the wrath of Zscript. Siiiiiiiiigh. @_@
Okay, you're using the OR (||) command incorrectly. You need to specify the ENTIRE criterion on each side of the OR. Like this:
Code:
ffc script Patrol{
    void run(){
    while(true){
        if (this->X == Link->X+8 || this->X == Link->X-8) {
            this->Vx = 0;
            }
        if (this->X != Link->X+8 || this->X != Link->X-8) {
            this->Vx = 1;
            }
            
       Waitframe(); 
}
}
}
You need a "this->X ==" on BOTH sides of the OR. It should (might) work as intended now.

Also, I am so glad now that the [CODE] BBtag doesn't do the same function as [noparse] BBtag. It let me highlight the change to the code.



The reason the corner was stopping the guard had nothing to do with the corner... it had to do with Link being to the RIGHT of the guard. Since your script was not properly checking to the LEFT (that second side of the OR), the guard just zoomed along.

Since Link's XY position is recorded as the UPPER LEFT side of his tile, you might want to switch it three ORs... like so:
Code:
ffc script Patrol{
    void run(){
    while(true){
        if (this->X == Link->X || this->X == Link->X+8 || this->X == Link->X+15) {
            this->Vx = 0;
            }
        if (this->X != Link->X || this->X != Link->X+8 || this->X != Link->X+15) {
            this->Vx = 1;
            }
            
       Waitframe(); 
}
}
}

Also, since this script doesn't check y-proximity, the guard may stop if Link is all the way across the room. It may need a few extra lines, but let's just make sure it works on the horizontal first.