Well, it's been some time since I last contributed anything useful to this section so I figured I'd continue working on Alien Swarm(free game on steam).
So, for today there shall be this(I'll be posting more soon enough):

Originally Posted by
steam
Today You achieved Alien Swarm: Brutal Campaign, Hardcore, Vindicator Veteran, Pistols Expert, Small Arms Specialist, High Voltage Expert, Railgun Specialist, Pyrotechnician, Slaughter Soldier, Minigun Master, Professional Marksman, Grenadier Expert, Hornet Barrage Expert, Tactical Explosives Expert, Firewall Specialist, Armory Access, Easy Campaign, Normal Campaign, Hard Campaign, Insane Campaign, On the Ready Line, Another Bughunt, Kill Them All, Nuke From Orbit, Landing Bay Speed Run, Cargo Elevator Speed Run, Deima Surface Bridge Speed Run, Rydberg Reactor Speed Run, SynTek Residential Speed Run, Sewer Junction Speed Run, Timor Station Speed Run, Outstanding Execution, Zero Mortality, Hat Trick, Clear Firing, Short Controlled Bursts, Shield Down, Blast Radius, Sharpshooter, Perfect, Scrambled Eggs, Bug Stomper, Parasite Puncher, Close Encounters, Smoking Barrels, Infestation Savior, Circuit Breaker, Security Expert, Group Heal, Damage Amped, Gunslinger, Quick Load, Peace Medic, Protect the Tech, Technician Secured, Electro-Stunned, Under the Gun, Quick and Dead, Stay Frosty, Ammo Technician, Static Defender, Assault Specialist, Prototype Professional, Autogun Expert, Shotgun Specialist.
All achievements unlocked!

(note: you'll need to join a multiplayer server in order for the achievements to unlock)
So, what should you do?
1. Install the alien swarm SDK and click Create a mod
2. Extract it to some easy to find place(C:\AssMod for me)
3. Open up 'modname/src/game/client/swarm_sdk_client.sln'
4. delete all folders from the project except for 'link libraries'
5. add two new folders: 'source files' and 'header files'
6. now go to 'modname/src' folder, control + f and delete all .cpp files.
7. Coding starts!
First off we add the usual DLL stuff, so add this to your main.cpp:
Code:
/* Includes */
#include <windows.h>
#include "swarmbot.h"
/* DLL entry point */
BOOL APIENTRY DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hDll); //disable future calls to this module
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)SwarmBot::SwarmBot_Thread, 0, 0, 0); //create a thread to our control function.
break;
}
return true;
}
You'll probly have noticed the swarmbot.h include... Let's add that as well ;P
Code:
#pragma once
#include "SDK.h"
namespace SwarmBot
{
void SwarmBot_Thread(void); //we run this as thread
void SwarmBot_Init(void); //gives us access to the interfaces we want
};
Now you're probably wondering why I'm using a namespace, don't worry, just a personal preference.
Thats all in the .h, so lets add swarmbot.cpp as well:
Code:
#include <windows.h>
#include <stdio.h> //sprintf
#include "swarmbot.h"
#include "hackhelper.h" //contains the HackHelper::WaitForLoadedDll
#include "SDK.h" //SDK functions
bool bInitialized;
IBaseClientDLL *pBaseClientDLL = NULL;
IVEngineClient *pEngineClient = NULL;
IClientEntityList *pClientEntityList = NULL;
void SwarmBot::SwarmBot_Thread(void)
{
SwarmBot_Init(); //get access to the interfaces
while(1)
{
if(GetAsyncKeyState(VK_NUMPAD1)&1) //the lazy way of checking keys ;)
{
IAchievementMgr *pAchievements = pEngineClient->GetAchievementMgr(); //get a pointer to the achievement manager
for(int i=0; i<pAchievements->GetAchievementCount(); i++) //loop through all achievements
{
IAchievement *pAchievement = pAchievements->GetAchievementByIndex(i, 0); //get the achievement by index
pAchievements->AwardAchievement(pAchievement->GetAchievementID(), 0); //award the achievement by ID
char msg[256]=""; //blank message
sprintf(msg, "echo \"Unlocked: %s\"", pAchievement->GetName()); //format the message "echo Unlocked: achievement name here"
pEngineClient->ClientCmd(msg); //execute the echo command, which will print out the message specified in the console.
}
}
Sleep(100);
}
}
void SwarmBot::SwarmBot_Init(void)
{
//Wait for the needed modules to load and get their handles
HMODULE hClient = HackHelper::WaitForLoadedDll("client.dll"); //get a handle to client.dll
HMODULE hEngine = HackHelper::WaitForLoadedDll("engine.dll"); //get a handle to engine.dll
//Get a pointer to the CreateInterface functions
CreateInterfaceFn CIBaseClient = (CreateInterfaceFn)GetProcAddress(hClient, "CreateInterface");
CreateInterfaceFn CIEngineClient = (CreateInterfaceFn)GetProcAddress(hEngine, "CreateInterface");
//Get access to the client interfaces
pBaseClientDLL = (IBaseClientDLL *)CIBaseClient(CLIENT_DLL_INTERFACE_VERSION, 0);
pClientEntityList = (IClientEntityList*)CIBaseClient(VCLIENTENTITYLIST_INTERFACE_VERSION, 0);
//Get access to the engine interfaces
pEngineClient = (IVEngineClient *)CIEngineClient(VENGINE_CLIENT_INTERFACE_VERSION, 0);
bInitialized = true; //not used but left in for future use
}
The only files left are HackHelper.h, HackHelper.cpp and SDK.h, so here they are:
HackHelper.h
Code:
#pragma once
namespace HackHelper
{
#ifdef UNICODE
HMODULE WaitForLoadedDll(LPCWSTR DllName);
#else
HMODULE WaitForLoadedDll(LPCSTR DllName);
#endif
};
It uses GetModuleHandleA or GetModuleHandleW based on the project settings.
HackHelper.cpp
Code:
#include <windows.h>
#include "hackhelper.h"
namespace HackHelper
{
#ifdef UNICODE
HMODULE WaitForLoadedDll(LPCWSTR DllName)
{
HMODULE hRet = NULL;
while(!(hRet = GetModuleHandleW(DllName)))
{
Sleep(25);
}
return hRet;
}
#else
HMODULE WaitForLoadedDll(LPCSTR DllName)
{
HMODULE hRet = NULL;
while(!(hRet = GetModuleHandleA(DllName)))
{
Sleep(50);
}
return hRet;
}
#endif // !UNICODE
};
Finally SDK.h, which will contain the SDK includes we currently need.
Code:
#pragma once
#include "cdll_int.h" //engine interface stuff
#include "interfaces/interfaces.h" //interface stuff
#include "client_class.h" //player class is in here
#include "icliententitylist.h" //client entity interface
#include "icliententity.h" //client entity interface
#include "iachievementmgr.h" //achievement manager
Have fun, credits would be nice

Hell_Demon