Advertisement
Guest User

Untitled

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