Author Topic: Akimbo Guns I made will not fire visible projectiles and gun flashes  (Read 1452 times)

I attempted to akimbo-ize one of my pistol I've made and it went well until the part when they wont fire visible projectiles or show the gun flashes nor explosions

Here's the code
Code: [Select]
//AkimboM1911.cs

AddDamageType("AkimboM1911",   '<bitmap:add-ons/Weapon_AkimboM1911/CI_AkimboM1911> %1',    '%2 <bitmap:add-ons/Weapon_AkimboM1911/CI_AkimboM1911> %1',0.2,1);
datablock ProjectileData(AkimboM1911Projectile)
{
   projectileShapeName = "base/data/shapes/bullet.dts";
   directDamage        = 10;
   directDamageType    = $DamageType::AkimboM1911;
   radiusDamageType    = $DamageType::AkimboM1911;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 1;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 2;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse      = 100;
   verticalImpulse   = 100;
   explosion           = AkimboM1911Explosion;
   particleEmitter     = AkimboM1911TrailEmitter;

   muzzleVelocity      = 150;
   velInheritFactor    = 1;

   armingDelay         = 00;
   lifetime            = 4000;
   fadeDelay           = 3500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 2.0;
   lightColor  = ".9 0.3 0";

   uiName = "M1911 Akimbo Bullet";
};

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

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

//gui stuff
uiName = "M1911 Akimbo";
iconName = "./icon_m1911";
doColorShift = false;
colorShiftColor = "1 1 1 1.000";

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

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

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   // 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 = BowItem;
   ammo = " ";
   projectile = AkimboM1911Projectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;

   doColorShift = False;
   colorShiftColor = AkimboM1911Item.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // 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";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.2;
stateSequence[0] = "ready";

stateName[1] = "Ready";
stateSequence[1] = "ready";
stateTransitionOnTriggerDown[1] = "Fire";

stateName[2] = "Fire";
stateSequence[2] = "Fire";
stateTransitionOnTimeout[2] = "Reload";
    stateWaitForTimeout[2] = true;
stateTimeoutValue[2] = 0.25;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateSound[2] = m1911ShotSound;
    stateEmitter[2] = AkimboM1911FlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";

stateName[3] = "Reload";
stateAllowImageChange[3] = false;
stateTransitionOnTriggerUp[3] = "FireAkimboM1911";
stateSequence[3] = "ready";

stateName[4] = "FireAkimboM1911";
stateTimeoutValue[4] = 0.18;
stateScript[4] = "onFireAkimboM1911";
stateTransitionOnTimeOut[4] = "ready";
};


function AkimboM1911Image::onFireAkimboM1911(%this,%obj,%slot)
{
   %obj.setImageTrigger(1,1);
}


datablock ShapeBaseImageData(LeftAkimboM1911Image)
{
   // Basic Item properties
   shapeFile = "./m1911.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 1;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   // 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 = BowItem;
   ammo = " ";
   projectile = AkimboM1911Projectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = false;

   doColorShift = False;
   //colorShiftColor = AkimboGunItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // 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";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.2;
stateSequence[0] = "ready";
   stateSound[0] = weaponSwitchSound;

stateName[1] = "Ready";
stateSequence[1] = "ready";
stateTransitionOnTriggerDown[1] = "Fire";

stateName[2] = "Fire";
stateSequence[2] = "Fire";
stateTransitionOnTimeout[2] = "Reload";
   stateWaitForTimeout[2] = true;
stateTimeoutValue[2] = 0.15;
stateFire[2] = true;
stateAllowImageChange[2] = false;
stateScript[2] = "onFire";
stateSound[2] = m1911ShotSound;
   stateEmitter[2] = AkimboM1911FlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";

stateName[3] = "Reload";
stateAllowImageChange[3] = false;
stateTransitionOnTriggerUp[3] = "Ready";
stateSequence[3] = "ready";


};

function LeftAkimboM1911Image::onFire(%this, %obj, %slot)
{
   Parent::onFire(%this,%obj,%slot);
   if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, leftrecoil);
}

function AkimboM1911Image::onMount(%this, %obj, %slot)
{
   Parent::onMount(%this, %obj, %slot);
   //mount lefthanded gun
   %obj.mountImage(LeftAkimboM1911Image, 1);
   //%obj.playThread(0, armreadyboth);
}
function AkimboM1911Image::onUnMount(%this, %obj, %slot)
{
   Parent::onUnMount(%this, %obj, %slot);
   //unmount lefthanded gun
   %obj.unMountImage(1);
   //%obj.playThread(0, root);
}


function LeftAkimboM1911Image::onMount(%this, %obj, %slot)
{
   Parent::onMount(%this, %obj, %slot);
   %obj.playThread(1, armreadyboth);
}
function LeftAkimboM1911Image::onUnMount(%this, %obj, %slot)
{
   Parent::onUnMount(%this, %obj, %slot);
}

function AkimboM1911Image::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);

   //%obj.setImageTrigger(1,1);
}

yeah it's large

Aw stuff, wrong board.

make sure to move the bullet .dts file and all the textures for the flash to the proper directory.

since im on my 3GS i wont be able to quote properly, so problems are
1. the bullet.dts isnt in the base/data/shapes, thats where you use a invisible projectile like plasma
2. some people making akimbo weapons make some mistakes, for example
some of the datablocks are wrongly named as a result of CTRL + Fing without knowing they missed out something
ok to get to the errors, here it is
projectileShapeName should be "add-ons/weapon_gun/bullet.dts" if you do not have a custom bullet model for the gun
explosion = AkimboM1911Explosion; should be M1911Explosion if you are not making fancy balanced weapons for your akimbo variant, same thing for particleEmitter

all of the errors should be pointed out by now, also you dont need to leave //AkimboM1911.cs there unless you want to show off your scripting skills