Author Topic: Multipile projectiles help.  (Read 443 times)

I'm trying to give a weapon the ability to fire (basically buckshot), I need help editing the code to give it that ability.

Below is the full code, (Yes I know it's nekram's I'm just improving it for personal use)

Code: [Select]
AddDamageType("ww2_Ithaca37",   '<bitmap:add-ons/weapon_9a91/ci> %1',    '%2 <bitmap:add-ons/Weapon_9a91/ci> %1',0.2,1);
datablock ProjectileData(ww2_Ithaca37Projectile)
{
   projectileShapeName = "add-ons/weapon_gun/bullet.dts";
   directDamage        = 18;
   directDamageType    = $DamageType::ww2_Ithaca37;
   radiusDamageType    = $DamageType::ww2_Ithaca37;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;         
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 1;         
   brickExplosionMaxVolumeFloating = 2; 

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

   muzzleVelocity      = 200;
   velInheritFactor    = 1;

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

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

datablock ItemData(ww2_Ithaca37Item)
{
category = "Weapon";
className = "Weapon";

shapeFile = "./models/Ithaca37.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

uiName = "Ithaca 37";
iconName = "./Icon";
doColorShift = false;
colorShiftColor = "1.00 1.00 1.00 1.000";

image = ww2_Ithaca37Image;
canDrop = true;
};

datablock ShapeBaseImageData(ww2_Ithaca37Image)
{
   shapeFile = "./models/Ithaca37.dts";
   emap = true;
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0;
   rotation = eulerToMatrix( "0 0 0" );
   correctMuzzleVector = true;
   className = "WeaponImage";
   item = BowItem;
   ammo = " ";
   projectile = ww2_Ithaca37Projectile;
   projectileType = Projectile;

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

   melee = false;
   armReady = true;

   doColorShift = false;
   colorShiftColor = ww2_Ithaca37Item.colorShiftColor;

stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

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

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = WW2muzzleFireEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = ShotgunFireSound;

stateName[3] = "Smoke";
stateSequence[3] = "Reload";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.7;
stateEjectShell[3]       = true;
stateSound[3] = ShotgunroosterSound;
stateTransitionOnTimeout[3]     = "Reload";

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

};

function Ithaca37Image::onFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();
     
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-3")));
%obj.playThread(2, plant);

%projectile = %this.projectile;
%spread = 0.0015;
%shellcount = 3;

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


datablock ShapeBaseImageData(ww2_Ithaca37Image2)
{
shapeFile = "./models/Ithaca37.dts";
   emap = true;
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = "0.000001 +0.100001 -0.000001";
   rotation = "";
   correctMuzzleVector = true;
   className = "WeaponImage";
   item = BowItem;
   ammo = " ";
   projectile = ww2_Ithaca37Projectile;
   projectileType = Projectile;
casing = WW2ShotgunShellDebris;
shellExitDir        = "1.0 -1.3 1.0";
shellExitOffset     = "0 0 0";
shellExitVariance   = 15.0;
shellVelocity       = 7.0;

   melee = true;
   armReady = true;

   doColorShift = false;
   colorShiftColor = ww2_Ithaca37Item.colorShiftColor;

stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

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

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = WW2muzzleFireEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = ShotgunFireSound;

stateName[3] = "Smoke";
stateSequence[3] = "Reload";
stateEmitter[3] = gunSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.7;
stateEjectShell[3]       = true;
stateSound[3] = ShotgunroosterSound;
stateTransitionOnTimeout[3]     = "Reload";

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

};

function Ithaca37Image2::onFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();
     
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-3")));
%obj.playThread(2, plant);

%projectile = %this.projectile;
%spread = 0.0015;
%shellcount = 3;

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

package ww2_Ithaca37imageSwitch
{
function Armor::onTrigger(%this,%obj,%slot,%val)
{
Parent::onTrigger(%this,%obj,%slot,%val);
if(%slot == 4 && %val)
{
if(%obj.getMountedImage(0) == ww2_Ithaca37Image.getID())
{
%obj.updateArm(ww2_Ithaca37Image2);
%obj.mountImage(ww2_Ithaca37Image2,0);
}
else if(%obj.getMountedImage(0) == ww2_Ithaca37Image2.getID())
{
%obj.updateArm(ww2_Ithaca37Image2);
%obj.mountImage(ww2_Ithaca37Image,0);
}
}
}
};
activatePackage(ww2_Ithaca37imageSwitch);




So where do I need to put what?


http://forum.blockland.us/index.php?topic=73981.0
look at the code on a shotgun

I have the old Sawed-Off that someone made... I'm looking for the piece of the code in specific where that funtion would be located.

Also I couldn't seem to find that shotgun... Thanks...

Nevermind, Found another topic that has it. Locking....
« Last Edit: July 31, 2013, 11:53:09 PM by Romulus of the sky »