Jump to content
latios

Tool: dp2rathena - convert divine-pride data to rathena format

Recommended Posts

Hi all, I put together a command-line tool to help save time when porting lots of existing items to an rAthena server: https://github.com/Latiosu/dp2rathena
I noticed that the rAthena community often refers to divine-pride.net (DP) as a source of truth, so I figured it would be useful to connect with their API.

Summary
The tool uses data from divine-pride.net and attempts to map the API response to a desired rAthena database format.

Installation
Requires Python 3.6+ and pip installed: 

pip install dp2rathena

Usage
Generate a divine-pride.net API key if you don't have one yet (registration required), then you can start converting data:

dp2rathena terminal animation


Example 1: Store API key and convert items with id 501 and 1101

dp2rathena config
dp2rathena item 501 1101

Produces this output:

Spoiler
Header:
  Type: ITEM_DB
  Version: 1
Body:
- Id: 501
  AegisName: Red_Potion
  Name: Red Potion
  Type: Healing
  Buy: 10
  Weight: 70
- Id: 1101
  AegisName: Sword
  Name: Sword
  Type: Weapon
  SubType: 1hSword
  Buy: 100
  Weight: 500
  Attack: 25
  Range: 1
  Slots: 3
  Jobs:
    Alchemist: true
    Assassin: true
    Blacksmith: true
    Crusader: true
    Knight: true
    Merchant: true
    Novice: true
    Rogue: true
    SuperNovice: true
    Swordman: true
    Thief: true
  Locations:
    Right_Hand: true
  WeaponLevel: 1
  EquipLevelMin: 2
  Refineable: true
  View: 2

 

 

Example 2: Convert mobskills for mobs with id 1002, 1049 and 1299 and save to a file called "attacks.txt" (re-uses stored API key if present)

dp2rathena mobskill 1002 1049 1299 > C:\Users\Latios\Desktop\attacks.txt

Produces a file in the Desktop folder called "attacks.txt":

Spoiler
1002,[email protected]_EMOTION,loot,197,1,2000,0,5000,yes,self,always,,2,,,,,,
1002,[email protected]_WATERATTACK,attack,184,1,2000,0,5000,yes,target,always,,,,,,,,
1049,[email protected]_EMOTION,walk,197,1,2000,0,5000,yes,self,always,,2,,,,,,
1049,[email protected]_FIREATTACK,attack,186,1,2000,0,5000,yes,target,always,,,,,,,,
1299,Goblin [email protected]_TELEPORT,idle,26,1,10000,0,0,yes,self,rudeattacked,,,,,,,,
1299,Goblin [email protected]_MAXIMIZE,attack,114,5,500,1000,5000,no,self,always,,,,,,,27,
1299,Goblin [email protected]_MAXIMIZE,chase,114,5,500,1000,5000,no,self,always,,,,,,,27,
1299,Goblin [email protected]_SHIELDCHARGE,attack,250,3,500,0,5000,no,target,always,,,,,,,27,
1299,Goblin [email protected]_SUMMONSLAVE,attack,196,5,10000,2000,60000,no,self,slavele,2,1122,1123,1124,1125,1126,27,
1299,Goblin [email protected]_SUMMONSLAVE,idle,196,5,10000,2000,60000,no,self,slavele,2,1122,1123,1124,1125,1126,27,

 

 

Example 3: Convert mob with id 20357 to mob_db.yml format

dp2rathena mob 20357

Produces following command-line output:

Spoiler
Header:
  Type: MOB_DB
  Version: 2
Body:
- Id: 20357
  AegisName: EP17_1_SANARE1
  Name: Heart Hunter Sanare
  Level: 120
  Hp: 30159
  BaseExp: 6702
  JobExp: 5362
  Attack: 765
  Attack2: 504
  Defense: 200
  MagicDefense: 27
  Str: 51
  Agi: 51
  Vit: 70
  Int: 63
  Dex: 117
  Luk: 77
  AttackRange: 1
  SkillRange: 10
  ChaseRange: 12
  Size: Medium
  Race: Demihuman
  Element: Neutral
  ElementLevel: 2
  WalkSpeed: 200
  AttackDelay: 531
  AttackMotion: 1268       
  DamageMotion: 480        
  Ai: Unknown
  Drops:
  - Item: Crude_Ammo
    Rate: 1000
  - Item: Heart_Hunter_Seal
    Rate: 1250
  - Item: Oridecon_Stone
    Rate: 150
  - Item: Oridecon
    Rate: 12
  - Item: EP17_1_EVT02
    Rate: 10
  - Item: Explosive_Powder
    Rate: 30
  - Item: Sanare_Card
    Rate: 1
    StealProtected: true

 

Further instructions can be found at the repository: https://github.com/Latiosu/dp2rathena

Limitations

I've moved this section to the GitHub repository above to keep it up-to-date.

