mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +02:00
Redo code that makes SOAP float on OIL
Rather than hacking velocity, do it directly through can_move. Add a special case to make it slowly float upwards, rather than immediate like most weight differences in TPT.
This commit is contained in:
@@ -2487,6 +2487,8 @@ void Simulation::init_can_move()
|
|||||||
can_move[PT_THDR][PT_THDR] = 2;
|
can_move[PT_THDR][PT_THDR] = 2;
|
||||||
can_move[PT_EMBR][PT_EMBR] = 2;
|
can_move[PT_EMBR][PT_EMBR] = 2;
|
||||||
can_move[PT_TRON][PT_SWCH] = 3;
|
can_move[PT_TRON][PT_SWCH] = 3;
|
||||||
|
can_move[PT_SOAP][PT_OIL] = 0;
|
||||||
|
can_move[PT_OIL][PT_SOAP] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2812,6 +2814,14 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
// SOAP slowly floats up inside OIL
|
||||||
|
case PT_SOAP:
|
||||||
|
if (parts[i].type == PT_OIL)
|
||||||
|
{
|
||||||
|
if (RNG::Ref().chance(19, 20) || std::abs(parts[i].x - nx) > 3 || std::abs(parts[i].y - ny) > 3)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (parts[i].type)
|
switch (parts[i].type)
|
||||||
|
@@ -234,22 +234,6 @@ static int update(UPDATE_FUNC_ARGS)
|
|||||||
parts[i].ctype = 1;
|
parts[i].ctype = 1;
|
||||||
parts[i].life = 10;
|
parts[i].life = 10;
|
||||||
}
|
}
|
||||||
for (rx=-2; rx<3; rx++)
|
|
||||||
for (ry=-2; ry<3; ry++)
|
|
||||||
if (BOUNDS_CHECK && (rx || ry))
|
|
||||||
{
|
|
||||||
r = pmap[y+ry][x+rx];
|
|
||||||
if (!r)
|
|
||||||
continue;
|
|
||||||
if (TYP(r) == PT_OIL)
|
|
||||||
{
|
|
||||||
float ax, ay;
|
|
||||||
ax = (parts[i].vx*0.5f + parts[ID(r)].vx)/2;
|
|
||||||
ay = ((parts[i].vy-0.1f)*0.5f + parts[ID(r)].vy)/2;
|
|
||||||
parts[i].vx = parts[ID(r)].vx = ax;
|
|
||||||
parts[i].vy = parts[ID(r)].vy = ay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (rx=-2; rx<3; rx++)
|
for (rx=-2; rx<3; rx++)
|
||||||
for (ry=-2; ry<3; ry++)
|
for (ry=-2; ry<3; ry++)
|
||||||
|
Reference in New Issue
Block a user