Does this deserve the title of "Hackiest Hack Ever"?
yes
 33%  [ 2 ]
no
 66%  [ 4 ]
Total Votes : 6

Gobbles commented in optionsDlg.cs that his setWindowStyle(); function is the "hackyest Hackyiest HAxx evar." I'd like to challenge this with a method I came up with this weekend that bypasses the projectile system on 20+ weapons, saving loads of datablocks:

from dtbinit.cs:

Code:
////////SuperFuntimeMegaPenisUltraHack////////
datablock ProjectileData(HackProjectile)//bullets
{
   projectileShapeName = "dtb/data/shapes/weapons/grenade.dts";
   directDamage        = 40;
   radiusDamage        = 0;
   damageRadius        = 0.5;
   muzzleVelocity      = 200;
   armingDelay         = 0;
   lifetime            = 20000;
   fadeDelay           = 16000;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 1;
   damagetype        = '%1 or %2 (whoever is testing the weapon) needs to learn to code';
};

//The point of this is to have a single projectile used by most weapons,
//which can have all it's shit redefined, saving shitloads of datablocks.
//Unfortunatly, I cannot redefine the shape, so I'll need to make few templates
//for different kinds of weapons to use. -DShiznit

datablock ProjectileData(Hack2Projectile)//missiles
{
   projectileShapeName = "dtb/data/shapes/weapons/missile.dts";
   directDamage        = 40;
   radiusDamage        = 0;
   damageRadius        = 0.5;
   muzzleVelocity      = 200;
   armingDelay         = 0;
   lifetime            = 20000;
   fadeDelay           = 16000;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 1;
   damagetype        = '%1 or %2 (whoever is testing the weapon) needs to learn to code';
};

datablock ProjectileData(Hack3Projectile)//beams
{
   projectileShapeName = "";
   directDamage        = 40;
   radiusDamage        = 0;
   damageRadius        = 0.5;
   muzzleVelocity      = 200;
   armingDelay         = 0;
   lifetime            = 20000;
   fadeDelay           = 16000;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 1;
   damagetype        = '%1 or %2 (whoever is testing the weapon) needs to learn to code';
};

exec("dtb/server/scripts/weapons/sword.cs");//melee weapons, contains mining code

function HackProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
       tbmradiusDamage
     (%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
      %this.damageRadius,%this.radiusDamage,%this.damageType,%this.impulse);
}

function Hack2Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
       tbmradiusDamage
     (%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
      %this.damageRadius,%this.radiusDamage,%this.damageType,%this.impulse);
}

function Hack3Projectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
       tbmradiusDamage
     (%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
      %this.damageRadius,%this.radiusDamage,%this.damageType,%this.impulse);
}


from acidgun.cs

Code:

   projectile = Hack3Projectile;
   projectileType = Projectile;


Code:
function AcidgunImage::onFire(%this, %obj, %slot)//edited by DShiznit for SuperFuntimeMegaPenisUltraHack
   {
      // Get the type of projectile we are gonna fire
      %projectile = %this.projectile;

   //this is where the hacking takes place -DShiznit
      %projectile.directDamage        = 3;
      %projectile.radiusDamage        = 2;
      %projectile.damageRadius        = 1.5;
      %projectile.explosion           = AcidgunExplosion;
    %projectile.particleEmitter     = AcidgunTrailEmitter;

      %projectile.muzzleVelocity      = 40;
   %projectile.dragCoeffiecient = 50.0;
      %projectile.velInheritFactor    = 1;

      %projectile.armingDelay         = 0;
      %projectile.lifetime            = 5000;
      %projectile.fadeDelay           = 0;
      %projectile.bounceElasticity    = 0;
      %projectile.bounceFriction      = 0;
      %projectile.isBallistic         = true;
      %projectile.gravityMod = 1;

      %projectile.hasLight    = false;
      %projectile.lightRadius = 3.0;
      %projectile.lightColor  = "0.2 0.055 0.0 0.8";
   %projectile.damagetype        = '%1 was melted by %2';
   %projectile.impulse         = 20;//added this for onCollision


the projectile in the script was removed and the projectile set in the imagedata changed to hack3projectile. There is no difference in-game, and it reduces the datablock count by 1. Times this by the 20+ weapons I hacked, and you'll see this add up, or to be more accurate, subtract down.
may I be the first n00b to ask; what the helll is this for again?
Some low-res lego thing. Just ignore it.
rthprog wrote:
may I be the first n00b to ask; what the helll is this for again?


Good question. What could he possibly be talking about in the Blockland subforum...?
if torquescript supports a cloneing function we could do it with bricks too. But i have a better long term plan for them anyway.


what you need to know about that, as compared to datablocks, is that if you use it on a large scale, it will hammer your network performance.


anyway, here's my entry.

Quote:
function showTerrainPath(){
ETerrainEditor.attachTerrain();
ETerrainEditor.currentMode = "paint";
echo(ETerrainEditor.getTerrainMaterials());
}

function fixTerrainPath(%oldmod, %newmod){


ETerrainEditor.attachTerrain();
ETerrainEditor.currentMode = "paint";

%matlist = ETerrainEditor.getTerrainMaterials();
%max = getRecordCount(%matlist);
echo("Fixing " @%max@ " materials");
for(%i = 0; %i < %max; %i++){
%curpath = getRecord(%matlist, %i);
if(strlen(%curpath) > 0){
%newpath = %newmod @ getSubStr(%curpath, strlen(%oldmod), strlen(%curpath) - strlen(%oldmod));
//echo(%newpath);
%matlist = setRecord(%matlist, %i, %newpath);
}
}
echo(%matlist);
ETerrainEditor.setTerrainMaterials(%matlist);
Terrain.save(Terrain.terrainFile);
}


I'm pretty sure that NONE of those functions are documented. anywhere.
If I'm reading this right, that updates the file path for terrain textures from TBM to the 1.5 TBG for the texture painter? That is definitely a hell of a hacky hack.

For some reason, trail emitters aren't showing up for the electro-gun for any of my connected clients (I think this might be happening with other beam weapons, i'm not sure), and I think this might be because the emitter isn't being preloaded and downloaded to the client. This should be easy to verify and fix by making a "hackexplosion" that would have an emitter[#] for each weapon's trail particle, preloading the emitters adding only 1 datablock.

