Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Enhancement: i_char.py and character overhaul. Bugfixes, speedups, optimizations, etc. #862

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4e9ac37
init, wip
aliig Jun 13, 2022
5656c2a
through paladins
aliig Jun 13, 2022
0d0d9b7
fix hold click
aliig Jun 13, 2022
d0bef3d
move select_teleport() to char from ui.skills and rename
aliig Jun 13, 2022
aeb437b
cleanup
aliig Jun 13, 2022
69a25eb
rework teleport / move / pather
aliig Jun 13, 2022
f1b7b24
get rid of self._should_pre_move logic
aliig Jun 13, 2022
efccfce
merge master
aliig Jun 13, 2022
967b53b
fix town portal
aliig Jun 13, 2022
f24383d
fix teleport, pathing, auras
aliig Jun 13, 2022
405b1e6
finetuning
aliig Jun 13, 2022
c4dc2f3
pickit stuff
aliig Jun 13, 2022
96801c4
remove vscode insertions
aliig Jun 13, 2022
e29beea
revert delay
aliig Jun 13, 2022
eef0ffb
hammerdin enigma, charged, and walk classes working
aliig Jun 13, 2022
fa2436f
start sorc
aliig Jun 14, 2022
222567a
lightsorc wip
aliig Jun 14, 2022
2d91d82
continue sorc, bug right now with holding still
aliig Jun 14, 2022
29974e9
merge master
aliig Jun 17, 2022
923f479
Merge branch 'master' into char-update
aliig Jun 17, 2022
ad7a4c7
breakpoints wip
aliig Jun 17, 2022
3690cc9
finish fn
aliig Jun 17, 2022
e5724c2
merge master
aliig Jun 18, 2022
4489778
commiting WIP on move()
aliig Jun 18, 2022
0c55339
start implementing quickcast--WIP
aliig Jun 18, 2022
66dfe0d
save
aliig Jun 18, 2022
8f55d4f
Merge branch 'master' into char-update
aliig Jun 18, 2022
590a614
save
aliig Jun 18, 2022
9f24b9b
wip
aliig Jun 19, 2022
ebf9ca5
save
aliig Jun 19, 2022
9ced5b3
wip
aliig Jun 19, 2022
6719b30
wip
aliig Jun 19, 2022
b36a903
cleanup i_char.py
aliig Jun 20, 2022
dec483a
through i_char.py
aliig Jun 20, 2022
9254215
cleanup unused imports
aliig Jun 20, 2022
250ba0b
bring target detect into _cast_at_position function
aliig Jun 20, 2022
cdad145
cleanup
aliig Jun 20, 2022
7f4f2ec
save as
aliig Jun 20, 2022
a326adb
wip, pindle working :p
aliig Jun 21, 2022
596c82d
Merge branch 'master' into char-update
aliig Jun 21, 2022
d3c0b6b
save as
aliig Jun 21, 2022
0de6896
Merge branch 'master' into char-update
aliig Jun 22, 2022
7e392e2
save as
aliig Jun 22, 2022
bda5149
Merge branch 'master' into char-update
aliig Jun 22, 2022
78205c2
wip
aliig Jun 22, 2022
d3622a8
wip
aliig Jun 22, 2022
afbb4f2
wip
aliig Jun 23, 2022
c9c511f
Merge branch 'master' into char-update
aliig Jun 23, 2022
6b2e2e4
wip
aliig Jun 23, 2022
0a10842
wip
aliig Jun 25, 2022
8c44bf1
wip
aliig Jun 27, 2022
c0ed2f7
merge master
aliig Jun 27, 2022
25e964c
Merge branch 'master' into char-update
aliig Jun 27, 2022
aa444fe
wip
aliig Jun 27, 2022
ff54670
fix cleansing
aliig Jun 30, 2022
c9f1405
wip
aliig Jun 30, 2022
b84123e
Merge branch 'char-update' of https://github.com/bottytools/botty int…
aliig Jun 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ order=run_pindle, run_eldritch
| ------------------ | -------------------------------------------------------------------------------------------------|
| type | Build type. Currently only "sorceress" or "hammerdin" is supported |
| belt_rows | Integer value of how many rows the char's belt has |
| casting_frames | Depending on your char and fcr you will have a specific casting frame count. Check it here: https://diablo2.diablowiki.net/Breakpoints and fill in the right number. Determines how much delay there is after each teleport for example. If your system has some delay e.g. on vms, you might have to increase this value above the suggest value in the table! |
| faster_cast_rate | Set to your character's faster cast rate, will calculate skill cooldowns |
| extra_casting_frames | This will cause skills to wait an additional `extra_casting_frames` after calculated cooldown period. Helpful for low-performance. |
| cta_available | 0: no cta available, 1: cta is available and should be used during prebuff |
| safer_routines | Set to 1 to enable optional defensive maneuvers/etc during combat/runs at the cost of increased runtime (ex. hardcore players)
| safer_routines | Set to 1 to enable optional defensive maneuvers/etc during combat/runs at the cost of increased runtime (ex. hardcore players) |
| use_charged_teleport | 0: Character doesn't teleport or is able to teleport without charges. 1: Character depends on teleport charges to teleport. |
| num_loot_columns | Number of columns in inventory used for loot (from left!). Remaining space can be used for charms |
| force_move | Hotkey for "force move" |
| inventory_screen | Hotkey to open inventory |
Expand Down
2 changes: 1 addition & 1 deletion assets/NTItemAlias.dbl
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ NTIPAliasStat["skillpoisonoverridelength"] = 101;
NTIPAliasStat["itemfasterblockrate"] = 102; NTIPAliasStat["fbr"] = 102;
NTIPAliasStat["skillbypassundead"] = 103;
NTIPAliasStat["skillbypassdemons"] = 104;
NTIPAliasStat["itemfastercastrate"] = 105; NTIPAliasStat["fcr"] = 105;
NTIPAliasStat["itemfastercastrate"] = 105; NTIPAliasStat["faster_cast_rate"] = 105;
NTIPAliasStat["skillbypassbeasts"] = 106;

