Skip to content

Commit

Permalink
添加实体动作操作接口
Browse files Browse the repository at this point in the history
  • Loading branch information
HalcyonAlcedo committed May 18, 2021
1 parent 236b7d8 commit af67da2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ namespace Base {
//可设置参数
string ModName = "LuaScript";
string ModAuthor = "Alcedo";
string ModVersion = "v1.2.1 Beta";
long long ModBuild = 121005181559;
string ModVersion = "v1.2.1";
long long ModBuild = 121005182125;
string Version = "421470";
}
#pragma endregion
Expand Down
12 changes: 10 additions & 2 deletions Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,8 @@ namespace Component {
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
Base::Vector4 quaternion = Base::Calculation::AngleToQuaternion(angle);
*offsetPtr<float>((undefined(*)())Ptr, 0x174) = quaternion.x;
*offsetPtr<float>((undefined(*)())Ptr, 0x17C) = quaternion.z;
*(float*)(Ptr + 0x174) = quaternion.x;
*(float*)(Ptr + 0x17C) = quaternion.z;
}
}
static void SetEntityAimCoordinate(string ptr, Base::Vector2 aim) {
Expand All @@ -909,6 +909,14 @@ namespace Component {
SetEntityAngle(ptr,aim_angle);//设置角度
}
}
static void EntityBehaviorControl(string ptr, int fsm) {
long long Ptr = 0;
sscanf_s(ptr.c_str(), "%p", &Ptr, sizeof(long long));
void* EntityAddress = (double*)Ptr;
if (EntityAddress != nullptr) {
Base::Monster::BehaviorControl(EntityAddress, fsm);
}
}
#pragma endregion
#pragma region GetMonstersName_CN
static string GetMonstersName_CN(int id) {
Expand Down
8 changes: 8 additions & 0 deletions LuaScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ static int Game_Entity_SetEntityAimCoordinate(lua_State* pL) {
Component::SetEntityAimCoordinate(entity, Base::Vector2(x,z));
return 0;
}
static int Game_Entity_BehaviorControl(lua_State* pL) {
string entity = "0x" + (string)lua_tostring(pL, 1);
int id = (int)lua_tointeger(pL, 2);
Component::EntityBehaviorControl(entity, id);
return 0;
}
#pragma endregion
#pragma region SystemFun
static int System_Keyboard_CheckKey(lua_State* pL) {
Expand Down Expand Up @@ -1710,6 +1716,8 @@ int Lua_Main(string LuaFile)
lua_register(L, "Game_Entity_SetEntityAngle", Game_Entity_SetEntityAngle);
//将实体朝向指定的坐标
lua_register(L, "Game_Entity_SetEntityAimCoordinate", Game_Entity_SetEntityAimCoordinate);
//使实体执行动作
lua_register(L, "Game_Entity_BehaviorControl", Game_Entity_BehaviorControl);
#pragma endregion

#pragma endregion
Expand Down

0 comments on commit af67da2

Please sign in to comment.