@@ -58,6 +58,7 @@ void BombardTrajectoryType::Read(CCINIClass* const pINI, const char* pSection)
58
58
INI_EX exINI (pINI);
59
59
60
60
this ->Height .Read (exINI, pSection, " Trajectory.Bombard.Height" );
61
+ this ->Height = Math::max (0.0 , this ->Height );
61
62
this ->FallPercent .Read (exINI, pSection, " Trajectory.Bombard.FallPercent" );
62
63
this ->FallPercentShift .Read (exINI, pSection, " Trajectory.Bombard.FallPercentShift" );
63
64
this ->FallScatter_Max .Read (exINI, pSection, " Trajectory.Bombard.FallScatter.Max" );
@@ -153,14 +154,12 @@ bool BombardTrajectory::OnAI(BulletClass* pBullet)
153
154
if (this ->BulletDetonatePreCheck (pBullet))
154
155
return true ;
155
156
156
- // Extra check for trajectory falling
157
- const auto pOwner = pBullet->Owner ? pBullet->Owner ->Owner : BulletExt::ExtMap.Find (pBullet)->FirerHouse ;
157
+ this ->BulletVelocityChange (pBullet);
158
158
159
- if (this ->IsFalling && !this ->Type ->FreeFallOnTarget && this ->BulletDetonateRemainCheck (pBullet, pOwner))
159
+ // Extra check for trajectory falling
160
+ if (this ->IsFalling && !this ->Type ->FreeFallOnTarget && this ->BulletDetonateRemainCheck (pBullet))
160
161
return true ;
161
162
162
- this ->BulletVelocityChange (pBullet);
163
-
164
163
return false ;
165
164
}
166
165
@@ -208,6 +207,7 @@ void BombardTrajectory::PrepareForOpenFire(BulletClass* pBullet)
208
207
pBullet->Velocity *= pType->Trajectory_Speed / pBullet->Velocity .Magnitude ();
209
208
210
209
this ->CalculateDisperseBurst (pBullet);
210
+ this ->RemainingDistance += static_cast <int >(middleLocation.DistanceFrom (pBullet->SourceCoords ) + pType->Trajectory_Speed );
211
211
}
212
212
else
213
213
{
@@ -241,8 +241,9 @@ void BombardTrajectory::PrepareForOpenFire(BulletClass* pBullet)
241
241
this ->RefreshBulletLineTrail (pBullet);
242
242
243
243
pBullet->SetLocation (middleLocation);
244
- const auto pOwner = pBullet->Owner ? pBullet->Owner ->Owner : pExt->FirerHouse ;
245
- AnimExt::CreateRandomAnim (pType->TurningPointAnims , middleLocation, pBullet->Owner , pOwner, true );
244
+ const auto pTechno = pBullet->Owner ;
245
+ const auto pOwner = pTechno ? pTechno->Owner : pExt->FirerHouse ;
246
+ AnimExt::CreateRandomAnim (pType->TurningPointAnims , middleLocation, pTechno, pOwner, true );
246
247
}
247
248
}
248
249
@@ -496,7 +497,7 @@ bool BombardTrajectory::BulletDetonatePreCheck(BulletClass* pBullet)
496
497
return false ;
497
498
}
498
499
499
- bool BombardTrajectory::BulletDetonateRemainCheck (BulletClass* pBullet, HouseClass* pOwner )
500
+ bool BombardTrajectory::BulletDetonateRemainCheck (BulletClass* pBullet)
500
501
{
501
502
const auto pType = this ->Type ;
502
503
this ->RemainingDistance -= static_cast <int >(pType->FallSpeed );
@@ -519,26 +520,23 @@ void BombardTrajectory::BulletVelocityChange(BulletClass* pBullet)
519
520
520
521
if (!this ->IsFalling )
521
522
{
522
- if (pBullet->Location .Z + pBullet->Velocity .Z >= this ->Height )
523
+ this ->RemainingDistance -= static_cast <int >(pType->Trajectory_Speed );
524
+
525
+ if (this ->RemainingDistance < static_cast <int >(pType->Trajectory_Speed ))
523
526
{
524
527
if (this ->ToFalling )
525
528
{
526
529
this ->IsFalling = true ;
530
+ this ->RemainingDistance = 1 ;
527
531
const auto pTarget = pBullet->Target ;
528
532
auto middleLocation = CoordStruct::Empty;
529
533
530
534
if (!pType->FreeFallOnTarget )
531
535
{
532
- middleLocation = CoordStruct
533
- {
534
- static_cast <int >(pBullet->Location .X + pBullet->Velocity .X ),
535
- static_cast <int >(pBullet->Location .Y + pBullet->Velocity .Y ),
536
- static_cast <int >(pBullet->Location .Z + pBullet->Velocity .Z )
537
- };
538
-
539
536
if (pType->LeadTimeCalculate && pTarget)
540
537
pBullet->TargetCoords += pTarget->GetCoords () - this ->InitialTargetCoord + this ->CalculateBulletLeadTime (pBullet);
541
538
539
+ middleLocation = pBullet->Location ;
542
540
pBullet->Velocity .X = static_cast <double >(pBullet->TargetCoords .X - middleLocation.X );
543
541
pBullet->Velocity .Y = static_cast <double >(pBullet->TargetCoords .Y - middleLocation.Y );
544
542
pBullet->Velocity .Z = static_cast <double >(pBullet->TargetCoords .Z - middleLocation.Z );
@@ -569,7 +567,8 @@ void BombardTrajectory::BulletVelocityChange(BulletClass* pBullet)
569
567
570
568
pBullet->SetLocation (middleLocation);
571
569
const auto pTechno = pBullet->Owner ;
572
- AnimExt::CreateRandomAnim (pType->TurningPointAnims , middleLocation, pTechno, pTechno ? pTechno->Owner : pExt->FirerHouse , true );
570
+ const auto pOwner = pTechno ? pTechno->Owner : pExt->FirerHouse ;
571
+ AnimExt::CreateRandomAnim (pType->TurningPointAnims , middleLocation, pTechno, pOwner, true );
573
572
}
574
573
else
575
574
{
@@ -579,7 +578,7 @@ void BombardTrajectory::BulletVelocityChange(BulletClass* pBullet)
579
578
if (pType->LeadTimeCalculate && pTarget)
580
579
this ->LastTargetCoord = pTarget->GetCoords ();
581
580
582
- pBullet->Velocity *= std::abs (( this ->Height - pBullet-> Location . Z ) / pBullet-> Velocity . Z ) ;
581
+ pBullet->Velocity *= this ->RemainingDistance / pType-> Trajectory_Speed ;
583
582
}
584
583
}
585
584
}
0 commit comments