Jump to content
UPDATE 2 - External pictures are being replaced... ×
×
×
  • Create New...

Lock / UnLock / Reset Exp Ring


Recommended Posts

  • Bot

M2 Download Center

This is the hidden content, please
( Internal )

Open char.cpp and find this function 

void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast)

Search the case POINT_EXP and replace with this:

case POINT_EXP:
			{
				if (GetQuestFlag("exp_block") == 0) {

					DWORD exp = GetExp();
					DWORD next_exp = GetNextExp();

					if (amount < 0 && exp < -amount)
					{
						sys_log(1, "%s AMOUNT < 0 %d, CUR EXP: %d", GetName(), -amount, exp);
						amount = -exp;
						SetExp(exp + amount);
						val = GetExp();
					}
					else
					{
						if (gPlayerMaxLevel <= GetLevel())
							return;

						if (test_server)
							ChatPacket(CHAT_TYPE_INFO, "You have gained %d exp.", amount);

						DWORD iExpBalance = 0;

						if (exp + amount >= next_exp)
						{
							iExpBalance = (exp + amount) - next_exp;
							amount = next_exp - exp;

							SetExp(0);
							exp = next_exp;
						}
						else
						{
							SetExp(exp + amount);
							exp = GetExp();
						}

						DWORD q = DWORD(next_exp / 4.0f);
						int iLevStep = GetRealPoint(POINT_LEVEL_STEP);
						
						if (iLevStep >= 4)
						{
							sys_err("%s LEVEL_STEP bigger than 4! (%d)", GetName(), iLevStep);
							iLevStep = 4;
						}

						if (exp >= next_exp && iLevStep < 4)
						{
							for (int i = 0; i < 4 - iLevStep; ++i)
								PointChange(POINT_LEVEL_STEP, 1, false, true);
						}
						else if (exp >= q * 3 && iLevStep < 3)
						{
							for (int i = 0; i < 3 - iLevStep; ++i)
								PointChange(POINT_LEVEL_STEP, 1, false, true);
						}
						else if (exp >= q * 2 && iLevStep < 2)
						{
							for (int i = 0; i < 2 - iLevStep; ++i)
								PointChange(POINT_LEVEL_STEP, 1, false, true);
						}
						else if (exp >= q && iLevStep < 1)
							PointChange(POINT_LEVEL_STEP, 1);

						if (iExpBalance)
						{
							PointChange(POINT_EXP, iExpBalance);
						}

						val = GetExp();
					}
				}else{
					val = GetExp();
				}
			}
			break;

Now open Questlua_pc.cpp and add this in the namespace quest:

    int pc_block_exp(lua_State* L)
    {
        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        if (!lua_isnumber(L, 1)) {
            return 0;
        }
	int type=lua_tonumber(L,1);
	ch->SetQuestFlag("exp_block", type);
        if (type == 0) {
            ch->ChatPacket(CHAT_TYPE_INFO, "<ExpBlockSystem> [%d] You unlock your experience.", ch->GetQuestFlag("exp_block"));
        }else{
            ch->ChatPacket(CHAT_TYPE_INFO, "<ExpBlockSystem> [%d] You lock your experience.", ch->GetQuestFlag("exp_block"));
        }
        return 0;
    }

And this in the RegisterPCFunctionTable:

{ "block_exp",        pc_block_exp        },

Now compile your source, and try this quest:

quest ExpBlockQuest begin
    state start begin
        when 72501.use begin
            say_title("Block EXP Ring:")
            say("")
            local s = select("Lock EXP", "Unlock EXP", "Reset EXP", "Close")
            if s == 1 then
                pc.block_exp(1)
                setskin(NOWINDOW)
            elseif s == 2 then
                pc.block_exp(0)
                setskin(NOWINDOW)
            elseif s == 3 then
                say_title("Block EXP Ring:")
                say("")    
                say("Are you sure to reset[ENTER]your EXP points: "..pc.get_exp().."?")            
                local s2=select("Yes", "No")
                if s2 == 1 then
                    pc.block_exp(0)
                    pc.give_exp2(-pc.get_exp())
                    syschat("<ExpBlockSystem> You reset your experience.")
                    setskin(NOWINDOW)
                end
            end
        end
    end
end  

 

  • Metin2 Dev 2
  • Love 2
  • Good 1

english_banner.gif

Link to comment
Share on other sites

Why not?

Quote
        int type=lua_tonumber(L,1);
        PC* Check = CQuestManager::Instance().GetCurrentPC();
        Check->SetFlag("exp_block", type);
ch->SetQuestFlag("exp_block", type);

 

Quote
        if (type == 0) {
            ch->ChatPacket(CHAT_TYPE_INFO, "<ExpBlockSystem> [%d] You unlock your experience.", Check->GetFlag("exp_block"));
        }else{
            ch->ChatPacket(CHAT_TYPE_INFO, "<ExpBlockSystem> [%d] You lock your experience.", Check->GetFlag("exp_block"));
        }
ch->ChatPacket(CHAT_TYPE_INFO, "<ExpBlockSystem> [%d] You %s your experience.", ch->GetQuestFlag("exp_block"), (type == 0 ? "lock" : "unlock"));
  • Love 1
Link to comment
Share on other sites

  • 5 weeks later...
  • 3 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.


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.