Jump to content

Death Event - lose level after death


Recommended Posts

  • Premium

Go to char_battle.cpp and search for (in ::Dead function):

CGuildManager::instance().Kill(pkKiller, this);

 

Add this after:

#ifdef DEATH_EVENT
#define DEATH_INITIAL_LEVEL	1 // What's the level the player should start?

			ResetPoint(MINMAX(1, DEATH_INITIAL_LEVEL, PLAYER_MAX_LEVEL_CONST));
			ClearSkill();
			ClearSubSkill();


			LPITEM	item;
			for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
			{
				if ((item = GetInventoryItem(i)))
				{
					ITEM_MANAGER::instance().RemoveItem(item, "DEATH_EVENT");
					SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
				}
			}

			ChatPacket(CHAT_TYPE_INFO, "<Death Event> You died and as such, your level is now %d and you lost all your equipment", GetLevel());
#endif

 

In service.h, add:

#define DEATH_EVENT

 

Edited by msnas
Link to comment
Share on other sites

1 hour ago, Mefarious said:

@ msnas Could you help me again?
I want to make quest when talk to NPC for example 20094.chat."balbla" she will reset level to 1 and give me gold equal to level i had.
I dont know how to call dead function in quest, she can even kill me to cause definition you helped me last time.
Thanks in advance

 

Add this to your questlua_pc + add quest_functions according. pc.reset_level (code not tested)



{ "reset_level",	pc_reset_level},

#ifdef DEATH_EVENT
#define DEATH_INITIAL_LEVEL	1 // What's the level the player should start?
ALUA(pc_reset_level)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	int lvlBeforeReset = ch->GetLevel();
	
	ch->ResetPoint(MINMAX(1, DEATH_INITIAL_LEVEL, PLAYER_MAX_LEVEL_CONST));
	ch->ClearSkill();
	ch->ClearSubSkill();

	LPITEM item;
	for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
	{
		if ((item = ch->GetInventoryItem(i)))
		{
			ITEM_MANAGER::instance().RemoveItem(item, "DEATH_EVENT_BY_QUEST");
			ch->SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
		}
	}
	
	ch->PointChange(POINT_GOLD, lvlBeforeReset);
	ch->ChatPacket(CHAT_TYPE_INFO, "<Death Request> Resetted. Your level was %d, because of that same amount of gold is credited.", lvlBeforeReset);
}
#endif

 

Then in quest like:

 

quest resetchar begin
	state start begin
		when 20094.chat."balbla" begin
			if pc.get_level() > 1 then
				pc.reset_level()
			end
		end
	end
end

 

Edited by Minton

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

3 minutes ago, Mefarious said:

OKey im trying to compile it, and now shiuld i type all possibilities each of 120lvls give different amount of gold after reset? 
i dont understand this 
ch->PointChange(POINT_GOLD, lvlBeforeReset);

It gives gold.

If you reset a lv 120 character you get 120 gold

If you reset a lv10 character you get 10 gold

Is that you wanted?

 

 

 

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

31 minutes ago, Mefarious said:

yea i wanted to get gold, but i have to think about how muchm its like im creating RogueLike server and need for example
2 lvl -50yang
3lvl 75yang
4lvl 150yang etc etc as i want 120 lvl -10kk etc

edit, quest doesnt work, it doesnt reset level

You should fill in all level gold rewards. What it says? nothing? 

 

ALUA(pc_reset_level)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	int lvlBeforeReset = ch->GetLevel();
	
	ch->ResetPoint(MINMAX(1, DEATH_INITIAL_LEVEL, PLAYER_MAX_LEVEL_CONST));
	ch->ClearSkill();
	ch->ClearSubSkill();

	LPITEM item;
	for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
	{
		if ((item = ch->GetInventoryItem(i)))
		{
			ITEM_MANAGER::instance().RemoveItem(item, "DEATH_EVENT_BY_QUEST");
			ch->SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
		}
	}
	int goldByLevel[PLAYER_EXP_TABLE_MAX + 1] =
	{
		0,  // PLACEHOLDER
		10, // LV 1
		20, // LV 2
		30, // LV 3
		40, // LV 4
		50, // LV 5
		60, // LV 6
	};
	ch->PointChange(POINT_GOLD, goldByLevel[lvlBeforeReset]);
	ch->ChatPacket(CHAT_TYPE_INFO, "<Death Request> Your level was %d, because of that same amount of gold is credited.", lvlBeforeReset);
	
	return 0;
}

 

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

