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-01-2007, 11:38 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
Bush Destroying System

Hi people, someone needed a bush destroying system, and I needed one for my server anyway, so here it is. Basicly how it works:

When called, checks if there are bushes near player (player facing). If there is, triggers an event on serverside to change the tiles to the dead bush tiles, then puts an NPC joining the class "effect_bush" which shows the effect typically shown. (This can be edited to drop a rupee, or something). The server automaticly changes this tile back after x amount of seconds (determined in serveroptions as respawntime I think).

Here is the code.

Code for Weapon/GUI-Script -Player/Bush:
PHP Code:
// Made by Chris Zakuto
function onActionServerSidecmddpostiles )
{
  switch ( 
cmd )
  {
    case 
"changeBush":
    {
      
level.tilesdpos[0], dpos[1] ] = tiles[0];
      
level.tilesdpos[0] + 1dpos[1] ] = tiles[1];
      
level.tilesdpos[0], dpos[1] + ] = tiles[2];
      
level.tilesdpos[0] + 1dpos[1] + ] = tiles[3];
      
updateboarddpos[0], dpos[1], 2);
      
      
temp."effect_bush";
      
putnpc2dpos[0], dpos[1], "
      join( \"" 
temp."\" );
      " 
);
      break;
    }
  }
}
//#CLIENTSIDE
function onCreated()
{
  
/*
      1 2
      3 4
  */
  
  // Default tiles, should work fine. (Change if you need to)
  
this.tileOne 2;
  
this.tileTwo 3;
  
this.tileThree 18;
  
this.tileFour 19;
  
  
this.deadTileOne 677;
  
this.deadTileTwo 678;
  
this.deadTileThree 693;
  
this.deadTileFour 694;
  
doInit();
}
function 
doInit()
{
  
temp.vars = {
                
"tileOne",
                
"tileTwo",
                
"tileThree",
                
"tileFour"
              
};
  
  if ( 
this.bushTiles != NULL )
  {
    
this.bushTiles.clear();
  }
  
  for ( 
temp.atemp.vars )
  {
    
temp.value this.( @ temp.);
    
this.bushTiles.addtemp.value );
  }
}
public function 
destroyBushes()
{
  
temp.dirx_0 = { -2, -101};
  
temp.diry_0 = { -1};
  
temp.dirx_1 = { -2, -1};
  
temp.diry_1 = { -2, -101};
  
temp.dirx_2 = { -2, -101};
  
temp.diry_2 = { 0123};
  
temp.dirx_3 = { -10123};
  
temp.diry_3 = { -3, -2, -1012};
  
  if ( 
this.tempTiles != NULL )
  {
    
this.tempTiles.clear();
  }
  for ( 
temp.itemp.( @ "dirx_" player.dir ) )
  {
    for ( 
temp.atemp.( @ "diry_" player.dir ) )
    {
      
temp.tile tilesintplayer.) + temp.iintplayer.) + temp.];
      if ( 
temp.tile in this.bushTiles )
      {
        
temp.obj = { temp.tile, { intplayer.) + temp.iintplayer.) + temp.} };
        
this.tempTiles.addtemp.obj );
      }
    }
  }
  if ( 
checkBushthis.tempTiles ) == true )
  {
    if ( 
temp.tileOne != NULL )
    {
      
temp.tileOne.clear();
    }
    for ( 
temp.nthis.tempTiles )
    {
      if ( 
temp.n[0] == )
      {
        
temp.tileOne.addtemp.n[1] );
      }
    }
    for ( 
temp.ztemp.tileOne )
    {
      
triggerServer"gui"name"changeBush"temp.z, { this.deadTileOnethis.deadTileTwothis.deadTileThreethis.deadTileFour } );
    }
  }
}
function 
checkBushtiles )
{
  for ( 
temp.ithis.bushTiles )
  {
    
temp.foo false;
    for ( 
temp.atiles )
    {
      if ( 
temp.a[0] == temp.)
      {
        
temp.foo true;
      }
    }
    if ( 
temp.foo == false )
    {
      return 
false;
    }
    
    
temp.foo false;
  }
  return 
true;

Here is the class for the bush killing effect, which can be modified easily.

Code for Class effect_bush:
PHP Code:
function onCreated()
{
  
sleep.5 );
  
destroy();
}
//#CLIENTSIDE
function onCreated()
{
  
putleaps0this.xthis.);

To call the bush killing, just trigger the weapon like so.

PHP Code:
( @ "-Player/Bush" ).destroyBushes(); 
If you need any help installing this system/modifying it, I'm happy to help.
__________________
Reply With Quote
  #2  
Old 05-01-2007, 11:56 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Cool, could be a little laggy though
Reply With Quote
  #3  
Old 05-02-2007, 12:16 AM
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 Rapidwolve View Post
Cool, could be a little laggy though
I know, but this is the best way I could think of doing it. When I tested it, there wasn't much lag, just slightly slower than default. It's really not much slower.
__________________
Reply With Quote
  #4  
Old 05-02-2007, 12:26 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
I think you're taking him too literally when he said he wanted a Bush destroying system. The other Bush is what he meant!
Reply With Quote
  #5  
Old 05-02-2007, 12:44 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Alert
Novo, cbkbud, and Stan are missing, the goverment has nothing to say on this issue.
Reply With Quote
  #6  
Old 05-02-2007, 03:59 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
temp.idiot = new TStaticVar();
I thought you couldn't destroy non-TStaticVars
Reply With Quote
  #7  
Old 05-02-2007, 04:15 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Rapidwolve View Post
temp.idiot = new TStaticVar();
I thought you couldn't destroy non-TStaticVars

temp vars are temporary, so what would there be to destroy?
Reply With Quote
  #8  
Old 05-02-2007, 08:05 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
lol

I made my own, hehe.
Thanks!
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 07:33 PM.


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