Jump to content

[C++] How to block skills on specific maps


VegaS™
 Share

Recommended Posts

For who want in client-side:

[email protected]<script data-cfhash='f9e31' type="text/javascript">/*  */</script>/Source/Client/UserInterface/InstanceBaseBattle.cpp
//1.) Search:
bool CInstanceBase::NEW_UseSkill(UINT uSkill, UINT uMot, UINT uMotLoopCount, bool isMovingSkill)
{
//2.) Add bellow:
#ifdef ENABLE_FEATURES_BLOCK_SKILL
	static std::string uCurrentMap = CPythonBackground::Instance().GetWarpMapName();
	static std::string uArrayListOfMaps[] = {
		"metin2_map_a1",
		"metin2_map_b1",	/* loaded from atlasinfo.txt */
		"metin2_map_c1"
	}; 		
	
	for (int i=0;i<_countof(uArrayListOfMaps);i++) {
		if (!IsGameMaster() && (!uCurrentMap.compare(uArrayListOfMaps[i]))) {
			TraceError("CInstanceBase::UseSkill on map %s was blocked.", uArrayListOfMaps[i].c_str());
			return false;
		}
	}
#endif

For who want in server-side:

[email protected]/*  *//Server/game/src/game/char_skill.cpp
//1.) Search:
	if (0 == dwSkillVnum) return false;
//2.) Add bellow:
#ifdef ENABLE_FEATURES_BLOCK_SKILL
	static int arrayMapIndex[] = {
		1, 21, 41 /* loaded from map/index.txt */
	}; 		
	
	for (int i=0;i<_countof(arrayMapIndex);i++) {
		if (!IsGM() && GetMapIndex() == arrayMapIndex[i]) {
			ChatPacket(CHAT_TYPE_NOTICE, "CHARACTER::UseSkill on mapIndex %d was blocked.", arrayMapIndex[i]);
			return false;
		}
	}
#endif

 

Can you add a "anti pvp function" for any maps? :D

 

Example: user A cannot attack user B but user A can attack a mob/stone/boss - for farmmaps etc.
[email protected]/*  *//Source/Client/UserInterface/PythonPlayerEventHandler.cpp
//1.) Search:
void CPythonPlayerEventHandler::OnHit(UINT uSkill, CActorInstance& rkActorVictim, BOOL isSendPacket)
{
//2.) Add bellow:
	static std::string uCurrentMap = CPythonBackground::Instance().GetWarpMapName();
	static std::string uArrayListOfMaps[] = {
		"metin2_map_a1",
		"metin2_map_b1",	/* loaded from atlasinfo.txt */
		"metin2_map_c1"
	}; 		
	
	for (int i=0;i<_countof(uArrayListOfMaps);i++) {
		if (rkActorVictim.IsPC() && (!uCurrentMap.compare(uArrayListOfMaps[i]))) {
			TraceError("CPythonPlayerEventHandler::OnHit on map %s was blocked because players is protected.", uArrayListOfMaps[i].c_str());
			return;
		}
	}

//3.) And add on first line or where you want:
#include "PythonBackground.h"
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.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...