speaking of hacking, I'm trying to find some methods for getting brick physics to not suck. The first idea I came up with is to make the death vehicle use the same model as the brick it's being attached to, but if I couldn't redefine the model used by projectiles, theres no way I could make this work. My second idea was to have the death vehicle scale itself based on the bricks x y z data, times it's scale. This would be easy to do, but I'm not sure if the death vehicle's collision mesh is even large enough to be effective.

EDIT- I thought computeCRC had something to do with collision detection (as it appears only in vehicle scripts and player.cs) but it's something else. I feel so stupid now. Guess I'll try method 2.
wikipedia wrote:
A cyclic redundancy check (CRC) is a type of function that takes as input a data stream of any length, and produces as output a value of a certain space, commonly a 32-bit integer. The term CRC denotes either the function or the function's output. A CRC can be used as a checksum to detect accidental alteration of data during transmission or storage. CRCs are popular because they are simple to implement in binary hardware, are easy to analyze mathematically, and are particularly good at detecting common errors caused by noise in transmission channels. The CRC was invented by W. Wesley Peterson, and published in his 1961 paper[1]. The IEEE-recommended 32-bit CRC used in Ethernet and elsewhere appeared at a telecommunications conference in 1975.
I tried method 2, and almost have it working, but not quite:

from tumble2 function in player.cs:

Code:
   //mount the object on a new deathvehicle for %time milliseconds
   %currentVehicle = %obj.getObjectMount();
   %client = %obj.client;

   //this is where stuff for the hack is defined -DShiznit
   %objData = %obj.getDataBlock();
   %objDataClass = %objData.classname;
   %objlastscale = %obj.getscale();
   %xhack = getword(%obj.getscale(), 0);
   %yhack = getword(%obj.getscale(), 1);
   %zhack = getword(%obj.getscale(), 2);
   error("brick scale = ",%xhack SPC %yhack SPC %zhack);
   %xscale = %xhack * %objdata.x / 3;
   %yscale = %yhack * %objdata.y / 3;
   %zscale = %zhack * %objdata.z / 13;
   error("tumble scale = ",%xscale SPC %yscale SPC %zscale);
   %xhack2 = getword(%objlastscale, 0);
   %yhack2 = getword(%objlastscale, 1);
   %zhack2 = getword(%objlastscale, 2);
   %xrelative = %xhack2 / %objdata.x * 3;
   %yrelative = %yhack2 / %objdata.y * 3;
   %zrelative = %zhack2 / %objdata.z * 13;
   error("brick relative scale = ",%xrelative SPC %yrelative SPC %zrelative);

   %newcar = new WheeledVehicle()
   {
      dataBlock = deathVehicle;
      client = %client;
      initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
   };
   

   //%newcar = %client.tumbleVehicle;
   %newcar.setVelocity("0 0 0");
   %newcar.setTransform(%obj.gettransform());

   //this is where the hack is actually used -DShiznit
   if(%objDataClass $= "brick" || %obj.getDataBlock().classname $= "baseplate")
   {
   %newcar.setScale(%xscale SPC %yscale SPC %zscale);
   }

   if(!%newcar)
      return;
   
   //neutralize current velocity
   %newcar.applyImpulse( %newcar.getPosition(), vectorScale(%newcar.getVelocity() * -1, %newcar.getDataBlock().mass) );

   //error("player tumbling!");

   if(%currentVehicle && (%currentVehicle.getDataBlock().getName() $= "skiVehicle") )
   {
      //%obj.client.setControlObject(%obj);
      //match ski vehicle
      //neutralize velocity first
      
      %newcar.setTransform(%currentVehicle.getTransform());
      %newcar.applyImpulse( %newcar.getPosition(), vectorScale(%currentVehicle.getVelocity(), %newcar.getDataBlock().mass) );
      %newcar.mountObject(%obj, 0);

      %currentVehicle.setTransform("0 0 -1000");
      %currentVehicle.schedule(500, delete);
   }
   else
   {
      //match player
      error("transform = ",%obj.getTransform());
      //%newcar.setTransform(%obj.getTransform());
      %newcar.applyImpulse( %newcar.getPosition(), vectorScale(%obj.getVelocity(), %newcar.getDataBlock().mass) );
      //%newcar.setTransform(%obj.getTransform());

      

      //%obj.setTransform("0 0 0 0 0 1 0");

      %newcar.mountObject(%obj, 0);
      %obj.setscale(%xrelative SPC yrelative SPC zrelative);
      

      //error("not skiing");
      //error("transform = ",%obj.getTransform());
   }   

   
   %newcar.schedule(%time, delete);
   schedule(%time, 0, %obj.setscale(%objlastscale));

   %nextTumbleVehicle = new WheeledVehicle()
   {
      dataBlock = deathVehicle;
      client = %client;
      initialPosition = %posX @ " " @ %posY @ " " @ %posZ;
   };
   %obj.client.tumbleVehicle = %nextTumbleVehicle;
   %nextTumbleVehicle.setTransform("0 0 -90");

   //%newcar.schedule(%time, unmountobject, %obj);
   //%obj.schedule(%time, setcontrolobject, 0);
   //%newcar.schedule(%time + 250, setTransform, "0 0 -90");

   


