View Single Post
  #1  
Old 09-01-2007, 03:12 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
A problem with getangle

Currently scripting some custom projectiles however I'm having a problem with my getangle();

PHP Code:
/*

  ** Custom Projectile Notes **
: Attributes
  - Attr 1: Base Direction
  - Attr 2: Speed Calc
  - Attr 3: P-Type, (Random, Track)
  - Attr 4: Tracking Who/Owner, (String: Npc, Player)
  - Attr 5: (Npc/Player Id
  - Attr 6: Coords of mouse click
 
: Variables
  - Speed: How fast this projectile will travel
 
*/
function onCreated() {
  
canwarp();
  
canwarp2();
  
  
setimg("block.png");
  
setTimer(0.1);
}
function 
onTimeout() {
  if (
this.attr[3] == "random") {
    echo(
"Projectile: Has a randomized movement pattern.");
  }
  else if (
this.attr[3] == "track") {
    
temp.obj this.attr[4] == "npc" this.level.npcs[this.attr[5]] : this.level.players[this.attr[5]];
    if (
temp.obj.objecttype() in {"TServerPlayer""TServerNPC"}) {
      
temp.tx temp.obj.x;
      
temp.ty temp.obj.y;
    
      
this.dir getdir((temp.tx this.x), (temp.ty this.y));
      
this.attr[1] = getangle((temp.tx this.x), (temp.ty this.y));
    }
  }
  
this.chat "Direction: " this.dir;
  if (
onwall(this.xthis.y))
    
destroy();
  for (
temp.pl this.level.players) {
  }
  for (
temp.nc this.level.npcs) {
  }
  
this.+= cos(this.attr[1]);
  
this.+= sin(this.attr[1]);
   
  
setTimer(1);
}
function 
onPlayerChats() {
  if (
player.account in serveroptions.staffdevaccess.tokenize(",")) {
    if (
player.chat == ":destroy") {
      
destroy();
    }
  }

The major problem is where I use getangle to set this.attr[1]. It's getting the wrong angle tho that should work.

It's moving in an arc away from the player like this... _|
__________________
Stan.
Reply With Quote