Jump to content
  • 0

Custom Points


Dolphin86

Question


  • Group:  Members
  • Topic Count:  255
  • Topics Per Day:  0.06
  • Content Count:  706
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

situation :

1. Player talks to NPC A and do task, when complete player get @custom_points
2. Player can view his current @custom_points by using a useable item (call function i have this cover but not on showing the current total @custom_points)
3. Player can spend the @custom_points from statement above 

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  132
  • Reputation:   53
  • Joined:  06/02/12
  • Last Seen:  

Hi. Yeah, giving custom points to things like Blacksmith' weapon forging, or Alchemist's potion creation is not possible with default scripting.
But if it's "crafting" using NPCs, its simple using variables.

"custom_points" is not the same as "@custom_points".
@variables are lost when the player logout.
Just remove the @ and the points will stay.
More here: (from \doc\script_commands.txt)

Spoiler
Variables are divided into and uniquely identified by the combination of:
prefix  - determines the scope and extent (or lifetime) of the variable
name    - an identifier consisting of '_' and alphanumeric characters
postfix - determines the type of the variable: integer or string

Scope can be:
global    - global to all servers
local     - local to the server
account   - attached to the account of the character identified by RID
character - attached to the character identified by RID
npc       - attached to the NPC
scope     - attached to the scope of the instance

Extent can be:
permanent - They still exist when the server resets.
temporary - They cease to exist when the server resets.

Prefix: scope and extent
nothing  - A permanent variable attached to the character, the default variable
           type. They are stored by char-server in the `char_reg_num` and
           `char_reg_str`.
"@"      - A temporary variable attached to the character.
           SVN versions before 2094 revision and RC5 version will also treat
           'l' as a temporary variable prefix, so beware of having variable
           names starting with 'l' if you want full backward compatibility.
"$"      - A global permanent variable.
           They are stored by map-server in database table `mapreg`.
"$@"     - A global temporary variable.
           This is important for scripts which are called with no RID
           attached, that is, not triggered by a specific character object.
"."      - A NPC variable.
           They exist in the NPC and disappear when the server restarts or the
           NPC is reloaded. Can be accessed from inside the NPC or by calling
           'getvariableofnpc'. Function objects can also have .variables which
           are accessible from inside the function, however 'getvariableofnpc'
           does NOT work on function objects.
".@"     - A scope variable.
           They are unique to the instance and scope. Each instance has its
           own scope that ends when the script ends. Calling a function with
           callsub/callfunc starts a new scope, returning from the function
           ends it. When a scope ends, its variables are converted to values
           ('return .@var;' returns a value, not a reference).
"'"      - An instance variable.
           These are used with the instancing system and are unique to each
           instance type. Can be accessed from inside the instance or by calling
           'getinstancevar'.
"#"      - A permanent local account variable.
           They are stored by char-server in the `acc_reg_num` table and
           `acc_reg_str`.
"##"     - A permanent global account variable stored by the login server.
           They are stored in the `global_acc_reg_num` table and
		   `global_acc_reg_str`.
           The only difference you will note from normal # variables is when
           you have multiple char-servers connected to the same login server.
           The # variables are unique to each char-server, while the ## variables
           are shared by all these char-servers.

