Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
Register ProjectsBlogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-22-2010, 11:36 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
Shovel

http://forums.graalonline.com/forums...ad.php?t=73836
/\
PHP 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", {102329910100816130197131147114}},
    {
"sand", {301171170299329923010297715,  83813822881812976}},
    {
"darksand", {170947949895847904339905}}
  };
  for (
temp.currentTilestemp.allTiles)
  {
    if (
temp.tilePosition in temp.currentTiles[1])
    {
      
temp.foundTile temp.currentTiles[0];
      break;
    }
  }
  return 
temp.foundTile;
}
function 
doDrops(dropPositiondropMode)
{
  for (
temp.currentDroptemp.dropMode)
  {
    if (
temp.currentDrop[1] != 0)
    {
      
temp.doDrop = (random(0300) < temp.currentDrop[1]? truefalse);
    }
     else
    {
      
temp.doDrop true;
    }
    if (
temp.doDrop)
    {
      
putnpc2(temp.dropPosition[0], temp.dropPosition[1], ("join" SPC temp.currentDrop[0] @";"));
    }
  }
}
public function 
dropPosition()
{
  
temp.playerPos = {{0.751}, {0.61.5}};
  
temp.dropPos = {
    
player.+ (player.dir in {02}? temp.playerPos[0][0] : temp.playerPos[1][0]) + vecx(player.dir) * 2,
    
player.+ (player.dir in {02}? temp.playerPos[0][1] : temp.playerPos[1][1]) + vecy(player.dir) * 2
  
};
  return 
temp.dropPos;
}
//#CLIENTSIDE
function onWeaponFired()
{
  
triggerserver("weapon"this.name"dig");
  
setani("grab",NULL);

how would i make that drop sumthing? also only dig in sand and leave a rock lifted hole?
Reply With Quote
  #2  
Old 07-22-2010, 11:45 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 4,963
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
By learning how to script.
__________________
Reply With Quote
  #3  
Old 07-22-2010, 11:46 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
Quote:
Originally Posted by fowlplay4 View Post
By learning how to script.
Ha. Your funny. I know how to script im trying to do what i am saying but it isnt working out so good.
Reply With Quote
  #4  
Old 07-22-2010, 11:58 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 4,963
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by xMane View Post
Ha. Your funny. I know how to script im trying to do what i am saying but it isnt working out so good.
Then it should have been obvious to..

Edit the checkTiles, and how the switch statement evaluates the value returned by it.

You can use a script like this to get the tiles ID.

PHP Code:
//#CLIENTSIDE
function onMouseDown() {
  
player.chat "Tile: " tiles[mousexmousey];

__________________
Reply With Quote
  #5  
Old 07-23-2010, 12:01 AM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
oooooooooooo. lol so how would it check if player.x.tiles or wat how would i check if its in the tiles?
Reply With Quote
  #6  
Old 07-23-2010, 12:13 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,010
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Where did you get this code from? It's obviously not yours, seems beyond your skill level.
__________________
Reply With Quote
  #7  
Old 07-23-2010, 12:13 AM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
they'res a link at the top >.> also how do i find the current tile i am on?
Reply With Quote
  #8  
Old 07-23-2010, 12:25 AM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Quote:
Originally Posted by xMane View Post
how do i find the current tile i am on?
Quote:
Originally Posted by fowlplay4 View Post
You can use a script like this to get the tiles ID.

PHP Code:
//#CLIENTSIDE
function onMouseDown() {
  
player.chat "Tile: " tiles[mousexmousey];

Reply With Quote
  #9  
Old 07-23-2010, 12:30 AM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
OOOOOOOOOH. didnt notice xD
Reply With Quote
  #10  
Old 07-23-2010, 01:33 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,669
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 repute
Send a message via AIM to cbk1994
Look into putnpc2...

Quote:
Originally Posted by fowlplay4 View Post
By learning how to script.
__________________
Reply With Quote
  #11  
Old 07-23-2010, 06:07 AM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
Ok I fully scriptd it from scrach thanks for ur help guys I ended up not using putnpc2 atm but imma add it l8r. 1 question also how do I change colors effect on a light2.png in a gani.
Reply With Quote
  #12  
Old 07-23-2010, 08:09 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,100
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
haha you used my old script, thanks.

Inside the gani use
HTML Code:
COLOREFFECT SPRITEINDEX 1 1 1 0.5
__________________
Reply With Quote
  #13  
Old 07-23-2010, 04:50 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
Quote:
Originally Posted by xAndrewx View Post
haha you used my old script, thanks.

Inside the gani use
HTML Code:
COLOREFFECT SPRITEINDEX 1 1 1 0.5
Thanks xD. I love the shovel script but for somereason it was'nt working properly so i had to script it again. xD mynes sucks but its "ok".
PHP Code:
function onActionServerSide(trigger)
{
 if(
trigger == "randomize")
 {
  
temp.random=int(random(0,10));
  if(
temp.random==0)
{
  
setani("ge_chestfound",NULL);
//adding diff amounts of gralats
}
 }
  if(
trigger == "dig")
 {
 
temp.sandtiles = {170,15,8,301,358,391};
 if(
tiles[player.x,player.yin temp.sandtiles)
 {
  
setani("ge_shovel",NULL);
  }else
   
setani("shovel2",NULL);
 }
}
//#CLIENTSIDE
function onWeaponFired()
{

 
triggerserver("gui"name"dig");
 
triggerserver("gui"name"randomize");

Reply With Quote
  #14  
Old 07-23-2010, 05:28 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 4,963
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well that's some fail triggering right there, why are you doing things that should be done on the clientside on the serverside?

PHP Code:
function onActionServerSide(trigger

 if(
trigger == "award"
 { 
  
// stuff 
 


//#CLIENTSIDE 
function onWeaponFired() 

 
temp.sandtiles = {170,15,8,301,358,391}; 
 if(
tiles[player.x,player.yin temp.sandtiles
 { 
  
setani("ge_shovel",NULL); 
  
temp.random=int(random(0,10));  
  if(
temp.random==5)  
  {  
    
setani("ge_chestfound",NULL);
    
triggerserver("gui"name"award");
  } 
 } else {
   
setani("shovel2",NULL); 
 } 

__________________
Reply With Quote
  #15  
Old 07-23-2010, 05:48 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
Dont wanna be hackable :/. sooya. i changed it. but now how do i add freeze to it
PHP Code:
function onActionServerSide(trigger)
{
 if(
trigger == "randomize")
 {
  
temp.random=int(random(0,10));
  if(
temp.random==0)
  {
   
player.gralats+=int(random(10,75));
  
setani("ge_chestfound",NULL);
  }
 }
  if(
trigger == "dig")
 {
 
temp.sandtiles = {170,15,8,301,358,391};
 if(
tiles[player.x,player.yin temp.sandtiles)
 {
  
setani("ge_shovel",NULL);
  
//removed clientr.lastdig={player.x,player.y};
  
triggerclient("gui"name"DoRandom");
  }else
   
setani("shovel2",NULL);
 }
}
//#CLIENTSIDE
function onWeaponFired()
{
 
triggerserver("gui"name"dig");
}
function 
onDoRandom();
{
 
triggerserver("gui"name"randomize");

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:54 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.