mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-01-19 18:14:44 +00:00
Added new Move Code
Added Move Code, TS callback, and commands to interface with Move code.
This commit is contained in:
parent
2ee8c36a90
commit
81a28fe3ba
|
|
@ -84,6 +84,7 @@
|
|||
<ClInclude Include="include\DXAPI\GameBase.h" />
|
||||
<ClInclude Include="include\DXAPI\GameConnection.h" />
|
||||
<ClInclude Include="include\DXAPI\GrenadeProjectile.h" />
|
||||
<ClInclude Include="include\DXAPI\Move.h" />
|
||||
<ClInclude Include="include\DXAPI\NetConnection.h" />
|
||||
<ClInclude Include="include\DXAPI\NetObject.h" />
|
||||
<ClInclude Include="include\DXAPI\Player.h" />
|
||||
|
|
@ -104,6 +105,7 @@
|
|||
<ClCompile Include="source\DXAPI\GameBase.cpp" />
|
||||
<ClCompile Include="source\DXAPI\GameConnection.cpp" />
|
||||
<ClCompile Include="source\DXAPI\GrenadeProjectile.cpp" />
|
||||
<ClCompile Include="source\DXAPI\Move.cpp" />
|
||||
<ClCompile Include="source\DXAPI\NetConnection.cpp" />
|
||||
<ClCompile Include="source\DXAPI\NetObject.cpp" />
|
||||
<ClCompile Include="source\DXAPI\Player.cpp" />
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@
|
|||
<ClInclude Include="include\LinkerAPI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\DXAPI\Move.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\DXAPI\DXAPI.cpp">
|
||||
|
|
@ -125,5 +128,8 @@
|
|||
<ClCompile Include="source\LinkerAPI.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\DXAPI\Move.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/GameBase.h>
|
||||
#include <DXAPI/Move.h>
|
||||
#include <DXAPI/NetObject.h>
|
||||
#include <DXAPI/Player.h>
|
||||
#include <DXAPI/Projectile.h>
|
||||
|
|
@ -31,7 +32,6 @@
|
|||
#include <DXAPI/NetConnection.h>
|
||||
#include <DXAPI/TCPObject.h>
|
||||
#include <DXAPI/ScriptObject.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
//! A typedef referring to some type of unresolved object in the game.
|
||||
|
|
|
|||
38
CommonAPI/Common/include/DXAPI/Move.h
Normal file
38
CommonAPI/Common/include/DXAPI/Move.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/GameBase.h>
|
||||
|
||||
#include <LinkerAPI.h>
|
||||
namespace DX
|
||||
{
|
||||
|
||||
struct Move {
|
||||
int px;
|
||||
int py;
|
||||
int pz;
|
||||
int pyaw;
|
||||
int ppitch;
|
||||
int proll;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float yaw;
|
||||
float pitch;
|
||||
float roll;
|
||||
int unused;
|
||||
int count;
|
||||
bool freelook;
|
||||
bool triggers[6];
|
||||
|
||||
};
|
||||
struct AIMove {
|
||||
unsigned int id;
|
||||
Move move;
|
||||
bool used;
|
||||
};
|
||||
float clampFloat(float in);
|
||||
float clampMove(float in);
|
||||
void generateNullMove(Move * ret);
|
||||
|
||||
};
|
||||
55
CommonAPI/Common/source/DXAPI/Move.cpp
Normal file
55
CommonAPI/Common/source/DXAPI/Move.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include <DXAPI/Move.h>
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_2PI 6.28318530717958647692528676655900576
|
||||
namespace DX
|
||||
{
|
||||
void generateNullMove(Move * ret) {
|
||||
DX::Move nullmove = {
|
||||
16,
|
||||
16,
|
||||
16,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
0,
|
||||
0,
|
||||
false,false,false,false,false,false
|
||||
|
||||
|
||||
};
|
||||
ret = &nullmove;
|
||||
}
|
||||
float clamp(float in, float min, float max) {
|
||||
if (in < min) {
|
||||
return min;
|
||||
} else if (in > max) {
|
||||
return max;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
float clip(float n, float lower, float upper) {
|
||||
return std::max(lower, std::min(n, upper));
|
||||
}
|
||||
float clampFloat(float in){
|
||||
return clip(in,-1.0f,1.0f);
|
||||
}
|
||||
|
||||
float clampMove(float in) {
|
||||
float tmpfloat = clamp(in,-M_PI,M_PI);
|
||||
if (tmpfloat < 0.0) {
|
||||
return tmpfloat + M_2PI;
|
||||
} else {
|
||||
return tmpfloat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,11 +20,116 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
|
||||
#include <DXAPI/DXAPI.h>
|
||||
#include <LinkerAPI.h>
|
||||
|
||||
#include <DXAPI/Move.h>
|
||||
#include <DXConCmds.h>
|
||||
static DX::Move curmove;
|
||||
static unsigned int tmpobjptr=0;
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
static DX::AIMove aimoves[1024];
|
||||
|
||||
DX::AIMove * getAIMovePtr(unsigned int id) {
|
||||
int moveindex=0;
|
||||
bool foundindex=false;
|
||||
for (int x=0; x<1024; x++) {
|
||||
if (aimoves[x].id==id && aimoves[x].used==true) {
|
||||
moveindex=x;
|
||||
foundindex=true;
|
||||
break;
|
||||
}
|
||||
if (aimoves[x].used==false) {
|
||||
moveindex=x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundindex==true) {
|
||||
return &aimoves[moveindex];
|
||||
} else {
|
||||
aimoves[moveindex].id=id;
|
||||
aimoves[moveindex].used=true;
|
||||
DX::generateNullMove(&(aimoves[moveindex].move));
|
||||
return &aimoves[moveindex];
|
||||
}
|
||||
}
|
||||
DX::Move tmpmove;
|
||||
__declspec(dllexport) void __cdecl newAIMoveListGenerator(DX::Move** moves, unsigned int * moveCount) {
|
||||
__asm {
|
||||
mov tmpobjptr,ecx
|
||||
}
|
||||
|
||||
unsigned int * origobjptr;
|
||||
origobjptr=(unsigned int *) tmpobjptr;
|
||||
DX::AIMove * aimove;
|
||||
DX::GameConnection * aiconn;
|
||||
//Con::printf ("Possible offsets for ID starting at 0x4\n");
|
||||
if (origobjptr !=0 ) {
|
||||
//unsigned int * idptr;
|
||||
//unsigned int offset=0x4;
|
||||
//for (offset=0x4; offset<0x100; offset+=0x4) {
|
||||
|
||||
//idptr=(unsigned int *)((* (origobjptr))+offset);
|
||||
//Con::printf ("Offset: %08X Addr: %08X Data: %d",offset, idptr, *idptr);
|
||||
|
||||
//}
|
||||
aiconn = &DX::GameConnection((unsigned int)origobjptr+0xA0);
|
||||
aimove = getAIMovePtr(aiconn->identifier);
|
||||
char movecallback[120]="";
|
||||
sprintf (movecallback,"AIMoveCallback(%d);",aiconn->identifier);
|
||||
Con::evaluate(movecallback,false,NULL,NULL);
|
||||
//Con::printf ("BasePointer: %08X", aiconn.base_pointer_value);
|
||||
//Con::printf ("Ecx Value: %08X", origobjptr);
|
||||
//Con::printf("ID: %d\n",aiconn.identifier);
|
||||
//Con::evaluate ("listPlayers();",true,NULL,NULL);
|
||||
|
||||
//Con::printf("orig: %08X obj: %08X\n",origobjptr,0xBADABEEB);
|
||||
|
||||
|
||||
|
||||
//Con::printf("Move processed for %08X\n",(aicon.identifier));
|
||||
}
|
||||
//memcpy (&tmpmove,&(aimove->move),sizeof(DX::Move));
|
||||
//DX::generateNullMove(&(aimove->move));
|
||||
*moves = &(aimove->move);
|
||||
*moveCount=1;
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
bool consetTrigger(Linker::SimObject *obj, S32 argc, const char *argv[]) {
|
||||
unsigned int aiconid = atoi(argv[1]);
|
||||
unsigned int index = atoi(argv[2]);
|
||||
if (index < 6) {
|
||||
DX::AIMove * aimove = getAIMovePtr(aiconid);
|
||||
bool value = dAtob(argv[3]);
|
||||
aimove->move.triggers[index]=value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool consetMove(Linker::SimObject *obj, S32 argc, const char *argv[]) {
|
||||
// setMove(%aicon, x, y, z, yaw, pitch, roll);
|
||||
unsigned int aiconid = atoi(argv[1]);
|
||||
DX::AIMove * aimove = getAIMovePtr(aiconid);
|
||||
aimove->move.x=DX::clampFloat(atof(argv[2]));
|
||||
aimove->move.y=DX::clampFloat(atof(argv[3]));
|
||||
aimove->move.z=DX::clampFloat(atof(argv[4]));
|
||||
aimove->move.yaw=DX::clampMove(atof(argv[5]));
|
||||
aimove->move.pitch=DX::clampMove(atof(argv[6]));
|
||||
aimove->move.roll=DX::clampMove(atof(argv[7]));
|
||||
//Con::printf ("Set move variables for %d to x:%f y:%f z:%f yaw:%f pitch:%f roll:%f\n",aimove->id,aimove->move.x,aimove->move.y,aimove->move.z,aimove->move.yaw,aimove->move.pitch,aimove->move.roll);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool conEnableNewAI(Linker::SimObject *obj, S32 argc, const char *argv[])
|
||||
{
|
||||
|
||||
(*((unsigned int *)0x75e360))=(unsigned int)newAIMoveListGenerator;
|
||||
return true;
|
||||
}
|
||||
|
||||
static S32 gravid=0;
|
||||
static float movespeed=0.0;
|
||||
__declspec(dllexport) void ServerProcess(unsigned int deltaTime)
|
||||
|
|
@ -60,7 +165,9 @@ extern "C"
|
|||
Con::addMethodB("GrenadeProjectile", "explode", &conProjectileExplode,"Explodes the given projectile", 5, 5);
|
||||
Con::addMethodB("GameBase","setProcessTicks",&conSetProcessTicks,"Sets the flag for processing ticks or not", 3, 3);
|
||||
Con::addMethodB("Projectile", "explode", &conProjectileExplode,"Explodes the given projectile", 5, 5);
|
||||
|
||||
Con::addMethodB(NULL,"enableNewAI",&conEnableNewAI,"Enables the new Move Generation code for the AI", 1,4);
|
||||
Con::addMethodB(NULL,"setAIMove",&consetMove,"setAIMove(%aicon, x, y, z, yaw, pitch, roll)", 2,10);
|
||||
Con::addMethodB(NULL,"setAITrigger", &consetTrigger, "setAITrigger(%aicon,triggerid,value);",2,5);
|
||||
Con::addMethodS("GrenadeProjectile", "getposition", &conGrenadeProjectileGetPosition,"Accurately gets the position of the GrenadeProjectile", 2, 2);
|
||||
Con::addMethodS("GrenadeProjectile", "getvelocity", &conGrenadeProjectileGetVelocity,"Gets the velocity of the GrenadeProjectile", 2, 2);
|
||||
Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
|||
static bool sDogPetted = false;
|
||||
static DWORD mainthreadid=0;
|
||||
static bool evaldone=1;
|
||||
|
||||
void overrideputhex(unsigned char hex) {
|
||||
char hexstr[40]="";
|
||||
char outchar=' ';
|
||||
|
|
|
|||
Loading…
Reference in a new issue