2 minutes ago, Mefarious said:

Its not working for me or i just put it wrong , no error show up, quest reads function without error, but when i click on npc to reset nothing happens

Add me on Discord.

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

  • 1 year later...
On 1/3/2022 at 5:05 PM, msnas said:

I tried to modify the code for my needs but it doesn't work i think i'm doing something wrong, i need that only the equipment that the character is wearing is gonna fall on the ground, don't need level drop and not even all the inventory could you help me with that? also do you think that there is a way to make spawn an interactive item like a tombstone, and by clicking on it a window containing all the items will open up? instead of make them drop on the ground

 

Link to comment
Share on other sites

  • Premium
11 hours ago, Alessio said:

I tried to modify the code for my needs but it doesn't work i think i'm doing something wrong, i need that only the equipment that the character is wearing is gonna fall on the ground, don't need level drop and not even all the inventory could you help me with that?

	PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = ch->GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}

 

11 hours ago, Alessio said:

also do you think that there is a way to make spawn an interactive item like a tombstone, and by clicking on it a window containing all the items will open up? instead of make them drop on the ground

It's possible but it would require time.

Edited by msnas
Link to comment
Share on other sites

is it working the code that @msnas writed for you? i tried it and it doesn't work, i think that i'm doing something wrong but i don't understand what, i'm writing everythin exactly where he said

On 2/23/2023 at 11:51 AM, msnas said:
	PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = ch->GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}

i tried to use the code but nothing happen in game when i die, i also tried to use the cose that you shared the first time but still nothing, do you have any ideas on what am i doing wrong?

 

Edited by Alessio
Link to comment
Share on other sites

On 2/23/2023 at 11:51 AM, msnas said:
	PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = ch->GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}

 

hey i understood my mistake, i wasn't doing gamecompile after modifing the files, i tried the code that you have writed for Mefarious and it work super good, then i tried to modify it like you showed me and i get this error while i do gamecompile

char_battle.cpp:1258:15: error: use of undeclared identifier 'ch'
                if ((item = ch->GetWear(i)))
                                   ^
char_battle.cpp:1264:27: error: no matching member function for call to 'ItemLog'
                        LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
                        ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
./log.h:29:9: note: candidate function not viable: no known conversion from 'DWORD' (aka 'unsigned int') to 'const                                                                            char *' for 4th argument
                void            ItemLog(LPCHARACTER ch, LPITEM item, const char * c_pszText, const char * c_pszHin                                                                           t);
                                ^
./log.h:30:9: note: candidate function not viable: requires 5 arguments, but 4 were provided
                void            ItemLog(LPCHARACTER ch, int itemID, int itemVnum, const char * c_pszText, const ch                                                                           ar * c_pszHint);
                                ^
./log.h:28:9: note: candidate function not viable: requires 8 arguments, but 4 were provided
                void            ItemLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwItemID, const char * c_pszText, con                                                                           st char * c_pszHint, const char * c_pszIP, DWORD dwVnum);
                                ^
compile horsename_manager.cpp
compile input.cpp
2 errors generated.
gmake: *** [Makefile:119: OBJDIR/char_battle.o] Error 1
gmake: *** Waiting for unfinished jobs....
root@metin2:/usr/metin2/src/game/src #
     

could you help me, please?                         '
 

this is what i did
 

CGuildManager::instance().Kill(pkKiller, this);
		}
#ifdef DEATH_EVENT

			PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = ch->GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}
#endif

 

Edited by Alessio
Link to comment
Share on other sites

  • Premium
33 minutes ago, Alessio said:

hey i understood my mistake, i wasn't doing gamecompile after modifing the files, i tried the code that you have writed for Mefarious and it work super good, then i tried to modify it like you showed me and i get this error while i do gamecompile

char_battle.cpp:1258:15: error: use of undeclared identifier 'ch'
                if ((item = ch->GetWear(i)))
                                   ^
char_battle.cpp:1264:27: error: no matching member function for call to 'ItemLog'
                        LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
                        ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
./log.h:29:9: note: candidate function not viable: no known conversion from 'DWORD' (aka 'unsigned int') to 'const                                                                            char *' for 4th argument
                void            ItemLog(LPCHARACTER ch, LPITEM item, const char * c_pszText, const char * c_pszHin                                                                           t);
                                ^
