Code Release: bulletTime 0.2

Ultimate Empire

BattleForums Addict
Joined
May 18, 2003
Messages
701
Reaction score
0
I've decided to start releasing old code that BFHS or myself kept private. I will do this every so often as different code become abandonware/obsolete/cool to look at.

My first release is bulletTime which took advantage of the dead body bug. Where, if a person precisley stood on top of their own (or someone elses) dead body...they would be immune to ANY ranged/ranged magical attack from ANYONE. I'm not sure if this bug has been fixed or not.

The code for the module bulletTime 0.2, is designed to stand over your own dead body (once you've been killed) and lock you there (impossible to move by accident) so you can fire your own ranged attacks, until you choose to move by typing in an unlock command or teleporting/leaping or getting damaged (melee or if for some reason you get hit by ranged attack).

I will be posting comments/editing this post in the future.
Remember to source myself and BFHS if you use this code in anyway.
Thanks, and enjoy!


Code:
////////////////////////////////////////////////////////////////////////////
// bulletTime 0.2 by Ultimate Empire and BFHS
////////////////////////////////////////////////////////////////////////////

//This is the statement that links your module to the d2hackit framework.
//When compiling your source, make sure it is in the same directory as
//Or one directory above this file. (This means you need to get the source code
//for D2hackit)

#include "ClientCore.cpp"



//Boolean variables

//If player has died yet (true if they can use their dead body/false otherwise)
bool KilledPlayer=false;

//TRUE if player has typed .bt go
bool commanded=false;

//TRUE if player has successfully moved ontop of their dead body
bool stuck=false;

//TRUE if player is in process of moving to body
bool damn=false;

//TRUE if their health is 'ok' (unchanged)
bool ok=false;

//TRUE if the person attempts a teleports away from body
bool teleported=false;


//Strings don't really exist in C++ or anywhere for that matter
//So we use an array of characters to output lines of text
char Msg1[256];
char Msg2[256];
char Msg3[256];
char PID[256];

//Packets in d2hacket or of type BYTE, these are like the ones you manually
//send with d2hackit in game, but in c++ format
BYTE attack[5]={0x05,0,0,0,0};
BYTE xypos[5]={0x03,0,0,0,0};
BYTE BID[4]={0,0,0,0};
BYTE pickup[]={0x13,0,0,0,0,0,0,0,0};
BYTE MyPosX[2]={0,0};
BYTE MyPosY[2]={0,0};
BYTE ForceRun[11]={0x15,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
BYTE teleport[4]={0,0,0,0};
BYTE warpto[4]={0,0,0,0};
BYTE attempt[11]={0x15,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
BYTE bodylocal[11]={0x15,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

//Standard integers
int PacketOne;
int health;
int hmedian=1;
int comp1;
int comp2;

THISGAMESTRUCT* thisgame;

////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////////////

// PUBLIC FUNCTIONS
BOOL PRIVATE OnGameCommandGo(char** argv, int argc);
BOOL PRIVATE OnGameCommandUnstuck(char** argv, int argc);
BOOL PRIVATE OnGameCommandMatrix(char** argv, int argc);


CLIENTINFO
(		
	0,2,				    // Module version (Major, Minor)
	"Ultimate Empire and the BFHS",	    // Author
	"battleforums.com",	            // url (http:// is appended)
	"Bullet Time",			    // Short module description
	""				    // Author eMail
)

////////////////////////////////////////////////////////////////////////////
// Module Commands
////////////////////////////////////////////////////////////////////////////

MODULECOMMANDSTRUCT ModuleCommands[]=
{
	{	
		"help",
		OnGameCommandHelp,
		"helpÿc0 List commands available in this module.\n"
		"<command> helpÿc0 Shows detailed help for <command> in this module."
	},
	{
		// MyCommand
		"entermatrix",		// command users use to call MyCommand
		OnGameCommandMatrix,	// the function name
		"Main Help Function"	// command description
	},
	{
		// Go
		"go",										
		OnGameCommandGo,							
		"Runs and stands on your corpse."	
	},
	{
		// Unstuck
		"run",										
		OnGameCommandUnstuck,							
		"Allows movement from invincible position."	
	},

	{NULL}	
};

// called about every 10th of a second
DWORD EXPORT OnGameTimerTick(VOID)
{
	return true;
} /



//////////////////////////////////////////////////////////////////////
// OnGameJoin - Introduction
//////////////////////////////////////////////////////////////////////

VOID EXPORT OnGameJoin(THISGAMESTRUCT* aThisgame) {
	thisgame = aThisgame;
	stuck=false;
	server->GamePrintInfo("What are you saying... that I can dodge bullets?");
	server->GamePrintInfo("No, Neo. I'm telling you that when you're ready, you won't have to.");
	server->GamePrintInfo("");
	server->GamePrintInfo("ÿc0Type ÿc2.bt entermatrix ÿc0 to learn the ways...");
	server->GamePrintInfo("Or proceed to phase 2 if you are familiar.");

	server->GamePrintInfo("You are currently: ÿc1VULNERABLE");
	server->GamePrintInfo("You are currently: ÿc1VULNERABLE");
	return;
}

////////////////////////////////////////////////////////////////////////
// outgoing
////////////////////////////////////////////////////////////////////////////


//
DWORD EXPORT OnGamePacketBeforeSent(BYTE* aPacket, DWORD aLen)
{
	//If the person moves or teleports (or leaps??)
	//Tell them that they are now vulnerable

	if ((aPacket[0] == 0x0c) && (stuck))
	{
		memcpy(teleport,aPacket+1,4);
		memcpy(warpto,ForceRun+6,4);
		if ((char *)teleport == (char *)attempt)
		{
			stuck=false;
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
		}
	}
	
	if ((aPacket[0] == 0x66) || (aPacket[0] == 0x41))
	{
		stuck=false;
		server->GamePrintInfo("ÿc1VULNERABLE");
		server->GamePrintInfo("ÿc1VULNERABLE");
		server->GamePrintInfo("ÿc1VULNERABLE");
		server->GamePrintInfo("ÿc1VULNERABLE");
		return true;
	}
	
	if ((aPacket[0] == 0x01) && (stuck) || (aPacket[0] == 0x03) && (stuck) || (aPacket[0] == 0x04) && (stuck))	// Copy down the person's location 

for future reference
	{

		server->GameSendPacketToGame(ForceRun, 11);
		return false;
	}

	return aLen;
}

////////////////////////////////////////////////////////////////////////////
// incoming
////////////////////////////////////////////////////////////////////////////

DWORD EXPORT OnGamePacketBeforeReceived(BYTE* aPacket, DWORD aLen)
{
	
	
	//Check for changes in health
	//If they are getting hit when they are supposed to be in bullettime mode
	//then tell them they are vulnerable.


	if (aPacket[0] == 0x95)
	{
		
		health = *((WORD *)(aPacket + 1)) & 0x0FFF;
		

		if (hmedian >> health)
		{
			ok=true;
		}

		if (hmedian <= health)
		{
			ok=false;
			hmedian = health;
		}
		if ((stuck) & (ok))
		{

			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1Health Rel");
			ok=false;
			stuck=false;
		}
	}
	
	//If they are where they should be by typing .bt go then they will be
	//stcuk in place and invincible to ranged attacks
	if ((aPacket[0] == 0x96) && (aPacket[7] == 0) && (aPacket[8] == 0) && (commanded))
	{
		stuck=true;
		server->GameSendPacketToServer(pickup, 9);
		commanded=false;
		server->GamePrintInfo("ÿc2>;===---    -    ! BULLET TIME !    -    ---===;<");
		server->GamePrintInfo("ÿc2>;===---    -    ! BULLET TIME !    -    ---===;<");
		server->GamePrintInfo("ÿc2>;===---    -    ! BULLET TIME !    -    ---===;<");
		hmedian=health - 1;
		return true;
	}
	
	if (aPacket[0] == 0x15)
	{
		//THESE WERE MY ATTEMPTS AT TELEPORTS TURNING OFF THE STUCK
		if (damn)
		{
			memcpy(bodylocal,aPacket,11);
			damn=false;
		}
		if (stuck)
		{
			memcpy(attempt,aPacket,11);
			
			if ((char *)teleport == (char *)attempt)
			{
				stuck=false;
				server->GamePrintInfo("ÿc1VULNERABLE");
				server->GamePrintInfo("ÿc1VULNERABLE");
				server->GamePrintInfo("ÿc1VULNERABLE");
				server->GamePrintInfo("ÿc1VULNERABLE");
			}
		}
		if (teleported)
		{
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			server->GamePrintInfo("ÿc1VULNERABLE");
			stuck=false;
		}
	}


	if (aPacket[0] == 0x5a)
	{	
		//When you first die, instruct user to stand near body and type .bt go
		sprintf(Msg1, "%s", (char*) (aPacket+8));
		sprintf(PID, "%s", &thisgame->player->PlayerName[0]);   //PID is the Player's name
		if (strcmpi(Msg1,PID) == 0) 
		{ 
			server->GamePrintInfo("ÿc3You have died. Now resurrect yourself and go stand within viewable range of your body");
			server->GamePrintInfo("ÿc3then type ÿc2.bt go");
			KilledPlayer=true;

		}

	return true;
	}
	
	//Takes note of where you died so module can go back there...duh!
	//
	if ((aPacket[0] == 0x59) && (KilledPlayer)) {


		int posstart;
		posstart=((int)aLen)-4;
		memcpy(xypos+1,aPacket+posstart,4);
		memcpy(BID,aPacket+1,4);
		memcpy(pickup+5,BID,4);
		KilledPlayer=false;

		return true;
	}
	return aLen;
}

////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
////////////////////////////////////////////////////////////////////////////

// Record
BOOL PRIVATE OnGameCommandGo(char** argv, int argc)
{
	//server->GamePrintInfo("Moving to dead body");
	damn=true;
	memcpy(ForceRun+2, &thisgame->player->PlayerID, 4); // playerID
	server->GameSendPacketToServer(xypos, 5);
	memcpy(ForceRun+6,xypos+1,4);
	server->GameSendPacketToGame(ForceRun, 11);
	

	commanded=true;
	
	return true;
}

BOOL PRIVATE OnGameCommandUnstuck(char** argv, int argc)
{
	stuck=false;
	server->GamePrintInfo("ÿc1VULNERABLE");
	server->GamePrintInfo("ÿc1VULNERABLE");
	server->GamePrintInfo("ÿc1VULNERABLE");
	server->GamePrintInfo("ÿc1VULNERABLE");
	return true;
}


BOOL PRIVATE OnGameCommandMatrix(char** argv, int argc)
{
	stuck=false;
	server->GamePrintInfo("Welcome to the Matrix. Prepare to learn the art of BulletTime.");
	server->GamePrintInfo("Follow these instructions to successful dodge missile attacks (NOT MELEE)");
	server->GamePrintInfo("1. The first step is to kill yourself so we have a body to work with. Go let someone kill you.");
	server->GamePrintInfo("2. After that, go within range of your body within an unobstructed view and type ÿc2.bt go");
	server->GamePrintInfo("3. After that, you will be immune to missile attacks, but only if you stay in one place.");
	server->GamePrintInfo("4. You can unlock yourself by typing ÿc2.bt run ÿc0 or by getting hit by a melee attack.");
	server->GamePrintInfo("DO NOT: Teleport, Leap, Warp, etc. while locked. You have been warned.");
	return true;
}
 

Ultimate Empire

BattleForums Addict
Joined
May 18, 2003
Messages
701
Reaction score
0
Update: Modified code for some errors commenting
Update: Should now be more user-friendly for learning purposes
 

binny

Member!
Joined
Apr 13, 2005
Messages
208
Reaction score
0
Location
canaDa
Very nice. Unfortunately my C++ knowledge is not advanced enough to make use of that ;)
 

Ultimate Empire

BattleForums Addict
Joined
May 18, 2003
Messages
701
Reaction score
0
I find that you don't really need to know much C++ in order to learn how to understand modules. Although I find it extremly useful for making them :) Here is what you need to get started if you're interested, in chronological order:

1) Learn the principles of the D2 packet system. Here is Ace's compilation, and is a good place to start.

2) Look at the source code to old modules. You should know what they do first, and then examine them thoroughly to see what makes them tick.

3) Online C++ tutorial for just the basics. It'll take you only 1 night to master a simple tutorial (Object-oriented design is recommended, but not required for creating a module). Here or Here will do fine. As well, you'll need the d2hackit framework (source code) and Visual C++ 6.0 or some other compiler.

