Skip to content
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

Removed many magic numbers and using Enums instead. #228

Open
wants to merge 326 commits into
base: master
Choose a base branch
from

Conversation

cr3nox
Copy link

@cr3nox cr3nox commented Jul 10, 2017

Sorry, i accidentally closed pull Request #226. Created a new one here.
So i reworked all changed Lines.
@noah- you were right, Visual Studio somehow fucked up the Lines, so i changed them all in Notepad++.

From @noah- :

Hi, thank you for your contribution. A few things that need changing

  • I don't see the file "Enums.js" in the commit
  • the include("common/Enums.js"); should be located in the default.dbj file, not in each individual file (tools files will need it included as they are not run from the default.dbj, in which case the check to see if it is already included is not necessary)
  • it appears your local file editor does not match the same spacing as the existing files, please check to see if tabs/spaces are appropriated correctly (I looked at it again, it seems like you are using spaces instead of tabs), consider running through JSLINT on notepad++ or any other text editor.

Some Files look weird in the comparison, dunno, just took the original Files from kolton/master and changed the magic numbers:

  • bots/Duriel.js
  • bots/Questing.js
  • bots/Sharptooth.js
  • bots/Stormtree.js
  • bots/Treshsocket.js
  • bots/Travincal.js

Original Description:
Removed many magic numbers and using libs/common/enums.js instead.

Modified all Files in:

  • libs/
  • libs/bots
  • libs/common
  • libs/config
  • tools/

greetings crenox-

kolton and others added 30 commits August 10, 2012 10:07
…ed click cancel on waiting in line timeout

D2BotMule.dbj - added handling for the rest of out of game locations
MuleLogger.js - error handling + wait for me.gameReady
NTItemParser.dbl - added/fixed some item colors
OOG.js - don't call getArea().name directly
BaalHelper.js - move to the center of throne before scanning for baal's portal (antihostile can break the run without this)
Questing.js - added some ptints and town chores
Summoner.js - added offset to preset unit move
Attack.js - fixed attack for vultures, attack.kill throws error if it fails to kill the boss
Barbarian.js - fixed find item switch
Paladin.js - use the faster dodge function on dolls (instead of getIntoPosition)
Sorceress.js - static fix
Misc.js - town check now sends messages with TownChicken.js
Pather.js - fixed exit taking for some areas (harem/cellar etc), added journeyTo stuff, grab wp if the character doesn't have it
AntiHostile.js - some more tweaks, added assassin entrance camping
ToolsThread.js - global quit fixes, don't call getArea().name directly
TownChicken.js - added potion check

added WPGetter.js for testing purposes (add Scripts.WPGetter)
fixed remove key error from key wizard
fixed a potential bug that caused continuous restart
fixed legacy profile detector
D2BotLead.dbj - added the ability to join different channels for different profiles without having to make copies of the same file.
D2BotMule.dbj - added ignore list, mule won't pick up junk and will throw away scrolls
AutoBaal.js/BaalHelper.js - misc tweaks and temporary edits
Diablo.js - added stray monster handling, the bot will check previously cleared positions for monsters
Cubing.js - fixed magic (and probably rare) item rolling
Misc.js - added Misc.spy(name) function to log other players' gear to d2bot#
Town.js - added a check for Town.identify() to avoid unneeded NPC interactions
AntiHostile.js - more experimental code
RushThread.js - updated diablo sequence with new fastdiablo code

