Making a gun shoot Objects

Ask questions, discuss ideas, get answers
Post Reply
Deadeye
Posts: 17
Joined: Sat Mar 06, 2010 3:49 am

Making a gun shoot Objects

Post by Deadeye »

Hey guys i need a ssm to make a gun such as the DP to shoot objects like the Defgun.
the code i used is:
ObjectTemplate.Active DP
ObjectTemplate.projectileTemplate Defgun

I want the gun to spawn a defgun with every bullet.But the code crashes the server when i click.

i want a gun that can do this:
Image
tanelorn
Posts: 42
Joined: Thu Oct 14, 2010 6:19 pm

Re: Making a gun shoot Objects

Post by tanelorn »

You must use a standard projectile with a firearm. However, there are a couple options that allow you to use a firearm to do this:

1. In the projectile code, attach a PCO (player occupiable object) to it. You can put spawners on the PCO. Review the game code to find PCOs (all vehicles are PCOs), and review the map spawning code for correct syntax for spawners.

2. You can make the firing effect (like the muzzle effect of the DP) throw out a bundle object. Bundle objects are alot like PCOs but lack some characteristics (such as, they can't be occupied). But you can attach spawners to them also (At least I think you can). This approach is for those who are familiar with effects coding and know what an emitter is.

If you're fresh to coding, then you'll have to spend alot of time becoming familiar with all of this stuff. If you're an experienced coder, then the above is enough for you to succeed.
Tanelorn-Desert Combat Realism mod lead
DCR Website: http://www.tanelorn.us/dcr/pages/index.htm
DCR AI development: http://www.battlefieldsingleplayer.com/ ... opic=15529
DCR new features: http://bfmods.com/viewtopic.php?f=6&t=727
Deadeye
Posts: 17
Joined: Sat Mar 06, 2010 3:49 am

Re: Making a gun shoot Objects

Post by Deadeye »

Thanks, But i am very new to modding i would rather like a code to spawn them like i used this code:
ObjectTemplate.Active Type99
ObjectTemplate.addFireArmsPosition 0/0/0 0/0/0
ObjectTemplate.velocity 100

ObjectTemplate.Active barProjectile
ObjectTemplate.timeToLive CRD_NONE/0/0/0
ObjectTemplate.addTemplate ArtillerySpawner
ObjectTemplate.SetPosition 0/0/0

but when i fire the gun the defgun spawns above the soldier and little forward i want to make it shoot an object that you cannot get in, and that it appears level and in the middle of the screen, i also would like it to never dissapear. Sorry for being so picky :( i just am not good at modding and need to learn. Thanks
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Post by freddy »

change value on FireArmsPosition 0/0/0 0/0/0

a guess 0/0/25 0/0/0 but try your way forward

or even better change SetPosition of spawner instead

Code: Select all

ObjectTemplate.addTemplate ArtillerySpawner
ObjectTemplate.SetPosition 0/0/0  <------   0/0/25  
Deadeye
Posts: 17
Joined: Sat Mar 06, 2010 3:49 am

Re: Making a gun shoot Objects

Post by Deadeye »

Ok i tried that, it worked, but when i shoot they only survive for 1 second then blow up i want them to never disappear. I have tried speedMod 0 and Time to live 999 none of them seems to work
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Post by freddy »

Deadeye wrote: they only survive for 1 second then blow up
does this happen if you only "shoot" out one defgun to?
Deadeye
Posts: 17
Joined: Sat Mar 06, 2010 3:49 am

Re: Making a gun shoot Objects

Post by Deadeye »

yea, but maybe it is spawning 2 per bullet, i put the code on a knife and it spawned 2 jeeps in one click.
Post Reply