73 lines
3.1 KiB
JavaScript
73 lines
3.1 KiB
JavaScript
// ===========================================================================
|
|
// Vortrex's Roleplay Resource
|
|
// https://github.com/VortrexFTW/gtac_roleplay
|
|
// ===========================================================================
|
|
// FILE: animation.js
|
|
// DESC: Provides animation functions and usage
|
|
// TYPE: Client (JavaScript)
|
|
// ===========================================================================
|
|
|
|
function makePedPlayAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition, freezePlayer) {
|
|
logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animGroup}/${animId} for ped ${pedId}`);
|
|
if(getGame() < VRR_GAME_GTA_IV) {
|
|
if(animType == VRR_ANIMTYPE_NORMAL) {
|
|
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
|
getElementFromId(pedId).clearAnimations();
|
|
} else {
|
|
getElementFromId(pedId).clearObjective();
|
|
}
|
|
getElementFromId(pedId).addAnimation(animGroup, animId);
|
|
|
|
if(getElementFromId(pedId) == localPlayer && !freezePlayer) {
|
|
inAnimation = true;
|
|
setLocalPlayerControlState(false, false);
|
|
localPlayer.collisionsEnabled = false;
|
|
}
|
|
} else if(animType == VRR_ANIMTYPE_BLEND) {
|
|
getElementFromId(pedId).position = getElementFromId(pedId).position;
|
|
getElementFromId(pedId).blendAnimation(animGroup, animId, animSpeed);
|
|
} else if(animType == VRR_ANIMTYPE_MOVEADD) {
|
|
getElementFromId(pedId).position = getElementFromId(pedId).position;
|
|
getElementFromId(pedId).blendAnimation(animGroup, animId, animSpeed);
|
|
}
|
|
} else {
|
|
natives.requestAnims(animGroup);
|
|
natives.taskPlayAnimNonInterruptable(getElementFromId(pedId), animId, animGroup, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition, -1);
|
|
}
|
|
}
|
|
|
|
// ===========================================================================
|
|
|
|
function forcePedAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition) {
|
|
if(getGame() < VRR_GAME_GTA_IV) {
|
|
forcedAnimation = [animGroup, animId];
|
|
setLocalPlayerControlState(false, false);
|
|
getElementFromId(pedId).position = getElementFromId(pedId).position;
|
|
getElementFromId(pedId).addAnimation(animGroup, animId);
|
|
|
|
inAnimation = true;
|
|
setLocalPlayerControlState(false, false);
|
|
localPlayer.collisionsEnabled = false;
|
|
}
|
|
}
|
|
|
|
// ===========================================================================
|
|
|
|
function makePedStopAnimation(pedId) {
|
|
if(getElementFromId(pedId) == null) {
|
|
return false;
|
|
}
|
|
|
|
if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
|
|
getElementFromId(pedId).clearAnimations();
|
|
} else {
|
|
getElementFromId(pedId).clearObjective();
|
|
}
|
|
|
|
if(getElementFromId(pedId) == localPlayer) {
|
|
localPlayer.collisionsEnabled = true;
|
|
setLocalPlayerControlState(true, false);
|
|
}
|
|
}
|
|
|
|
// ===========================================================================
|