User Tag List

Results 1 to 6 of 6

Thread: Majora attempts scripting.

  1. #1
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    1,197
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,388
    Level
    20
    vBActivity - Bars
    Lv. Percent
    94.01%

    Majora attempts scripting.

    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. @_@
    Last edited by Majora; 10-05-2012 at 01:58 PM.

  2. #2
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    35
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,621
    Level
    25
    vBActivity - Bars
    Lv. Percent
    1.45%
    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.
    I'm an author. If you're interested in checking out my works, you can find them on Amazon.com:


  3. #3
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    35
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,621
    Level
    25
    vBActivity - Bars
    Lv. Percent
    1.45%
    Lets try this...

    Code:
    ffc script Patrol{
        void run(){
        while(true){
    		if (ComboF[ComboAt(this->X+16, this->Y || this->Y+8 || this->Y+15)] == 96){ //Checks if the combo to the right has flag 96
    			this->Vx = -1;
    		}
    		else if (ComboF[ComboAt(this->X-1, this->Y || this->Y+8 || this->Y+15)] == 96){
    			this->Vx = 1;
    		}
    		else if ((this->X == Link->X-8 || this->X == Link->X+23) && (this->Y == Link->Y || this->Y == Link->Y +8 || this->Y == Link-> Y+15)){
    			this->Vx = 0;
    		}            
           Waitframe(); 
    }

    EDIT: Doesn't compile, because I'm a space case. What about this?

    Code:
    int PatrolV;
    
    ffc script Patrol{
        void run(){
        while(true){
    		if (Screen->ComboF[ComboAt(this->X+16, this->Y) || ComboAt(this->X+16, this->Y+8) || ComboAt(this->X+16, this->Y+15)] == 96 || this->X > 208){ //Checks if the combo to the right has flag 96
    			PatrolV = -1;
    		}
    		else if (Screen->ComboF[ComboAt(this->X-1, this->Y) || ComboAt(this->X-1, this->Y+8) || ComboAt(this->X-1, this->Y+15)] == 96 ||  this->X < -1){
    			PatrolV = 1;
    		}
    		else if ((this->X == Link->X-8 || this->X == Link->X+23) && (this->Y == Link->Y || this->Y == Link->Y +8 || this->Y == Link-> Y+15)){
    			this->Vx = 0;
    		}
    		else {this->Vx = PatrolV}
    	Waitframe(); 
    	}
    }
    Last edited by CJC; 10-05-2012 at 04:59 PM.

  4. #4
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    1,197
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,388
    Level
    20
    vBActivity - Bars
    Lv. Percent
    94.01%
    ComboF is undeclared. ;_;

  5. #5
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    35
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,621
    Level
    25
    vBActivity - Bars
    Lv. Percent
    1.45%
    I'm sorry I'm so inept at this. I'll try again.

    Code:
    ffc script Patrol{	
        void run(){
        while(true){
    		if (this->X > 208){
    			this->Vx = -1;
    		}
    		else if (this->X < -1){
    			this->Vx = 1;
    		}
    		else if ((this->X == Link->X-8 || this->X == Link->X+23) && (this->Y == Link->Y || this->Y == Link->Y +8 || this->Y == Link-> Y+15)){
    			this->Vx = 0;
    		}
    	Waitframe(); 
    	}
    }
    EDIT: Getting closer!

    Code:
    int PatrolV = 1; //The guard will begin by moving to the right
    
    ffc script Patrol{	
        void run(){
        while(true){
    		if (this->X > 208){
    			PatrolV = -1;
    		}
    		else if (this->X < 1){
    			PatrolV = 1;
    		}
    		if ((((this->X == Link->X-8) && (PatrolV == 1)) || ((this->X == Link->X+23) && (PatrolV == -1))) && (this->Y == Link->Y || this->Y == Link->Y +8 || this->Y == Link-> Y+15)){
    			this->Vx = 0;
    		}
    		else {this->Vx = PatrolV};
    	Waitframe(); 
    	}
    }
    Last edited by CJC; 10-05-2012 at 05:42 PM.

  6. #6
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    1,197
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,388
    Level
    20
    vBActivity - Bars
    Lv. Percent
    94.01%
    Everything works except the guard only stops once in each direction if it bumps into link. How to make it always stop if it bumps into link? then wait until link moves along the Y axis a certain distance before resuming its movement.

    Code:
    int PatrolV;
    
    ffc script Patrol{    
        void run(int MaxX, int MaxY, int npcissolid, int MinX, int MinY, int cbo){
        int tho=(this->TileHeight*16-16);
        while(true){
            if (this->X > MaxX){
                PatrolV = -.75;
                this->Data = cbo+1;
            }
            else if (this->X < MinX){
                PatrolV = .75;
                this->Data = cbo;
            }
            if ((((this->X == Link->X-12) && (PatrolV == .75)) || ((this->X == Link->X+23) && (PatrolV == -.75))) && (this->Y == Link->Y || this->Y == Link->Y +12 || this->Y == Link-> Y+15)){
                this->Vx = 0;
            }
            else {this->Vx = PatrolV;}
            //This enables the NPC to be solid without having to lay a solid combo under it.
            if (npcissolid>0){
                if ((Abs(Link->X - this->X) < 10) && 
                    (Link->Y <= this->Y+tho + 12) && (Link->Y > this->Y+tho+8)){Link->Y = this->Y+tho+12;}
                
                if ((Abs(Link->Y - this->Y-tho) < 10) && 
                    (Link->X >= this->X - 12) && (Link->X < this->X-8)){Link->X = this->X-12;}
            
                if ((Abs(Link->X - this->X) < 10) && 
                    (Link->Y >= this->Y+tho - 12) && (Link->Y < this->Y+tho-8)){Link->Y = this->Y+tho-12;}
            
                if ((Abs(Link->Y - this->Y-tho) < 10) && 
                    (Link->X <= this->X + 12) && (Link->X > this->X+8)){Link->X = this->X+12;}
            }
        Waitframe(); 
        }
    }
    }
    And also that chunk of code at the bottom for FFC pseudo-solidity, can someone edit it so that FFCs are only half solid? If this was a combo in the combo editor, only the bottom half would be pink.

    Double-also I want to remove the hard-coded speeds and just make it PURELY "if link is nearby, stop. if link is not nearby, resume paying attention to your speed values". That is, the ones on the FFC itself.
    Last edited by Majora; 10-09-2012 at 09:49 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social