mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- vis.cpp
This commit is contained in:
parent
02bdba71fc
commit
411c814dc3
6 changed files with 71 additions and 74 deletions
|
@ -1933,7 +1933,7 @@ DSWActor* DoPickTarget(DSWActor*, uint32_t max_delta_ang, int skip_targets);
|
|||
|
||||
void change_sprite_stat(short, short);
|
||||
void change_actor_stat(DSWActor* actor, int stat);
|
||||
void SetOwner(DSWActor*, DSWActor*);
|
||||
void SetOwner(DSWActor*, DSWActor*, bool flag = true);
|
||||
void SetOwner(int a, int b); // we still need this...
|
||||
void ClearOwner(DSWActor* ownr);
|
||||
DSWActor* GetOwner(DSWActor* child);
|
||||
|
|
|
@ -45,7 +45,7 @@ SPRITEp WarpPlane(int32_t* x, int32_t* y, int32_t* z, int16_t* sectnum)
|
|||
|
||||
void ProcessVisOn(void);
|
||||
void VisViewChange(PLAYERp pp, int* vis);
|
||||
int SpawnVis(short Parent, short sectnum, int x, int y, int z, int amt);
|
||||
void SpawnVis(DSWActor* Parent, short sectnum, int x, int y, int z, int amt);
|
||||
|
||||
enum TriggerType { TRIGGER_TYPE_REMOTE_SO };
|
||||
|
||||
|
|
|
@ -2347,7 +2347,7 @@ pUziFire(PANEL_SPRITEp psp)
|
|||
}
|
||||
else
|
||||
{
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 32);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 32);
|
||||
|
||||
if (!WeaponOK(psp->PlayerP))
|
||||
return;
|
||||
|
@ -3007,7 +3007,7 @@ pShotgunAction(PANEL_SPRITEp psp)
|
|||
void
|
||||
pShotgunFire(PANEL_SPRITEp psp)
|
||||
{
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 32);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 32);
|
||||
InitShotgun(psp->PlayerP);
|
||||
//SpawnShotgunShell(psp);
|
||||
}
|
||||
|
@ -3379,7 +3379,7 @@ pRailAction(PANEL_SPRITEp psp)
|
|||
void
|
||||
pRailFire(PANEL_SPRITEp psp)
|
||||
{
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 16);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 16);
|
||||
if (psp->PlayerP->WpnRailType == 0)
|
||||
InitRail(psp->PlayerP);
|
||||
else
|
||||
|
@ -3788,15 +3788,15 @@ pHotheadAttack(PANEL_SPRITEp psp)
|
|||
switch (psp->PlayerP->WpnFlameType)
|
||||
{
|
||||
case 0:
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 32);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 32);
|
||||
InitFireball(psp->PlayerP);
|
||||
break;
|
||||
case 1:
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 20);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 20);
|
||||
InitSpellRing(psp->PlayerP);
|
||||
break;
|
||||
case 2:
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 16);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 16);
|
||||
InitSpellNapalm(psp->PlayerP);
|
||||
break;
|
||||
}
|
||||
|
@ -4339,7 +4339,7 @@ pMicroAction(PANEL_SPRITEp psp)
|
|||
void
|
||||
pMicroFire(PANEL_SPRITEp psp)
|
||||
{
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 20);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 20);
|
||||
switch (psp->PlayerP->WpnRocketType)
|
||||
{
|
||||
case 0:
|
||||
|
@ -5159,7 +5159,7 @@ pGrenadeAction(PANEL_SPRITEp psp)
|
|||
void
|
||||
pGrenadeFire(PANEL_SPRITEp psp)
|
||||
{
|
||||
SpawnVis(psp->PlayerP->PlayerSprite, -1, -1, -1, -1, 32);
|
||||
SpawnVis(psp->PlayerP->Actor(), -1, -1, -1, -1, 32);
|
||||
InitGrenade(psp->PlayerP);
|
||||
}
|
||||
|
||||
|
|
|
@ -583,11 +583,11 @@ STATE s_IconFlag[] =
|
|||
{ICON_FLAG + 2, 32, DoGet, &s_IconFlag[0]}
|
||||
};
|
||||
|
||||
void SetOwner(DSWActor* ownr, DSWActor* child)
|
||||
void SetOwner(DSWActor* ownr, DSWActor* child, bool flag)
|
||||
{
|
||||
SPRITEp cp = &child->s();
|
||||
|
||||
if (ownr != nullptr && ownr->hasU())
|
||||
if (flag && ownr != nullptr && ownr->hasU())
|
||||
{
|
||||
SET(ownr->u()->Flags2, SPR2_CHILDREN);
|
||||
}
|
||||
|
|
|
@ -45,13 +45,12 @@ extern short NormalVisibility; // player.c
|
|||
|
||||
void ProcessVisOn(void)
|
||||
{
|
||||
int i;
|
||||
SPRITEp sp;
|
||||
|
||||
StatIterator it(STAT_VIS_ON);
|
||||
while ((i = it.NextIndex()) >= 0)
|
||||
SWStatIterator it(STAT_VIS_ON);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
sp = &sprite[i];
|
||||
sp = &actor->s();
|
||||
|
||||
if (VIS_VisDir(sp))
|
||||
{
|
||||
|
@ -73,12 +72,13 @@ void ProcessVisOn(void)
|
|||
if (VIS_VisCur(sp) >= NormalVisibility)
|
||||
{
|
||||
VIS_VisCur(sp) = NormalVisibility;
|
||||
if (sp->owner >= 0)
|
||||
auto own = GetOwner(actor);
|
||||
if (own != nullptr)
|
||||
{
|
||||
ASSERT(User[sp->owner].Data());
|
||||
RESET(User[sp->owner]->Flags2, SPR2_VIS_SHADING);
|
||||
ASSERT(own->hasU());
|
||||
RESET(own->u()->Flags2, SPR2_VIS_SHADING);
|
||||
}
|
||||
KillSprite(i);
|
||||
KillActor(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,6 @@ void ProcessVisOn(void)
|
|||
|
||||
void VisViewChange(PLAYERp pp, int *vis)
|
||||
{
|
||||
int i;
|
||||
SPRITEp sp;
|
||||
short BrightestVis = NormalVisibility;
|
||||
int x,y,z;
|
||||
|
@ -96,17 +95,18 @@ void VisViewChange(PLAYERp pp, int *vis)
|
|||
return;
|
||||
|
||||
// find the closest quake - should be a strength value
|
||||
StatIterator it(STAT_VIS_ON);
|
||||
while ((i = it.NextIndex()) >= 0)
|
||||
SWStatIterator it(STAT_VIS_ON);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
sp = &sprite[i];
|
||||
sp = &actor->s();
|
||||
|
||||
if (sp->owner >= 0)
|
||||
auto own = GetOwner(actor);
|
||||
if (own != nullptr)
|
||||
{
|
||||
x = sprite[sp->owner].x;
|
||||
y = sprite[sp->owner].y;
|
||||
z = sprite[sp->owner].z;
|
||||
sectnum = sprite[sp->owner].sectnum;
|
||||
x = own->s().x;
|
||||
y = own->s().y;
|
||||
z = own->s().z;
|
||||
sectnum = own->s().sectnum;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -127,57 +127,56 @@ void VisViewChange(PLAYERp pp, int *vis)
|
|||
*vis = BrightestVis;
|
||||
}
|
||||
|
||||
int SpawnVis(short Parent, short sectnum, int x, int y, int z, int amt)
|
||||
void SpawnVis(DSWActor* parentActor, short sectnum, int x, int y, int z, int amt)
|
||||
{
|
||||
short SpriteNum;
|
||||
SPRITEp sp;
|
||||
int i;
|
||||
|
||||
if (Parent >= 0)
|
||||
if (parentActor != nullptr)
|
||||
{
|
||||
if (sector[sprite[Parent].sectnum].floorpal == PALETTE_FOG)
|
||||
return -1;
|
||||
auto psp = &parentActor->s();
|
||||
auto pu = parentActor->u();
|
||||
|
||||
if (sector[sprite[Parent].sectnum].floorpal == PALETTE_DIVE_LAVA)
|
||||
return -1;
|
||||
if (sector[psp->sectnum].floorpal == PALETTE_FOG)
|
||||
return;
|
||||
|
||||
if (sector[psp->sectnum].floorpal == PALETTE_DIVE_LAVA)
|
||||
return;
|
||||
|
||||
// kill any others with the same parent
|
||||
StatIterator it(STAT_VIS_ON);
|
||||
while ((i = it.NextIndex()) >= 0)
|
||||
SWStatIterator it(STAT_VIS_ON);
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
sp = &sprite[i];
|
||||
if (sp->owner == Parent)
|
||||
if (GetOwner(itActor) == parentActor)
|
||||
{
|
||||
KillSprite(i);
|
||||
KillActor(itActor);
|
||||
}
|
||||
}
|
||||
|
||||
SpriteNum = COVERinsertsprite(sprite[Parent].sectnum, STAT_VIS_ON);
|
||||
sp = &sprite[SpriteNum];
|
||||
auto actorNew = InsertActor(psp->sectnum, STAT_VIS_ON);
|
||||
sp = &actorNew->s();
|
||||
SetOwner(parentActor, actorNew);
|
||||
|
||||
sp->owner = Parent;
|
||||
|
||||
ASSERT(User[Parent].Data());
|
||||
SET(User[Parent]->Flags2, SPR2_CHILDREN);
|
||||
ASSERT(parentActor->hasU());
|
||||
SET(pu->Flags2, SPR2_CHILDREN);
|
||||
|
||||
sp->x = sprite[Parent].x;
|
||||
sp->y = sprite[Parent].y;
|
||||
sp->z = sprite[Parent].z;
|
||||
sp->x = psp->x;
|
||||
sp->y = psp->y;
|
||||
sp->z = psp->z;
|
||||
|
||||
SET(User[Parent]->Flags2, SPR2_VIS_SHADING);
|
||||
SET(pu->Flags2, SPR2_VIS_SHADING);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sector[sectnum].floorpal == PALETTE_FOG)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
SpriteNum = COVERinsertsprite(sectnum, STAT_VIS_ON);
|
||||
sp = &sprite[SpriteNum];
|
||||
auto actorNew = InsertActor(sectnum, STAT_VIS_ON);
|
||||
sp = &actorNew->s();
|
||||
|
||||
sp->x = x;
|
||||
sp->y = y;
|
||||
sp->z = z - Z(20);
|
||||
sp->owner = -1;
|
||||
ClearOwner(actorNew);
|
||||
}
|
||||
|
||||
sp->cstat = 0;
|
||||
|
@ -186,8 +185,6 @@ int SpawnVis(short Parent, short sectnum, int x, int y, int z, int amt)
|
|||
VIS_VisDir(sp) = 1;
|
||||
VIS_VisCur(sp) = NormalVisibility;
|
||||
VIS_VisGoal(sp) = amt;
|
||||
|
||||
return SpriteNum;
|
||||
}
|
||||
|
||||
END_SW_NS
|
||||
|
|
|
@ -10676,7 +10676,7 @@ SpawnBasicExp(int16_t Weapon)
|
|||
|
||||
SpawnExpZadjust(Weapon, exp, Z(15), Z(15));
|
||||
DoExpDamageTest(expActor);
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -11009,7 +11009,7 @@ SpawnBoltExp(int16_t Weapon)
|
|||
DoExpDamageTest(expActor);
|
||||
|
||||
SetExpQuake(explosion); // !JIM! made rocket launcher shake things
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -11072,7 +11072,7 @@ SpawnTankShellExp(int16_t Weapon)
|
|||
|
||||
SpawnExpZadjust(Weapon, exp, Z(40), Z(40));
|
||||
DoExpDamageTest(expActor);
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -11307,7 +11307,7 @@ SpawnMicroExp(int16_t Weapon)
|
|||
//
|
||||
|
||||
SpawnExpZadjust(Weapon, exp, Z(20), Z(20));
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -11548,7 +11548,7 @@ SpawnGrenadeExp(int16_t Weapon)
|
|||
DoExpDamageTest(expActor);
|
||||
|
||||
SetExpQuake(explosion);
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 0);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 0);
|
||||
|
||||
#if 0
|
||||
short ang;
|
||||
|
@ -11647,7 +11647,7 @@ SpawnMineExp(int16_t Weapon)
|
|||
//
|
||||
|
||||
SpawnExpZadjust(Weapon, exp, Z(100), Z(20));
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
SetExpQuake(explosion);
|
||||
|
||||
|
@ -11707,7 +11707,7 @@ SpawnSectorExp(int16_t Weapon)
|
|||
|
||||
DoExpDamageTest(expActor);
|
||||
SetExpQuake(explosion);
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -11743,7 +11743,7 @@ SpawnLargeExp(int16_t Weapon)
|
|||
// Should not cause other sectors to explode
|
||||
DoExpDamageTest(expActor);
|
||||
SetExpQuake(explosion);
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -11823,7 +11823,7 @@ SpawnLittleExp(int16_t Weapon)
|
|||
RESET(exp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
||||
eu->Radius = DamageData[DMG_BASIC_EXP].radius;
|
||||
DoExpDamageTest(expActor);
|
||||
SpawnVis(-1, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
SpawnVis(nullptr, exp->sectnum, exp->x, exp->y, exp->z, 16);
|
||||
|
||||
return explosion;
|
||||
}
|
||||
|
@ -18254,7 +18254,7 @@ InitSobjGun(PLAYERp pp)
|
|||
{
|
||||
case 32:
|
||||
case 0:
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 8);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 8);
|
||||
SpawnBigGunFlames(short(sp - sprite), pp->PlayerSprite, pp->sop);
|
||||
SetGunQuake(short(sp - sprite));
|
||||
InitTankShell(short(sp - sprite), pp);
|
||||
|
@ -18264,7 +18264,7 @@ InitSobjGun(PLAYERp pp)
|
|||
pp->FirePause = SP_TAG5(sp);
|
||||
break;
|
||||
case 1:
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 32);
|
||||
SpawnBigGunFlames(-short(sp - sprite), pp->PlayerSprite, pp->sop);
|
||||
InitSobjMachineGun(short(sp - sprite), pp);
|
||||
if (!SP_TAG5(sp))
|
||||
|
@ -18274,7 +18274,7 @@ InitSobjGun(PLAYERp pp)
|
|||
break;
|
||||
case 2:
|
||||
if (SW_SHAREWARE) break;
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 32);
|
||||
InitTurretLaser(short(sp - sprite), pp);
|
||||
if (!SP_TAG5(sp))
|
||||
pp->FirePause = 120;
|
||||
|
@ -18283,7 +18283,7 @@ InitSobjGun(PLAYERp pp)
|
|||
break;
|
||||
case 3:
|
||||
if (SW_SHAREWARE) break;
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 32);
|
||||
InitTurretRail(short(sp - sprite), pp);
|
||||
if (!SP_TAG5(sp))
|
||||
pp->FirePause = 120;
|
||||
|
@ -18292,7 +18292,7 @@ InitSobjGun(PLAYERp pp)
|
|||
break;
|
||||
case 4:
|
||||
if (SW_SHAREWARE) break;
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 32);
|
||||
InitTurretFireball(short(sp - sprite), pp);
|
||||
if (!SP_TAG5(sp))
|
||||
pp->FirePause = 20;
|
||||
|
@ -18301,7 +18301,7 @@ InitSobjGun(PLAYERp pp)
|
|||
break;
|
||||
case 5:
|
||||
if (SW_SHAREWARE) break;
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 32);
|
||||
InitTurretRocket(short(sp - sprite), pp);
|
||||
if (!SP_TAG5(sp))
|
||||
pp->FirePause = 100;
|
||||
|
@ -18310,7 +18310,7 @@ InitSobjGun(PLAYERp pp)
|
|||
break;
|
||||
case 6:
|
||||
if (SW_SHAREWARE) break;
|
||||
SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32);
|
||||
SpawnVis(actor, -1, -1, -1, -1, 32);
|
||||
InitTurretMicro(short(sp - sprite), pp);
|
||||
if (!SP_TAG5(sp))
|
||||
pp->FirePause = 100;
|
||||
|
|
Loading…
Reference in a new issue