-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start.json #13
base: main
Are you sure you want to change the base?
start.json #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import discord | ||
from discord import Member | ||
|
||
import random | ||
import json | ||
import asyncio | ||
import math | ||
import re | ||
import os | ||
|
||
|
||
ARRIVING_STATE = "arriving" | ||
WIN_STATE = "dying" | ||
LOSE_STATE = "attacking" | ||
def new_func(): | ||
LOSE_STATE = "attacking" | ||
return LOSE_STATE | ||
|
||
LOSE_STATE = new_func() | ||
BOMB_DMG_TYPE = "bomb" | ||
|
||
|
||
class Enemy(): | ||
def __init__(self, path: str, min_enrage_mult: float, max_enrage_mult: float, enraged: bool=False): | ||
self.path = path | ||
|
@@ -50,36 +50,24 @@ def __init__(self, path: str, min_enrage_mult: float, max_enrage_mult: float, en | |
self.max_enrage_mult = max_enrage_mult | ||
self.enraged = enraged | ||
|
||
# maybe reduce the number of these so it makes more sense which is stronger | ||
self._title_prefixes = [ | ||
"Angry", | ||
"Enraged", | ||
"Formidable", | ||
"Rampaging", | ||
"Ferocious", | ||
"Epic", | ||
"Mythic", | ||
"Ancient", | ||
"Colossal", | ||
"Unstoppable", | ||
"Apocalyptic", | ||
"Eternal", | ||
"Divine" | ||
"Angry", "Enraged", "Formidable", "Rampaging", "Ferocious", | ||
"Epic", "Mythic", "Ancient", "Colossal", "Unstoppable", | ||
"Apocalyptic", "Eternal", "Divine" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep these each on a single line like they were before. makes them easier to read and maintain |
||
] | ||
if stats.get('enrage_titles_override'): | ||
self._title_prefixes = stats['enrage_titles_override'] | ||
|
||
self.enraged_amt = min_enrage_mult | ||
|
||
if enraged: | ||
# am I doing my math right here? | ||
min_enrage_mult-=1 | ||
max_enrage_mult-=1 | ||
enraged_amt = min_enrage_mult + random.random() * (max_enrage_mult-min_enrage_mult) | ||
min_enrage_mult -= 1 | ||
max_enrage_mult -= 1 | ||
enraged_amt = min_enrage_mult + random.random() * (max_enrage_mult - min_enrage_mult) | ||
|
||
self.health *= enraged_amt + 1 | ||
self.max_health = self.health | ||
self.reward_mult *= enraged_amt * .75 + 1 | ||
self.reward_mult *= enraged_amt * 0.75 + 1 | ||
self.enraged_amt = enraged_amt + 1 | ||
|
||
self.name = f"{self.title_prefix} {self.name}" | ||
|
@@ -158,7 +146,6 @@ def title_prefix(self): | |
px = len(self._title_prefixes) - 1 | ||
|
||
return self._title_prefixes[ | ||
# map value from between mn and mx (exclusive) to between pn and px (inclusive) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please put this comment back |
||
math.floor((self.enraged_amt - mn) / (mx - mn) * (px - pn)) + pn | ||
] | ||
|
||
|
@@ -168,7 +155,7 @@ def countdown(self): | |
try: | ||
return max(5, cd) | ||
except: | ||
return max(5, random.random()*(cd[1]-cd[0]) + cd[0]) | ||
return max(5, random.random() * (cd[1] - cd[0]) + cd[0]) | ||
|
||
def format_msg(self, msg, **kwargs): | ||
if msg: | ||
|
@@ -182,60 +169,70 @@ def hurt(self, player: Member, dmg_type: str, damage: int): | |
return | ||
is_bomb = dmg_type == BOMB_DMG_TYPE | ||
pid = player.id | ||
# dmg as an arg for purchasable bombs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please put these comments back |
||
if (not is_bomb) and dmg_type not in self.hurt_by: | ||
# miss penalty | ||
self.hurt_mult[pid] = self.hurt_mult.get(pid, 1) * .9 | ||
self.hurt_mult[pid] = self.hurt_mult.get(pid, 1) * 0.9 | ||
return 0 | ||
hurt_mult = 1 if is_bomb else self.hurt_mult.get(pid, 1) | ||
dmg = damage * hurt_mult * max(1 - (self.armor+self.added_armor), 0) | ||
dmg = damage * hurt_mult * max(1 - (self.armor + self.added_armor), 0) | ||
self.health -= dmg | ||
if self.health <= 0: | ||
self.health = 0 | ||
self.attacked_by[player.id] = self.attacked_by.get(player.id, 0) + min(self.health, dmg) | ||
if not is_bomb: | ||
# make future hits weaker | ||
self.hurt_mult[pid] = self.hurt_mult.get(pid, 1) * .75 | ||
self.hurt_mult[pid] = self.hurt_mult.get(pid, 1) * 0.75 | ||
else: | ||
self.bombed_by[player.id] = self.bombed_by.get(player.id, 0) + 1 | ||
return dmg | ||
|
||
def attack(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please put this function back |
||
self.state = LOSE_STATE | ||
return self.penalty_mult | ||
|
||
def tick(self): | ||
if self.health <= 0: | ||
self.health = 0 | ||
self.state = WIN_STATE | ||
return | ||
|
||
# Health-based state transitions | ||
health_percentage = self.health_percentage | ||
|
||
if health_percentage > 0.75: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the phases should be based on the configuration done in the |
||
self.state = "standing" # Dragon stands tall | ||
elif health_percentage > 0.25: | ||
self.state = "flying" # Dragon flies above attacks | ||
else: | ||
self.state = "attacking" # Dragon breathes fire on the server | ||
|
||
# Handle the arrival state transition | ||
if self.state == ARRIVING_STATE: | ||
self.state = self.default_state | ||
else: | ||
choices = {s: self.states[s].get('weight', 1) for s in | ||
self.state_dict.get('next_state', self._active_states) | ||
} | ||
self.state_dict.get('next_state', self._active_states)} | ||
self.state = random.choices( | ||
[*choices], | ||
weights=[*choices.values()] | ||
)[0] | ||
|
||
self.hurt_mult = {} | ||
|
||
async def update(self): | ||
self.bombed_by = {} | ||
|
||
await asyncio.sleep(self.countdown) | ||
self.linger -= self.countdown/60 | ||
self.linger -= self.countdown / 60 | ||
|
||
if self.linger <= 0: | ||
self.linger = 0 | ||
if self.health <= 0: | ||
self.state = WIN_STATE | ||
else: | ||
self.state = LOSE_STATE | ||
return | ||
self.tick() | ||
|
||
|
||
# Add logic for handling Dragon's behaviors based on current state | ||
if self.state == "attacking": | ||
# Dragon deals damage when in attacking state | ||
damage = self.attacking | ||
# You might want to specify how much damage the Dragon does here | ||
# For example, deal damage to players that are currently engaged | ||
# Implement damage dealing logic here if necessary | ||
|
||
|
||
self.tick() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function isn't needed, please remove this ❤️