Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile

Wolf3d Haven Forum

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Wolf3d Haven Forum

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


2 posters

    Coding question: Confusion over a step-by-step tutorial

    segwayspeedracer
    segwayspeedracer
    Wolf3d n00b
    Wolf3d n00b


    Number of posts : 8
    Age : 34
    Registration date : 2014-01-31

    Coding question: Confusion over a step-by-step tutorial Empty Coding question: Confusion over a step-by-step tutorial

    Post by segwayspeedracer Sun Oct 26, 2014 5:01 pm

    Hello wolfers,

    I have a question that I am not sure is either very simple or annoyingly specific. I want to make a simple source code edit to Wolfenstein 3d. I am using this tutorial http://www.wolfenstein3d.co.uk/coding-pacenemy.htm to change the pac-man ghosts into one shootable enemy. 

    I followed the steps perfectly, but when I compiled I got a bunch of errors:

    Errors

    The compiler stopped at wl_act2.cpp, so it's very likely the errors will continue past this section.

    Is there something wildly obvious wrong with what I'm doing or with this code? I apologize if I'm asking too specific of a coding question. I am trying to learn it in my spare time.

    Any help would be great appreciated Coding question: Confusion over a step-by-step tutorial Icon_smile

    - segwayspeedracer
    Nexion
    Nexion
    Seasoned Wolfer
    Seasoned Wolfer


    Number of posts : 277
    Age : 111
    Location : Dimension of Anti-Time
    Hobbie : bringing chaos & madness into universe
    Message : Planet N
    Registration date : 2008-02-27

    Coding question: Confusion over a step-by-step tutorial Empty patch 1.0

    Post by Nexion Sun Oct 26, 2014 5:30 pm

    This tutorial was written for the DOS version of the code which differs in some aspect to the windows port version which you are using.
    s_inkychase1 and co. you probably need to define like the rest - "extern statetype s_inkychase1;"

    ...SPR_BLINKY_W1,10,T_Chase,NULL...
    should be also:
    ...SPR_BLINKY_W1,10,(statefunc)T_Chase,NULL...

    You can check in already existing code (like for the officer) how it looks there.

    In SpawnGhosts for example:
    new->obclass = ghostobj;
    should be changed to:
    newobj->obclass = ghostobj;

    also for the rest of the "new->".
    Also you maybe forgot or mistyped ; at end of lines.
    segwayspeedracer
    segwayspeedracer
    Wolf3d n00b
    Wolf3d n00b


    Number of posts : 8
    Age : 34
    Registration date : 2014-01-31

    Coding question: Confusion over a step-by-step tutorial Empty Re: Coding question: Confusion over a step-by-step tutorial

    Post by segwayspeedracer Sun Oct 26, 2014 5:47 pm

    Awesome. This makes a ton of sense.. I noticed some things were slightly different. Thank you so much!

    alien
    segwayspeedracer
    segwayspeedracer
    Wolf3d n00b
    Wolf3d n00b


    Number of posts : 8
    Age : 34
    Registration date : 2014-01-31

    Coding question: Confusion over a step-by-step tutorial Empty [Solution posted] Coding Pac-Man as One Enemy.

    Post by segwayspeedracer Tue Oct 28, 2014 1:23 pm

    Here's how I got it to work.

    1) In wl_act2.cpp, around line 450, inside the GUARD section, underneath the guard externs and statetypes:

    //
    // ghosts
    //

    extern  statetype s_blinkywait1;

    extern  statetype s_blinkychase1;
    extern  statetype s_blinkychase2;
    extern  statetype s_blinkychase3;
    extern  statetype s_blinkychase4;

    extern  statetype s_blinkydie1;
    extern  statetype s_blinkydie2;
    extern  statetype s_blinkydie3;
    extern  statetype s_blinkydie4;

    statetype s_blinkywait1          = {false,SPR_BLINKY_W1,0,(statefunc)T_Stand,NULL,&s_blinkywait1};

    statetype s_blinkychase1         = {false,SPR_BLINKY_W1,10,(statefunc)T_Ghosts,NULL,&s_blinkychase2};
    statetype s_blinkychase2         = {false,SPR_BLINKY_W2,10,(statefunc)T_Ghosts,NULL,&s_blinkychase3};
    statetype s_blinkychase3         = {false,SPR_PINKY_W1,10,(statefunc)T_Ghosts,NULL,&s_blinkychase4};
    statetype s_blinkychase4         = {false,SPR_PINKY_W2,10,(statefunc)T_Ghosts,NULL,&s_blinkychase1};

    statetype s_blinkydie1          = {false,SPR_INKY_W1,10,NULL,NULL,&s_blinkydie2};
    statetype s_blinkydie2          = {false,SPR_INKY_W2,10,NULL,NULL,&s_blinkydie3};
    statetype s_blinkydie3          = {false,SPR_CLYDE_W1,10,NULL,NULL,&s_blinkydie4};
    statetype s_blinkydie4          = {false,SPR_CLYDE_W2,10,NULL,NULL,&s_blinkydie4};
    #endif

    2) In wl_Act2, Around line 2004, inside the SCHABBS / GIFT / FAT section. There's an #indef SPEAR at the beginning. Immediately following:

    /*
    ===============
    =
    = SpawnGhosts
    =
    ===============
    */

    #indef SPEAR

    void SpawnGhosts (int which, int tilex, int tiley)
    {
         SpawnNewObj (tilex,tiley,&s_blinkywait1);
         newobj->obclass = ghostobj;
         newobj->speed = SPDDOG;
         newobj->dir = nodir;
         newobj->hitpoints = starthitpoints[gamestate.difficulty][en_blinky];
         newobj->flags |= FL_SHOOTABLE; //change to |= FL_SHOOTABLE|FL_AMBUSH; if you want ghost to initiate attack only on sight
         if (!loadedgame)
             gamestate.killtotal++;
    }

    3) In wl_def.h, around line 1253, insert this inside WL_ACT2 DEFINITIONS. I put it underneath s_grddie1:

    extern  statetype s_blinkydie1;

    3.b) Also, place this in a slightly lower section. I chose to put it above s_hitlerchase1:

    extern  statetype s_blinkychase1;


    4) In wl_state.cpp, insert this inside KILLACTOR Section. I put it directly underneath case_dogobj;

            case ghostobj:
                GivePoints (1000);
                NewState (ob,&s_blinkydie1);
                break;

    5) In wl_state.cpp, insert this in First Sighting section. I put it directly underneath case_realhitlerobj;

            case ghostobj:
                PlaySoundLocActor(SCHABBSHASND,ob);
                NewState (ob,&s_blinkychase1);
                ob->speed *=2;          // go faster when chasing player
                break;

    6) In wl_state.cpp, insert this in Sight Player section. I put it directly above case_bossobj;

                case ghostobj:

    This should be it.

    I'm getting an error message if I try to incorporate a death sound, so I can work out the kinks of that later. Note that this is my flavor for a pac-man ghost enemy. I like to have him wait until he hears me to attack. Pac-Man actually charges after you once the game begins. If you want to have this, for step 2, change

         SpawnNewObj (tilex,tiley,&s_blinkywait1);

    into

         SpawnNewObj (tilex,tiley,&s_blinkychase1);

    Also, I prefer   

         newobj->speed = SPDDOG;

    if this is too fast, you can change to

         newobj->speed = SPDPATROL;

    and then, if you want to adjust from there, change, in STEP 5, the number 2 to a different number.

                ob->speed *=2;          // go faster when chasing player

    Hope I helped! I'll tidy up this post later. I'm off to work.

    Sponsored content


    Coding question: Confusion over a step-by-step tutorial Empty Re: Coding question: Confusion over a step-by-step tutorial

    Post by Sponsored content


      Current date/time is Thu Nov 21, 2024 6:39 am