PDA

View Full Version : NPC->isInvincible()



HeroOfFire
02-18-2009, 02:36 AM
After working on a script that simulates shutters opening when there are no more killable enemies on the screen, I realized that testing for the "unkillable" enemies is tedious, specific only to quests that have the same invincible enemies, and will be outdated when more invincible enemies, such as the advanced traps, are implemented. A function that simply checks a single flag would be far more efficient than this:


if(testEnemy->ID > 9 && testEnemy->ID != NPC_BOULDER && testEnemy->ID != NPC_BUBBLEITEMP && testEnemy->ID != NPC_BUBBLEITEMR && testEnemy->ID != NPC_BUBBLEITEMT && testEnemy->ID != NPC_BUBBLESWORDP && testEnemy->ID != NPC_BUBBLESWORDR && testEnemy->ID != NPC_BUBBLESWORDT && testEnemy->ID != NPC_GHINI2 && testEnemy->ID != NPC_ITEMFAIRY && testEnemy->ID != NPC_ROCK && testEnemy->ID != NPC_SHOOTFBALL && testEnemy->ID != NPC_SHOOTFLAME && testEnemy->ID != NPC_SHOOTFLAME2 && testEnemy->ID != NPC_SHOOTMAGIC && testEnemy->ID != NPC_SHOOTROCK && testEnemy->ID != NPC_SHOOTSPEAR && testEnemy->ID != NPC_SHOOTSWORD && testEnemy->ID != NPC_TRAP && testEnemy->ID != NPC_TRAPHORIZC && testEnemy->ID != NPC_TRAPHORIZLOS && testEnemy->ID != NPC_TRAPVERTC && testEnemy->ID != NPC_TRAPVERTLOS && testEnemy->ID != NPC_TRIGGER && testEnemy->ID != NPC_ZORA)

This would be practical to have, right? Most of the script above could be reduced to "!testEnemy->isInvincible()", and it would be up to date with any changes made in the enemy editor.

Gleeok
02-18-2009, 06:13 PM
You could probably stick it in a butt I mean for loop.



const int NOEN_EXE_HND = num;
int ENCHK[NOEN_EXE_HND] = {ID,ID,ID,ID...};

bool enemyChecker(npc testEnemy){
for( i; i< NOEN_EXE_HND;i++)
if(testEnemy->ID == ENCHK[i])
0;
1;
}

HeroOfFire
02-19-2009, 01:06 AM
Actually, that works well given I have other scripts that could look for different data from the array. Global arrays are still broken, but I have long since found a workaround that is great for this situation.

Also, fun fact. The fairy item npc? Turns out its ID is 4180. That caused a funny bug until I used Trace() and got the rather high number...

pkmnfrk
02-19-2009, 05:34 AM
Also, fun fact. The fairy item npc? Turns out its ID is 4180. That caused a funny bug until I used Trace() and got the rather high number...

Are you referring to the moving or the stationary fairy?

Joe123
02-19-2009, 05:55 AM
If you're making a function out of it, you needn't really use an array (especially seeing as they're broken), just write out that line of code that you're so loathe to use.

_L_
02-19-2009, 07:04 AM
Also, fun fact. The fairy item npc? Turns out its ID is 4180.An NPC_ITEMFAIRY has its ID incremented by 0x1000 multiplied by the number of fairies already onscreen. That, of course, should be absent when you get its ID in ZScript.

Bug fixed!

By the way, I simplified your check down to this:

(id > NPC_ABEI2
&&
id != NPC_BOULDER
&&
id != NPC_ROCK
&&
id != NPC_GHINI2
&&
!(id >= NPC_SHOOTSWORD && id <= NPC_SHOOTFLAME2)
&&
!(id >= NPC_TRIGGER && id <= NPC_BUBBLEITEMR)
&&
!(id >= NPC_BUBBLESWORDP && id <= NPC_ITEMFAIRY)
&&
!(id >= NPC_TRAPHORIZLOS && id <= NPC_TRAPVERTC)
&&
id != NPC_TRAP
&&
id != NPC_ZORA)

Gleeok
02-19-2009, 08:36 AM
An NPC_ITEMFAIRY has its ID incremented by 0x1000 multiplied by the number of fairies already onscreen. That, of course, should be absent when you get its ID in ZScript.

Bug fixed!

By the way, I simplified your check down to this:

(id > NPC_ABEI2
&&
id != NPC_BOULDER
&&
id != NPC_ROCK
&&
id != NPC_GHINI2
&&
!(id >= NPC_SHOOTSWORD && id <= NPC_SHOOTFLAME2)
&&
!(id >= NPC_TRIGGER && id <= NPC_BUBBLEITEMR)
&&
!(id >= NPC_BUBBLESWORDP && id <= NPC_ITEMFAIRY)
&&
!(id >= NPC_TRAPHORIZLOS && id <= NPC_TRAPVERTC)
&&
id != NPC_TRAP
&&
id != NPC_ZORA)

What if someone changed them in the editor though? :p

_L_
02-19-2009, 12:41 PM
Then you'd simply write a different function!

HeroOfFire
02-20-2009, 04:13 AM
Now this is interesting.

All four types of Zols spawn gels that register with IDs well above 255, and in the layout mentioned for the moving fairy NPC. I already modified my scripts to ignore IDs above 255, and based on the results I'm getting, the spawned gels eventually get their proper ID.

Vires and keese on the other hand, do not seem to produce these way off IDs. The spawned keese appear with correct Ids the same frame the Vire dies.