User Tag List

Results 1 to 3 of 3

Thread: How to set the warp return point?

  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,762
    Level
    21
    vBActivity - Bars
    Lv. Percent
    69.16%

    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

  2. #2
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,432
    Level
    24
    vBActivity - Bars
    Lv. Percent
    69.95%
    warpreturnc is return index 0-3 for all 8 warps. Each one gets two bits.
    0-1: Tile warp A
    2-3: Tile warp B
    ...
    14-15: Side warp D

    There's no reason to deal with that. You would just need
    Code:
     x = tmpscr->warpreturnx[warpretsq]; 
     y = tmpscr->warpreturny[warpretsq];
    Why not make the return an optional third argument to Link->Warp() instead of a separate function?

  3. #3
    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,762
    Level
    21
    vBActivity - Bars
    Lv. Percent
    69.16%
    Quote Originally Posted by Saffith View Post
    warpreturnc is return index 0-3 for all 8 warps. Each one gets two bits.
    0-1: Tile warp A
    2-3: Tile warp B
    ...
    14-15: Side warp D

    There's no reason to deal with that. You would just need
    Code:
     x = tmpscr->warpreturnx[warpretsq]; 
     y = tmpscr->warpreturny[warpretsq];
    Aye, that certainly worked, and did the job.


    Why not make the return an optional third argument to Link->Warp() instead of a separate function?

    My reasons...

    Gleeok expressly told me that it would be better to add new functions, than to modify or overload existing ones.

    Replacing Link->Warp(int, int) with Link->Warp(int, int, int, ...) would break existing scripts, and probably quests.

    Overloading a ZASM instruction and making redirects is a bloody pain...

    What I did, is add in Link->WarpReturnSquare, int Link->WarpEffect, int Link->WarpSound, bool Link->PlayWarpSound

    int WarpEffect allows setting an effect for a Link->Warp, or Link->PitWarp. This is andled with a switch-case, so only valid types do things differently.
    int WarpSound, if set to > 0 allows playing a sound when warping. I expressly forbid this during sidewarps, and I probably need to vbound it.
    bool PlayWarpSound is a flag that the user may toggle to allow a warp sound during a sidewarp. I need to rename it to SideWarpSound.

    While I was at it, I plugged in Screen->ZapIn(), Screen->ZapOut, Screen->WavyIn(), Screen->WavyOut, and Screen->OpeningWipe
    These allow replicating the in-build warp animations on demand, without warping. Could be useful. I know that I wanted to do that in the past for an effect, as did one of the other scripters.

    Meanwhile, @Dimentio added SCC warp codes for Link, that also use these variables, so it isn't only for one thing.

    Thankfully, all of these new ZScript things work, and I've been doing bug testing. Thus far, the only bugs that I was unable to kill, are caused by the SCC warp. I also patched in an SCC for setting Screen->D, while I was working with Dimentio. This felt natural, given that there is one to read it.

    Anyway...thank you @Saffith for clarifying this.

    P.S. Don't fret.I used intermediate handlers for allof this, rather than directly tying anything to a class variable.

    Edit:

    If you want to look at, or try out anything:
    Sources | Windows Binaries

    LinkClass::dowarp() is such a mess that I may just rewrite some parts of it to segregate normal, pit, and other warping.

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