Jump to content
  • 0

How to get JobEXP to a variable when mob killed?


Question

Posted

Hey, guys. 

I want to know if it's possible to set the job experience gained from a killed mob to a variable. Look, the default script is something like this:

OnNPCKillEvent:

if(killedrid == ID_MOB) {set variable, variable + X_POINTS;}

By this way, i have to set the ID_MOB wich will give the X_POINTS, and how many points it will give. I was wonderwing if it's possible to do something like this:

OnNPCKillEvent:

set variable, variable + X_POINTS;

I want to get the X_POINTS exactly the same as shown at @showexp command. It's too much work setting mob by mob and it's X_POINTS. Another problem is the job_exp_rate and the renewal levelling. 

22 answers to this question

Recommended Posts

  • 0
Posted (edited)

I don't know if this can work.

-	script	Mob_Exp	-1,{

OnInit:

	if(checkre(RENEWAL_EXP)) {
		setarray .penalty[0],	16,40,
					15,115,
					14,120,
					13,125,
					12,130,
					11,135,
					10,140,
					9,135,
					8,130,
					7,125,
					6,120,
					5,115,
					4,110,
					3,105,
					-1,100,
					-6,95,
					-11,90,
					-16,85,
					-21,60,
					-26,35,
					-31,10;

		for(.@size = getarraysize(.penalty);.@i < .@size;.@i+=2) {
			.@diff = .penalty[.@i];
			if(.@diff < 0) 
				.penalty[.@i] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
		}
	}
	end;

OnNPCKillEvent.

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(checkre(RENEWAL_EXP) && .@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		.@mod = inarray(.penalty,.@lvl_dif);
		if(.@mod != -1 && .@mod%2 == 0)
			.@exp_gained*= .penalty[.@mod + 1];
	}
	dispbottom "You gained "+F_InsertComma(.@exp_gained)+" job exp.";
	end;

}

 

Edited by n0tttt
Ups, fixed OnInit loop
  • 0
Posted
40 minutes ago, n0tttt said:

I don't know if this can work.


-	script	Mob_Exp	-1,{

OnInit:

	if(checkre(RENEWAL_EXP)) {
		setarray .penalty[0],	16,40,
					15,115,
					14,120,
					13,125,
					12,130,
					11,135,
					10,140,
					9,135,
					8,130,
					7,125,
					6,120,
					5,115,
					4,110,
					3,105,
					-1,100,
					-6,95,
					-11,90,
					-16,85,
					-21,60,
					-26,35,
					-31,10;

		for(.@size = getarraysize(.penalty);.@i < .@size;.@i+=2) {
			.@diff = .penalty[.@i*2];
			if(.@diff < 0) 
				.penalty[.@i*2] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
		}
	}
	end;

OnNPCKillEvent.

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(checkre(RENEWAL_EXP) && .@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		.@mod = inarray(.penalty,.@lvl_dif);
		if(.@mod != -1 && .@mod%2 == 0)
			.@exp_gained*= .penalty[.@mod + 1];
	}
	dispbottom "You gained "+F_InsertComma(.@exp_gained)+" job exp.";
	end;

}

 

I'm getting an error with this:

image.png.eff8399611867e12f753a3f9bd2e26e5.png

  • 0
Posted
20 minutes ago, n0tttt said:

Change every instance of


checkre(RENEWAL_EXP)

 with checkre(3) then. I thought it used consts.

Mate, still get the same error. This "if" is checking if i'm using renewal_exp or not? Cause if it this, i think it's unnecessary.

This code will help me with "mastery" leveling. Instead of typing each monster X_POINTS, code will get their job_exp. I've already set how much experience each level will require to lvl up, just like db\re\job_exp.txt.

Here's my code:

