Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. // UHCPluginDemo.cpp : Defines the exported functions for the DLL application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "UHCPlugin.h"
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. using namespace syscalls;
  10.  
  11. // syscalls that returns a 'vector' uses the first parameter to return its value
  12. void vectorSyscallExample(vector ret) {
  13.     kbGetMapCenter(ret);
  14. }
  15.  
  16. void test(int player) {
  17.     aiChat(player, "Hello World!");
  18. }
  19.  
  20. // Turns a random enemy's settlers into sheep
  21. void __stdcall cheatExample(int) {
  22.     xsSetContextPlayer(1);
  23.     for (int i = 1; i < getNumberPlayers(); i++) {
  24.         if (kbIsPlayerEnemy(i) && !kbIsPlayerResigned(i)) {
  25.             xsSetContextPlayer(i);
  26.             trUnitSelectClear();
  27.  
  28.             int unitQueryID = kbUnitQueryCreate("CheatUnitQuery");
  29.             kbUnitQuerySetIgnoreKnockedOutUnits(unitQueryID, true);
  30.             kbUnitQuerySetPlayerID(unitQueryID, i, true);
  31.             kbUnitQuerySetUnitType(unitQueryID, kbGetProtoUnitID("Settler"));
  32.             kbUnitQuerySetState(unitQueryID, cUnitStateAlive);
  33.             kbUnitQueryResetResults(unitQueryID);
  34.             int numberFound = kbUnitQueryExecute(unitQueryID);
  35.  
  36.             for (int n = 0; n < numberFound; n++)
  37.                 trUnitSelectByID(kbUnitQueryGetResult(unitQueryID, n));
  38.  
  39.             trUnitChangeProtoUnit("Sheep");
  40.             //trSoundPlayFN("SheepSelect.wav", "", -1, "", "");
  41.             break;
  42.         }
  43.     }
  44. }
  45.  
  46. extern "C" _declspec(dllexport)
  47. int __stdcall UHCPluginMain(UHCPluginInfo* pluginInfo) {
  48.     // Register your syscalls and cheats here...
  49.  
  50.     // After registering a syscall, it can be used in the 'scope' you defined.
  51.     pluginInfo->SyscallRegister(pluginInfo->info, XS, Vector,
  52.         "xsTest", vectorSyscallExample, 0, "xsTest: vector syscall example.");
  53.  
  54.     pluginInfo->SyscallRegister(pluginInfo->info, AI, Void,
  55.         "aiTest", (void*)test, 1, "aiTest: Sends 'Hello World!' to specified player.");
  56.     pluginInfo->SyscallSetParamInteger(pluginInfo->info, AI, 0, 1);
  57.  
  58.     pluginInfo->CheatRegister(pluginInfo->info, L"force of nature", true, cheatExample);
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement