Author Topic: Weapon Problems.  (Read 960 times)

Ok so i've been makeing Throwing Knife.
I have custom animations. That dont work because of the script.
And my alternate fire dosent work.

Code:
Code: [Select]
//projectile
AddDamageType("ThrowingKnifeDirect",   '<bitmap:add-ons/Weapon_ThrowingKnife/CI_ThrowingKnife> %1',       '%2 <bitmap:add-ons/Weapon_ThrowingKnife/CI_ThrowingKnife> %1',1,1);
datablock ProjectileData(ThrowingKnifeProjectile)
{
   projectileShapeName = "./ThrowingKnifeProjectile.dts";
   directDamage        = 75;
   directDamageType  = $DamageType::ThrowingKnifeDirect;
   radiusDamageType  = $DamageType::ThrowingKnifeRadius;
   impactImpulse   = 000;
   verticalImpulse   = 000;
   explosion           = ThrowingKnifeExplosion;
   particleEmitter     = ThrowingKnifeTrailEmitter;

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

   muzzleVelocity      = 50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 20000;
   fadeDelay           = 19500;
   bounceElasticity    = 0.2;
   bounceFriction      = 0.2;
   isBallistic         = true;
   gravityMod = 0.50;

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

   uiName = "ThrowingKnifeProjectile";
};

//projectile
AddDamageType("ThrowingKnife",   '<bitmap:add-ons/Weapon_ThrowingKnife/CI_ThrowingKnife> %1',    '%2 <bitmap:add-ons/Weapon_ThrowingKnife/CI_ThrowingKnife> %1',0.75,1);
datablock ProjectileData(ThrowingKnifeProjectile2)
{
   directDamage        = 35;
   directDamageType  = $DamageType::ThrowingKnife;
   radiusDamageType  = $DamageType::ThrowingKnife;
   explosion           = ThrowingKnifeExplosion;
   //particleEmitter     = as;

   muzzleVelocity      = 50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 100;
   fadeDelay           = 70;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;

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

   uiName = "ThrowingKnifeProjectile2";
};

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

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

//gui stuff
uiName = "Throwing Knife";
iconName = "";
doColorShift = true;
colorShiftColor = "0.400 0.196 0 1.000";

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

//function ThrowingKnife::onUse(%this,%user)
//{
// //mount the image in the right hand slot
// %user.mountimage(%this.image, $RightHandSlot);
//}

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(ThrowingKnifeImage)
{
   // Basic Item properties
   shapeFile = "./ThrowingKnife.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.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 = ThrowingKnifeItem;
   ammo = " ";
   projectile = ThrowingKnifeProjectile;
   projectileType = Projectile;

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

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

stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "ready";
stateAllowImageChange[1] = true;

stateName[2]                    = "Charge";
stateTransitionOnTimeout[2] = "Hold";
stateTimeoutValue[2]            = 0.7;
stateWaitForTimeout[2] = false;
stateTransitionOnTriggerUp[2] = "AbortCharge";
stateScript[2]                  = "onCharge";
stateAllowImageChange[2]        = false;

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

stateName[4] = "Charge";
stateTransitionOnTriggerUp[4] = "Throw";
stateAllowImageChange[4] = false;

stateName[5] = "Fire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.5;
stateFire[5] = true;
stateSequence[5] = "fire";
stateScript[5] = "onFire";
stateWaitForTimeout[5] = true;
stateAllowImageChange[5] = false;
stateSound[5] = ThrowingKnifeFireSound;
};

function ThrowingKnifeImage::onCharge(%this, %obj, %slot)
{
%obj.playthread(0, Hold);
}

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

function ThrowingKnifeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(0, Throw);
Parent::onFire(%this, %obj, %slot);
}

function ThrowingknifeImage::onMount(%this, %obj, %slot)
{
%obj.hidenode("RHand");
}


function ThrowingknifeImage::onUnMount(%this, %obj, %slot)
{
%obj.unhidenode("RHand");
%obj.playThread(0, root);
}