-	script	Fishing_Exp	-1,{
	
	OnInit:
	
	if(checkre(3)) {
		setarray .penalty[0],	16,40,
					15,115,
					14,120,
					13,125,
					12,130,
					11,135,
					10,140,
					9,135,
					8,130,
					7,125,
					6,120,
					5,115,
					4,110,
					3,105,
					-1,100,
					-6,95,
					-11,90,
					-16,85,
					-21,60,
					-26,35,
					-31,10;

		for(.@size = getarraysize(.penalty);.@i < .@size;.@i+=2) {
			.@diff = .penalty[.@i*2];
			if(.@diff < 0) 
				.penalty[.@i*2] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
		}
	}

setArray .FishingLvl[0],
1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

set .MaxFishingLvl, getarraysize(.FishingLvl);

end;

OnNPCKillEvent:

if (fishing !=1) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(checkre(3) && .@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		.@mod = inarray(.penalty,.@lvl_dif);
		if(.@mod != -1 && .@mod%2 == 0)
			.@exp_gained*= .penalty[.@mod + 1];
			set FishingExp, FishingExp + .@exp_gained;
	}
set FishingExp, FishingExp + 1;
if(.FishingLvl[FishingLvl] <= FishingExp && FishingLvl < .MaxFishingLvl){
	set FishingLvl, FishingLvl + 1;
	dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
	set FishingExp,0;
	if(FishingLvl == .MaxFishingLvl) {
		dispbottom "Your Fishing Mastery is at maximum level.";
}
}

end;
}

 

  • 0
Posted

And like this?

-	script	Fishing_Exp	-1,{

OnInit:
	
	setarray .penalty[0],	16,40,
				15,115,
				14,120,
				13,125,
				12,130,
				11,135,
				10,140,
				9,135,
				8,130,
				7,125,
				6,120,
				5,115,
				4,110,
				3,105,
				-1,100,
				-6,95,
				-11,90,
				-16,85,
				-21,60,
				-26,35,
				-31,10;

	for(.@size = getarraysize(.penalty);.@i < .@size;.@i+=2) {
		.@diff = .penalty[.@i];
		if(.@diff < 0) 
			.penalty[.@i] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
	}

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		.@mod = inarray(.penalty,.@lvl_dif);
		if(.@mod != -1 && .@mod%2 == 0)
			.@exp_gained*= .penalty[.@mod + 1];
	}
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

 

  • 0
Posted (edited)
19 minutes ago, n0tttt said:

And like this?


-	script	Fishing_Exp	-1,{

OnInit:
	
	setarray .penalty[0],	16,40,
				15,115,
				14,120,
				13,125,
				12,130,
				11,135,
				10,140,
				9,135,
				8,130,
				7,125,
				6,120,
				5,115,
				4,110,
				3,105,
				-1,100,
				-6,95,
				-11,90,
				-16,85,
				-21,60,
				-26,35,
				-31,10;

	for(.@size = getarraysize(.penalty);.@i < .@size;.@i+=2) {
		.@diff = .penalty[.@i];
		if(.@diff < 0) 
			.penalty[.@i] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
	}

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		.@mod = inarray(.penalty,.@lvl_dif);
		if(.@mod != -1 && .@mod%2 == 0)
			.@exp_gained*= .penalty[.@mod + 1];
	}
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

 

I think it's working, but i've got this problem:

image.png.ac3c887caefcaddff8184b74a31bfffe.png

Script gives me 854,750 exp while i receive only 1709 job exp.

dispbottom is @showexp and:

dispbottom "You gained "+F_InsertComma(.@exp_gained)+" Fishing exp.";

 

Edited by LucianoCP
  • 0
Posted (edited)

What about this?

-	script	Fishing_Exp	-1,{

OnInit:
	
	setarray .penalty[0],	16,40,
				15,115,
				14,120,
				13,125,
				12,130,
				11,135,
				10,140,
				9,135,
				8,130,
				7,125,
				6,120,
				5,115,
				4,110,
				3,105,
				-1,100,
				-6,95,
				-11,90,
				-16,85,
				-21,60,
				-26,35,
				-31,10;

	for(.penalty_size = getarraysize(.penalty);.@i < .penalty_size;.@i+=2) {
		.@diff = .penalty[.@i];
		if(.@diff < 0) 
			.penalty[.@i] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
	}

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		for(;.@i < .penalty_size;.@i+=2) {
			if(.@lvl_dif >= .penalty[.@i])
				break;
		}
		if(.@i != .penalty_size)
			.@exp_gained*= .penalty[.@mi + 1];
	}
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

If not, I can think of a "hacky" way by using JobExp.

