Informations
Jump to content

Lorem Ipsum...

Click to Dismiss this Notification
Ładowanie danych...

Check Safe Zone For Monster Fix


Recommended Posts

  • Premium+

 

Hey everyone,

Here is a quick and effective server-side modification to prevent players from luring aggressive monsters into towns or designated safe zones. This script continuously checks the monster's coordinates, and if it steps into a "No-PK" / safe attribute zone, it is instantly and safely removed from the map.

Below are the step-by-step changes required in your source code.

📂 Step 1: Open game\src\char.h

First, we need to declare the new function. Look for your public section and add the following line:

C++
void CheckSafeZoneForMonster();

📂 Step 2: Open game\src\char.cpp

Next, we will implement the actual logic. You can add this block anywhere within the global namespace area of the file:

C++
void CHARACTER::CheckSafeZoneForMonster()
{
if (!IsMonster())
return;

if (IsDead())
return;

LPSECTREE sectree = GetSectree();
if (!sectree)
return;

if (sectree->IsAttr(GetX(), GetY(), ATTR_BANPK))
{
M2_DESTROY_CHARACTER(this);
return;
}
}

📂 Step 3: Update the State Machine in game\src\char.cpp

Finally, we need to make sure the server triggers this check regularly. Find your UpdateStateMachine function and modify it to include our new check, exactly like this:

C++
void CHARACTER::UpdateStateMachine(DWORD dwPulse)
{
if (dwPulse < m_dwNextStatePulse)
return;

if (IsDead())
return;

CheckSafeZoneForMonster();

if (IsDead())
return;

Update();
m_dwNextStatePulse = dwPulse + m_dwStateDuration;
}

And that's it! Recompile your game source, and monsters will no longer be able to invade your safe zones.

If you found this useful, feel free to leave a comment or drop a like!

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...