(Tutorial) Two door open a Key (as in Doom)

View previous topic View next topic Go down

(Tutorial) Two door open a Key (as in Doom)

Post by Officer-M. John (Admin) on Sun Dec 18, 2016 2:38 pm

This routine is based on the Doom because there is also to open up two door a Key. For a long time it did not go well. I asked it for help, but with no success. Finally WSJ closed door code has been some restructuring. Let's also add:

You need adding new door (but now the dr_lock3 and dr_lock4 door use for 2nd closed door.)

WL_DEF.H:

You changed void OperateDoor (int door); For this code:

Code:

boolean OperateDoor (int door);

WL_ACT1.CPP:

You find it OperateDoor part and you change the entire contents of the following:

Code:

boolean OperateDoor (int door)
{
    int lock  = doorobjlist[door].lock;
    int tilex = doorobjlist[door].tilex;
    int tiley = doorobjlist[door].tiley;

    switch (lock)
    {
        case dr_lock1:
            if (!(gamestate.keys & 1))
            {
                SD_PlaySound (NOWAYSND);
                return false;
            }
            break;
        case dr_lock2:
            if (!(gamestate.keys & 2))
            {
                SD_PlaySound (NOWAYSND);
                return false;
            }
            break;
        case dr_lock3:
            if (!(gamestate.keys & 1))
            {
                SD_PlaySound (NOWAYSND);
                return false;
            }
            break;
        case dr_lock4:
            if (!(gamestate.keys & 2))
            {
                SD_PlaySound (NOWAYSND);
                return false;
    }

    return true;

   
    switch (doorobjlist[door].action)
    {
        case dr_closed:
        case dr_closing:
            OpenDoor (door);
            break;
        case dr_open:
        case dr_opening:
            CloseDoor (door);
            break;           
    }
}

Wow. There we had and 2nd closed doors right now. Thanks WSJ your close door code and ID Software the idea.
avatar
Officer-M. John (Admin)
Admin

Posts : 329
Join date : 2015-10-02
Age : 19

View user profile http://wolf3dfanboys.usersboard.com

Back to top Go down

Re: (Tutorial) Two door open a Key (as in Doom)

Post by Officer-M. John (Admin) Yesterday at 5:09 pm

Updated 18/12/2016 2:38 pm

I found so bug,that sometimes the door doesn't close. I fixed the problem. You need change only in WL_ACT1.CPP:

Code:

void OperateDoor (int door)
{
    int lock  = doorobjlist[door].lock;

    switch (lock)
    {
        case dr_lock1:
        case dr_lock3:
            if (!(gamestate.keys & 1))
            {
                SD_PlaySound (NOWAYSND);
                return;
            }
            break;
        case dr_lock2:
        case dr_lock4:
            if (!(gamestate.keys & 2))
            {
                SD_PlaySound (NOWAYSND);
                return;
            }
            break;
    }

    switch (doorobjlist[door].action)
    {
        case dr_closed:
        case dr_closing:
            OpenDoor (door);
            break;
        case dr_open:
        case dr_opening:
            CloseDoor (door);
            break;
    }
}

Thanks AlumiuN,that you did correct code for problem's fix. Smile
avatar
Officer-M. John (Admin)
Admin

Posts : 329
Join date : 2015-10-02
Age : 19

View user profile http://wolf3dfanboys.usersboard.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum