|
|
@@ -7,8 +7,6 @@
|
|
|
|
|
|
#include "../../../middleware/bap/activity_message/auth_fields.h"
|
|
|
#include "../../../middleware/bap/activity_message/auth_schema_catalog.h"
|
|
|
-#include "../../../middleware/bap/activity_message/mission_effect_auth.h"
|
|
|
-#include "../../../middleware/bap/activity_message/squad_attachment_auth.h"
|
|
|
#include "../../../middleware/bap/activity_message/volume_toggle_auth.h"
|
|
|
#include "mission_script_lua_dispatch.h"
|
|
|
#include "mission_script_lua_internal.h"
|
|
|
@@ -108,8 +106,6 @@ namespace auth_catalog = middleware::bap::activity_message::auth_schema_catalog;
|
|
|
namespace {
|
|
|
|
|
|
constexpr const api::MemberSpec& kVolumeActive = api::slot_member("set_volume_active");
|
|
|
-constexpr const api::MemberSpec& kSquadAttachment = api::slot_member("set_squad_attachment");
|
|
|
-constexpr const api::MemberSpec& kMissionEffect = api::slot_member("set_mission_effect");
|
|
|
|
|
|
/** Reads one required boolean argument; any other type is an error. */
|
|
|
[[nodiscard]] bool required_boolean(lua_State* state, const char* name) {
|
|
|
@@ -159,84 +155,6 @@ constexpr const api::MemberSpec& kMissionEffect = api::slot_member("set_mission_
|
|
|
state, source, scriptable_auth::kType32Schema, scriptable_auth::kType32BitCount, body);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Selects or clears the squad a type-26 attachment follows. spawn_generation names the source
|
|
|
- * placement; a request for any other placement is refused as stale.
|
|
|
- */
|
|
|
-[[nodiscard]] int slot_set_squad_attachment(lua_State* state) {
|
|
|
- const auto* const handle =
|
|
|
- static_cast<const SlotHandle*>(luaL_checkudata(state, 1, kSlotMetatable));
|
|
|
- refuse_unknown_arguments(state, kSquadAttachment);
|
|
|
- const SlotHandle sourceHandle = checked_argument<SlotHandle>(
|
|
|
- state, required_key(kSquadAttachment, "source", api::ValueKind::handle), kSlotMetatable);
|
|
|
- const lua_Integer generation = checked_integer_argument(
|
|
|
- state, required_key(kSquadAttachment, "spawn_generation", api::ValueKind::integer));
|
|
|
- const bool active =
|
|
|
- required_boolean(state, required_key(kSquadAttachment, "active", api::ValueKind::boolean));
|
|
|
- SlotDefinition target{}, source{};
|
|
|
- if (!current_slot(state, *handle, target) || !current_slot(state, sourceHandle, source)) {
|
|
|
- return luaL_error(state, "attachment or squad source is stale or invalid");
|
|
|
- }
|
|
|
- if (target.slotType != scriptable_auth::kType26SlotType
|
|
|
- || target.authSchema != scriptable_auth::kType26Schema
|
|
|
- || (target.flags & format::kSlotSchemaJoinExact) == 0
|
|
|
- || source.slotType != format::kSquadSlotType
|
|
|
- || source.authSchema != format::kSquadAuthSchema
|
|
|
- || (source.flags & format::kSlotSchemaJoinExact) == 0
|
|
|
- || target.objectTag != source.objectTag || target.registryKey != source.registryKey) {
|
|
|
- return luaL_error(state, "attachment requires an exact same-owner type-1 source");
|
|
|
- }
|
|
|
- if (generation <= 0 || generation > (std::numeric_limits<std::int32_t>::max)()) {
|
|
|
- return luaL_error(state, "spawn_generation must be a positive signed 32-bit integer");
|
|
|
- }
|
|
|
- CallFrame& frame = active_frame(state);
|
|
|
- Intent intent{};
|
|
|
- intent.kind = IntentKind::setSquadAttachment;
|
|
|
- intent.firstRow = target.nativeRow;
|
|
|
- intent.secondRow = source.nativeRow;
|
|
|
- intent.sourceSpawnGeneration = static_cast<std::uint64_t>(generation);
|
|
|
- intent.active = active;
|
|
|
- return queue_intent(state, frame, intent);
|
|
|
-}
|
|
|
-
|
|
|
-/** Attaches the authored hop-on effect to the entities a type-34 filter selects. */
|
|
|
-[[nodiscard]] int slot_set_mission_effect(lua_State* state) {
|
|
|
- namespace effect = middleware::bap::activity_message::mission_effect;
|
|
|
- const auto* const handle =
|
|
|
- static_cast<const SlotHandle*>(luaL_checkudata(state, 1, kSlotMetatable));
|
|
|
- refuse_unknown_arguments(state, kMissionEffect);
|
|
|
- SlotDefinition slot{};
|
|
|
- if (!current_slot(state, *handle, slot) || slot.slotType != effect::kSlotType
|
|
|
- || slot.authSchema != effect::kSchema) {
|
|
|
- return luaL_error(state, "mission effect requires an authored type-26 hop-on");
|
|
|
- }
|
|
|
- const bool enabled =
|
|
|
- optional_boolean_argument(state, boolean_option(kMissionEffect, "enabled"));
|
|
|
- const char* const filterKey = optional_key(kMissionEffect, "filter", api::ValueKind::handle);
|
|
|
- scriptable_auth::Type2LaneClientRef filter{};
|
|
|
- if (enabled) {
|
|
|
- lua_getfield(state, 2, filterKey);
|
|
|
- const bool present = !lua_isnil(state, -1);
|
|
|
- lua_pop(state, 1);
|
|
|
- if (!present
|
|
|
- || !optional_slot_reference(
|
|
|
- state, filterKey, scriptable_auth::kType34SlotType, filter)) {
|
|
|
- return luaL_error(state, "mission effect requires a type-34 filter");
|
|
|
- }
|
|
|
- }
|
|
|
- const lua_Integer revision =
|
|
|
- optional_integer_argument(state, integer_option(kMissionEffect, "revision"));
|
|
|
- if (!valid_counter(revision)) {
|
|
|
- return luaL_error(state, "effect revision must be positive");
|
|
|
- }
|
|
|
- std::array<std::byte, effect::kBytes> body{};
|
|
|
- std::size_t written = 0;
|
|
|
- if (!effect::encode(filter, enabled, static_cast<std::int32_t>(revision), body, written)) {
|
|
|
- return luaL_error(state, "mission effect encoder failed");
|
|
|
- }
|
|
|
- return queue_slot_auth(state, slot, effect::kSchema, effect::kBits, body);
|
|
|
-}
|
|
|
-
|
|
|
/** Pushes one property of the slot's Auth catalog entry, or nil when it has none. */
|
|
|
template <typename Push> void push_auth(lua_State* state, const SlotDefinition& slot, Push push) {
|
|
|
const auth_catalog::Type* const auth =
|
|
|
@@ -354,8 +272,6 @@ constexpr std::array<SlotBinding, std::size(api::kSlotMembers)> kSlotBindings{{
|
|
|
[](lua_State* state, const SlotDefinition& slot) { lua_pushinteger(state, slot.flags); }},
|
|
|
{"set_object_filter", &slot_set_object_filter},
|
|
|
{"set_volume_active", &slot_set_volume_active},
|
|
|
- {"set_squad_attachment", &slot_set_squad_attachment},
|
|
|
- {"set_mission_effect", &slot_set_mission_effect},
|
|
|
{"watch_damage", &slot_watch_damage},
|
|
|
{"set_object_active", &slot_set_object_active},
|
|
|
{"set_channel", &slot_set_channel},
|