mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
Allow rule access from lua, double checked and fixed up the spell mitigation stuff
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "../common/timer.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/classes.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "lua_parser.h"
|
||||
#include "lua_item.h"
|
||||
#include "lua_iteminst.h"
|
||||
@@ -33,6 +34,7 @@ struct Skills { };
|
||||
struct BodyTypes { };
|
||||
struct Filters { };
|
||||
struct MessageTypes { };
|
||||
struct Rule { };
|
||||
|
||||
struct lua_registered_event {
|
||||
std::string encounter_name;
|
||||
@@ -1485,6 +1487,18 @@ int random_roll0(int max) {
|
||||
return zone->random.Roll0(max);
|
||||
}
|
||||
|
||||
int get_rulei(int rule) {
|
||||
return RuleManager::Instance()->GetIntRule((RuleManager::IntType)rule);
|
||||
}
|
||||
|
||||
float get_ruler(int rule) {
|
||||
return RuleManager::Instance()->GetRealRule((RuleManager::RealType)rule);
|
||||
}
|
||||
|
||||
bool get_ruleb(int rule) {
|
||||
return RuleManager::Instance()->GetBoolRule((RuleManager::BoolType)rule);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_general() {
|
||||
return luabind::namespace_("eq")
|
||||
[
|
||||
@@ -2205,4 +2219,46 @@ luabind::scope lua_register_message_types() {
|
||||
];
|
||||
}
|
||||
|
||||
luabind::scope lua_register_rules_const() {
|
||||
return luabind::class_<Rule>("Rule")
|
||||
.enum_("constants")
|
||||
[
|
||||
#define RULE_INT(cat, rule, default_value) \
|
||||
luabind::value(#rule, RuleManager::Int__##rule),
|
||||
#include "../common/ruletypes.h"
|
||||
luabind::value("_IntRuleCount", RuleManager::_IntRuleCount),
|
||||
#undef RULE_INT
|
||||
#define RULE_REAL(cat, rule, default_value) \
|
||||
luabind::value(#rule, RuleManager::Real__##rule),
|
||||
#include "../common/ruletypes.h"
|
||||
luabind::value("_RealRuleCount", RuleManager::_RealRuleCount),
|
||||
#undef RULE_REAL
|
||||
#define RULE_BOOL(cat, rule, default_value) \
|
||||
luabind::value(#rule, RuleManager::Bool__##rule),
|
||||
#include "../common/ruletypes.h"
|
||||
luabind::value("_BoolRuleCount", RuleManager::_BoolRuleCount)
|
||||
];
|
||||
}
|
||||
|
||||
luabind::scope lua_register_rulei() {
|
||||
return luabind::namespace_("RuleI")
|
||||
[
|
||||
luabind::def("Get", &get_rulei)
|
||||
];
|
||||
}
|
||||
|
||||
luabind::scope lua_register_ruler() {
|
||||
return luabind::namespace_("RuleR")
|
||||
[
|
||||
luabind::def("Get", &get_ruler)
|
||||
];
|
||||
}
|
||||
|
||||
luabind::scope lua_register_ruleb() {
|
||||
return luabind::namespace_("RuleB")
|
||||
[
|
||||
luabind::def("Get", &get_ruleb)
|
||||
];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,10 @@ luabind::scope lua_register_skills();
|
||||
luabind::scope lua_register_bodytypes();
|
||||
luabind::scope lua_register_filters();
|
||||
luabind::scope lua_register_message_types();
|
||||
luabind::scope lua_register_rules_const();
|
||||
luabind::scope lua_register_rulei();
|
||||
luabind::scope lua_register_ruler();
|
||||
luabind::scope lua_register_ruleb();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+5
-1
@@ -1096,7 +1096,11 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
lua_register_object(),
|
||||
lua_register_packet(),
|
||||
lua_register_packet_opcodes(),
|
||||
lua_register_stat_bonuses()
|
||||
lua_register_stat_bonuses(),
|
||||
lua_register_rules_const(),
|
||||
lua_register_rulei(),
|
||||
lua_register_ruler(),
|
||||
lua_register_ruleb()
|
||||
];
|
||||
|
||||
} catch(std::exception &ex) {
|
||||
|
||||
Reference in New Issue
Block a user