Remove broad command

This commit is contained in:
Vladislav Khorev committed 2026-11-06 21:30:17 +06:00
1 parent 1ab9f300b6
commit 3f68a8ba07
11 files changed
+120 -160

No files matched your search

+20 -44
View File
@@ -124,9 +124,8 @@ namespace FRG {
if (cbName.empty())
std::cerr << "[script] npc_walk_to: on_arrived must be a global Lua function\n";
}
loc->updateCharacterState(*npc, [x, z](CharacterState& workingState) {
workingState.homePosition = Eigen::Vector3f(x, 0.f, z);
});
loc->gameServer().submit(SetCharacterHomePositionCommand{
loc->locationId(), npc->entityId(), Eigen::Vector3f(x, 0.f, z)});
loc->setCharacterTarget(
*npc, Eigen::Vector3f(x, y, z), std::move(cbName));
});
@@ -142,18 +141,16 @@ namespace FRG {
const float rad = angle * static_cast<float>(M_PI) / 180.f;
logger() << "[script] npc_rotate_to: " << npcId << " angle " << angle << " degrees (" << rad << " radians)" << std::endl;
loc->updateCharacterState(*npc, [rad](CharacterState& workingState) {
workingState.targetFacingAngle = rad;
});
loc->gameServer().submit(SetCharacterFacingAngleCommand{
loc->locationId(), npc->entityId(), rad, false});
});
api.set_function("player_rotate_to",
[loc](float angle) {
const float rad = angle * static_cast<float>(M_PI) / 180.f;
logger() << "[script] player_rotate_to: angle " << angle << " degrees (" << rad << " radians)" << std::endl;
loc->updateCharacterState(*loc->player, [rad](CharacterState& workingState) {
workingState.targetFacingAngle = rad;
});
loc->gameServer().submit(SetCharacterFacingAngleCommand{
loc->locationId(), loc->player->entityId(), rad, false});
});
api.set_function("player_stop_and_rotate_to_npc",
@@ -188,9 +185,9 @@ namespace FRG {
if (cbName.empty())
std::cerr << "[script] player_walk_to: on_arrived must be a global Lua function\n";
}
loc->updateCharacterState(*loc->player, [x, z](CharacterState& workingState) {
workingState.homePosition = Eigen::Vector3f(x, 0.f, z);
});
loc->gameServer().submit(SetCharacterHomePositionCommand{
loc->locationId(), loc->player->entityId(),
Eigen::Vector3f(x, 0.f, z)});
loc->setCharacterTarget(
*loc->player, Eigen::Vector3f(x, y, z), std::move(cbName));
});
@@ -440,13 +437,7 @@ namespace FRG {
if (loc->player)
{
loc->setCharacterHp(*loc->player, value);
loc->updateCharacterState(*loc->player, [](CharacterState& workingState) {
if (workingState.currentState == AnimationState::ACTION_TO_DEATH ||
workingState.currentState == AnimationState::DEATH_IDLE) {
workingState.currentState = AnimationState::STAND;
workingState.resetAnim = true;
}
});
loc->resetCharacterAfterDeath(*loc->player);
}
});
// get_player_hp() → float (0 if no player)
@@ -602,10 +593,8 @@ namespace FRG {
return;
}
Eigen::Vector3f pos(x, y, z);
loc->updateCharacterState(*npc, [&pos](CharacterState& workingState) {
workingState.position = pos;
workingState.homePosition = pos;
});
loc->gameServer().submit(SetCharacterPositionCommand{
loc->locationId(), npc->entityId(), pos, true});
loc->setCharacterTarget(*npc, pos);
});
@@ -618,10 +607,8 @@ namespace FRG {
return;
}
const float rad = angle * static_cast<float>(M_PI) / 180.f;
loc->updateCharacterState(*npc, [rad](CharacterState& workingState) {
workingState.facingAngle = rad;
workingState.targetFacingAngle = rad;
});
loc->gameServer().submit(SetCharacterFacingAngleCommand{
loc->locationId(), npc->entityId(), rad, true});
});
// set_npc_enabled(npc_id, enabled)
@@ -632,34 +619,23 @@ namespace FRG {
std::cerr << "[script] set_npc_enabled: unknown NPC id '" << npcId << "'\n";
return;
}
loc->updateCharacterState(*npc, [value](CharacterState& workingState) {
workingState.enabled = value;
workingState.attack = 0;
workingState.attack_cooldown = 0;
workingState.currentState = AnimationState::STAND;
if (workingState.canAttack)
workingState.attackTargetId = "player";
workingState.battle_state = 0;
});
loc->gameServer().submit(SetCharacterEnabledCommand{
loc->locationId(), npc->entityId(), value});
});
api.set_function("player_set_position",
[loc](float x, float y, float z) {
Eigen::Vector3f pos(x, y, z);
loc->updateCharacterState(*loc->player, [&pos](CharacterState& workingState) {
workingState.position = pos;
workingState.homePosition = pos;
});
loc->gameServer().submit(SetCharacterPositionCommand{
loc->locationId(), loc->player->entityId(), pos, true});
loc->setCharacterTarget(*loc->player, pos);
});
api.set_function("player_set_rotation",
[loc](float angle) {
const float rad = angle * static_cast<float>(M_PI) / 180.f;
loc->updateCharacterState(*loc->player, [rad](CharacterState& workingState) {
workingState.facingAngle = rad;
workingState.targetFacingAngle = rad;
});
loc->gameServer().submit(SetCharacterFacingAngleCommand{
loc->locationId(), loc->player->entityId(), rad, true});
});
// move_object(name, x, y, z, duration_sec [, on_complete])