Wolf3d Haven Forum

Please log in or register. Smile
Wolf3d Haven Forum

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


    SDL Error regarding player sighting

    Share

    Dr.Zin
    Bring em' On!
    Bring em' On!

    Male
    Number of posts : 180
    Age : 32
    Location : Nowhere
    Message : General Programmer
    World of Tanks Username: ToreHund
    Registration date : 2010-08-11

    SDL Error regarding player sighting

    Post by Dr.Zin on Sat Sep 03, 2011 5:10 pm

    I've encountered what appears to be an SDL bug when trying to add new enemies. I did some searching over at DHW and there seems to be no solution as of yet but when adding a new enemy using MCS's method (basically copying existing code and changing names to suit) one gets thrown an "An actor in ATTACKMODE called SightPlayer!" error. I've looked all over to see why this is happening but to no avail. After messing with it and commenting out the code which checks if the actor is in ATTACKMODE, I was rather surprised to find that it rendered the guards completely static. Even shooting them did not activate them or even hurt them. So, I faced them northwards and an even more surprising thing happens, when alerted they turn into Ubermutants! I went and checked to make sure that my Ubermuntant code was fine and it checked out as well (I simply moved the code around to outside of one of the ifdef SPEAR blocks). And obviously I checked to make sure the spawn functions spawned the new guard object rather than the Ubermutant object. Richter Belmont had a similar problem with his new guards turning into plants. I am including both the FirstSighting() and SightPlayer() functions below. Any work around for this would be greatly appreciated.

    Spoiler:



    Code:

    /*
    ===============
    =
    = FirstSighting
    =
    = Puts an actor into attack mode and possibly reverses the direction
    = if the player is behind it
    =
    ===============
    */

    void FirstSighting (objtype *ob)
    {
        //
        // react to the player
        //
        switch (ob->obclass)
        {
            case guardobj:
                PlaySoundLocActor(HALTSND,ob);
                NewState (ob,&s_grdchase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case officerobj:
                PlaySoundLocActor(SPIONSND,ob);
                NewState (ob,&s_ofcchase1);
                ob->speed *= 5;                // go faster when chasing player
                break;

             //r23: Adding Liebenstandart Guard
            case liebengrdobj:
             PlaySoundLocActor(HALTSND,ob);
             NewState (ob,&s_lgdchase1);
             ob->speed *= 3;  // go faster when chasing player
             break;

            case mutantobj:
                NewState (ob,&s_mutchase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case ssobj:
                PlaySoundLocActor(SCHUTZADSND,ob);
                NewState (ob,&s_sschase1);
                ob->speed *= 4;                // go faster when chasing player
                break;

            case dogobj:
                PlaySoundLocActor(DOGBARKSND,ob);
                NewState (ob,&s_dogchase1);
                ob->speed *= 2;                // go faster when chasing player
                break;

    #ifndef SPEAR
            case bossobj:
                SD_PlaySound(GUTENTAGSND);
                NewState (ob,&s_bosschase1);
                ob->speed = SPDPATROL*3;        // go faster when chasing player
                break;

    #ifndef APOGEE_1_0
            case gretelobj:
                SD_PlaySound(KEINSND);
                NewState (ob,&s_gretelchase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case giftobj:
                SD_PlaySound(EINESND);
                NewState (ob,&s_giftchase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case fatobj:
                SD_PlaySound(ERLAUBENSND);
                NewState (ob,&s_fatchase1);
                ob->speed *= 3;                // go faster when chasing player
                break;
    #endif

            case schabbobj:
                SD_PlaySound(SCHABBSHASND);
                NewState (ob,&s_schabbchase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case fakeobj:
                SD_PlaySound(TOT_HUNDSND);
                NewState (ob,&s_fakechase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case mechahitlerobj:
                SD_PlaySound(DIESND);
                NewState (ob,&s_mechachase1);
                ob->speed *= 3;                // go faster when chasing player
                break;

            case realhitlerobj:
                SD_PlaySound(DIESND);
                NewState (ob,&s_hitlerchase1);
                ob->speed *= 5;                // go faster when chasing player
                break;

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

             //r14: Adding Ubermutant
            case uberobj:
                NewState (ob,&s_uberchase1);
                ob->speed = 3000;                      // go faster when chasing player
                break;
             //r17: adding deathknight
            case deathobj:
                SD_PlaySound(KNGITHSIGHTSND);
                NewState (ob,&s_deathchase1);
                ob->speed = 2048;                      // go faster when chasing player
                break;
    #else
            case spectreobj:
                SD_PlaySound(GHOSTSIGHTSND);
                NewState (ob,&s_spectrechase1);
                ob->speed = 800;                        // go faster when chasing player
                break;

            case angelobj:
                SD_PlaySound(ANGELSIGHTSND);
                NewState (ob,&s_angelchase1);
                ob->speed = 1536;                      // go faster when chasing player
                break;

            case transobj:
                SD_PlaySound(TRANSSIGHTSND);
                NewState (ob,&s_transchase1);
                ob->speed = 1536;                      // go faster when chasing player
                break;

            case uberobj:
                NewState (ob,&s_uberchase1);
                ob->speed = 3000;                      // go faster when chasing player
                break;

            case willobj:
                SD_PlaySound(WILHELMSIGHTSND);
                NewState (ob,&s_willchase1);
                ob->speed = 2048;                      // go faster when chasing player
                break;
    #endif
        }

        if (ob->distance < 0)
            ob->distance = 0;      // ignore the door opening command

        ob->flags |= FL_ATTACKMODE|FL_FIRSTATTACK;
    }



    /*
    ===============
    =
    = SightPlayer
    =
    = Called by actors that ARE NOT chasing the player.  If the player
    = is detected (by sight, noise, or proximity), the actor is put into
    = it's combat frame and true is returned.
    =
    = Incorporates a random reaction delay
    =
    ===============
    */

    boolean SightPlayer (objtype *ob)
    {
        if (ob->flags & FL_ATTACKMODE)
            Quit ("An actor in ATTACKMODE called SightPlayer!");

        if (ob->temp2)
        {
            //
            // count down reaction time
            //
            ob->temp2 -= (short) tics;
            if (ob->temp2 > 0)
                return false;
            ob->temp2 = 0;                                  // time to react
        }
        else
        {
            if (!areabyplayer[ob->areanumber])
                return false;

            if (ob->flags & FL_AMBUSH)
            {
                if (!CheckSight (ob))
                    return false;
                ob->flags &= ~FL_AMBUSH;
            }
            else
            {
                if (!madenoise && !CheckSight (ob))
                    return false;
            }


            switch (ob->obclass)
            {
                case guardobj:
                    ob->temp2 = 1+US_RndT()/4;
                    break;
                case officerobj:
                    ob->temp2 = 2;
                    break;
             case liebengrdobj: //r23: Adding Liebenstandart Guard
                    ob->temp2 = 1+US_RndT()/4;
                    break;
                case mutantobj:
                    ob->temp2 = 1+US_RndT()/6;
                    break;
                case ssobj:
                    ob->temp2 = 1+US_RndT()/6;
                    break;
                case dogobj:
                    ob->temp2 = 1+US_RndT()/8;
                    break;

                case bossobj:
                case schabbobj:
                case fakeobj:
                case mechahitlerobj:
                case realhitlerobj:
                case gretelobj:
                case giftobj:
                case fatobj:
                case spectreobj:
                case angelobj:
                case transobj:
                case uberobj:
                case willobj:
                case deathobj:
                    ob->temp2 = 1;
                    break;
            }
            return false;
        }

        FirstSighting (ob);

        return true;
    }



    If a packet hits a pocket on a socket on a port,
    and the bus is interupted as a very last resort,
    and the address of the memory makes your floppy disk abort
    then the socket packet pocket has an error to report!

    http://radix-16.com/
    Wolf3d Chat

    Dr.Zin
    Bring em' On!
    Bring em' On!

    Male
    Number of posts : 180
    Age : 32
    Location : Nowhere
    Message : General Programmer
    World of Tanks Username: ToreHund
    Registration date : 2010-08-11

    Re: SDL Error regarding player sighting

    Post by Dr.Zin on Sat Sep 03, 2011 5:20 pm

    Nevermind, call me Dr.Idiot, when in a frenzy some weeks ago when adding the Ubermutant, I moved the Uberminant's spot upward in the classtype enum. So, a note to those adding SoD bosses: DON'T MOVE THEIR SPOT IN THE CLASSTYPE ENUM! Obvious I know but hey, I'm tired Razz.



    If a packet hits a pocket on a socket on a port,
    and the bus is interupted as a very last resort,
    and the address of the memory makes your floppy disk abort
    then the socket packet pocket has an error to report!

    http://radix-16.com/
    Wolf3d Chat

      Current date/time is Tue Dec 06, 2016 2:10 am