-	script	Fishing_Exp	-1,{

OnInit:

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnPCLoginEvent:

	if(fishing)
		@jobexp = JobExp;
	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery
	.@exp_gained = JobExp - @jobexp;
	@jobexp = JobExp;
	dispbottom "You gained "+F_InsertComma(.@exp_gained)+" job exp.";
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

but you might need to add:

@jobexp = JobExp;

in your fishing script after set fishing,1;

Edited by n0tttt
  • 0
Posted
8 hours ago, n0tttt said:

What about this?


-	script	Fishing_Exp	-1,{

OnInit:
	
	setarray .penalty[0],	16,40,
				15,115,
				14,120,
				13,125,
				12,130,
				11,135,
				10,140,
				9,135,
				8,130,
				7,125,
				6,120,
				5,115,
				4,110,
				3,105,
				-1,100,
				-6,95,
				-11,90,
				-16,85,
				-21,60,
				-26,35,
				-31,10;

	for(.penalty_size = getarraysize(.penalty);.@i < .penalty_size;.@i+=2) {
		.@diff = .penalty[.@i];
		if(.@diff < 0) 
			.penalty[.@i] = min(MAX_LEVEL + (~(.@diff) + 1),MAX_LEVEL*2);
	}

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@rates = getbattleflag("job_exp_rate");
	.@exp_gained = .@mob_jexp*.@rates/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		for(;.@i < .penalty_size;.@i+=2) {
			if(.@lvl_dif >= .penalty[.@i])
				break;
		}
		if(.@i != .penalty_size)
			.@exp_gained*= .penalty[.@mi + 1];
	}
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

If not, I can think of a "hacky" way by using JobExp.


-	script	Fishing_Exp	-1,{

OnInit:

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnPCLoginEvent:

	if(fishing)
		@jobexp = JobExp;
	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery
	.@exp_gained = JobExp - @jobexp;
	@jobexp = JobExp;
	dispbottom "You gained "+F_InsertComma(.@exp_gained)+" job exp.";
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

but you might need to add:


@jobexp = JobExp;

in your fishing script after set fishing,1;

 

Mate, i've found the error. It doesn't need to set the .@rates as multiplier, because when the scripts gets the strmobinfo(7,killerid), the rates are already applied. Look, my rates are 500x. So, 854,750/500 = 1.709,5. The screenshot display jobexp = 1709. (;

  • 0
Posted
4 minutes ago, n0tttt said:

Nice find man.

Anyways I had a typo.


.@exp_gained*= .penalty[.@mi + 1];

has to be


.@exp_gained*= .penalty[.@i + 1];

Ok, it's not 100% right.

I'm using this code:

.@exp_gained = strmobinfo(7,killedrid)/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {	
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		.@mod = inarray(.penalty,.@lvl_dif);
		if(.@mod != -1 && .@mod%2 == 0)
			.@exp_gained*= .penalty[.@mod + 1];
	}

I'm killing a 29 lvl mob. If my lvl is higher than 26, this happens:

image.png.e784c58af6a9912f20663079147d1f82.png

if my lvl is equal or below 26, this:

image.png.d1c0d1d3ffdc66ad5c71f07d9979fa53.png

  • 0
Posted

And like this?

	.@exp_gained = strmobinfo(7,killedrid)/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		for(;.@i < .penalty_size;.@i+=2) {
			if(.@lvl_dif >= .penalty[.@i])
				break;
		}
		if(.@i != .penalty_size)
			.@exp_gained*= .penalty[.@i + 1];
	}

 

  • 0
Posted (edited)
20 minutes ago, n0tttt said:

And like this?


	.@exp_gained = strmobinfo(7,killedrid)/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		for(;.@i < .penalty_size;.@i+=2) {
			if(.@lvl_dif >= .penalty[.@i])
				break;
		}
		if(.@i != .penalty_size)
			.@exp_gained*= .penalty[.@i + 1];
	}

 

still wrong ?

By .@exp_gained = strmobinfo(7,killedrid) i get exactly "mob_job_exp" from mob.db * job_rate. From that, we need to improve the "renewal leveling" thing. I could do a bunch of "if"s, but i don't know if this is the best way. something like:

.@exp_gained = strmobinfo(7,killedrid)
.@mob_lvl = strmobinfo(3,killedrid)
.@lvl_dif = .@mob_lvl - BaseLevel
  
if (.@lvl_dif == 10) { //if the mob has 10 lvls more than you, exp gets buffed by 40%
	set .@exp_gained, .@expgained*1.4
}

I don't know how to work on arrays (neither basic script haha). Hope this provides a north for you.

Edited by LucianoCP
  • 0
Posted
	.@exp_gained = strmobinfo(7,killedrid)/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		for(;.@i < .penalty_size;.@i+=2) {
			if(.@lvl_dif >= .penalty[.@i])
				break;
		}
		if(.@i != .penalty_size)
			.@exp_gained*= .penalty[.@i + 1]/100;
	}