From console.log, generated when tumble2 applied to an unscaled 32x32 plate:

Code:
brick scale = 1 1 1
tumble scale = 10.6667 10.6667 0.0769231
brick relative scale = 0.09375 0.09375 13
transform = -159.795 -56.5842 146.506 1 0 0 0



It scales the deathvehicle fine, and generates what the scale of the brick relative to the death vehicle should be to get the original size (I think, unless I did the math wrong), but it doesn't rescale it after mounting. And now it's giving me result of void function call errors when I try doing it to scaled and rotated bricks (on my AT-AT build) since I realized an error I made in my code. It still doesn't work though. Halp. Neutral
I've tried that before... way too crashy and laggy for my taste, even in the new engine. Stupid vehicles.
it would be possible for me to implement physics-enabled bricks in the new version but i think it would be wise for them to be used sparingly. Cemetech towers crumbling around your ears would take serious horsepower.
If we could somehow harness the Debris objects and skin them, 'twould be a nice solution.
elfprince13 wrote:
it would be possible for me to implement physics-enabled bricks in the new version but i think it would be wise for them to be used sparingly. Cemetech towers crumbling around your ears would take serious horsepower.
Oh man, that would be epic.
elfprince13 wrote:
it would be possible for me to implement physics-enabled bricks in the new version but i think it would be wise for them to be used sparingly. Cemetech towers crumbling around your ears would take serious horsepower.


It should actually be really, really easy. Block collision is insanely simple and fast. If its slow, its a bad physics engine and not a hard problem Wink
Kllrnohj wrote:
elfprince13 wrote:
it would be possible for me to implement physics-enabled bricks in the new version but i think it would be wise for them to be used sparingly. Cemetech towers crumbling around your ears would take serious horsepower.


It should actually be really, really easy. Block collision is insanely simple and fast. If its slow, its a bad physics engine and not a hard problem Wink


I'll test it out and see how it goes. keep in mind that cemetech towers has a couple of thousand bricks.
elfprince13 wrote:
Kllrnohj wrote:
elfprince13 wrote:
it would be possible for me to implement physics-enabled bricks in the new version but i think it would be wise for them to be used sparingly. Cemetech towers crumbling around your ears would take serious horsepower.


It should actually be really, really easy. Block collision is insanely simple and fast. If its slow, its a bad physics engine and not a hard problem Wink


I'll test it out and see how it goes. keep in mind that cemetech towers has a couple of thousand bricks.
I wouldn't mind seeing how that worked out in terms of lagginess and framerate.
If you fixed torque's object management, which is the root of most of the lag problems, vehicles would be just as easy to render in large amounts as bricks.

I think the problem with my code is that it tries to rescale the block mounted to the death vehicle, which torque isn't designed to do. I wonder if I could BS the collision detection by redefining the bounding box when the vehicle is created? I'm not trying to have thousands of bricks have physics, just a handful at a time.

Speaking of thousands of bricks with physics, have you guys read up on Retail's upcoming [not] physics:

http://coderhump.com/archives/275

If you read the article, then watch the video, you may notice that the physic bricks don't have any effect on the actual game world, they merely bounce into each other, because they're a client-rendered facade. Is it just me, or is that not a true physics engine?
a, can't redefine the mass center or mass box, nor can I even center the brick on the deathvehicle. I wonder if it's possible to mount static shapes to a debris object?
Please do not double-post.
shit sorry.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement