Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void CLuaPedDefs::LoadFunctions()
{"removePedFromVehicle", RemovePedFromVehicle},
{"setPedDoingGangDriveby", SetPedDoingGangDriveby},
{"setPedAnimation", ArgumentParserWarn<false, SetPedAnimation>},
{"getPedAnimation", ArgumentParserWarn<false, GetPedAnimation>},
{"setPedAnimationProgress", SetPedAnimationProgress},
{"setPedAnimationSpeed", SetPedAnimationSpeed},
{"setPedOnFire", SetPedOnFire},
Expand Down Expand Up @@ -148,6 +149,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setWeaponSlot", "setPedWeaponSlot");
lua_classfunction(luaVM, "setWalkingStyle", "setPedWalkingStyle");
lua_classfunction(luaVM, "setAnimation", "setPedAnimation");
lua_classfunction(luaVM, "getAnimation", "getPedAnimation");
lua_classfunction(luaVM, "setAnimationProgress", "setPedAnimationProgress");
lua_classfunction(luaVM, "setAnimationSpeed", "setPedAnimationSpeed");
lua_classfunction(luaVM, "setWearingJetpack", "setPedWearingJetpack"); // introduced in 1.5.5-9.13846
Expand Down Expand Up @@ -424,6 +426,26 @@ bool CLuaPedDefs::SetPedAnimation(CElement* pPed, std::optional<std::variant<std
return CStaticFunctionDefinitions::SetPedAnimation(pPed, animBlockName, animationName, time.value_or(-1), blendTime.value_or(250), loop.value_or(true), updatePosition.value_or(true), interruptable.value_or(true), freezeLastFrame.value_or(true), restoreTask.value_or(false));
}

std::variant<bool, CLuaMultiReturn<std::string, std::string, int, bool, bool, bool, bool, int, bool>> CLuaPedDefs::GetPedAnimation(CPed* pPed)
{
const SPlayerAnimData& animData = pPed->GetAnimationData();

if (!animData.IsAnimating())
return false;

return CLuaMultiReturn<std::string, std::string, int, bool, bool, bool, bool, int, bool>(
animData.blockName,
animData.animName,
animData.time,
animData.loop,
animData.updatePosition,
animData.interruptable,
animData.freezeLastFrame,
animData.blendTime,
animData.taskToBeRestoredOnAnimEnd
);
}

int CLuaPedDefs::SetPedAnimationProgress(lua_State* luaVM)
{
CElement* pElement;
Expand Down
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#pragma once
#include "CLuaDefs.h"
#include <lua/CLuaMultiReturn.h>

class CLuaPedDefs : public CLuaDefs
{
Expand Down Expand Up @@ -73,6 +74,7 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(RemovePedFromVehicle);
LUA_DECLARE(SetPedDoingGangDriveby);
static bool SetPedAnimation(CElement* pPed, std::optional<std::variant<std::string, std::monostate, bool>> blockName, std::optional<std::variant<std::string, std::monostate, bool>> animName, std::optional<int> time, std::optional<bool> loop, std::optional<bool> updatePosition, std::optional<bool> interruptable, std::optional<bool> freezeLastFrame, std::optional<int> blendTime, std::optional<bool> restoreTask);
static std::variant<bool, CLuaMultiReturn<std::string, std::string, int, bool, bool, bool, bool, int, bool>> GetPedAnimation(CPed* pPed);
LUA_DECLARE(SetPedAnimationProgress);
LUA_DECLARE(SetPedAnimationSpeed);
LUA_DECLARE(SetPedWeaponSlot);
Expand Down