./log.h:30:9: note: candidate function not viable: requires 5 arguments, but 4 were provided
                void            ItemLog(LPCHARACTER ch, int itemID, int itemVnum, const char * c_pszText, const ch                                                                           ar * c_pszHint);
                                ^
./log.h:28:9: note: candidate function not viable: requires 8 arguments, but 4 were provided
                void            ItemLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwItemID, const char * c_pszText, con                                                                           st char * c_pszHint, const char * c_pszIP, DWORD dwVnum);
                                ^
compile horsename_manager.cpp
compile input.cpp
2 errors generated.
gmake: *** [Makefile:119: OBJDIR/char_battle.o] Error 1
gmake: *** Waiting for unfinished jobs....
root@metin2:/usr/metin2/src/game/src #
     

could you help me, please?                         '
 

this is what i did
 

CGuildManager::instance().Kill(pkKiller, this);
		}
#ifdef DEATH_EVENT

			PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = ch->GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}
#endif

 

	PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}

 

Link to comment
Share on other sites

4 minutes ago, msnas said:
	PIXEL_POSITION pxPos = GetXYZ();
	LPITEM item;
	for (int i = 0; i < WEAR_MAX_NUM; ++i)
	{
		if ((item = GetWear(i)))
		{
			item->RemoveFromCharacter();
			item->AddToGround(GetMapIndex(), pxPos);
			item->StartDestroyEvent();
			
			LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
		}
	}

 

ch error resolved, now i have this left

char_battle.cppcompile polymorph.cpp
:1264:27: error: no matching member function for call to 'ItemLog'
                        LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
                        ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
./log.h:29:9: note: candidate function not viable: no known conversion from 'DWORD' (aka 'unsigned int') to 'const char *' for 4th argument
                void            ItemLog(LPCHARACTER ch, LPITEM item, const char * c_pszText, const char * c_pszHint);
                                ^
./log.h:30:9: note: candidate function not viable: requires 5 arguments, but 4 were provided
                void            ItemLog(LPCHARACTER ch, int itemID, int itemVnum, const char * c_pszText, const char * c_pszHint);
                                ^
./log.h:28:9: note: candidate function not viable: requires 8 arguments, but 4 were provided
                void            ItemLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwItemID, const char * c_pszText, const char * c_pszHint, const char * c_pszIP, DWORD dwVnum);
                                ^

 

Link to comment
Share on other sites

  • Premium
4 hours ago, Alessio said:

ch error resolved, now i have this left

char_battle.cppcompile polymorph.cpp
:1264:27: error: no matching member function for call to 'ItemLog'
                        LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetID());
                        ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
./log.h:29:9: note: candidate function not viable: no known conversion from 'DWORD' (aka 'unsigned int') to 'const char *' for 4th argument
                void            ItemLog(LPCHARACTER ch, LPITEM item, const char * c_pszText, const char * c_pszHint);
                                ^
./log.h:30:9: note: candidate function not viable: requires 5 arguments, but 4 were provided
                void            ItemLog(LPCHARACTER ch, int itemID, int itemVnum, const char * c_pszText, const char * c_pszHint);
                                ^
./log.h:28:9: note: candidate function not viable: requires 8 arguments, but 4 were provided
                void            ItemLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwItemID, const char * c_pszText, const char * c_pszHint, const char * c_pszIP, DWORD dwVnum);
                                ^

 

			PIXEL_POSITION pxPos = GetXYZ();
			LPITEM item;
			for (int i = 0; i < WEAR_MAX_NUM; ++i)
			{
				if ((item = GetWear(i)))
				{
					item->RemoveFromCharacter();
					item->AddToGround(GetMapIndex(), pxPos);
					item->StartDestroyEvent();

					LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetName());
				}
			}

 

  • Love 1
Link to comment
Share on other sites

34 minutes ago, msnas said:
			PIXEL_POSITION pxPos = GetXYZ();
			LPITEM item;
			for (int i = 0; i < WEAR_MAX_NUM; ++i)
			{
				if ((item = GetWear(i)))
				{
					item->RemoveFromCharacter();
					item->AddToGround(GetMapIndex(), pxPos);
					item->StartDestroyEvent();

					LogManager::instance().ItemLog(this, item, "DROP_EVENT", item->GetName());
				}
			}

 

works perfectly, thank you so much ^^
 

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



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