Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*=========================================================
- Variant Mining
- by Mumbles
- ===========================================================
- Idea: http://goo.gl/ndXr6R
- ===========================================================
- 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.
- ===========================================================
- Compatibility:
- Optimised for Hercules emulators.
- ===========================================================
- Changelog:
- v1.0 - First version.
- v1.0.1 - Fixed issue with success algorithm.
- v1.0.2 - Added randomised debris.
- v1.0.3 - Added additional locations in Payon Cave.
- v2.0 - Optimised for Hercules emulators.
- v2.0.1 - Updated algorithms.
- v2.0.2 - Added randomised disappearing and respawning.
- v2.0.3 - Updated version format.
- =========================================================*/
- - script Variant Mineral#0::mining 1907,{
- /*-----------------------------------------------------
- Script
- -----------------------------------------------------*/
- // 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 += 2) {
- if (countitem(.tool[.@i]) < .tool[.@i + 1]) {
- message strcharinfo(0), "You need to bring "+ .tool[.@i + 1] +" "+ getitemname(.tool[.@i]) +" to mine!";
- .@gearless++;
- }
- }
- // Show count of tools not in inventory
- if (.@gearless) {
- .@grammar$ = (getarraysize(.tool) > 1 ? "tools were" : "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 += 2) {
- delitem .tool[.@i], .tool[.@i + 1];
- }
- // 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++) {
- .@random = rand(2) * (!rand(1) ? -1 : 1);
- makeitem .debris, 1, .@m$, .@x + .@random, .@y + .@random;
- }
- // Randomize target mineral to mine
- do {
- .@target = rand(getarraysize(.mineral));
- } while (.@target % 2);
- // Max range of success
- .@range = .success[.@target + 1];
- // Check if failed
- if (rand(1, .@range) != .success[.@target]) {
- message strcharinfo(0), "Nothing valuable was excavated...";
- } else {
- // Get mineral(s)
- getitem .mineral[.@target], .mineral[.@target + 1];
- message strcharinfo(0), "You have successfully mined "+ .mineral[.@target + 1] +" "+ getitemname(.mineral[.@target]) +"!";
- callfunc ("npcmove",1);
- }
- end;
- OnInit:
- // Minerals (constant/ID, amount)
- setarray .mineral[0], 1010, 5, 1011, 3, 984, 1, 985, 1, 7807, 1, 7231, 1, 7233, 1, 7232, 1;
- // Success rate: (x / y)% chance
- setarray .success[0], 1, 5, // 4/10 (40%)
- 1, 2, // 3/10 (30%)
- 4, 5, // 1/25 (4%)
- 1, 50; // 1/50 (2%)
- // Equipment (constant/ID)
- setarray .equip[0], 5009, 2218, 7318;
- // Tools (constant/ID, amount)
- setarray .tool[0], 7327, 1;
- // Mining time (in seconds)
- .progress = 1;
- // Audio/visual effects
- .sound$ = "chepet_attack.wav";
- .effect = EF_HIT5;
- // Debris
- .debris = 7049; // Stone
- .limit = 3; // Scatter limit
- // Hiding and Respawning
- .var_amount = 44; // Amount of Variant Minerals
- .hide_chance = 5; // Chance in x to hide (default: 4 [25%])
- .respawn_chance = 8; // Chance in x to respawn (default: 2 [50%])
- .respawn_rate = 1; // Every x hours (max: 12)
- end;
- }
- function 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("pvp_n_4-3", .@x, .@y, cell_chkpass)) break;
- }
- movenpc "Variant Mineral#"+getarg(0), .@x, .@y; //Move NPC
- setnpcdisplay "Variant Mineral#"+getarg(0), 1907; // set the npc sprite
- end;
- }
- /*-----------------------------------------------------
- Duplicates
- -----------------------------------------------------*/
- pvp_n_4-3,100,92,0 duplicate(mining) Variant Mineral#1 1907
- pvp_n_4-3,100,95,0 duplicate(mining) Variant Mineral#2 1907
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement