Graal Forums

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

Chandler 05-05-2007 07:15 PM

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

killerogue 05-05-2007 07:23 PM

Nice work Chandler.

Rapidwolve 05-05-2007 08:50 PM

Good job, clean and simple.

cbk1994 05-05-2007 08:58 PM

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.

Chandler 05-05-2007 09:11 PM

Ahh, my public function!

cbk1994 05-05-2007 10:27 PM

Quote:

Originally Posted by Chandler (Post 1305724)
Ahh, my public function!

Share it please :*(

I hate vectors z.z

Rapidwolve 05-06-2007 05:14 AM

Yes, please show.

*1000th post*

killerogue 05-06-2007 05:19 AM

It's in his core script thingy. You can find it in examples on Skyld's wiki methinks.

Chandler 05-06-2007 08:31 AM

Quote:

Originally Posted by killerogue (Post 1305798)
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;
}


Rapidwolve 05-06-2007 03:54 PM

Quote:

Originally Posted by Chandler (Post 1305815)
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

theHAWKER 05-06-2007 08:08 PM

Quote:

Originally Posted by cbkbud (Post 1305718)
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...

Twinny 05-06-2007 08:11 PM

Quote:

Originally Posted by theHAWKER (Post 1305924)
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.


All times are GMT +2. The time now is 12:54 PM.

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