NTIPAliasStat["itemsingleskill"] = 107;
Expand Down
4 changes: 2 additions & 2 deletions assets/d2r_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"Item Name Display": 1,
"Chat Background": 0,
"Always Run": 1,
"Quick Cast Enabled": 0,
"Display Active Skill Bindings": 0,
"Quick Cast Enabled": 1,
"Display Active Skill Bindings": 1,
"Lobby Wide Item Drop Enabled": 1,
"Item Tooltip Hotkey Appender": 1
}
Binary file added assets/templates/inventory/active_weapon_main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_charge_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_holy_shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_tele_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_tele_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_tp_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_tp_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/templates/ui/skills/bar_vigor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion config/game.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ repair_btn=318,473,90,80
left_inventory=35,92,378,378
right_inventory=866,348,379,152
skill_right=664,673,41,41
skill_right_expanded=655,375,385,255
skill_speed_bar=655,375,385,255
skill_left=574,673,41,41
main_menu_top_left=0,0,100,100
gamebar_anchor=600,650,90,90
Expand Down Expand Up @@ -136,6 +136,8 @@ tab_indicator=31,82,385,14
deposit_btn=454,365,186,43
equipped_inventory_area=861,59,387,287
inventory_bg_pattern=21,622,1236,75
active_skills_bar=372,605,538,47
active_weapon_tabs=864,65,93,30

[path]
; static pathes in format: x0,y0, x1,y1, x2,y2, ...
Expand Down
10 changes: 6 additions & 4 deletions config/params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ order=run_pindle, run_eldritch_shenk
; These configs have to be alligned with your d2r settings and char build
type=light_sorc
belt_rows=4
casting_frames=10
faster_cast_rate=105
faster_cast_rate_offhand=105
extra_casting_frames=1
cta_available=0
; safer_routines: enable for optional defensive maneuvers/etc during combat/runs at the cost of increased runtime (ex. hardcore players)
safer_routines=0
; use_charged_teleport: set to 1 if your character depends on teleport charges to teleport
use_charged_teleport=0

; num_loot_columns: Number of empty columns from left to right of inventory to be used for looting.
; Store charms, etc. to the right of the inventory.
Expand Down Expand Up @@ -313,8 +317,6 @@ logg_lvl=debug
message_body_template={{"content": "{msg}"}}
message_headers=
ocr_during_pickit=0
;use "can_teleport_natively" or "can_teleport_with_charges" if you want to force certain behavior in case autodetection isn't working properly
override_capabilities=
pathing_delay_factor=4
pathing_delay_factor=0
;If you want to control Hyper-V window from host use 0,51 here
window_client_area_offset=0,0
12 changes: 8 additions & 4 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@ def on_start_from_town(self):
view.pickup_corpse()
wait_until_hidden(ScreenObjects.Corpse)
belt.fill_up_belt_from_inventory(Config().char["num_loot_columns"])
self._char.discover_capabilities()
if corpse_present and self._char.capabilities.can_teleport_with_charges and not self._char.select_tp():
if self._char.capabilities is None or not self._char.capabilities.can_teleport_natively:
self._char.discover_capabilities()
if corpse_present and self._char.capabilities.can_teleport_with_charges:
keybind = Config().char["teleport"]
Logger.info(f"Teleport keybind is lost upon death. Rebinding teleport to '{keybind}'")
self._char.remap_right_skill_hotkey("TELE_ACTIVE", Config().char["teleport"])
skills.remap_right_skill_hotkey("TELE_ACTIVE", keybind)

