Skip to content
cxong edited this page Sep 21, 2014 · 12 revisions

C-Dogs SDL lets you create custom weapons for campaigns and dogfights. You can do this by defining your own guns and bullets, and optionally providing your own graphics and sounds. All the weapons in C-Dogs are implemented using the same system!

There are two key concepts: guns fire bullets, and bullets travel and hit things. But did you know that bullets can also fire guns? This is how grenades work: when the grenade "bullets" reach the end of their range, they "fire" an "explosion gun", which in turn fires "explosion fireballs". Of course it doesn't have to end there...

Reference

Here's a big list of properties that you can set for guns and bullets:

guns.json

  • Pic (string): what the player will hold. Values: "blaster", "knife", or "".
  • Name (string): what the gun will be called, in menus and in the HUD. Must be unique!
  • Bullet (string): the name of the bullet that the gun will fire. Check out /data/bullets.json, or if you're using custom bullets, make sure to provide one with this name in your bullets.json.
  • Cost (integer): how much the gun costs to fire, in terms of score. Most guns in C-Dogs costs score to fire.
  • Lock (integer): rate of fire, in terms of the number of game ticks between each bullet fired. The number of ticks per second is 70, so a lock of 70 is one shot per second, 7 is 10 shots per second.
  • ReloadLead (integer): when the reload sound is played, ahead of when the gun is able to be fired again, in terms of game ticks. For guns that take a long time to reload, it's a good idea to add a reload sound to let the player know when they can fire again. It's best to have the sound play a little before the gun is actually ready, hence this parameter. Great for shotguns, rifles etc.
  • Sound (string): what sound this gun makes when fired. Must be a sound that is in /sounds, or provide your own in your /sounds folder. Skip the extension!
  • ReloadSound (string): what sound to play when this gun becomes ready to fire. If you want to play the sound before the gun is ready, set a value for ReloadLead.
  • SoundLockLength (integer): time between the gun making its sounds, in game ticks. Sometimes you want to have a rapid-fire gun but it would sound awful if it made a sound every shot! Set a SoundLockLength value to space out the firing sounds. Great for flamers, or anything that fires a continuous stream.
  • Recoil (float): the random spread of the bullets, in radians.
  • SpreadCount (integer): for guns that fire a spread of bullets, how many bullets to fire. Great for shotguns.
  • SpreadWidth (float): the angle between each bullet in a spread, in radians.
  • AngleOffset (float): normally guns fire bullets in whatever direction the player is facing; if you want to fire slightly to the left or right, use a value for this (in radians). Mainly used for explosions, to slightly rotate the spread pattern.
  • MuzzleHeight (integer): how high the bullet will be fired at. Default is 10, which matches the gun the player is holding. If you want a bullet to come out at the player's feet (think dynamites, mines), use 0.
  • Elevation, or ElevationLow and ElevationHigh (integer): whether the bullet will be fired at an angle up or down. Positive means the bullet will travel upwards. Values are in 1/16th pixels. You can either use a single Elevation value, or provide both ElevationLow and ElevationHigh - the game will randomly choose values within that range every time the gun fires. Great for explosions and grenades when coupled with the bullet's Falling property. Note: C-Dogs is a 2D game and bullet height has no effect on whether it will hit or not, it's mostly cosmetic! (but it does affect when the bullet hits the ground...)
  • MuzzleFlashParticle (string): the name of the particle that represents the muzzle flash. The particle must already exist in /data/particles.json, or provide your own in your particles.json. See particles.json for more details.
  • Brass (string): the name of the particle that represents ejected casings / brass. These are small particles that fly out from the side of the gun, and typically land on the ground. Great for machine guns!
  • CanShoot (boolean): whether you can fire this gun. "How can you possibly not fire a gun???" the answer is: the knife. This is only used for the knife.
  • ShakeAmount (integer): when the gun is fired, how much the screen will shake. Don't over-do this! Great for explosions, or very big guns.

Sample

The techdemo/funwithguns.cdogscpn campaign contains several custom weapons, including custom graphics and sound. You can use it as a handy template.