Fixed gloves crafting lines in char configs (thanks Futon)
Added gems and token cubing to char configs
Comparing pickit with item wasn't working.
Update d2bs/kolbot/libs/bots/ShopBot.js
…to resize then yourself if you want lower quality
D2BotMule.dbj - added torch muling, don't login until a signal is given from the caller profile, drop scrolls, ignore scrolls and other trash items
default.dbj - added TorchSystem, consolidated events
AutoMule.js - added torch muling
NTItemParser.dbl - fix for maxquantity regarding items in stash and owned items, fixed buying a sold item back from NPC because of this
OOG.js - added login account timeout
ShopBot.js - fixed pickit check
Attack.js - added invalidated unit check to checkMonster
Assassin.js - linked trap range to a variable that can be changed from other scripts (namely antihostile)
Paladin.js - melee skill and hammer tweaks
Sorceress.js - added energy shield recast, added valid monster check to static
Config.js - added the option to use Profile.js format for character config (for when class doesn't matter like whith leeching)
Misc.js - added item quality color for item viewer reports
Pather.js - removed arcane sanctuary as previous area to canyon because it's not possible to pather there without the portal (which would make having to path to arcane obsolete)
Prototypes.js - me.findItems returns an empty array on no items now, added getColor prototype
Town.js - tweaked screen canceling and delays to address a certain crash bug
AntiHostile.js - event consolidation, attack tweaks
ToolsThread.js - event consolidation. main events are now here, all the other files have script event that relays info from ToolsThread. added config caching to prevent a certain (and odd) bug of losing reference to Config object
TownChicken.js - added init lines for pickit/runewords/cubing which fixes valid runeword rerolling or potentially valid unid item selling
Pindleskin.js - call kill instead of clear for Nihlathak

Added files
OrgTorch.js
TorchSystem.js
keyorg.nip
multiple followers will no longer prevent leader from muling
temporarily reverted d2bot#
updated d2bs core
added improved auto mule and torch system to D2BotFollow.dbj and D2BotChannel.dbj
OOG.js - fixed case 21, added case 23 handling from the new d2bs core (connecting msg on char select screen)
Diablo.js/DiabloHelper.js - increased Diablo wait time
Mephisto.js - don't stop the whole script on immune council members
added script error reporting to logs/ScriptErrorLog.txt
Misc.js - added error reporting, txt file and experimental packet buy func (packet buy not in use yet)
Pather.js - ignore canyon -> arcane travel, added arcane back to prevArea array
Prototypes.js - item color tweaks, item.buy() tweaks
Town.js - delay tweaks

added wpgetter script to character configs
Open the Mephisto chest.
Check for organs before first organ run in OrgTorch.
Don't fail out if Pindleskin is missing (so you can still run Nihlathak.
kolton and others added 22 commits December 3, 2014 19:43
updated d2bot# - http://www.blizzhackers.cc/viewtopic.php?f=204&t=498707
updated d2bs - http://www.blizzhackers.cc/viewtopic.php?f=204&t=495817&start=330

fixed muling triggers in D2BotChannel.dbj, D2BotFollow.dbj
OOG.js - added D2Bot.uploadItem (same functionality as right click/upload to imgur in item viewer), updated d2bot.stop
Diablo.js - added preattack from a distance for seal bosses with hammerdins, added stray monster handling
Attacks/Barbarian.js - added repair check after attacking
Attacks/Paladin.js - use secondary skill if hammer position is blocked
Misc.js - improved Packet.telewalk
Precast.js - higher enchant slot by dzik
Town.js - fixed potion handling from inventory, added certain quest items to no-drop list
RushThread.js - send rushee back to town if sequence fails
tools/RushThread.js - added numpad 6 hotkey for Mule Logger
added the missing bot script Crafting.js, it was meant to be there when CraftingSystem was added.
removed D2BotChannelMaster.dbj, it's old, incomplete and its author has been gona for a long time
D2BotChannel.dbj - fixed error reporting, don't try to rejoin games with too high level restriction
D2BotMule.dbj - warning+stop profile if rd blocker is on, release cd-key when finished
D2BotMuleLog.dbj - fixed error reporting, warning+stop profile if rd blocker is on
default.dbj - added automap handling based on Config.AutoMap
MuleLogger.js - added item sorting based on item type, character viewer lists should be more organized now
OOG.js - reduced timeoutDelay spam to d2bot#, made setText change text only if it's different from current text
TorchSystem.js - added LogOrgans by Gagget
MFHelper.js - improved portal handling and retries
OrgTorch.js - status prints to d2bot# by Gagget
Rushee.js - added harem tp handling
Barbarian.js - fixed low mana skill warning
Necromancer.js - corpse explosion improvement by Kam1kaz3
Sorceress.js - don't try to telestomp inaccessible monsters (ie. storm casters on lava etc.)
Config.js - added default values for new config options: AutoMap, DroppedItemsAnnounce (by Kam1kaz3), UnpartyShitlisted, QuitListMode and Charge
Misc.js - added Misc.getNearbyPlayerCount() func that can be used to count players in the same area within getUnit range, added stack info to script error reporting, improved Packet.teleWalk
Pather.js - made Charge configurable, rewrote makePortal, usePortal won't try to take portals if the character is already in target area
Pickit.js - organ log handler by Gagget
Prototypes.js - fixed unit.attacking, added stat parsing from description for equipped items in getStatEx
Town.js - announce items dropped by FieldID by Kam1kaz3, gambling can take item names now, Town.move will go to town automatically if not already in town
AntiHostile.js - actively scan for hostiles instead of triggering from event
Party.js - added the ability to unparty if partied with a shitlisted character
RushThread.js - added harem tp, wait for players to enter act 4 after killing Mephisto, delay before telling rushees to leave in order to prevent quest fails.
ToolsThread.js - added the ability to quit based on profile names (this reads character names from data folder), fixed a potential error in checkVipers function

updated character configs with new options and updated recipes with item names for easier readability
D2Bot# - gracefully close d2 window

Enchant.js - abort cows function if Akara is too far from her normal spot or if she's been led out of town
Rusher.js - fixed pause/resume commands
Prototypes.js - don't throw errors in unit.dead
Town.js - ignore NPCs that have been led out of town
- D2Bot.exe new version
- D2BS.dll version 1864
- D2M.dll, libnspr4.dll, js32.dll not used anymore
- Changed structure/names of key/profile/schedules
- Changed log file directories
D2Bot - added auto updater (click About), it updates from github
            - your profile start info should be -w -ns -sleepy for optimal CPU usage
            - made 1.14d the default option, added -sleeply to all new profiles
            - fixed a profile copy bug that would add two dashes
D2BS - changed GameDraw hook to unused function
D2Bot - added auto updater (click About), it updates from github
            - your profile start info should be -w -ns -sleepy for optimal CPU usage
            - made 1.14d the default option, added -sleeply to all new profiles
            - fixed a profile copy bug that would add two dashes
D2BS - changed GameDraw hook to unused function
- auto update should now work without restarting d2bot by clicking about
Fixed another Auto Update bug
Fixed an exception handling crash
Fixed cdkey deadlock issue
reworked all changed lines
@noah-
Copy link
Collaborator

noah- commented Jul 10, 2017

Thanks for uploading the Enums.js file. Here are my comments for the naming conventions:

All top level items should start with Capital letters so for example:
Skills.Common._________ instead of Skills.common

I would also consider not having a common attribute and listing them as is similar to "None", so like
Skills.LEFT_HAND_THROW

Also, last level items (ie ITEM: value) should always be capitalized for enums, so for example, it should be
Skills.NONE

All the other skills should be like:
LEFT_HAND_THROW or Amazon.MAGIC_ARROW

These should be things you can modify using regex, do not do them individually (will take long time!)
In this file, i see mostly ".": or .: as the patterns needed to be matched.

Copy link
Collaborator

@noah- noah- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments in the "Conversation" tab.

@mf022
Copy link
Contributor

mf022 commented Aug 22, 2018

Help is still needed? How it can be done?

@Kongolan
Copy link

Kongolan commented Sep 8, 2018

Is support this Idea a lot, it makes not only coding easier, but the code more readable. We literally need this, i hope you can finish it in a proper way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.