Advertisement
Tkap1

Untitled

Oct 15th, 2022
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. func s_stat* get_tower_stats(
  2.     s_item_tower* item_tower,
  3.     s_sarray<int, c_max_tower_upgrade_tiers>* upgrades,
  4.     s_stat skill_tree_stats[e_stat_count],
  5.     int upgrade_tier,
  6.     s_lin_arena* frame_arena
  7. )
  8. {
  9.     m_timed_function();
  10.  
  11.     s_stat* result = (s_stat*)la_get(frame_arena, sizeof(*result) * e_stat_count, false);
  12.  
  13.     s_stat* stats_from_upgrades = get_stats_from_upgrades(upgrades, frame_arena);
  14.     s_stat* stats_from_type = get_stats_from_tower_type(item_tower->type, frame_arena);
  15.  
  16.     for(int i = 0; i < e_stat_count; i++)
  17.     {
  18.         result[i] = make_stat();
  19.         result[i].base = g_stat_data[i].tower_base;
  20.  
  21.         if(stats_from_upgrades)
  22.         {
  23.             result[i] = result[i] + stats_from_upgrades[i];
  24.         }
  25.  
  26.         s_stat stat_from_affix = get_item_tower_affix_stat(item_tower, (e_stat)i);
  27.         s_stat stat_from_tree = skill_tree_stats[i];
  28.         s_stat stat = stat_from_affix + stat_from_tree + stats_from_type[i];
  29.  
  30.         result[i].base += stat.base;
  31.         assert(floats_equal(result[i].extra_increased, 0));
  32.         result[i].extra_increased += stat.increased;
  33.         result[i].more *= stat.more;
  34.     }
  35.  
  36.     // @Note(tkap, 12/09/2022): We cannot have "increased effect of gems" on a gem. That would be a mindfuck and wouldn't work.
  37.     s_stat stats_from_gems[e_stat_count];
  38.     get_item_tower_gem_stats(item_tower, stats_from_gems, result[e_stat_gem_effect]);
  39.  
  40.     for(int i = 0; i < e_stat_count; i++)
  41.     {
  42.         result[i].base += stats_from_gems[i].base;
  43.         result[i].extra_increased += stats_from_gems[i].increased;
  44.         result[i].more *= stats_from_gems[i].more;
  45.     }
  46.  
  47.     {
  48.         float orbs_per_upgrade = calculate_stat(result[e_stat_orbs_per_upgrade]);
  49.         result[e_stat_orb].base += (int)(orbs_per_upgrade * upgrade_tier);
  50.     }
  51.  
  52.  
  53.     return result;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement