This repository was archived by the owner on Nov 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongswords_v2_1.js
More file actions
47 lines (47 loc) · 1.38 KB
/
Longswords_v2_1.js
File metadata and controls
47 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var pYaw = 0;
var zVel = 0;
var xVel = 0;
//Determines how powerful the sword is, default is 1, 0 to disable the movement.
var moveAmp =1;
function useItem(x, y, z, itemId, blockId, side)
{
//if you tapped using an iron, gold, or diamond sword
if ((itemId == 276) || (itemId ==283) || (itemId ==267)){
if (getPlayerZ()-z >= -1 && getPlayerZ()-z <= 1 && getPlayerX()-x >= -1 && getPlayerX()-x <= 1)
{
setVelY(getPlayerEnt(),0.8)
}
else
{
//correcting the yaw
pYaw = getYaw(getPlayerEnt())
while (pYaw < 0) {
pYaw = pYaw + 360;
}
while (pYaw > 360) {
pYaw = pYaw - 360;
}
//z axis movement
if((pYaw >= 90&&pYaw <= 270) == false){
if(pYaw >= 0&&pYaw <= 90) {zVel = ((90-pYaw)/90)}
else if(pYaw < 360&&pYaw >= 270) {zVel = ((pYaw-270)/90)}
}
if(pYaw >= 90&&pYaw <= 270) {
if(pYaw >= 90&&pYaw < 180){zVel = (((pYaw - 90)/-90))}
else if(pYaw >180&&pYaw < 270) {zVel = ((90-pYaw+180)/-90)}
}
//x axis movement
if(pYaw >= 0&&pYaw <= 180) {
if(pYaw > 0&&pYaw <= 90) {xVel = (pYaw/-90)}
if(pYaw > 90&&pYaw < 180) {xVel = ((90-pYaw+90)/-90)}
}
if(pYaw >=180&&pYaw < 360) {
if(pYaw >=180&&pYaw < 270){xVel = ((pYaw-180)/90)}
if(pYaw >=270&&pYaw < 360){xVel = ((90-pYaw+270)/90)}
}
setVelY(getPlayerEnt(),0.4)
setVelZ(getPlayerEnt(),(zVel*moveAmp))
setVelX(getPlayerEnt(),(xVel*moveAmp))
}
}
}