mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-22 11:41:08 +00:00
- DVector3 version of EGS.
This commit is contained in:
parent
25a048c62f
commit
87ef58c07e
3 changed files with 31 additions and 13 deletions
|
@ -262,8 +262,9 @@ void lotsofstuff(DDukeActor* actor, int n, int spawntype)
|
|||
{
|
||||
for (int i = n; i > 0; i--)
|
||||
{
|
||||
int r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR.
|
||||
auto j = EGS(actor->sector(), actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, actor, 5);
|
||||
int r1 = krand(); // using the RANDCORRECT version from RR.
|
||||
double r2 = zrand(47);
|
||||
auto j = CreateActor(actor->sector(), actor->spr.pos.plusZ(-r2), spawntype, -32, 8, 8, r1 & 2047, 0, 0, actor, 5);
|
||||
if (j) j->spr.cstat = randomFlip();
|
||||
}
|
||||
}
|
||||
|
@ -5229,15 +5230,15 @@ void movefta(void)
|
|||
{
|
||||
if (badguy(act))
|
||||
{
|
||||
double px = ps[p].opos.X + (64 - (krand() & 127)) * maptoworld;
|
||||
double py = ps[p].opos.Y + (64 - (krand() & 127)) * maptoworld;
|
||||
double px = ps[p].opos.X - xyrand(64);
|
||||
double py = ps[p].opos.Y - xyrand(64);
|
||||
updatesector(DVector3(px, py, 0), &psect);
|
||||
if (psect == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
double sx = act->spr.pos.X + (64 - (krand() & 127)) * maptoworld;
|
||||
double sy = act->spr.pos.Y + (64 - (krand() & 127)) * maptoworld;
|
||||
double sx = act->spr.pos.X - xyrand(64);
|
||||
double sy = act->spr.pos.Y - xyrand(64);
|
||||
// The second updatesector call here used px and py again and was redundant as coded.
|
||||
|
||||
// SFLAG_MOVEFTA_CHECKSEE is set for all actors in Duke.
|
||||
|
@ -5245,9 +5246,9 @@ void movefta(void)
|
|||
(actorflag(act, SFLAG_MOVEFTA_CHECKSEEWITHPAL8) && act->spr.pal == 8) ||
|
||||
(bcos(act->spr.ang) * (px - sx) + bsin(act->spr.ang) * (py - sy) >= 0))
|
||||
{
|
||||
int r1 = krand();
|
||||
int r2 = krand();
|
||||
canseeme = cansee({ sx, sy, act->spr.pos.Z - (r2 % (52 << 8)) * maptoworld }, act->sector(), { px, py, ps[p].opos.Z - (r1 % (32 << 8)) * maptoworld }, ps[p].cursector);
|
||||
double r1 = zrand(32);
|
||||
double r2 = zrand(52);
|
||||
canseeme = cansee({ sx, sy, act->spr.pos.Z - r2 }, act->sector(), { px, py, ps[p].opos.Z - r1 }, ps[p].cursector);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -171,7 +171,12 @@ int furthestangle(DDukeActor* snum, int angDiv);
|
|||
void getglobalz(DDukeActor* s);
|
||||
void OnEvent(int id, int pnum = -1, DDukeActor* snum = nullptr, int dist = -1);
|
||||
|
||||
DDukeActor* EGS(sectortype* whatsect, int s_x, int s_y, int s_z, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss);
|
||||
DDukeActor* CreateActor(sectortype* whatsect, const DVector3& pos, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss);
|
||||
|
||||
inline DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss)
|
||||
{
|
||||
return CreateActor(whatsectp, { s_x * inttoworld, s_y * inttoworld, s_z * zinttoworld }, s_pn, s_s, s_xr, s_yr, s_a, s_ve, s_zv, s_ow, s_ss);
|
||||
}
|
||||
|
||||
void ceilingglass(DDukeActor* snum, sectortype* sectnum, int cnt);
|
||||
void spriteglass(DDukeActor* snum, int cnt);
|
||||
|
@ -240,4 +245,15 @@ void loadcons();
|
|||
void recordoldspritepos();
|
||||
void DrawStatusBar();
|
||||
|
||||
inline double zrand(int spread)
|
||||
{
|
||||
int r = krand() % (spread << 8);
|
||||
return r * zmaptoworld;
|
||||
}
|
||||
|
||||
inline double xyrand(int mask)
|
||||
{
|
||||
return ((krand() % mask) - (mask << 1) - 1) * maptoworld;
|
||||
}
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -45,11 +45,12 @@ BEGIN_DUKE_NS
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
// this creates a new actor but does not run any init code on it
|
||||
// direct calls should only be done for very simple things.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss)
|
||||
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_s, int8_t s_xr, int8_t s_yr, int s_a, int s_ve, int s_zv, DDukeActor* s_ow, int8_t s_ss)
|
||||
{
|
||||
// sector pointer must be strictly validated here or the engine will crash.
|
||||
if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr;
|
||||
|
@ -61,7 +62,7 @@ DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8
|
|||
SetupGameVarsForActor(act);
|
||||
|
||||
|
||||
act->set_int_pos({ s_x, s_y, s_z });
|
||||
act->spr.pos = pos;
|
||||
act->spr.cstat = 0;
|
||||
act->spr.picnum = s_pn;
|
||||
act->spr.shade = s_s;
|
||||
|
|
Loading…
Reference in a new issue