Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   move() blockcheck? (https://forums.graalonline.com/forums/showthread.php?t=134264860)

iBeatz 10-24-2011 03:57 PM

move() blockcheck?
 
What exactly is this parameter and how is it used?

callimuc 10-24-2011 04:32 PM

This is something from a project Dusty made once.

PHP Code:

function onCreated() {
  
showcharacter();
  
this.dir = (int(random(0,2))*2)+1;
  
this.attr[1] = "ce_chicken-white.png";
  
setCharani("ce_chicken_idle",null);
  
setTimer(random(.25,2));
}

function 
onTimeout() {
  
temp.dx random(-3,3);
  
temp.dy random(-3,3);
  
temp.dist = (dx^2+dy^2)^.5;
  
temp.checkwall 0;
  for (
temp.i=0;i<dist;i+=.5) {
    
//if (onwall2(this.x+.5+((dx/dist)*.5)+(dx*i),this.y+1+((dy/dist)*.5)+(dy*i),2,2)) {
    
if (onwall2(this.x+1+(dx/dist)+(dx*i),this.y+1+(dy/dist)+(dy*i),1,1) || onwater(this.x+1.5+(dx/dist)+(dx*i),this.y+1.5+(dy/dist)+(dy*i))) {
      
checkwall 1;
      break;
    }
  }
  if (
checkwall == 1) {
    
setTimer(.1);
    return;
  }

  
setCharani("ce_chicken_walk",null);
  if (
dx 0this.dir 3;
  else 
this.dir 1;
  
move(dx,dy,dist/3,8);
}


function 
onMovementfinished() {
  
setCharani("ce_chicken_idle",null);
  
setTimer(random(.1,2));



Semms like there is no parameter for that. Just using onwall2().

fowlplay4 10-24-2011 05:12 PM

It's built-in wall checking for an object when move is called.

You use it like this:

move(dx, dy, time, 4);

If you want blockcheck and eventwhendone (onMovementFinished) you do:

move(dx, dy, time, 4 + 8);

Personally I have had no pleasant experiences with it at least on the serverside and can't really recommend it then again I haven't used it in ages.

Crow 10-24-2011 07:34 PM

I believe that once it hits a wall, it will set the NPC back to the position it had before the move() call; so it's quite useless.

DustyPorViva 10-24-2011 08:17 PM

Quote:

Originally Posted by callimuc (Post 1671636)
This is something from a project Dusty made once.

Semms like there is no parameter for that. Just using onwall2().

There is a parameter for it, but it's not very reliable.

My method simply scans for the nearest wall, and makes sure the move() does not exceed that space.


All times are GMT +2. The time now is 05:06 AM.

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