User Tag List

Results 1 to 4 of 4

Thread: Moving Enemies with an FFC

  1. #1
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,612
    Level
    24
    vBActivity - Bars
    Lv. Percent
    99.93%

    Moving Enemies with an FFC

    This is the second time I've encountered a bug like this. What I want to happen is for an enemy to follow the ffc around the screen. That doesn't happen. The enemy gets created and moved to the x,y coordinates of the ffc's original starting location, but as the ffc moves, the enemy stays put. The code IS moving the enemy each frame, as evidenced by the fact what the enemy doesn't move anywhere.

    Code:
    // =====================================
    // enemy_ghosting - This ffc will create
    // a specified enemy at the location of the
    // ffc.  It will set the enemy's HP to a 
    // defined value.  The enemy will be kept 
    // centered at the ffc.
    // Use to give an FFC "hit points" by creating
    // a fire enemy or shooter that moves with it.
    // D0 = The enemy ID you want to create.
    // D1 = The HP you want the enemy to have.
    // =======================================
    
    ffc script enemy_ghosting{
    
    	void run(int enemy_id, int hit_points){
    
    		npc ghost_enemy = npc CreateNPC(enemy_id);
    		ghost_enemy->HP = hit_points;
    		int x = this->X;
    		int y = this->Y;
    
    		while (true){
    
    			ghost_enemy->X = x;
    			ghost_enemy->Y = y;
    			int x = this->X;
    			int y = this->Y;
    			Waitframe();
    
    		} // end of while loop
    
    	} // end of void run
    
    } // end of enemy_ghosting

  2. #2
    Developer
    ZC Developer
    jman2050's Avatar
    Join Date
    Jun 2001
    Location
    Do you really need to know
    Age
    37
    Posts
    3,883
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    5,709
    Level
    23
    vBActivity - Bars
    Lv. Percent
    46.21%

    Re: Moving Enemies with an FFC

    Code:
    ghost_enemy->X = x;
    ghost_enemy->Y = y;
    int x = this->X;
    int y = this->Y;
    Waitframe();
    You're not doing what you think you're doing. What you're indeed doing is setting the enemy's X/Y to the X/Y defined at the start of the script, and then you declare two NEW variables (the fact that they're named the same is of no consequence, by using int x you're declaring a new variable. I'm not sure if it's supposed to be legal, but that's how it works currently).

    Just take out the int x, int y and replace it with just x and y, and you should be fine.
    AGN's Resident Zelda Classic Developer and Sonic the Hedgehog Fanboy

  3. #3
    Octorok
    Join Date
    Oct 2003
    Location
    Monsteropolis
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,147
    Level
    11
    vBActivity - Bars
    Lv. Percent
    62.14%

    Re: Moving Enemies with an FFC

    A couple of questions about the script in general:

    • Are int x/y even necessary? I'm not exactly seeing why you can't just manipulate this->X/Y and set it to them at the moment.
    • Wouldn't npc ghost_enemy be invalid by the second frame? You might need to specify its number as a parameter and reload it if you run into any problems...
    Crash Man is the coolest Robot Master ever! Well, aside from Skull Man, Elec Man, Quick Man, Gemini Man, Shadow Man... ahh, forget it!

    Megaman: "Who cares if it's peacetime? You're an inventor, damnit - MAKE SOMETHING!"
    Dr Light: " 'Necessity is the mother of invention.' "
    Megaman: "Good, I'm hungry. Go invent me a sandwich."

  4. #4
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,612
    Level
    24
    vBActivity - Bars
    Lv. Percent
    99.93%

    Re: Moving Enemies with an FFC

    Yea, the x and y are necessary. I don't know why, but when I set this code up like so:

    Code:
    ghost_enemy->X = this->X;
    ghost_enemy->Y = this->Y;
    It would spawn them at 0,0 and never move em. I have no idea why; there were no complicating factors. (Single ffc, no other scripts, no movement.)

    As to your second question: No, it doesn't get "invalidated" by the second frame. ghost_enemy is declared as pointing to the npc that the script just gave birth to, and keeps pointing at it each frame until you re-assign it. There IS a problem when the enemy dies, however. What appears to happen is the script just grabs another enemy on the screen without being prompted. If there are no more enemies, it will crash. I'm trying to work around this.

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