Ticket #42659

Unhardcode autoupgrade

Open Date: 2021-07-23 08:19 Last Update: 2021-07-23 20:13

Reporter:
Owner:
(None)
Status:
Open
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
None
File:
None

Details

Autoupgrade (Leonardo effect) is a gimmick bonus, like hut findings, but it is now hardcoded. The result is, we can't have any good way for adding flexibility to it (e.g., upgrade only units in domestic borders, or have wonders that upgrade different classes separately). So, the logical solution is: write autoupgrade code into a Lua callback in default.lua, and the effect "Upgrade_Unit" will just be used by AI and autohelp as it is, and the default callback looks at it but some other one might not. To do it, we must develop in separate tickets:

  • "phase_end" signal (called in srv_main.c when we now deal with this effect, after do_tech_parasite_effect() and before player_restore_units() from which we cut do_upgrade_effects());
  • API to do the things do_upgrade_effects() does:
  • void (Unit):transform(Unit_Type to_what, bool dont_lose_veteranship) -- maybe the second parameter may be unhardcoded further?
  • an API for unit_upgrade_test(punit, TRUE). Suggestion:
    • string (Unit):transform_blocker(Unit_Type tf_to) -- possible values: nil, "cargo", "transport", "tile"; maybe numeric results and constants table for less garbage
    • Unit_Type (Unit_Type):upgrade_type(Player owner) --for can_upgrade_unittype(), maybe also a shortcut Unit_Type (Unit):upgrade_type(); nil if can't yet upgrade
    • maybe as more low-level control of the previous: Unit_Type (Unit_Type).obsoleted_by and bool (Player):can_build_direct(Unit_Type utype).

Ticket History (3/4 Histories)

2021-07-23 08:19 Updated by: ihnatus
  • New Ticket "Unhardcode autoupgrade" created
2021-07-23 08:22 Updated by: ihnatus
  • Details Updated
2021-07-23 20:07 Updated by: ihnatus
  • Details Updated
2021-07-23 20:13 Updated by: ihnatus
  • Details Updated

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login