This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Michael

By: a guest on Feb 17th, 2010  |  syntax: C++  |  size: 1.60 KB  |  views: 124  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data