Example #1
0
//
// Function that changes wall texture.
// Tell it if switch is ok to use again (1=yes, it's a button).
//
void P_ChangeSwitchTexture(line_t *line, int useAgain)
{
    int         i = 0;
    int         swtex;
    side_t      *side = &sides[line->sidenum[0]];
    short       texTop = side->toptexture;
    short       texMid = side->midtexture;
    short       texBot = side->bottomtexture;

    // don't zero line->special until after exit switch test
    if (!useAgain)
        line->special = 0;

    // search for a texture to change
    do
    {
        swtex = switchlist[i];

        if (swtex == texTop)
        {
            S_StartSectorSound(&line->soundorg, sfx_swtchn);
            if (useAgain)
                P_StartButton(line, top, swtex, BUTTONTIME);
            side->toptexture = switchlist[i ^ 1];
            break;
        }
        else if (swtex == texMid)
        {
            S_StartSectorSound(&line->soundorg, sfx_swtchn);
            if (useAgain)
                P_StartButton(line, middle, swtex, BUTTONTIME);
            side->midtexture = switchlist[i ^ 1];
            break;
        }
        else if (swtex == texBot)
        {
            S_StartSectorSound(&line->soundorg, sfx_swtchn);
            if (useAgain)
                P_StartButton(line, bottom, swtex, BUTTONTIME);
            side->bottomtexture = switchlist[i ^ 1];
            break;
        }
        i++;
    } while (swtex != -1);
}
Example #2
0
//
// Move a plat up and down
//
void T_PlatRaise(plat_t *plat)
{
    result_e    res;

    if (freeze)
        return;

    switch (plat->status)
    {
        case up:
            res = T_MovePlane(plat->sector, plat->speed, plat->high, plat->crush, 0, 1, false);

            if (plat->type == raiseAndChange || plat->type == raiseToNearestAndChange)
                if (!(leveltime & 7) && plat->sector->floorheight != plat->high)
                    S_StartSectorSound(&plat->sector->soundorg, sfx_stnmov);

            if (res == crushed && !plat->crush)
            {
                plat->count = plat->wait;
                plat->status = down;
                S_StartSectorSound(&plat->sector->soundorg, sfx_pstart);
            }
            else
            {
                if (res == pastdest)
                {
                    // if not an instant toggle type, wait, make plat stop sound
                    if (plat->type != toggleUpDn)
                    {
                        plat->count = plat->wait;
                        plat->status = waiting;
                        S_StartSectorSound(&plat->sector->soundorg, sfx_pstop);
                    }
                    else // else go into stasis awaiting next toggle activation
                    {
                        plat->oldstatus = plat->status; // jff 3/14/98 after action wait
                        plat->status = in_stasis;       // for reactivation of toggle
                    }

                    switch (plat->type)
                    {
                        case blazeDWUS:
                        case downWaitUpStay:
                        case raiseAndChange:
                        case raiseToNearestAndChange:
                        case genLift:
                            P_RemoveActivePlat(plat);
                            break;

                        default:
                            break;
                    }
                }
            }

            break;

        case down:
            res = T_MovePlane(plat->sector, plat->speed, plat->low, false, 0, -1, false);

            if (res == pastdest)
            {
                // if not an instant toggle, start waiting, make plat stop sound
                if (plat->type != toggleUpDn)           // jff 3/14/98 toggle up down
                {                                       // is silent, instant, no waiting
                    plat->count = plat->wait;
                    plat->status = waiting;
                    S_StartSectorSound(&plat->sector->soundorg, sfx_pstop);
                }
                else    // instant toggles go into stasis awaiting next activation
                {
                    plat->oldstatus = plat->status;     // jff 3/14/98 after action wait
                    plat->status = in_stasis;           // for reactivation of toggle
                }

                // jff 1/26/98 remove the plat if it bounced so it can be tried again
                // only affects plats that raise and bounce
                switch (plat->type)
                {
                    case raiseAndChange:
                    case raiseToNearestAndChange:
                        P_RemoveActivePlat(plat);

                    default:
                        break;
                }
            }

            break;

        case waiting:
            if (!--plat->count)
            {
                plat->status = (plat->sector->floorheight == plat->low ? up : down);
                S_StartSectorSound(&plat->sector->soundorg, sfx_pstart);
            }

            break;

        case in_stasis:
            break;
    }
}
Example #3
0
//
// Do Platforms
//  "amount" is only used for SOME platforms.
//
dboolean EV_DoPlat(line_t *line, plattype_e type, int amount)
{
    plat_t      *plat;
    int         secnum = -1;
    dboolean    rtn = false;
    sector_t    *sec = NULL;

    // Activate all <type> plats that are in_stasis
    switch (type)
    {
        case perpetualRaise:
            P_ActivateInStasis(line->tag);
            break;

        case toggleUpDn:
            P_ActivateInStasis(line->tag);
            rtn = true;
            break;

        default:
            break;
    }

    while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
    {
        sec = sectors + secnum;

        if (P_SectorActive(floor_special, sec))
            continue;

        // Find lowest & highest floors around sector
        rtn = true;
        plat = Z_Calloc(1, sizeof(*plat), PU_LEVSPEC, NULL);
        P_AddThinker(&plat->thinker);

        plat->type = type;
        plat->sector = sec;
        plat->sector->floordata = plat;
        plat->thinker.function = T_PlatRaise;
        plat->tag = line->tag;
        plat->low = sec->floorheight;

        switch (type)
        {
            case raiseToNearestAndChange:
                plat->speed = PLATSPEED / 2;
                sec->floorpic = sides[line->sidenum[0]].sector->floorpic;
                plat->high = P_FindNextHighestFloor(sec, sec->floorheight);
                plat->status = up;
                sec->special = 0;
                S_StartSectorSound(&sec->soundorg, sfx_stnmov);
                break;

            case raiseAndChange:
                plat->speed = PLATSPEED / 2;
                sec->floorpic = sides[line->sidenum[0]].sector->floorpic;
                plat->high = sec->floorheight + amount * FRACUNIT;
                plat->status = up;
                S_StartSectorSound(&sec->soundorg, sfx_stnmov);
                break;

            case downWaitUpStay:
                plat->speed = PLATSPEED * 4;
                plat->low = MIN(P_FindLowestFloorSurrounding(sec), sec->floorheight);
                plat->high = sec->floorheight;
                plat->wait = TICRATE * PLATWAIT;
                plat->status = down;
                S_StartSectorSound(&sec->soundorg, sfx_pstart);
                break;

            case blazeDWUS:
                plat->speed = PLATSPEED * 8;
                plat->low = MIN(P_FindLowestFloorSurrounding(sec), sec->floorheight);
                plat->high = sec->floorheight;
                plat->wait = TICRATE * PLATWAIT;
                plat->status = down;
                S_StartSectorSound(&sec->soundorg, sfx_pstart);
                break;

            case perpetualRaise:
                plat->speed = PLATSPEED;
                plat->low = MIN(P_FindLowestFloorSurrounding(sec), sec->floorheight);
                plat->high = MAX(sec->floorheight, P_FindHighestFloorSurrounding(sec));
                plat->wait = TICRATE * PLATWAIT;
                plat->status = (plat_e)(M_Random() & 1);
                S_StartSectorSound(&sec->soundorg, sfx_pstart);
                break;

            case toggleUpDn:                        // jff 3/14/98 add new type to support instant toggle
                plat->speed = PLATSPEED;            // not used
                plat->wait = TICRATE * PLATWAIT;    // not used
                plat->crush = true;                 // jff 3/14/98 crush anything in the way

                // set up toggling between ceiling, floor inclusive
                plat->low = sec->ceilingheight;
                plat->high = sec->floorheight;
                plat->status = down;
                break;

            default:
                break;
        }

        P_AddActivePlat(plat);
    }

    if (sec)
        for (int i = 0; i < sec->linecount; i++)
            sec->lines[i]->flags &= ~ML_SECRET;

    return rtn;
}