# Run /nopickup command to avoid picking up stuff on accident
if Config().char["enable_no_pickup"] and (not self._ran_no_pickup and not self._game_stats._nopickup_active):
Expand Down Expand Up @@ -301,6 +302,9 @@ def on_maintenance(self):
need_inspect |= (self._game_stats._run_counter - 1) % Config().char["runs_per_stash"] == 0
if need_inspect:
img = personal.open()
# Check which weapon is bound (main vs offhand)
if self._char.main_weapon_equipped is None:
self._char.main_weapon_equipped = personal.is_main_weapon_active(img)
# Update TP, ID, key needs
if self._game_stats._game_counter == 1:
self._use_id_tome = common.tome_state(img, 'id')[0] is not None
Expand Down Expand Up @@ -368,7 +372,7 @@ def on_maintenance(self):
# Check if we are out of tps or need repairing
need_repair = is_visible(ScreenObjects.NeedRepair)
need_routine_repair = False if not Config().char["runs_per_repair"] else self._game_stats._run_counter % Config().char["runs_per_repair"] == 0
need_refill_teleport = self._char.capabilities.can_teleport_with_charges and (not self._char.select_tp() or self._char.is_low_on_teleport_charges())
need_refill_teleport = self._char.capabilities.can_teleport_with_charges and (not self._char.select_teleport() or self._char.is_low_on_teleport_charges())
if need_repair or need_routine_repair or need_refill_teleport or sell_items:
if need_repair:
Logger.info("Repair needed. Gear is about to break")
Expand Down
3 changes: 1 addition & 2 deletions src/char/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .i_char import IChar
from .capabilities import CharacterCapabilities
from .i_char import IChar
18 changes: 6 additions & 12 deletions src/char/barbarian.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import keyboard
from ui import skills
from utils.custom_mouse import mouse
from char import IChar, CharacterCapabilities
from char import IChar
from char.tools.capabilities import CharacterCapabilities
import template_finder
from pather import Pather
from logger import Logger
Expand All @@ -17,7 +18,6 @@ def __init__(self, skill_hotkeys: dict, pather: Pather):
Logger.info("Setting up Barbarian")
super().__init__(skill_hotkeys)
self._pather = pather
self._do_pre_move = True
# offset shenk final position further to the right and bottom

def _cast_war_cry(self, time_in_s: float):
Expand Down Expand Up @@ -70,12 +70,10 @@ def pre_buff(self):
wait(self._cast_duration + 0.08, self._cast_duration + 0.1)

def pre_move(self):
# select teleport if available
super().pre_move()
# in case teleport hotkey is not set or teleport can not be used, use leap if set
should_cast_leap = self._skill_hotkeys["leap"] and not skills.is_left_skill_selected(["LEAP"])
can_teleport = self.capabilities.can_teleport_natively and skills.is_right_skill_active()
if should_cast_leap and not can_teleport:
if should_cast_leap and not self.can_teleport():
keyboard.send(self._skill_hotkeys["leap"])
wait(0.15, 0.25)

Expand All @@ -90,11 +88,7 @@ def kill_pindle(self) -> bool:
if self.capabilities.can_teleport_natively:
self._pather.traverse_nodes_fixed("pindle_end", self)
else:
if not self._do_pre_move:
# keyboard.send(self._skill_hotkeys["concentration"])
# wait(0.05, 0.15)
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, timeout=1.0, do_pre_move=self._do_pre_move)
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, timeout=0.1)
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, timeout=1.0)
self._cast_war_cry(Config().char["atk_len_pindle"])
wait(0.1, 0.15)
self._do_hork(4)
Expand All @@ -104,15 +98,15 @@ def kill_eldritch(self) -> bool:
if self.capabilities.can_teleport_natively:
self._pather.traverse_nodes_fixed("eldritch_end", self)
else:
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, timeout=1.0, do_pre_move=self._do_pre_move)
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, timeout=1.0)
wait(0.05, 0.1)
self._cast_war_cry(Config().char["atk_len_eldritch"])
wait(0.1, 0.15)
self._do_hork(4)
return True

