Author Topic: Weapon won't damage properly  (Read 571 times)

The direct damage won't register in-game as higher than 100, and the radius damage doesn't work at all. I tried testing just radius damage without Direct to see if something would happen, but alas.

The particles for the Explosion Data-block still work as normal though.

Code: [Select]
datablock ExplosionData(BladeofPlanes22Explosion)
{

   emitter[0] = BladeofPlaneloveplosionEmitter;
   emitter[1] = BladeofPlaneloveplosionEmitter2;
   emitter[2] = BladeofPlaneloveplosionEmitter3;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = false;
   camShakeFreq = "7.0 8.0 7.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 15.0;

   // Dynamic light
   lightStartRadius = 3;
   lightEndRadius = 1;
   lightStartColor = "0.5 0.5 0.5";
   lightEndColor = "0 0 0";

   impulseRadius = 4;
   impulseForce = 100;

   damageRadius = 3.2;
   radiusDamage = 400;
};

//projectile
AddDamageType("BladeofPlanes22",   '<bitmap:add-ons/Weapon_BladeofPlanes/CI_BOP> %1',    '%2 <bitmap:add-ons/Weapon_BladeofPlanes/CI_BOP> %1',1,1);
datablock ProjectileData(BladeofPlanes22Projectile)
{
   directDamage        = 0;
   directDamageType    = $DamageType::BladeofPlanes22;
   radiusDamageType    = $DamageType::BladeofPlanes22;
   impactImpulse   = 0;
   verticalImpulse   = 0;
   explosion           = BladeofPlanes22Explosion;
   particleEmitter     = BladeofPlaneloveplosionEmitter3;

   brickExplosionRadius = 0;
   brickExplosionImpact = true; //destroy a brick if we hit it directly?
   brickExplosionForce  = 0;
   brickExplosionMaxVolume = 0;
   brickExplosionMaxVolumeFloating = 0;

   muzzleVelocity      = 200;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 205;
   fadeDelay           = 205;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = true;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

   uiName = "BladeofPlanes";
};


//////////
// item //
//////////
datablock ItemData(BladeofPlanesItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./BladeOfPlanes2.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Blade of Planes";
iconName = "./icon_BladeofPlanes";
doColorShift = true;
colorShiftColor = "0.400 0.196 0 1.000";

// Dynamic properties defined by the scripts
image = BladeofPlanesImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BladeofPlanesImage)
{
   // Basic Item properties
   shapeFile = "./BladeOfPlanes2.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "-0.5 -0.6 -0.5";
   //eyeOffset = "0.1 0.2 -0.55";

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off.  
   correctMuzzleVector = true;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = BladeofPlanesItem;
   ammo = " ";
   projectile = BladeofPlanes22Projectile;
   projectileType = Projectile;

   //casing = " ";
   doColorShift = true;
   colorShiftColor = "0.400 0.196 0 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.45;
stateTransitionOnTimeout[0] = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1] = "Ready";
stateSequence[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Charge";
stateAllowImageChange[1] = true;

stateName[2]                    = "Charge";
stateTransitionOnTimeout[2] = "Armed";
stateTimeoutValue[2]            = 0.65;
stateSequence[2] = "Charge";
stateWaitForTimeout[2] = false;
stateTransitionOnTriggerUp[2] = "AbortCharge";
stateScript[2]                  = "onCharge";
stateAllowImageChange[2]        = true;

stateName[3] = "AbortCharge";
stateTransitionOnTimeout[3] = "Ready";
stateTimeoutValue[3] = 0.05;
stateWaitForTimeout[3] = true;
stateScript[3] = "onAbortCharge";
stateAllowImageChange[3] = true;

stateName[4] = "Armed";
stateTransitionOnTriggerUp[4] = "Fire";
stateAllowImageChange[4] = true;

stateName[5] = "Fire";
stateTransitionOnTimeout[5] = "Reload";
stateTimeoutValue[5] = 0.15;
stateFire[5] = true;
stateSequence[5] = "Fire";
stateScript[5] = "onFire";
stateWaitForTimeout[5] = true;
stateAllowImageChange[5] = true;


stateName[6]  = "Reload";
stateTimeoutValue[6]  = 0.65;
stateSequence[6]  = "Reload";
stateTransitionOnTimeout[6]  = "Ready";
stateWaitForTimeout[6]  = true;
};

function BladeofPlanesImage::onAbortCharge(%this, %obj, %slot)
{
%obj.playthread(2, root);
}

function BladeofPlanesImage::onFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();

%projectile = BladeofPlanes22Projectile;
%spread = 0.0000;

%sound = getRandom(1,3);
switch(%sound)
{
case 1:
            serverPlay3D(BladeofPlanesFire1Sound,%obj.getPosition());
case 2:
            serverPlay3D(BladeofPlanesFire2Sound,%obj.getPosition());
case 3:
            serverPlay3D(BladeofPlanesFire3Sound,%obj.getPosition());
default:
echo("Invalid Sound");
}
%shellcount = 1;
%obj.playThread(2, plant);


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;
}

function BladeofPlanesImage::onMount(%this, %obj, %slot)
{

%obj.hideNode("LHand");
%obj.hideNode("RHand");
%obj.hideNode("LHook");
%obj.hideNode("RHook");
%obj.playThread(0, armreadyboth);
}

function BladeofPlanesImage::onUnMount(%this, %obj, %slot)
{

%obj.unhideNode("LHand");
%obj.unhideNode("RHand");
%obj.playThread(0, root);
}

function BladeofPlanes22Projectile::onExplode(%this,%obj)
{
  %rnd = getRandom(1,3);
  if(%rnd == 1) serverPlay3D(BladeofPlaneloveplosion1Sound,%obj.getTransform());
  if(%rnd == 2) serverPlay3D(BladeofPlaneloveplosion2Sound,%obj.getTransform());
  if(%rnd == 3) serverPlay3D(BladeofPlaneloveplosion3Sound,%obj.getTransform());
  parent::onExplode(%this,%obj);
}

Am I overlooking something crucial?
« Last Edit: March 05, 2013, 09:08:31 PM by Deadzone »


directDamage = 0;?

That's because I was making sure that the radius damage would even do anything. Apparently this has something to do with my issues:
Code: [Select]
function BladeofPlanes22Projectile::onExplode(%this,%obj)
{
  %rnd = getRandom(1,3);
  if(%rnd == 1) serverPlay3D(BladeofPlaneloveplosion1Sound,%obj.getTransform());
  if(%rnd == 2) serverPlay3D(BladeofPlaneloveplosion2Sound,%obj.getTransform());
  if(%rnd == 3) serverPlay3D(BladeofPlaneloveplosion3Sound,%obj.getTransform());
  parent::onExplode(%this,%obj);
}
It's 'cause I don't know what the hell I'm doing, isn't it?
If anyone knows of any lines to add to this so I could keep the random explosion sounds: please speak up.
« Last Edit: March 06, 2013, 10:30:28 AM by Deadzone »

I think direct damage is locked from 0 to 100 in the default implementation. I don't know why. You can overwrite the method for your projectile with one that has the mClamp bit removed, though - information about that can be found here: http://forum.blockland.us/index.php?topic=14090.0