Skip to content

Instantly share code, notes, and snippets.

@bensonchow123
Created January 29, 2025 16:30
Show Gist options
  • Save bensonchow123/45240871ec17f3f35916cd4a1df9e7b5 to your computer and use it in GitHub Desktop.
Save bensonchow123/45240871ec17f3f35916cd4a1df9e7b5 to your computer and use it in GitHub Desktop.
Help me with this
@app_commands.command(name="calculate_portable_campfire", description="When to place campfire before you die.")
async def calculate_portable_campfire(self, interaction: Interaction, cold_res: float, num_campfires_to_use: int):
base_per_cold_tick_rate = 100 # Base ticks per Cold increase (without resistance)
campfire_cooldown_ticks = 6000 # 5 minutes = 6000 ticks
cold_threshold = 100 # Death at 100 Cold
campfire_cold_reduction = 50 # Each campfire reduces Cold by 50`
per_cold_tick_rate_with_resistance = base_per_cold_tick_rate + cold_res
per_cold_tick_rate_in_tunnels = per_cold_tick_rate_with_resistance * 0.8
campfire_reduce_cold_ticks = campfire_cold_reduction * per_cold_tick_rate_in_tunnels # ticks the campfires reduce cold by
result_embed = Embed(
title="Campfire Placement",
description=f"""
**Cold Resistance:** {cold_res}
**Number of Campfires:** {num_campfires_to_use}
**Seconds per cold: **{per_cold_tick_rate_in_tunnels /20} sec, calculated by `((100 + cold res) * 0.8) / 20`
**Per cold tick rate with resistance:** {per_cold_tick_rate_with_resistance}, calculated by `100 + cold res`
**Per cold tick rate in tunnels:** {per_cold_tick_rate_in_tunnels}, calculated by `per_cold_tick_rate_with_resistance * 0.8`
**Campfire cooldown:** 5 minutes = 6000 ticks
**Campfire cold reduction:** 50
"""
)
result_list = []
if num_campfires_to_use == 1:
result_list.append(f"Always use at 99 cold, as you only use 1 campfire")
elif campfire_reduce_cold_ticks >= campfire_cooldown_ticks:
result_list.append(f"Always use at 99 cold, as you gain cold slower or equal to the cooldown of the campfire")
else:
cold_increase_ticks_per_campfire_before_cooldown_expires = campfire_cooldown_ticks - campfire_reduce_cold_ticks
result_embed.description += f"\n**Cold increase ticks per campfire before cooldown expires:** {cold_increase_ticks_per_campfire_before_cooldown_expires}, calculated by `6000 - (50 * per_cold_tick_rate_in_tunnels)`"
cold_increase_per_campfire_before_cooldown_exipres = cold_increase_ticks_per_campfire_before_cooldown_expires / per_cold_tick_rate_in_tunnels
result_embed.description += f"\n**Cold increase per campfire before cooldown expires:** {cold_increase_per_campfire_before_cooldown_exipres}, calculated by `cold_increase_ticks_per_campfire_before_cooldown_expires / per_cold_tick_rate_in_tunnels`"
cold_increase_total_from_campfires = cold_increase_per_campfire_before_cooldown_exipres * num_campfires_to_use
result_embed.description += f"\n**Total cold increase from campfires:** {cold_increase_total_from_campfires}, calculated by `cold_increase_per_campfire_before_cooldown_exipres * num_campfires_to_use`"
if cold_increase_total_from_campfires >= cold_threshold:
result_list.append(f"It is impossible for you to use this much campfires before you die")
else:
result_list = []
campfire_count_copy = num_campfires_to_use
for i in range(1, num_campfires_to_use + 1):
results = f"campfire {i}: use at {floor(cold_threshold - (campfire_count_copy * cold_increase_per_campfire_before_cooldown_exipres))} cold"
campfire_count_copy -= 1
result_list.append(results)
result_embed.add_field(name="Campfire placements", value="\n".join(result_list))
await interaction.response.send_message(embed=result_embed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment