Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   shorter way? (https://forums.graalonline.com/forums/showthread.php?t=76269)

Angel_Light 08-14-2007 04:12 AM

shorter way?
 
is there a shorter way to do this?

PHP Code:

  if ( player.dir == 0) {
    if ( 
tiletypeintthis.x), int(this.y-1)) != 22)
      goto( 
int(this.x), int(this.y-1));
  }
  
  else if ( 
player.dir == 1) {
    if ( 
tiletypeint(this.x-1), int(this.y)) != 22)
      goto( 
int(this.x-1), int(this.y));
  }
  
  else if ( 
player.dir == 2) {
    if ( 
tiletypeint(this.x), int(this.y+1)) != 22)
      goto( 
int(this.x), int(this.y+1));
  }
  
  else if ( 
player.dir == 3) {
    if ( 
tiletypeint(this.x+1), int(this.y)) != 22)
      goto( 
int(this.x+1), int(this.y));
  } 


DustyPorViva 08-14-2007 04:19 AM

Yes, with vecx/y :)

PHP Code:

for (i=0;i<4;i++) {
  if (
player.dir==&& tiletype(int(this.x+vecx(player.dir)), int(this.y+vecx(player.dir))) != 22) {
     goto(
int(this.x+vecx(player.dir)), int(this.y+vecx(player.dir)))
  }



Angel_Light 08-14-2007 04:35 AM

Your amazing ^^

EDIT : Works great except it moves in diagonals XD fix?

Chompy 08-14-2007 04:31 PM

PHP Code:

for(temp.04++) {
  if (
player.dir == i) {
    
temp.tx int(this.+ (i==1?-1:(i==3?1:0));
    
temp.ty int(this.+ (i==0?-1:(i==2?1:0));
    if (
tiletype(txty) != 22) {
      goto(
txty);
    }
  }


PHP Code:

temp.= {
  { 
0,-1},
  {-
10},
  { 
01},
  { 
10}
};
temp.player.dir;
if (
tiletype(int(this.a[b][0], this.a[b][1])) != 22) {
  goto(
int(this.a[b][0], this.a[b][1]);


dunno if they work (no vecx/y used ;o)

xXziroXx 08-14-2007 05:25 PM

PHP Code:

for (i=0;i<4;i++) {
  if (
player.dir==&& tiletype(int(this.x+vecy(player.dir)), int(this.y+vecx(player.dir))) != 22) {
     goto(
int(this.x+vecy(player.dir)), int(this.y+vecx(player.dir)))
  }



coreys 08-14-2007 07:18 PM

lol
everyone has their own way.

Chompy 08-14-2007 08:27 PM

PHP Code:

for (i=0;i<4;i++) {
  if (
player.dir == && tiletype(int(this.x+vecy(i)), int(this.y+vecx(i)) != 22)
     goto(
int(this.x+vecy(i)), int(this.y+vecx(i)));


wee..?

zokemon 08-15-2007 01:06 AM

I fail to see the need for a loop here...
PHP Code:

if (tiletype(int(this.vecx(player.dir)), int(this.vecy(player.dir))) != 22)
  goto(
int(this.vecx(player.dir)), int(this.vecy(player.dir)); 


Chompy 08-15-2007 01:37 AM

Zero comes and saves the cpu/lag time again!

DustyPorViva 08-15-2007 02:10 AM

Quote:

Originally Posted by zokemon (Post 1340092)
I fail to see the need for a loop here...
PHP Code:

if (tiletype(int(this.vecx(player.dir)), int(this.vecy(player.dir))) != 22)
  goto(
int(this.vecx(player.dir)), int(this.vecy(player.dir)); 


Hmm, very good point! I completely missed that.

zokemon 08-15-2007 08:28 AM

:p


All times are GMT +2. The time now is 07:44 AM.

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