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
  #1  
Old 07-29-2008, 11:13 PM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
getDir()

I have a custom baddy script which I've written (It's still in progress so it just uses chat commands to test it's functionality so far) and I'm having some trouble with a certain command.

PHP Code:
function onCreated() {
  
this.isBaddy true;
  
this.maxHealth 100;
  
this.atkdmg 1;
  
setImg("Block.png");
  
this.chat "Rawr I'm a baddy!";
  
onTimeout();
}

function 
onPlayerChats() {
  
temp.movex player..5 vecx(player.dir) * 2;
  
temp.movey player..5 vecy(player.dir) * 2;
  if ( 
player.chat == "destroybaddy" destroy();
  elseif ( 
player.chat == "remove target" this.target NULL;
  elseif ( 
player.chat.tokenize()[0] == "target" ) {
    
this.target player.chat.tokenize()[1];
    
this.chat "Targeting: "this.target;
  }
  
}

function 
onTimeout() {
  
this.attack = ( this.attack # 40;
  
if ( this.target != NULL ) {
    
temp.findPlayer(this.target);
    
temp.movex temp.a..5 vecx(temp.a.dir) * 2;
    
temp.movey temp.a..5 vecy(temp.a.dir) * 2;
    if ( !(
this.x in |temp.movex-.5,temp.movex+.5|)  || !(this.y in |temp.movey-.5,temp.movey+.5|) ) {
      
this.last temp.test;
      
this.newmove = !this.newmove;
      
MoveTotemp.movex,temp.movey );
    }
    else if ( 
this.attack == 10 Attack();
  }
  if ( 
playerscount setTimer(0);
  else 
setTimer(.05);
}

//Move one space closer to newx,newy
function MoveTonewx,newy ) {
  
temp.angle getangle((newx this.x),(newy this.y));
  
this.xvel cos(temp.angle);
  
this.yvel sin(temp.angle);
  
this.+= this.xvel;
  
this.-= this.yvel;
  
this.dir getDirthis.this.);
  
this.chat "My dir is " this.dir;
}

//Testing removal of HP
function Attack() findPlayerthis.target ).clientr.myhealthstat -= this.atkdmg
Everything runs just fine except for this:

PHP Code:
  this.dir getDirnewx this.newy this.);
  
this.chat "My dir is " this.dir
This is always returning zero. I need to find the direction which the baddy is facing depending on where it moves so I can apply the proper direction for the setcharani animations for the baddy.
Anyone know what I may be doing wrong?

Also, this is my first custom baddy script. Any other CONSTRUCTIVE criticism or suggesstions for any other part of this script is obviously welcome.
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 08:38 PM.


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