Advertisement
Guest User

Untitled

a guest
May 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "Engine.h"
  7. #include "Engine/World.h"
  8. #include <vector>
  9. #include "BaseSystem.generated.h"
  10.  
  11. UENUM()
  12. enum class EDAI_AttackType : uint8
  13. {
  14. AT_Projectile,
  15. AT_Slam
  16. };
  17.  
  18. USTRUCT()
  19. struct FDAIInfo /*Struct to contain all necessary information for an individual attack*/
  20. {
  21. GENERATED_BODY()
  22.  
  23. public:
  24. UPROPERTY()
  25. int iIndex;
  26. UPROPERTY()
  27. float fLearningValue = 0.0f;
  28. UPROPERTY()
  29. EDAI_AttackType m_AttackType;
  30.  
  31. // Default Constructor ~ SHOULD NOT BE USED
  32. FDAIInfo()
  33. {
  34.  
  35. }
  36.  
  37. // Constructor
  38. FDAIInfo(int _index, float _learningValue, EDAI_AttackType _type)
  39. {
  40. iIndex = _index;
  41. fLearningValue = _learningValue;
  42. m_AttackType = _type;
  43. }
  44.  
  45. // Functions
  46. /*Increment struct learning variable by an amount*/
  47. void IncrementLearningValue(float _amount)
  48. {
  49. fLearningValue = FMath::Clamp(fLearningValue + _amount, 0.0f, 1.0f);
  50. }
  51.  
  52. /*Calculates and returns a predicted best projectile attack location
  53. Assumed constant projectile speed.*/
  54. FVector CalculateProjectileAttack(
  55. FVector _projectileOrigin, // The origin of the projectile to be spawned
  56. FVector _targetLocation, // Target's current location
  57. float _projectileSpeed, // The speed of the projectile
  58. FVector _targetVelocity,
  59. float _deltaTime) // Target's current directional force
  60. {
  61. float fDistance = FVector::Dist(_projectileOrigin, _targetLocation);
  62. float fTime = fDistance / _projectileSpeed;
  63. FVector PredictedLocation = _targetLocation + ((_targetVelocity * fLearningValue) * fTime);
  64. return PredictedLocation;
  65. }
  66.  
  67. /*Calculates and returns a predicted best slam attack location*/
  68. FVector CalculateSlamAttack(
  69. float _fWindup, // ??
  70. FVector _projectileOrigin, // The origin of the projectile to be spawned
  71. FVector _targetLocation) // Target's current location
  72. {
  73.  
  74. }
  75. };
  76.  
  77. /**
  78. *
  79. */
  80. class DYNAMICAIPLUGIN_API DynamicAI
  81. {
  82. public:
  83. DynamicAI(); // Constructor
  84. ~DynamicAI(); // Destructor
  85.  
  86. //// Public Variables
  87.  
  88.  
  89. //// Public Functions
  90.  
  91. /*Create a new instance of DAIInfo and add it to the array, return the index of the struct.*/
  92. int CreateDAIStruct(float _learningValue, EDAI_AttackType _type);
  93. /*Create a new instance of DAIInfo and add it to the array, return the index of the struct.*/
  94. int CreateDAIStruct(EDAI_AttackType _type);
  95.  
  96. UPROPERTY()
  97. TArray<FDAIInfo> m_Attacks; // Array of Dynamic AI Information structs
  98.  
  99. private:
  100. //// Private Variables
  101.  
  102. //// Private Functions
  103.  
  104. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement