Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <API/ARK/Ark.h>
- #pragma comment(lib, "ArkApi.lib")
- DECLARE_HOOK(APrimalStructure_TakeDamage, float, APrimalStructure*, float, FDamageEvent*, AController*, AActor*);
- float Hook_APrimalStructure_TakeDamage(APrimalStructure* _this, float Damage, FDamageEvent* DamageEvent, AController* EventInstigator, AActor* DamageCauser)
- {
- if (_this && EventInstigator && EventInstigator->IsA(AShooterPlayerController::StaticClass()))
- {
- AShooterPlayerController* AttackerShooterController = static_cast<AShooterPlayerController*>(EventInstigator);
- if (AttackerShooterController && AttackerShooterController->PlayerStateField() && AttackerShooterController->GetPlayerCharacter() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField())
- {
- FString WeaponName;
- AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField()->GetItemName(&WeaponName, false, true, nullptr);
- if (WeaponName.Contains(L"Flamethrower")) return 0;
- }
- }
- else if (EventInstigator && EventInstigator->CharacterField())
- {
- ACharacter* character = EventInstigator->CharacterField();
- if (character && character->IsA(APrimalDinoCharacter::GetPrivateStaticClass()))
- {
- APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(character);
- FString descr;
- dino->GetDinoDescriptiveName(&descr);
- if (descr.Contains(L"Dragon")
- || descr.Contains(L"Wyvern")
- || descr.Contains(L"Broodmother")
- || descr.Contains(L"Megapithecus")
- || descr.Contains(L"DodoRex")
- || descr.Contains(L"Odracir")
- || descr.Contains(L"Rawaiim")
- || descr.Contains(L"Nilloc")
- || descr.Contains(L"Smough")
- || descr.Contains(L"Karkinos")
- || descr.Contains(L"Gnashor")
- || descr.Contains(L"Bokito")
- || descr.Contains(L"Mormaw")
- || descr.Contains(L"Perdition")
- || descr.Contains(L"Raphus")
- || descr.Contains(L"Primordius")
- || descr.Contains(L"Demonic")
- || descr.Contains(L"Celestial")
- || descr.Contains(L"Chaos")
- || descr.Contains(L"Spirit")
- || descr.Contains(L"Badass")
- || descr.Contains(L"Champion")
- || descr.Contains(L"Alpha")
- || descr.Contains(L"Elite")
- || descr.Contains(L"Ancient")
- || descr.Contains(L"Zomdodo")
- || descr.Contains(L"Monkey")
- || descr.Contains(L"Apex")
- || descr.Contains(L"Toxic")
- || descr.Contains(L"Fabled")
- || descr.Contains(L"Primal")
- || descr.Contains(L"Elder")
- || descr.Contains(L"Buffon")
- || descr.Contains(L"Light")
- || descr.Contains(L"Ice")
- || descr.Contains(L"Fire")
- || descr.Contains(L"Electric")
- || descr.Contains(L"Captain"))
- return 0;
- }
- if (DamageCauser)
- {
- FString descr;
- DamageCauser->GetHumanReadableName(&descr);
- if (descr.Contains("Tek Turret"))
- {
- return 0;
- }
- }
- }
- APrimalStructure_TakeDamage_original(_this, Damage, DamageEvent, EventInstigator, DamageCauser);
- }
- void SuicideCMD(AShooterPlayerController* AttackerShooterController, FString* message, int mode)
- {
- if (!AttackerShooterController || !AttackerShooterController->PlayerStateField() || !AttackerShooterController->GetPlayerCharacter() || AttackerShooterController->GetPlayerCharacter()->IsDead()) return;
- if (!ArkApi::GetApiUtils().IsRidingDino(AttackerShooterController)) AttackerShooterController->GetPlayerCharacter()->Suicide();
- if (!AttackerShooterController || !AttackerShooterController->PlayerStateField() || !AttackerShooterController->GetPlayerCharacter() || !AttackerShooterController->GetPlayerCharacter()->IsConscious()) return;
- if (!AttackerShooterController || !AttackerShooterController->PlayerStateField() || !AttackerShooterController->GetPlayerCharacter() || AttackerShooterController->GetPlayerCharacter()->IsSitting(false)) return;
- if (AttackerShooterController && AttackerShooterController->PlayerStateField() && AttackerShooterController->GetPlayerCharacter() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField())
- {
- FString WeaponName;
- AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField()->GetItemName(&WeaponName, false, true, nullptr);
- if (WeaponName.Contains(L"Flamethrower")) return;
- Log::GetLog()->warn("Weapon Name: {}", WeaponName.ToString());
- }
- }
- void Load()
- {
- Log::Get().Init("NoNunnaki");
- ArkApi::GetHooks().SetHook("APrimalStructure.TakeDamage", &Hook_APrimalStructure_TakeDamage,
- &APrimalStructure_TakeDamage_original);
- ArkApi::GetCommands().AddChatCommand("/suicide", &SuicideCMD);
- }
- void Unload()
- {
- ArkApi::GetHooks().DisableHook("APrimalStructure.TakeDamage", &Hook_APrimalStructure_TakeDamage);
- ArkApi::GetCommands().RemoveChatCommand("/suicide");
- }
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
- {
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- Load();
- break;
- case DLL_PROCESS_DETACH:
- Unload();
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement