예제 #1
0
/*
  void movefairy(fix &x,fix &y,int misc) {
  return;
  }

  void killfairy(int misc) {
  return;
  }
  */
bool addfairy(fix x, fix y, int misc3, int id)
{
    addenemy(x,y,curQuest->specialEnemies().fairyItem,id);
    ((enemy*)guys.spr(guys.Count()-1))->dstep=misc3;
    ((enemy*)guys.spr(guys.Count()-1))->step=(misc3/100.0);
    movefairy(x,y,id);
    return true;
}
예제 #2
0
/*
  void movefairy(fix &x,fix &y,int misc) {
  return;
  }

  void killfairy(int misc) {
  return;
  }
  */
bool addfairy(fix x, fix y, int misc3, int id)
{
    addenemy(x,y,eITEMFAIRY,id);
    ((enemy*)guys.spr(guys.Count()-1))->dstep=misc3;
    ((enemy*)guys.spr(guys.Count()-1))->step=(misc3/100.0);
    movefairy(x,y,id);
    return true;
}
예제 #3
0
ItemDefinitionRef select_dropitem(int item_set, int x, int y)
{
    int total_chance=0;
    
    for(int k=0; k<11; ++k)
    {
        int current_chance=item_drop_sets[item_set].chance[k];
        
        if(k>0)
        {
            ItemDefinitionRef current_item=item_drop_sets[item_set].item[k-1];
            if (curQuest->isValid(current_item))
            {
                if ((!get_bit(quest_rules, qr_ENABLEMAGIC) || (game->get_maxmagic() <= 0)) && (curQuest->getItemDefinition(current_item).family == itype_magic))
                {
                    current_chance = 0;
                }

                if ((!get_bit(quest_rules, qr_TRUEARROWS)) && (curQuest->getItemDefinition(current_item).family == itype_arrowammo))
                {
                    current_chance = 0;
                }
            }
        }
        
        total_chance+=current_chance;
    }
    
    if(total_chance==0)
        return ItemDefinitionRef();
        
    int item_chance=(rand()%total_chance)+1;
    
    ItemDefinitionRef drop_item;
    
    for(int k=10; k>=0; --k)
    {
    
        int current_chance=item_drop_sets[item_set].chance[k];
        ItemDefinitionRef current_item=(k==0 ? ItemDefinitionRef() : item_drop_sets[item_set].item[k-1]);
        
        if((!get_bit(quest_rules,qr_ENABLEMAGIC)||(game->get_maxmagic()<=0)) && 
            (curQuest->isValid(current_item) && curQuest->getItemDefinition(current_item).family == itype_magic))
        {
            current_chance=0;
        }
        
        if((!get_bit(quest_rules,qr_TRUEARROWS)) &&
            (curQuest->isValid(current_item) && curQuest->getItemDefinition(current_item).family == itype_arrowammo))
        {
            current_chance=0;
        }
        
        if(current_chance>0&&item_chance<=current_chance)
        {
            drop_item=current_item;
            break;
        }
        else
        {
            item_chance-=current_chance;
        }
    }
    
    if(curQuest->isValid(drop_item) && curQuest->getItemDefinition(drop_item).family==itype_fairy)
    {
        for(int j=0; j<items.Count(); ++j)
        {
            if((curQuest->getItemDefinition(((item *)items.spr(j))->itemDefinition).family==itype_fairy)
                && ((abs(items.spr(j)->x-x)<32)||(abs(items.spr(j)->y-y)<32)))
            {
                drop_item=ItemDefinitionRef();
                break;
            }
        }
    }
    
    return drop_item;
}
예제 #4
0
int select_dropitem(int item_set, int x, int y)
{
    int total_chance=0;
    
    for(int k=0; k<11; ++k)
    {
        int current_chance=item_drop_sets[item_set].chance[k];
        
        if(k>0)
        {
            int current_item=item_drop_sets[item_set].item[k-1];
            
            if((!get_bit(quest_rules,qr_ENABLEMAGIC)||(game->get_maxmagic()<=0))&&(itemsbuf[current_item].family == itype_magic))
            {
                current_chance=0;
            }
            
            if((!get_bit(quest_rules,qr_TRUEARROWS))&&(itemsbuf[current_item].family == itype_arrowammo))
            {
                current_chance=0;
            }
        }
        
        total_chance+=current_chance;
    }
    
    if(total_chance==0)
        return -1;
        
    int item_chance=(rand()%total_chance)+1;
    
    int drop_item=-1;
    
    for(int k=10; k>=0; --k)
    {
    
        int current_chance=item_drop_sets[item_set].chance[k];
        int current_item=(k==0 ? -1 : item_drop_sets[item_set].item[k-1]);
        
        if((!get_bit(quest_rules,qr_ENABLEMAGIC)||(game->get_maxmagic()<=0))&&(current_item>=0&&itemsbuf[current_item].family == itype_magic))
        {
            current_chance=0;
        }
        
        if((!get_bit(quest_rules,qr_TRUEARROWS))&&(current_item>=0&&itemsbuf[current_item].family == itype_arrowammo))
        {
            current_chance=0;
        }
        
        if(current_chance>0&&item_chance<=current_chance)
        {
            drop_item=current_item;
            break;
        }
        else
        {
            item_chance-=current_chance;
        }
    }
    
    if(drop_item>=0 && itemsbuf[drop_item].family==itype_fairy)
    {
        for(int j=0; j<items.Count(); ++j)
        {
            if((itemsbuf[items.spr(j)->id].family==itype_fairy)&&((abs(items.spr(j)->x-x)<32)||(abs(items.spr(j)->y-y)<32)))
            {
                drop_item=-1;
                break;
            }
        }
    }
    
    return drop_item;
}
예제 #5
0
void FaroresWindAction::update()
{
    if(timer>0)
    {
        timer--;
        if(phase!=1) // Whatever
            return;
    }
    
    int ltile=0;
    int lflip=0;
    
    switch(phase)
    {
    //if(timer==0)
    case 0:
        {
            linktile(&ltile, &lflip, ls_stab, down, zinit.linkanimationstyle);
            unpack_tile(newtilebuf, ltile, lflip, true);
            memcpy(linkTile, unpackbuf, 256);
            
            if(get_bit(quest_rules,qr_EXPANDEDLTM))
                ltile+=item_tile_mod();
            
            linktile(&link.tile, &link.flip, &link.extend, ls_pound, down, zinit.linkanimationstyle);
            
            if(get_bit(quest_rules,qr_EXPANDEDLTM))
            {
                link.tile+=item_tile_mod();
            }
        }
        phase=1;
        timer=64;
        // Fall though
        
    case 1:
        link.setX(fix(baseX+((rand()%3)-1)));
        link.setY(fix(baseY+((rand()%3)-1)));
        if(timer==0)
            phase=2;
        break;
        
    case 2:
        link.setX(fix(baseX));
        link.setY(fix(baseY));
        linktile(&link.tile, &link.flip, &link.extend, ls_stab, down, zinit.linkanimationstyle);
        
        if(get_bit(quest_rules,qr_EXPANDEDLTM))
            link.tile+=item_tile_mod();
        
        phase=3;
        timer=32;
        break;
    
    case 3:
        if(get_bit(quest_rules,qr_MORESOUNDS))
            sfx(itemsbuf[magicitem].usesound,pan(int(link.getX())));
            
        link.setDontDraw(true);
        
        for(int i=0; i<16; ++i)
        {
            for(int j=0; j<16; ++j)
            {
                if(linkTile[i*16+j])
                {
                    if(itemsbuf[magicitem].misc1==1)  // Twilight
                    {
                        particles.add(new pTwilight(link.getX()+j, link.getY()-link.getZ()+i, 5, 0, 0, (rand()%8)+i*4));
                        int k=particles.Count()-1;
                        particle *p = (particle*)(particles.spr(k));
                        p->step=3;
                    }
                    else if(itemsbuf[magicitem].misc1==2)  // Sands of Hours
                    {
                        particles.add(new pTwilight(link.getX()+j, link.getY()-link.getZ()+i, 5, 1, 2, (rand()%16)+i*2));
                        int k=particles.Count()-1;
                        particle *p = (particle*)(particles.spr(k));
                        p->step=4;
                        
                        if(rand()%10 < 2)
                        {
                            p->color=1;
                            p->cset=0;
                        }
                    }
                    else
                    {
                        particles.add(new pFaroresWindDust(link.getX()+j, link.getY()-link.getZ()+i, 5, 6, linkTile[i*16+j], rand()%96));
                        
                        int k=particles.Count()-1;
                        particle *p = (particle*)(particles.spr(k));
                        p->angular=true;
                        p->angle=rand();
                        p->step=(((double)j)/8);
                        p->yofs=link.getYOfs();
                    }
                }
            }
        }
        phase=4;
        timer=130;
        break;
    
    case 4:
        restart_level();
        magicitem=-1;
        link.setDontDraw(false);
        link.currentItemAction=this; // This won't do...
        phase=5;
        
        break;
    }
}
예제 #6
0
void ending()
{
    /*
      *************************
      * WIN THE GAME SEQUENCE *
      *************************
      0    LINK at ZELDA's side
      288  begin WIPE (8px per side per step, each 5 frames)
      363  WIPE complete, DOT out, A/B items out
      QMisc.colors.link_dot = 255;
      show_subscreen_items = false;
      365  first MESSAGE character in
      371  next character in
      407  last character in
      668  LINK out, ZELDA out
      669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
      733  BLUE flash bg
      734  RED
      735  GREEN
      736  BLACK
      ...
      860  BLACK, LINK out, ZELDA out
      861  LINK in, ZELDA in
      927  first MSG character in
      935  next character in
      1335 last character in
      1461 LINK out, ZELDA out
      1493 begin SCROLL
      */
    
    //get rid off all sprites but Link and Zelda
    items.clear();
    Ewpns.clear();
    Lwpns.clear();
    Sitems.clear();
    chainlinks.clear();
    decorations.clear();
    
    music_stop();
    kill_sfx();
    sfx(WAV_ZELDA);
    Quit=0;
    
    game->set_cheat(game->get_cheat() | (cheat>1)?1:0);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    draw_screen_clip_rect_y1=0;
    draw_screen_clip_rect_y2=223;
    //draw_screen_clip_rect_show_link=true;
    //draw_screen_clip_rect_show_guys=false;
    
    for(int f=0; f<365; f++)
    {
        if(f==363)
        {
            //363  WIPE complete, DOT out, A/B items out
            QMisc.colors.link_dot = 255;
            show_subscreen_items = false;
            
            for(int i = guys.Count() - 1; i >= 0; i--)
            {
                if(guys.spr(i)->id > gDUMMY9)
                {
                    guys.del(i);
                }
            }
            
            guys.draw(framebuf,true);
            Link.draw(framebuf);
        }
        
        if(f>=288 && ((f-288)%5 == 0))
        {
            //288  begin WIPE (8px per side per step, each 5 frames)
            //TODO::
            draw_screen_clip_rect_x1+=8;
            draw_screen_clip_rect_x2-=8;
            //draw_screen_clip_rect_show_guys=true;
        }
        
        draw_screen(tmpscr);
        advanceframe(true);
        
        if(Quit) return;
    }
    
    clear_bitmap(msgdisplaybuf);
    draw_screen(tmpscr);
    advanceframe(true);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    //draw_screen_clip_rect_show_guys=false;
    
    char tmpmsg[6][25];
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    strncpy(tmpmsg[x], MsgStrings[QMisc.endstring].s+(24*x), 24);
    }
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x+3], "%.24s", MsgStrings[QMisc.endstring+1].s+(24*x));
        //    strncpy(tmpmsg[x+3], MsgStrings[QMisc.endstring+1].s+(24*x), 24);
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("THANKS LINK,YOU'RE",32,96,6,noproc);
        putendmsg("THE HERO OF HYRULE.",32,112,6,noproc);
    }
    else
    {
        putendmsg(tmpmsg[0],32,80,6,noproc);
        putendmsg(tmpmsg[1],32,96,6,noproc);
        putendmsg(tmpmsg[2],32,112,6,noproc);
    }
    
    for(int f=408; f<927; f++)
    {
        /*
          668  LINK out, ZELDA out
          669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
          733  BLUE flash bg
          734  RED
          735  GREEN
          736  BLACK
          ...
          860  BLACK, LINK out, ZELDA out
          861  LINK in, ZELDA in
          */
        if(f==668)
        {
            rectfill(framebuf,120,129,152,145,0);
            blit(framebuf, tmp_bmp, 120,113, 0,0, 32,32);
        }
        
        if(f==860)
        {
            blit(tmp_bmp, framebuf, 0,0, 120,113, 32,32);
        }
        
        if(f==669 || f==861)
        {
            overtile16(framebuf,36,120,129,6,0);//draw Zelda two-handed overhead
            overtile16(framebuf,BSZ?32:29,136,129,6,0);//draw Link two-handed overhead
        }
        
        if(f==733)
        {
            blit(framebuf,scrollbuf,0,playing_field_offset!=0?168:0,0,0,256,passive_subscreen_height);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(!(framebuf->line[y][x]&15))
                    {
                        framebuf->line[y][x]=16;
                    }
                }
            }
        }
        
        if(f>=733 && f<861)
        {
            static byte flash[4] = {0x12,0x16,0x2A,0x0F};
            RAMpal[16] = NESpal(flash[(f-733)&3]);
            refreshpal=true;
        }
        
        if(f==861)
        {
            blit(scrollbuf,framebuf,0,0,0,playing_field_offset!=0?168:0,256,passive_subscreen_height);
            try_zcmusic((char*)"zelda.nsf", 1, ZC_MIDI_ENDING);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(framebuf->line[y][x]==16)
                    {
                        framebuf->line[y][x]=0;
                    }
                }
            }
        }
        
        if(f>668 && f!=860)
        {
            put_triforce();
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("FINALLY,",96,160,8,put_triforce);
        putendmsg("PEACE RETURNS TO HYRULE.",32,176,8,put_triforce);
        putendmsg("THIS ENDS THE STORY.",48,200,8,put_triforce);
    }
    else
    {
        putendmsg(tmpmsg[3],32,160,6,noproc);
        putendmsg(tmpmsg[4],32,176,6,noproc);
        putendmsg(tmpmsg[5],32,200,6,noproc);
    }
    
    for(int f=1336; f<1492; f++)
    {
        if(f<1461)
        {
            put_triforce();
        }
        
        if(f==1461)
        {
            blit(tmp_bmp,framebuf,0,0,120,113,32,32);
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    clear_bitmap(scrollbuf);
    blit(framebuf,scrollbuf,0,0,0,0,256,224);
    endingpal();
    // draw the brick
    puttile16(scrollbuf,3,256,0,csBOSS,0);
    
    int len=600*2;
    
    if(game->get_quest()>1)
    {
        len=720*2;
    }
    
    int creditsLine=0;
    int endTextLine=0;
    
    const EndingTextLine* endText;
    int numEndTextLines=0;
    int deathsYPos=-1;
    int timeYPos=-1;
    
    switch(game->get_quest())
    {
    case 1:
        endText=quest1End;
        numEndTextLines=numQuest1EndLines;
        break;
        
    case 2:
        endText=quest2End;
        numEndTextLines=numQuest2EndLines;
        deathsYPos=792;
        break;
        
    case 3:
    case 4:
        endText=quest34End;
        numEndTextLines=numQuest34EndLines;
        deathsYPos=792;
        break;
        
    default:
        endText=customQuestEnd;
        numEndTextLines=numCustomQuestEndLines;
        deathsYPos=784;
        timeYPos=800;
        break;
    }
    
    for(int f=0; f<len; f++)
    {
        if(!(f&15))
        {
            int y=(f>>1)+224;
            
            if(y>240 && y<584)
            {
                brick(24,224);
                brick(224,224);
            }
            
            if(y==240 || y==584)
            {
                for(int x=24; x<=224; x+=8)
                {
                    brick(x,224);
                }
            }
            
            if(creditsLine<numCreditsLines)
            {
                if(y==credits[creditsLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               credits[creditsLine].text,
                               credits[creditsLine].xPos,
                               224,
                               credits[creditsLine].color,
                               0);
                    creditsLine++;
                }
            }
            else
            {
                if(endTextLine<numEndTextLines &&
                   y==endText[endTextLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               endText[endTextLine].text,
                               endText[endTextLine].xPos,
                               224,
                               endText[endTextLine].color,
                               0);
                    endTextLine++;
                }
                else if(y==deathsYPos)
                    textprintf_ex(scrollbuf, zfont, 72, 224, red, 0,
                                  "%-8s -%3d", game->get_name(), game->get_deaths());
                else if(y==timeYPos)
                {
                    if(game->get_timevalid() && !game->get_cheat())
                        textout_centre_ex(scrollbuf, zfont, time_str_med(game->get_time()), 128, 224, blue, 0);
                }
            }
        }
        
        if(f==112)                                              // after subscreen has scrolled away
        {
            init_NES_mode();
            loadpalset(9,pSprite(spPILE));
            endingpal();
        }
        
        if(f&1)
        {
            blit(scrollbuf,scrollbuf,0,1,0,0,256,232);
        }
        
        blit(scrollbuf,framebuf,0,0,0,0,256,224);
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
        
        load_control_state();
        rSbtn();
    }