Informations
Jump to content

Lorem Ipsum...

Click to Dismiss this Notification
Ładowanie danych...

Recommended Posts

  • Premium+

306054_e7f63e3ea18ecb639c0e0d551941b3f0.

 

[C++/Py] Metin Stone Damage Limit System

This system allows server administrators to define a maximum damage threshold for specific Metin stones or special monsters. Once configured, players will not be able to exceed the specified damage value against these targets, ensuring better game balance and preventing rapid destruction of objectives.


### Technical Overview

  • Server-Side: Implements the actual damage cap logic within the battle mechanics.

  • Client-Side: Displays the damage limit information directly in the target window when a player selects a Metin stone.

  • Configuration: Limits are defined per mob VNUM. While this version uses hardcoded maps, the configuration can be updated via SQL and refreshed in-game using the /reload p or /reload m commands depending on your implementation.


### Client Source Fix

If you encounter a compilation error regarding INSTANCE_TYPE_STONE missing in your Python character module, apply the following change:

File: PythonCharacterModule.cpp

C++
// Search for:
PyModule_AddIntConstant(poModule, "INSTANCE_TYPE_NPC", CActorInstance::TYPE_NPC);

// Add below:
PyModule_AddIntConstant(poModule, "INSTANCE_TYPE_STONE", CActorInstance::TYPE_STONE);

### Server-Side Implementation

File: char_battle.cpp Function: bool CHARACTER::Damage

C++
// Search for the block where damage is sent to the client:
if (pAttacker)
    SendDamagePacket(pAttacker, dam, damageFlag);

// Add the limit logic BEFORE the code above:
std::map<int, int> damageLimits = {
    {8009, 25000},
    {8010, 30000},
    {8011, 35000},
    {8012, 40000},
    {8013, 45000},
    {8014, 50000},
    {8024, 55000},
    {8025, 60000},
    {8026, 70000},
    {8027, 100000},
    {8127, 100000},
    {8158, 100000}
};

auto it = damageLimits.find(GetRaceNum());
if (it != damageLimits.end() && dam > it->second) {
    dam = it->second;
}

### Client-Side Implementation

File: uitarget.py

1. Define the UI dictionary:

Python
# Search for GRADE_NAME and add LIMITE_NIVEL below it:
LIMITE_NIVEL = {
    8009: "25000",
    8010: "30000",
    8011: "35000",
    8012: "40000",
    8013: "45000",
    8014: "50000",
    8024: "55000",
    8025: "60000",
    8026: "70000",
    8027: "100000",
    8127: "100000",
    8158: "100000",
}

2. Initialize the Text Line:

Python
# In __init__(self), search for closeButton = ui.Button() and add above:
damageLimitText = ui.TextLine()
damageLimitText.SetParent(self)
damageLimitText.SetOutline()
damageLimitText.SetHorizontalAlignRight()
damageLimitText.Hide()
self.damageLimitText = damageLimitText

3. Add the display function:

Python
# Add this function after __ShowMainCharacterMenu(self):
def ShowDamageLimitText(self, vid):
    vnum = nonplayer.GetRaceNumByVID(vid)

    if vnum in self.LIMITE_NIVEL:
        limita_damage = self.LIMITE_NIVEL[vnum]
        self.damageLimitText.SetText("Damage limit: " + str(limita_damage))
    else:
        self.damageLimitText.SetText("No damage limit for this target.")

    self.damageLimitText.Show()

4. Update UI Positioning:

Python
# Replace the existing UpdatePosition(self) function with this one:
def UpdatePosition(self):
    self.SetPosition(wndMgr.GetScreenWidth() / 2 - self.GetWidth() / 2, 10)

    if chr.GetInstanceType(self.vid) == chr.INSTANCE_TYPE_STONE:
        self.SetSize(self.GetWidth(), self.GetHeight() + 20)

        self.ShowDamageLimitText(self.vid)

        self.damageLimitText.SetPosition(self.GetWidth() / 2, 30)
        self.damageLimitText.Show()
    else:
        self.damageLimitText.Hide()

### Summary Note

The server-side code ensures that players cannot bypass the restriction, while the client-side changes provide a clear visual indicator in the Target UI, telling the player exactly what the damage ceiling is for the current Metin stone.

 

This is the hidden content, please

This is the hidden content, please

This is the hidden content, please

This is the hidden content, please

This is the hidden content, please

 

 

Link to comment
Share on other sites


spacer.png

Hi TechroomsBOT 👋

Thanks for starting a new topic on Techrooms – Blockchain, Programming, Gaming & Crypto Forum!  
If you’re new here — welcome. If you’ve been around for a while — great to have you back 😊

To help you get the most out of TechRooms, here are a few useful places to explore:

────────────────────────────────────
💎 Premium Membership (Optional)
Support the community and unlock extra perks:

🚫 Ad-free browsing  
Faster access & priority support  
📊 Private analysis & signals  
🧪 Early access to beta features & tools  
📥 Downloadable premium resources  

🎟️ Upgrade here: Premium Link
────────────────────────────────────

🧠 Popular Sections You Might Like

📊 Crypto Signals & Market Analysis  
Get free signals and market insights: Signals

💾 Tech Tools & Programs  
Automation, software, utilities & security tools: Tools Techrooms

🗣️ Discussions & Q&A  
Ask questions, share knowledge, help others: Forum

📚 Tech Book Library  
Books, guides and resources for members: Books

📚 Quizzes  
Members Quizzes: Quizzes

🎓 Learning & Courses  
Blockchain, security, coding and more: Blockchain Courses

🧠 Hacking & Firewall Courses 
Hacking, security, firewall and more: Firewall Courses

🪙 Earn Tokens for Posting  
Create valuable content and get rewarded

🃏 Blackjack  
Take a break and play: Blackjack

💖 Support via Crypto Donation (Optional)
Cosmos Wallet: 
cosmos1p5sjqcu3gp9vkjdyc9uee2mw4a4zvjvqz2lj2g 
Donate: Donate

📜 Forum Rules  
Please read before posting: Techrooms Rules

────────────────────────────────────
Stay connected. Stay ahead. Stay TechRooms. 🚀

 

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

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.

spacer.png

Disable AdBlock
The popup will be closed in 5 seconds...