Author Topic: How do I gun  (Read 3855 times)

WHAT IS THIS

HOW DO I READ THIS
DO I NEED SOMETHING

are you looking at a forgetin dts in notepad


dtses are model files and cannot be modified

you can open .cs files in notepad

oh wow im a loving idiot
gonna unlock this if something goes wrong

oh god I got distracted
anyways, I was just wondering
what is this "isBallistic" thing
how do I make the bullet come out in random directions
and how do I make it shoot multiple bullets at once

isballistic means the bullet has an arch iirc

isballistic means the bullet has an arch iirc
Specifies whether the Projectile will be affected by gravity, and whether it can bounce before exploding.
You're basically right though

As for shooting multiple bullets, your weapon needs to have an onFire script with this in it
Code: [Select]
function NAME_OF_WEAPON_IMAGE_DATABLOCK::onFire(%this,%obj,%slot)
{
%obj.playThread(2, shiftAway);

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

You can change the values for %shellcount and %spread for different results

more questions
do I have to put that anywhere in specific or can I just stick it at the bottom?
what would I put in "NAME_OF_WEAPON_IMAGE_DATABLOC K"?
isn't there supposed to be a semicolon at the end of the script you posted and at the end of this:

do I put something at "this.projectile"

do I have to put that anywhere in specific or can I just stick it at the bottom?
They usually go toward the bottom

what would I put in "NAME_OF_WEAPON_IMAGE_DATABLOC K"?
The item's ShapeBaseImageData/image datablock, it looks like this
http://pastebin.com/raw.php?i=jfddYZ84

isn't there supposed to be a semicolon at the end of the script you posted and at the end of this:
functions don't use that, those are usually at the end of datablocks for items and images

And for clarification, the 'ItemData' is the DTS model, and it's properties when it's spawned on a brick, and the 'ShapeBaseImageData' is the DTS model and it's properties for when it's mounted onto either the player, a vehicle, or some other object

do I put something at "this.projectile"
No, the code i provided works in a way that it retrieves the projectile data from the item's image data without having to modify it


Replace gunImage with the datablock name of your weapon image or you'll overwrite the default gun.
Replace
ShapeBaseImageData(gunImage)::onFire(%this,%obj,%slot)
with
yourWeaponImageDatablockName::onFire(%this,%obj,%slot)

Replace gunImage with the datablock name of your weapon image or you'll overwrite the default gun.
Replace
ShapeBaseImageData(gunImage)::onFire(%this,%obj,%slot)
with
yourWeaponImageDatablockName::onFire(%this,%obj,%slot)
I'm confused, what is the "WeaponImage" and why would it overwrite the default gun?

You're basically right though

As for shooting multiple bullets, your weapon needs to have an onFire script with this in it
-snipped-

You can change the values for %shellcount and %spread for different results
Woo time to make a 500 shell machinegun

how do I make the bullet come out in random directions

That is what Masterlegodude said about the multiple bullets thing, it's that spread that changes the spread (go figure).