---

Let me know if you'd like to be able to convert other data from DP, some other suggestion or any questions. 

Edit: Add terminal animation for a visual explanation

Edited by latios
Can now generate mob_db.yml entries
  • Upvote 3
  • Love 1
  • Like 2
Link to comment
Share on other sites

hi 

i wanna know more can you make a step by step instruction for this one for me to pull data 

 

finally able to run the command.

for having issues

go to your terminal then type python if you have python already installed it will run it automatically, if not it will go to microsoft store then install it, 

like me im having an issue once im doing the installation.

do this  1st  https://datatofish.com/add-python-to-windows-path/

once done try to install the file again, or just type pip install dp2rathena

you can also check if its properly installed by typing dp2rathena version

if that gives you the version of the file, then its done

  • Upvote 1
Link to comment
Share on other sites

I've just released version 0.3.0 which allows for converting mob skills and creating a mob_skill_db.txt file.

To update your dp2rathena to the latest version, you'll need to run:

pip install -U dp2rathena

Instructions for how to use the new feature are listed at the top of this thread and within the tool help text. For example running the help command:

dp2rathena mobskill --help

Will produce this help text:

Spoiler
Usage: dp2rathena mobskill [OPTIONS] [VALUE]...

  Converts mob ids to rathena mob_skill_db.txt.

  Examples:
      # Pass API key and convert mob ids 1002 and 1049
      dp2rathena --api-key <your-api-key> mobskill 1002 1049

      # Pass API key and convert mobs via STDIN
      dp2rathena -k <your-api-key> mobskill -f -

      # Save API key and convert mob ids in ids_to_convert.txt
      dp2rathena config
      dp2rathena mobskill -f ids_to_convert.txt

Options:
  -f, --file  A file with mob ids to convert, newline separated.
  --debug     Shows debug information when querying Divine-Pride.
  -h, --help  Show this message and exit.

 

Let me know if you come across any issues or have any requests/suggestions.

I'll do my best to reply promptly /ok

Link to comment
Share on other sites

On 9/13/2021 at 8:46 AM, Snaehild said:

This is an awesome tool. Do you have an ETA for the mob_db.txt support? 

Hi there Snaehild!

I'm so glad you like it! I hope to release support for mob_db.txt by the end of this month 🙏

  • Love 1
Link to comment
Share on other sites

On 9/16/2021 at 7:58 AM, latios said:

Hi there Snaehild!

I'm so glad you like it! I hope to release support for mob_db.txt by the end of this month 🙏


Lovely. I will be waiting.

Link to comment
Share on other sites

On 9/26/2021 at 12:42 AM, Snaehild said:


Lovely. I will be waiting.

Hi @Snaehild, apologies I haven't quite finished getting mob_db.txt conversion feature yet, but have just released the mob_db.yml conversion feature in case that's still relevant to you.

I've got mob_db.txt feature at the top of my list now.

Link to comment
Share on other sites

4 hours ago, latios said:

Hi @Snaehild, apologies I haven't quite finished getting mob_db.txt conversion feature yet, but have just released the mob_db.yml conversion feature in case that's still relevant to you.

I've got mob_db.txt feature at the top of my list now.

Hey latios, thank you for letting me know. I actually need YML more. you're the best! 

  • Love 1
Link to comment
Share on other sites

how do i use this program? wouldn't have a video to help? I installed everything right so I don't know how to use the program or the API.

Link to comment
Share on other sites

On 10/6/2021 at 1:51 AM, kennykiro said:

how do i use this program? wouldn't have a video to help? I installed everything right so I don't know how to use the program or the API.

Hi there @kennykiro, it's unclear to me what kind of struggle you are having.

Do you have an example of where you are stuck?

Additionally, are you already familiar with using command-line (CLI) tools, if so, do you have an examples of CLI tools you like to use? I may be able to give better examples if I understand what you are familiar with.

 

@kennykiro I've updated the GitHub repo with slightly clearer information and also a small terminal animation, which may or may not help you but hopefully it does 🙏

 dp2rathena terminal animation

Link to comment
Share on other sites

Hi, I'm having problem when trying to use your script/program. Whenever I try to use dp2rathena mob **** I get this printed in the command prompt. I've removed the api key from the code but I have my own.

