From d0936c3c075bd39c39fb51486c0678cc1498c788 Mon Sep 17 00:00:00 2001 From: Calvin Balke Date: Fri, 30 Jan 2015 13:36:27 -0800 Subject: [PATCH] Updated Scripts and added projectile collisions Added a new projectile collision detection feature. It requires projectiles to be added to CollideGroup. Also added a new ClientCommandGroup that clients should be added to after they have finished ghosting. Currently setMPS effects everything in MoveGroup. setMPS now uses X, Y, and Z as arguments instead of X only. --- Mod Sources/TSExtension/TSExtension.suo | Bin 44544 -> 44544 bytes .../TSExtension/include/DXAPI/MatMath.h | 4 +- .../TSExtension/include/DXAPI/SceneObject.h | 4 + .../TSExtension/source/DXAPI/SceneObject.cpp | 1 + .../TSExtension/source/DXConCmds.cpp | 72 +++++++++- Patches/autoexec.cs | 2 +- Patches/clientautoexec.cs | 2 +- Patches/servertest.cs | 133 +++++++++++++++++- 8 files changed, 206 insertions(+), 12 deletions(-) diff --git a/Mod Sources/TSExtension/TSExtension.suo b/Mod Sources/TSExtension/TSExtension.suo index dc7b030014d6e3714dffc9d9cc15830d352efbc5..24322fa0c6ed3fbd3362dff536870ba4f886f38b 100644 GIT binary patch delta 89 zcmZp;!_;txX+sVRTS9L6bQPP;MJ%^u1*f^D-zk~%xa8v&4d24d+7On>g09M&8Og3QQ+59E!JnQ7cEQXuE#P9?H0OuAT)&Kwi delta 89 zcmZp;!_;txX+sVRn?r*7125~%MJ%^u1vy-Uf{$q&%-X(V%1@PJEY&QN1znXlHz=Jj oW-(=8V3@4nsxi4F%zyG>7Q@Y7!p^gDGX4hwL#Wi|FEKoU0RF`yC;$Ke diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h index 10ee5fb..5f4c3b7 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/MatMath.h @@ -177,5 +177,7 @@ namespace DX m_quatF_set_matF_C(ang->x,ang->y,ang->z,ang->w); } }; - + inline float pointdistance(DX::Point3F p1, DX::Point3F p2) { + return (sqrt(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2)+pow(p1.z-p2.z,2))); + } } // End NameSpace DX diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h index 5a5f128..d154835 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/SceneObject.h @@ -5,6 +5,9 @@ namespace DX { + + + class SceneObject : public NetObject { public: @@ -12,6 +15,7 @@ namespace DX Point3F position; Point3F scale; + void * container; float * worldtoobj; float * objtoworld; Point3F objboxmin; diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp index 40d8da0..4a3a02d 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI/SceneObject.cpp @@ -4,6 +4,7 @@ namespace DX { SceneObject::SceneObject(unsigned int obj) : position(*(float*)(obj + 168), *(float*)(obj + 184), *(float*)(obj + 200)), scale(*(float*)(obj + 284), *(float*)(obj + 288), *(float*)(obj + 292)), + container((void*)(unsigned int)(obj+0xD8)), worldtoobj((float*)(obj + 0xDC)), objtoworld((float*)(obj+0x9C)), objboxmin(*(float*)(obj + 296), *(float*)(obj + 300), *(float*)(obj + 304)), diff --git a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp index 32732f6..6645fbb 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp @@ -5,6 +5,8 @@ #include #include #include +#include + static float counter=0; static float mpsx=0.0; static float mpsy=0.0; @@ -13,9 +15,10 @@ static bool moveplayerstoo=1; static bool clientupdate=false; static float timecounter=0; #define CMALLOC (char*)malloc + void sendCommandAll(int argc,char *cmd[]) { - unsigned int mainsim=(unsigned int) Sim::findObjectc("ClientGroup"); + unsigned int mainsim=(unsigned int) Sim::findObjectc("ClientCommandGroup"); if (mainsim) { DX::SimGroup ccg=DX::SimGroup(mainsim); for (unsigned int x=0; x3) { + char evalstring[1024]=""; + sprintf (evalstring,"ProjCollisionCallback(%d,%d);",sobj2.identifier,sobj3.identifier); + Con::eval(evalstring, false, NULL); + } + } + } + + + + + + } + } + +} + void moveRecursive(unsigned int simgroup,float xoff, float yoff, float zoff){ unsigned int mainsim=(unsigned int)simgroup; @@ -134,19 +188,25 @@ void serverProcessReplacement(unsigned int timeDelta) { float basex=348.08; float basey=-178.761; float basez=113.037; - timecounter+=((float)((timeDelta)*0.001)); - if (timecounter>=0.002) { + //timecounter+=((float)((timeDelta)*0.001)); + //if (timecounter>=0.002) { clientupdate=true; - } + //} if (Sim::findObjectc("MoveGroup")) { basex+=counter; DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("MoveGroup")); 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 (Sim::findObjectc("CollideGroup")) { + basex+=counter; + DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("CollideGroup")); + collide((unsigned int)Sim::findObjectc("CollideGroup")); +// Con::eval("MoveRoutineDone();",false,NULL); + } if (clientupdate==true) { timecounter=0; - clientupdate=false; + //clientupdate=false; } __asm diff --git a/Patches/autoexec.cs b/Patches/autoexec.cs index 8d6ac8d..55cac61 100644 --- a/Patches/autoexec.cs +++ b/Patches/autoexec.cs @@ -3,7 +3,7 @@ memPatch("A3A100","5052BA00000000B8200000005150526800000000E8C7D6B4FF5A585981C20 memPatch("A3A200","5052BA00000000B8200000005150526800000000E8C7D5B4FF5A585981C20100000039C27CE65A58E9FC8AB8FF"); memPatch("5C2D22","E9D97447009090"); memPatch("5C2D85","E9767347009090"); -memPatch("43D72E","7E"); +//memPatch("43D72E","7E"); memPatch("0058665C","9090909090909090"); memPatch("00586682","90909090909090909090"); memPatch("005866AB","90909090909090909090"); diff --git a/Patches/clientautoexec.cs b/Patches/clientautoexec.cs index 8d6ac8d..55cac61 100644 --- a/Patches/clientautoexec.cs +++ b/Patches/clientautoexec.cs @@ -3,7 +3,7 @@ memPatch("A3A100","5052BA00000000B8200000005150526800000000E8C7D6B4FF5A585981C20 memPatch("A3A200","5052BA00000000B8200000005150526800000000E8C7D5B4FF5A585981C20100000039C27CE65A58E9FC8AB8FF"); memPatch("5C2D22","E9D97447009090"); memPatch("5C2D85","E9767347009090"); -memPatch("43D72E","7E"); +//memPatch("43D72E","7E"); memPatch("0058665C","9090909090909090"); memPatch("00586682","90909090909090909090"); memPatch("005866AB","90909090909090909090"); diff --git a/Patches/servertest.cs b/Patches/servertest.cs index ffd4e77..6fea8b5 100644 --- a/Patches/servertest.cs +++ b/Patches/servertest.cs @@ -4,7 +4,7 @@ - +loadMod("TSExtension"); $movesim = new SimSet(MoveEffectSet); function onMoveRoutine(%obj, %offset, %center, %radius){ @@ -21,11 +21,138 @@ function onMoveRoutine(%obj, %offset, %center, %radius){ $moveoffset=%offset; } +$collidegroup = new SimSet(CollideGroup); +function DiscImage::onFire(%data, %obj, %slot) +{ + if(%obj.fireTimeoutDisc) //-nite- + return; +// %data.lightStart = getSimTime(); +// if( %obj.station $= "" && %obj.isCloaked() ) +// { +// if( %obj.respawnCloakThread !$= "" ) +// { +// Cancel(%obj.respawnCloakThread); +// %obj.setCloaked( false ); +// %obj.respawnCloakThread = ""; +// } +// else +// { +// if( %obj.getEnergyLevel() > 20 ) +// { +// %obj.setCloaked( false ); +// %obj.reCloak = %obj.schedule( 500, "setCloaked", true ); +// } +// } +// } + + %vehicle = 0; + %weapon = %obj.getMountedImage(0).item; + + if(%obj.client.mode[%weapon] == 0) + { + %projectile = "DiscProjectile"; + %mode = "LinearProjectile"; + %obj.fireTimeoutDisc = 1000; //should be the same as 1.25 -Nite- + %enUse = 0; + %ammoUse = 1; + } //1250 + else if(%obj.client.mode[%weapon] == 1) + { + %projectile = "TurboDisc"; + %mode = "LinearProjectile"; + %obj.fireTimeoutDisc = 1250; //should be the same as .25 -Nite- + %enUse = 7; + %ammoUse = 1; + } //230 + else if(%obj.client.mode[%weapon] == 2) + { + %projectile = "PowerDiscProjectile"; + %mode = "LinearProjectile"; + %enUse = 15; + %ammoUse = 2; + %obj.fireTimeoutDisc = 1500; //should be same as 2.25 -Nite- + } //2250 + + if(%obj.powerRecirculator) + %enUse *= 0.75; + + if(%ammoUse > %obj.getInventory(%data.ammo) || %enUse > %obj.getEnergyLevel()) + { + schedule(%obj.fireTimeoutDisc, 0, "DiscFireTimeoutClear", %obj); + return; + } + + %p = new(%mode)() + { + dataBlock = %projectile; + initialDirection = %obj.getMuzzleVector(%slot); + initialPosition = %obj.getMuzzlePoint(%slot); + sourceObject = %obj; + sourceSlot = %slot; + vehicleObject = %vehicle; + }; + CollideGroup.add(%p); + %useEnergyObj = %obj.getObjectMount(); + + if(!%useEnergyObj) + %useEnergyObj = %obj; + + %vehicle = %useEnergyObj.getType() & $TypeMasks::VehicleObjectType ? %useEnergyObj : 0; + + // Vehicle Damage Modifier + if(%vehicle) + %p.vehicleMod = %vehicle.damageMod; + + if(%obj.damageMod) + %p.damageMod = %obj.damageMod; + + if (isObject(%obj.lastProjectile) && %obj.deleteLastProjectile) + %obj.lastProjectile.delete(); + + %obj.lastProjectile = %p; + %obj.deleteLastProjectile = %data.deleteLastProjectile; + MissionCleanup.add(%p); + // all this for emulating state stuff -Nite- + %obj.play3D(DiscFireSound);// play fire sounds -Nite- + if( %obj.getState() !$= "Dead" ) // +soph + %obj.setActionThread("light_recoil"); //Play anim recoil -Nite- + schedule(500, %obj.play3D(DiscReloadSound),%obj);//play reload sound 500ms after we fire -Nite- + schedule(%obj.fireTimeoutDisc, 0, "DiscFireTimeoutClear", %obj); //Use fire time out for each mode -Nite- + // serverCmdPlayAnim(%obj.client,"light_recoil"); //this worked too lol -Nite- + + // AI hook + if(%obj.client) + %obj.client.projectile = %p; + + %obj.decInventory(%data.ammo, %ammoUse); + %obj.useEnergy(%enUse); + + if(%obj.client.mode[%weapon] == 1) + %obj.applyKick(-500); + + if(%obj.client.mode[%weapon] == 2) + %obj.applyKick(-1000); +} + + + + +function ProjCollisionCallback(%proj1, %proj2) { + echo(%proj1 SPC "collided with" SPC %proj2); + %proj1.delete(); + %proj2.delete(); +} function moveRoutineDone() { for (%x=0;%x<(MoveEffectSet.getCount()); %x++) { %obj=MoveEffectSet.getObject(%x); - %obj.setPosition(VectorAdd(%obj.position,$moveoffset)); + if(%obj.getType() | $TypeMasks::PlayerObjectType) { + if (%obj.isjetting() || %obj.isjumping() ) { + echo ("Artificial Gravity Disengaged for" SPC %obj); + } else { + %obj.setPosition(VectorAdd(%obj.position,$moveoffset)); + } + } } MoveEffectSet.clear(); @@ -34,4 +161,4 @@ function moveRoutineDone() { 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. \ No newline at end of file +setMPS(0.0,0.0,0.0); // Moves the base 0.5 meters per second on the X axis. \ No newline at end of file