Guest User

Untitled

a guest
Nov 28th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <API/ARK/Ark.h>
  3.  
  4. #pragma comment(lib, "ArkApi.lib")
  5.  
  6. DECLARE_HOOK(APrimalStructure_TakeDamage, float, APrimalStructure*, float, FDamageEvent*, AController*, AActor*);
  7.  
  8. float Hook_APrimalStructure_TakeDamage(APrimalStructure* _this, float Damage, FDamageEvent* DamageEvent, AController* EventInstigator, AActor* DamageCauser)
  9. {
  10. if (EventInstigator && EventInstigator->CharacterField())
  11. {
  12. ACharacter* character = EventInstigator->CharacterField();
  13. if (character && character->IsA(APrimalDinoCharacter::GetPrivateStaticClass()))
  14. {
  15. APrimalDinoCharacter* dino = static_cast<APrimalDinoCharacter*>(character);
  16. FString descr;
  17. dino->GetDinoDescriptiveName(&descr);
  18. if (descr.Contains(L"Dragon")
  19. || descr.Contains(L"Wyvern")
  20. || descr.Contains(L"Broodmother")
  21. || descr.Contains(L"Megapithecus")
  22. || descr.Contains(L"DodoRex")
  23. || descr.Contains(L"Odracir")
  24. || descr.Contains(L"Rawaiim")
  25. || descr.Contains(L"Nilloc")
  26. || descr.Contains(L"Smough")
  27. || descr.Contains(L"Karkinos")
  28. || descr.Contains(L"Gnashor")
  29. || descr.Contains(L"Bokito")
  30. || descr.Contains(L"Mormaw")
  31. || descr.Contains(L"Perdition")
  32. || descr.Contains(L"Raphus")
  33. || descr.Contains(L"Primordius")
  34. || descr.Contains(L"Demonic")
  35. || descr.Contains(L"Celestial")
  36. || descr.Contains(L"Chaos")
  37. || descr.Contains(L"Spirit")
  38. || descr.Contains(L"Badass")
  39. || descr.Contains(L"Champion")
  40. || descr.Contains(L"Alpha")
  41. || descr.Contains(L"Elite")
  42. || descr.Contains(L"Ancient")
  43. || descr.Contains(L"Zomdodo")
  44. || descr.Contains(L"Monkey")
  45. || descr.Contains(L"Apex")
  46. || descr.Contains(L"Toxic")
  47. || descr.Contains(L"Fabled")
  48. || descr.Contains(L"Primal")
  49. || descr.Contains(L"Elder")
  50. || descr.Contains(L"Buffon")
  51. || descr.Contains(L"Light")
  52. || descr.Contains(L"Ice")
  53. || descr.Contains(L"Fire")
  54. || descr.Contains(L"Electric")
  55. || descr.Contains(L"Captain"))
  56. return 0;
  57. }
  58. AShooterPlayerController* AttackerShooterController = static_cast<AShooterPlayerController*>(EventInstigator);
  59. if (AttackerShooterController && AttackerShooterController->PlayerStateField() && AttackerShooterController->GetPlayerCharacter() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField())
  60. {
  61. FString WeaponName;
  62. AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField()->GetItemName(&WeaponName, false, true, nullptr);
  63. if (WeaponName.Contains(L"Flamethrower")) return 0;
  64. }
  65. if (DamageCauser)
  66. {
  67. FString descr;
  68. DamageCauser->GetHumanReadableName(&descr);
  69.  
  70. if (descr.Contains("Tek Turret"))
  71. {
  72. return 0;
  73. }
  74. }
  75. }
  76. APrimalStructure_TakeDamage_original(_this, Damage, DamageEvent, EventInstigator, DamageCauser);
  77. }
  78.  
  79. void SuicideCMD(AShooterPlayerController* AttackerShooterController, FString* message, int mode)
  80. {
  81. if (!AttackerShooterController || !AttackerShooterController->PlayerStateField() || !AttackerShooterController->GetPlayerCharacter() || AttackerShooterController->GetPlayerCharacter()->IsDead()) return;
  82. if (!ArkApi::GetApiUtils().IsRidingDino(AttackerShooterController)) AttackerShooterController->GetPlayerCharacter()->Suicide();
  83. if (!AttackerShooterController || !AttackerShooterController->PlayerStateField() || !AttackerShooterController->GetPlayerCharacter() || !AttackerShooterController->GetPlayerCharacter()->IsConscious()) return;
  84. if (!AttackerShooterController || !AttackerShooterController->PlayerStateField() || !AttackerShooterController->GetPlayerCharacter() || AttackerShooterController->GetPlayerCharacter()->IsSitting(false)) return;
  85. if (AttackerShooterController && AttackerShooterController->PlayerStateField() && AttackerShooterController->GetPlayerCharacter() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField() && AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField())
  86.  
  87. {
  88. FString WeaponName;
  89. AttackerShooterController->GetPlayerCharacter()->CurrentWeaponField()->AssociatedPrimalItemField()->GetItemName(&WeaponName, false, true, nullptr);
  90. if (WeaponName.Contains(L"Flamethrower")) return;
  91. Log::GetLog()->warn("Weapon Name: {}", WeaponName.ToString());
  92.  
  93. }
  94. }
  95.  
  96.  
  97. void Load()
  98. {
  99. Log::Get().Init("NoNunnaki");
  100.  
  101. ArkApi::GetHooks().SetHook("APrimalStructure.TakeDamage", &Hook_APrimalStructure_TakeDamage,
  102. &APrimalStructure_TakeDamage_original);
  103.  
  104. ArkApi::GetCommands().AddChatCommand("/suicide", &SuicideCMD);
  105.  
  106.  
  107. }
  108.  
  109. void Unload()
  110. {
  111. ArkApi::GetHooks().DisableHook("APrimalStructure.TakeDamage", &Hook_APrimalStructure_TakeDamage);
  112. ArkApi::GetCommands().RemoveChatCommand("/suicide");
  113. }
  114.  
  115. BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
  116. {
  117. switch (ul_reason_for_call)
  118. {
  119. case DLL_PROCESS_ATTACH:
  120. Load();
  121. break;
  122. case DLL_PROCESS_DETACH:
  123. Unload();
  124. break;
  125. }
  126. return TRUE;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment