@@ -694,8 +694,17 @@ int CLuaWeaponDefs::SetWeaponClipAmmo(lua_State* luaVM)
694694 return 1 ;
695695}
696696
697- std::variant<float , int , bool , CLuaMultiReturn<float ,float ,float >> CLuaWeaponDefs::GetWeaponProperty (lua_State* luaVM, std::variant<CClientWeapon*, int , std::string> weapon, eWeaponSkill skill , eWeaponProperty property)
697+ std::variant<float , int , bool , CLuaMultiReturn<float ,float ,float >> CLuaWeaponDefs::GetWeaponProperty (lua_State* luaVM, std::variant<CClientWeapon*, int , std::string> weapon, std::variant< int , std::string> weaponSkill , eWeaponProperty property)
698698{
699+ eWeaponSkill skill = WEAPONSKILL_POOR;
700+ if (std::holds_alternative<int >(weaponSkill))
701+ skill = static_cast <eWeaponSkill>(std::get<int >(weaponSkill));
702+ else if (std::holds_alternative<std::string>(weaponSkill))
703+ StringToEnum (std::get<std::string>(weaponSkill), skill);
704+
705+ if (skill < eWeaponSkill::WEAPONSKILL_POOR || skill >= eWeaponSkill::WEAPONSKILL_MAX_NUMBER)
706+ throw LuaFunctionError (" Invalid weapon skill value." , true );
707+
699708 // custom weapon
700709 if (std::holds_alternative<CClientWeapon*>(weapon))
701710 {
@@ -831,7 +840,7 @@ std::variant<float, int, bool, CLuaMultiReturn<float,float,float>> CLuaWeaponDef
831840 return false ;
832841}
833842
834- std::variant<float , int , bool , CLuaMultiReturn<float , float , float >> CLuaWeaponDefs::GetOriginalWeaponProperty (lua_State* luaVM, std::variant<int , std::string> weapon, eWeaponSkill skill , eWeaponProperty property)
843+ std::variant<float , int , bool , CLuaMultiReturn<float , float , float >> CLuaWeaponDefs::GetOriginalWeaponProperty (lua_State* luaVM, std::variant<int , std::string> weapon, std::variant< int , std::string> weaponSkill , eWeaponProperty property)
835844{
836845 eWeaponType weaponType = eWeaponType::WEAPONTYPE_INVALID;
837846 if (std::holds_alternative<int >(weapon))
@@ -842,6 +851,15 @@ std::variant<float, int, bool, CLuaMultiReturn<float, float, float>> CLuaWeaponD
842851 if (weaponType < eWeaponType::WEAPONTYPE_UNARMED || weaponType > eWeaponType::WEAPONTYPE_FLARE)
843852 throw LuaFunctionError (" Weapon ID or name is invalid." , true );
844853
854+ eWeaponSkill skill = WEAPONSKILL_POOR;
855+ if (std::holds_alternative<int >(weaponSkill))
856+ skill = static_cast <eWeaponSkill>(std::get<int >(weaponSkill));
857+ else if (std::holds_alternative<std::string>(weaponSkill))
858+ StringToEnum (std::get<std::string>(weaponSkill), skill);
859+
860+ if (skill < eWeaponSkill::WEAPONSKILL_POOR || skill >= eWeaponSkill::WEAPONSKILL_MAX_NUMBER)
861+ throw LuaFunctionError (" Invalid weapon skill value." , true );
862+
845863 CWeaponStat* weaponStats = g_pGame->GetWeaponStatManager ()->GetOriginalWeaponStats (weaponType, skill);
846864 if (!weaponStats)
847865 return false ;
0 commit comments