Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

[846] Fairies are NPCs?

3 replies · 1,126 views · Started 31 July 2008

I have a script that checks to see when all enemies are dead:

fail = Screen->NumNPCs() > 0;

99% of the time, this works perfectly. However, if the enemies spawn a moving fairy, then it won't trigger until the fairy has been grabbed or disappears. I thought fairies were items, not NPCs.

They are both, actually. There is a fairy NPC that is invisible and untouchable. It moves around the screen in a random fashion. There is a fairy item that heals you when you touch it. When a fairy item is created, a fairy NPC is created and linked to the item. When the fairy NPC moves, it updates the linked fairy item's position as well. This is done because there is no movement code for items.

So, you'll probably need to manually check all NPCs on the screen and set fail to true if any of them are not a fairy NPC.

Heh, that's funny. I posted this same bug last year sometime.

Yeah, you need a workaround for npc checks if you are using fairies. Another way might be to have enemies never spawn fairies...haven't tried that though.

:S

Well, bother. I would consider turning off fairies, if that didn't mean turning off other items too.

Well, I guess then I'll be writing a new function:

int NumRealNPCs() {
int ret = 0;
npc g;
for(int i = 0; i < Screen->NumNPCs(); i++) {
g = Screen->LoadNPC(i);
if(g->ID != NPC_FAIRY) ret++;
}
return ret;
}

...

fail = NumRealNPCs() > 0;


[strike]Out of curiosity, since there is no Fairy entry in the enemies list, what ID does a fairy have? Or, failing that, how can I tell if a given NPC is a fairy?[/strike]

Hurrr. NPC_FAIRY.