[+] Added MissileType::ParabolCoefficient, to control curve coefficient in MissileParabolic

[*] All calculations in MissileParabolic now use doubles instead of ints
This commit is contained in:
cybermind 2013-08-14 19:23:54 +06:00
parent e988ff95b6
commit 9521969aeb
4 changed files with 12 additions and 8 deletions

View file

@ -379,6 +379,7 @@ public:
int Class; /// missile class
int NumBounces; /// number of bounces
int ParabolCoefficient; /// parabol coefficient in parabolic missile
int StartDelay; /// missile start delay
int Sleep; /// missile sleep
int Speed; /// missile speed

View file

@ -1231,7 +1231,8 @@ MissileType::MissileType(const std::string &ident) :
Ident(ident), Transparency(0), DrawLevel(0),
SpriteFrames(0), NumDirections(0), ChangeVariable(-1), ChangeAmount(0), ChangeMax(false),
CorrectSphashDamage(false), Flip(false), CanHitOwner(false), FriendlyFire(false),
AlwaysFire(false), Pierce(false), PierceOnce(false), Class(), NumBounces(0), StartDelay(0),
AlwaysFire(false), Pierce(false), PierceOnce(false), Class(), NumBounces(0),
ParabolCoefficient(2048), StartDelay(0),
Sleep(0), Speed(0), TTL(-1), Damage(0), ReduceFactor(100), SmokePrecision(0),
Range(0), SplashFactor(0),
ImpactParticle(NULL), SmokeParticle(NULL), OnImpact(NULL),

View file

@ -55,10 +55,10 @@
static bool ParabolicMissile(Missile &missile)
{
// Should be initialised by an other method (computed with distance...)
const int k = -2048; //-1024; // Coefficient of the parabol.
const int zprojToX = 4; // Projection of Z axis on axis X.
const int zprojToY = 1024; // Projection of Z axis on axis Y.
int z; // should be missile.Z later.
const double k = -missile.Type->ParabolCoefficient; // Coefficient of the parabol.
const double zprojToX = 4.0; // Projection of Z axis on axis X.
const double zprojToY = 1024.0; // Projection of Z axis on axis Y.
double z; // should be missile.Z later.
MissileInitMove(missile);
if (missile.TotalStep == 0) {
@ -73,10 +73,10 @@ static bool ParabolicMissile(Missile &missile)
missile.position = missile.source + diff * missile.CurrentStep / missile.TotalStep;
Assert(k != 0);
z = missile.CurrentStep * (missile.TotalStep - missile.CurrentStep) / k;
z = (double)missile.CurrentStep * (missile.TotalStep - missile.CurrentStep) / k;
// Until Z is used for drawing, modify X and Y.
missile.position.x += z * zprojToX / 64;
missile.position.y += z * zprojToY / 64;
missile.position.x += (int)(z * zprojToX / 64.0);
missile.position.y += (int)(z * zprojToY / 64.0);
missile.MissileNewHeadingFromXY(missile.position - orig_pos);
for (; pos.x * sign.x <= missile.position.x * sign.x
&& pos.y * sign.y <= missile.position.y * sign.y;

View file

@ -130,6 +130,8 @@ void MissileType::Load(lua_State *l)
}
} else if (!strcmp(value, "NumBounces")) {
this->NumBounces = LuaToNumber(l, -1);
} else if (!strcmp(value, "ParabolCoefficient")) {
this->ParabolCoefficient = LuaToNumber(l, -1);
} else if (!strcmp(value, "Delay")) {
this->StartDelay = LuaToNumber(l, -1);
} else if (!strcmp(value, "Sleep")) {