[Fixed] Catapult flying away if shooting from a Mounted Bow which is in a Catapult's Mag #1311
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Status
Description
Fixes #1247.
I decided to make this a separate PR and not to include this in #1251.
When a Mounted Bow is in a Catapult's mag and you are firing from that Mounted Bow, the catapult would fly away.
This change fixes that so when shooting from the Mounted Bow, it will shoot arrows and not detach.
The Mounted Bow can be shot forward normally if firing from the catapult's gunner position.
Apparently, the code assumes a Mounted Bow on its own does not have a "MAG" attachment point.
However, when it is attached to the Catapult, it will return a "MAG" attachment point - the one by the catapult.
By changing
this.getAttachments().getAttachmentPointByName("MAG");
to
this.getAttachments().getAttachmentPoint("MAG", true);
, it will only return the "MAG" attachment point if the blob is the socket - The Mounted Bow will therefore never somehow fetch a wrong mag attachment point now and the bug won't happen.As a bonus, another bug has been fixed by this:
Mounted Bow won't show a wrong "load item" button after it was previously in a Catapult's mag.
It will now still only show a load button if you have arrows in your inventory or hand.
Steps to Test or Reproduce
Place changed file in a mod folder.
Start your dev install with the mod.
Go to Save the Princess.
!tradingpost
!999 coins
Buy a Mounted Bow
!catapult
Place the Mounted Bow in the Catapult's mag
Attach to the Mounted Bow and fire.
Notice the catapult will fly away. After this change, it will shoot arrows and not detach from the catapult.