Advertisement
Guest User

Michael

a guest
Feb 17th, 2010
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. //SAMPLE DLL
  2.  
  3.  
  4. #include <windows.h>
  5.  
  6. //void* memset(void* ptr, char value, int size)
  7. //{
  8. //  char* tempptr = (char*)ptr;
  9. //  for(int i = 0; i < size; i++)
  10. //  {
  11. //      tempptr[i] = value;
  12. //  }
  13. //  return ptr;
  14. //}
  15.  
  16. struct Vect2
  17. {
  18.    public:
  19.    float x, y;
  20.    Vect2()
  21.    {
  22.       x = 0; y = 0;
  23.    }
  24.    Vect2(float _x, float _y)
  25.    {
  26.       x = _x; y = _y;
  27.    }
  28. };
  29.  
  30. struct ShipInfo
  31. {
  32.    int ShipID;
  33.  
  34.    Vect2 CurrentPosition;
  35.    Vect2 CurrentVelocity;
  36.  
  37.    float Health;
  38.    float Shields;
  39.  
  40.    int Kills;
  41. };
  42.  
  43. struct Output {
  44.    bool TryToShoot; // Shoot if possible
  45.    float ShootAngle; // 0 - 6.28 (2 * PI)
  46.    float ShootPower; // 0 - 10
  47.  
  48.    Vect2 DesiredPosition;
  49.    float Speed;
  50.    Output()
  51.    {
  52.       TryToShoot = false; ShootAngle = 0; ShootPower = 0;
  53.       DesiredPosition.x = 0; DesiredPosition.y = 0;
  54.       Speed = 0;
  55.    }
  56. };
  57.  
  58. struct Input
  59. {
  60.    ShipInfo EnemyShips[3];
  61.  
  62.    ShipInfo MyShip;
  63.  
  64.    float TimeRemaining;
  65. };
  66.  
  67. #define DECLDIR __declspec(dllexport)
  68. extern "C"
  69. {
  70.     DECLDIR Output __stdcall AiFunc(Input in, float delta)
  71.     {
  72.        Output out;
  73.        
  74.        
  75. // BEGIN_USER_CODE
  76. static int state = 0;
  77. static float timer = 0;
  78. timer += delta;
  79.  
  80. if(timer > 3)
  81. {
  82.     timer = 0;
  83.     state++;
  84.     if(state > 1) state = 0;
  85. }
  86.    
  87. switch(state)
  88. {
  89.     case 0:
  90.     out.DesiredPosition = Vect2(0,25);
  91.     break;
  92.     case 1:
  93.     out.DesiredPosition = Vect2(0,50);
  94.     break;
  95. }
  96. // END_USER_CODE
  97.  
  98.        
  99.        return out;
  100.     }
  101.    
  102.     BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  103.     {
  104.         //MessageBox(NULL, "Inside DllMain", NULL, NULL);
  105.         return 0;
  106.     }
  107.    
  108. }
  109.        
  110.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement