Fix incorrect RNG call in WARP, code cleanup

x velocity was set using .chance instead of .between. This always returned false, meaning vx always was set to .5 giving a rightward bias
This commit is contained in:
jacob1 2022-01-06 20:29:07 -05:00
parent 95a9e93645
commit eadd381da9
No known key found for this signature in database
GPG Key ID: 4E58A32D510E1995

View File

@ -51,7 +51,6 @@ void Element::Element_WARP()
static int update(UPDATE_FUNC_ARGS)
{
int trade, r, rx, ry;
if (parts[i].tmp2 > 2000)
{
parts[i].temp = 10000;
@ -59,13 +58,13 @@ static int update(UPDATE_FUNC_ARGS)
if (RNG::Ref().chance(1, 50))
sim->create_part(-3, x, y, PT_ELEC);
}
for ( trade = 0; trade<5; trade ++)
for (int trade = 0; trade < 5; trade ++)
{
rx = RNG::Ref().between(-1, 1);
ry = RNG::Ref().between(-1, 1);
int rx = RNG::Ref().between(-1, 1);
int ry = RNG::Ref().between(-1, 1);
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
int r = pmap[y + ry][x + rx];
if (!r)
continue;
if (TYP(r) != PT_WARP && TYP(r) != PT_STKM && TYP(r) != PT_STKM2 && TYP(r) != PT_DMND && TYP(r) != PT_CLNE && TYP(r) != PT_BCLN && TYP(r) != PT_PCLN)
@ -74,7 +73,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].y = parts[ID(r)].y;
parts[ID(r)].x = float(x);
parts[ID(r)].y = float(y);
parts[ID(r)].vx = RNG::Ref().chance(-2, 1) + 0.5f;
parts[ID(r)].vx = RNG::Ref().between(-2, 1) + 0.5f;
parts[ID(r)].vy = float(RNG::Ref().between(-2, 1));
parts[i].life += 4;
pmap[y][x] = r;