Jump to content
Mumbles

Variant Mining

Recommended Posts

Utility: Variant Mining

As per xienne15's request: http://herc.ws/board/topic/1886-simple-mining/

 

Description:

A simple mining system; allows for interacting players to excavate minerals by "mining" them with special equipment and tools. Minerals disappear and respawn randomly; chance is determined by configuration.

 

Configuration is mostly done in arrays so that settings may be changed with no modifications to the script. Duplicate in additional locations as needed; update the value of '.var_amount' correspondingly.

 

Download:

https://github.com/datmumbles/Scripts/raw/master/util/mining.txt

Share this post


Link to post
Share on other sites

Thanks. I will try this out. :)

 

Sure thing; be sure to adjust the success rates to your liking - the original request asked for particularly low rates. The .success array takes values in comparison to fractions (ex. 3, 4 is the same as 3 / 4 or 75%). Thanks for trying it out!

Edited by Via

Share this post


Link to post
Share on other sites

Suggestion:

When mining, if you fail or succeed the mine would be gone and be relocated to a different area( x, y )..

 

Yes, second devotion. if this would be add in the feature it'll be interesting.

Thank you!!!

Share this post


Link to post
Share on other sites
// Move Npcfunction    script    npcmove    {        while(1) {            set .@x,rand(0,300); // 0 to 300 random x coordinate            set .@y,rand(0,300); // 0 to 300 random y coordinate            if( checkcell("pay_dun00", .@x, .@y, cell_chkpass)) break; // check if passable            }                movenpc "Variant Mineral#"+getarg(0), .@x, .@y;  //Move NPC                setnpcdisplay "Variant Mineral#"+getarg(0), 1907; // set the npc sprite            end;}// Duplicates-    script    Variant#1    -1,{    doevent "mining::OnMine"; goto OnMove; // call mining script's OnMine label then move the npc    OnInit:    OnMove:        callfunc ("npcmove",1); // call npc move to move the variant#1, number 1 is the #1 in the Variant#1.    end;}-    script    Variant#2    -1,{    doevent "mining::OnMine"; goto OnMove;    OnInit:    OnMove:        callfunc ("npcmove",2); // call npc move to move the variant#1, number 2 is the #2 in the Variant#2.    end;}// dupes againpay_dun00,1,1,0    duplicate(Variant#1)    Variant Mineral#1    1907pay_dun00,1,1,0    duplicate(Variant#2)    Variant Mineral#2    1907

 

@edit

But you need to add more if you want to have more minerals.

Edited by quesoph

Share this post


Link to post
Share on other sites

 

// Move Npcfunction    script    npcmove    {        while(1) {            set .@x,rand(0,300); // 0 to 300 random x coordinate            set .@y,rand(0,300); // 0 to 300 random y coordinate            if( checkcell("pay_dun00", .@x, .@y, cell_chkpass)) break; // check if passable            }                movenpc "Variant Mineral#"+getarg(0), .@x, .@y;  //Move NPC                setnpcdisplay "Variant Mineral#"+getarg(0), 1907; // set the npc sprite            end;}// Duplicates-    script    Variant#1    -1,{    doevent "mining::OnMine"; goto OnMove; // call mining script's OnMine label then move the npc    OnInit:    OnMove:        callfunc ("npcmove",1); // call npc move to move the variant#1, number 1 is the #1 in the Variant#1.    end;}-    script    Variant#2    -1,{    doevent "mining::OnMine"; goto OnMove;    OnInit:    OnMove:        callfunc ("npcmove",2); // call npc move to move the variant#1, number 2 is the #2 in the Variant#2.    end;}// dupes againpay_dun00,1,1,0    duplicate(Variant#1)    Variant Mineral#1    1907pay_dun00,1,1,0    duplicate(Variant#2)    Variant Mineral#2    1907

 

@edit

But you need to add more if you want to have more minerals.

 

 

 

Thanks for the quick respond, btw? where can i put that part of the script?

it would be great if you could provide a whole script with that current add-on part.

 

Thanks in Advance!

Share this post


Link to post
Share on other sites

 

 

