Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inaccuracy to RocketTypes #1151

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ This page lists all the individual contributions to the project by their author.
- Implement the Torpedo logic from Red Alert 1 for BulletTypes.
- Add `BuildTimeCost`.
- Allow scenarios to have custom score screen bar colors.
- Add `Inaccuracy` to RocketTypes.
- **secsome**:
- Add support for up to 32767 waypoints to be used in scenarios.
- **ZivDero**:
Expand Down
1 change: 1 addition & 0 deletions docs/New-Features-and-Enhancements.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ Warhead= ; WarheadType, the warhead that this rocket's explosion
EliteWarhead= ; WarheadType, the warhead that this rocket's explosion uses when the spawner is elite.
TakeoffAnim= ; AnimType, the takeoff animation used by this rocket.
TrailAnim= ; AnimType, the trail animation used by this rocket.
Inaccuracy= ; integer, the maximum number of leptons that this rocket is able to miss its target by.
```

```{note}
Expand Down
13 changes: 12 additions & 1 deletion src/new/locomotion/rocketlocomotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,18 @@ IFACEMETHODIMP_(void) RocketLocomotionClass::Move_To(Coordinate to)

MissionTimer = timer_delay;
CurrentPitch = rocket->PitchInitial * DEG_TO_RAD(90);
DestinationCoord = to;

/**
* Apply some inaccuracy to the coordinate if the rocket type specifies so.
*/
if (rocket->Inaccuracy <= 0) {
DestinationCoord = to;
}
else {
const int randomx = Random_Pick(-rocket->Inaccuracy, rocket->Inaccuracy);
const int randomy = Random_Pick(-rocket->Inaccuracy, rocket->Inaccuracy);
DestinationCoord = to + Coordinate(randomx, randomy, 0);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/new/rockettype/rockettype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ RocketTypeClass::RocketTypeClass(const char* name) :
CloseEnoughFactor(1.0),
Type(nullptr),
Warhead(nullptr),
EliteWarhead(nullptr)
EliteWarhead(nullptr),
Inaccuracy(0)
{
ASSERT_FATAL_PRINT(name != nullptr, "Invalid name for RocketType!");

Expand Down Expand Up @@ -397,6 +398,7 @@ bool RocketTypeClass::Read_INI(CCINIClass& ini)
EliteWarhead = ini.Get_Warhead(IniName, "EliteWarhead", EliteWarhead);
TakeoffAnim = ini.Get_Anim(IniName, "TakeoffAnim", TakeoffAnim);
TrailAnim = ini.Get_Anim(IniName, "TrailAnim", TrailAnim);
Inaccuracy = ini.Get_Int(IniName, "Inaccuracy", Inaccuracy);

return true;
}
5 changes: 5 additions & 0 deletions src/new/rockettype/rockettype.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,9 @@ RocketTypeClass final : IPersistStream
*/
const AnimTypeClass* TakeoffAnim;
const AnimTypeClass* TrailAnim;

/**
* The maximum number of leptons that this rocket is able to miss its target by.
*/
int Inaccuracy;
};
Loading