2019-11-28 11:55:22 +00:00
|
|
|
#define HOOK(hookName, source, ...) \
|
|
|
|
{ \
|
2020-08-15 13:10:48 +00:00
|
|
|
try { \
|
2021-06-26 09:26:20 +00:00
|
|
|
auto aggregator = (source)->GetScriptIterator(); \
|
2021-04-18 10:50:48 +00:00
|
|
|
ArbUt::BorrowedPtr<CreatureLib::Battling::BattleScript> next = (CreatureLib::Battling::BattleScript*)1; \
|
|
|
|
while (aggregator.GetNext(next)) { \
|
2020-08-15 13:10:48 +00:00
|
|
|
try { \
|
|
|
|
next->hookName(__VA_ARGS__); \
|
|
|
|
} catch (const std::exception& e) { \
|
2020-08-17 10:18:01 +00:00
|
|
|
THROW("Exception running script hook '" #hookName "': " << e.what()) \
|
2020-08-15 13:10:48 +00:00
|
|
|
} \
|
2020-07-31 12:17:38 +00:00
|
|
|
} \
|
2020-08-15 14:34:52 +00:00
|
|
|
} catch (const ArbUt::Exception& e) { \
|
2020-08-15 13:10:48 +00:00
|
|
|
throw e; \
|
|
|
|
} catch (const std::exception& e) { \
|
2020-08-17 10:18:01 +00:00
|
|
|
THROW("Exception setting up script hook '" #hookName "': " << e.what()) \
|
2020-05-29 16:49:48 +00:00
|
|
|
} \
|
|
|
|
}
|
2021-10-29 17:31:08 +00:00
|
|
|
|
|
|
|
#define EXECUTE_SCRIPT_FUNC(scriptWrapper, hookName, ...) \
|
|
|
|
{ \
|
|
|
|
try { \
|
|
|
|
if (scriptWrapper.HasValue()) { \
|
|
|
|
if (scriptWrapper.IsSet()) { \
|
|
|
|
for (const auto& sv : scriptWrapper.GetScriptSet()->GetIterator()) { \
|
|
|
|
sv->hookName(__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
scriptWrapper.GetScript()->get()->hookName(__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} catch (const ArbUt::Exception& e) { \
|
|
|
|
throw e; \
|
|
|
|
} catch (const std::exception& e) { \
|
|
|
|
THROW("Exception setting up script hook '" #hookName "': " << e.what()) \
|
|
|
|
} \
|
2021-10-29 21:55:41 +00:00
|
|
|
}
|