Jump to content

Recommended Posts

  • Developer
Posted (edited)
This is the hidden content, please

Alternative download links →

This is the hidden content, please
or
This is the hidden content, please

Hi devs,
A while ago, during one of my routine cleanups of dead code, I stumbled upon a snippet that gave certain items at character creation
(inside ::PlayerCreateSuccess).

It was never actually used because it was under china_event_server.
If you're using a codebase that hasn't had dead code removed, you might still have it lying around.

I figured delivering starter items at that point was a good idea, and likely tested back in the day, at least on Chinese servers.
So I decided to create what I’d call a "definitive version" of the give_basic_weapon system, using this old Ymir approach.

Here's what I'm referring to with "OLD YMIR CODE":

Spoiler

spacer.png

Now, if you still have this, just remove, I wrote a Json handler to easly setup everything.
Put simply, this allows you to create characters with predefined items, both equipped and in inventory, including custom attributes and sockets.

Json Example:

spacer.png

So, first login in game will be like:

spacer.png

Pros:
This follows the Ymir logic, there used to be a system that gave basic items to Chinese players, though it was never really used.
You can spawn with the items already equipped and specify any slot number you want for each item.
You can also set up count, bonuses and stones(sockets, so also duration) in the starter equipment.
Since it happens during character creation, there's no risk of doing it before CItem or QuestManager is properly initialized, indeed, we don't even use them here.
The function is called during PlayerCreate, so you don't need a quest flag to prevent giving items twice. It only triggers on character creation.
It supports a lightweight reload (core based), so you can hot test or run a starter boost event without shutting down the server.

Cons:
The only annoying part is having to specify the exact slot indexes where items go, even for equipment. But hey, you only need to do it once.


It has common items, shared items, job items, but check the readme on GitHub to figure out how to use it:

This is the hidden content, please

 


Given that this follows Ymir's original approach, I kept the implementation style consistent.
The files start_item.cpp/.h resemble start_position.cpp/.h, and I opted not to introduce a new class-
just a small set of global functions was sufficient.  

 

About nlohman json
You can check my old post to see how to include nlohman json in your files:

 

If you have any questions or if I made a mistake in the tutorial, feel free to comment.

Edited by Mitachi
Updated Internal Link
  • Metin2 Dev 46
  • Eyes 1
  • Flame 1
  • Good 5
  • muscle 1
  • Love 3
  • Love 32


Join

Link to comment
https://metin2.dev/topic/33780-cool-start-with-items-ymir-way/
Share on other sites

  • Nitro Booster

It would not be wrong to say that this is a great contribution from a great man, as there were many members in the community looking for this. Considering that there are still servers that give starter items with quests or cmd commands, this new way is quite good.

  • Flame 1
  • Love 1
  • Forum Moderator

Great work, I would say I am unsure about that one, on the one hand it is probably the most powerful way to handle this and fairly fail-safe, but on the other hand it is some boilerplate code and it feels like reinventing the wheel. I would prefer the original way for really "basic" items but as soon as we need to go the extra mile and really provide specific items and modify it on the fly, this take the edge fairly quickly. I also like the fact that it can be easily extended (like allow random rare attr on the json would simply mean a token and a few lines of c++) AND that this can be reused for other parts. I really feel like it can be a powerful way to give "uniform" items in the case of events for example, or even battle-pass and whatnot.

Great release and great use of lovely forgotten code!

  • Good 1
  • muscle 1

Gurgarath
coming soon

  • Developer
Posted (edited)
20 hours ago, Gurgarath said:

Great work, I would say I am unsure about that one, on the one hand it is probably the most powerful way to handle this and fairly fail-safe, but on the other hand it is some boilerplate code and it feels like reinventing the wheel. I would prefer the original way for really "basic" items but as soon as we need to go the extra mile and really provide specific items and modify it on the fly, this take the edge fairly quickly. I also like the fact that it can be easily extended (like allow random rare attr on the json would simply mean a token and a few lines of c++) AND that this can be reused for other parts. I really feel like it can be a powerful way to give "uniform" items in the case of events for example, or even battle-pass and whatnot.

Great release and great use of lovely forgotten code!

Thank you for always saying what you think, it is appreciated ngl.
The handling of sockets and bonuses is not something essential, I just added it to extend it a bit before releasing it so it doesn't seems that I'm writing a quest in c++, it's just extra broth put there, what I liked was the Ymir approach never used!

However, that's 16 extra lines of code (6 of which are parentheses), and in json you can simply don't use them
spacer.png

You also have to consider that in order to share something on the forum you have to package it well, I can't come here and say “guys ymir used this code in china do it too.” a bit of effort was required 🤣

Edited by Mitachi
  • Metin2 Dev 1
  • Love 1


Join

  • Active Member

Great idea, but I have noticed an error in your guide. 

cmd_gm.cpp
/// 2.) Search in void CHARACTER::MountVnum(DWORD vnum):

//Should be:
/// 2.) Search in ACMD(do_reload): -> ACMD = #define ACMD(name)  void (name)(LPCHARACTER ch, const char *argument, int cmd, int subcmd)

 

  • muscle 1

First of all, thank you for your great work on the give_basic_weapon system.
I just wanted to let you know that the /reload give_basic_weapon command doesn’t seem to work on my side
Is there something extra I should implement to enable it?

  • 2 weeks later...

Errors:

1: Time-limited items cannot be added.

2: Metin stones cannot be added to objects such as armor and weapons with the json file.

For example:

/i 19

you can add stones to this object. But you cannot add stones to the object that comes with the json file.

  • Developer
On 7/3/2025 at 4:35 PM, BadRomani said:

Errors:

1: Time-limited items cannot be added.

2: Metin stones cannot be added to objects such as armor and weapons with the json file.

For example:

/i 19

you can add stones to this object. But you cannot add stones to the object that comes with the json file.

You just need to setup sockets for all of them, in the case of armor/weapons, if sockets are 0, aren't usable. So put 1, in the case of /i 19 which is Sword+9, it's used to have just one slot, so you can put sockets like that: [1, 0, 0], so the first socket is allowed to collect stones in that case. About the other items, it will put socket to 0 as default, so they were created but insta disappear I guess, so again just setup the sockets.

  • Love 1


Join

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.