示例#1
0
void DDoor::Tick ()
{
	EResult res;

	if (m_Sector->floorplane.d != m_OldFloorDist)
	{
		if (!m_Sector->floordata || !m_Sector->floordata->IsKindOf(RUNTIME_CLASS(DPlat)) ||
			!(barrier_cast<DPlat*>(m_Sector->floordata))->IsLift())
		{
			m_OldFloorDist = m_Sector->floorplane.d;
			m_BotDist = m_Sector->ceilingplane.PointToDist (m_BotSpot,
				m_Sector->floorplane.ZatPoint (m_BotSpot));
		}
	}

	switch (m_Direction)
	{
	case 0:
		// WAITING
		if (!--m_TopCountdown)
		{
			switch (m_Type)
			{
			case doorRaise:
				m_Direction = -1; // time to go back down
				DoorSound (false);
				break;
				
			case doorCloseWaitOpen:
				m_Direction = 1;
				DoorSound (true);
				break;
				
			default:
				break;
			}
		}
		break;
		
	case 2:
		//	INITIAL WAIT
		if (!--m_TopCountdown)
		{
			switch (m_Type)
			{
			case doorRaiseIn5Mins:
				m_Direction = 1;
				m_Type = doorRaise;
				DoorSound (true);
				break;
				
			default:
				break;
			}
		}
		break;
		
	case -1:
		// DOWN
		res = MoveCeiling (m_Speed, m_BotDist, -1, m_Direction, false);

		// killough 10/98: implement gradual lighting effects
		if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d)
		{
			EV_LightTurnOnPartway (m_LightTag, FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d,
				m_TopDist + m_Sector->floorplane.d));
		}

		if (res == pastdest)
		{
			SN_StopSequence (m_Sector, CHAN_CEILING);
			switch (m_Type)
			{
			case doorRaise:
			case doorClose:
				m_Sector->ceilingdata = NULL;	//jff 2/22/98
				Destroy ();						// unlink and free
				break;
				
			case doorCloseWaitOpen:
				m_Direction = 0;
				m_TopCountdown = m_TopWait;
				break;
				
			default:
				break;
			}
		}
		else if (res == crushed)
		{
			switch (m_Type)
			{
			case doorClose:				// DO NOT GO BACK UP!
				break;
				
			default:
				m_Direction = 1;
				DoorSound (true);
				break;
			}
		}
		break;
		
	case 1:
		// UP
		res = MoveCeiling (m_Speed, m_TopDist, -1, m_Direction, false);
		
		// killough 10/98: implement gradual lighting effects
		if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d)
		{
			EV_LightTurnOnPartway (m_LightTag, FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d,
				m_TopDist + m_Sector->floorplane.d));
		}

		if (res == pastdest)
		{
			SN_StopSequence (m_Sector, CHAN_CEILING);
			switch (m_Type)
			{
			case doorRaise:
				m_Direction = 0; // wait at top
				m_TopCountdown = m_TopWait;
				break;
				
			case doorCloseWaitOpen:
			case doorOpen:
				m_Sector->ceilingdata = NULL;	//jff 2/22/98
				Destroy ();						// unlink and free
				break;
				
			default:
				break;
			}
		}
		else if (res == crushed)
		{
			switch (m_Type)
			{
			case doorRaise:
			case doorRaiseIn5Mins:
				m_Direction = -1;
				DoorSound(false);
				break;

			default:
				break;
			}
		}
		break;
	}
}
示例#2
0
void T_VerticalDoor (vldoor_t* door)
{
  result_e  res;

  // Is the door waiting, going up, or going down?
  switch(door->direction)
  {
    case 0:
      // Door is waiting
      if (!--door->topcountdown)  // downcount and check
      {
        switch(door->type)
        {
          case blazeRaise:
          case genBlazeRaise:
            door->direction = -1; // time to go back down
            S_StartSound((mobj_t *)&door->sector->soundorg,sfx_bdcls);
            break;

          case normal:
          case genRaise:
            door->direction = -1; // time to go back down
            S_StartSound((mobj_t *)&door->sector->soundorg,sfx_dorcls);
            break;

          case close30ThenOpen:
          case genCdO:
            door->direction = 1;  // time to go back up
            S_StartSound((mobj_t *)&door->sector->soundorg,sfx_doropn);
            break;

          case genBlazeCdO:
            door->direction = 1;  // time to go back up
            S_StartSound((mobj_t *)&door->sector->soundorg,sfx_bdopn);
            break;

          default:
            break;
        }
      }
      break;

    case 2:
      // Special case for sector type door that opens in 5 mins
      if (!--door->topcountdown)  // 5 minutes up?
      {
        switch(door->type)
        {
          case raiseIn5Mins:
            door->direction = 1;  // time to raise then
            door->type = normal;  // door acts just like normal 1 DR door now
            S_StartSound((mobj_t *)&door->sector->soundorg,sfx_doropn);
            break;

          default:
            break;
        }
      }
      break;

    case -1:
      // Door is moving down
      res = T_MovePlane
            (
              door->sector,
              door->speed,
              door->sector->floorheight,
              false,
              1,
              door->direction
            );

      /* killough 10/98: implement gradual lighting effects */
      // e6y: "Tagged doors don't trigger special lighting" handled wrong
      // http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943
      // Old code: if (door->lighttag && door->topheight - door->sector->floorheight)
      if (door->lighttag && door->topheight - door->sector->floorheight && compatibility_level >= mbf_compatibility)
        EV_LightTurnOnPartway(door->line,
                              FixedDiv(door->sector->ceilingheight -
                                       door->sector->floorheight,
                                       door->topheight -
                                       door->sector->floorheight));

      // handle door reaching bottom
      if (res == pastdest)
      {
        switch(door->type)
        {
          // regular open and close doors are all done, remove them
          case blazeRaise:
          case blazeClose:
          case genBlazeRaise:
          case genBlazeClose:
            door->sector->ceilingdata = NULL;  //jff 2/22/98
            P_RemoveThinker (&door->thinker);  // unlink and free
            // killough 4/15/98: remove double-closing sound of blazing doors
            if (comp[comp_blazing])
              S_StartSound((mobj_t *)&door->sector->soundorg,sfx_bdcls);
            break;

          case normal:
          case closeDoor:
          case genRaise:
          case genClose:
            door->sector->ceilingdata = NULL; //jff 2/22/98
            P_RemoveThinker (&door->thinker);  // unlink and free
            break;

          // close then open doors start waiting
          case close30ThenOpen:
            door->direction = 0;
            door->topcountdown = TICRATE*30;
            break;

          case genCdO:
          case genBlazeCdO:
            door->direction = 0;
            door->topcountdown = door->topwait; // jff 5/8/98 insert delay
            break;

          default:
            break;
        }
        // e6y: "Tagged doors don't trigger special lighting" handled wrong
        // http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943
        if (door->lighttag && door->topheight - door->sector->floorheight && compatibility_level < mbf_compatibility)
          EV_LightTurnOnPartway(door->line,0);
      }
      /* jff 1/31/98 turn lighting off in tagged sectors of manual doors
       * killough 10/98: replaced with gradual lighting code
       */
      else if (res == crushed) // handle door meeting obstruction on way down
      {
        switch(door->type)
        {
          case genClose:
          case genBlazeClose:
          case blazeClose:
          case closeDoor:      // Close types do not bounce, merely wait
            break;

          case blazeRaise:
          case genBlazeRaise:
            door->direction = 1;
	    if (!comp[comp_blazing]) {
	      S_StartSound((mobj_t *)&door->sector->soundorg,sfx_bdopn);
	      break;
	    }

          default:             // other types bounce off the obstruction
            door->direction = 1;
            S_StartSound((mobj_t *)&door->sector->soundorg,sfx_doropn);
            break;
        }
      }
      break;

    case 1:
      // Door is moving up
      res = T_MovePlane
            (
              door->sector,
              door->speed,
              door->topheight,
              false,
              1,
              door->direction
            );

      /* killough 10/98: implement gradual lighting effects */
      // e6y: "Tagged doors don't trigger special lighting" handled wrong
      // http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943
      // Old code: if (door->lighttag && door->topheight - door->sector->floorheight)
      if (door->lighttag && door->topheight - door->sector->floorheight && compatibility_level >= mbf_compatibility)
        EV_LightTurnOnPartway(door->line,
                              FixedDiv(door->sector->ceilingheight -
                                       door->sector->floorheight,
                                       door->topheight -
                                       door->sector->floorheight));

      // handle door reaching the top
      if (res == pastdest)
      {
        switch(door->type)
        {
          case blazeRaise:       // regular open/close doors start waiting
          case normal:
          case genRaise:
          case genBlazeRaise:
            door->direction = 0; // wait at top with delay
            door->topcountdown = door->topwait;
            break;

          case close30ThenOpen:  // close and close/open doors are done
          case blazeOpen:
          case openDoor:
          case genBlazeOpen:
          case genOpen:
          case genCdO:
          case genBlazeCdO:
            door->sector->ceilingdata = NULL; //jff 2/22/98
            P_RemoveThinker (&door->thinker); // unlink and free
            break;

          default:
            break;
        }

        /* jff 1/31/98 turn lighting on in tagged sectors of manual doors
   * killough 10/98: replaced with gradual lighting code */
        // e6y: "Tagged doors don't trigger special lighting" handled wrong
        // http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943
        if (door->lighttag && door->topheight - door->sector->floorheight && compatibility_level < mbf_compatibility)
          EV_LightTurnOnPartway(door->line,FRACUNIT);
      }
      break;
  }
}
示例#3
0
//
// T_VerticalDoor
//
void DDoor::RunThink ()
{
    EResult res;

    switch (m_Direction)
    {
    case 0:
        // WAITING
        if (!--m_TopCountdown)
        {
            switch (m_Type)
            {
            case doorRaise:
                m_Direction = -1; // time to go back down
                DoorSound (false);
                break;

            case doorCloseWaitOpen:
                m_Direction = 1;
                DoorSound (true);
                break;

            default:
                break;
            }
        }
        break;

    case 2:
        //	INITIAL WAIT
        if (!--m_TopCountdown)
        {
            switch (m_Type)
            {
            case doorRaiseIn5Mins:
                m_Direction = 1;
                m_Type = doorRaise;
                DoorSound (true);
                break;

            default:
                break;
            }
        }
        break;

    case -1:
        // DOWN
        res = MoveCeiling (m_Speed, m_Sector->floorheight, false, m_Direction);
        if (m_Line && m_Line->id)
        {
            EV_LightTurnOnPartway(m_Line->id,
                                  FixedDiv(
                                      m_Sector->ceilingheight - m_Sector->floorheight,
                                      m_TopHeight - m_Sector->floorheight
                                  )
                                 );
        }
        if (res == pastdest)
        {
            //S_StopSound (m_Sector->soundorg);
            switch (m_Type)
            {
            case doorRaise:
            case doorClose:
                m_Sector->ceilingdata = NULL;	//jff 2/22/98
                Destroy ();						// unlink and free
                break;

            case doorCloseWaitOpen:
                m_Direction = 0;
                m_TopCountdown = m_TopWait;
                break;

            default:
                break;
            }
            if (m_Line && m_Line->id)
            {
                EV_LightTurnOnPartway(m_Line->id, 0);
            }
        }
        else if (res == crushed)
        {
            switch (m_Type)
            {
            case doorClose:				// DO NOT GO BACK UP!
                break;

            default:
                m_Direction = 1;
                DoorSound (true);
                break;
            }
        }
        break;

    case 1:
        // UP
        res = MoveCeiling (m_Speed, m_TopHeight, false, m_Direction);

        if (m_Line && m_Line->id)
        {
            EV_LightTurnOnPartway(m_Line->id,
                                  FixedDiv(
                                      m_Sector->ceilingheight - m_Sector->floorheight,
                                      m_TopHeight - m_Sector->floorheight
                                  )
                                 );
        }
        if (res == pastdest)
        {
            //S_StopSound (m_Sector->soundorg);
            switch (m_Type)
            {
            case doorRaise:
                m_Direction = 0; // wait at top
                m_TopCountdown = m_TopWait;
                break;

            case doorCloseWaitOpen:
            case doorOpen:
                m_Sector->ceilingdata = NULL;	//jff 2/22/98
                Destroy ();						// unlink and free
                break;

            default:
                break;
            }
            if (m_Line && m_Line->id)
            {
                EV_LightTurnOnPartway(m_Line->id, FRACUNIT);
            }
        }
        break;
    }
}
示例#4
0
//
// T_VerticalDoor
//
void DDoor::RunThink ()
{
	fixed_t ceilingheight = P_CeilingHeight(m_Sector);
	fixed_t floorheight = P_FloorHeight(m_Sector);
	
	EResult res;
		
	switch (m_Status)
	{
	case finished:
		PlayDoorSound();
		// fall through
	case destroy:
		P_SetDoorDestroy(this);
		return;
		
	case waiting:
		// WAITING
		if (!--m_TopCountdown)
		{
			switch (m_Type)
			{
			case doorRaise:
				// time to go back down
				m_Status = closing;
				PlayDoorSound();
				break;
				
			case doorCloseWaitOpen:
				m_Status = opening;
				PlayDoorSound();
				break;
				
			default:
				break;
			}
		}
		break;
		
	case init:
		//	INITIAL WAIT
		if (!--m_TopCountdown)
		{
			switch (m_Type)
			{
			case doorRaiseIn5Mins:
				m_Type = doorRaise;
				m_Status = opening;
				PlayDoorSound();
				break;

			default:
				break;
			}
		}
		break;
		
	case closing:
		res = MoveCeiling(m_Speed, floorheight, false, -1);
		
        if (m_Line && m_Line->id)
        {
            EV_LightTurnOnPartway(m_Line->id,
                FixedDiv(ceilingheight - floorheight, m_TopHeight - floorheight));
        }
		if (res == pastdest)
		{
			//S_StopSound (m_Sector->soundorg);
			SN_StopSequence (m_Sector);
			switch (m_Type)
			{
			case doorRaise:
			case doorClose:
				m_Status = finished;
				return;
				
			case doorCloseWaitOpen:
				m_TopCountdown = m_TopWait;
				m_Status = waiting;
				break;
				
			default:
				break;
			}
            if (m_Line && m_Line->id)
            {
                EV_LightTurnOnPartway(m_Line->id, 0);
            }
		}
		else if (res == crushed)
		{
			switch (m_Type)
			{
			case doorClose:				// DO NOT GO BACK UP!
				break;
				
			default:
				m_Status = reopening;
				PlayDoorSound();
				break;
			}
		}
		break;
		
	case reopening:
	case opening:
		res = MoveCeiling(m_Speed, m_TopHeight, false, 1);
		
        if (m_Line && m_Line->id)
        {
            EV_LightTurnOnPartway(m_Line->id,
                FixedDiv(ceilingheight - floorheight, m_TopHeight - floorheight));
        }
		if (res == pastdest)
		{
			//S_StopSound (m_Sector->soundorg);
			SN_StopSequence (m_Sector);
			switch (m_Type)
			{
			case doorRaise:
				// wait at top
				m_TopCountdown = m_TopWait;
				m_Status = waiting;
				break;
				
			case doorCloseWaitOpen:
			case doorOpen:
				m_Status = finished;
				return;
				
			default:
				break;
			}
            if (m_Line && m_Line->id)
            {
                EV_LightTurnOnPartway(m_Line->id, FRACUNIT);
            }
		}
		break;
	default:
		break;
	}
}
示例#5
0
//
// T_VerticalDoor
//
// Passed a door structure containing all info about the door.
// See P_SPEC.H for fields.
// Returns nothing.
//
// jff 02/08/98 all cases with labels beginning with gen added to support
// generalized line type behaviors.
//
void VerticalDoorThinker::Think()
{
   result_e  res;
   
   // Is the door waiting, going up, or going down?
   switch(direction)
   {
   case plat_stop:
      // Door is waiting
      if(!--topcountdown)  // downcount and check
      {
         switch(type)
         {
         case doorNormal:
         case paramCloseIn: // haleyjd 03/01/05
         case blazeRaise:
            direction = plat_down; // time to go back down
            P_DoorSequence(false, turbo, false, sector); // haleyjd
            break;

         case closeThenOpen:
            direction = plat_up;  // time to go back up
            P_DoorSequence(true, turbo, false, sector); // haleyjd
            break;

         default:
            break;
         }
      }
      break;

   case plat_special: // haleyjd: changed from 2
      // Special case for sector type door that opens in 5 mins
      if(!--topcountdown)  // 5 minutes up?
      {
         switch(type)
         {
         case doorRaiseIn:
            direction = plat_up; // time to raise then
            if(turbo)
               type = blazeRaise; // act like a blaze raise door
            else
               type = doorNormal; // door acts just like normal 1 DR door now
            P_DoorSequence(true, turbo, false, sector); // haleyjd
            break;
            
         default:
            break;
         }
      }
      break;

   case plat_down:
      // Door is moving down
      res = T_MoveCeilingDown(sector, speed, sector->floorheight, -1);

      // killough 10/98: implement gradual lighting effects
      if(lighttag && topheight - sector->floorheight)
         EV_LightTurnOnPartway(lighttag,
                               FixedDiv(sector->ceilingheight - sector->floorheight,
                                        topheight - sector->floorheight));

      // handle door reaching bottom
      if(res == pastdest)
      {
         S_StopSectorSequence(sector, SEQ_ORIGIN_SECTOR_C);

         switch(type)
         {
         // regular raise and close doors are all done, remove them
         case doorNormal:
         case doorClose:
         case blazeRaise:
         case blazeClose:
         case paramCloseIn:      // haleyjd 03/01/05
            sector->ceilingdata = NULL;  //jff 2/22/98
            this->remove();  // unlink and free
            // killough 4/15/98: remove double-closing sound of blazing doors
            // haleyjd 10/06/06: behavior is determined via sound sequence now
            break;

            // close then open doors start waiting
         case closeThenOpen:
            direction    = plat_stop;
            topcountdown = topwait; // jff 5/8/98 insert delay
            break;

         default:
            break;
         }
      }

      //jff 1/31/98 turn lighting off in tagged sectors of manual doors
      // killough 10/98: replaced with gradual lighting code

      else if(res == crushed)
      {
         // handle door meeting obstruction on way down
         switch(type)
         {
         case paramCloseIn:      // haleyjd 03/01/05
         case blazeClose:
         case doorClose:      // Close types do not bounce, merely wait
            break;
            
         default:             // other types bounce off the obstruction
            direction = plat_up;
            P_DoorSequence(true, false, true, sector); // haleyjd
            break;
         }
      }
      break;

   case plat_up:
      // Door is moving up
      res = T_MoveCeilingUp(sector, speed, topheight, -1);

      // killough 10/98: implement gradual lighting effects
      if(lighttag && topheight - sector->floorheight)
         EV_LightTurnOnPartway(lighttag,
                               FixedDiv(sector->ceilingheight - sector->floorheight,
                                        topheight - sector->floorheight));

      // handle door reaching the top
      if(res == pastdest)
      {
         switch(type)
         {
         case blazeRaise:       // regular open/close doors start waiting
         case doorNormal:
            direction    = plat_stop; // wait at top with delay
            topcountdown = topwait;
            break;
            
         case closeThenOpen:  // close and close/open doors are done
         case blazeOpen:
         case doorOpen:
            S_StopSectorSequence(sector, SEQ_ORIGIN_SECTOR_C);
            sector->ceilingdata = NULL; //jff 2/22/98
            this->remove(); // unlink and free
            break;
            
         default:
            break;
         }
      }

      // SoM: With attached sectors, doors can now encounter crushed events while opening
      else if(demo_version >= 333 && res == crushed)
      {
         // handle door meeting obstruction on attached surface moving down
         switch(type)
         {
         case doorOpen:      // Open types do not bounce, merely wait
         case blazeOpen:
            break;
            
         default:             // other types bounce off the obstruction
            direction = plat_down;
            P_DoorSequence(false, false, true, sector); // haleyjd
            break;
         }
      }

      //jff 1/31/98 turn lighting on in tagged sectors of manual doors
      // killough 10/98: replaced with gradual lighting code
      break;
   }
}