• View unanswered postsView active topics

  • (Solved) A little code help on The Simpsons mod

    Discuss Wolf3D and Wolf3D modding/ports

    Postby Officer-Michael John 28 Jul 2018, 19:34

    I have 2 code problem of The Simpsons mod. It doesn't work Parallax Sky and Player uses same weapon as the player.

    Parallax Sky:

    WL_DRAW.CPP:

    Code: Select all
    /*
    ==============
    =
    = DrawParallax
    =
    = by Ripper
    =
    ==============
    */

    #define TEXTURESHIFT    6
    #define TEXTURESIZE     (1<<TEXTURESHIFT)
    #define TEXTUREMASK     (TEXTURESIZE*(TEXTURESIZE-1))

    #define NUMPARALLAXTEX  16

    static inline byte *PM_GetTexture(int wallpic)
    {
        return Pages+wallpic*PMPageSize;
    }

    void DrawParallax(int startpage)
    {
       word xtex,nextxtex,offs;
       byte *skytex;
       byte *destbuf=(byte *)(vbuf); // + 0xa0000000L
       int i,x=0,x2,curtex,nextx=0,texoffs,t,tend;
       byte mask;
       int midangle=player->angle*(FINEANGLES/ANGLES);
       int skyheight=viewheight>>1;
       startpage += NUMPARALLAXTEX - 1;

       t=pixelangle[0]+midangle;
       while(t<0) t+=FINEANGLES;
       while(t>=FINEANGLES) t-=FINEANGLES;
       xtex=(word)((((long)t) * NUMPARALLAXTEX * TEXTURESIZE)/FINEANGLES);

       do
       {
          curtex=xtex>>TEXTURESHIFT;
          //skytex=Pages+((startpage-curtex)<<14);
          skytex=PM_GetTexture(startpage-curtex);
          nextx=0x7fff;
          for(i=0;i<4;i++)
          {
             mask=1<<((x+i)&3);
             VGAMAPMASK(mask);
             for(x2=x+i;x2<viewwidth;x2+=4)
             {
                t=pixelangle[x2]+midangle;
                while(t<0) t+=FINEANGLES;
                while(t>=FINEANGLES) t-=FINEANGLES;
                xtex=(word)((((long)t) * NUMPARALLAXTEX * TEXTURESIZE)/FINEANGLES);

                t=xtex>>TEXTURESHIFT;
                if(t!=curtex)
                {
                   if(x2<nextx) nextx=x2,nextxtex=xtex;
                   break;
                }

                texoffs= TEXTUREMASK -((xtex & (TEXTURESIZE - 1) ) << TEXTURESHIFT);
                tend=skyheight-(wallheight[x2]>>3);
                if(tend<=0) continue;
                for(t=0,offs=x2>>2;t<tend;t++,offs+=80)
                   destbuf[offs]=skytex[texoffs+((t*TEXTURESIZE)/skyheight)];
             }
             if(x2>=viewwidth+3) nextx=viewwidth;

          }
          x=nextx;
          xtex=nextxtex;
       }
       while(x<viewwidth);
    }

    unsigned parallax=1;

        if(parallax)
              DrawParallax(mapsegs[0][63]); 


    If I change wall number to parallax sky then it doesn't change to actually wall graphic as in Wolf4SDL.

    Clone Enemy:

    WL_ACT2.CPP:

    Code: Select all
                    if (ob->obclass == officerobj)
                  { 
                    if (gamestate.weapon == wp_pistol)
                      ob->state = &s_ofcchase1;
                    else if (gamestate.weapon == wp_machinegun)
                      ob->state = &s_ofc2chase1;   
                     }     


    2nd code I test in Mod pack. I added these codes in 4GW. When player uses machinegun and officer too,but it shoot then uses pistol at shooting.
    Last edited by Officer-Michael John on 02 Aug 2018, 14:12, edited 1 time in total.
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        

    Postby AshenOne 29 Jul 2018, 11:40

    ..
    Last edited by AshenOne on 13 Jun 2022, 18:52, edited 2 times in total.
    AshenOne

     
    Posts: 31

      

    Postby Officer-Michael John 29 Jul 2018, 11:53

    AshenOne wrote:Delete system32 and throw the computer out a window, then you have fixes! :D
    ok let's stop being funny.

    1. Are you sure you put the good texture to the good mapcorner? Maybe you forgot something while copy pasted the code.
    2. WL_ACT2.C -> T_Chase -> // go into attack frame -> try to do something in the switch.


    Haha.

    1. I added 102 Wall graphic (in 52) that is parallax sky and it doesn't do nothing.
    2. What to do in switch?

    Codes Chris Chokan did to Me and I tried to do for better.
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        

    Postby AshenOne 29 Jul 2018, 12:27

    ..
    Last edited by AshenOne on 13 Jun 2022, 18:51, edited 2 times in total.
    AshenOne

     
    Posts: 31

      

    Postby Officer-Michael John 29 Jul 2018, 16:47

    AshenOne wrote:Well I knew you weren't able to do that alone.

    1. I asked you that you put the texture on the GOOD MAPCORNER...
    2. Try to do it as you did with the ofcchase.


    1.Yes. I have 2 picture:

    ImageImage

    2. I added same code with officer2obj,but isn1t nothing.
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        

    Postby Officer-Michael John 02 Aug 2018, 14:22

    Chris Chokan helped again. Parallax Sky fix (WL_DRAW.CPP):

    Code: Select all
    /*
    ==============
    =
    = DrawParallax
    =
    = by Ripper
    =
    ==============
    */

    #define TEXTURESHIFT    6
    #define TEXTURESIZE     (1<<TEXTURESHIFT)
    #define TEXTUREMASK     (TEXTURESIZE*(TEXTURESIZE-1))

    #define NUMPARALLAXTEX  16

    void DrawParallax(int startpage)
    {
       word xtex,nextxtex,offs;
       byte *skytex;
       byte *destbuf=(byte *)(vbuf); // + 0xa0000000L
       int i,x=0,x2,curtex,nextx=0,texoffs,t,tend;
       byte mask;
       int midangle=player->angle*(FINEANGLES/ANGLES);
       int skyheight=viewheight>>1;
       startpage += NUMPARALLAXTEX - 1;

       t=pixelangle[0]+midangle;
       while(t<0) t+=FINEANGLES;
       while(t>=FINEANGLES) t-=FINEANGLES;
       xtex=(word)((((long)t) * NUMPARALLAXTEX * TEXTURESIZE)/FINEANGLES);

       do
       {
          curtex=xtex>>TEXTURESHIFT;
          skytex=Pages+((startpage-curtex)<<12);
          nextx=0x1fff;
          for(i=0;i<4;i++)
          {
             mask=1<<((x+i)&3);
             VGAMAPMASK(mask);
             for(x2=x+i;x2<viewwidth;x2+=4)
             {
                t=pixelangle[x2]+midangle;
                while(t<0) t+=FINEANGLES;
                while(t>=FINEANGLES) t-=FINEANGLES;
                xtex=(word)((((long)t) * NUMPARALLAXTEX * TEXTURESIZE)/FINEANGLES);

                t=xtex>>TEXTURESHIFT;
                if(t!=curtex)
                {
                   if(x2<nextx) nextx=x2,nextxtex=xtex;
                   break;
                }

                texoffs= TEXTUREMASK -((xtex & (TEXTURESIZE - 1) ) << TEXTURESHIFT);
                tend=skyheight-(wallheight[x2]>>3);
                if(tend<=0) continue;
                for(t=0,offs=x2>>2;t<tend;t++,offs+=80)
                   destbuf[offs]=skytex[texoffs+((t*TEXTURESIZE)/skyheight)];
             }
             if(x2>=viewwidth+3) nextx=viewwidth;

          }
          x=nextx;
          xtex=nextxtex;
       }
       while(x<viewwidth);
    }

        if(parallax)
          DrawParallax(MAPSPOT(0,63,0));


    14 to 12. and DrawParallax(mapsegs[0][63]); to DrawParallax(MAPSPOT(0,63,0));

    Clone code fix (WL_ACT2.CPP):

    Code: Select all
                            case officerobj:
                                    if (gamestate.weapon == wp_pistol)
                                      NewState (ob,&s_ofcshoot1);
                                    else if (gamestate.weapon == wp_machinegun)
                                      NewState (ob,&s_ofc2shoot1);   
                                    break;


    And I share,that sound change too:

    Code: Select all
           case officerobj:
             if (gamestate.weapon == wp_pistol)       
             PlaySoundLocActor(NAZIFIRESND,ob);   
             else if (gamestate.weapon == wp_machinegun)       
               PlaySoundLocActor(SSFIRESND,ob);
               break;
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        

    Postby AshenOne 02 Aug 2018, 16:37

    ..
    Last edited by AshenOne on 13 Jun 2022, 18:51, edited 2 times in total.
    AshenOne

     
    Posts: 31

      

    Postby Officer-Michael John 02 Aug 2018, 19:24

    AshenOne wrote:Ok, but why you shared them?
    Btw it's good to see that you returned to discord once again, I thought it was too boring for you, but as I see it isn't boring at all when there's someone who fix your errors right? :wink:


    Therefore,that if who want to use these. I came back until I don't have fixes.
    Officer-Michael John
    User avatar

     
    Posts: 185
    Location: Hungary

        


    Return to General Wolf3D/modding Discussion and tutorials


    Who is online

    Users browsing this forum: No registered users and 1 guest