Jump to content
×
×
  • Create New...
  • 0

Death Event - lose level after death


Mefarious

Question

Hello, i want to write quest/change source to lose level after death to make something similar to roguelike games.
After death character level should be reset to 1 and whole inventory cleaned, it cna be done by source, quest, or force client to speak by player /ip /l 1, what ever, anyone know how to do it?

Link to comment
Share on other sites

  • Answers 12
  • Created
  • Last Reply

Top Posters For This Question

12 answers to this question

Recommended Posts

  • 0
  • Premium
Posted (edited)

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

  • 0

@ 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

Link to comment
Share on other sites

  • 0
  • Premium
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
Link to comment
Share on other sites

  • 0

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);

Link to comment
Share on other sites

  • 0
  • Premium
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?

 

 

 

Link to comment
Share on other sites

  • 0

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

Edited by Mefarious
Link to comment
Share on other sites

  • 0
  • Premium
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.

Link to comment
Share on other sites

  • -1
  • Premium
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;
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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.