I have made a pretty poor grappling hook and done it a weird way but oh well lol it still works. I was wondering if anyone would happen to have any knowledge on how to make it so you could hit a player and press a to reel them towards you maybe lmao.
Also how would I detect if it hits lets say for instance a bush? then it could change the bush tiles to cut down bush tiles, I know how that is done, Via tiles and updateboard.
But the detection of specific tiles I'm unsure of.
Here's my script so far.
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.pullin = false;
this.shooting = false;
this.pullable = false;
}
function onWeaponFired() {
hideimgs(200, 10000);
this.dir = player.dir;
this.sx = player.x + 1;
this.sy = player.y + 1.5;
this.shooting = true;
onTimeout();
}
function onTimeout() {
if (this.shooting == true) {
showpoly(1, {
player.x + 1, player.y + 1.5, this.sx, this.sy
});
findimg(1).layer = 0;
findimg(1).red = 0;
findimg(1).green = 1;
findimg(1).blue = 0;
this.sx2 = this.sx;
this.sy2 = this.sy;
if (this.dir == 0 && !onwall(this.sx, this.sy - 0.5)) {
this.sy -= 0.5;
}
if (this.dir == 1 && !onwall(this.sx - 0.5, this.sy)) {
this.sx -= 0.5;
}
if (this.dir == 2 && !onwall(this.sx, this.sy + 0.5)) {
this.sy += 0.5;
}
if (this.dir == 3 && !onwall(this.sx + 0.5, this.sy)) {
this.sx += 0.5;
}
freezeplayer(1);
if(this.sx2 == this.sx && this.sy2 == this.sy){
Hit();
settimer(0);
findimg(1).red = 1;
findimg(1).green = 0;
findimg(1).blue = 0;
return;
}
}
if (this.pullin == true) {
freezeplayer(1);
showpoly(1, {
player.x + 1, player.y + 1.5, this.sx, this.sy
});
findimg(1).layer = 0;
findimg(1).red = 1;
findimg(1).green = 0;
findimg(1).blue = 0;
if (this.dir == 0 && player.y > this.sy) {
player.y -= 0.5;
}
if (this.dir == 2 && player.y < this.sy) {
player.y += 0.5;
}
if (this.dir == 1 && player.x > this.sx) {
player.x -= 0.5;
}
if (this.dir == 3 && player.x < this.sx) {
player.x += 0.5;
}
if (player.y == this.sy) {
if (this.dir == 0 || this.dir == 2) {
this.pullin = false;
freezeplayer(0);
hideimg(1);
}
}
if (player.x == this.sx) {
if (this.dir == 1 || this.dir == 3) {
this.pullin = false;
freezeplayer(0);
hideimg(1);
}
}
}
settimer(0.05);
}
function Hit() {
this.pullable = true;
player.chat = "Press A to reel in!";
}
function onKeyPressed(code, key) {
if (key == "a" && this.pullable == true) {
this.pullable = false;
this.shooting = false;
this.pullin = true;
onTimeout();
}
}