C:\WINDOWS\system32>dp2rathena mob 20592
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\dp2rathena.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\cli.py", line 233, in mob
    converter.Converter(api_key, debug).convert_mob(to_convert, sort, wrap)
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\converter.py", line 76, in convert_mob
    mobs.append(mapper.map_mob(self.fetch_mob(mobid)))
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\converter.py", line 50, in fetch_mob
    raise err
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\converter.py", line 46, in fetch_mob
    return self.api.monster.get(mobid)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 407, in get
    return self.request('get', *parts, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 383, in request
    return self.__call__(*parts).request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 403, in request
    return self._parent.request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 403, in request
    return self._parent.request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 403, in request
    return self._parent.request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 219, in request
    r.raise_for_status()
  File "C:\Program Files\Python310\lib\site-packages\requests\models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://divine-pride.net/api/database/monster/20592?apiKey=*******************

 

Link to comment
Share on other sites

Hi @exyoupjkbrxd, that's quite strange 🤔. I have a few questions and ideas:

  1. If you copy and paste the URL (with your actual API key) into a browser, are you able to see the relevant JSON data?
    https://divine-pride.net/api/database/monster/20592?apiKey=yoursecretapikey
  2. Does it work if you call the command by passing in your API key?
    dp2rathena -k yoursecretapikey mob 20592

There might be some whitespace at the beginning/end of your API key.

I was able to successfully pull the data for mob 20592 with my own API key:

Spoiler
Header:
  Type: MOB_DB
  Version: 2
Body:
- Id: 20592
  AegisName: POISONOUS
  Name: Poisonous
  Level: 188
  Hp: 2407086
  BaseExp: 343870
  JobExp: 240708
  Attack: -278
  Defense: 132
  MagicDefense: 63
  Str: 145
  Agi: 141
  Vit: 77
  Int: 67
  Dex: 175
  Luk: 11
  AttackRange: 1
  SkillRange: 10
  ChaseRange: 12
  Size: Medium
  Race: Formless
  Element: Ghost
  ElementLevel: 4
  WalkSpeed: 350
  AttackDelay: 1033
  AttackMotion: 1440
  DamageMotion: 672
  Ai: Unknown
  Drops:
  - Item: Poisonous_Card
    Rate: 1
    StealProtected: true

 

 

Link to comment
Share on other sites

10 minutes ago, latios said:

Hi @exyoupjkbrxd, that's quite strange 🤔. I have a few questions and ideas:

  1. If you copy and paste the URL (with your actual API key) into a browser, are you able to see the relevant JSON data?
    https://divine-pride.net/api/database/monster/20592?apiKey=yoursecretapikey
  2. Does it work if you call the command by passing in your API key?
    dp2rathena -k yoursecretapikey mob 20592

There might be some whitespace at the beginning/end of your API key.

I was able to successfully pull the data for mob 20592 with my own API key:

  Reveal hidden contents
Header:
  Type: MOB_DB
  Version: 2
Body:
- Id: 20592
  AegisName: POISONOUS
  Name: Poisonous
  Level: 188
  Hp: 2407086
  BaseExp: 343870
  JobExp: 240708
  Attack: -278
  Defense: 132
  MagicDefense: 63
  Str: 145
  Agi: 141
  Vit: 77
  Int: 67
  Dex: 175
  Luk: 11
  AttackRange: 1
  SkillRange: 10
  ChaseRange: 12
  Size: Medium
  Race: Formless
  Element: Ghost
  ElementLevel: 4
  WalkSpeed: 350
  AttackDelay: 1033
  AttackMotion: 1440
  DamageMotion: 672
  Ai: Unknown
  Drops:
  - Item: Poisonous_Card
    Rate: 1
    StealProtected: true

 

 

Hello, copy pasting the URL with my API key show this page (I've remove the API Key):
image.thumb.png.028b8dba0304b384e5a409c7643eea0a.png

And using the dp2rathena -k yoursecretapikey mob 20592, I get

C:\Users\Alex>dp2rathena -k ------------------------------- mob 20592
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\dp2rathena.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\cli.py", line 233, in mob
    converter.Converter(api_key, debug).convert_mob(to_convert, sort, wrap)
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\converter.py", line 76, in convert_mob
    mobs.append(mapper.map_mob(self.fetch_mob(mobid)))
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\converter.py", line 50, in fetch_mob
    raise err
  File "C:\Program Files\Python310\lib\site-packages\dp2rathena\converter.py", line 46, in fetch_mob
    return self.api.monster.get(mobid)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 407, in get
    return self.request('get', *parts, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 383, in request
    return self.__call__(*parts).request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 403, in request
    return self._parent.request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 403, in request
    return self._parent.request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 403, in request
    return self._parent.request(method=method, **options)
  File "C:\Program Files\Python310\lib\site-packages\tortilla\wrappers.py", line 219, in request
    r.raise_for_status()
  File "C:\Program Files\Python310\lib\site-packages\requests\models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://divine-pride.net/api/database/monster/20592?apiKey=------------------------

 

Link to comment
Share on other sites

Hi again @exyoupjkbrxd, in this case I think you may want to reach out to Dia, the admin of Divine-Pride for support: https://www.divine-pride.net/forum/index.php?/staff/

It sounds like there may be an issue with your API key if you aren't able to make any standard API calls even without using dp2rathena 🤔

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.