And manual values:

-	script	Fishing_Exp	-1,{

OnInit:

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@exp_gained = .@mob_jexp;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif <= -31)
			.@exp_gained*= 10;
		else if(.@lvl_dif <= -26)
			.@exp_gained*= 35;
		else if(.@lvl_dif <= -21)
			.@exp_gained*= 60;
		else if(.@lvl_dif <= -16)
			.@exp_gained*= 85;
		else if(.@lvl_dif <= -11)
			.@exp_gained *= 90;
		else if(.@lvl_dif <= -6)
			.@exp_gained*= 95;
		else if(.@lvl_dif <= -1)
			.@exp_gained*= 100;
		else if(.@lvl_dif <= 3)
			.@exp_gained*= 105;
		else if(.@lvl_dif <= 4)
			.@exp_gained*= 110;
		else if(.@lvl_dif <= 5)
			.@exp_gained*= 115;
		else if(.@lvl_dif <= 6)
			.@exp_gained*= 120;
		else if(.@lvl_dif <= 7)
			.@exp_gained*= 125;
		else if(.@lvl_dif <= 8)
			.@exp_gained*= 130;
		else if(.@lvl_dif <= 9)
			.@exp_gained*= 135;
		else if(.@lvl_dif <= 10)
			.@exp_gained*= 140;
		else if(.@lvl_dif <= 11)
			.@exp_gained*= 135;
		else if(.@lvl_dif <= 12)
			.@exp_gained*= 130;
		else if(.@lvl_dif <= 13)
			.@exp_gained*= 125;
		else if(.@lvl_dif <= 14)
			.@exp_gained*= 120;
		else if(.@lvl_dif <= 15)
			.@exp_gained*= 115;
		else
			.@exp_gained*= 40;
		.@exp_gained/= 100;
	}
	dispbottom "You gained "+F_InsertComma(.@exp_gained)+" job exp.";
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

 

  • 0
Posted
1 hour ago, n0tttt said:

	.@exp_gained = strmobinfo(7,killedrid)/100;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif < 0)
			.@lvl_dif = MAX_LEVEL + (~(.@lvl_dif) + 1);
		for(;.@i < .penalty_size;.@i+=2) {
			if(.@lvl_dif >= .penalty[.@i])
				break;
		}
		if(.@i != .penalty_size)
			.@exp_gained*= .penalty[.@i + 1]/100;
	}

And manual values:


