[Quest API] Add RandomizeFeature() overloads to Perl/Lua. (#2532)

# Perl
- Add `$mob->RandomizeFeatures()` to Perl.
- Add `$mob->RandomizeFeatures(send_illusion)` to Perl.
- Add `$mob->RandomizeFeatures(send_illusion, set_variables)` to Perl.

# Lua
- Add `mob:RandomizeFeatures()` to Lua.
- Add `mob:RandomizeFeatures(send_illusion)` to Lua.
- Add `mob:RandomizeFeatures(send_illusion, set_variables)` to Lua.

# Notes
- Previous overload required `send_illusion` and `set_variables` despite both default values being `true`, this will allow you to just send nothing if you want both to be `true`.
- Change `RandomizeFeatures()` type to `bool` from `void` to match source method, returns `false` when used on a race that has no features to randomize.
- This allows operators to do something different if the NPC can't use this method.
This commit is contained in:
Kinglykrab 2022-11-14 16:59:17 -05:00 committed by GitHub
parent fd2fc76706
commit e72ec4ae56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 13 deletions

View File

@ -272,11 +272,6 @@ void Lua_Mob::ChangeSize(double in_size, bool no_restriction) {
self->ChangeSize(static_cast<float>(in_size), no_restriction);
}
void Lua_Mob::RandomizeFeatures(bool send_illusion, bool save_variables) {
Lua_Safe_Call_Void();
self->RandomizeFeatures(send_illusion, save_variables);
}
void Lua_Mob::GMMove(double x, double y, double z) {
Lua_Safe_Call_Void();
self->GMMove(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z));
@ -2478,6 +2473,21 @@ Lua_Mob Lua_Mob::GetUltimateOwner() {
return Lua_Mob(self->GetUltimateOwner());
}
bool Lua_Mob::RandomizeFeatures() {
Lua_Safe_Call_Bool();
return self->RandomizeFeatures();
}
bool Lua_Mob::RandomizeFeatures(bool send_illusion) {
Lua_Safe_Call_Bool();
return self->RandomizeFeatures(send_illusion);
}
bool Lua_Mob::RandomizeFeatures(bool send_illusion, bool save_variables) {
Lua_Safe_Call_Bool();
return self->RandomizeFeatures(send_illusion, save_variables);
}
void Lua_Mob::CloneAppearance(Lua_Mob other) {
Lua_Safe_Call_Void();
self->CloneAppearance(other);
@ -2821,7 +2831,9 @@ luabind::scope lua_register_mob() {
.def("ProjectileAnimation", (void(Lua_Mob::*)(Lua_Mob,int,bool,double,double,double,double))&Lua_Mob::ProjectileAnimation)
.def("QuestSay", (void(Lua_Mob::*)(Lua_Client,const char *))&Lua_Mob::QuestSay)
.def("QuestSay", (void(Lua_Mob::*)(Lua_Client,const char *,luabind::adl::object))&Lua_Mob::QuestSay)
.def("RandomizeFeatures", (void(Lua_Mob::*)(bool,bool))&Lua_Mob::RandomizeFeatures)
.def("RandomizeFeatures", (bool(Lua_Mob::*)(void))&Lua_Mob::RandomizeFeatures)
.def("RandomizeFeatures", (bool(Lua_Mob::*)(bool))&Lua_Mob::RandomizeFeatures)
.def("RandomizeFeatures", (bool(Lua_Mob::*)(bool,bool))&Lua_Mob::RandomizeFeatures)
.def("RangedAttack", &Lua_Mob::RangedAttack)
.def("RemoveAllNimbusEffects", &Lua_Mob::RemoveAllNimbusEffects)
.def("RemoveNimbusEffect", (void(Lua_Mob::*)(int))&Lua_Mob::RemoveNimbusEffect)

View File

@ -76,7 +76,9 @@ public:
void DoAnim(int anim_num, int type, bool ackreq, int filter);
void ChangeSize(double in_size);
void ChangeSize(double in_size, bool no_restriction);
void RandomizeFeatures(bool send_illusion, bool save_variables);
bool RandomizeFeatures();
bool RandomizeFeatures(bool send_illusion);
bool RandomizeFeatures(bool send_illusion, bool save_variables);
void GMMove(double x, double y, double z);
void GMMove(double x, double y, double z, double heading);
void TryMoveAlong(float distance, float heading);

View File

@ -277,11 +277,6 @@ void Perl_Mob_ChangeSize(Mob* self, float in_size, bool no_restriction) // @cate
self->ChangeSize(in_size, no_restriction);
}
void Perl_Mob_RandomizeFeatures(Mob* self, bool send_illusion, bool save_variables) // @categories Script Utility
{
self->RandomizeFeatures(send_illusion, save_variables);
}
void Perl_Mob_GMMove(Mob* self, float x, float y, float z) // @categories Script Utility
{
self->GMMove(x, y, z);
@ -2457,6 +2452,21 @@ Mob* Perl_Mob_GetUltimateOwner(Mob* self) // @categories Script Utility, Pet
return self->GetUltimateOwner();
}
bool Perl_Mob_RandomizeFeatures(Mob* self) // @categories Script Utility
{
return self->RandomizeFeatures();
}
bool Perl_Mob_RandomizeFeatures(Mob* self, bool send_illusion) // @categories Script Utility
{
return self->RandomizeFeatures(send_illusion);
}
bool Perl_Mob_RandomizeFeatures(Mob* self, bool send_illusion, bool save_variables) // @categories Script Utility
{
return self->RandomizeFeatures(send_illusion, save_variables);
}
void Perl_Mob_CloneAppearance(Mob* self, Mob* other) // @categories Script Utility
{
self->CloneAppearance(other);
@ -2818,7 +2828,9 @@ void perl_register_mob()
package.add("ProjectileAnim", (void(*)(Mob*, Mob*, int, bool, float, float, float))&Perl_Mob_ProjectileAnim);
package.add("ProjectileAnim", (void(*)(Mob*, Mob*, int, bool, float, float, float, float))&Perl_Mob_ProjectileAnim);
package.add("ProjectileAnim", (void(*)(Mob*, Mob*, int, bool, float, float, float, float, const char*))&Perl_Mob_ProjectileAnim);
package.add("RandomizeFeatures", &Perl_Mob_RandomizeFeatures);
package.add("RandomizeFeatures", (bool(*)(Mob*))&Perl_Mob_RandomizeFeatures);
package.add("RandomizeFeatures", (bool(*)(Mob*, bool))&Perl_Mob_RandomizeFeatures);
package.add("RandomizeFeatures", (bool(*)(Mob*, bool, bool))&Perl_Mob_RandomizeFeatures);
package.add("RangedAttack", &Perl_Mob_RangedAttack);
package.add("RemoveAllAppearanceEffects", &Perl_Mob_RemoveAllAppearanceEffects);
package.add("RemoveAllNimbusEffects", &Perl_Mob_RemoveAllNimbusEffects);