checkhitswitch

intentionally not merged because this is too messy.
This commit is contained in:
Christoph Oelckers 2020-05-10 18:05:36 +02:00
parent 536e3c886c
commit c9a47d2e44
9 changed files with 1063 additions and 562 deletions

View file

@ -216,6 +216,8 @@ G_EXTERN msy_ msy;
G_EXTERN int32_t g_windTime, g_windDir;
G_EXTERN int16_t g_fakeBubbaCnt, g_mamaSpawnCnt, g_banjoSong, g_bellTime, g_bellSprite;
#define BellTime g_bellTime
#define word_119BE0 g_bellSprite
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS];
G_EXTERN uint8_t enemysizecheat, ufospawnsminion, pistonsound, g_chickenWeaponTimer, g_RAendLevel, g_RAendEpisode, g_fogType;
G_EXTERN int32_t g_cdTrack;
@ -345,9 +347,6 @@ extern psaccess ps;
#define spriteq SpriteDeletionQueue
#define spriteqloc g_spriteDeleteQueuePos
// This is for dealing with those horrible switch/case messes the code is full of.
// With two different sets of tile constants the switches won't do anymore.
inline bool isIn(int value, int first)
{
return value == first;
@ -358,10 +357,13 @@ bool isIn(int value, int first, Args... args)
{
return value == first || isIn(value, args...);
}
// This is for picking between two identical names with different indices, e.g. CRACK and RR_CRACK.
#define pPick(d) (isRR()? (RR_##d) : (d))
// This is mainly for convenience and easier lookup for an eventual cleanup.
#define pPick2(d, r) (isRR()? (r) : (d))
inline bool isIn(int value, const std::initializer_list<int> &list)
{
for (auto v : list) if (v == value) return true;
return false;
}
inline bool PlayerInput(int pl, int bit)

View file

@ -269,6 +269,7 @@ typedef struct player_struct {
} DukePlayer_t;
// transition helpers
#define SeaSick sea_sick
#define firstaid_amount inv_amount[GET_FIRSTAID]
#define steroids_amount inv_amount[GET_STEROIDS]
#define holoduke_amount inv_amount[GET_HOLODUKE]

View file

@ -138,23 +138,16 @@ void animatewalls(void);
bool activatewarpelevators(int s, int w);
int check_activator_motion(int lotag);
void operateactivators(int l, int w);
void G_OperateForceFields(int spriteNum,int wallTag);
inline void operateforcefields(int s, int w)
{
G_OperateForceFields(s, w);
}
void G_OperateMasterSwitches(int lotag);
inline void operatemasterswitches(int l)
{
return G_OperateMasterSwitches(l);
}
void operateforcefields(int s,int low);
void operateforcefields_common(int s, int low, const std::initializer_list<int>& tiles);
void operatemasterswitches(int lotag);
void operaterespawns(int lotag);
void operatesectors(int s, int i);
void P_HandleSharedKeys(int playerNum);
int getanimationgoal(const int32_t* animPtr);
bool isanearoperator(int lotag);
bool isanunderoperator(int lotag);
int P_ActivateSwitch(int playerNum, int wallOrSprite, int nSwitchType);
bool checkhitswitch(int playerNum, int wallOrSprite, int nSwitchType);
void P_CheckSectors(int playerNum);
void Sect_DamageCeiling(int sectNum);
inline void checkhitceiling(int sec) { Sect_DamageCeiling(sec); }
@ -222,6 +215,7 @@ inline int dist(const spritetype* s1, const spritetype* s2)
return(FindDistance3D(vx, vy, vz >> 4));
}
enum { SWITCH_WALL, SWITCH_SPRITE };
#endif

View file

@ -53,6 +53,10 @@ void animatewalls_d(void);
void animatewalls_r(void);
void operaterespawns_d(int low);
void operaterespawns_r(int low);
void operateforcefields_r(int s, int low);
void operateforcefields_d(int s, int low);
bool checkhitswitch_d(int snum, int w, int switchtype);
bool checkhitswitch_r(int snum, int w, int switchtype);
bool isadoorwall(int dapic)
{
@ -69,6 +73,16 @@ void operaterespawns(int low)
if (isRR()) operaterespawns_r(low); else operaterespawns_d(low);
}
void operateforcefields(int s, int low)
{
if (isRR()) operateforcefields_r(s, low); else operateforcefields_d(s, low);
}
bool checkhitswitch(int snum, int w, int switchtype)
{
return isRR() ? checkhitswitch_r(snum, w, switchtype) : checkhitswitch_d(snum, w, switchtype);
}
//---------------------------------------------------------------------------
//
//
@ -936,7 +950,7 @@ void operatesectors(int sn, int ii)
//
//---------------------------------------------------------------------------
void operateactivators(short low, short snum)
void operateactivators(int low, int snum)
{
int i, j, k;
short * p;
@ -1028,6 +1042,59 @@ void operateactivators(short low, short snum)
operaterespawns(low);
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operatemasterswitches(int low)
{
short i;
i = headspritestat[6];
while (i >= 0)
{
if (sprite[i].picnum == MASTERSWITCH && sprite[i].lotag == low && sprite[i].yvel == 0)
sprite[i].yvel = 1;
i = nextspritestat[i];
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operateforcefields_common(int s, int low, const std::initializer_list<int> &tiles)
{
int i, p;
for (p = numanimwalls; p >= 0; p--)
{
i = animwall[p].wallnum;
if (low == wall[i].lotag || low == -1)
if (isIn(wall[i].overpicnum, tiles))
{
animwall[p].tag = 0;
if (wall[i].cstat)
{
wall[i].cstat = 0;
if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR &&
sprite[s].lotag == 30)
wall[i].lotag = 0;
}
else
wall[i].cstat = 85;
}
}
}
END_DUKE_NS

View file

@ -205,5 +205,401 @@ void operaterespawns_d(int low)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operateforcefields_d(int s, int low)
{
operateforcefields_common(s, low, { W_FORCEFIELD, W_FORCEFIELD + 1, W_FORCEFIELD + 2, BIGFORCE });
}
//---------------------------------------------------------------------------
//
// how NOT to implement switch animations...
//
//---------------------------------------------------------------------------
bool checkhitswitch_d(int snum, int w, int switchtype)
{
uint8_t switchpal;
int i, x, lotag, hitag, picnum, correctdips, numdips;
int sx, sy;
if (w < 0) return 0;
correctdips = 1;
numdips = 0;
if (switchtype == SWITCH_SPRITE) // A wall sprite
{
lotag = sprite[w].lotag; if (lotag == 0) return 0;
hitag = sprite[w].hitag;
sx = sprite[w].x;
sy = sprite[w].y;
picnum = sprite[w].picnum;
switchpal = sprite[w].pal;
}
else
{
lotag = wall[w].lotag; if (lotag == 0) return 0;
hitag = wall[w].hitag;
sx = wall[w].x;
sy = wall[w].y;
picnum = wall[w].picnum;
switchpal = wall[w].pal;
}
switch (picnum)
{
case DIPSWITCH:
case DIPSWITCH + 1:
case TECHSWITCH:
case TECHSWITCH + 1:
case ALIENSWITCH:
case ALIENSWITCH + 1:
break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
if (ps[snum].access_incs == 0)
{
if (switchpal == 0)
{
if ((ps[snum].got_access & 1))
ps[snum].access_incs = 1;
else FTA(70, &ps[snum]);
}
else if (switchpal == 21)
{
if (ps[snum].got_access & 2)
ps[snum].access_incs = 1;
else FTA(71, &ps[snum]);
}
else if (switchpal == 23)
{
if (ps[snum].got_access & 4)
ps[snum].access_incs = 1;
else FTA(72, &ps[snum]);
}
if (ps[snum].access_incs == 1)
{
if (switchtype == SWITCH_WALL)
ps[snum].access_wallnum = w;
else
ps[snum].access_spritenum = w;
}
return 0;
}
case DIPSWITCH2:
case DIPSWITCH2 + 1:
case DIPSWITCH3:
case DIPSWITCH3 + 1:
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
case PULLSWITCH:
case PULLSWITCH + 1:
case HANDSWITCH:
case HANDSWITCH + 1:
case SLOTDOOR:
case SLOTDOOR + 1:
case LIGHTSWITCH:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH:
case SPACEDOORSWITCH + 1:
case FRANKENSTINESWITCH:
case FRANKENSTINESWITCH + 1:
case LIGHTSWITCH2:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2:
case POWERSWITCH2 + 1:
if (check_activator_motion(lotag)) return 0;
break;
default:
if (isadoorwall(picnum) == 0) return 0;
break;
}
i = headspritestat[0];
while (i >= 0)
{
if (lotag == sprite[i].lotag) switch (sprite[i].picnum)
{
case DIPSWITCH:
case TECHSWITCH:
case ALIENSWITCH:
if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum++;
else if (sprite[i].hitag == 0) correctdips++;
numdips++;
break;
case TECHSWITCH + 1:
case DIPSWITCH + 1:
case ALIENSWITCH + 1:
if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum--;
else if (sprite[i].hitag == 1) correctdips++;
numdips++;
break;
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
sprite[i].picnum++;
if (sprite[i].picnum > (MULTISWITCH + 3))
sprite[i].picnum = MULTISWITCH;
break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
case SLOTDOOR:
case LIGHTSWITCH:
case SPACELIGHTSWITCH:
case SPACEDOORSWITCH:
case FRANKENSTINESWITCH:
case LIGHTSWITCH2:
case POWERSWITCH1:
case LOCKSWITCH1:
case POWERSWITCH2:
case HANDSWITCH:
case PULLSWITCH:
case DIPSWITCH2:
case DIPSWITCH3:
sprite[i].picnum++;
break;
case PULLSWITCH + 1:
case HANDSWITCH + 1:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2 + 1:
case SLOTDOOR + 1:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH + 1:
case FRANKENSTINESWITCH + 1:
case DIPSWITCH2 + 1:
case DIPSWITCH3 + 1:
sprite[i].picnum--;
break;
}
i = nextspritestat[i];
}
for (i = 0; i < numwalls; i++)
{
x = i;
if (lotag == wall[x].lotag)
switch (wall[x].picnum)
{
case DIPSWITCH:
case TECHSWITCH:
case ALIENSWITCH:
if (switchtype == SWITCH_WALL && i == w) wall[x].picnum++;
else if (wall[x].hitag == 0) correctdips++;
numdips++;
break;
case DIPSWITCH + 1:
case TECHSWITCH + 1:
case ALIENSWITCH + 1:
if (switchtype == SWITCH_WALL && i == w) wall[x].picnum--;
else if (wall[x].hitag == 1) correctdips++;
numdips++;
break;
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
wall[x].picnum++;
if (wall[x].picnum > (MULTISWITCH + 3))
wall[x].picnum = MULTISWITCH;
break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
case SLOTDOOR:
case LIGHTSWITCH:
case SPACELIGHTSWITCH:
case SPACEDOORSWITCH:
case LIGHTSWITCH2:
case POWERSWITCH1:
case LOCKSWITCH1:
case POWERSWITCH2:
case PULLSWITCH:
case HANDSWITCH:
case DIPSWITCH2:
case DIPSWITCH3:
wall[x].picnum++;
break;
case HANDSWITCH + 1:
case PULLSWITCH + 1:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2 + 1:
case SLOTDOOR + 1:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH + 1:
case DIPSWITCH2 + 1:
case DIPSWITCH3 + 1:
wall[x].picnum--;
break;
}
}
if (lotag == (short)65535)
{
ps[myconnectindex].gm = MODE_EOL;
if (ud.from_bonus)
{
ud.level_number = ud.from_bonus;
ud.m_level_number = ud.level_number;
ud.from_bonus = 0;
}
else
{
// fixme: This needs to be taken from the level definitions.
ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0;
ud.m_level_number = ud.level_number;
}
return 1;
}
vec3_t v = { sx, sy, ps[snum].posz };
switch (picnum)
{
default:
if (isadoorwall(picnum) == 0) break;
case DIPSWITCH:
case DIPSWITCH + 1:
case TECHSWITCH:
case TECHSWITCH + 1:
case ALIENSWITCH:
case ALIENSWITCH + 1:
if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 ||
picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 ||
picnum == TECHSWITCH || picnum == TECHSWITCH + 1)
{
if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1)
{
if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(ALIEN_SWITCH1, w, &v);
else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v);
}
else
{
if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(SWITCH_ON, w, &v);
else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v);
}
if (numdips != correctdips) break;
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v);
}
case DIPSWITCH2:
case DIPSWITCH2 + 1:
case DIPSWITCH3:
case DIPSWITCH3 + 1:
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
case ACCESSSWITCH:
case ACCESSSWITCH2:
case SLOTDOOR:
case SLOTDOOR + 1:
case LIGHTSWITCH:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH:
case SPACEDOORSWITCH + 1:
case FRANKENSTINESWITCH:
case FRANKENSTINESWITCH + 1:
case LIGHTSWITCH2:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2:
case POWERSWITCH2 + 1:
case HANDSWITCH:
case HANDSWITCH + 1:
case PULLSWITCH:
case PULLSWITCH + 1:
if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) ||
picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3))
lotag += picnum - MULTISWITCH;
x = headspritestat[3];
while (x >= 0)
{
if (((sprite[x].hitag) == lotag))
{
switch (sprite[x].lotag)
{
case SE_12_LIGHT_SWITCH:
sector[sprite[x].sectnum].floorpal = 0;
hittype[x].temp_data[0]++;
if (hittype[x].temp_data[0] == 2)
hittype[x].temp_data[0]++;
break;
case SE_24_CONVEYOR:
case SE_34:
case SE_25_PISTON:
hittype[x].temp_data[4] = !hittype[x].temp_data[4];
if (hittype[x].temp_data[4])
FTA(15, &ps[snum]);
else FTA(2, &ps[snum]);
break;
case SE_21_DROP_FLOOR:
FTA(2, &ps[screenpeek]);
break;
}
}
x = nextspritestat[x];
}
operateactivators(lotag, snum);
operateforcefields(ps[snum].i, lotag);
operatemasterswitches(lotag);
if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 ||
picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 ||
picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1;
if (hitag == 0 && isadoorwall(picnum) == 0)
{
if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(SWITCH_ON, w, &v);
else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v);
}
else if (hitag != 0)
{
auto flags = S_GetUserFlags(hitag);
if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, w, &v);
else
A_PlaySound(hitag, ps[snum].i);
}
return 1;
}
return 0;
}
END_DUKE_NS

