User Tag List

Results 1 to 3 of 3

Thread: How to set the warp return point?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,765
    Level
    21
    vBActivity - Bars
    Lv. Percent
    69.76%

    How to set the warp return point?

    I tried a few things, and I'm coming up short.


    Does wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3; not set the return square by using an index of 0 to 3, where those are the valid warp returns?
    For that matter, what is the intent of this:

    >>(8+(index*2)))&3

    There are no code comments to explain what is going on with this...so tat I know what the appropriate values might be.


    What I have now, is this:


    Code:
    //added public vars
    int warpretsq; //Used as tmpscr[t].sidewarp*[warpretsq];
    and
    bool isscriptedwarp;
    //to link.h
    
    //Added a setter/getter pair both to link.h and link.cpp. The functions for LinkClass are:
    
    //
    void LinkClass::setWarpReturnSquare(int sq)
    {
        warpretsq=vbound(sq,0,3);
    	
    }
    
    int LinkClass::getWarpReturnSquare()
    {
        return warpretsq;
    }
    
    void LinkClass::setWarpReturnSquare(int sq)
    {
        warpretsq=vbound(sq,0,3);
    	
    }
    
    bool LinkClass::getScriptedWarp(){
    	
    	return isscriptedwarp;
    }
    
    void LinkClass::setScriptedWarp(bool v){
    	
    	isscriptedwarp = v;
    }
    Obviously, I added a setter to select warpretsq to ZScript. This part works. (Setting, and getting it.)

    isscripted warp is a flag that I might use if it comes down to it and this needs wholly special conditions.
    //Added some routines to dowarp(int, int)

    Code:
    //in dowarp() link.cpp
        case 1:                                                 // side warp
            wtype = tmpscr[t].sidewarptype[index];
            wdmap = tmpscr[t].sidewarpdmap[index];
            wscr = tmpscr[t].sidewarpscr[index];
            overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
            wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
        Z_message("Warp Return is (index, warpreturnc,sum wrindex)\n", index, tmpscr->warpreturnc, wrindex);
        Z_scripterrlog("index: \n", index);
        Z_scripterrlog("tmpscr->warpreturnc: \n", tmpscr->warpreturnc);
        Z_scripterrlog("wrindex: \n", wrindex);
            break;
    
    case wtIWARP:
        case wtIWARPBLK:
        case wtIWARPOPEN:
        case wtIWARPZAP:
        case wtIWARPWAVE:                                       // insta-warps
        {
            //for determining whether to exit cave
            int type1 = combobuf[MAPCOMBO(x,y-16)].type;
            int type2 = combobuf[MAPCOMBO(x,y)].type;
            int type3 = combobuf[MAPCOMBO(x,y+16)].type;
            
            bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
                             ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
                             
            if(!(tmpscr->flags3&fIWARPFULLSCREEN))
            {
                //ALLOFF kills the action, but we want to preserve Link's action if he's swimming or diving -DD
                bool wasswimming = (action == swimming);
                byte olddiveclk = diveclk;
                ALLOFF();
                
                if(wasswimming)
                {
                    action = swimming;
                    diveclk = olddiveclk;
                }
                
                kill_sfx();
    	    if ( warpsound > 0 && getPlayLinkWarpSound() !=0 ) {
    		    sfx(warpsound); 
    		    setPlayLinkWarpSound(false);
    	    }
            }
            
            if(wtype==wtIWARPZAP)
            {
                zapout();
            }
            else if(wtype==wtIWARPWAVE)
            {
                //only draw Link if he's not in a cave -DD
                wavyout(!cavewarp);
            }
            else if(wtype!=wtIWARP)
            {
                bool b2 = COOLSCROLL&&cavewarp;
                blackscr(30,b2?false:true);
            }
            
            int c = DMaps[currdmap].color;
            currdmap = wdmap;
            dlevel = DMaps[currdmap].level;
            currmap = DMaps[currdmap].map;
            init_dmap();
            update_subscreens(wdmap);
            
            ringcolor(false);
            
            if(DMaps[currdmap].color != c)
                loadlvlpal(DMaps[currdmap].color);
                
            homescr = currscr = wscr + DMaps[currdmap].xoff;
            
            lightingInstant(); // Also sets naturaldark
            
            loadscr(0,currdmap,currscr,-1,overlay);
            
            x = tmpscr->warpreturnx[wrindex];
    !Note that we get this variable from:
    wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;

    This gets its 'index' value from the new var: warpretsq

    So, this ultimately becomes

    wrindex=(tmpscr->warpreturnc>>(8+(warpretsq*2)))&3;
    x = tmpscr->warpreturnx[wrindex];

    If I set warpretsq to '3, it becomes

    wrindex=(tmpscr->warpreturnc>>(8+(3*2)))&3;
    x = tmpscr->warpreturnx[wrindex];
    y = tmpscr->warpreturny[wrindex];

    Why the deuce is this not working?!

    ...continuing the warp function code...

    Code:
            y = tmpscr->warpreturny[wrindex];
            
            if(didpit)
            {
                didpit=false;
                x=pitx;
                y=pity;
            }
            
            type1 = combobuf[MAPCOMBO(x,y-16)].type;
            type2 = combobuf[MAPCOMBO(x,y)].type;
            type3 = combobuf[MAPCOMBO(x,y+16)].type;
            
            if(x==0)   dir=right;
            
            if(x==240) dir=left;
            
            if(y==0)   dir=down;
            
            if(y==160) dir=up;
            
            markBmap(dir^1);
            
            if(iswater(MAPCOMBO(x,y+8)) && _walkflag(x,y+8,0) && current_item(itype_flippers))
            {
                hopclk=0xFF;
                attackclk = charging = spins = 0;
                action=swimming;
            }
            else
                action = none;
                
            //preloaded freeform combos
            ffscript_engine(true);
            
            putscr(scrollbuf,0,0,tmpscr);
            putscrdoors(scrollbuf,0,0,tmpscr);
            
            if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
            {
                reset_pal_cycling();
                putscr(scrollbuf,0,0,tmpscr);
                putscrdoors(scrollbuf,0,0,tmpscr);
                walkup(COOLSCROLL);
            }
            else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
            {
                reset_pal_cycling();
                putscr(scrollbuf,0,0,tmpscr);
                putscrdoors(scrollbuf,0,0,tmpscr);
                walkdown2(COOLSCROLL);
            }
            else if(wtype==wtIWARPZAP)
            {
                zapin();
            }
            else if(wtype==wtIWARPWAVE)
            {
                wavyin();
            }
            else if(wtype==wtIWARPOPEN)
            {
                openscreen();
            }
            
            show_subscreen_life=true;
            show_subscreen_numbers=true;
            playLevelMusic();
            currcset=DMaps[currdmap].color;
            dointro();
            setEntryPoints(x,y);
        }
        break;
    Why is this not having the expected results?!

    The desired outcome is:

    Link->SetWarpReturn = 3; //Set to Warp Return C
    Link->Warp(dmap,screen); //Warps to dmap, screen, warp return 3

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