User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: NPC data types crashing on NPC death

  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%

    NPC data types crashing on NPC death

    This is getting annoying. When you have a script that creates an NPC and a pointer to that NPC, it appears that it crashes without fail upon that NPC's death. This code, for instance, crashes upon the enemy's death.

    Code:
    // =====================================
    // enemy_hp_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.
    // This script will monitor the health of the 
    // creature it created, and either warps or
    // changes the combo of the FFC when the NPCs
    // health is below 10.
    // 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.
    // D2 = 0 -> Switch FFC combo
    //      Any other value -> Warp player
    // D2 = The destination DMAP.
    // D3 = The screen on the destination DMAP.
    // D4 = The number of this FFC (for this-> bug)
    // =======================================
    
    ffc script enemy_hp_ghosting{
    
    	void run(int enemy_id, int hit_points, int warp_or_change, int dest_dmap, int dest_screen, int this_ffc_number){
    
    		npc ghost_enemy = Screen->CreateNPC(enemy_id);
    		ghost_enemy->HP = hit_points;
    		int x = this->X;
    		int y = this->Y;
    		bool enemy_defeated = false;
    		ffc this_ffc = Screen->LoadFFC(this_ffc_number);
    
    		while (!enemy_defeated){
    
    				ghost_enemy->X = x;
    				ghost_enemy->Y = y;
    				x = this_ffc->X;
    				y = this_ffc->Y;
    
    				if (ghost_enemy->HP <= 10) {
    	
    					ghost_enemy->HP = 0;
    					ghost_enemy = Screen->LoadNPC(1);
    					enemy_defeated = true;
    					if ( warp_or_change == 0 ){
    						Game->PlaySound(3);
    						this_ffc->Data++;
    					}
    					else{
    						Link->Warp(dest_dmap, dest_screen);
    					}
    				}	
    
    			Waitframe();
    
    		} // end of while loop
    
    	} // end of void run
    
    } // end of enemy_ghosting
    I tried to make sure this code would never, ever refer to ghost_enemy once it had died. When it is down to 10 hit points, a variable is set that disables the while loop. The enemy is then killed by setting HP to zero. There should be no time where the engine is looking for an NPC that isnt there. Yet, as soon as an enemy dies, it's crashtown.

  2. #2
    Octorok
    Join Date
    Oct 2006
    Age
    47
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    969
    Level
    10
    vBActivity - Bars
    Lv. Percent
    78.93%

    Re: NPC data types crashing on NPC death

    What is this line for: "ghost_enemy = Screen->LoadNPC(1);", which appears after you set the HP to 0? Does it crash if you take that line out?

  3. #3
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,028
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.53%

    Re: NPC data types crashing on NPC death

    I'm guessing Blue Knight is correct. LoadNPC seems to crash currently if the NPC being indexed does not exist. It's high on my list of bugs to fix as soon as I get back next week.

  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: NPC data types crashing on NPC death

    I added the line BlueKnight is talking about as an attempt to avoid crashing. Without the line, it will crash. With the line, supposedly NPC will be redirected to enemy #1, but that doesn't seem to happen either.

  5. #5
    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: NPC data types crashing on NPC death

    So, I don't suppose anyone has fixed this problem yet? Or figured out a way to stop Zquest from crashing the instant an NPC variable points to a dead NPC?

    I suppose one could simulate the effect just by moving NPCs off the screen and setting a variable. This is sort of a sloppy solution, though.

    -C

  6. #6
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,028
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.53%

    Re: NPC data types crashing on NPC death

    Yes, this has been fixed in the next beta.
    http://www.armageddongames.net/forum...ad.php?t=95616

  7. #7
    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: NPC data types crashing on NPC death

    That thread dealt with syntax problems with the LoadFFC(x) statement at compile time. Does your fix also solve crashing problems when the NPC pointed to by a NPC data type dies at runtime?

  8. #8
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,028
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.53%

    Re: NPC data types crashing on NPC death

    Yes. Any attempt to access an invalid NPC should now print an error to the allegro log instead of crashing ZC.

  9. #9
    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: NPC data types crashing on NPC death

    Cool. So, from the player's perspective, nothing happens? The NPC or FFC pointer just makes a note that there's nothing to point to, and then evaporates?

  10. #10
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.1%

    Re: NPC data types crashing on NPC death

    The statement does nothing in the game, but the pointer remains and the script continues running.
    So you'll still want to be careful to avoid doing this, at least in loops. Writing error messages every frame can cause massive slowdown. Plus, it makes for a really huge log file.

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