Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Script: Mining (https://forums.graalonline.com/forums/showthread.php?t=68273)

Skyld 08-21-2006 10:51 PM

Script: Mining
 
Here is a mining system, also posted in the interest of education. Since I will probably never use these scripts, it makes sense to post them for other people!

There are two parts to the mining system; you will need to add the mining class (which is the script for the rocks), and you will also require the axe.

If you put the mining class in a class called "mining", then use the following to make a rock in a level:
PHP Code:

this.join("mining"); 

The axe is simple enough. Just add the weapon, add in your own animation into setani() and play.

You'll need to edit the mining class though; first, you'll need to put the appropriate images in the right place so the rock looks like it's being mined. Secondly, you'll have to insert your own item adding routine, so that you can actually add the item to the player. The method was different on Rudora, so it's no good putting that in there.

It's a fairly old script and could probably do with some work, especially if you want it to be more complex. Enjoy.

Axe weapon:
PHP Code:

//#CLIENTSIDE

function onWeaponFired()
{
  
setani("ani""params");
  
  
freezeplayer(1);
  
sleep(0.5);
  
  
ar = {player.+ (vecx(player.dir) * 2) + 1.1,
        
player.+ (vecy(player.dir) * 2) + 1.1};
  
  
showimg(2001"@Courier New@b@+"ar[0], ar[1]);

  
triggeraction(ar[0], ar[1], "axe"10);
  
hitobjects(1ar[0], ar[1]);
  
  
putleaps(2this.wx 0.5this.wy 0.5);
  
  
sleep(0.5);
  
  
setani("idle""");
  
hideimg(2001);


Mining class:
PHP Code:

function onCreated()
{
  
this.show();
  
  
this.offset 0

  
this.owner "none";
  
  
// Define possible types
  
this.types = {"bronze""silver""gold""crystal""metal"};
  
this.idtype int(random(0this.types.size()));
  
this.rtype this.types[this.idtype];
  
  
// set your default rock image here
 
  
this.setshape(13232);
  
  
this.chat "(Owner: " this.owner ")";
}

function 
onActionaxe()
{
  if (
this.owner == "none")
  {
    
this.owner player.account;
  }
    else
  if (
this.owner == player.account)
  {
    
setTimer(15);
  }
  
  
this.chat "(Owner: " this.owner ")";
  
  
this.progress += params[0];
  
  if (
this.progress 199)
  {
    
player.chat "You got a " this.rtype " rock!";
    
    
// Add your item to the player here
    
    
this.progress 0;
    
    
hide();
    
sleep(15); // <- how long to vanish for
    
onCreated();
  }
    else
  if (
this.progress 160)
  {
    
// set first progress rock image
  
}
    else
  if (
this.progress 120)
  {
    
// set second progress rock image
  
}
    else
  if (
this.progress 80)
  {
    
// set third progress rock image
  
}
    else
  if (
this.progress 40)
  {
    
// set fourth progress rock image
  
}
    else
  if (
this.progress 0)
  {
    
// set last progress rock image
  
}
}
  
function 
onTimeout()
{
  
this.owner "none";
  
this.chat "(Owner: " this.owner ")";



Draenin 09-13-2006 05:22 PM

Hahaha. Owner tags. MYSTERIOUS CONCEPT.

devilsknite1 10-10-2008 03:17 AM

Oh, thanks, you just saved me about 10 minutes! :D

Chompy 10-10-2008 02:58 PM

Quote:

Originally Posted by devilsknite1 (Post 1431178)
Oh, thanks, you just saved me about 10 minutes! :D

Oh, you just revived a 2 year old thread D:

The Code Gallery just gets less and less posts/releases as the time goes by, as if scripters jsut want to release big and fancy stuff..

xXziroXx 10-10-2008 05:05 PM

Quote:

Originally Posted by Chompy (Post 1431280)
Oh, you just revived a 2 year old thread D:

There's nothing wrong with that in a forum such as Code Gallery. :noob:

Pelikano 12-31-2008 03:50 PM

Isn't sleep() GS1 and shouldn't be used in GS2 at all?

It screws up my timers rofl

[email protected] 12-31-2008 04:15 PM

no, just don't add a sleep inside a timeout lol


All times are GMT +2. The time now is 05:33 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.