PDA

View Full Version : Dexterity Rope & Posts Question


Alpho
02-20-2015, 07:26 PM
Hello! I have another scripting question.

I'm trying to make 2 wooden posts, with a rope connecting them, which a player can grab to walk across. This would be for a Dexterity skill later on. Right now, the only problem I'm having is that the rope which connects the posts shows incorrectly. When a player grabs a post and walks across the rope, I changed the layer of the rope to 0 so that it shows under my player. Though, doing so resulted in any other player that walks "underneath" the rope (not walking on it) now shows on top of it.

There's probably another better way all together to show the rope..or even a better way to do this all together? I posted the code and an image of the code's result below.

Each post is joined to the class "dexterity_post".
Each post has the direction in which the player should be walking set to this.attr[2];

I plan to add left and right directions to this later as well. I suppose the best way to do it would be to add all directions (diagonal too) with one detection script?

//#CLIENTSIDE
function onCreated() {
this.setshape2(1, 2, {
0,
22
});

temp.radius = 64;

temp.npcs = this.level.findareanpcs(
this.x - (temp.radius / 2),
this.y - (temp.radius / 2),
temp.radius,
temp.radius
);

for (temp.npc : temp.npcs) {
if (temp.npc != this) {
if (temp.npc.isinclass("dexterity_post")) {
this.link = {temp.npc.x - 1, temp.npc.y - 1};
}
}
}

switch (this.attr[2]) {
case "down":
with (findimg(1)) {
x = this.x + 0.4;
y = this.y + (thiso.link[1] - thiso.y - 5);
image = "olwest_lassorope.png";
layer = 2;
stretchy = (thiso.link[1] - thiso.y) / 1.5;
}
break;
}
}

function onActionGrab() {
player.x = this.x - 1;
player.y = this.y - 1;

temp.ani_walk = "walk";
player.pauseani(10);
movement.onFreeze(10);

findimg(1).layer = 0;

switch (this.attr[2]) {
case "up":
player.dir = 0;

while (player.y != this.link[1] - 1) {
player.y -= 0.5;
player.ani = temp.ani_walk;
sleep(0.05);
}
break;
case "down":
player.dir = 2;

while (player.y != this.link[1] + 2) {
player.y += 0.5;
player.ani = temp.ani_walk;
sleep(0.05);
}
break;
}

findimg(1).layer = 2;
player.pauseani(0);
movement.onFreeze(0);
player.ani = player.idleani;
}

http://i.imgur.com/yQheVCq.png
Note: The post graphics are not final and are just placeholders