How to Create Weapons and Ammo in FAKK2
Last Updated: September 16, 2000
This document
explains how to create weapons and ammo in FAKK2. Here’s a quick summary of the steps needed to be done:
·
Create a
weapon model (i.e. crossbow.tik)
·
Create a
projectile model (i.e. crossbow_fx3.tik) if the weapon shoots projectiles
·
Create an
explosion model (I.e. crossbow_impact.tik) if the projectile will explode.
·
Create an ammo
pickup model (I.e. ammo_bolt.tik) if you want the player to pick up ammo for
the weapon (The ammo commands are listed after the weapon commands below).
·
Add new states
to the player state files so that the player can ready, putaway and fire the
weapon. Make sure that the animations
you use in the state file are defined in the player .tik file.
·
Add the
appropriate server commands to the player for the firing/putaway/ready
animations.
If the weapon
is a dual handed weapon (2handed), you may specify an alternate firing mode for
the weapon. The properties of the
alternate firing mode can be specified by prefixing the command with the
keyword “alternate”.
In the INIT
section create a server section and put in the commands needed to describe this
weapon. Here is a list of server INIT
commands that are used for weapons.
Server INIT General Weapon Commands
classname <name> |
The
classname of the weapon. It will be
used later when checking which animation to play when firing, readying,
putting away etc…(This is an internallly used name) |
name <name> |
The name of
the weapon that will appear on the HUD |
[alternate]
firetype <projectile | bullet> |
Specifies
what type of weapon this is. ‘bullet’
is a hitscan weapon. A projectile
weapon launches a model out of the barrel. |
[alternate]
firingrate <time> |
Specifies a
time in seconds that the weapon must “wait” before it can be fired again. |
hand <left | right | dual
| any > |
Specifies
which hand the weapon may be used in.
Dual is for 2 handed weapons.
Any is used for weapons that may be wielded in either hand. |
[alternate]
clipsize <value> |
Specifies
the amount of ammo that is held in one clip.
Default is 0. |
[alternate]
ammotype <name> |
Specifies
the name of the type of ammo this weapon uses. |
[alternate]
startammo <amount> |
Specifies
the amount of ammo this weapon has when it is picked up |
[alternate]
ammorequired <amount> |
The amount
of ammo this weapon requires to be fired. Default is 1. |
[alternate]
maxchargetime <time> |
Set the
maximum amount of time for this weapon to charge up. This is for weapons which require the
attack button to be held down in order to charge them |
Server INIT Commands used for Projectile Weapon Models
[alternate]
projectile <model> |
Specifies
the name of the model to use as a projectile. |
Server INIT Commands used for Bullet
Weapon Model
[alternate]
bulletdamage <value> |
Set the
damage that a single bullet will do when it hits an entity |
[alternate]
bulletknockback <value> |
Set the
amount of knockback that will get applied when a bullet hits an entity |
[alternate]
bulletcount <value> |
Set the
number of bullets that are traced when a weapon is shot |
[alternate]
bulletrange <value> |
Set the
maximum range a bullet can travel |
[alternate]
bulletspread <spreadx> <spready> |
Set the
amount of spread in the x and y directions.
These are float values which specify the maxamount of deviation from
the center. |
If the weapon is a projectile based weapon, when it is fired it will spawn a
projectile using the specified model.
This projectile model has special commands that define it’s properties. Here’s a list of commands that are used in
the INIT section of the TIKI file.
Server INIT Commands Used for
Projectile Models
speed <floatvalue> |
Set the
speed of the projectile |
minspeed
<speed> |
Set the
minimum speed for this projectile.
This is used for charge up weapons, so that they have at least a
minimum amount of speed if the player just taps the fire button and basically
gives it no charge. |
chargespeed |
Sets the
projectile so that the speed of the projectile is directly related to the
amount that the charge time is held. |
hitdamage <floatvalue> |
Set the
damage a projectile causes when it directly hits an entity |
radiusdamage <floatvalue> |
Set the
damage caused when a projectile “explodes” near an entity. The dropoff of damage from the center of
the explosion is linear. |
life <seconds> |
Set the life
of a projectile. It will explode
automatically when the life expires |
minlife <seconds> |
Sets the min
life of a projectile. This is used
for charge up weapons, so that the projectile has a minimum value of life if
the player just taps the fire button. |
chargelife |
Sets the
projectile so that the life of the projectile is directly related to the
amount that the charge time is held. |
knockback <floatvalue> |
Set the
knockback that is caused when the projectile does damage to an entity |
gravity <floatvalue> |
Set the
gravity on the projectile. This can
be used to simulate lobbed weapons |
dlight <r> <g> <b>
<intensity> |
Set the
projectile to be a dlight. r,g,b are
the color components. intensity is
the brightness of the light (radius).
The color values range from 0 to 1.0 and the intensity is a float
value. |
avelocity [crandom|random]
<yaw> [crandom|random] <pitch> [crandom|random]
<roll> |
Set the
angular velocity of the projectile.
If random is specifed the value will range from 0 to value. If
crandom is specified the value will range from –value to value. |
meansofdeath <string> |
Set the
means of death of the weapon. This is
used for death messages. If you want
to see a list of the means of death types.
Type the showmeansofdeath command at the console. |
beam <cmdlist….> |
Creates a
beam that is drawn from the barrel to the projectile. The cmdlist is any valid beam command. |
bouncetouch |
Causes the
projectile to bounce when it hits a solid.
Also changes the physics model to MOVETYPE_BOUNCE. |
bouncesound <soundname> |
Set the name
of a sound to be played when the projectile bounces. |
explosionmodel
<modelname> |
Set the
model that the explosion will use |
Weapons use
the “fire” animation to determine when to fire. The command used is called “shoot” and is described below.
Server Animation Commands for Weapon
Models
shoot |
Signals the
game code on the server to fire the weapon. |
Projectiles
also have some specific animation based commands that are used to cause
damage. When a projectile strikes a solid
(world or entity) and it’s not a bouncy projectile (see above) it will
explode. This will execute the
“explode” animation specified in the TIKI file. In order to cause damage to stuff near the explosion use these
commands.
Server Animation Commands for
Projectile Models
|
|
The explosion
command is a normal TIKI file. It can
have all of the normal commands of any TIKI.
Here are the special commands that are used in the INIT section for
explosion models to cause damage to entities.
INIT Commands for Explosion Models
radiusdamage <floatvalue> |
Sets the
amount of damage caused by this explosion. |
Here is the
list of commands that are used in the Ammo TIKI files. This model represents pickupable ammo for
the player.
INIT Command for Ammo Models
classname AmmoEntity |
This is a
required command and it must be exactly as specified. It tells the game that this model is ammo. |
name <string> |
Set the name
of the Ammo. This should match
exactly with the name that is specified with the ammotype command used
in the weapon. |
amount <integer> |
Set the
amount of ammo that will be given to the player when they pick it up. |
Addition of States to the Player
Statefile
Here’s a
snippet of the player’s state file that deals with weapons (readying, firing,
putting away, and charging up) with some description of how it works (the
actual commands are in bold):
The RAISE_WEAPON
checks to see if a new weapon has been readied by the player and plays the correct animation based on which
weapon is being readied. The IS_NEW_WEAPON command takes 2
parameters. The first parameter is the
hand which it is checking for a new
weapon, and the 2nd parameter is the name of the weapon.
state RAISE_WEAPON
{
torso
{
raise_right_from_holster : IS_NEW_WEAPON
"dualhand" "2HandedWeapon"
raise_left_from_holster : IS_NEW_WEAPON "lefthand"
"Crossbow"
raise_right_from_holster : IS_NEW_WEAPON
"righthand" "Crossbow"
raise_sword_right : IS_NEW_WEAPON "righthand"
"Sword"
raise_sword_right : IS_NEW_WEAPON "righthand"
"TestWeap"
}
states
{
STAND : ANIMDONE_TORSO
}
}
The CHECK
ATTACK LEFT state checks to see which weapon to has been fired and will
call the ATTACK_LEFT state if any of the conditions specified are true. The IS_WEAPON_ACTIVE condition uses 2
parameters. The first parameter is the
hand parameter which can be “lefthand”, “righthand”, or “dualhand”. The 2nd parameter is the name of
the weapon that is in the hand.
state
CHECK_ATTACK_LEFT
{
states
{
ATTACK_LEFT : IS_WEAPON_ACTIVE
"dualhand" "2HandedWeapon"
ATTACK_LEFT : IS_WEAPON_ACTIVE
"lefthand" "Crossbow"
ATTACK_LEFT : IS_WEAPON_ACTIVE
"lefthand" "TestWeap"
STAND : !ATTACKLEFT
}
}
The ATTACK_LEFT
state checks to see which weapon is being fired and plays the appropriate
animation.
state ATTACK_LEFT
{
torso
{
twohanded_primary_fire :
IS_WEAPON_ACTIVE "dualhand" "2HandedWeapon"
left_fire_crossbow : IS_WEAPON_ACTIVE "lefthand"
"Crossbow"
left_fire_crossbow : IS_WEAPON_ACTIVE "lefthand"
"TestWeap"
left_fire_crossbow : default
}
states
{
STAND : ANIMDONE_TORSO !ATTACKLEFT
}
}
The PUTAWAY_LEFT
state checks to see what animation to play based on what weapon is being put
away.
state PUTAWAY_LEFT
{
torso
{
lower_left_to_holster : IS_WEAPON_ACTIVE
"lefthand" "Crossbow"
lower_sword_left : default
}
states
{
STAND : ANIMDONE_TORSO
}
}
Here is a listing
of the states that are used to create charged up weapons:
In the STAND
state, there is a condition which checks for the left attack button to be
pressed and the appropriate charge weapon in the left hand. If both of these are true, it jumps to the START_CHARGE_ATTACK_LEFT
state
START_CHARGE_ATTACK_LEFT : ATTACKLEFT IS_WEAPON_ACTIVE
"lefthand" "Sling"
In the START_CHARGE_ATTACK_LEFT
state, the “left_charge_sling” animation is being played in a loop until the
left attack button is released and the animation has finished playing. This is the charge up animation and the
commands in the TIKI file tell the game to begin the charging of the weapon
state
START_CHARGE_ATTACK_LEFT
{
torso
{
left_charge_sling : IS_WEAPON_ACTIVE
"lefthand" "Sling"
}
states
{
RELEASE_ATTACK_LEFT : !ATTACKLEFT ANIMDONE_TORSO
}
}
In the RELEASE_ATTACK_LEFT
state, the left_release_attack_sling animation is played. This animation has the releasefire command
which results in the actual firing of the active weapon and goes back to the STAND
state upon completion.
state
RELEASE_ATTACK_LEFT
{
torso
{
left_release_attack_sling :
IS_WEAPON_ACTIVE "lefthand" "Sling"
}
states
{
STAND : ANIMDONE_TORSO
}
}
Player Animation Commands for Weapons
Here are the
animation commands used by the player to utilize the weapons:
activatenewweapon |
Activates
the new weapon that is being readied.
This command must be used to activate a weapon that is being
raised. |
deactivateweapon
<hand> |
Deactivates
the weapon in the specified hand.
This must be issued after a weapon has been putaway. |
charge <hand> |
Starts the
charging of the weapon in the specified hand. This is for weapons that charge up and then are released |
fire <hand> |
Fire the
weapon in the specified hand. Hand
can be lefthand, righthand, or dualhand. |
releasefire
<hand> |
Fires the
weapon in the specified hand by releasing it. This is used for weapons which are charged up and then
released. |
Here are some
examples of the command in use:
The
raise_sword_right animation is played when the player readies the sword in the
left hand. The notable command in this
animation is the “Activatenewweapon”.
This is needed for the activation of the new weapon so it may be fired.
raise_sword_right stand_draw_sword.ska
{
server
{
5 activatenewweapon
5 surface sword +nodraw
}
client
{
5 sound $juliedir$/swordout1a.wav 1
.3
}
}
The right fire
crossbow animation is played when the crossbow is fired from the right
hand. The notable command is the “fire”
command which occurs on the first frame.
The first parameter specifies to
the player which hand weapon to fire.
right_fire_crossbow crossbow_right_fire.ska
{
server
{
first fire righthand
}
}
The
lower_sword_left animation is played when the player puts away the sword
weapon. The notable command is the
“deactivateweapon” command which signals the game to deactivate the weapon in the lefthand.
lower_sword_left stand_draw_weapon_left.ska
{
server
{
5 deactivateweapon lefthand
}
client
{
first sound $juliedir$/move5b.wav 1
.3
}
}