View file

@ -325,5 +325,578 @@ void operaterespawns_r(int low)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void operateforcefields_r(int s, int low)
{
operateforcefields_common(s, low, { BIGFORCE });
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool checkhitswitch_r(int snum, int w, int switchtype)
{
char switchpal;
short i, x, lotag, hitag, picnum, correctdips, numdips;
int sx, sy;
if (w < 0) return 0;
correctdips = 1;
numdips = 0;
if (switchtype == 1) // A wall sprite
{
lotag = sprite[w].lotag; if (lotag == 0) return 0;
hitag = sprite[w].hitag;
sx = sprite[w].x;
sy = sprite[w].y;
picnum = sprite[w].picnum;
switchpal = sprite[w].pal;
}
else
{
lotag = wall[w].lotag; if (lotag == 0) return 0;
hitag = wall[w].hitag;
sx = wall[w].x;
sy = wall[w].y;
picnum = wall[w].picnum;
switchpal = wall[w].pal;
}
switch (picnum)
{
case DIPSWITCH:
case DIPSWITCH + 1:
case TECHSWITCH:
case TECHSWITCH + 1:
case ALIENSWITCH:
case ALIENSWITCH + 1:
break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
if (ps[snum].access_incs == 0)
{
if (switchpal == 0)
{
if (ps[snum].keys[1])
ps[snum].access_incs = 1;
else
{
FTA(70, &ps[snum]);
if (isRRRA()) spritesound(99, w);
}
}
else if (switchpal == 21)
{
if (ps[snum].keys[2])
ps[snum].access_incs = 1;
else
{
FTA(71, &ps[snum]);
if (isRRRA()) spritesound(99, w);
}
}
else if (switchpal == 23)
{
if (ps[snum].keys[3])
ps[snum].access_incs = 1;
else
{
FTA(72, &ps[snum]);
if (isRRRA()) spritesound(99, w);
}
}
if (ps[snum].access_incs == 1)
{
if (switchtype == 0)
ps[snum].access_wallnum = w;
else
ps[snum].access_spritenum = w;
}
return 0;
}
case MULTISWITCH2:
case MULTISWITCH2 + 1:
case MULTISWITCH2 + 2:
case MULTISWITCH2 + 3:
case RRTILE8464:
case RRTILE8660:
if (isRRRA()) break;
case DIPSWITCH2:
case DIPSWITCH2 + 1:
case DIPSWITCH3:
case DIPSWITCH3 + 1:
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
case PULLSWITCH:
case PULLSWITCH + 1:
case HANDSWITCH:
case HANDSWITCH + 1:
case SLOTDOOR:
case SLOTDOOR + 1:
case LIGHTSWITCH:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH:
case SPACEDOORSWITCH + 1:
case FRANKENSTINESWITCH:
case FRANKENSTINESWITCH + 1:
case LIGHTSWITCH2:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2:
case POWERSWITCH2 + 1:
case NUKEBUTTON:
case NUKEBUTTON + 1:
case RRTILE2214:
case RRTILE2697:
case RRTILE2697 + 1:
case RRTILE2707:
case RRTILE2707 + 1:
if (check_activator_motion(lotag)) return 0;
break;
default:
if (isadoorwall(picnum) == 0) return 0;
break;
}
i = headspritestat[0];
while (i >= 0)
{
if (lotag == sprite[i].lotag) switch (sprite[i].picnum)
{
case DIPSWITCH:
case TECHSWITCH:
case ALIENSWITCH:
if (switchtype == 1 && w == i) sprite[i].picnum++;
else if (sprite[i].hitag == 0) correctdips++;
numdips++;
break;
case TECHSWITCH + 1:
case DIPSWITCH + 1:
case ALIENSWITCH + 1:
if (switchtype == 1 && w == i) sprite[i].picnum--;
else if (sprite[i].hitag == 1) correctdips++;
numdips++;
break;
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
sprite[i].picnum++;
if (sprite[i].picnum > (MULTISWITCH + 3))
sprite[i].picnum = MULTISWITCH;
break;
case MULTISWITCH2:
case MULTISWITCH2 + 1:
case MULTISWITCH2 + 2:
case MULTISWITCH2 + 3:
if (!isRRRA()) break;
sprite[i].picnum++;
if (sprite[i].picnum > (MULTISWITCH2 + 3))
sprite[i].picnum = MULTISWITCH2;
break;
case RRTILE2214:
if (ud.level_number > 6)
ud.level_number = 0;
sprite[i].picnum++;
break;
case RRTILE8660:
if (!isRRRA()) break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
case SLOTDOOR:
case LIGHTSWITCH:
case SPACELIGHTSWITCH:
case SPACEDOORSWITCH:
case FRANKENSTINESWITCH:
case LIGHTSWITCH2:
case POWERSWITCH1:
case LOCKSWITCH1:
case POWERSWITCH2:
case HANDSWITCH:
case PULLSWITCH:
case DIPSWITCH2:
case DIPSWITCH3:
case NUKEBUTTON:
case RRTILE2697:
case RRTILE2707:
if (sprite[i].picnum == DIPSWITCH3)
if (sprite[i].hitag == 999)
{
short j, nextj;
j = headspritestat[107];
while (j >= 0)
{
nextj = nextspritestat[j];
if (sprite[j].picnum == RRTILE3410)
{
sprite[j].picnum++;
sprite[j].hitag = 100;
sprite[j].extra = 0;
spritesound(474, j);
}
else if (sprite[j].picnum == RRTILE295)
deletesprite(j);
j = nextj;
}
sprite[i].picnum++;
break;
}
if (sprite[i].picnum == NUKEBUTTON)
chickenplant = 0;
if (sprite[i].picnum == RRTILE8660)
{
BellTime = 132;
word_119BE0 = i;
}
sprite[i].picnum++;
break;
case PULLSWITCH + 1:
case HANDSWITCH + 1:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2 + 1:
case SLOTDOOR + 1:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH + 1:
case FRANKENSTINESWITCH + 1:
case DIPSWITCH2 + 1:
case DIPSWITCH3 + 1:
case NUKEBUTTON + 1:
case RRTILE2697 + 1:
case RRTILE2707 + 1:
if (sprite[i].picnum == NUKEBUTTON + 1)
chickenplant = 1;
if (sprite[i].hitag != 999)
sprite[i].picnum--;
break;
}
i = nextspritestat[i];
}
for (i = 0; i < numwalls; i++)
{
x = i;
if (lotag == wall[x].lotag)
switch (wall[x].picnum)
{
case DIPSWITCH:
case TECHSWITCH:
case ALIENSWITCH:
if (switchtype == 0 && i == w) wall[x].picnum++;
else if (wall[x].hitag == 0) correctdips++;
numdips++;
break;
case DIPSWITCH + 1:
case TECHSWITCH + 1:
case ALIENSWITCH + 1:
if (switchtype == 0 && i == w) wall[x].picnum--;
else if (wall[x].hitag == 1) correctdips++;
numdips++;
break;
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
wall[x].picnum++;
if (wall[x].picnum > (MULTISWITCH + 3))
wall[x].picnum = MULTISWITCH;
break;
case MULTISWITCH2:
case MULTISWITCH2 + 1:
case MULTISWITCH2 + 2:
case MULTISWITCH2 + 3:
if (!isRRRA()) break;
wall[x].picnum++;
if (wall[x].picnum > (MULTISWITCH2 + 3))
wall[x].picnum = MULTISWITCH2;
break;
case RRTILE8660:
if (!isRRRA()) break;
case ACCESSSWITCH:
case ACCESSSWITCH2:
case SLOTDOOR:
case LIGHTSWITCH:
case SPACELIGHTSWITCH:
case SPACEDOORSWITCH:
case LIGHTSWITCH2:
case POWERSWITCH1:
case LOCKSWITCH1:
case POWERSWITCH2:
case PULLSWITCH:
case HANDSWITCH:
case DIPSWITCH2:
case DIPSWITCH3:
case RRTILE2697:
case RRTILE2707:
wall[x].picnum++;
break;
case HANDSWITCH + 1:
case PULLSWITCH + 1:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2 + 1:
case SLOTDOOR + 1:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH + 1:
case DIPSWITCH2 + 1:
case DIPSWITCH3 + 1:
case RRTILE2697 + 1:
case RRTILE2707 + 1:
wall[x].picnum--;
break;
}
}
if (lotag == (short)65535)
{
ps[myconnectindex].gm = MODE_EOL;
if (ud.from_bonus)
{
ud.level_number = ud.from_bonus;
ud.m_level_number = ud.level_number;
ud.from_bonus = 0;
}
else
{
// fixme: This needs to be taken from the level definitions.
if (isRRRA() && ud.level_number == 6 && ud.volume_number == 0)
g_RAendEpisode = 1; // hack to force advancing to episode 2.
ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0;
ud.m_level_number = ud.level_number;
}
}
vec3_t v = { sx, sy, ps[snum].posz };
switch (picnum)
{
default:
if (isadoorwall(picnum) == 0) break;
case DIPSWITCH:
case DIPSWITCH + 1:
case TECHSWITCH:
case TECHSWITCH + 1:
case ALIENSWITCH:
case ALIENSWITCH + 1:
if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 ||
picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 ||
picnum == TECHSWITCH || picnum == TECHSWITCH + 1)
{
if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1)
{
if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(ALIEN_SWITCH1, w, &v);
else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v);
}
else
{
if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(SWITCH_ON, w, &v);
else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v);
}
if (numdips != correctdips) break;
S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v);
}
case MULTISWITCH2:
case MULTISWITCH2 + 1:
case MULTISWITCH2 + 2:
case MULTISWITCH2 + 3:
case RRTILE8464:
case RRTILE8660:
if (!isRRRA()) break;
case DIPSWITCH2:
case DIPSWITCH2 + 1:
case DIPSWITCH3:
case DIPSWITCH3 + 1:
case MULTISWITCH:
case MULTISWITCH + 1:
case MULTISWITCH + 2:
case MULTISWITCH + 3:
case ACCESSSWITCH:
case ACCESSSWITCH2:
case SLOTDOOR:
case SLOTDOOR + 1:
case LIGHTSWITCH:
case LIGHTSWITCH + 1:
case SPACELIGHTSWITCH:
case SPACELIGHTSWITCH + 1:
case SPACEDOORSWITCH:
case SPACEDOORSWITCH + 1:
case FRANKENSTINESWITCH:
case FRANKENSTINESWITCH + 1:
case LIGHTSWITCH2:
case LIGHTSWITCH2 + 1:
case POWERSWITCH1:
case POWERSWITCH1 + 1:
case LOCKSWITCH1:
case LOCKSWITCH1 + 1:
case POWERSWITCH2:
case POWERSWITCH2 + 1:
case HANDSWITCH:
case HANDSWITCH + 1:
case PULLSWITCH:
case PULLSWITCH + 1:
case RRTILE2697:
case RRTILE2697 + 1:
case RRTILE2707:
case RRTILE2707 + 1:
if (isRRRA())
{
if (picnum == RRTILE8660)
{
BellTime = 132;
word_119BE0 = w;
sprite[w].picnum++;
}
else if (picnum == RRTILE8464)
{
sprite[w].picnum = sprite[w].picnum + 1;
if (hitag == 10001)
{
if (ps[snum].SeaSick == 0)
ps[snum].SeaSick = 350;
operateactivators(668, ps[snum].i);
operatemasterswitches(668);
spritesound(328, ps[snum].i);
return 1;
}
}
else if (hitag == 10000)
{
if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) ||
picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3) ||
picnum == MULTISWITCH2 || picnum == (MULTISWITCH2 + 1) ||
picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3))
{
int var6c[3], var54, j;
short jpn, jht;
var54 = 0;
S_PlaySound3D(SWITCH_ON, w, &v);
for (j = 0; j < MAXSPRITES; j++)
{
jpn = sprite[j].picnum;
jht = sprite[j].hitag;
if ((jpn == MULTISWITCH || jpn == MULTISWITCH2) && jht == 10000)
{
if (var54 < 3)
{
var6c[var54] = j;
var54++;
}
}
}
if (var54 == 3)
{
S_PlaySound3D(78, w, &v);
for (j = 0; j < var54; j++)
{
sprite[var6c[j]].hitag = 0;
if (picnum >= MULTISWITCH2)
sprite[var6c[j]].picnum = MULTISWITCH2 + 3;
else
sprite[var6c[j]].picnum = MULTISWITCH + 3;
checkhitswitch_r(snum, var6c[j], 1);
}
}
return 1;
}
}
}
if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) ||
picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3))
lotag += picnum - MULTISWITCH;
if (isRRRA())
{
if (picnum == MULTISWITCH2 || picnum == (MULTISWITCH2 + 1) ||
picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3))
lotag += picnum - MULTISWITCH2;
}
x = headspritestat[3];
while (x >= 0)
{
if (((sprite[x].hitag) == lotag))
{
switch (sprite[x].lotag)
{
case 46:
case 47:
case 48:
if (!isRRRA()) break;
case 12:
sector[sprite[x].sectnum].floorpal = 0;
hittype[x].temp_data[0]++;
if (hittype[x].temp_data[0] == 2)
hittype[x].temp_data[0]++;
break;
case 24:
case 34:
case 25:
hittype[x].temp_data[4] = !hittype[x].temp_data[4];
if (hittype[x].temp_data[4])
FTA(15, &ps[snum]);
else FTA(2, &ps[snum]);
break;
case 21:
FTA(2, &ps[screenpeek]);
break;
}
}
x = nextspritestat[x];
}
operateactivators(lotag, snum);
operateforcefields(ps[snum].i, lotag);
operatemasterswitches(lotag);
if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 ||
picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 ||
picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1;
if (hitag == 0 && isadoorwall(picnum) == 0)
{
if (switchtype == SWITCH_SPRITE)
S_PlaySound3D(SWITCH_ON, w, &v);
else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v);
}
else if (hitag != 0)
{
auto flags = S_GetUserFlags(hitag);
if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, w, &v);
else
A_PlaySound(hitag, ps[snum].i);
}
return 1;
}
return 0;
}
END_DUKE_NS