-	script	Fishing_Exp	-1,{

OnInit:

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

	.@mob_jexp = strmobinfo(7,killedrid);
	.@exp_gained = .@mob_jexp;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if(.@lvl_dif != 0) {		
		if(.@lvl_dif <= -31)
			.@exp_gained*= 10;
		else if(.@lvl_dif <= -26)
			.@exp_gained*= 35;
		else if(.@lvl_dif <= -21)
			.@exp_gained*= 60;
		else if(.@lvl_dif <= -16)
			.@exp_gained*= 85;
		else if(.@lvl_dif <= -11)
			.@exp_gained *= 90;
		else if(.@lvl_dif <= -6)
			.@exp_gained*= 95;
		else if(.@lvl_dif <= -1)
			.@exp_gained*= 100;
		else if(.@lvl_dif <= 3)
			.@exp_gained*= 105;
		else if(.@lvl_dif <= 4)
			.@exp_gained*= 110;
		else if(.@lvl_dif <= 5)
			.@exp_gained*= 115;
		else if(.@lvl_dif <= 6)
			.@exp_gained*= 120;
		else if(.@lvl_dif <= 7)
			.@exp_gained*= 125;
		else if(.@lvl_dif <= 8)
			.@exp_gained*= 130;
		else if(.@lvl_dif <= 9)
			.@exp_gained*= 135;
		else if(.@lvl_dif <= 10)
			.@exp_gained*= 140;
		else if(.@lvl_dif <= 11)
			.@exp_gained*= 135;
		else if(.@lvl_dif <= 12)
			.@exp_gained*= 130;
		else if(.@lvl_dif <= 13)
			.@exp_gained*= 125;
		else if(.@lvl_dif <= 14)
			.@exp_gained*= 120;
		else if(.@lvl_dif <= 15)
			.@exp_gained*= 115;
		else
			.@exp_gained*= 40;
		.@exp_gained/= 100;
	}
	dispbottom "You gained "+F_InsertComma(.@exp_gained)+" job exp.";
	set FishingExp, FishingExp + .@exp_gained;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

  

Wow, just saw it now. I've made manual "if"s too. So, here's my code:

-	script	Fishing_Exp	-1,{

OnInit:

	setarray .FishingLvl[0],
	1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
	41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
	90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
	213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
	474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
	873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
	1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
	2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

	end;

OnNPCKillEvent:

	if (fishing !=1 || FishingvLvl >= .MaxFishingLvl) {end;} //this will check if he made a quest to learn the mastery

.@mob_jexp = strmobinfo(7,killedrid);
	.@exp_gained = .@mob_jexp;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if (.@lvl_dif >= 16) {set .@exp_gained, .@exp_gained*40;}
	if (.@lvl_dif == 15 || .@lvl_dif == 5) {set .@exp_gained, .@exp_gained*115;}
	if (.@lvl_dif == 14 || .@lvl_dif == 6) {set .@exp_gained, .@exp_gained*120;}
	if (.@lvl_dif == 13 || .@lvl_dif == 7) {set .@exp_gained, .@exp_gained*125;}
	if (.@lvl_dif == 12 || .@lvl_dif == 8) {set .@exp_gained, .@exp_gained*130;}
	if (.@lvl_dif == 11 || .@lvl_dif == 9) {set .@exp_gained, .@exp_gained*135;}
	if (.@lvl_dif == 10) {set .@exp_gained, .@exp_gained*140;}
	if (.@lvl_dif == 4) {set .@exp_gained, .@exp_gained*110;}
	if (.@lvl_dif == 3) {set .@exp_gained, .@exp_gained*105;}
	if (.@lvl_dif <= 2 && .@lvl_dif >= -5) {set .@exp_gained, .@exp_gained*100;}
	if (.@lvl_dif <= -6 && .@lvl_dif >= -10) {set .@exp_gained, .@exp_gained*95;}
	if (.@lvl_dif <= -11 && .@lvl_dif >= -15) {set .@exp_gained, .@exp_gained*90;}
	if (.@lvl_dif <= -16 && .@lvl_dif >= -20) {set .@exp_gained, .@exp_gained*85;}
	if (.@lvl_dif <= -21 && .@lvl_dif >= -25) {set .@exp_gained, .@exp_gained*60;}
	if (.@lvl_dif <= -26 && .@lvl_dif >= -30) {set .@exp_gained, .@exp_gained*35;}
	if (.@lvl_dif <= -31) {set .@exp_gained, .@exp_gained*10;}
set .@exp_gained,.@exp_gained/100;
dispbottom "Experience Gained Mastery: "+.@exp_gained+" ("+(.@exp_gained*100)/.FishingLvl[FishingLvl]+"%)";
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;
}

I made a dispbottom similar to @showexp, but if the gained experience is below 1% to lvl up the fishing, it says "0%".

Look:

dispbottom "Experience Gained Mastery: "+.@exp_gained+" ("+(.@exp_gained*100)/.FishingLvl[FishingLvl]+"%)";

What can i do for it to show something like "Experience Gained Mastery: 318 (0.25%)" instead of "Experience Gained Mastery: 318 (0%)"?

  • 0
Posted
1 hour ago, LucianoCP said:

Wow, just saw it now. I've made manual "if"s too. So, here's my code:

I made a dispbottom similar to @showexp, but if the gained experience is below 1% to lvl up the fishing, it says "0%".

Look:


dispbottom "Experience Gained Mastery: "+.@exp_gained+" ("+(.@exp_gained*100)/.FishingLvl[FishingLvl]+"%)";

What can i do for it to show something like "Experience Gained Mastery: 318 (0.25%)" instead of "Experience Gained Mastery: 318 (0%)"?

Try to use this function

function	script	porcentagem	{
	return (getarg(0) / 100)+"."+(((getarg(0) % 100) <= 9) ? "0" : "")+""+(getarg(0) % 100)+"%";
}

calling with your array like this

"+callfunc("porcentagem", YourArrayHere+").",0;

 

  • 0
