Author Topic: Problems with making Add-on.  (Read 1064 times)

I was making an AK-47 when I exported the DTS, It works fine and looks awesome for a second model but it sorta doesn't work.. Well I can enable the add-on, But doesn't show up as a spawn-able weapon.

Quote
//AK-47.cs
datablock AudioProfile(AK-47shot1Sound)
{
   filename    = ".Sounds/AK-471.wav";
   description = AudioClosest3d;
   preload = true;
};

AddDamageType("AK-47",   '<bitmap:add-ons/Weapon_AK-47/CI_AK-47> %1',    '%2 <bitmap:add-ons/Weapon_AK-47/CI_AK-47> %1',0.05,1);
datablock ProjectileData(AK-47Projectile)
{
   projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
   directDamage        = 31;
   directDamageType    = $DamageType::AK-47;
   radiusDamageType    = $DamageType::AK-47;

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

   impactImpulse       = 0;
   verticalImpulse     = 0;
   explosion           = gunExplosion;
   particleEmitter     = "";

   muzzleVelocity      = 200;
   velInheritFactor    = 0.5;

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

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

   uiName = "AK-47 Bullet";
};

//////////
// item //
//////////
datablock ItemData(AK-47Item)
{
   category = "Weapon";  // Mission editor category
   className = "Weapon"; // For inventory system

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

   //gui stuff
   uiName = "AK-47;
   iconName = "./Icon_AK-47";
   doColorShift = true;
   colorShiftColor = "0.25 0.25 0.25 1.000";

    // Dynamic properties defined by the scripts
   image = AK-47Image;
   canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(AK-47Image)
{
   // Basic Item properties
   shapeFile = ".Models/AK47.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 = AK-47Projectile;
   projectileType = Projectile;

   casing = gunShellDebris;
   shellExitDir        = "1.0 -1.3 1.0";
   shellExitOffset     = "0 0 0";
   shellExitVariance   = 15.0;   
   shellVelocity       = 7.0;

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

   doColorShift = true;
   colorShiftColor = AK-47Item.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";
   stateEjectShell[2]      = true;
   stateSequence[2]      = "Fire";
   stateTransitionOnTimeout[2]   = "reload";
   stateWaitForTimeout[2]       = true;
   stateTimeoutValue[2]       = 0.04;
   stateFire[2]          = true;
   stateAllowImageChange[2]    = false;
   stateScript[2]          = "onFire";
   stateSound[2]          = AK-47Shot1Sound;
   stateEmitter[2]          = gunFlashEmitter;
   stateEmitterTime[2]       = 0.05;
   stateEmitterNode[2]       = "muzzleNode";

   stateName[3]         = "Fire2";
   stateEjectShell[3]      = true;
   stateSequence[3]      = "Fire2";
   stateTransitionOnTimeout[3]   = "reload";
   stateWaitForTimeout[3]       = true;
   stateTimeoutValue[3]       = 0.02;
   stateFire[3]          = true;
   stateAllowImageChange[3]    = false;
   stateScript[3]          = "onFire2";
   stateSound[3]          = AK-47Shot1Sound;
   stateEmitter[3]          = gunFlashEmitter;
   stateEmitterTime[3]       = 0.05;
   stateEmitterNode[3]       = "muzzleNode";

   stateName[4]         = "Reload";
   stateTimeoutValue[4]      = 0.04;
   stateTransitionOnTriggerUp[4] = "ready";
   stateTransitionOnTimeout[4]   = "Fire2";
};

};

function AK-47Image::onMount(%this, %obj, %slot)  //change M4A1 to whatever you want
{   
   %obj.hidenode("RHand");
        %obj.hidenode("LHand");
}


function AK-47Image::onUnMount(%this, %obj, %slot) //change M4A1 to whatever you want
{   
   %obj.unhidenode("RHand");
        %obj.unhidenode("LHand");
}

function AK-47Image::onFire(%this,%obj,%slot)
{


   %projectile = %this.projectile;
   %spread = 0.0010;
   %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;
}

function AK-47Image::onFire2(%this,%obj,%slot)
{
   %projectile = %this.projectile;
   %spread = 0.0014;
   %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;
}

function AK-47Image::onFire3(%this,%obj,%slot)
{
   if(%obj.getDamagePercent() < 1.0)
      %obj.playThread(2, shiftAway);
   Parent::onFire(%this,%obj,%slot);   
}

This is the code. Is there something wrong?


I was making an AK-47 when I exported the DTS, It works fine and looks awesome for a second model but it sorta doesn't work.. Well I can enable the add-on, But doesn't show up as a spawn-able weapon.

This is the code. Is there something wrong?
Snip
I'm no coder, but I'm pretty sure that after the //GUI stuff comment, the uiname needs to be uiName = "AK-47"; rather than uiName = "AK-47;

I'm no coder, but I'm pretty sure that after the //GUI stuff comment, the uiname needs to be uiName = "AK-47"; rather than uiName = "AK-47;

Sadly doesn't solve the problem.



oh yea, item should refer to the item datablock you made so item should be "AK-47Item"