Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-21-2006, 10:51 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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 ")";

Reply With Quote
  #2  
Old 09-13-2006, 05:22 PM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Hahaha. Owner tags. MYSTERIOUS CONCEPT.
Reply With Quote
  #3  
Old 10-10-2008, 03:17 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Oh, thanks, you just saved me about 10 minutes!
Reply With Quote
  #4  
Old 10-10-2008, 02:58 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by devilsknite1 View Post
Oh, thanks, you just saved me about 10 minutes!
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..
__________________
Reply With Quote
  #5  
Old 10-10-2008, 05:05 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Chompy View Post
Oh, you just revived a 2 year old thread D:
There's nothing wrong with that in a forum such as Code Gallery.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 12-31-2008, 03:50 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Isn't sleep() GS1 and shouldn't be used in GS2 at all?

It screws up my timers rofl
Reply With Quote
  #7  
Old 12-31-2008, 04:15 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
no, just don't add a sleep inside a timeout lol
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:14 PM.


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