Posted (edited)
5 hours ago, Rizta said:

Try to use this function


function	script	porcentagem	{
	return (getarg(0) / 100)+"."+(((getarg(0) % 100) <= 9) ? "0" : "")+""+(getarg(0) % 100)+"%";
}

 calling with your array like this


"+callfunc("porcentagem", YourArrayHere+").",0;

 

Thanks, mate. It worked, but the showed value is wrong. This is what i've made:

dispbottom "Gained "+.@exp_gained+"("+callfunc("porcentagem", (.@exp_gained*100)/.FishingLvl[FishingLvl])+") mastery points.",0;

function	script	porcentagem	{
	return (getarg(0) / 100)+"."+(((getarg(0) % 100) <= 9) ? "0" : "")+""+(getarg(0) % 100)+"%";
}

I killed a mob who gives me 3% exp based on this code:

dispbottom "Gained "+.@exp_gained+" ("+(.@exp_gained*100)/.FishingLvl[FishingLvl]+"%) mastery points.";

I set the FishingLvl and JobLvl to 12 and this happens:

image.png.a00a218ac195656b17877179ffea82d8.png

Edited by LucianoCP
  • 0
Posted

I have this function by Tokeiburu.

function	script	get_decimal	{
	.@x = getarg(0);
	.@y = getarg(1);

	.@precision = getarg(2,2); // The amount of digits to keep after the dot
	.@mod = pow(10, .@precision);
	.@left = .@x / .@y;
	.@right = (.@x * .@mod / .@y) % .@mod;
	.@result$ = "" + .@left;

	if (!.@right)
		return .@result$;

	// Removes trailing zeroes, for example:
	// With .@zeroes set to 0, 5 / 2 will output 2.5
	// With .@zeroes set to 1, 5 / 2 will output 2.50
	.@zeroes = 0;

	for (.@i = 0; .@i < .@precision; .@i++) {
		.@digit = .@right % 10;
		.@right = .@right / 10;

		if (!.@zeroes) {
			if (.@digit == 0)
				continue;

			.@output$ = insertchar(.@output$, .@digit + "", 0);
			.@zeroes = 1;
		}
		else {
			.@output$ = insertchar(.@output$, .@digit + "", 0);
		}
	}

	return .@result$ + "," + .@output$;
}

 

	dispbottom "Gained "+.@exp_gained+" mastery points ("+get_decimal(.FishingLvl[FishingLvl]*100,.@exp_gained)+")%.";

 

  • 0
Posted
35 minutes ago, n0tttt said:

I have this function by Tokeiburu.


function	script	get_decimal	{
	.@x = getarg(0);
	.@y = getarg(1);

	.@precision = getarg(2,2); // The amount of digits to keep after the dot
	.@mod = pow(10, .@precision);
	.@left = .@x / .@y;
	.@right = (.@x * .@mod / .@y) % .@mod;
	.@result$ = "" + .@left;

	if (!.@right)
		return .@result$;

	// Removes trailing zeroes, for example:
	// With .@zeroes set to 0, 5 / 2 will output 2.5
	// With .@zeroes set to 1, 5 / 2 will output 2.50
	.@zeroes = 0;

	for (.@i = 0; .@i < .@precision; .@i++) {
		.@digit = .@right % 10;
		.@right = .@right / 10;

		if (!.@zeroes) {
			if (.@digit == 0)
				continue;

			.@output$ = insertchar(.@output$, .@digit + "", 0);
			.@zeroes = 1;
		}
		else {
			.@output$ = insertchar(.@output$, .@digit + "", 0);
		}
	}

	return .@result$ + "," + .@output$;
}

 


	dispbottom "Gained "+.@exp_gained+" mastery points ("+get_decimal(.FishingLvl[FishingLvl]*100,.@exp_gained)+")%.";

 

expected ";"?

image.png.fecb703eb1b08d520639f9314b6a52ee.png

  • 0
Posted

The function has to load before the script.

Otherwise...

	function get_decimal;	
	dispbottom "Gained "+F_InsertComma(.@exp_gained+)" mastery points ("+get_decimal(.FishingLvl[FishingLvl]*100,.@exp_gained)+"%).";

 

  • 0
Posted
36 minutes ago, n0tttt said:

The function has to load before the script.

Otherwise...


	function get_decimal;	
	dispbottom "Gained "+F_InsertComma(.@exp_gained+)" mastery points ("+get_decimal(.FishingLvl[FishingLvl]*100,.@exp_gained)+"%).";

 

ok, the function is working, but i think the math is wrong.

i have .@exp_gained telling me the exp gained and i need to know what % this represents compared to the max (100%) exp at the .FishingLvl[FishingLvl] (let's call it X), so:

.FishingLvl[FishingLvl] = 100

.@exp_gained = X

.@exp_gained*100 = .FishingLvl[FishingLvl]*X

X = (.@exp_gained*100)/.FishingLvl[FishingLvl]

Now, i think i need to run this math in the function... Because if i run at the callfunction, it goes to natural numbers?

  • 0
Posted (edited)

Sorry. I don't know why I put the divisor first.

	set .@exp_gained,.@exp_gained/100;
	function get_decimal;
	dispbottom "Gained "+F_InsertComma(.@exp_gained+)" mastery points ("+get_decimal(.@exp_gained*100,.FishingLvl[FishingLvl])+"%).";
	FishingExp+= .@exp_gained;
	dispbottom "Total: "+F_InsertComma(FishingExp)+"/"+F_InsertComma(.FishingLvl[FishingLvl])+" ("+get_decimal(min(FishingExp,.FishingLvl[FishingLvl])*100,.FishingLvl[FishingLvl])+"%).";
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;

And yeah, you'll get natural numbers. In fact the function returns a string.

Edited by n0tttt
  • Love 1
  • 0
Posted
19 minutes ago, n0tttt said:

Sorry. I don't know why I put the divisor first.


	set .@exp_gained,.@exp_gained/100;
	function get_decimal;
	if(.FishingLvl[FishingLvl] > 1) {
		dispbottom "Gained "+F_InsertComma(.@exp_gained+)" mastery points ("+get_decimal(.@exp_gained*100,.FishingLvl[FishingLvl])+"%).";
		FishingExp+= .@exp_gained;
		dispbottom "Total: "+F_InsertComma(FishingExp)+"/"+F_InsertComma(.FishingLvl[FishingLvl])+" ("+get_decimal(min(FishingExp,.FishingLvl[FishingLvl])*100,.FishingLvl[FishingLvl])+"%).";
	}
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
		if(FishingLvl == .MaxFishingLvl) {
			dispbottom "Your Fishing Mastery is at maximum level.";
		}
	}
	end;

And yeah, you'll get natural numbers. In fact the function returns a string.

Thanks, mate! Running correctly now.

Here's the final code:

