|
|
1.1 root 1: 1.1.1.3 ! root 2: //************************************************************************** ! 3: //** ! 4: //** p_ceilng.c : Heretic 2 : Raven Software, Corp. ! 5: //** ! 6: //** $RCSfile: p_ceilng.c,v $ ! 7: //** $Revision: 1.17 $ ! 8: //** $Date: 95/09/11 22:06:25 $ ! 9: //** $Author: cjr $ ! 10: //** ! 11: //************************************************************************** ! 12: ! 13: #include "h2def.h" ! 14: #include "p_local.h" 1.1.1.2 root 15: #include "soundst.h" 16: 17: //================================================================== 18: //================================================================== 19: // 1.1.1.3 ! root 20: // CEILINGS 1.1.1.2 root 21: // 22: //================================================================== 23: //================================================================== 1.1 root 24: 1.1.1.3 ! root 25: ceiling_t *activeceilings[MAXCEILINGS]; 1.1 root 26: 1.1.1.2 root 27: //================================================================== 28: // 1.1.1.3 ! root 29: // T_MoveCeiling 1.1.1.2 root 30: // 31: //================================================================== 1.1 root 32: void T_MoveCeiling (ceiling_t *ceiling) 33: { 1.1.1.3 ! root 34: result_e res; ! 35: 1.1 root 36: switch(ceiling->direction) 37: { 1.1.1.3 ! root 38: // case 0: // IN STASIS ! 39: // break; ! 40: case 1: // UP 1.1 root 41: res = T_MovePlane(ceiling->sector,ceiling->speed, 1.1.1.3 ! root 42: ceiling->topheight, false, 1, ceiling->direction); ! 43: if (res == RES_PASTDEST) ! 44: { ! 45: SN_StopSequence((mobj_t *)&ceiling->sector->soundorg); 1.1 root 46: switch(ceiling->type) 47: { 1.1.1.3 ! root 48: case CLEV_CRUSHANDRAISE: 1.1 root 49: ceiling->direction = -1; 1.1.1.3 ! root 50: ceiling->speed = ceiling->speed*2; 1.1 root 51: break; 52: default: 1.1.1.3 ! root 53: P_RemoveActiveCeiling(ceiling); 1.1 root 54: break; 55: } 1.1.1.3 ! root 56: } 1.1 root 57: break; 1.1.1.3 ! root 58: case -1: // DOWN 1.1 root 59: res = T_MovePlane(ceiling->sector,ceiling->speed, 1.1.1.3 ! root 60: ceiling->bottomheight, ceiling->crush, 1, ceiling->direction); ! 61: if(res == RES_PASTDEST) ! 62: { ! 63: SN_StopSequence((mobj_t *)&ceiling->sector->soundorg); 1.1 root 64: switch(ceiling->type) 65: { 1.1.1.3 ! root 66: case CLEV_CRUSHANDRAISE: ! 67: case CLEV_CRUSHRAISEANDSTAY: 1.1 root 68: ceiling->direction = 1; 1.1.1.3 ! root 69: ceiling->speed = ceiling->speed/2; 1.1 root 70: break; 71: default: 1.1.1.3 ! root 72: P_RemoveActiveCeiling(ceiling); 1.1 root 73: break; 74: } 1.1.1.3 ! root 75: } ! 76: else if(res == RES_CRUSHED) ! 77: { 1.1 root 78: switch(ceiling->type) 79: { 1.1.1.3 ! root 80: case CLEV_CRUSHANDRAISE: ! 81: case CLEV_LOWERANDCRUSH: ! 82: case CLEV_CRUSHRAISEANDSTAY: ! 83: //ceiling->speed = ceiling->speed/4; 1.1 root 84: break; 85: default: 86: break; 87: } 1.1.1.3 ! root 88: } 1.1 root 89: break; 90: } 91: } 92: 1.1.1.2 root 93: //================================================================== 94: // 1.1.1.3 ! root 95: // EV_DoCeiling ! 96: // Move a ceiling up/down and all around! 1.1.1.2 root 97: // 98: //================================================================== 1.1.1.3 ! root 99: int EV_DoCeiling (line_t *line, byte *arg, ceiling_e type) 1.1 root 100: { 1.1.1.3 ! root 101: int secnum,rtn; ! 102: sector_t *sec; ! 103: ceiling_t *ceiling; ! 104: 1.1 root 105: secnum = -1; 106: rtn = 0; 1.1.1.3 ! root 107: ! 108: /* Old Ceiling stasis code 1.1.1.2 root 109: // 1.1.1.3 ! root 110: // Reactivate in-stasis ceilings...for certain types. 1.1.1.2 root 111: // 1.1 root 112: switch(type) 113: { 1.1.1.3 ! root 114: case CLEV_CRUSHANDRAISE: 1.1 root 115: P_ActivateInStasisCeiling(line); 116: default: 117: break; 118: } 1.1.1.3 ! root 119: */ ! 120: while ((secnum = P_FindSectorFromTag(arg[0], secnum)) >= 0) 1.1 root 121: { 122: sec = §ors[secnum]; 123: if (sec->specialdata) 124: continue; 1.1.1.3 ! root 125: 1.1.1.2 root 126: // 127: // new door thinker 128: // 1.1 root 129: rtn = 1; 130: ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); 131: P_AddThinker (&ceiling->thinker); 132: sec->specialdata = ceiling; 133: ceiling->thinker.function = T_MoveCeiling; 134: ceiling->sector = sec; 1.1.1.3 ! root 135: ceiling->crush = 0; ! 136: ceiling->speed = arg[1]*(FRACUNIT/8); 1.1 root 137: switch(type) 138: { 1.1.1.3 ! root 139: case CLEV_CRUSHRAISEANDSTAY: ! 140: ceiling->crush = arg[2]; // arg[2] = crushing value 1.1 root 141: ceiling->topheight = sec->ceilingheight; 1.1.1.2 root 142: ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); 1.1 root 143: ceiling->direction = -1; 144: break; 1.1.1.3 ! root 145: case CLEV_CRUSHANDRAISE: 1.1 root 146: ceiling->topheight = sec->ceilingheight; 1.1.1.3 ! root 147: case CLEV_LOWERANDCRUSH: ! 148: ceiling->crush = arg[2]; // arg[2] = crushing value ! 149: case CLEV_LOWERTOFLOOR: 1.1 root 150: ceiling->bottomheight = sec->floorheight; 1.1.1.3 ! root 151: if(type != CLEV_LOWERTOFLOOR) ! 152: { 1.1.1.2 root 153: ceiling->bottomheight += 8*FRACUNIT; 1.1.1.3 ! root 154: } 1.1 root 155: ceiling->direction = -1; 156: break; 1.1.1.3 ! root 157: case CLEV_RAISETOHIGHEST: 1.1 root 158: ceiling->topheight = P_FindHighestCeilingSurrounding(sec); 159: ceiling->direction = 1; 1.1.1.3 ! root 160: break; ! 161: case CLEV_LOWERBYVALUE: ! 162: ceiling->bottomheight = sec->ceilingheight-arg[2]*FRACUNIT; ! 163: ceiling->direction = -1; ! 164: break; ! 165: case CLEV_RAISEBYVALUE: ! 166: ceiling->topheight = sec->ceilingheight+arg[2]*FRACUNIT; ! 167: ceiling->direction = 1; ! 168: break; ! 169: case CLEV_MOVETOVALUETIMES8: ! 170: { ! 171: int destHeight = arg[2]*FRACUNIT*8; ! 172: ! 173: if(arg[3]) ! 174: { ! 175: destHeight = -destHeight; ! 176: } ! 177: if(sec->ceilingheight <= destHeight) ! 178: { ! 179: ceiling->direction = 1; ! 180: ceiling->topheight = destHeight; ! 181: if(sec->ceilingheight == destHeight) ! 182: { ! 183: rtn = 0; ! 184: } ! 185: } ! 186: else if(sec->ceilingheight > destHeight) ! 187: { ! 188: ceiling->direction = -1; ! 189: ceiling->bottomheight = destHeight; ! 190: } ! 191: break; ! 192: } ! 193: default: ! 194: rtn = 0; 1.1 root 195: break; 196: } 197: ceiling->tag = sec->tag; 198: ceiling->type = type; 199: P_AddActiveCeiling(ceiling); 1.1.1.3 ! root 200: if(rtn) ! 201: { ! 202: SN_StartSequence((mobj_t *)&ceiling->sector->soundorg, ! 203: SEQ_PLATFORM+ceiling->sector->seqType); ! 204: } 1.1 root 205: } 206: return rtn; 207: } 208: 1.1.1.2 root 209: //================================================================== 210: // 1.1.1.3 ! root 211: // Add an active ceiling 1.1.1.2 root 212: // 213: //================================================================== 1.1 root 214: void P_AddActiveCeiling(ceiling_t *c) 215: { 1.1.1.3 ! root 216: int i; 1.1 root 217: for (i = 0; i < MAXCEILINGS;i++) 218: if (activeceilings[i] == NULL) 219: { 220: activeceilings[i] = c; 221: return; 222: } 223: } 224: 1.1.1.2 root 225: //================================================================== 226: // 1.1.1.3 ! root 227: // Remove a ceiling's thinker 1.1.1.2 root 228: // 229: //================================================================== 1.1 root 230: void P_RemoveActiveCeiling(ceiling_t *c) 231: { 1.1.1.3 ! root 232: int i; ! 233: 1.1 root 234: for (i = 0;i < MAXCEILINGS;i++) 235: if (activeceilings[i] == c) 236: { 237: activeceilings[i]->sector->specialdata = NULL; 238: P_RemoveThinker (&activeceilings[i]->thinker); 1.1.1.3 ! root 239: P_TagFinished(activeceilings[i]->sector->tag); 1.1 root 240: activeceilings[i] = NULL; 241: break; 242: } 243: } 244: 1.1.1.3 ! root 245: #if 0 1.1.1.2 root 246: //================================================================== 247: // 1.1.1.3 ! root 248: // Restart a ceiling that's in-stasis 1.1.1.2 root 249: // 250: //================================================================== 1.1 root 251: void P_ActivateInStasisCeiling(line_t *line) 252: { 1.1.1.3 ! root 253: int i; ! 254: 1.1 root 255: for (i = 0;i < MAXCEILINGS;i++) 1.1.1.3 ! root 256: if (activeceilings[i] && (activeceilings[i]->tag == line->arg1) && 1.1 root 257: (activeceilings[i]->direction == 0)) 258: { 259: activeceilings[i]->direction = activeceilings[i]->olddirection; 260: activeceilings[i]->thinker.function = T_MoveCeiling; 1.1.1.3 ! root 261: SN_StartSequence((mobj_t *)&activeceilings[i]->sector->soundorg, ! 262: SEQ_PLATFORM+activeceilings[i]->sector->seqType); 1.1 root 263: } 264: } 1.1.1.3 ! root 265: #endif 1.1 root 266: 1.1.1.2 root 267: //================================================================== 268: // 1.1.1.3 ! root 269: // EV_CeilingCrushStop ! 270: // Stop a ceiling from crushing! 1.1.1.2 root 271: // 272: //================================================================== 1.1.1.3 ! root 273: ! 274: int EV_CeilingCrushStop(line_t *line, byte *args) 1.1 root 275: { 1.1.1.3 ! root 276: int i; ! 277: int rtn; ! 278: 1.1 root 279: rtn = 0; 280: for (i = 0;i < MAXCEILINGS;i++) 1.1.1.3 ! root 281: { ! 282: if(activeceilings[i] && activeceilings[i]->tag == args[0]) 1.1 root 283: { 284: rtn = 1; 1.1.1.3 ! root 285: SN_StopSequence((mobj_t*)&activeceilings[i]->sector->soundorg); ! 286: activeceilings[i]->sector->specialdata = NULL; ! 287: P_RemoveThinker (&activeceilings[i]->thinker); ! 288: P_TagFinished(activeceilings[i]->sector->tag); ! 289: activeceilings[i] = NULL; ! 290: break; 1.1 root 291: } 1.1.1.3 ! root 292: } 1.1 root 293: return rtn; 294: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.