datablock ShapeBaseImageData(ThrowingKnife2Image)
{
   // Basic Item properties
   shapeFile = "./ThrowingKnife.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 = ThrowingKnifeItem;
   ammo = " ";
   projectile = ThrowingKnifeProjectile2;
   projectileType = Projectile;



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

   doColorShift = false;

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

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

stateName[2]                    = "attack";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateSound[2] = ThrowingKnifeSwingSound;

stateName[3] = "Smoke";
stateTimeoutValue[3]            = 1.0;
stateTransitionOnTimeout[3]     = "Reload";

stateName[4] = "Reload";
stateSequence[4]                = "Reload";
stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "Ready";

};

function ThrowingKnife2Image2::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(0, attack);
Parent::onFire(%this,%obj,%slot);
}



function ThrowingKnifeImage2::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(0, attack);
Parent::onFire(%this,%obj,%slot);
}

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

function ThrowingknifeImage2::onMount(%this, %obj, %slot)
{
%obj.hidenode("RHand");
}


function ThrowingknifeImage2::onUnMount(%this, %obj, %slot)
{
%obj.unhidenode("RHand");
}

package ThrowingKnife
{
function servercmdlight(%client)
{
if(%client.player.getMountedImage(0) $= ThrowingKnifeImage2.getID())
{
 %client.player.mountImage(ThrowingKnifeImage2,0);
}    

else if(%client.player.getMountedImage(0) $= ThrowingKnifeImage2.getID())
{
 %client.player.mountImage(ThrowingKnifeImage2,0);
}
else
{
 Parent::servercmdlight(%client);
}
}
   function Armor::onTrigger(%this, %player, %slot, %val)
{
if(%player.getMountedImage(0) $= ThrowingKnifeImage2.getID() && %slot $= 4 && %val)
{
if(%player.lastNade !$= "" && getSimTime() - %player.lastNade < 3000)
{
return;
}
%projectile = ThrowingKnifeProjectile2;
%vector = %player.getMuzzleVector(0);
%objectVelocity = %player.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %player.getMuzzlePoint(0);
sourceObject = %player;
sourceSlot = 0;
client = %player.client;
};
%player.lastNade = getSimTime();
serverPlay3D(ThrowingKnifeFireSound,%player.getPosition());
MissionCleanup.add(%p);
return %p;

}
else if(%player.getMountedImage(0) $= ThrowingKnifeImage2.getID() && %slot $= 4 && %val)
{
if(%player.lastNade !$= "" && getSimTime() - %player.lastNade < 3000)
{
return;
}
%projectile = ThrowingKnifeProjectile2;
%vector = %player.getMuzzleVector(0);
%objectVelocity = %player.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %player.getMuzzlePoint(0);
sourceObject = %player;
sourceSlot = 0;
client = %player.client;
};
%player.lastNade = getSimTime();
serverPlay3D(ThrowingKnifeFireSound,%player.getPosition());
MissionCleanup.add(%p);
return %p;

}
Parent::onTrigger(%this, %player, %slot, %val);
}
};
ActivatePackage(ThrowingKnife);
« Last Edit: February 19, 2010, 05:55:33 PM by aware14 »

Please help if you know how.

I don't know this, but why do you have 2 projectiles with the same name?


Still dosent work and fixed.



Code: [Select]
function servercmdlight(%client)If I recall correctly, that reacts to typing /light, not pressing the light key.

Code: [Select]
function servercmdlight(%client)If I recall correctly, that reacts to typing /light, not pressing the light key.

I need help with animations.
And i know im not a handicap.

If I recall correctly, that reacts to typing /light, not pressing the light key.
It is triggered by both. Pressing the light key is virtually the same as typing /light.

Code: [Select]
if(%client.player.getMountedImage(0) $= ThrowingKnifeImage2.getID())
{
%client.player.mountImage(ThrowingKnifeImage2,0);
}     
else if(%client.player.getMountedImage(0) $= ThrowingKnifeImage2.getID())
{
%client.player.mountImage(ThrowingKnifeImage2,0);
}
Should those conditions and results be different? Basically, it's going:
If we're holding the second form of the throwing knife, equip the second form of the throwing knife. On the other hand, if we aren't holding the throwing knife, check to see if we're holding the second form of the throwing knife. If so, equip the second form of the throwing knife.

Also, why do you need to modify armor::ontrigger to insert an altfire if you're just going to use the light to swap between firing modes?

I dont have a way to make an alt fire...
Im not the best at scripting. :C



I have the same animation problems..... they never work