1
0

Pickups spawn with correct speed and position

Added a comment-space as well.
This commit is contained in:
Tiger Wang 2013-09-04 18:26:00 +01:00
parent 6059c44dcb
commit ad89a0d460
2 changed files with 11 additions and 29 deletions

View File

@ -1514,22 +1514,13 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
{ {
float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
float SpeedY = (float)(a_FlyAwaySpeed * r1.randInt(1000)); float SpeedY = 1;
float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
// Add random offset to the spawn position: // (FS #338 Fixed with mid block position spawn, previous TODOs/comments removed)
int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16); int MicroX = (int)(floor(a_BlockX) * 32) + 16;
int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16); int MicroY = (int)(floor(a_BlockY) * 32) + 16;
int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16); int MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
// TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338),
// I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics
SpeedX = SpeedY = SpeedZ = 0;
// TODO 2013_05_12 _X: It seems that pickups bug out even with zero speed, trying mid-block position:
MicroX = (int)(floor(a_BlockX) * 32) + 16;
MicroY = (int)(floor(a_BlockY) * 32) + 16;
MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
cPickup * Pickup = new cPickup( cPickup * Pickup = new cPickup(
MicroX, MicroY, MicroZ, MicroX, MicroY, MicroZ,
@ -1545,22 +1536,13 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ) void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ)
{ {
// TODO 2013_05_12 _X: Because spawning pickups with nonzero speed causes them to bug (FS #338),
// I decided to temporarily reset the speed to zero to fix it, until we have proper pickup physics
a_SpeedX = a_SpeedY = a_SpeedZ = 0;
MTRand r1; MTRand r1;
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
{ {
// Add random offset to the spawn position: // (FS #338 Fixed with mid block position spawn, previous TODOs/comments removed)
int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16); int MicroX = (int)(floor(a_BlockX) * 32) + 16;
int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16); int MicroY = (int)(floor(a_BlockY) * 32) + 16;
int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16); int MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
// TODO 2013_05_12 _X: It seems that pickups bug out even with zero speed, trying mid-block position:
MicroX = (int)(floor(a_BlockX) * 32) + 16;
MicroY = (int)(floor(a_BlockY) * 32) + 16;
MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
cPickup * Pickup = new cPickup( cPickup * Pickup = new cPickup(
MicroX, MicroY, MicroZ, MicroX, MicroY, MicroZ,