View file

@ -664,7 +664,7 @@ void G_DoCheats(void)
operatesectors(i, pPlayer->i);
}
}
G_OperateForceFields(pPlayer->i, -1);
operateforcefields(pPlayer->i, -1);
P_DoQuote(QUOTE_CHEAT_UNLOCK, pPlayer);
end_cheat(pPlayer);

View file

@ -671,7 +671,7 @@ growspark_rr:
{
A_DamageObject(hitData.sprite, kneeSprite);
if (playerNum >= 0)
P_ActivateSwitch(playerNum, hitData.sprite, 1);
checkhitswitch(playerNum, hitData.sprite, 1);
}
else if (hitData.wall >= 0)
{
@ -681,7 +681,7 @@ growspark_rr:
{
A_DamageWall(kneeSprite, hitData.wall, &hitData.pos, projecTile);
if (playerNum >= 0)
P_ActivateSwitch(playerNum, hitData.wall, 0);
checkhitswitch(playerNum, hitData.wall, 0);
}
}
}
@ -772,7 +772,7 @@ growspark_rr:
if (playerNum >= 0 && CheckShootSwitchTile(sprite[hitData.sprite].picnum))
{
P_ActivateSwitch(playerNum, hitData.sprite, 1);
checkhitswitch(playerNum, hitData.sprite, 1);
return -1;
}
}
@ -790,7 +790,7 @@ growspark_rr:
if (playerNum >= 0 && CheckShootSwitchTile(hitWall->picnum))
{
P_ActivateSwitch(playerNum, hitData.wall, 0);
checkhitswitch(playerNum, hitData.wall, 0);
return -1;
}
@ -4441,7 +4441,7 @@ static int32_t P_DoCounters(int playerNum)
{
if (pPlayer->access_spritenum >= 0)
{
P_ActivateSwitch(playerNum, pPlayer->access_spritenum, 1);
checkhitswitch(playerNum, pPlayer->access_spritenum, 1);
switch (sprite[pPlayer->access_spritenum].pal)
{
case 0: RR ? pPlayer->keys[1] = 1 : pPlayer->got_access &= (0xffff - 0x1); break;
@ -4452,7 +4452,7 @@ static int32_t P_DoCounters(int playerNum)
}
else
{
P_ActivateSwitch(playerNum,pPlayer->access_wallnum,0);
checkhitswitch(playerNum,pPlayer->access_wallnum,0);
switch (wall[pPlayer->access_wallnum].pal)
{
case 0: RR ? pPlayer->keys[1] = 1 : pPlayer->got_access &= (0xffff - 0x1); break;

View file

@ -118,539 +118,6 @@ void G_AnimateCamSprite(int smoothRatio)
}
void G_OperateMasterSwitches(int lotag)
{
for (bssize_t SPRITES_OF(STAT_STANDABLE, i))
if (PN(i) == TILE_MASTERSWITCH && SLT(i) == lotag && SP(i) == 0)
SP(i) = 1;
}
void G_OperateForceFields(int spriteNum, int wallTag)
{
for (bssize_t animwallNum = 0; animwallNum < g_animWallCnt; ++animwallNum)
{
int const wallNum = animwall[animwallNum].wallnum;
if ((wallTag == wall[wallNum].lotag || wallTag == -1)
&& ((!RR && G_GetForcefieldPicnum(wallNum) == TILE_W_FORCEFIELD) || (wall[wallNum].overpicnum == TILE_BIGFORCE)))
{
animwall[animwallNum].tag = 0;
if (wall[wallNum].cstat)
{
wall[wallNum].cstat = 0;
if (spriteNum >= 0 && sprite[spriteNum].picnum == TILE_SECTOREFFECTOR && sprite[spriteNum].lotag == SE_30_TWO_WAY_TRAIN)
wall[wallNum].lotag = 0;
}
else
wall[wallNum].cstat = FORCEFIELD_CSTAT;
}
}
}
// List of switches that function like dip (combination lock) switches.
#define DIPSWITCH_LIKE_CASES \
DIPSWITCH__STATIC: \
case TECHSWITCH__STATIC: \
case ALIENSWITCH__STATIC
// List of access switches.
#define ACCESSSWITCH_CASES \
ACCESSSWITCH__STATIC: \
case ACCESSSWITCH2__STATIC
// List of switches that don't fit the two preceding categories, and are not
// the TILE_MULTISWITCH. 13 cases.
#define REST_SWITCH_CASES \
DIPSWITCH2__STATIC: \
case DIPSWITCH3__STATIC: \
case FRANKENSTINESWITCH__STATIC: \
case HANDSWITCH__STATIC: \
case LIGHTSWITCH2__STATIC: \
case LIGHTSWITCH__STATIC: \
case LOCKSWITCH1__STATIC: \
case POWERSWITCH1__STATIC: \
case POWERSWITCH2__STATIC: \
case PULLSWITCH__STATIC: \
case SLOTDOOR__STATIC: \
case SPACEDOORSWITCH__STATIC: \
case SPACELIGHTSWITCH__STATIC: \
case RRTILE2697__STATICRR: \
case RRTILE2707__STATICRR
// Returns:
// 0: is not a dipswitch-like switch
// 1: is one, off
// 2: is one, on
static int G_IsLikeDipswitch(int switchPic)
{
for (bssize_t i=0; i<2; i++)
if (switchPic == TILE_DIPSWITCH+i || switchPic == TILE_TECHSWITCH+i || switchPic == TILE_ALIENSWITCH+i)
return 1+i;
return 0;
}
// Get base (unpressed) tile number for switch.
static int G_GetBaseSwitch(int switchPic)
{
if (switchPic > TILE_MULTISWITCH && switchPic <= TILE_MULTISWITCH+3)
return TILE_MULTISWITCH;
if (RRRA && switchPic > TILE_MULTISWITCH2 && switchPic <= TILE_MULTISWITCH2+3)
return TILE_MULTISWITCH2;
if (RR)
{
if (switchPic == TILE_NUKEBUTTON+1 || switchPic == TILE_RRTILE2697+1 || switchPic == TILE_RRTILE2707+1)
return switchPic-1;
}
return ((RR && (switchPic == TILE_NUKEBUTTON+1 || switchPic == TILE_RRTILE2697+1 || switchPic == TILE_RRTILE2707+1)) ||
switchPic == TILE_DIPSWITCH + 1 || switchPic == TILE_DIPSWITCH2 + 1 || switchPic == TILE_DIPSWITCH3 + 1 ||
switchPic == TILE_TECHSWITCH + 1 || switchPic == TILE_ALIENSWITCH + 1 || switchPic == TILE_PULLSWITCH + 1 ||
switchPic == TILE_HANDSWITCH + 1 || switchPic == TILE_SLOTDOOR + 1 || switchPic == TILE_SPACEDOORSWITCH + 1 ||
switchPic == TILE_SPACELIGHTSWITCH + 1 || switchPic == TILE_LIGHTSWITCH + 1 || switchPic == TILE_LIGHTSWITCH2 + 1 ||
switchPic == TILE_FRANKENSTINESWITCH + 1 || switchPic == TILE_POWERSWITCH1 + 1 || switchPic == TILE_POWERSWITCH2 + 1 ||
switchPic == TILE_LOCKSWITCH1 + 1) ?
switchPic-1 : switchPic;
}
enum { SWITCH_WALL, SWITCH_SPRITE };
int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
{
if (wallOrSprite < 0)
return 0;
vec3_t davector;
int16_t lotag, hitag;
int16_t nSwitchPicnum;
uint8_t nSwitchPal;
if (switchType == SWITCH_SPRITE) // A wall sprite
{
if (sprite[wallOrSprite].lotag == 0)
return 0;
lotag = sprite[wallOrSprite].lotag;
hitag = sprite[wallOrSprite].hitag;
davector = *(vec3_t *)&sprite[wallOrSprite];
nSwitchPicnum = sprite[wallOrSprite].picnum;
nSwitchPal = sprite[wallOrSprite].pal;
}
else
{
if (wall[wallOrSprite].lotag == 0)
return 0;
lotag = wall[wallOrSprite].lotag;
hitag = wall[wallOrSprite].hitag;
davector = *(vec3_t *)&wall[wallOrSprite];
davector.z = g_player[playerNum].ps->pos.z;
nSwitchPicnum = wall[wallOrSprite].picnum;
nSwitchPal = wall[wallOrSprite].pal;
}
// Printf("P_ActivateSwitch called picnum=%i switchissprite=%i\n",picnum,switchissprite);
int basePicnum = G_GetBaseSwitch(nSwitchPicnum);
int correctDips = 1;
int numDips = 0;
switch (DYNAMICTILEMAP(basePicnum))
{
case DIPSWITCH_LIKE_CASES:
break;
case ACCESSSWITCH_CASES:
if (g_player[playerNum].ps->access_incs == 0)
{
static const int32_t key_switchpal[3] = { 0, 21, 23 };
static const int32_t need_key_quote[3] = { QUOTE_NEED_BLUE_KEY, QUOTE_NEED_RED_KEY, QUOTE_NEED_YELLOW_KEY };
for (bssize_t nKeyPal = 0; nKeyPal < 3; nKeyPal++)
{
if (nSwitchPal == key_switchpal[nKeyPal])
{
if ((!RR && (g_player[playerNum].ps->got_access & (1 << nKeyPal)))
|| (RR && g_player[playerNum].ps->keys[nKeyPal+1]))
g_player[playerNum].ps->access_incs = 1;
else
{
P_DoQuote(need_key_quote[nKeyPal], g_player[playerNum].ps);
if (RRRA)
{
if (switchType == SWITCH_SPRITE)
A_PlaySound(99, wallOrSprite);
else
A_PlaySound(99, g_player[playerNum].ps->i);
}
}
break;
}
}
if (g_player[playerNum].ps->access_incs == 1)
{
if (switchType == SWITCH_WALL)
g_player[playerNum].ps->access_wallnum = wallOrSprite;
else
g_player[playerNum].ps->access_spritenum = wallOrSprite;
}
return 0;
}
fallthrough__;
case RRTILE2214__STATICRR:
case RRTILE8464__STATICRR:
case RRTILE8660__STATICRR:
case NUKEBUTTON__STATIC:
case MULTISWITCH__STATIC:
case MULTISWITCH2__STATICRR:
case REST_SWITCH_CASES:
if (!RR && nSwitchPicnum == TILE_NUKEBUTTON) goto default_case;
if (RR && !RRRA && (nSwitchPicnum == TILE_MULTISWITCH2 || nSwitchPicnum == TILE_RRTILE8464 || nSwitchPicnum == TILE_RRTILE8660)) goto default_case;
if (check_activator_motion(lotag))
return 0;
break;
default:
default_case:
if (isadoorwall(nSwitchPicnum) == 0)
return 0;
break;
}
for (bssize_t SPRITES_OF(STAT_DEFAULT, spriteNum))
{
if (lotag == SLT(spriteNum))
{
// Put the tile number into a variable so later switches don't
// trigger on the result of changes:
int const spritePic = PN(spriteNum);
if (spritePic >= TILE_MULTISWITCH && spritePic <= TILE_MULTISWITCH+3)
{
sprite[spriteNum].picnum++;
if (sprite[spriteNum].picnum > TILE_MULTISWITCH+3)
sprite[spriteNum].picnum = TILE_MULTISWITCH;
}
if (RRRA && spritePic >= TILE_MULTISWITCH2 && spritePic <= TILE_MULTISWITCH2+3)
{
sprite[spriteNum].picnum++;
if (sprite[spriteNum].picnum > TILE_MULTISWITCH2+3)
sprite[spriteNum].picnum = TILE_MULTISWITCH2;
}
switch (DYNAMICTILEMAP(spritePic))
{
case DIPSWITCH_LIKE_CASES:
if (switchType == SWITCH_SPRITE && wallOrSprite == spriteNum)
PN(spriteNum)++;
else if (SHT(spriteNum) == 0)
correctDips++;
numDips++;
break;
case RRTILE2214__STATICRR:
if (ud.level_number > 6)
ud.level_number = 0;
sprite[spriteNum].picnum++;
break;
case ACCESSSWITCH_CASES:
case REST_SWITCH_CASES:
case NUKEBUTTON__STATIC:
case RRTILE8660__STATICRR:
if (!RR && spritePic == TILE_NUKEBUTTON)
break;
if (RR && !RRRA && spritePic == TILE_RRTILE8660)
break;
if (RR)
{
if (PN(spriteNum) == TILE_DIPSWITCH3 && SHT(spriteNum) == 999)
{
int j = headspritestat[107];
while (j >= 0)
{
int const nextj = nextspritestat[j];
if (sprite[j].picnum == TILE_RRTILE3410)
{
sprite[j].picnum++;
sprite[j].hitag = 100;
sprite[j].extra = 0;
A_PlaySound(474, j);
}
else if (sprite[j].picnum == TILE_RRTILE295)
A_DeleteSprite(j);
j = nextj;
}
sprite[spriteNum].picnum++;
break;
}
if (PN(spriteNum) == TILE_NUKEBUTTON)
g_chickenPlant = 0;
if (RRRA && PN(spriteNum) == TILE_RRTILE8660)
{
g_bellTime = 132;
g_bellSprite = spriteNum;
}
}
sprite[spriteNum].picnum++;
break;
default:
if (spritePic <= 0) // oob safety
break;
switch (DYNAMICTILEMAP(spritePic - 1))
{
case DIPSWITCH_LIKE_CASES:
if (switchType == SWITCH_SPRITE && wallOrSprite == spriteNum)
PN(spriteNum)--;
else if (SHT(spriteNum) == 1)
correctDips++;
numDips++;
break;
case REST_SWITCH_CASES:
case NUKEBUTTON__STATIC:
if (!RR && spritePic == TILE_NUKEBUTTON+1)
break;
if (RR && PN(spriteNum) == TILE_NUKEBUTTON+1)
g_chickenPlant = 1;
if (!RR || SHT(spriteNum) != 999)
sprite[spriteNum].picnum--;
break;
}
break;
}
}
}
for (bssize_t wallNum=numwalls-1; wallNum>=0; wallNum--)
{
if (lotag == wall[wallNum].lotag)
{
if (wall[wallNum].picnum >= TILE_MULTISWITCH && wall[wallNum].picnum <= TILE_MULTISWITCH+3)
{
wall[wallNum].picnum++;
if (wall[wallNum].picnum > TILE_MULTISWITCH+3)
wall[wallNum].picnum = TILE_MULTISWITCH;
}
if (RRRA && wall[wallNum].picnum >= TILE_MULTISWITCH2 && wall[wallNum].picnum <= TILE_MULTISWITCH2+3)
{
wall[wallNum].picnum++;
if (wall[wallNum].picnum > TILE_MULTISWITCH2+3)
wall[wallNum].picnum = TILE_MULTISWITCH2;
}
switch (DYNAMICTILEMAP(wall[wallNum].picnum))
{
case DIPSWITCH_LIKE_CASES:
if (switchType == SWITCH_WALL && wallNum == wallOrSprite)
wall[wallNum].picnum++;
else if (wall[wallNum].hitag == 0)
correctDips++;
numDips++;
break;
case ACCESSSWITCH_CASES:
case REST_SWITCH_CASES:
case RRTILE8464__STATICRR:
case RRTILE8660__STATICRR:
if (RR && !RRRA && wall[wallNum].picnum == TILE_RRTILE8660) break;
wall[wallNum].picnum++;
break;
default:
if (wall[wallNum].picnum <= 0) // oob safety
break;
switch (DYNAMICTILEMAP(wall[wallNum].picnum - 1))
{
case DIPSWITCH_LIKE_CASES:
if (switchType == SWITCH_WALL && wallNum == wallOrSprite)
wall[wallNum].picnum--;
else if (wall[wallNum].hitag == 1)
correctDips++;
numDips++;
break;
case REST_SWITCH_CASES:
wall[wallNum].picnum--;
break;
}
break;
}
}
}
if ((uint16_t)lotag == UINT16_MAX)
{
P_EndLevel();
return 1;
}
basePicnum = G_GetBaseSwitch(nSwitchPicnum);
switch (DYNAMICTILEMAP(basePicnum))
{
default:
if (isadoorwall(nSwitchPicnum) == 0)
break;
fallthrough__;
case DIPSWITCH_LIKE_CASES:
if (G_IsLikeDipswitch(nSwitchPicnum))
{
S_PlaySound3D((nSwitchPicnum == TILE_ALIENSWITCH || nSwitchPicnum == TILE_ALIENSWITCH + 1) ? ALIEN_SWITCH1 : SWITCH_ON,
(switchType == SWITCH_SPRITE) ? wallOrSprite : g_player[playerNum].ps->i, &davector);
if (numDips != correctDips)
break;
S_PlaySound3D(END_OF_LEVEL_WARN, g_player[playerNum].ps->i, &davector);
}
fallthrough__;
case ACCESSSWITCH_CASES:
case MULTISWITCH__STATIC:
case MULTISWITCH2__STATICRR:
case REST_SWITCH_CASES:
case RRTILE8464__STATICRR:
case RRTILE8660__STATICRR:
{
if (RR && !RRRA && (basePicnum == TILE_MULTISWITCH2 || basePicnum == TILE_RRTILE8464 || basePicnum == TILE_RRTILE8660)) break;
if (RRRA && switchType == SWITCH_SPRITE)
{
if (nSwitchPicnum == TILE_RRTILE8660)
{
g_bellTime = 132;
g_bellSprite = wallOrSprite;
sprite[wallOrSprite].picnum++;
}
else if (nSwitchPicnum == TILE_RRTILE8464)
{
sprite[wallOrSprite].picnum = sprite[wallOrSprite].picnum+1;
if (hitag == 10001)
{
if (g_player[playerNum].ps->sea_sick == 0)
g_player[playerNum].ps->sea_sick = 350;
operateactivators(668, playerNum);
G_OperateMasterSwitches(668);
A_PlaySound(328,g_player[playerNum].ps->i);
return 1;
}
}
else if (hitag == 10000)
{
if( nSwitchPicnum == TILE_MULTISWITCH || nSwitchPicnum == (TILE_MULTISWITCH+1) ||
nSwitchPicnum == (TILE_MULTISWITCH+2) || nSwitchPicnum == (TILE_MULTISWITCH+3) ||
nSwitchPicnum == TILE_MULTISWITCH2 || nSwitchPicnum == (TILE_MULTISWITCH2+1) ||
nSwitchPicnum == (TILE_MULTISWITCH2+2) || nSwitchPicnum == (TILE_MULTISWITCH2+3) )
{
int var6c[3], var54;
int jpn, jht;
var54 = 0;
S_PlaySound3D(SWITCH_ON, wallOrSprite, &davector);
for (bssize_t j = 0; j < MAXSPRITES; j++)
{
jpn = sprite[j].picnum;
jht = sprite[j].hitag;
if ((jpn == TILE_MULTISWITCH || jpn == TILE_MULTISWITCH2) && jht == 10000)
{
if (var54 < 3)
{
var6c[var54] = j;
var54++;
}
}
}
if (var54 == 3)
{
S_PlaySound3D(SWITCH_ON, wallOrSprite, &davector);
for (bssize_t j = 0; j < var54; j++)
{
sprite[var6c[j]].hitag = 0;
if (nSwitchPicnum >= TILE_MULTISWITCH2)
sprite[var6c[j]].picnum = TILE_MULTISWITCH2+3;
else
sprite[var6c[j]].picnum = TILE_MULTISWITCH+3;
P_ActivateSwitch(playerNum,var6c[j],1);
}
}
return 1;
}
}
}
if (nSwitchPicnum >= TILE_MULTISWITCH && nSwitchPicnum <= TILE_MULTISWITCH + 3)
lotag += nSwitchPicnum - TILE_MULTISWITCH;
if (RRRA && nSwitchPicnum >= TILE_MULTISWITCH2 && nSwitchPicnum <= TILE_MULTISWITCH2 + 3)
lotag += nSwitchPicnum - TILE_MULTISWITCH2;
for (bssize_t SPRITES_OF(STAT_EFFECTOR, spriteNum))
{
if (sprite[spriteNum].hitag == lotag)
{
switch (sprite[spriteNum].lotag)
{
case 46:
case 47:
case 48:
if (!RRRA) break;
fallthrough__;
case SE_12_LIGHT_SWITCH:
sector[sprite[spriteNum].sectnum].floorpal = 0;
actor[spriteNum].t_data[0]++;
if (actor[spriteNum].t_data[0] == 2)
actor[spriteNum].t_data[0]++;
break;
case SE_24_CONVEYOR:
case SE_34:
case SE_25_PISTON:
actor[spriteNum].t_data[4] = !actor[spriteNum].t_data[4];
P_DoQuote(actor[spriteNum].t_data[4] ? QUOTE_DEACTIVATED : QUOTE_ACTIVATED, g_player[playerNum].ps);
break;
case SE_21_DROP_FLOOR:
P_DoQuote(QUOTE_ACTIVATED, g_player[screenpeek].ps);
break;
}
}
}
operateactivators(lotag, playerNum);
G_OperateForceFields(g_player[playerNum].ps->i, lotag);
G_OperateMasterSwitches(lotag);
if (G_IsLikeDipswitch(nSwitchPicnum))
return 1;
if (!hitag && isadoorwall(nSwitchPicnum) == 0)
S_PlaySound3D(SWITCH_ON, (switchType == SWITCH_SPRITE) ? wallOrSprite : g_player[playerNum].ps->i, &davector);
else if (hitag)
{
auto flags = S_GetUserFlags(hitag);
if (switchType == SWITCH_SPRITE && (flags & SF_TALK) == 0)
S_PlaySound3D(hitag, wallOrSprite, &davector);
else
A_PlaySound(hitag, g_player[playerNum].ps->i);
}
return 1;
}
}
return 0;
}
void G_ActivateBySector(int sectNum, int spriteNum)
{
int activatedSectors = 0;
@ -3189,6 +2656,7 @@ void P_CheckSectors(int playerNum)
}
else
{
if (RRRA && ud.level_number == 6 && ud.volume_number == 0)
g_RAendEpisode = 1;
ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0;
@ -3405,7 +2873,7 @@ void P_CheckSectors(int playerNum)
{
if (RR && !RRRA)
g_canSeePlayer = playerNum;
if (P_ActivateSwitch(playerNum, nearSprite, 1))
if (checkhitswitch(playerNum, nearSprite, 1))
return;
switch (DYNAMICTILEMAP(sprite[nearSprite].picnum))
@ -3608,7 +3076,7 @@ void P_CheckSectors(int playerNum)
{
if (RR && !RRRA)
g_canSeePlayer = playerNum;
P_ActivateSwitch(playerNum,nearWall,0);
checkhitswitch(playerNum,nearWall,0);
}
return;
}
@ -3672,7 +3140,7 @@ void P_CheckSectors(int playerNum)
P_DoQuote(41,pPlayer);
}
}
else P_ActivateSwitch(playerNum,nearWall,0);
else checkhitswitch(playerNum,nearWall,0);
}
}
}