DOTA TWO BAYBEE

a93dee0 · gmorell · 2023-02-06 05:28

5 files +96 -7

Files changed

modified lib/lambent_ex/machine/ext/gsi.ex
+96 −7
@@ -108,6 +108,10 @@ defmodule LambentEx.Machine.Ext.GSI do
108 108 []
109 109 end
110 110
111 + def generate_flash(state, color, ticks, value) do
112 + []
113 + end
114 +
111 115 defp read(:csgo_team, state), do: state[:gs] |> get_in(["player", "team"])
112 116 defp read(:csgo_health, state), do: state[:gs] |> get_in(["player", "state", "health"]) || 0
113 117 defp read(:csgo_armor, state), do: state[:gs] |> get_in(["player", "state", "armor"]) || 0
@@ -200,14 +204,102 @@ defmodule LambentEx.Machine.Ext.GSI do
200 204 }
201 205 end
202 206
207 + # game state
208 + defp read(:dota_map_day, state), do: state[:gs] |> get_in(["map", "daytime"]) || false
209 + defp read(:dota_clock_time, state), do: state[:gs] |> get_in(["map", "clock_time"]) || 0
210 + defp read(:dota_game_time, state), do: state[:gs] |> get_in(["map", "game_time"]) || 0
211 + defp read(:dota_score_r, state), do: state[:gs] |> get_in(["map", "radiant_score"]) || 0
212 + defp read(:dota_score_d, state), do: state[:gs] |> get_in(["map", "dire_score"]) || 0
213 + defp read(:dota_paused, state), do: state[:gs] |> get_in(["map", "paused"]) || false
214 + defp read(:dota_team, state), do: state[:gs] |> get_in(["player", "team_name"])
215 + defp read(:dota_ward_purchase_cooldown, state), do: state[:gs] |> get_in(["map", "ward_purchase_cooldown"])
216 + # scoring
217 + defp read(:dota_player_kills, state), do: state[:gs] |> get_in(["player", "kills"]) || 0
218 + defp read(:dota_player_deaths, state), do: state[:gs] |> get_in(["player", "deaths"]) || 0
219 + defp read(:dota_player_assists, state), do: state[:gs] |> get_in(["player", "assists"]) || 0
220 + defp read(:dota_player_denies, state), do: state[:gs] |> get_in(["player", "denies"]) || 0
221 + defp read(:dota_player_last_hits, state), do: state[:gs] |> get_in(["player", "last_hits"]) || 0
222 + defp read(:dota_player_kill_streak, state), do: state[:gs] |> get_in(["player", "kill_streak"]) || 0
223 + # gold
224 + defp read(:dota_player_xpm, state), do: state[:gs] |> get_in(["player", "xpm"]) || 0
225 + defp read(:dota_player_gpm, state), do: state[:gs] |> get_in(["player", "gpm"]) || 0
226 + defp read(:dota_player_gold, state), do: state[:gs] |> get_in(["player", "gold"]) || 0
227 + defp read(:dota_player_gold_unreliable, state), do: state[:gs] |> get_in(["player", "gold_unreliable"]) || 0
228 + defp read(:dota_player_gold_reliable, state), do: state[:gs] |> get_in(["player", "gold_reliable"]) || 0
229 + defp read(:dota_player_gold_from_creep_kills, state), do: state[:gs] |> get_in(["player", "gold_from_creep_kills"]) || 0
230 + defp read(:dota_player_gold_from_hero_kills, state), do: state[:gs] |> get_in(["player", "gold_from_hero_kills"]) || 0
231 + defp read(:dota_player_gold_from_income, state), do: state[:gs] |> get_in(["player", "gold_from_income"]) || 0
232 + defp read(:dota_player_gold_from_shared, state), do: state[:gs] |> get_in(["player", "gold_from_shared"]) || 0
233 + # numbers
234 + defp read(:dota_mana, state), do: state[:gs] |> get_in(["hero", "mana"]) || 0
235 + defp read(:dota_mana_max, state), do: state[:gs] |> get_in(["hero", "max_mana"]) || 0
236 + defp read(:dota_mana_pct, state), do: state[:gs] |> get_in(["hero", "mana_percent"]) || 0
237 + defp read(:dota_health, state), do: state[:gs] |> get_in(["hero", "health"]) || 0
238 + defp read(:dota_health_max, state), do: state[:gs] |> get_in(["hero", "max_health"]) || 0
239 + defp read(:dota_health_pct, state), do: state[:gs] |> get_in(["hero", "health_percent"]) || 0
240 + # statuses
241 + defp read(:dota_hero_smoked, state), do: state[:gs] |> get_in(["hero", "smoked"]) ||false
242 + defp read(:dota_hero_alive, state), do: state[:gs] |> get_in(["hero", "alive"]) || false
243 + defp read(:dota_hero_muted, state), do: state[:gs] |> get_in(["hero", "muted"]) || false
244 + defp read(:dota_hero_break, state), do: state[:gs] |> get_in(["hero", "break"]) || false
245 + defp read(:dota_hero_hexed, state), do: state[:gs] |> get_in(["hero", "hexed"]) || false
246 + defp read(:dota_hero_silenced, state), do: state[:gs] |> get_in(["hero", "silenced"]) || false
247 + defp read(:dota_hero_has_debuff, state), do: state[:gs] |> get_in(["hero", "has_debuff"]) || false
248 + defp read(:dota_hero_disarmed, state), do: state[:gs] |> get_in(["hero", "disarmed"]) || false
249 + defp read(:dota_hero_stunned, state), do: state[:gs] |> get_in(["hero", "stunned"]) || false
250 + defp read(:dota_hero_magicimmune, state), do: state[:gs] |> get_in(["hero", "magicimmune"]) || false
251 + # hero
252 + defp read(:dota_hero_xpos, state), do: state[:gs] |> get_in(["map", "xpos"]) || 0
253 + defp read(:dota_hero_ypos, state), do: state[:gs] |> get_in(["map", "ypos"]) || 0
254 + defp read(:dota_hero_level, state), do: state[:gs] |> get_in(["hero", "level"]) || 0
255 + defp read(:dota_hero_xp, state), do: state[:gs] |> get_in(["hero", "xp"]) || 0
256 + defp read(:dota_hero_attributes_level, state), do: state[:gs] |> get_in(["hero", "attributes_level"]) || 0
257 + defp read(:dota_hero_respawn_seconds, state), do: state[:gs] |> get_in(["hero", "respawn_seconds"]) || 0
258 + defp read(:dota_hero_buyback_money, state), do: state[:gs] |> get_in(["hero", "buyback_cost"]) || 0
259 + defp read(:dota_hero_buyback_seconds, state), do: state[:gs] |> get_in(["hero", "buyback_cooldown"]) || 0
260 + # talents
261 + defp read(:dota_hero_aghs_scepter, state), do: state[:gs] |> get_in(["hero", "aghanims_scepter"]) || false
262 + defp read(:dota_hero_aghs_shard, state), do: state[:gs] |> get_in(["hero", "aghanims_shard"]) || false
263 + defp read(:dota_hero_talent_1, state), do: state[:gs] |> get_in(["hero", "talent_1"]) || false
264 + defp read(:dota_hero_talent_2, state), do: state[:gs] |> get_in(["hero", "talent_2"]) || false
265 + defp read(:dota_hero_talent_3, state), do: state[:gs] |> get_in(["hero", "talent_3"]) || false
266 + defp read(:dota_hero_talent_4, state), do: state[:gs] |> get_in(["hero", "talent_4"]) || false
267 + defp read(:dota_hero_talent_5, state), do: state[:gs] |> get_in(["hero", "talent_5"]) || false
268 + defp read(:dota_hero_talent_6, state), do: state[:gs] |> get_in(["hero", "talent_6"]) || false
269 + defp read(:dota_hero_talent_7, state), do: state[:gs] |> get_in(["hero", "talent_7"]) || false
270 + defp read(:dota_hero_talent_8, state), do: state[:gs] |> get_in(["hero", "talent_8"]) || false
271 + # abilities
272 + defp read(:dota_hero_ability_1, state), do: state[:gs] |> get_in(["hero", "ability_1"]) || false
273 + defp read(:dota_hero_ability_2, state), do: state[:gs] |> get_in(["hero", "ability_2"]) || false
274 + defp read(:dota_hero_ability_3, state), do: state[:gs] |> get_in(["hero", "ability_3"]) || false
275 + defp read(:dota_hero_ability_4, state), do: state[:gs] |> get_in(["hero", "ability_4"]) || false
276 + defp read(:dota_hero_ability_5, state), do: state[:gs] |> get_in(["hero", "ability_5"]) || false
277 + defp read(:dota_hero_ability_6, state), do: state[:gs] |> get_in(["hero", "ability_6"]) || false
278 + defp read(:dota_hero_ability_7, state), do: state[:gs] |> get_in(["hero", "ability_7"]) || false
279 + defp read(:dota_hero_ability_8, state), do: state[:gs] |> get_in(["hero", "ability_8"]) || false
280 + ## these are passed in the result of above eg; read(:dota_hero_ability_active, read(:dota_hero_ability_1, state))
281 + defp read(:dota_hero_ability_active, state), do: state |> Map.get("ability_active") || false
282 + defp read(:dota_hero_ability_can_cast, state), do: state |> Map.get("can_cast") || false
283 + defp read(:dota_hero_ability_charge_cooldown, state), do: state |> Map.get("charge_cooldown") || 0
284 + defp read(:dota_hero_ability_charges, state), do: state |> Map.get("charges") || 0
285 + defp read(:dota_hero_ability_cooldown, state), do: state |> Map.get("cooldown") || 0
286 + defp read(:dota_hero_ability_level, state), do: state |> Map.get("level") || 0
287 + defp read(:dota_hero_ability_max_charges, state), do: state |> Map.get("max_charges") || 0
288 + defp read(:dota_hero_ability_name, state), do: state |> Map.get("name")
289 + defp read(:dota_hero_ability_passive, state), do: state |> Map.get("passive") || false
290 + defp read(:dota_hero_ability_ultimage, state), do: state |> Map.get("ultimate") || false
291 + # building statuses # todo
292 + # items # todo
293 + # wearables # todo
294 +
203 295 defp read(:dota, state) do
204 296 %{
205 − health_fill: [],
297 + health_fill: generate_fill(state, {@green, @whitish}, read(:dota_health, state), read(:dota_health_max, state)),
206 298 health_bright: [],
207 − mana_fill: [],
299 + mana_fill: generate_fill(state, {@blue, @whitish}, read(:dota_mana, state), read(:dota_mana_max, state)),
208 300 mana_bright: [],
209 − money_fill: [],
210 − money_bright: []
301 + money_reliable_fill: generate_fill(state, {@yellow, @whitish}, read(:dota_player_gold_reliable, state), read(:dota_player_gold, state)),
302 + money_reiiable_bright: []
211 303 }
212 304 end
213 305
@@ -234,10 +326,7 @@ defmodule LambentEx.Machine.Ext.GSI do
234 326 end
235 327
236 328 def handle_info({name, path, data}, state) do
237 − IO.inspect({name, state[:name]})
238 −
239 329 if name == state[:name] do
240 − # IO.inspect(data)
241 330 flashes = delta(data, state)
242 331 {:noreply, state |> Map.put(:path, path) |> Map.put(:gs, data)}
243 332 else

Parents: 8bd7ebf