User Tag List

Results 1 to 9 of 9

Thread: NPC->isInvincible()

  1. #1
    Octorok
    Join Date
    Jan 2007
    Age
    38
    Posts
    143
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,174
    Level
    11
    vBActivity - Bars
    Lv. Percent
    74.36%

    NPC->isInvincible()

    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:

    Code:
    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.
    Programmings my game because I program games.
    "Wait. You lost me at the part about the 'almost certain death'." - A quote I would love to make in an MMORPG.
    Disclaimer: Din's Fire does not make the user immune to the effects of lava. Do not use Din's Fire in mid-jump over a pool of lava. Death and severe burns will follow.

    ZCG Current Version:
    Version 0.05
    For Mac Build 1076 Windows Build 1082

  2. #2
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,959
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.28%

    Re: NPC->isInvincible()

    You could probably stick it in a butt I mean for loop.

    Code:
    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;
    }
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  3. #3
    Octorok
    Join Date
    Jan 2007
    Age
    38
    Posts
    143
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,174
    Level
    11
    vBActivity - Bars
    Lv. Percent
    74.36%

    Re: NPC->isInvincible()

    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...
    Programmings my game because I program games.
    "Wait. You lost me at the part about the 'almost certain death'." - A quote I would love to make in an MMORPG.
    Disclaimer: Din's Fire does not make the user immune to the effects of lava. Do not use Din's Fire in mid-jump over a pool of lava. Death and severe burns will follow.

    ZCG Current Version:
    Version 0.05
    For Mac Build 1076 Windows Build 1082

  4. #4
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,143
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.73%

    Re: NPC->isInvincible()

    Quote Originally Posted by HeroOfFire View Post
    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?
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  5. #5
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    32
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,304
    Level
    26
    vBActivity - Bars
    Lv. Percent
    8.85%

    Re: NPC->isInvincible()

    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.

  6. #6
    Developer
    ZC Developer

    Join Date
    Aug 2006
    Location
    Australia
    Age
    37
    Posts
    2,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,851
    Level
    25
    vBActivity - Bars
    Lv. Percent
    37.82%

    Re: NPC->isInvincible()

    Quote Originally Posted by HeroOfFire View Post
    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:
    Code:
    (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)

  7. #7
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,959
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.28%

    Re: NPC->isInvincible()

    Quote Originally Posted by _L_ View Post
    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:
    Code:
    (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
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  8. #8
    Developer
    ZC Developer

    Join Date
    Aug 2006
    Location
    Australia
    Age
    37
    Posts
    2,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,851
    Level
    25
    vBActivity - Bars
    Lv. Percent
    37.82%

    Re: NPC->isInvincible()

    Then you'd simply write a different function!

  9. #9
    Octorok
    Join Date
    Jan 2007
    Age
    38
    Posts
    143
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,174
    Level
    11
    vBActivity - Bars
    Lv. Percent
    74.36%

    Re: NPC->isInvincible()

    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.
    Programmings my game because I program games.
    "Wait. You lost me at the part about the 'almost certain death'." - A quote I would love to make in an MMORPG.
    Disclaimer: Din's Fire does not make the user immune to the effects of lava. Do not use Din's Fire in mid-jump over a pool of lava. Death and severe burns will follow.

    ZCG Current Version:
    Version 0.05
    For Mac Build 1076 Windows Build 1082

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