Postfix: integer or string
nothing - integer variable, can store positive and negative numbers, but only
          whole numbers (so don't expect to do any fractional math)
'$'     - string variable, can store text

Examples:
  name  - permanent character integer variable
  name$ - permanent character string variable
 @name  - temporary character integer variable
 @name$ - temporary character string variable
 $name  - permanent global integer variable
 $name$ - permanent global string variable
$@name  - temporary global integer variable
$@name$ - temporary global string variable
 .name  - NPC integer variable
 .name$ - NPC string variable
.@name  - scope integer variable
.@name$ - scope string variable
 'name  - instance integer variable
 'name$ - instance string variable
 #name  - permanent local account integer variable
 #name$ - permanent local account string variable
##name  - permanent global account integer variable
##name$ - permanent global account string variable

Variables can be accessed and modified much like in other programming languages.

	.@x = 100;
	.@x = .@y = 100;

Support for modifying variable values using 'set' is still supported (and required
to exist for this new method to work) so previous scripts will continue to work.

When assigning values, all operator methods are supported which exist in the below
'Operators' section. For instance:

	.@x += 100;
	.@x -= 100;

 

 

mes "Click me to gain points";
next;
	switch(select("- Get Points:- Cancel")){
		case 1:
			mes "(script get points) +1 custom points";
			
			// Increase the value by 1. Basically gives 1 point to the player
			custom_points += 1;	
			
			close;
		
		case 2:
			mes "Cancel";
			close;

}

More Examples:

mes "You got 3 points";
custom_points += 3;

mes "You made the potion You got 1 point";
custom_points++;

mes "You crafted the armor. You got 98346 points";
custom_points += 98346;	

mes "You did my task. You got 100 temporary points.";
mes "You will lose them when you logout";
mes "They are unrelated to others points.";
@custom_points += 100;

mes "You crafted all the armors.";
mes "You got 50 account points. Every character you have can spend them.";
mes "They are unrelated to others points.";
#custom_points += 50;

Spending means losing, so just decrease the variable. Examples:

mes "Ok. I will give you the Emperium for 5 points";
custom_points -= 5;
getitem "EMPELIUM", 1;

mes "Ok. I will give you the 15 Apples for 1 point";
custom_points--;
getitem "APPLE", 15;

mes "Ok. I will give you the this special buff effect. You spent 8151 points for it.";
custom_points -= 8151;
sc_start SC_GLORIA,300000,5;

mes "OK. You spent 100 points to unlock +10 DMG weapons chance.";
weapon_points -= 100;
unlocked_10_dmg = true;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  132
  • Reputation:   53
  • Joined:  06/02/12
  • Last Seen:  

Hello. Useable Item function example:

  - Id: 12000000
    AegisName: Task_Book
    Name: Task Book
    Type: DelayConsume
    Script: |
      callfunc "F_custom_points_item";

 

function	script	F_custom_points_item	{
	mes "You have ^0055FF" + @custom_points + "^000000 Points.";
	close;
}

 

//===== rAthena Script =======================================
//= Hunting Missions
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.4
//===== Compatible With: ===================================== 
//= rAthena Project
//===== Description: =========================================
//= Random hunting missions.
//= Rewards are based on quest difficulty.
//= 
//= NOTE: Requires SQL mob database.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Small improvements and fixes.
//= 1.2 Added party support and replaced blacklists with an
//=     SQL query, both thanks to AnnieRuru.
//= 1.3 Re-added a blacklist adapted for the SQL query.
//= 1.3a Added mission reset options.
//= 1.3b Function updates.
//= 1.4 Check for deleted characters, thanks to AnnieRuru.
//=     Syntax updates and style cleaning.
//============================================================

yuno,160,85,3	script	Hunting Tasks	4_F_EDEN_MASTER,{
function Chk;
	cutin "arquien_n_atnad01", 2;
	mes "[Hunting Tasks]";
	mes "Hello, " + strcharinfo(0) + "!";
	if (!#Task_Delay) {
		next;
		mes "[Hunting Tasks]";
		mes "I can't find any records...";
		mes "You must be new here!";
		emotion ET_HUK;
		next;
		callsub Task_Info;
		emotion ET_GO;
		#Task_Delay = 1;
		close3;
	}
	mes F_Rand("Working hard, as always...", "Not slacking, I hope...");
	mes "Is there anything I can help";
	mes "you with?";
	mes " ";
	mes "^777777~ You've completed " + F_InsertPlural(Task_Total,"task",0,"^0055FF%d^777777 %s") + ". ~^000000";
	next;
	switch(select(
		((!Task0) ? " ~ New Task::" : ": ~ Task Status: ~ Abandon Task") +
		": ~ Information: ~ Task Shop: ~ View Top Hunters: ~ ^777777Cancel^000000"
	)) {
	case 1:
		mes "[Hunting Tasks]";
		if (#Task_Count) {
			mes "You've started a task";
			mes "on another character.";
			if (!@hm_char_del_check) {  // check for deleted character
				query_sql("SELECT 1 FROM `char_reg_num` WHERE `key` = 'Task0' AND `char_id` IN(SELECT `char_id` FROM `char` WHERE `account_id` = " + getcharid(3) + ")", .@i);
				if (!.@i) {
					next;
					mes "[Hunting Tasks]";
					mes "I can't seem to find any records";
					mes "for that character, though...";
					mes "One moment, please.";
					emotion ET_SCRATCH;
					#Task_Count = 0;
				}
				@hm_char_del_check = true;
			}
			close3;
		}
		if (#Task_Delay > gettimetick(2) && .Delay) {
			mes "I'm afraid you'll have to wait " + Time2Str(#Task_Delay) + " before taking another task.";
			close3;
		}
		mes "You must hunt:";
		if (.no_sql) {
			for (.@i = 0; .@i < .Quests; .@i++) {
				do {
					.@id = getrandmobid(MOBG_BRANCH_OF_DEAD_TREE, RMF_ALL, BaseLevel+15);
				} while (countinarray(.@mob, .@id) || (BaseLevel<=99 && strmobinfo(3,.@id) < BaseLevel-20) || (BaseLevel>99 && strmobinfo(3,.@id) < 90));
				setarray .@mob[.@i],.@id;
			}
		}
		else
			query_sql("SELECT ID FROM `" + .mob_db$ + "` WHERE left(name_aegis, 4) != 'meta' AND left(name_aegis, 2) != 'E_' AND base_exp > 0 AND job_exp > 0 AND (class != 'boss' OR class is null) AND (drop3_item like '%_card' OR drop4_item like '%_card' OR drop5_item like '%_card' OR drop6_item like '%_card' OR drop7_item like '%_card' OR drop8_item like '%_card' OR drop9_item like '%_card' OR drop10_item like '%_card') AND ID < 2000 AND instr('"+.Blacklist$+"',ID) = 0 ORDER BY rand() LIMIT " + .Quests, .@mob);
		for (.@i = 0; .@i < .Quests; .@i++) {
			setd "Task" + .@i, .@mob[.@i];
			setd "Task" + .@i +"_", 0;
		}
		#Task_Count = rand(.Count[0], .Count[1]);
		callsub Task_Status;
		next;
		mes "[Hunting Tasks]";
		mes "Report back when";
		mes "you've finished.";
		mes "Good luck!";
		close3;
	case 2:
		mes "[Hunting Tasks]";
		mes "Task status:";
		callsub Task_Status;
		close3;
	case 3:
		mes "[Hunting Tasks]";
		mes "Do you really want to";
		mes "abandon your task?";
		if (.Reset < 0 && .Delay)
			mes "Your delay time will not be reset.";
		else if (.Reset > 0)
			mes "It will cost " + F_InsertComma(.Reset) + " Zeny.";
		next;
		switch(select(" ~ Abandon...: ~ ^777777Cancel^000000")) {
		case 1:
			if (.Reset > 0) {
				if (Zeny < .Reset) {
					mes "[Hunting Tasks]";
					mes "You don't have enough";
					mes "Zeny to drop this task.";
					emotion ET_SORRY;
					close3;
				}
				Zeny -= .Reset;
				emotion ET_MONEY;
			}
			mes "[Hunting Tasks]";
			mes "Alright, I've dropped";
			mes "your current task.";
			specialeffect2 EF_STORMKICK4;
			for (.@i = 0; .@i < .Quests; .@i++) {
				setd "Task"+.@i, 0;
				setd "Task"+.@i+"_", 0;
			}
			#Task_Count = 0;
			if (.Reset < 0 && .Delay)
				#Task_Delay = gettimetick(2) + (.Delay * 3600);
			close3;
		case 2:
			mes "[Hunting Tasks]";
			mes "I knew you were kidding!";
			mes "Keep up the good work.";
			emotion ET_SMILE;
			close3;
		}
	case 4:
		callsub Task_Info;
		close3;
	case 5:
		mes "[Hunting Tasks]";
		mes "You have ^0055FF" + @custom_points + "^000000 Task Points.";
		mes "Use them well!";
		callshop "task_shop",1;
		npcshopattach "task_shop";
		end;
	case 6:
		mes "[Hunting Tasks]";
		mes "The top hunters are:";
		query_sql("SELECT char_id AS id, (SELECT `name` FROM `char` WHERE char_id = id),`value` FROM `char_reg_num` WHERE `key` = 'Task_Total' ORDER BY CAST(`value` AS SIGNED) DESC LIMIT 5", .@id, .@name$, .@val);
		for (.@i = 0; .@i < 5; .@i++)
			mes "  [Rank " + (.@i+1) + "]  " + ((.@name$[.@i] == "") ? "^777777none" : "^0055FF" + .@name$[.@i]+"^000000 : ^FF0000" + .@val[.@i] + " pt.") + "^000000";
		close3;
	case 7:
		mes "[Hunting Tasks]";
		mes "Nothing? Okay...";
		emotion ET_SCRATCH;
		close3;
	}
	end;

Task_Status:
	@f = false;
	deletearray .@j[0], getarraysize(.@j);
	for (.@i = 0; .@i < .Quests; .@i++) {
		.@j[.@i] = getd("Task" + .@i);
		.@j[.Quests] = .@j[.Quests] + strmobinfo(3,.@j[.@i]);
		.@j[.Quests+1] = .@j[.Quests+1] + (strmobinfo(6,.@j[.@i]) / (getbattleflag("base_exp_rate") / 100) * .Modifier[0]);
		.@j[.Quests+2] = .@j[.Quests+2] + (strmobinfo(7,.@j[.@i]) / (getbattleflag("job_exp_rate") / 100) * .Modifier[1]);
		mes " > "+Chk(getd("Task"+.@i+"_"),#Task_Count) + strmobinfo(1,.@j[.@i]) + " (" + getd("Task"+.@i+"_") + "/" + #Task_Count + ")^000000";
	}

	// Reward formulas:
	.@Task_Points = 3 + (.@j[.Quests] / .Quests / 6);
	.@Base_Exp = #Task_Count * .@j[.Quests+1] / 5;
	.@Job_Exp = #Task_Count * .@j[.Quests+2] / 5;
	.@Zeny = #Task_Count * .Quests * .@j[.@i] * .Modifier[2];

	next;
	mes "[Hunting Tasks]";
	mes "Task rewards:";
	mes " > Task Points: ^0055FF" + .@Task_Points + "^000000";
	if (.Modifier[0])
		mes " > Base Experience: ^0055FF" + F_InsertComma(.@Base_Exp) + "^000000";
	if (.Modifier[1])
		mes " > Job Experience: ^0055FF" + F_InsertComma(.@Job_Exp) + "^000000";
	if (.Modifier[2])
		mes " > Zeny: ^0055FF" + F_InsertComma(.@Zeny) + "^000000";
	if (@f) {
		@f = false;
		return;
	}
	next;
	mes "[Hunting Tasks]";
	mes "Oh, you're done!";
	mes "Good work.";
	mes "Here's your reward.";
	emotion ET_BEST;
	specialeffect2 EF_ANGEL;
	specialeffect2 EF_TRUESIGHT;
	@custom_points += .@Task_Points;
	BaseExp += .@Base_Exp;
	JobExp += .@Job_Exp;
	Zeny += .@Zeny;
	for (.@i = 0; .@i < .Quests; .@i++) {
		setd "Task" + .@i, 0;
		setd "Task" + .@i+"_", 0;
	}
	#Task_Count = 0;
	if (.Delay)
		#Task_Delay = gettimetick(2) + (.Delay * 3600);
	Task_Total++;
	if (Task_Total == 1)
		query_sql("INSERT INTO `char_reg_num` (`char_id`,`key`,`index`,`value`) VALUES (" + getcharid(0) + ",'Task_Total','0',1)");
	else
		query_sql("UPDATE `char_reg_num` SET `value` = " + Task_Total + " WHERE `char_id` = " + getcharid(0) + " AND `key` = 'Task_Total'");
	close3;

Task_Info:
	mes "[Hunting Tasks]";
	mes "If you so choose, I can assign";
	mes "you a random hunting quest.";
	mes "Some are easier than others, but";
	mes "the rewards increase with difficulty.";
	next;
	mes "[Hunting Tasks]";
	mes "Tasks points are shared";
	mes "amongst all your characters.";
	if (.Delay)
		mes "Delay time is, too.";
	mes "You can't take tasks on";
	mes "multiple characters at once.";
	next;
	mes "[Hunting Tasks]";
	mes "You can start a quest";
	mes (.Delay ? "every " + ((.Delay == 1) ? "hour." : .Delay + " hours.") : "whenever you want.");
	mes "That's everything~";
	return;

function Chk {
	if (getarg(0) < getarg(1)) {
		@f = true;
		return "^FF0000";
	} else
		return "^00FF00";
}

OnBuyItem:
	.@size = getarraysize(@bought_nameid);
	for (.@i = 0; .@i < .@size; .@i++) {
		.@j = inarray(.Shop, @bought_nameid[.@i]);
		.@cost += (.Shop[.@j+1] * @bought_quantity[.@i]);
	}
	mes "[Hunting Tasks]";
	if (.@cost > @custom_points)
		mes "You don't have enough Task Points.";
	else {
		for (.@i = 0; .@i < .@size; .@i++) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased " + @bought_quantity[.@i] + "x " + getitemname(@bought_nameid[.@i]) + ".";
		}
		@custom_points -= .@cost;
		mes "Deal completed.";
		emotion ET_MONEY;
	}
	deletearray @bought_nameid[0], .@size;
	deletearray @bought_quantity[0], .@size;
	close3;

OnNPCKillEvent:
	if (!getcharid(1) || !.Party) {
		if (!#Task_Count || !Task0) end;
		for (.@i = 0; .@i < .Quests; .@i++) {
			if (strmobinfo(1,killedrid) == strmobinfo(1,getd("Task" + .@i))) {
				if (getd("Task" + .@i + "_") < #Task_Count) {
					dispbottom "[Hunting Task] Killed " + (set(getd("Task" + .@i + "_"),getd("Task" + .@i + "_") + 1)) +
					           " of " + #Task_Count + " " + strmobinfo(1,killedrid) + ".";
					end;
				}
			}
		}
	} else if (.Party) {
		.@mob = killedrid;
		getmapxy(.@map1$,.@x1,.@y1);
		getpartymember getcharid(1),1;
		getpartymember getcharid(1),2;
		for (.@i = 0; .@i < $@partymembercount; .@i++) {
			if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i])) {
				set .@Task_Count, getvar(#Task_Count, $@partymembercid[.@i]);
				set .@Task0, getvar(Task0, $@partymembercid[.@i]);
				set .@HP, readparam(HP, $@partymembercid[.@i]);

				if (.@Task_Count && .@Task0 && .@HP > 0) {
					getmapxy(.@map2$,.@x2,.@y2,BL_PC,rid2name($@partymemberaid[.@i]));
					if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
						for (.@j = 0; .@j < .Quests; .@j++) {
							.@my_mob_id = getvar( getd("Task"+.@j),$@partymembercid[.@i] );
							.@my_count = getvar( getd("Task"+.@j+"_"), $@partymembercid[.@i] );
							if (strmobinfo(1,.@mob) == strmobinfo(1,.@my_mob_id)) {
								if (.@my_count < .@Task_Count) {
									setd "Task"+.@j+"_", (.@my_count+1), $@partymembercid[.@i];
									dispbottom "[Hunting Task] Killed " + (.@my_count+1) + " of " + .@Task_Count + " " + strmobinfo(1,.@mob) + ".", 0x777777, $@partymembercid[.@i];
									break;
								}
							}
						}
					}
				}
			}
		}
	}
	end;

OnInit:
	.Delay = 1;            // Quest delay, in hours (0 to disable).
	.Quests = 3;            // Number of subquests per task (increases rewards).
	.Party = 3;             // Party options: 0 (exclude party kills), 1 (include party kills), 2 (same map only), 3 (screen area only)
	.Reset = 0;            // Reset options: -1 (abandoning task sets delay time), 0 (no delay time), [Zeny] (cost to abandon task, no delay time)
	setarray .Count[0],     // Min and max monsters per subquest (increases rewards).
		20,50;
	setarray .Modifier[0],  // Multipliers for Base Exp, Job Exp, and Zeny rewards.
		0,0,0;
	.mob_db$ =              // Table name of SQL mob database
		(checkre(0))?"mob_db_re":"mob_db";
	setarray .Shop[0],      // Reward items: <ID>,<point cost> (about 10~20 points per hunt).
		512,1,513,1,514,1,538,5,539,5,558,10,561,10;
	.Blacklist$ =           // Blacklisted mob IDs.
		"1062,1088,1183,1186,1200,1212,1220,1221,1234,1235,"+
		"1244,1245,1250,1268,1290,1293,1294,1296,1298,1299,"+
		"1300,1301,1303,1304,1305,1306,1308,1309,1311,1313,"+
		"1515,1588,1618,1676,1677,1678,1679,1796,1797,1974,"+
		"1975,1976,1977,1978,1979";
	.no_sql = 1; 		// Ignore sql mob database

	npcshopdelitem "task_shop",512;
	for (.@i = 0; .@i < getarraysize(.Shop); .@i += 2)
		npcshopadditem "task_shop", .Shop[.@i], .Shop[.@i+1];
	end;
}
-	shop	task_shop	-1,no,512:-1

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  255
  • Topics Per Day:  0.06
  • Content Count:  706
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

