Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SAMPLE DLL
- #include <windows.h>
- //void* memset(void* ptr, char value, int size)
- //{
- // char* tempptr = (char*)ptr;
- // for(int i = 0; i < size; i++)
- // {
- // tempptr[i] = value;
- // }
- // return ptr;
- //}
- struct Vect2
- {
- public:
- float x, y;
- Vect2()
- {
- x = 0; y = 0;
- }
- Vect2(float _x, float _y)
- {
- x = _x; y = _y;
- }
- };
- struct ShipInfo
- {
- int ShipID;
- Vect2 CurrentPosition;
- Vect2 CurrentVelocity;
- float Health;
- float Shields;
- int Kills;
- };
- struct Output {
- bool TryToShoot; // Shoot if possible
- float ShootAngle; // 0 - 6.28 (2 * PI)
- float ShootPower; // 0 - 10
- Vect2 DesiredPosition;
- float Speed;
- Output()
- {
- TryToShoot = false; ShootAngle = 0; ShootPower = 0;
- DesiredPosition.x = 0; DesiredPosition.y = 0;
- Speed = 0;
- }
- };
- struct Input
- {
- ShipInfo EnemyShips[3];
- ShipInfo MyShip;
- float TimeRemaining;
- };
- #define DECLDIR __declspec(dllexport)
- extern "C"
- {
- DECLDIR Output __stdcall AiFunc(Input in, float delta)
- {
- Output out;
- // BEGIN_USER_CODE
- static int state = 0;
- static float timer = 0;
- timer += delta;
- if(timer > 3)
- {
- timer = 0;
- state++;
- if(state > 1) state = 0;
- }
- switch(state)
- {
- case 0:
- out.DesiredPosition = Vect2(0,25);
- break;
- case 1:
- out.DesiredPosition = Vect2(0,50);
- break;
- }
- // END_USER_CODE
- return out;
- }
- BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
- {
- //MessageBox(NULL, "Inside DllMain", NULL, NULL);
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement