Skip to content

Commit a60390f

Browse files
committed
feat(extra-natives): add getters for health config
1 parent 254d063 commit a60390f

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

code/components/extra-natives-five/src/PedExtraNatives.cpp

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,4 +820,180 @@ static HookFunction initFunction([]()
820820
it->second.invincible = value;
821821
}
822822
});
823+
824+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_DEFAULT_HEALTH", [](fx::ScriptContext& context)
825+
{
826+
std::string name = context.GetArgument<const char*>(0);
827+
uint32_t configHash = HashString(name);
828+
829+
auto it = g_healthConfigs.find(configHash);
830+
if (it != g_healthConfigs.end())
831+
{
832+
context.SetResult(it->second.defaultHealth);
833+
}
834+
else
835+
{
836+
context.SetResult(0.0f);
837+
}
838+
});
839+
840+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_DEFAULT_ARMOR", [](fx::ScriptContext& context)
841+
{
842+
std::string name = context.GetArgument<const char*>(0);
843+
uint32_t configHash = HashString(name);
844+
845+
auto it = g_healthConfigs.find(configHash);
846+
if (it != g_healthConfigs.end())
847+
{
848+
context.SetResult(it->second.defaultArmor);
849+
}
850+
else
851+
{
852+
context.SetResult(0.0f);
853+
}
854+
});
855+
856+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_DEFAULT_ENDURANCE", [](fx::ScriptContext& context)
857+
{
858+
std::string name = context.GetArgument<const char*>(0);
859+
uint32_t configHash = HashString(name);
860+
861+
auto it = g_healthConfigs.find(configHash);
862+
if (it != g_healthConfigs.end())
863+
{
864+
context.SetResult(it->second.defaultEndurance);
865+
}
866+
else
867+
{
868+
context.SetResult(0.0f);
869+
}
870+
});
871+
872+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_FATIGUED_THRESHOLD", [](fx::ScriptContext& context)
873+
{
874+
std::string name = context.GetArgument<const char*>(0);
875+
uint32_t configHash = HashString(name);
876+
877+
auto it = g_healthConfigs.find(configHash);
878+
if (it != g_healthConfigs.end())
879+
{
880+
context.SetResult(it->second.fatiguedHealthThreshold);
881+
}
882+
else
883+
{
884+
context.SetResult(0.0f);
885+
}
886+
});
887+
888+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_INJURED_THRESHOLD", [](fx::ScriptContext& context)
889+
{
890+
std::string name = context.GetArgument<const char*>(0);
891+
uint32_t configHash = HashString(name);
892+
893+
auto it = g_healthConfigs.find(configHash);
894+
if (it != g_healthConfigs.end())
895+
{
896+
context.SetResult(it->second.injuredHealthThreshold);
897+
}
898+
else
899+
{
900+
context.SetResult(0.0f);
901+
}
902+
});
903+
904+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_DYING_THRESHOLD", [](fx::ScriptContext& context)
905+
{
906+
std::string name = context.GetArgument<const char*>(0);
907+
uint32_t configHash = HashString(name);
908+
909+
auto it = g_healthConfigs.find(configHash);
910+
if (it != g_healthConfigs.end())
911+
{
912+
context.SetResult(it->second.dyingHealthThreshold);
913+
}
914+
else
915+
{
916+
context.SetResult(0.0f);
917+
}
918+
});
919+
920+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_HURT_THRESHOLD", [](fx::ScriptContext& context)
921+
{
922+
std::string name = context.GetArgument<const char*>(0);
923+
uint32_t configHash = HashString(name);
924+
925+
auto it = g_healthConfigs.find(configHash);
926+
if (it != g_healthConfigs.end())
927+
{
928+
context.SetResult(it->second.hurtHealthThreshold);
929+
}
930+
else
931+
{
932+
context.SetResult(0.0f);
933+
}
934+
});
935+
936+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_DOG_TAKEDOWN_THRESHOLD", [](fx::ScriptContext& context)
937+
{
938+
std::string name = context.GetArgument<const char*>(0);
939+
uint32_t configHash = HashString(name);
940+
941+
auto it = g_healthConfigs.find(configHash);
942+
if (it != g_healthConfigs.end())
943+
{
944+
context.SetResult(it->second.dogTakedownThreshold);
945+
}
946+
else
947+
{
948+
context.SetResult(0.0f);
949+
}
950+
});
951+
952+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_WRITHE_FROM_BULLET_THRESHOLD", [](fx::ScriptContext& context)
953+
{
954+
std::string name = context.GetArgument<const char*>(0);
955+
uint32_t configHash = HashString(name);
956+
957+
auto it = g_healthConfigs.find(configHash);
958+
if (it != g_healthConfigs.end())
959+
{
960+
context.SetResult(it->second.writheFromBulletDamageThreshold);
961+
}
962+
else
963+
{
964+
context.SetResult(0.0f);
965+
}
966+
});
967+
968+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_MELEE_FATAL_ATTACK", [](fx::ScriptContext& context)
969+
{
970+
std::string name = context.GetArgument<const char*>(0);
971+
uint32_t configHash = HashString(name);
972+
973+
auto it = g_healthConfigs.find(configHash);
974+
if (it != g_healthConfigs.end())
975+
{
976+
context.SetResult(it->second.meleeCardinalFatalAttackCheck);
977+
}
978+
else
979+
{
980+
context.SetResult(false);
981+
}
982+
});
983+
984+
fx::ScriptEngine::RegisterNativeHandler("GET_HEALTH_CONFIG_INVINCIBLE", [](fx::ScriptContext& context)
985+
{
986+
std::string name = context.GetArgument<const char*>(0);
987+
uint32_t configHash = HashString(name);
988+
989+
auto it = g_healthConfigs.find(configHash);
990+
if (it != g_healthConfigs.end())
991+
{
992+
context.SetResult(it->second.invincible);
993+
}
994+
else
995+
{
996+
context.SetResult(false);
997+
}
998+
});
823999
});

0 commit comments

Comments
 (0)