9 hours ago, Racaae said:

Hello. Useable Item function example:

  - Id: 12000000
    AegisName: Task_Book
    Name: Task Book
    Type: DelayConsume
    Script: |
      callfunc "F_custom_points_item";

 

function	script	F_custom_points_item	{
	mes "You have ^0055FF" + @custom_points + "^000000 Points.";
	close;
}

 

//===== rAthena Script =======================================
//= Hunting Missions
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.4
//===== Compatible With: ===================================== 
//= rAthena Project
//===== Description: =========================================
//= Random hunting missions.
//= Rewards are based on quest difficulty.
//= 
//= NOTE: Requires SQL mob database.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.1 Small improvements and fixes.
//= 1.2 Added party support and replaced blacklists with an
//=     SQL query, both thanks to AnnieRuru.
//= 1.3 Re-added a blacklist adapted for the SQL query.
//= 1.3a Added mission reset options.
//= 1.3b Function updates.
//= 1.4 Check for deleted characters, thanks to AnnieRuru.
//=     Syntax updates and style cleaning.
//============================================================

yuno,160,85,3	script	Hunting Tasks	4_F_EDEN_MASTER,{
function Chk;
	cutin "arquien_n_atnad01", 2;
	mes "[Hunting Tasks]";
	mes "Hello, " + strcharinfo(0) + "!";
	if (!#Task_Delay) {
		next;
		mes "[Hunting Tasks]";
		mes "I can't find any records...";
		mes "You must be new here!";
		emotion ET_HUK;
		next;
		callsub Task_Info;
		emotion ET_GO;
		#Task_Delay = 1;
		close3;
	}
	mes F_Rand("Working hard, as always...", "Not slacking, I hope...");
	mes "Is there anything I can help";
	mes "you with?";
	mes " ";
	mes "^777777~ You've completed " + F_InsertPlural(Task_Total,"task",0,"^0055FF%d^777777 %s") + ". ~^000000";
	next;
	switch(select(
		((!Task0) ? " ~ New Task::" : ": ~ Task Status: ~ Abandon Task") +
		": ~ Information: ~ Task Shop: ~ View Top Hunters: ~ ^777777Cancel^000000"
	)) {
	case 1:
		mes "[Hunting Tasks]";
		if (#Task_Count) {
			mes "You've started a task";
			mes "on another character.";
			if (!@hm_char_del_check) {  // check for deleted character
				query_sql("SELECT 1 FROM `char_reg_num` WHERE `key` = 'Task0' AND `char_id` IN(SELECT `char_id` FROM `char` WHERE `account_id` = " + getcharid(3) + ")", .@i);
				if (!.@i) {
					next;
					mes "[Hunting Tasks]";
					mes "I can't seem to find any records";
					mes "for that character, though...";
					mes "One moment, please.";
					emotion ET_SCRATCH;
					#Task_Count = 0;
				}
				@hm_char_del_check = true;
			}
			close3;
		}
		if (#Task_Delay > gettimetick(2) && .Delay) {
			mes "I'm afraid you'll have to wait " + Time2Str(#Task_Delay) + " before taking another task.";
			close3;
		}
		mes "You must hunt:";
		if (.no_sql) {
			for (.@i = 0; .@i < .Quests; .@i++) {
				do {
					.@id = getrandmobid(MOBG_BRANCH_OF_DEAD_TREE, RMF_ALL, BaseLevel+15);
				} while (countinarray(.@mob, .@id) || (BaseLevel<=99 && strmobinfo(3,.@id) < BaseLevel-20) || (BaseLevel>99 && strmobinfo(3,.@id) < 90));
				setarray .@mob[.@i],.@id;
			}
		}
		else
			query_sql("SELECT ID FROM `" + .mob_db$ + "` WHERE left(name_aegis, 4) != 'meta' AND left(name_aegis, 2) != 'E_' AND base_exp > 0 AND job_exp > 0 AND (class != 'boss' OR class is null) AND (drop3_item like '%_card' OR drop4_item like '%_card' OR drop5_item like '%_card' OR drop6_item like '%_card' OR drop7_item like '%_card' OR drop8_item like '%_card' OR drop9_item like '%_card' OR drop10_item like '%_card') AND ID < 2000 AND instr('"+.Blacklist$+"',ID) = 0 ORDER BY rand() LIMIT " + .Quests, .@mob);
		for (.@i = 0; .@i < .Quests; .@i++) {
			setd "Task" + .@i, .@mob[.@i];
			setd "Task" + .@i +"_", 0;
		}
		#Task_Count = rand(.Count[0], .Count[1]);
		callsub Task_Status;
		next;
		mes "[Hunting Tasks]";
		mes "Report back when";
		mes "you've finished.";
		mes "Good luck!";
		close3;
	case 2:
		mes "[Hunting Tasks]";
		mes "Task status:";
		callsub Task_Status;
		close3;
	case 3:
		mes "[Hunting Tasks]";
		mes "Do you really want to";
		mes "abandon your task?";
		if (.Reset < 0 && .Delay)
			mes "Your delay time will not be reset.";
		else if (.Reset > 0)
			mes "It will cost " + F_InsertComma(.Reset) + " Zeny.";
		next;
		switch(select(" ~ Abandon...: ~ ^777777Cancel^000000")) {
		case 1:
			if (.Reset > 0) {
				if (Zeny < .Reset) {
					mes "[Hunting Tasks]";
					mes "You don't have enough";
					mes "Zeny to drop this task.";
					emotion ET_SORRY;
					close3;
				}
				Zeny -= .Reset;
				emotion ET_MONEY;
			}
			mes "[Hunting Tasks]";
			mes "Alright, I've dropped";
			mes "your current task.";
			specialeffect2 EF_STORMKICK4;
			for (.@i = 0; .@i < .Quests; .@i++) {
				setd "Task"+.@i, 0;
				setd "Task"+.@i+"_", 0;
			}
			#Task_Count = 0;
			if (.Reset < 0 && .Delay)
				#Task_Delay = gettimetick(2) + (.Delay * 3600);
			close3;
		case 2:
			mes "[Hunting Tasks]";
			mes "I knew you were kidding!";
			mes "Keep up the good work.";
			emotion ET_SMILE;
			close3;
		}
	case 4:
		callsub Task_Info;
		close3;
	case 5:
		mes "[Hunting Tasks]";
		mes "You have ^0055FF" + @custom_points + "^000000 Task Points.";
		mes "Use them well!";
		callshop "task_shop",1;
		npcshopattach "task_shop";
		end;
	case 6:
		mes "[Hunting Tasks]";
		mes "The top hunters are:";
		query_sql("SELECT char_id AS id, (SELECT `name` FROM `char` WHERE char_id = id),`value` FROM `char_reg_num` WHERE `key` = 'Task_Total' ORDER BY CAST(`value` AS SIGNED) DESC LIMIT 5", .@id, .@name$, .@val);
		for (.@i = 0; .@i < 5; .@i++)
			mes "  [Rank " + (.@i+1) + "]  " + ((.@name$[.@i] == "") ? "^777777none" : "^0055FF" + .@name$[.@i]+"^000000 : ^FF0000" + .@val[.@i] + " pt.") + "^000000";
		close3;
	case 7:
		mes "[Hunting Tasks]";
		mes "Nothing? Okay...";
		emotion ET_SCRATCH;
		close3;
	}
	end;

Task_Status:
	@f = false;
	deletearray .@j[0], getarraysize(.@j);
	for (.@i = 0; .@i < .Quests; .@i++) {
		.@j[.@i] = getd("Task" + .@i);
		.@j[.Quests] = .@j[.Quests] + strmobinfo(3,.@j[.@i]);
		.@j[.Quests+1] = .@j[.Quests+1] + (strmobinfo(6,.@j[.@i]) / (getbattleflag("base_exp_rate") / 100) * .Modifier[0]);
		.@j[.Quests+2] = .@j[.Quests+2] + (strmobinfo(7,.@j[.@i]) / (getbattleflag("job_exp_rate") / 100) * .Modifier[1]);
		mes " > "+Chk(getd("Task"+.@i+"_"),#Task_Count) + strmobinfo(1,.@j[.@i]) + " (" + getd("Task"+.@i+"_") + "/" + #Task_Count + ")^000000";
	}

	// Reward formulas:
	.@Task_Points = 3 + (.@j[.Quests] / .Quests / 6);
	.@Base_Exp = #Task_Count * .@j[.Quests+1] / 5;
	.@Job_Exp = #Task_Count * .@j[.Quests+2] / 5;
	.@Zeny = #Task_Count * .Quests * .@j[.@i] * .Modifier[2];

	next;
	mes "[Hunting Tasks]";
	mes "Task rewards:";
	mes " > Task Points: ^0055FF" + .@Task_Points + "^000000";
	if (.Modifier[0])
		mes " > Base Experience: ^0055FF" + F_InsertComma(.@Base_Exp) + "^000000";
	if (.Modifier[1])
		mes " > Job Experience: ^0055FF" + F_InsertComma(.@Job_Exp) + "^000000";
	if (.Modifier[2])
		mes " > Zeny: ^0055FF" + F_InsertComma(.@Zeny) + "^000000";
	if (@f) {
		@f = false;
		return;
	}
	next;
	mes "[Hunting Tasks]";
	mes "Oh, you're done!";
	mes "Good work.";
	mes "Here's your reward.";
	emotion ET_BEST;
	specialeffect2 EF_ANGEL;
	specialeffect2 EF_TRUESIGHT;
	@custom_points += .@Task_Points;
	BaseExp += .@Base_Exp;
	JobExp += .@Job_Exp;
	Zeny += .@Zeny;
	for (.@i = 0; .@i < .Quests; .@i++) {
		setd "Task" + .@i, 0;
		setd "Task" + .@i+"_", 0;
	}
	#Task_Count = 0;
	if (.Delay)
		#Task_Delay = gettimetick(2) + (.Delay * 3600);
	Task_Total++;
	if (Task_Total == 1)
		query_sql("INSERT INTO `char_reg_num` (`char_id`,`key`,`index`,`value`) VALUES (" + getcharid(0) + ",'Task_Total','0',1)");
	else
		query_sql("UPDATE `char_reg_num` SET `value` = " + Task_Total + " WHERE `char_id` = " + getcharid(0) + " AND `key` = 'Task_Total'");
	close3;

Task_Info:
	mes "[Hunting Tasks]";
	mes "If you so choose, I can assign";
	mes "you a random hunting quest.";
	mes "Some are easier than others, but";
	mes "the rewards increase with difficulty.";
	next;
	mes "[Hunting Tasks]";
	mes "Tasks points are shared";
	mes "amongst all your characters.";
	if (.Delay)
		mes "Delay time is, too.";
	mes "You can't take tasks on";
	mes "multiple characters at once.";
	next;
	mes "[Hunting Tasks]";
	mes "You can start a quest";
	mes (.Delay ? "every " + ((.Delay == 1) ? "hour." : .Delay + " hours.") : "whenever you want.");
	mes "That's everything~";
	return;

function Chk {
	if (getarg(0) < getarg(1)) {
		@f = true;
		return "^FF0000";
	} else
		return "^00FF00";
}

OnBuyItem:
	.@size = getarraysize(@bought_nameid);
	for (.@i = 0; .@i < .@size; .@i++) {
		.@j = inarray(.Shop, @bought_nameid[.@i]);
		.@cost += (.Shop[.@j+1] * @bought_quantity[.@i]);
	}
	mes "[Hunting Tasks]";
	if (.@cost > @custom_points)
		mes "You don't have enough Task Points.";
	else {
		for (.@i = 0; .@i < .@size; .@i++) {
			getitem @bought_nameid[.@i], @bought_quantity[.@i];
			dispbottom "Purchased " + @bought_quantity[.@i] + "x " + getitemname(@bought_nameid[.@i]) + ".";
		}
		@custom_points -= .@cost;
		mes "Deal completed.";
		emotion ET_MONEY;
	}
	deletearray @bought_nameid[0], .@size;
	deletearray @bought_quantity[0], .@size;
	close3;

OnNPCKillEvent:
	if (!getcharid(1) || !.Party) {
		if (!#Task_Count || !Task0) end;
		for (.@i = 0; .@i < .Quests; .@i++) {
			if (strmobinfo(1,killedrid) == strmobinfo(1,getd("Task" + .@i))) {
				if (getd("Task" + .@i + "_") < #Task_Count) {
					dispbottom "[Hunting Task] Killed " + (set(getd("Task" + .@i + "_"),getd("Task" + .@i + "_") + 1)) +
					           " of " + #Task_Count + " " + strmobinfo(1,killedrid) + ".";
					end;
				}
			}
		}
	} else if (.Party) {
		.@mob = killedrid;
		getmapxy(.@map1$,.@x1,.@y1);
		getpartymember getcharid(1),1;
		getpartymember getcharid(1),2;
		for (.@i = 0; .@i < $@partymembercount; .@i++) {
			if (isloggedin($@partymemberaid[.@i], $@partymembercid[.@i])) {
				set .@Task_Count, getvar(#Task_Count, $@partymembercid[.@i]);
				set .@Task0, getvar(Task0, $@partymembercid[.@i]);
				set .@HP, readparam(HP, $@partymembercid[.@i]);

				if (.@Task_Count && .@Task0 && .@HP > 0) {
					getmapxy(.@map2$,.@x2,.@y2,BL_PC,rid2name($@partymemberaid[.@i]));
					if ((.@map1$ == .@map2$ || .Party == 1) && (distance(.@x1,.@y1,.@x2,.@y2) <= 30 || .Party < 3)) {
						for (.@j = 0; .@j < .Quests; .@j++) {
							.@my_mob_id = getvar( getd("Task"+.@j),$@partymembercid[.@i] );
							.@my_count = getvar( getd("Task"+.@j+"_"), $@partymembercid[.@i] );
							if (strmobinfo(1,.@mob) == strmobinfo(1,.@my_mob_id)) {
								if (.@my_count < .@Task_Count) {
									setd "Task"+.@j+"_", (.@my_count+1), $@partymembercid[.@i];
									dispbottom "[Hunting Task] Killed " + (.@my_count+1) + " of " + .@Task_Count + " " + strmobinfo(1,.@mob) + ".", 0x777777, $@partymembercid[.@i];
									break;
								}
							}
						}
					}
				}
			}
		}
	}
	end;

OnInit:
	.Delay = 1;            // Quest delay, in hours (0 to disable).
	.Quests = 3;            // Number of subquests per task (increases rewards).
	.Party = 3;             // Party options: 0 (exclude party kills), 1 (include party kills), 2 (same map only), 3 (screen area only)
	.Reset = 0;            // Reset options: -1 (abandoning task sets delay time), 0 (no delay time), [Zeny] (cost to abandon task, no delay time)
	setarray .Count[0],     // Min and max monsters per subquest (increases rewards).
		20,50;
	setarray .Modifier[0],  // Multipliers for Base Exp, Job Exp, and Zeny rewards.
		0,0,0;
	.mob_db$ =              // Table name of SQL mob database
		(checkre(0))?"mob_db_re":"mob_db";
	setarray .Shop[0],      // Reward items: <ID>,<point cost> (about 10~20 points per hunt).
		512,1,513,1,514,1,538,5,539,5,558,10,561,10;
	.Blacklist$ =           // Blacklisted mob IDs.
		"1062,1088,1183,1186,1200,1212,1220,1221,1234,1235,"+
		"1244,1245,1250,1268,1290,1293,1294,1296,1298,1299,"+
		"1300,1301,1303,1304,1305,1306,1308,1309,1311,1313,"+
		"1515,1588,1618,1676,1677,1678,1679,1796,1797,1974,"+
		"1975,1976,1977,1978,1979";
	.no_sql = 1; 		// Ignore sql mob database

	          

 

the last script is kinda complicated for my level of knowladge, can you make a simpler version such as, in this situasion :

mes "Click me to gain points";
next;
	switch(select("- Get Points:- Cancel")){
		case 1:
			mes "(script get points) +1 custom points";
			close;
		
		case 2:
			mes "Cancel";
			close;

}

and how to spend the points?

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

On 3/16/2024 at 9:50 AM, Dolphin86 said:

how to spend the points?

The points are just a custom temporary character variable.
rathena/doc/script_commands.txt at master · rathena/rathena · GitHub

I think it might be more appropriate to use a permanent character variable for that instead.

This is how you can define a shop that uses the custom points.
rathena/doc/script_commands.txt at master · rathena/rathena · GitHub

Here it describes how the different shop points are used.
rathena/doc/script_commands.txt at master · rathena/rathena · GitHub

@Racaae's answer shows pretty clearly how you can do something from an item. 🙂

"Task" is very vague. What do you want the player to do specifically?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  255
  • Topics Per Day:  0.06
  • Content Count:  706
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

@Skorm well what i plan to do was player will do some activity example, crafting weapon, once player had succesfully craft the desire weapon, he will get crafting points, now if player wish to view his current point he will use an infinate item that will recall an npc / script which will show all of his current points, ( weapon craft, armor craft, etc)

and player can also spend his current points to unlock new stuff, example 100 weapon crafting can be spend to unlock bonus +10 dmg (i am using an etc item as indicator of player which will detect on the crafting sytem npc that will open a feature where player can craft +10 dmg weapons, but if i understand this point system i would just use the points instend of items, but i am worry if the points would be reset, when server reboot, restart or stop...)

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

44 minutes ago, Dolphin86 said:

@Skorm well what i plan to do was player will do some activity example, crafting weapon, once player had succesfully craft the desire weapon, he will get crafting points, now if player wish to view his current point he will use an infinate item that will recall an npc / script which will show all of his current points, ( weapon craft, armor craft, etc)

and player can also spend his current points to unlock new stuff, example 100 weapon crafting can be spend to unlock bonus +10 dmg (i am using an etc item as indicator of player which will detect on the crafting sytem npc that will open a feature where player can craft +10 dmg weapons, but if i understand this point system i would just use the points instend of items, but i am worry if the points would be reset, when server reboot, restart or stop...)

I'm pretty sure detecting if a player produced an item requires a source mod probably with an event similar to the OnPC events.

Link to comment
Share on other sites

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.

×
×
  • Create New...