def kill_shenk(self):
self._pather.traverse_nodes((Location.A5_SHENK_SAFE_DIST, Location.A5_SHENK_END), self, timeout=1.0, do_pre_move=self._do_pre_move)
self._pather.traverse_nodes((Location.A5_SHENK_SAFE_DIST, Location.A5_SHENK_END), self, timeout=1.0)
wait(0.05, 0.1)
self._cast_war_cry(Config().char["atk_len_shenk"])
wait(0.1, 0.15)
Expand Down
23 changes: 6 additions & 17 deletions src/char/basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import keyboard
from ui import skills
from utils.custom_mouse import mouse
from char import IChar,CharacterCapabilities
from char import IChar
from char.tools.capabilities import CharacterCapabilities
import template_finder
from pather import Pather
from logger import Logger
Expand All @@ -17,7 +18,6 @@ def __init__(self, skill_hotkeys: dict, pather: Pather):
Logger.info("Setting up Basic Character")
super().__init__(skill_hotkeys)
self._pather = pather
self._do_pre_move = True

def on_capabilities_discovered(self, capabilities: CharacterCapabilities):
# offset shenk final position further to the right and bottom
Expand All @@ -43,8 +43,7 @@ def _cast_attack_pattern(self, time_in_s: float):
keyboard.send(Config().char["stand_still"], do_press=False)

def pre_buff(self):
if Config().char["cta_available"]:
self._pre_buff_cta()
self._pre_buff_cta()
if self._skill_hotkeys["buff_1"]:
keyboard.send(self._skill_hotkeys["buff_1"])
wait(0.5, 0.15)
Expand Down Expand Up @@ -74,11 +73,7 @@ def kill_pindle(self) -> bool:
if self.capabilities.can_teleport_natively:
self._pather.traverse_nodes_fixed("pindle_end", self)
else:
if not self._do_pre_move:
# keyboard.send(self._skill_hotkeys["concentration"])
# wait(0.05, 0.15)
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, timeout=1.0, do_pre_move=self._do_pre_move)
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, timeout=0.1)
self._pather.traverse_nodes((Location.A5_PINDLE_SAFE_DIST, Location.A5_PINDLE_END), self, timeout=1.0)
self._cast_attack_pattern(Config().char["atk_len_pindle"])
wait(0.1, 0.15)
return True
Expand All @@ -87,19 +82,13 @@ def kill_eldritch(self) -> bool:
if self.capabilities.can_teleport_natively:
self._pather.traverse_nodes_fixed("eldritch_end", self)
else:
if not self._do_pre_move:
# keyboard.send(self._skill_hotkeys["concentration"])
# wait(0.05, 0.15)
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, timeout=1.0, do_pre_move=self._do_pre_move)
self._pather.traverse_nodes((Location.A5_ELDRITCH_SAFE_DIST, Location.A5_ELDRITCH_END), self, timeout=1.0)
wait(0.05, 0.1)
self._cast_attack_pattern(Config().char["atk_len_eldritch"])
return True

def kill_shenk(self):
# if not self._do_pre_move:
# keyboard.send(self._skill_hotkeys["concentration"])
# wait(0.05, 0.15)
self._pather.traverse_nodes((Location.A5_SHENK_SAFE_DIST, Location.A5_SHENK_END), self, timeout=1.0, do_pre_move=self._do_pre_move)
self._pather.traverse_nodes((Location.A5_SHENK_SAFE_DIST, Location.A5_SHENK_END), self, timeout=1.0)
wait(0.05, 0.1)
self._cast_attack_pattern(Config().char["atk_len_shenk"])
wait(0.1, 0.15)
Expand Down
6 changes: 2 additions & 4 deletions src/char/basic_ranged.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ def __init__(self, skill_hotkeys: dict, pather: Pather):
Logger.info("Setting up Basic Ranged Character")
super().__init__(skill_hotkeys)
self._pather = pather
self._do_pre_move = True

def _left_attack(self, cast_pos_abs: tuple[float, float], delay: tuple[float, float] = (0.2, 0.3), spray: int = 10):
def _left_attack(self, cast_pos_abs: tuple[float, float], delay: tuple[float, float] = (0.2, 0.3), spray: float = 10):
if self._skill_hotkeys["left_attack"]:
keyboard.send(self._skill_hotkeys["left_attack"])
for _ in range(4):
Expand All @@ -43,8 +42,7 @@ def _right_attack(self, cast_pos_abs: tuple[float, float], delay: tuple[float, f
mouse.click(button="right")

def pre_buff(self):
if Config().char["cta_available"]:
self._pre_buff_cta()
self._pre_buff_cta()
if self._skill_hotkeys["buff_1"]:
keyboard.send(self._skill_hotkeys["buff_1"])
wait(0.5, 0.15)
Expand Down
Loading