Jump to content

[HELP] Does this function exist?


Recommended Posts

It can make the quest easier, but I prefer the more in C++.

Mqjzg.png

//@svn/Source/Server/game/src/game/char_battle.cpp
//1.) Search:
void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
{
	if (IsDead())
		return;
//2.) Add bellow:
#ifdef ENABLE_COUNTING_KILLS	
	if (pkKiller->IsPC() && !IsPC())
	{
		CountingKills(pkKiller, this);	
	}
#endif
//3.) Search:
int CHARACTER::GetRealAlignment() const
{
	return m_iRealAlignment;
}
//4.) Add bellow:
#ifdef ENABLE_COUNTING_KILLS
void CountingKills(LPCHARACTER ch, LPCHARACTER tch)
{
/***************** Credits: VegaS *****************/
	int numberCount, total;
	std::string flag = "mob.count_kills";

	numberCount = ch->GetQuestFlag(flag);
	total = numberCount += 1;
	ch->SetQuestFlag(flag, total);
		
	ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Now you killed mob: %s", tch->GetName());
	ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Total counting of kills: %d.", numberCount);
}
#endif
//@svn/Source/Server/game/src/common/service.h
//Add where you want:
#define ENABLE_COUNTING_KILLS

 

//Example if you want to make special function to get counting kills:
//CPP - char.cpp / char_battle.cpp / char_item.cpp etc.
int CHARACTER::GetCountingKills()
{
	int res = ch->GetQuestFlag("mob.count_kills");
	return res;
}
// Header - char.h
	public:
		int	GetCountingKills();

//How to use:
//Part for other function on source to result chat.
		ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Total counting of kills: %d", ch->GetCountingKills());
//Part for result in lua.
//svn/Source/Server/game/src/game/questlua_pc.cpp
	luaL_reg pc_functions[] = 
	{
		{ "get_counting_kills",        pc_get_counting_kills },
	};
	int pc_get_counting_kills(lua_State * L)
	{	
		lua_pushnumber(L, ch->GetCountingKills());
		return 1;
	}
//yourquest.lua:
	say(string.format("<Debug> Total counting of kills: %d", pc.get_counting_kills()))

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 3
Link to comment
Share on other sites

  • Premium

I think he want to talk about the "fall", when you're hitted by a mob in Cape Dragon Head for example, when your character is falling on the ground. There's an anti-fall but it's only decorative as it doesn't work, the only way to avoid the fall is by using the Warrior's skill "Strong Body", otherwise the "Anti Fall" bonus that can be set on shield doesn't work

Am I right ?

Link to comment
Share on other sites

14 hours ago, VegaS said:

It can make the quest easier, but I prefer the more in C++.

Mqjzg.png


//@svn/Source/Server/game/src/game/char_battle.cpp
//1.) Search:
void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
{
	if (IsDead())
		return;
//2.) Add bellow:
#ifdef ENABLE_COUNTING_KILLS	
	if (pkKiller->IsPC() && !IsPC())
	{
		CountingKills(pkKiller, this);	
	}
#endif
//3.) Search:
int CHARACTER::GetRealAlignment() const
{
	return m_iRealAlignment;
}
//4.) Add bellow:
#ifdef ENABLE_COUNTING_KILLS
void CountingKills(LPCHARACTER ch, LPCHARACTER tch)
{
/***************** Credits: VegaS *****************/
	int numberCount, total;
	std::string flag = "mob.count_kills";

	numberCount = ch->GetQuestFlag(flag);
	total = numberCount += 1;
	ch->SetQuestFlag(flag, total);
		
	ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Now you killed mob: %s", tch->GetName());
	ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Total counting of kills: %d.", numberCount);
}
#endif
//@svn/Source/Server/game/src/common/service.h
//Add where you want:
#define ENABLE_COUNTING_KILLS

 


//Example if you want to make special function to get counting kills:
//CPP - char.cpp / char_battle.cpp / char_item.cpp etc.
int CHARACTER::GetCountingKills()
{
	int res = ch->GetQuestFlag("mob.count_kills");
	return res;
}
// Header - char.h
	public:
		int	GetCountingKills();

//How to use:
//Part for other function on source to result chat.
		ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Total counting of kills: %d", ch->GetCountingKills());
//Part for result in lua.
//svn/Source/Server/game/src/game/questlua_pc.cpp
	luaL_reg pc_functions[] = 
	{
		{ "get_counting_kills",        pc_get_counting_kills },
	};
	int pc_get_counting_kills(lua_State * L)
	{	
		lua_pushnumber(L, ch->GetCountingKills());
		return 1;
	}
//yourquest.lua:
	say(string.format("<Debug> Total counting of kills: %d", pc.get_counting_kills()))

 

Where is added this?

//How to use:
//Part for other function on source to result chat.
		ch->ChatPacket(CHAT_TYPE_INFO, "<Debug> Total counting of kills: %d", ch->GetCountingKills());

Would you also like to add a simple quest?

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

On 13.11.2016 at 6:18 PM, Gmmetinero said:

Would you also like to add a simple quest?

Lua will hate me now but you can try with this shit:

--[[###########################	# Quest: Counting kills   #	###########################]]
quest mob begin
	state start begin
		function res() return (pc.getqf("count_kills")) end
		function count()
			pc.setqf("count_kills", mob.res() + 1)
			syschat(string.format("<Debug Mode> Now you killed mob: %s. Your counters of kills mobs was increased +1.", mob_name(npc.get_race())))
		end

	when kill with not npc.is_pc() begin
		mob.count() end

	when 70001.use begin
		say_title("#Informations")
		say(string.format("<Debug Mode> Result of all kils: %d.", mob.res()))
        end
    end
end

 

  • Love 2
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 4

      Feeding game source to LLM

    2. 0

      Quest 6/7 Problem

    3. 5

      Effect weapons

    4. 0

      [C++] Fix Core Downer Using Negative Number in GM Codes

    5. 3

      Crystal Metinstone

    6. 4

      Feeding game source to LLM

    7. 113

      Ulthar SF V2 (TMP4 Base)

    8. 4

      Feeding game source to LLM

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.