To start you off:
- A common fact people don't know is that any d2hackit plugin/file (*.d2h extension) is really just a DLL (dynamic linked library) that was compiled alongside the d2hackit code.
 

wasup999999

BattleForums Member
Joined
Oct 10, 2003
Messages
450
Reaction score
0
Location
Hmm, Where Do You Think?
Website
Visit site
Not bad, not to bad of documentation. It wouldn't be bad to maybe explain to new developers the way d2hackit modules word, due to the fact that most people have no clue how they work (I mean the main syntax, not the noob stuff, like arrays n stuff). I have a feeling I might be into writing modules when the next d2hackit comes out.

Edit#2: (yes i can count) Removed my first edit.
 

binny

Member!
Joined
Apr 13, 2005
Messages
208
Reaction score
0
Location
canaDa
Ultimate Empire said:
I find that you don't really need to know much C++ in order to learn how to understand modules. Although I find it extremly useful for making them :) Here is what you need to get started if you're interested, in chronological order:

1) Learn the principles of the D2 packet system. Here is Ace's compilation, and is a good place to start.

2) Look at the source code to old modules. You should know what they do first, and then examine them thoroughly to see what makes them tick.

3) Online C++ tutorial for just the basics. It'll take you only 1 night to master a simple tutorial (Object-oriented design is recommended, but not required for creating a module). Here or Here will do fine. As well, you'll need the d2hackit framework (source code) and Visual C++ 6.0 or some other compiler.

To start you off:
- A common fact people don't know is that any d2hackit plugin/file (*.d2h extension) is really just a DLL (dynamic linked library) that was compiled alongside the d2hackit code.
Good stuff. I'll probably read some of that later. More for the sake of learning then actually doing anything with it. I already know the basics of C++ (functions, arrays and all that)
 

_Ace

BattleForums Senior Member
Joined
May 17, 2003
Messages
1,474
Reaction score
0
Location
Under my bed (Spain)
Website
Visit site
Too bad my packetlist (as everything I start) isn't finished, lol.
Oh well, if a d2hackit ever comes out for 1.11b I'll work on it more. But seeing Warden gayness I highly doubt it :(
 

Ultimate Empire

BattleForums Addict
Joined
May 18, 2003
Messages
701
Reaction score
0
I need someone to explain warden to me :) As well as alot of other things...

I wonder...maybe if I read the stickes :p
 

NewPosts

New threads

Top