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 07-16-2007, 10:49 AM
HolySheepy HolySheepy is offline
Registered User
Join Date: Apr 2007
Posts: 68
HolySheepy is on a distinguished road
Anti-Blocking Script

Hi,

so there was this Spar Room, but outside of the Spar the people where annoyed because they were blocked by other people. So i made this script.

Credits
  • Misconception - for helping me with testing it
  • kc/KirbyZen - for helping me with testing it
  • Tortoise - for allowing me to make it public
  • The people on these forums, that told me to use player.level.name instead of player.level

This Script was made for Delteria and was first used there. But you can use it on your server if you want.

If you find any bugs, let me know.

This script was styled with the /style command of the rc, so don't blame me for styling :P

this.includelevels = if you have this.exmode = 1; this is a list of levels where the script will be enabled

this.excludelevels = if you have this.exmode = 0; this is a list of levels where the script will be disabled

this.disabledzones = a list of arrays
format for each array: { level, startx, starty, endx, endy }
if the players x and y are in startx/starty and endx/endy then the script will be disabled

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.oldx = -1;
  
this.oldy = -1;
  
this.oldkeydown = { 000};
  
this.includelevels = { "kaljun_sparcomplexmain.nw" };
  
this.excludelevels = { };
  
this.disabledzones = { { "kaljun_sparcomplexmain.nw"17.51743.532 } };
  
this.exmode 1;
  
// Ex Modes:
  // 0 - Used in every Level except for those in this.excludelevels
  // 1 - Used only in Levels of this.includelevels
  
setTimer0.05 );
}
function 
onTimeout() {
  
this.speed player.shieldpower == 0.6 0.5;
  
this.modx = { 0, -this.speed0this.speed };
  
this.mody = { -this.speed0this.speed};
  
this.cmodx = { 000};
  
this.cmody = { 002};
  
this.mods = { "y""x""y""x" };
  if ( 
checkLevel() == true ) {
    if ( 
checkDisabled() == true) {
      
setTimer0.05 );
      return ;
    }
    for ( 
0this.modx.size(); i++ ) {
      if ( 
keydown) ) {
        if ( 
this.oldkeydown] == ) {
          
this.oldkeydown] = 1;
        } else {
          if ( 
this.(@ "old" this.mods] ) == player.(@ this.mods] )) {
            if ( !
onwall3player.0.5 this.modx], player.this.mody], 2) && testplayer2player.0.5 this.modx] + this.cmodx], player.this.mody] + this.cmody] ) != -) {
              if ( 
player.ani != "walk" ) {
                if ( 
player.ani == "grab" || player.ani == "pull" ) {
                  if ( 
keydown) ) {
                    
setTimer0.05 );
                    return ;
                  }
                }
                if ( 
checkTiletypesplayer.0.5 this.modx], player.this.mody], 22, { } ) == true ) {
                  
setani"sit""");
                }
                else if ( 
checkTiletypesplayer.0.5 this.modx], player.this.mody], 22, { 1112 } ) == true ) {
                  
setani"swim""" );
                }
                else {
                  
setani"walk""" );
                }
              }
              
player.+= this.modx];
              
player.+= this.mody];
            }
          }
        }
      } else {
        if ( 
this.oldkeydown] == )
          
this.oldkeydown] = 0;
      }
    }
  }
  
this.oldx player.x;
  
this.oldy player.y;

  
setTimer0.05 );
}

function 
checkDisabled() {
for ( 
czthis.disabledzones ) {
    if ( 
cz] == player.level.name ) {
      if ( 
player.x in cz], cz] | && player.y in cz], cz] | )
        return 
true;
    }
  }
  return 
false;
}

function 
checkLevel() {
  switch ( 
this.exmode ) {
    case 
0: {
        return ( !( 
player.level.name in this.excludelevels ) );
      }
      break;
    case 
1: {
        return ( 
player.level.name in this.includelevels );
      }
      break;
  }
  return 
false;
}

function 
onwall3startxstartycheckwcheckh ) {
  return ( 
checkTiletypesstartxstartycheckwcheckh, { 202122 } ) );
}

function 
checkTiletypesstartxstartycheckwcheckhtilec ) {
  
this.foundw 0;
  if ( 
tiletypestartxstarty in tilec ) {
    
this.foundw 1;
  }
  if ( 
this.foundw == ) {
    for ( 
cx startxcx startx checkwcx += 0.1 ) {
      for ( 
cy startycy starty checkhcy += 0.1 ) {
        if ( 
tiletypecxcy in tilec ) {
          
this.foundw 1;
          break;
        }
      }
    }
  }
  return ( 
this.foundw );
}

function 
testplayer2checkxchecky ) {
for ( 
pplayers ) {
    if ( 
player.id != p.id )
      if ( 
checkx in p.1.5p.| && checky in p.0.5p.| )
        return ( 
p.id );
  }
  return ( -
);

p.s.: maybe i will do some optimization and post a updated version

Last edited by HolySheepy; 07-16-2007 at 11:03 AM..
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:52 AM.


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