Renamed Server to servertest.cs

made some upgrades to the scripts, and added in movement for players and
vehicles inside a moving base.  Also added a real setMPS function with
x, y, and z.
This commit is contained in:
Calvin Balke 2015-01-28 14:36:38 -08:00
parent cc00588cca
commit 4830623b7a
6 changed files with 58 additions and 19 deletions

View file

@ -6,7 +6,10 @@
#include <DXAPI/DXAPI.h>
#include <DXAPI/MatMath.h>
static float counter=0;
static float mps=0.0;
static float mpsx=0.0;
static float mpsy=0.0;
static float mpsz=0.0;
static bool moveplayerstoo=1;
static bool clientupdate=false;
static float timecounter=0;
#define CMALLOC (char*)malloc
@ -60,7 +63,7 @@ void setClientPosition(unsigned int object,DX::Point3F pos){
sendGhostCommandAll(5,object,pos);
}
void moveRecursive(unsigned int simgroup,float xoff){
void moveRecursive(unsigned int simgroup,float xoff, float yoff, float zoff){
unsigned int mainsim=(unsigned int)simgroup;
if (mainsim) {
@ -76,14 +79,22 @@ void moveRecursive(unsigned int simgroup,float xoff){
DX::Point3F test;
mat1.getColumn(3,&test);
test.x+=xoff;
test.y+=yoff;
test.z+=zoff;
mat1.setColumn(3,&test);
sobj.setTransform(mat1.m);
if (moveplayerstoo==1) {
char evalstr[512]="";
sprintf (evalstr,"onMoveRoutine(%d,\"%g %g %g\",\"%g %g %g\",%g);",sobj.identifier,xoff,yoff,zoff,sobj.worldspherecenter.x,sobj.worldspherecenter.y,sobj.worldspherecenter.z,sobj.worldsphereradius);
Con::eval(evalstr,false,NULL);
}
if (clientupdate==true) {
setClientPosition(sobj.base_pointer_value,test);
setClientPosition(sobj.base_pointer_value,test);
}
}
} else {
moveRecursive(sim2.getObject(x),xoff);
moveRecursive(sim2.getObject(x),xoff,yoff,zoff);
}
}
}
@ -130,7 +141,8 @@ void serverProcessReplacement(unsigned int timeDelta) {
if (Sim::findObjectc("MoveGroup")) {
basex+=counter;
DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("MoveGroup"));
moveRecursive((unsigned int)Sim::findObjectc("MoveGroup"),(mps*((float)((timeDelta)*0.001))));
moveRecursive((unsigned int)Sim::findObjectc("MoveGroup"),(mpsx*((float)((timeDelta)*0.001))),(mpsy*((float)((timeDelta)*0.001))),(mpsz*((float)((timeDelta)*0.001))));
Con::eval("MoveRoutineDone();",false,NULL);
}
if (clientupdate==true) {
timecounter=0;
@ -185,7 +197,9 @@ const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]
return test2;
}
bool conSetMPS(Linker::SimObject *obj, S32 argc, const char *argv[]) {
mps=atof(argv[1]);
mpsx=atof(argv[1]);
mpsy=atof(argv[2]);
mpsz=atof(argv[3]);
return false;
}
const char *conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[])

View file

@ -43,7 +43,7 @@ extern "C"
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);
Con::addMethodS("SceneObject", "getPositionTest", &conGetPosition,"Gets the Rotation by alternate means as a test", 2, 2);
Con::addMethodB(NULL,"setMPS",&conSetMPS,"sets meters per second for turret", 2, 2);
Con::addMethodB(NULL,"setMPS",&conSetMPS,"sets meters per second for turret in format x,y,z", 4, 4);
// TCPObject
#ifdef ENABLE_TCPOBJECT
Con::addMethodS("TCPObject", "connect", &conTCPObjectConnect, "Connects to a remote server", 3, 3);

View file

@ -1,12 +0,0 @@
// this is a test for katabatic only with both client and server running their scripts.
// this should be run after joining the game, or you will fall through the map on spawn where the Team1 base used to be.
memPatch("5BBBDC",getServPAddr()); //Hooks the serverProcess function
$mg = new SimSet(MoveGroup);
MoveGroup.add(Team1); //Adds the Team1 base to the movement group
setMPS(0.5); // Moves the base 0.5 meters per second on the X axis.

37
Patches/servertest.cs Normal file
View file

@ -0,0 +1,37 @@
// this is a test for katabatic only with both client and server running their scripts.
// this should be run after joining the game, or you will fall through the map on spawn where the Team1 base used to be.
$movesim = new SimSet(MoveEffectSet);
function onMoveRoutine(%obj, %offset, %center, %radius){
InitContainerRadiusSearch(%obj.getWorldBoxCenter(),%radius,$TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType);
%obj2=ContainerSearchNext();
while (%obj2) {
if (!(MoveEffectSet.isMember(%obj2))) {
MoveEffectSet.add(%obj2);
}
%obj2 = ContainerSearchNext();
}
$moveoffset=%offset;
}
function moveRoutineDone() {
for (%x=0;%x<(MoveEffectSet.getCount()); %x++) {
%obj=MoveEffectSet.getObject(%x);
%obj.setPosition(VectorAdd(%obj.position,$moveoffset));
}
MoveEffectSet.clear();
}
memPatch("5BBBDC",getServPAddr()); //Hooks the serverProcess function
$mg = new SimSet(MoveGroup);
MoveGroup.add(Team1); //Adds the Team1 base to the movement group
setMPS(-10,0.0,0.0); // Moves the base 0.5 meters per second on the X axis.