Blockland Forums > Modification Help

Scripting Easiest Program/need help

Pages: << < (4/8) > >>

SpreadsPlague:


--- Quote from: Muffin on September 02, 2010, 02:40:01 PM ---So im guessing torque script is readable through notepad then?

--- End quote ---

yes

Muffin:

//Credits go to Azerath For the Main Script from his tutorial.

//G18.cs

//audio
datablock AudioProfile(G18Shot1Sound)
{
   filename    = "./G18.wav";
   description = AudioClose3d;
   preload = true;
};
datablock AudioProfile(bulletHitSound)
{
   filename    = "./bulletHit.wav";
   description = AudioClose3d;
   preload = true;
};


//shell
datablock DebrisData(G18ShellDebris)
{
   shapeFile = "./gunShell.dts";
   lifetime = 2.0;
   minSpinSpeed = -400.0;
   maxSpinSpeed = 200.0;
   elasticity = 0.5;
   friction = 0.2;
   numBounces = 3;
   staticOnMaxBounce = true;
   snapOnMaxBounce = false;
   fade = true;

   gravModifier = 2;
};


//muzzle flash effects
datablock ParticleData(G18FlashParticle)
{
   dragCoefficient      = 3;
   gravityCoefficient   = -0.5;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 25;
   lifetimeVarianceMS   = 15;
   textureName          = "base/data/particles/Cloud";
   spinSpeed      = 10.0;
   spinRandomMin      = -500.0;
   spinRandomMax      = 500.0;
   colors[0]     = "0.9 0.9 0.0 0.9";
   colors[1]     = "0.9 0.5 0.0 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 1.0;

   useInvAlpha = false;
};


This is torque script right? I found his on a Cs. File that i opened with notepad++
Edit:err part of it

Chrono:

That's torquescript, but just datablocks.

datablocks give objects their major aspects. Like player speed, health and stuff.

functions are more complicated things that change or add to how the game plays.

Muffin:

function G18Image::onFire(%this,%obj,%slot)
{
   if(%obj.getDamagePercent() < 1.0)
      %obj.playThread(2, plant);
   %projectile = %this.projectile;
   %spread = 0.0020;
   %shellcount = 1;

   for(%shell=0; %shell<%shellcount; %shell++)
   {
      %vector = %obj.getMuzzleVector(%slot);
      %objectVelocity = %obj.getVelocity();
      %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
      %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
      %velocity = VectorAdd(%vector1,%vector2);
      %x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
      %y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
      %z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
      %mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
      %velocity = MatrixMulVector(%mat, %velocity);

      %p = new (%this.projectileType)()
      {
         dataBlock = %projectile;
         initialVelocity = %velocity;
         initialPosition = %obj.getMuzzlePoint(%slot);
         sourceObject = %obj;
         sourceSlot = %slot;
         client = %obj.client;
      };
      MissionCleanup.add(%p);
   }
   return %p;
}
Then this si the funtion then? That means that the first part was How the weapon looked and the specs and stats of it. And the funtion is like the animations and How the gun is used when its in play?

Chrono:

An object-oriented function yes.

This is called when that specific weapon is fired.
%this is the datablock.
%obj is the player firing the weapon.
%slot will most likely be 0, for right hand slot.
%obj.playthread is the player playing an animation.
%projectile is the datablock's projectile value, which references a projectile datablock.
 for(%shell=0; %shell<%shellcount; %shell++) should only be in there for shotguns. The creator is an idiot.
All that vector stuff is creating spread.
%p = new (%this.projectileType)() is creating a projectile object, with the projectile datablock. The vectors determine the velocity, which includes the spread. The initial position gets the barrel point of the right hand weapon. sourceObject, slot, and client are all for damaging and killing functions, to know who did it.

Pages: << < (4/8) > >>

Go to full version