Opened 8 years ago

Closed 8 years ago

#3763 closed defect (fixed)

[PATCH] Attack interval tooltip wrong

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

The heavy warship repeatedly fires a single shot if no catapults are garrisoned. But the tooltip shows that it fires 0 shots per second, which should be corrected.

Attachments (2)

Screenshot (378).png (1.3 MB ) - added by Sergey Kushnirenko 8 years ago.
t3763.patch (757 bytes ) - added by Sergey Kushnirenko 8 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Sergey Kushnirenko, 8 years ago

Keywords: review patch added
Milestone: BacklogAlpha 20

comment:2 by Sergey Kushnirenko, 8 years ago

Summary: Heavy warship attack interval tooltip wrong[PATCH] Heavy warship attack interval tooltip wrong

by Sergey Kushnirenko, 8 years ago

Attachment: Screenshot (378).png added

comment:3 by Sergey Kushnirenko, 8 years ago

See screenshot in attach which number of attack correct for this warship.

comment:4 by elexis, 8 years ago

Keywords: review removed

Where do you take that number 5 from? For an ungarrisoned ship, arrowCount and defaultArrowCount will be identical anyway.

If one reduces the trireme defaultArrowCount from 3 to 0, we can see that it still fires one arrow. So the arrowcount is wrong for all units that have both an Attack and BuildingAI component. For example the macedonian siege tower also has this problem.

The correct way to solve this issue is to add +1 in the tooltip function in this case.

comment:5 by Sergey Kushnirenko, 8 years ago

Keywords: review added; simple removed

by Sergey Kushnirenko, 8 years ago

Attachment: t3763.patch added

comment:6 by elexis, 8 years ago

Keywords: review removed
Summary: [PATCH] Heavy warship attack interval tooltip wrong[PATCH] Attack interval tooltip wrong

Thanks leper and sanderd17 for explaining some background of the affected components.

Review: As mentioned before, this issue is not only affected the heavy warship but also other buildings:

  • the macedonian siege tower (template_unit_mechanical_siege_tower). The tooltip says 0 arrows while it shoots one.
  • trireme ship: it shoots 4 arrows instead of 3 if not garrisoned
  • heavy warship: if no catapults garrisoned, it shoots 1 arrow while the tooltip says 0

So only changing the tooltip if there are catapults garrissoned is wrong.


Fixing the tooltip: According to sanderd17, the +1 arrow must be added to the tooltip if and only if the entity has a BuildingAI and a UnitAI component.

For example regular towers (template_structure_defense_defense_tower) actually shoot one arrow and the tooltip is correct (displays 1 arrow). This is because the tower doesn't have a UnitAI component (contrary to ships and siege).

If I understood correctly, the Attack component determines the attack stats and UnitAI and BuildingAI independently decide whether to attack.

Line 63 in tooltips.js is the right place to change, but you need to add the +1 if and only if the entity has a UnitAI component.

Since having this is one arrow is a weird behavior, we add this weird behavior to tooltips.js too. Therefore add a comment, both to tooltip.js that explains why we add it and a TODO comment for BuildingAI.prototype.FireArrows that informs other developers that the UnitAI component also shoots one arrow (if the entity has that component) and that this should not happen ideally.


(13:05:14) sanderd17: I've tried disableing that arrow before, but not really succeeded, as it's nested quite deep (and you should still have unitAI to task a unit to attack something, so you can't just ignore the attack from unitAI)

comment:7 by elexis, 8 years ago

In 17783:

BuildingAI style fixes, refs #3763.
Remove a duplicate targetUnits-, some useless length-checks and unneeded comments.

comment:8 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 17784:

Don't shoot an undocumented arrow from UnitAI if the entity also has a BuildingAI component shooting arrows. Fixes #3763.
Instead, add the arrow to the affected unit templates (except bireme and trireme, refs #3196).

Note: See TracTickets for help on using tickets.