Jump to content
Forgot your email address? ×
×
×
  • Create New...
  • 0

[C++] New CONFIG options.


AlexxD

Question

Hi Dev's, for three days untill now I've worked to do some options in gamesource for CONFIG's files from server, to make my job for server easier!

 

Now, first option:

 

First new option in config is players max status over CONFIG:

 

1. In cmd_general.cpp, after

extern int g_server_id;

add:

extern int gPlayerMaxStatus;
extern int gPlayerMaxHT;
extern int gPlayerMaxIQ;
extern int gPlayerMaxST;
extern int gPlayerMaxDX;

2. Also in cmd_general.cpp search

ACMD(do_stat)

and after

idx = POINT_IQ;

add:

if (ch->GetRealPoint(idx) >= gPlayerMaxStatus)
		checking = true;

	switch (idx) {
		case POINT_HT:
			if ((ch->GetRealPoint(idx) < gPlayerMaxHT))
				checking = false;
			else
				checking = true;
		case POINT_IQ:
			if (ch->GetRealPoint(idx) < gPlayerMaxIQ)
				checking = false;
			else
				checking = true;
		case POINT_ST:
			if (ch->GetRealPoint(idx) < gPlayerMaxST)
				checking = false;
			else
				checking = true;
		case POINT_DX:
			if (ch->GetRealPoint(idx) < gPlayerMaxDX)
				checking = false;
			else
				checking = true;
	}

	if(checking==true)
		return;

3. Well done, pro metiners. :D Now in cmd_gm.cpp after

DropEvent_RefineBox_SetValue(const std::string& name, int value);

add:

extern int gPlayerMaxStatus;
extern int gPlayerMaxHT;
extern int gPlayerMaxIQ;
extern int gPlayerMaxST;
extern int gPlayerMaxDX;

4. Also in cmd_gm.cpp search

ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cannot set stat under initial stat."));

and you'll see something, a little bit down:

