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 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
 


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 12:26 PM.


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