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 05-05-2007, 07:15 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Shovel

HTML Code:
function onActionServerside(serverOption)
{
  if (temp.serverOption != "dig")
  {
    return false;
  }
  temp.digPosition = player.dropPosition();
  if (clientr.lastDig[0] == temp.digPosition[0] && clientr.lastDig[1] == clientr.lastDig[1])
  {
    return false;
  }
  
  temp.digCheck = this.checkTiles(temp.digPosition);
  
  clientr.lastDig = temp.digPosition;
  setani("v_shovel", "v_shovel-"@ temp.digCheck @".png");
  
  switch (temp.digCheck)
  { 
    case "grass":
      this.doDrops(temp.digPosition, {{"object_hole", 0}, {"object_artifact", 290}});
    break;
    
    case "sand":
      this.doDrops(temp.digPosition, {{"object_sandhole", 280}, {"generator_dungeon", 0}});
    break; 
  }
}
function checkTiles(position)
{
  temp.tilePosition = tiles[temp.position[0], temp.position[1]];
  temp.allTiles = {
    {"grass", {1023, 299, 1, 0, 1008, 16, 130, 197, 131, 147, 114}},
    {"sand", {301, 171, 170, 2993, 2992, 3010, 2977, 15,  8, 381, 382, 288, 181, 2976}},
    {"darksand", {170, 947, 949, 895, 847, 904, 339, 905}}
  };
  for (temp.currentTiles: temp.allTiles)
  {
    if (temp.tilePosition in temp.currentTiles[1])
    {
      temp.foundTile = temp.currentTiles[0];
      break;
    }
  }
  return temp.foundTile;
}
function doDrops(dropPosition, dropMode)
{
  for (temp.currentDrop: temp.dropMode)
  {
    if (temp.currentDrop[1] != 0)
    {
      temp.doDrop = (random(0, 300) < temp.currentDrop[1]? true: false);
    }
     else
    {
      temp.doDrop = true;
    }
    if (temp.doDrop)
    {
      putnpc2(temp.dropPosition[0], temp.dropPosition[1], ("join" SPC temp.currentDrop[0] @";"));
    }
  }
}
      
//#CLIENTSIDE
function onWeaponFired()
{
  triggerserver("weapon", this.name, "dig");
}
A shovel, works with pics1.png. Uses PUTNPC2 for classes
Reply With Quote
  #2  
Old 05-05-2007, 07:23 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Nice work Chandler.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #3  
Old 05-05-2007, 08:50 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Good job, clean and simple.
Reply With Quote
  #4  
Old 05-05-2007, 08:58 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
player.dropPosition();

Besides that, nice code. Doubt it'll be used by anyone but theHAWKER who will come complain about it, but it's pretty nice. Looks simple to edit aswell.
__________________
Reply With Quote
  #5  
Old 05-05-2007, 09:11 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Ahh, my public function!
Reply With Quote
  #6  
Old 05-05-2007, 10:27 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Chandler View Post
Ahh, my public function!
Share it please :*(

I hate vectors z.z
__________________
Reply With Quote
  #7  
Old 05-06-2007, 05:14 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Yes, please show.

*1000th post*
Reply With Quote
  #8  
Old 05-06-2007, 05:19 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
It's in his core script thingy. You can find it in examples on Skyld's wiki methinks.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #9  
Old 05-06-2007, 08:31 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by killerogue View Post
It's in his core script thingy. You can find it in examples on Skyld's wiki methinks.
Yeah

HTML Code:
public function dropPosition()
{
  temp.playerPos = {{0.75, 1}, {0.6, 1.5}};
  temp.dropPos = {
    player.x + (player.dir in {0, 2}? temp.playerPos[0][0] : temp.playerPos[1][0]) + vecx(player.dir) * 2,
    player.y + (player.dir in {0, 2}? temp.playerPos[0][1] : temp.playerPos[1][1]) + vecy(player.dir) * 2
  };
  return temp.dropPos;
}
Reply With Quote
  #10  
Old 05-06-2007, 03:54 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Chandler View Post
Yeah

HTML Code:
public function dropPosition()
{
  temp.playerPos = {{0.75, 1}, {0.6, 1.5}};
  temp.dropPos = {
    player.x + (player.dir in {0, 2}? temp.playerPos[0][0] : temp.playerPos[1][0]) + vecx(player.dir) * 2,
    player.y + (player.dir in {0, 2}? temp.playerPos[0][1] : temp.playerPos[1][1]) + vecy(player.dir) * 2
  };
  return temp.dropPos;
}
Woah, I never thought about doing it like that! Thanks
Reply With Quote
  #11  
Old 05-06-2007, 08:08 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Quote:
Originally Posted by cbkbud View Post
player.dropPosition();

Besides that, nice code. Doubt it'll be used by anyone but theHAWKER who will come complain about it, but it's pretty nice. Looks simple to edit aswell.
ur evil...

and i took ur advice and i learnd how to script in gs2...
__________________
**FLIP OUT**
Reply With Quote
  #12  
Old 05-06-2007, 08:11 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by theHAWKER View Post
ur evil...
And you have a notorious reputation

Quote:
Originally Posted by theHAWKER
and i took ur advice and i learnd how to script in gs2...
Great! When can we expect submissions in the code gallery? . More people (including myself) need to post there.
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 01:20 AM.


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