Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 04-16-2011, 05:02 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
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
Here's how Zodiac's baddy movement works. It doesn't move directly to the player in one step but instead takes it in strides of 0.5 seconds of movement at max.

PHP Code:
// Removed Zodiac Specific Code
function onPlayerEnters() {
  if (!
this.on) {
    
this.on true;
    
onTimeout();
  }
}

function 
onTimeout() {
  if (
players.size() < 1) {
    
this.on false;
    return;
  }
  
chase(players[0]);
}

function 
chase(target) {
  
// Set Speed
  
temp.speed .3;
    
  
// Calculate Position in front of Target
  
temp.tpos = {target.vecx(this.dir)*2.5target.vecy(this.dir)*2.5};
  
// Calculate Distance to Target
  
temp.dist = ((temp.tpos[0] - x)^+ (temp.tpos[1] - y)^2)^.5;
  
// Calculate Steps Required 
  
temp.steps temp.dist temp.speed;
  
// Avoid Too Many Steps
  
if (temp.steps 10)
    
temp.steps 10;

  
// Calculate Angle towards Target
  // Random helps prevent clumping of npcs
  
temp.angle getangle(temp.tpos[0] - xtemp.tpos[1] - y) + random(-0.2,0.2);
  
// Calculate the Delta
  
temp.dx cos(temp.angle) * temp.speed;
  
temp.dy = -sin(temp.angle) * temp.speed;

  
setcharani("walk"this.attr[2]);
  
move(temp.dx temp.stepstemp.dy temp.stepsint(temp.steps) * .058);

  
setTimer(int(temp.steps) * .05);
}

function 
onMovementFinished() {
  
setcharani("idle""");

Sure it still allows baddies to walk over walls but it's an even bigger issue when players can glitch them into corners and abuse the situation.
__________________
Quote:
Reply With Quote
 


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 10:48 PM.


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