Move get anim utils to shared
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
let ped = getElementFromId(pedId);
|
||||
|
||||
if(ped == null) {
|
||||
if (ped == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animationData[0]} for ped ${pedId}`);
|
||||
|
||||
let freezePlayer = false;
|
||||
switch(animationData.moveType) {
|
||||
switch (animationData.moveType) {
|
||||
case VRR_ANIMMOVE_FORWARD: {
|
||||
setElementCollisionsEnabled(ped, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(ped, getPosInFrontOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
@@ -30,7 +30,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
|
||||
case VRR_ANIMMOVE_BACK: {
|
||||
setElementCollisionsEnabled(pedId, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(pedId, getPosBehindPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
@@ -39,7 +39,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
|
||||
case VRR_ANIMMOVE_LEFT: {
|
||||
setElementCollisionsEnabled(pedId, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(pedId, getPosToLeftOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
@@ -48,7 +48,7 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
|
||||
case VRR_ANIMMOVE_RIGHT: {
|
||||
setElementCollisionsEnabled(pedId, false);
|
||||
if(ped.isSyncer) {
|
||||
if (ped.isSyncer) {
|
||||
setElementPosition(pedId, getPosToRightOfPos(getElementPosition(pedId), fixAngle(getElementHeading(pedId)), positionOffset));
|
||||
}
|
||||
freezePlayer = true;
|
||||
@@ -60,21 +60,21 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
}
|
||||
}
|
||||
|
||||
if(getGame() < VRR_GAME_GTA_IV) {
|
||||
if(animationData.animType == VRR_ANIMTYPE_NORMAL || animationData.animType == VRR_ANIMTYPE_SURRENDER) {
|
||||
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() < VRR_GAME_GTA_IV) {
|
||||
if (animationData.animType == VRR_ANIMTYPE_NORMAL || animationData.animType == VRR_ANIMTYPE_SURRENDER) {
|
||||
if (getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
||||
ped.clearAnimations();
|
||||
} else {
|
||||
ped.clearObjective();
|
||||
}
|
||||
ped.addAnimation(animationData.groupId, animationData.animId);
|
||||
|
||||
if(ped == localPlayer && freezePlayer == true) {
|
||||
if (ped == localPlayer && freezePlayer == true) {
|
||||
inAnimation = true;
|
||||
setLocalPlayerControlState(false, false);
|
||||
localPlayer.collisionsEnabled = false;
|
||||
}
|
||||
} else if(animationData.animType == VRR_ANIMTYPE_BLEND) {
|
||||
} else if (animationData.animType == VRR_ANIMTYPE_BLEND) {
|
||||
ped.position = ped.position;
|
||||
ped.blendAnimation(animationData.groupId, animationData.animId, animationData.animSpeed);
|
||||
}
|
||||
@@ -89,17 +89,17 @@ function makePedPlayAnimation(pedId, animationSlot, positionOffset) {
|
||||
function forcePedAnimation(pedId, animSlot) {
|
||||
let ped = getElementFromId(pedId);
|
||||
|
||||
if(ped == null) {
|
||||
if (ped == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let animationData = getAnimationData(animSlot);
|
||||
|
||||
if(getGame() < VRR_GAME_GTA_IV) {
|
||||
if (getGame() < VRR_GAME_GTA_IV) {
|
||||
ped.position = ped.position;
|
||||
ped.addAnimation(animationData.groupId, animationData.animId);
|
||||
|
||||
if(ped == localPlayer) {
|
||||
if (ped == localPlayer) {
|
||||
inAnimation = true;
|
||||
setLocalPlayerControlState(false, false);
|
||||
localPlayer.collisionsEnabled = false;
|
||||
@@ -115,34 +115,24 @@ function forcePedAnimation(pedId, animSlot) {
|
||||
function makePedStopAnimation(pedId) {
|
||||
let ped = getElementFromId(pedId);
|
||||
|
||||
if(ped == null) {
|
||||
if (ped == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getGame() != VRR_GAME_GTA_IV) {
|
||||
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
||||
if (getGame() != VRR_GAME_GTA_IV) {
|
||||
if (getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
||||
ped.clearAnimations();
|
||||
} else {
|
||||
ped.clearObjective();
|
||||
}
|
||||
}
|
||||
|
||||
if(ped == localPlayer) {
|
||||
if(getGame() != VRR_GAME_GTA_IV) {
|
||||
if (ped == localPlayer) {
|
||||
if (getGame() != VRR_GAME_GTA_IV) {
|
||||
localPlayer.collisionsEnabled = true;
|
||||
}
|
||||
setLocalPlayerControlState(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @param {number} animationSlot - The slot index of the animation
|
||||
* @return {AnimationData} The animation's data (array)
|
||||
*/
|
||||
function getAnimationData(animationSlot, gameId = getGame()) {
|
||||
return getGameConfig().animations[gameId][animationSlot];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
Reference in New Issue
Block a user