Commit 368aa7a4221d95b4518d1e201a421ce5d43437e4

Authored by Otowa Kotori
1 parent 1d8a60af

funcional tactical value will not get cached

... ... @@ -1547,11 +1547,12 @@ function _M:aiTalentTactics(t, aitarget, target_list, tactic, tg, wt_mod)
1547 1547 if log_detail > 2 then print("\t__cached weight for tactic:", tact, "vs", act.uid, act.name, "==", tid_cache[tact] and tid_cache[tact][act]) end
1548 1548 tgt_weight = nil
1549 1549 end
1550   -
  1550 + local have_functional_value = false
1551 1551 if not tgt_weight then -- compute the tactic weight value for this target
1552 1552 local val = val
1553 1553 if type(val) == "function" then -- evaluate a function
1554 1554 if log_detail > 2 then print("\t resolving functional tactic value", val) end
  1555 + have_functional_value = true
1555 1556 val = val(self, t, act) or 0
1556 1557 if log_detail > 2 then print("\t tactic value:", val) table.print(val, "\t\t") end
1557 1558 end
... ... @@ -1644,9 +1645,13 @@ function _M:aiTalentTactics(t, aitarget, target_list, tactic, tg, wt_mod)
1644 1645 print(("\t***TACTICAL WEIGHT CACHE MATCHES: [%d]%s %s (%s) on [%d]%s{%s}: %s vs %s(cache)"):format(self.uid, self.name, t.id, tact, act.uid, act.name, msg, tgt_weight, cache_tgt_weight))
1645 1646 end
1646 1647 end
1647   - tid_cache[tact][act] = tgt_weight
1648   - tid_cache[tact][act.uid] = act.aiDHash
1649   - if log_detail > 3 then print("\t__updated cached weight for tactic:", tact, "vs", act.uid, act.name, "==", tid_cache[tact][act]) end
  1648 + if not have_functional_value then
  1649 + tid_cache[tact][act] = tgt_weight
  1650 + tid_cache[tact][act.uid] = act.aiDHash
  1651 + if log_detail > 3 then print("\t__updated cached weight for tactic:", tact, "vs", act.uid, act.name, "==", tid_cache[tact][act]) end
  1652 + else
  1653 + if log_detail > 3 then print("\tNot cached weight for tactic:", tact, "vs", act.uid, act.name, "==", tgt_weight) end
  1654 + end
1650 1655 end
1651 1656 end -- end compute target weight branch
1652 1657 weighted_sum = weighted_sum + tgt_weight
... ...