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.x, this.y))
destroy();
for (temp.pl : this.level.players) {
}
for (temp.nc : this.level.npcs) {
}
this.x += cos(this.attr[1]);
this.y += 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... _|