-	script	Fishing_Exp	-1,{
	
	OnInit:

	setArray .FishingLvl[0],
1, 3800, 6200, 10400, 15200, 22900, 27100, 30000, 32500, 35700,
41300, 45000, 45800, 47600, 50300, 58700, 63900, 67100, 70300, 73500,
90600, 96200, 102700, 110200, 121400, 144700, 152900, 163100, 173300, 183500,
213500, 224700, 236000, 247200, 260700, 299800, 324800, 343600, 362300, 374800,
474400, 497000, 512100, 542200, 564800, 644300, 678200, 712100, 754500, 796900,
873100, 911900, 950600, 989400, 1028100, 1143300, 1199900, 1233800, 1279100, 1324300,
1486900, 1515900, 1603000, 1719200, 1806300, 2040300, 2244300, 2415900, 2746000, 2746000,
2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000,
2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000, 2746000;

	set .MaxFishingLvl, getarraysize(.FishingLvl);

end;

OnNPCKillEvent:

	if(fishing != 1 || FishingLvl >= .MaxFishingLvl) {end;} //the (fishing != 1) check let only fisher players to lvl up their fishing mastery. Need to put "set fishing,1" in your Fishing Teacher NPC.

	.@mob_jexp = strmobinfo(7,killedrid);
	.@exp_gained = .@mob_jexp;
	.@mob_lvl = strmobinfo(3,killedrid);
	.@lvl_dif = .@mob_lvl - BaseLevel;
	if (.@lvl_dif >= 16) {set .@exp_gained, .@exp_gained*40;}
	if (.@lvl_dif == 15 || .@lvl_dif == 5) {set .@exp_gained, .@exp_gained*115;}
	if (.@lvl_dif == 14 || .@lvl_dif == 6) {set .@exp_gained, .@exp_gained*120;}
	if (.@lvl_dif == 13 || .@lvl_dif == 7) {set .@exp_gained, .@exp_gained*125;}
	if (.@lvl_dif == 12 || .@lvl_dif == 8) {set .@exp_gained, .@exp_gained*130;}
	if (.@lvl_dif == 11 || .@lvl_dif == 9) {set .@exp_gained, .@exp_gained*135;}
	if (.@lvl_dif == 10) {set .@exp_gained, .@exp_gained*140;}
	if (.@lvl_dif == 4) {set .@exp_gained, .@exp_gained*110;}
	if (.@lvl_dif == 3) {set .@exp_gained, .@exp_gained*105;}
	if (.@lvl_dif <= 2 && .@lvl_dif >= -5) {set .@exp_gained, .@exp_gained*100;}
	if (.@lvl_dif <= -6 && .@lvl_dif >= -10) {set .@exp_gained, .@exp_gained*95;}
	if (.@lvl_dif <= -11 && .@lvl_dif >= -15) {set .@exp_gained, .@exp_gained*90;}
	if (.@lvl_dif <= -16 && .@lvl_dif >= -20) {set .@exp_gained, .@exp_gained*85;}
	if (.@lvl_dif <= -21 && .@lvl_dif >= -25) {set .@exp_gained, .@exp_gained*60;}
	if (.@lvl_dif <= -26 && .@lvl_dif >= -30) {set .@exp_gained, .@exp_gained*35;}
	if (.@lvl_dif <= -31) {set .@exp_gained, .@exp_gained*10;}

	set .@exp_gained,.@exp_gained/100;
	set FishingExp, FishingExp + .@exp_gained + 1;
	if(.FishingLvl[FishingLvl] <= FishingExp){
		set FishingLvl, FishingLvl + 1;
		dispbottom "[Level Up] Congrats! Your Fishing level is now: "+FishingLvl;
		set FishingExp,0;
	}
	if(showmasteryexp) {dispbottom "Gained "+.@exp_gained+" ("+callfunc("get_decimal", .@exp_gained*100,.FishingLvl[FishingLvl])+"%) mastery points.";}
	end;
}

function	script	get_decimal	{
	.@x = getarg(0);
	.@y = getarg(1);

	.@precision = getarg(2,2); // The amount of digits to keep after the dot
	.@mod = pow(10, .@precision);
	.@left = .@x / .@y;
	.@right = (.@x * .@mod / .@y) % .@mod;
	.@result$ = "" + .@left;

	if (!.@right)
		return .@result$;

	// Removes trailing zeroes, for example:
	// With .@zeroes set to 0, 5 / 2 will output 2.5
	// With .@zeroes set to 1, 5 / 2 will output 2.50
	.@zeroes = 1;

	for (.@i = 0; .@i < .@precision; .@i++) {
		.@digit = .@right % 10;
		.@right = .@right / 10;

		if (!.@zeroes) {
			if (.@digit == 0)
				continue;

			.@output$ = insertchar(.@output$, .@digit + "", 0);
			.@zeroes = 1;
		}
		else {
			.@output$ = insertchar(.@output$, .@digit + "", 0);
		}
	}

	return .@result$ + "." + .@output$;
}

Here's an atcommand to set the dispbottom exp. Like @showexp, use @showmasteryexp to enable/disable it.

-	script	showmasteryexp	-1,{
    OnInit:
        bindatcmd("showmasteryexp", "showmasteryexp::OnAtCmd");

        end;
        
    OnAtCmd:
		if (showmasteryexp) {
			message strcharinfo(0),"Gained Mastery EXP will not be shown.";
			set showmasteryexp,0;
		} else {
			message strcharinfo(0),"Gained Mastery EXP is now shown.";
			set showmasteryexp,1;
		}
        end;
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...