Skip to content

Missile_lockedonto, second attempt#2042

Open
Wartich wants to merge 2 commits intoDonBruce64:masterfrom
Wartich:master
Open

Missile_lockedonto, second attempt#2042
Wartich wants to merge 2 commits intoDonBruce64:masterfrom
Wartich:master

Conversation

@Wartich
Copy link

@Wartich Wartich commented Feb 26, 2026

Variable for when any gun is locked onto your vehicle. Please check it thoroughly because i have no coding knowledge and i relied on AI slopmastery to make it. Also it might have been messed up along the way, but it is functional both single and multi player


//Check to make sure we are still being tracked.
radarsTracking.removeIf(tracker -> !tracker.isValid || (!tracker.aircraftOnRadar.contains(this) && !tracker.groundersOnRadar.contains(this)));
gunsLockedOn.removeIf(gun -> !gun.isValid || (gun.engineTarget != null && gun.engineTarget.vehicleOn != this));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this condition, what if the gun's engine target is null (doesn't exist). This logic will not remove it since it returns false.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a commit that changed it a little

/**
* Unregisters this gun from the previous target vehicle's gunsLockedOn list.
*/
private void unregisterFromPreviousTargetVehicle() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I don't see a need to have this, and the code that checks for the gun states to run at the same time. Either the gun can handle registeration internally when things change, or it won't handle it and the vehicle should. Is there a reason you have it check for gun targeting on the vehicle? Did something get de-synced during testing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nuked it and it seems to work fine both singleplayer and dedicated server

// Check if engine target changed
if (engineTarget != prevEngineTarget) {
prevEngineTarget = engineTarget;
registerWithTargetVehicle();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final request here. I see that you put this code into a sub-routine, but that doesn't get called from anywhere else. I feel it would be cleaner to just put that sub-routine code here. Once that's done this should be good to merge.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is called for though? Or did i misunderstand you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants