/*=========================================================Variant Miningby Glitch [Via]===========================================================Request: [URL="https://boardtest.herc.ws/topic/1886-simple-mining/===========================================================Description:A"]http://herc.ws/board/topic/1886-simple-mining/===========================================================Description:A[/URL] 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