/*=========================================================Variant Miningby Glitch [Via]===========================================================Request: http://herc.ws/board/topic/1886-simple-mining/===========================================================Description:A simple mining system; allows for interacting players toexcavate minerals by "mining" them with special equipmentand tools. Configuration is done in arrays so that settings may bechanged with no modifications to the script. Keep in mindthat each array value is respective to their commented set. Duplicate in additional locations as needed.=========================================================*/ pay_dun00,54,147,0  script  Variant Mineral#1::mining   1907,{		// Check equipment	for (.@i = 0; .@i < getarraysize(.equip); .@i++)	{		if (!isequipped(.equip[.@i]))		{			message strcharinfo(0), "You need to have '"+ getitemname(.equip[.@i]) +"' equipped to mine!";			.@unequipped++;		}	}		// Show count of equipment not worn	if (.@unequipped)	{		message strcharinfo(0), .@unequipped +" of "+ getarraysize(.equip) +" equipment has not been worn.";		end;	}		// Check tools	for (.@i = 0; .@i < getarraysize(.tool); .@i++)	{		if (countitem(.tool[.@i]) < .inventory[.@i])		{			message strcharinfo(0), "You need to bring "+ .inventory[.@i] +" "+ getitemname(.tool[.@i]) +" to mine!";			.@gearless++;		}	}		// Show count of tools not in inventory	if (.@gearless)	{		if (getarraysize(.tool) > 1)			.@grammar$ = "tools were";		else			.@grammar$ = "tool was";			message strcharinfo(0), .@gearless +" of "+ getarraysize(.tool) +" "+ .@grammar$ +" not brought.";		end;	}		// Progress	message strcharinfo(0), "Mining in progress...";	progressbar "green", .progress;		// Delete tools	for (.@i = 0; .@i < getarraysize(.tool); .@i++)		delitem .tool[.@i], .inventory[.@i];		// Audio/visual effects	soundeffect .sound$, 0;	specialeffect .effect;		// Drop random debris	getmapxy(.@m$, .@x, .@y, 0);	.@scatter = rand(1, .limit);	for (.@i = 0; .@i < .@scatter; .@i++)	{		if (!rand(1))			.@random = rand(2) * -1;		else			.@random = rand(2);					makeitem .debris, 1, .@m$, .@x + .@random, .@y + .@random;	}		// Randomize target mineral to mine	.@target = rand(getarraysize(.mineral));		// Max range of success	.@range = .success[.@target * 2 + 1];		// Check if failed	if(rand(1, .@range) != .success[.@target * 2])	{		message strcharinfo(0), "Nothing valuable was excavated...";		end;	}		// Get mineral(s)	getitem .mineral[.@target], .amount[.@target];	message strcharinfo(0), "You have successfully mined "+ .amount[.@target] +" "+ getitemname(.mineral[.@target]) +"!";	end;		OnWhisperGlobal:		// Whisper anything to initialize settings		message strcharinfo(0), strnpcinfo(1) +" : 'OnInit' label has been intialized.";			OnInit:		// Minerals		setarray .mineral[0], 1010, 1011, 984, 985; // Phracon, Emveretarcon, Oridecon, Elunium		setarray .amount[0],	 5,    3,   1,   1; // Amount to mine				// Success rate: (x / y)% chance		setarray .success[0],   1, 5,   // 1/5 (20%)								1, 2,   // 1/2 (50%)								4, 5,   // 4/5 (80%)								1, 50;  // 1/50 (2%)				// Equipment		setarray .equip[0], 5009, 2218; // Safety Helmet, Flu Mask				// Tools		setarray .tool[0],	  7318, 7327; // Old Pick, Flashlight		setarray .inventory[0],    1,    1; // Amount per tool				// Mining time (in seconds)		.progress = 5;				// Audio/visual effects		.sound$ = "chepet_attack.wav";		.effect = 4;				// Debris		.debris = 7049; // Stone		.limit = 5;	 // Scatter limit		end;	}// Move Npcfunction    script    npcmove    {        while(1) {            set .@x,rand(0,300); // 0 to 300 random x coordinate            set .@y,rand(0,300); // 0 to 300 random y coordinate            if( checkcell("pay_dun00", .@x, .@y, cell_chkpass)) break; // check if passable            }                movenpc "Variant Mineral#"+getarg(0), .@x, .@y;  //Move NPC                setnpcdisplay "Variant Mineral#"+getarg(0), 1907; // set the npc sprite            end;}// Duplicates-    script    Variant#1    -1,{    doevent "mining::OnMine"; goto OnMove; // call mining script's OnMine label then move the npc    OnInit:    OnMove:        callfunc ("npcmove",1); // call npc move to move the variant#1, number 1 is the #1 in the Variant#1.    end;}-    script    Variant#2    -1,{    doevent "mining::OnMine"; goto OnMove;    OnInit:    OnMove:        callfunc ("npcmove",2); // call npc move to move the variant#1, number 2 is the #2 in the Variant#2.    end;}// dupes againpay_dun00,1,1,0    duplicate(Variant#1)    Variant Mineral#1    1907pay_dun00,1,1,0    duplicate(Variant#2)    Variant Mineral#2    1907

 

 

Edited by quesoph

Share this post


Link to post
Share on other sites
[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Emveretarcon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Oridecon', defaultingto 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: number value=0[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Elunium', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: variable name='Phracon'[Debug]: Data: number value=5[Debug]: Data: variable name='Emveretarcon'[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Phracon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: variable name='Emveretarcon'[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Emveretarcon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Oridecon', defaultingto 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: number value=0[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Elunium', defaulting to 0

I got errors from that scripts..?

Share this post


Link to post
Share on other sites

 

[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Emveretarcon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Oridecon', defaultingto 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: number value=0[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Elunium', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: variable name='Phracon'[Debug]: Data: number value=5[Debug]: Data: variable name='Emveretarcon'[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Phracon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: variable name='Emveretarcon'[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Emveretarcon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Oridecon', defaultingto 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: number value=0[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Elunium', defaulting to 0

I got errors from that scripts..?

 

This will not work with *Athena emulators until they add compatibility for item constants (in place of IDs); this script is optimised for Hercules emulators only.1

 

 

1If you are using Hercules, please update your emulator.

Share this post


Link to post
Share on other sites

 

 

[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Emveretarcon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Oridecon', defaultingto 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: number value=0[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#10 at pay_dun00 (86,139)[Warning]: script:get_val: cannot access player variable 'Elunium', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: variable name='Phracon'[Debug]: Data: number value=5[Debug]: Data: variable name='Emveretarcon'[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Phracon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: variable name='Emveretarcon'[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Emveretarcon', defaulting to 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: variable name='Oridecon'[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Oridecon', defaultingto 0[Error]: script_rid2sd: fatal error ! player not attached![Debug]: Function: setarray (9 parameters):[Debug]: Data: variable name='.mineral' index=0[Debug]: Data: number value=0[Debug]: Data: number value=5[Debug]: Data: number value=0[Debug]: Data: number value=3[Debug]: Data: number value=0[Debug]: Data: number value=1[Debug]: Data: variable name='Elunium'[Debug]: Data: number value=1[Debug]: Source (NPC): Variant Mineral#20 at pay_dun00 (35,54)[Warning]: script:get_val: cannot access player variable 'Elunium', defaulting to 0

I got errors from that scripts..?

 

This will not work with *Athena emulators until they add compatibility for item constants (in place of IDs); this script is optimised for Hercules emulators only.1

 

 

1If you are using Hercules, please update your emulator.

I already solved it, thanks :)

It's really nice scripts to share, btw is there a chance of adding a random spawn on a map after progressbar has been finish?

Edited by dagiccross

Share this post


Link to post
Share on other sites

I already solved it, thanks :)

It's really nice scripts to share, btw is there a chance of adding a random spawn on a map after progressbar has been finish?

You can use the monster command after the line containing the progressbar command.

Share this post


Link to post
Share on other sites

Cool plugin. I loved it! This one is simpler that Myzter's mining game.

My only concern is that for example I put 10/10 on the success chance, should it be 100%? My problem is that its still not 100% chance of success even though I put those values. I also tried 100/100 but still same result.

Am I missing something?

Share this post


Link to post
Share on other sites

@@Mumbles is it possible to add arrays for Normal Drops and Rare Drops..

And also for the success rate, for Normal drop and Rare Drops can be set also.

 

Can you do it?

Thanks in advance!

Edited by Vlync

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.