if (nPoint > 

change it with:

if (nPoint > gPlayerMaxStatus)
		{
			nChangeAmount -= nPoint - gPlayerMaxStatus;
			nPoint = gPlayerMaxStatus;
		}

5. Good. Now in config.cpp we'll need to insert our variables, to be read by rest of files! After

int gPlayerMaxLevel

add:

int gPlayerMaxStatus = 90;
int gPlayerMaxHT = 32767;
int gPlayerMaxIQ = 32767;
int gPlayerMaxST = 32767;
int gPlayerMaxDX = 32767;

6. After, search

TOKEN ("block_char_creation")

and after it add:

TOKEN("max_status")
		{
			str_to_number(gPlayerMaxStatus, value_string);
			
			gPlayerMaxStatus = MINMAX(1, gPlayerMaxStatus, 32767);

			if(gPlayerMaxHT==32767)
				gPlayerMaxHT = gPlayerMaxStatus;

			if(gPlayerMaxIQ==32767)
				gPlayerMaxIQ = gPlayerMaxStatus;

			if(gPlayerMaxST==32767)
				gPlayerMaxST = gPlayerMaxStatus;

			if(gPlayerMaxDX==32767)
				gPlayerMaxDX = gPlayerMaxStatus;

			fprintf(stderr, "PLAYER_MAX_STATUS: %dn", gPlayerMaxStatus);
		}
		
		TOKEN("max_ht")
		{
			str_to_number(gPlayerMaxHT, value_string);

			gPlayerMaxHT = MINMAX(1, gPlayerMaxHT, 32767);

			fprintf(stderr, "PLAYER_MAX_HT: %dn", gPlayerMaxHT);
		}
		
		TOKEN("max_iq")
		{
			str_to_number(gPlayerMaxIQ, value_string);

			gPlayerMaxIQ = MINMAX(1, gPlayerMaxIQ, 32767);

			fprintf(stderr, "PLAYER_MAX_IQ: %dn", gPlayerMaxIQ);
		}
		
		TOKEN("max_st")
		{
			str_to_number(gPlayerMaxST, value_string);

			gPlayerMaxST = MINMAX(1, gPlayerMaxST, 32767);

			fprintf(stderr, "PLAYER_MAX_ST: %dn", gPlayerMaxST);
		}
		
		TOKEN("max_dx")
		{
			str_to_number(gPlayerMaxDX, value_string);

			gPlayerMaxDX = MINMAX(1, gPlayerMaxDX, 32767);

			fprintf(stderr, "PLAYER_MAX_DX: %dn", gPlayerMaxDX);
		}

7. The last thing we need to do, is that we'll need to put extern's variables in config.h. Search

extern int gPlayerMaxLevel;

and add after it:

extern int gPlayerMaxStatus;
extern int gPLayerMaxHT;
extern int gPLayerMaxIQ;
extern int gPLayerMaxST;
extern int gPLayerMaxDX;

8. Well done. Warning. Once you do that, you'll need to put in CONFIG's files from game99 and channels that:

max_status: (from 0 to 32767)
max_ht: (from 0 to 32767)
max_iq: (from 0 to 32767)
max_st: (from 0 to 32767)
max_dx: (from 0 to 32767)

9. After that, if you do like me, you need to change POINT_VT, IQ, ST and DX from some files, to read it from CONFIG. In cmd_gm.cpp search

case POINT_HT : //

and change from case POINT_HT untill POINT_DX with:

case POINT_HT : // 체력
			if (nPoint + ch->GetPoint(POINT_HT) > gPlayerMaxHT)
			{
				nPoint = gPlayerMaxHT - ch->GetPoint(POINT_HT);
			}
			break;

		case POINT_IQ : // 지능
			if (nPoint + ch->GetPoint(POINT_IQ) > gPlayerMaxIQ)
			{
				nPoint = gPlayerMaxIQ - ch->GetPoint(POINT_IQ);
			}
			break;
			
		case POINT_ST : // 근력
			if (nPoint + ch->GetPoint(POINT_ST) > gPlayerMaxST)
			{
				nPoint = gPlayerMaxST - ch->GetPoint(POINT_ST);
			}
			break;
			
		case POINT_DX : // 민첩
			if (nPoint + ch->GetPoint(POINT_DX) > gPlayerMaxDX)
			{
				nPoint = gPlayerMaxDX - ch->GetPoint(POINT_DX);
			}
			break;

10. There you go. Enjoy. You're done!

  • Love 4

"Don't be a scammer. Don't be a hacker. Don't be a motherfucker. Karma is a bitch"

Link to comment

11 answers to this question

Recommended Posts

  • 0

Nice :D From Vanilla Sourcecode

whew then vanilla must've made a little bit of a mess :D

Let's play a little scenario. Here's what you'd do to have a bug in your CONFIG:

MAX_HT: 32767

MAX_STATUS: 100

 

In this case, when the gamefile reads your max-status, it'll do the following statement:

            if(gPlayerMaxHT==32767)

                gPlayerMaxHT = gPlayerMaxStatus;

 

So what happened to our max_ht of 32767? Yep, it's now 100. Though I guess no one will use 32767 I think it still counts as a bug.

 

Also I don't know why the variable isn't short int.. since.. well.. 32767 is the max length of short int. So it'd make more sense to chose short int :)

Link to comment
  • 0

 

Nice :D From Vanilla Sourcecode

whew then vanilla must've made a little bit of a mess :D

Let's play a little scenario. Here's what you'd do to have a bug in your CONFIG:

MAX_HT: 32767

MAX_STATUS: 100

 

In this case, when the gamefile reads your max-status, it'll do the following statement:

            if(gPlayerMaxHT==32767)

                gPlayerMaxHT = gPlayerMaxStatus;

 

So what happened to our max_ht of 32767? Yep, it's now 100. Though I guess no one will use 32767 I think it still counts as a bug.

 

Also I don't know why the variable isn't short int.. since.. well.. 32767 is the max length of short int. So it'd make more sense to chose short int :)

 

You're right but I don't know why're you talking at third person.. Whatever, there's some people who loves Pokemon Metin2 and if they want int then they can use max value of it, not short int but if they want this they'll gonna change that 32767 with the max value of int, from config.cpp and cmd_general.cpp if I'm don't wrong. :/ I don't tested it with different value, i put them to not 'bug' the server. In some servers I saw 90 VIT, 95 INT, 90 STR, 90 DEX. And it's from gamefiles, not with another adds.

"Don't be a scammer. Don't be a hacker. Don't be a motherfucker. Karma is a bitch"

Link to comment
  • 0

I talked at third person to give an example from the perspective of a normal user and.. well, nevermind.

then why not at first use short int? If they want to raise the value above 32767 (which in normal cases doesn't happen) they'd also just change the datatype. Generally using int takes more memory and isn't the way you'd write your programs. If you don't need more, then just don't waste your resources on that ;)

  • Love 2
Link to comment
  • 0
  • Former Staff

why didn't you just make it like this

 

PLAYER_MAX_STATUS // in the config

 

no one will set the HT 100 and IQ 95 O.o <--- for example

 

sorry for my bad english

Link to comment
  • 0

why didn't you just make it like this

 

PLAYER_MAX_STATUS // in the config

 

no one will set the HT 100 and IQ 95 O.o <--- for example

 

sorry for my bad english

Yes but for those who wants diferite values like HT 3000 and VT 2000, with MAX_STATUS = 4000.. :D

 

I talked at third person to give an example from the perspective of a normal user and.. well, nevermind.

then why not at first use short int? If they want to raise the value above 32767 (which in normal cases doesn't happen) they'd also just change the datatype. Generally using int takes more memory and isn't the way you'd write your programs. If you don't need more, then just don't waste your resources on that ;)

You can use short int when you use values begin from 0 to 32767. the value of int is big, what you saying is true, but for those who wants extremely values on them servers, can use int value. ;)

"Don't be a scammer. Don't be a hacker. Don't be a motherfucker. Karma is a bitch"

Link to comment
  • 0
On 23/05/2015 at 6:30 PM, DeeJaYSooN said:
The error says that you did not declare the "checking", to solve your problem you must add the
"bool checking = false;" below

ACMD(do_stat)
{
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));

 

Like this:

ACMD(do_stat)
{
	char arg1[256];
	one_argument(argument, arg1, sizeof(arg1));
	bool checking = false;

 

Link to comment

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

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


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.