[modding, dat] Feature Request: allow Techs as "init stage event callback" to ensure TechEffects applied at correct timing/order during game start

(Let “passive” means Tech with Research Location=-1, and Game will automatically activates it if dependencies are met, and without user input)

The Problem:

  • Some Tech Effects cannot be applied during early stage of game start, and they must be deferred.
    e.g. read/write Resource.32 (Population Cap); Apply “Spawng Unit”; – cannot be applied in TechTree or other “passive” Techs with already satisfied dependencies.
  • Since Resource/Attribute modification is not fully fledged scripting or expressions, sometimes ordering between TechEffects is wanted. (e.g. to resolve not-commutative operations)

As as result, triggering events (as Tech dependencies) are necessary to ensure that Tech Effects are applied at the correct time, or in correct order.

However now it is overwhelming tricky (if possible) to setup a Tech that activates both “deferred” and automatically. (and probably impossible to ensure order)

Introduce triggering Techs as “init stage event callback” to ensure TechEffects are applied at correct timing or order during game start.

  • Add hardcoded Resource values: [Triggering_Tech_For_InitEvent_XXXX] = “TechID of the triggering Tech”
    Or further extend “Full Tech Mode” to register any number of Techs as “callback” for each initialization stage.
  • Set the triggering Tech as researched on the specific initialization stage, ignoring all dependencies.
  • (Ensuring triggering Tech disabled might be unnecessary, because Techs can be disabled by adding dependencies to itself)

At least two events are needed, but more events are always better:

  • One event for “before Starting Age”, which should be fired after game applies TechTree/TeamBonus/initial “passive” Techs, and before game applies “Starting Age”.
    This event is can be used to “finalize” passive bonuses and ensuring TechEffects’ math order.
  • One event for “after Game start”, when every Resource or TechEffect is expected to be ready.
    (I don’t know the order of above two events because it is difficult to measure now, but it does not matter as long as the order is consistent)

Building’s “Initiate Technology” does not meet the requirement because:

  • It requires a specific Building. (cannot be for Nomad etc.)
  • A triggering Tech when the game applies “Starting Age” is useful, which cannot be simulated by “Initiate Technology”.
  • If the “Initiate Technology” has no deps, or its deps is satisfied at begining, the behavior is really surprising.
    Apparently Game does not keep it disabled until Building built, but activates it early because its deps are already satisfied.

The “Initiate Technology” behavior is really surprising. (Pompeii mode)
(Tech activation is counted by updating Villager’s attack/armor/etc.)

  1. (Method A) If TownCenter.InitiateTechnology = TechA:
    TechA is activated 1 times.
  2. (Method B) If TownCenter.AnnexUnit[0] = BuildingB; BuildingB.HP = -1, BuildingB.InitiateTechnology = TechB:
    (in short, trigger Initiate Technology by dying annex unit)
    • TechB is activated 2 times at game start: 1st time early, 2nd time deferred (Spawning Unit is possible).
    • TechB is infinitely repeatable (re-activate every-time when a Town Center is built).
    • If TechB.ResearchTime > 0, it is triggered once, but no longer deferred…
  3. (Method C) If TownCenter.AnnexUnit[0] = BuildingC1; BuildingC1.HP=-1, BuildingC1.DeadUnit=UnitC2; UnitC2 is decayable (set resource and decay rate), UnitC2.DeatUnit = BuildingC3; BuildingC3.InitiateTechnology = TechC:
    (in short, a dying and decaying annex, (after decay) spawns another dying unit to trigger Initiate Technology)
    • TechC is activated 2 times – 1 time at game start, and 2nd time deferred.
    • TechC is infinitely repeatable (re-activate every-time after a Town Center is built).
    • If TechC.ResearchTime > 0, it is triggered once, and deferred.
  4. In case of Method B/C, TechB/C does not work reliably as a deps: it often fails to activate other Techs depending on it (it seems to work as deps only when it is the last unsolved deps)

I don’t know if this behavior is expected or not, but the proposal will not break Initiate Technology’s compatibility.
(Initiate Technology’s repeating behavior could be useful, but I would guess that no one wants the extra duplicated activation during game start.)

Current Partial Workaround:
From what I experimented, it seems impossible to implement it in Rome mode.

@Felizon89 @StepS7578
Could you please took a look? Thanks a lot.
(I thought it should be easy to implement and does not break existing things.)

It seems that in Pompeii mode, Tech need research time > 0 to avoid got activated at the very beginning of the game. If I recall correctly, it was the legacy behavior of Rise of Rome.

But why bother simulate this inferior behavior and make it different from default AOE2 mode?
In AOE2 dat, apparently shadow Techs have research time = 0.