FPS Engine Library
Comment: 'The following actions create ...'
The following actions create the ammo and clip count listings.
Comment: 'The pitch angle is the angle ...'
The pitch angle is the angle you want the projectile to follow vertically. So a perfectly level horizontal trajectory would yield an angle of 0, a completely vertical shot into the air would yield 90, a perfectly
vertical shot into the ground would yield 270, etc. Default it is set to be the camera pitch angle. To determine the pitch angle for a shot that isn't oriented along the camera's view, follow these directions:
0 degrees is a line going forward oriented parallel to the ground.
For shots that are oriented up as well as forward, the pitch is the number of degrees between the shot's trajectory and 0 degrees.
For shots oriented down as well as forward, the pitch is equal to (360 - x), where x is the number of degrees between the trajectory and 0 degrees.
To summarize, I'll give two examples.:
A shot oriented 45 degrees into the air would yield a pitch of 45.
A shot oriented 45 degrees towards the ground would yield a pitch of (360 - 45) which = 315
Comment: 'Spawn location is the point a...'
Spawn location is the point at which the projectile's trajectory begins. Default is for it to be the current camera target of player 1. This is for use in an FPS. The camera for an FPS should have a distance around 1.0,
and thus the projectile will spawn roughly at the player's point of view. To use the projectile system with, say, a top-down view dumgeon grinder a la Diablo, you would use the 'set variable' action in this trigger to
set the spawn point to the player's character's position, or more accurately the position of the character's weapon. This would create a projectile that appears at the player's character's ranged weapon and then
flies away in the direction specified by the variable '[LOCAL] Yaw angle', presumably towards the enemies.
Comment: 'Add rocket launcher to array'
Add rocket launcher to array
Comment: 'The only thing you have to do...'
The only thing you have to do to make this library work is
to create a suitable camera for a FPS type game. Some
camera property values I find ideal for such a purpose are
as follows:
Distance = 1
Field of view = 25 to 27
Pitch = 0
Z offset = 0.5 to 0.7
Then, select the variable that follows this comment, which
is named 'Camera'. Edit its default value, and click to the
tab called 'value'. In that tab will be a listing of all camera
objects in your map. Select the one you want (the one you
set to have values appropriate for an FPS). And then hit
OK. That's it!
Comment: 'The Z offset is the height th...'
The Z offset is the height that the projectile will spawn at and must be a non-zero value for the systemto work at all for reasons explained in the comment above the global variable 'Weapon Z offset'. That variable
is used as the default value of this local variable here. That means that all projectiles throughout the game will spawn at a given height. This is useful in an FPS for making sure that the projectiles' tracelines
always begin at roughly the same height as, say, the player's FPS-style camera. However, other values can be used. To continue the example of the top-down dungeon grind RPG listed above, the local 'Z offset'
variable here would be set through a trigger action to be the height of the player's character's weapon. So the spawn point would determine the X and Y of the shot's launch point and this 'Z offset' variable would
determine the Z of the launch point.
Comment: 'A note about the weapon data....'
A note about the weapon data. The weapons won't do any
damage when the map first starts unless you create the map
with my 'FPS Engine Mod' file. That is because the damage
type effects that are applied to hit units are custom effects.
They are required to have no associated graphics (models
and particles) because those graphics are handled by the
weapon data variables '[weaponname] projectile' and
'[weaponname] impact' and the weapon operator.
However, I don't want you to be locked into having to use
my mod data. So I'll explain what to do to create your own
damage effects. Find a suitable damage effect to base yours
on. Take the marine damage for example. Now duplicate it,
and make sure that you check all the boxes to COPY rather
than to LINK in the dependencies window. Now, there will
be models associated with your new effect that will be
named something like 'marine attack launch copy' and 'marine
attack impact copy'. There will be others listed as well if you
copy from the marine gauss rifle. Other starting points you could
duplicate instead would also have models of various number.
Important part: select those copied models. delete them.
Now you have a weapon that does damage using the starcraft 2
damage system rather than just, say, subtracting X number of
HP from the target. This means you can set the death animation
of a unit killed with a weapon to a certain death animation (fire,
impact, etc.). You can also use the damage bonus system to
vary the damage by armor or unit property.
Now, go to the '[weaponname] damage' variable. Select your
duplicated and now model-free damage effect in the values
tab. Hit okay. Start er up and git shootin!
The reason I suggest you use the mod I have made with
pre-made damage effects is so that users not familiar with
the data editor or new to triggering or mapping can still use
this trigger library with an absolute minimum of work.
Comment: 'This trigger should be initia...'
This trigger should be initially off. The only time it will be on will be while a movement key (as specified by the movement direction key variables in the WASD folder) is pressed down.
This is because even though the trigger wouldnt fire when there's no keys pressed because of the 'Or' condition, it would still be running and then failing the condition check every 0.0
seconds. That's a helluva lotta trigger calls when the trigger's just gonna fail the condition check anyway because it's not needed. So therefor the triger is only on when there's a key down
and thus the trigger will pass its condition check and do something useful rather than 'running on idle' so to speak and wasting system resources.
Comment: 'Add rifle to array'
Add rifle to array
Comment: 'Add gatling/autocannon to array'
Add gatling/autocannon to array
Comment: 'This trace operates with the ...'
This trace operates with the cosine and sine of the pitch angle. The variable 'vertical' is the sine of the pitch angle, and the variable 'horizontal' is the cosine of said angle. These values are then multiplied by
the velocity multiplier of the current weapon. This velocity multiplier determines the speed of the projectile. The product of that multiplication is then saved as the current weapon's horizontal and vertical. Those
values are then in turn passed to the weapon operator, which uses them to animate the projectile's trajectory.
Comment: 'See the 'Camera positioning' ...'
See the 'Camera positioning' trigger for an explaination of why it is off initially, and turned on and off by the key press and release triggers.
Comment: 'For adding weapons, follow th...'
For adding weapons, follow these directions. Copy the folder 'template' under the 'weapon data' folder. Then, replace the values with those of your new weapon. Then, what you need to do is copy all of these
variable actions: Name, operator type, damage, impact, projectile, gunshot sound, impact sound, range, velocity multiplier, cooldown, and zoom modifier. Then change the array number for the copies to the
ID number of your new weapon. Since ID numbers 1 thru 4 are already taken, the first new weapon you add would be 5. Then you would set the value on the right side of the set variable action to that of
your new weapon.
Comment: 'When you switch the view to t...'
When you switch the view to third person via the 'view type' variable, you need to turn this on with a trigger. The way it works is that when you move, the 'positioning' trigger is turned on, and depending on
the view type 'TP movement' for thid person is also turned on. that handles either the camera movement or camera AND unit movment respectively. However, in third person
mode you need the unit to turn with the camera ALWAYS, rather than just when you're moving. Because the movement trigger set is turned on and off by the WASD key press triggers, it wouldn't work to
use the key press triggers to enable this rotation trigger for the reason that in that case the unit would only rotate when moving. So to recap, when switching the view to third person type, tur this on, when
switching back, turn this off.
Comment: 'This is your end point of the...'
This is your end point of the movement.
Comment: 'Move distance is how far you ...'
Move distance is how far you want the camera to move each time this trigger runs when the camera is moving DIRECTLY FORWARD.
Move distance back is simply a negative version of 'move distance' used when the camera is going DIRECTLY BACKWARD.
Comment: 'This is the camera yaw angle.'
This is the camera yaw angle.
Comment: 'Update weapon name, ammo, and...'
Update weapon name, ammo, and clip number readouts
Comment: 'Strafe distance is how far th...'
Strafe distance is how far the camera will move each time this trigger runs when the camera is going DIRECTLY SIDEWAYS.
There's no need for a negative strafe because the movement is always positive, rather it is the angle of movement that changes by 180 degrees.
Comment: 'The following actions create ...'
The following actions create the reloading progress bar used in the reloading operator.
Comment: 'The number of weapons integer...'
The number of weapons integer variable is used by the
weapon switch triggers to determine whether or not to
increase or decrease the 'current weapon ID' variable.
For each weapon you add, increase this 'number of
weapons' variable by 1. Furthermore, each new weapon
needs a new weapon ID, in consecutive order. In other
words there are 4 weapons now, with IDs 1 thru 4. If
you create a new weapon you must set its ID then to 5.
If there are 6 weapons, they have to be numbered 1
thru 6. If there are 10, 1 thru 10. No weapon should have
0 as its ID. For further info on adding weapons, see the
trigger named 'Initialization' in this folder.
Comment: 'Strafe angle distance is how ...'
Strafe angle distance is how far you want the camera to move each time the camera is moving BOTH FORWARD AND SIDEWAYS AT THE SAME TIME.
Strafe angle distance is simply a negative version of 'move distance' used when the camera is going BOTH BACKWARDS AND SIDEWAYS AT THE SAME TIME.
Comment: 'These camera stop distances r...'
These camera stop distances relate to detecting if there's a cliff or unit in the way. These are critical in an FPS because there's no unit to run into the wall and stop.
Without the two pathing operator functions that these variables are fed into, the camera will simply go wherever it is directed, including walking over/through units and cliffs.
Comment: 'This is the starting point of...'
This is the starting point of your movement operation.
Comment: 'This trigger is used to deter...'
This trigger is used to determine when the player releases the shooting command key or mouse button. The constant weapon operators will look for the 'set constant weapon command released?' boolean to be false.
As long as it is false, the constant weapon operator will continue to cycle through its actions, continuing to fire the weapon. This trigger will set that boolean to be true when the key or mouse button used to fire is
released. At that point the constant weapon operator will recognize that it should stop firing, and it will run to its conclusion rather than continuing to cycle and thus continuing to shoot.
Comment: 'These data table entries are ...'
These data table entries are critical. Without a corresponding entry, you will not be able to hit a unit of a type not listed here. These are the unit heights. They are used by the weapon operators to determine
whether a shot hits a unit or flies over its head. believe me, I tried lots of other solutions, and the only way there is to give a unit a hight is to do it by hand. So, for any type of unit not listed here already, you
must add a value. An example is a firebat. I'm gonna take a educated guess and say a firebat is between 0.9 and 1.2 tall. So you would copy one of these entries, replace the unit type in the copy with the
unity type 'Firebat', and then save the real value as the height. Then you'd go play the map and see whether your estimated height works. Do that by shooting over the firebats head repeatedly, lowering the
angle each time to see at what point it finally registers as a hit.
Without a unit height value any shot that goes into a circle of a certain size around the unit's XY value would hit it, even if the shot went way wide and went over the units head. Until you input a value for a unit
type, the weapon operators will simply ignore the unit as if it wasn't there, because there will be no value in the daa table under that unit type's name string to access for the height data.
Comment: 'Add flamethrower to array'
Add flamethrower to array
Comment: 'Finally, the last relevant lo...'
Finally, the last relevant local variable is the 'yaw angle'. This is equal to the angle you want to projectile to travel along horizontally. So in an FPS it would be the camera yaw of player 1, as it is set here as default.
In the hypothetical top-down shooter game mentioned above it would be the facing of the player's character. That would ensure that the 'forward' direction that the projectile would travel along would be aligned
to the direction the character unit is facing.
Comment: 'A note about this 'weapon ope...'
A note about this 'weapon operator type' integer variable:
Each type of weapon (instant, projectile, constant, etc) has
its own identifying integer. When you make a new weapon
you must set its operator type variable to the type of weapon
you want. For a very very fast bullet, you'd chose instant.
For a slower shot with a visible projectile, you'd chose
projectile. Each weapon operator type has a corresponding
integer value, which are listed below.
For an instant-type weapon: 1
For a projectile-type weapon: 2
For an AoE constant weapon: 3
For a linear fire constant weapon: 4
Comment: 'This 'constant weapon update ...'
This 'constant weapon update actor?' boolean is used by the
constant weapon operator to determine whether or not it needs
to re-orient the weapon graphics to the current camera angle.
If it didn't re-orient, the weapon's graphic wouldn't turn with
the player's camera.
Operators
Flamethrower
Weapon Data
Utility
Rocket Launcher
Weapons
Current Weapon Variables
Template
Player Action Triggers
Pickups
Trigger Variables
WASD
Operators/Presets
Combat System
Camera
Zoom
Rifle
Player Unit Data
Gatling
Switch weapons forward
Combat Initialization
Unmake dummy unit
Detect Lmousebutton release
Key release
Key press
Zoom in
Current health update
TP rotation
Reload
Update HP Bar
Switch weapons backward
Zoom out
UntitledTrigger001222
Detect shoot (Lmousebutton)
Camera positioning
Global Initialization
Mouse release
Make dummy unit
Pickup Trigger
Ammo Count Update Operator
Ground Impact Operator
Linear Projectile Constant Weapon Operator
Instant Weapon Operator
Reloading Operator
Walk Unit Pathing Operator
AOE Constant Weapon Operator
Constant Weapon Angle Update Operator
Projectile Weapon Operator
Unit Impact Operator
Walk Terrain Pathing Operator
100
true
0.0
true
1
-;Missile,Destructible,Item,Buried,Dead,Hidden
""
45.0
90.0
true
0.0
1
EditorDefaultSound
1
false
1
0.25
false
Zergling
1
true
AutocannonDamage
60
1.5
1.0
0.5
1
false
100.0
0.01
250
1
0.0
1
1
1
Firebat
1
EditorDefaultSound
0.0
true
Firebat_AttackImpact
0
[RELOAD]
true
Autocannon
100.0
0.1
0
false
DummyStationaryEvade
180.0
2
2
true
150.0
0.8
250
FlamethrowerDamage
30.0
1
10.0
100.0
0.0001
0.67
0.5
0.0
true
4
0
1
SiegeTank_SiegedAttackImpact
1
false
true
0.04
1
60
10
90.0
1
0
0
100.0
1.3
0.0
false
2.35
50
0.0
0
true
2
0
3
4
1.35
[RELOADING]
1.0
false
0.0
false
true
false
1
false
false
0.67
2
0.1
1.0
UI_FileSelectionSelect
false
30
3
true
false
45.0
true
Ghost_AttackLaunch
true
0.0
OrbitalCommand
0
1.0
false
0
true
1
]
1
Assets\Textures\ui_chatbaricons_terran_individual.dds
LaserTurretWeapon
45.0
false
0
true
true
true
[
2.0
0
false
1
true
Ground;Structure,Missile,Item,Buried,Dead,Hidden
true
false
1.0
0
false
1
Template
1
false
1
true
1
2.0
true
true
[
1
MissileTurret_AttackLaunch
0.0
false
true
1.0
0
true
1
0
PistolAmmo
5.0
0.0
1.12
[CLIPS]
1.4
4
GhostSnipeAttackImpact
false
false
[CLIPS]
false
0
""
1
0.0
false
false
RifleDamage
true
1
/
true
true
false
true
1.0
0
2
0.0
false
1.0
1
true
1
Ground,Structure;Missile,Item,Buried,Dead,Hidden
Rifle
0.1
1.33
1
true
true
Hydralisk
false
Ghost
1
1
-30
true
1
90.0
50
45.0
1
150
false
2
false
0.0
1
PlayerUnitDummy
true
true
false
0.8
false
1
100.0
false
0
false
0
90
-0.5
0
0
false
RocketDamage
1
45.0
-;Missile,Destructible,Item,Buried,Dead,Hidden
100.0
90.0
true
true
true
Ghost_AttackLaunch
true
1.6
1
DummyStationaryEvade
0
0
false
true
1.1
/
0
true
45.0
0
1
Hellion
SiegeTankSiegedAttackImpact
false
1
5.0
4
1
0
1.0
Ghost_AttackImpact
true
0.5
0.2
true
false
true
0.0
false
true
Rocket Launcher
false
0
2
true
Marine
1.15
-;Missile,Dead,Hidden
0.1
1
5
1
10
0.0
[
DummyMovingEvade
1
true
true
0.0
true
1
45.0
false
1.1
1
0.01
15.0
0.5
1
0
1
100.0
0.9
FlamethrowerAmmo
0.0
OrbitalCommandFlying
0.0
1
180.0
false
true
0
0.005
true
false
0
-;Missile,Destructible,Item,Buried,Dead,Hidden
1
2
]
1
true
1
1.0
1.8
DummyMovingEvade
false
0.01
true
1
30
35
1
10
0.1
true
1.0
30.0
90.0
1
false
75
1.0
0.1
1
FirebatAttackLaunch
true
""
100.0
1
false
10
1
1
false
1
1.0
1
2.65
false
1
1.7
0.1
true
60
0.4
3.1
10
1
1
true
false
0.3
GhostSnipeAttackImpact
[RELOAD]
false
false
1
]
1
false
0.2
TychusChaingunAttackImpact
1
1.0
0
true
0
0.0
0
true
1
1
false
0.1
0
0
0
false
2.0
45.0
1.33
0.0
-;Missile,Dead,Hidden
1
AutocannonAmmo
1
1.0
1.0
0
false
0
45.0
0
0.0
false
true
0
1
1
90.0
15.0
1
true
0
2.0
0.5
1
[
VikingAssault
[ROUNDS]
100.0
300
0.0
0
true
0.0
true
RocketAmmo
6
0
Pickup
false
true
1
false
true
250
1.0
0.1
false
10
45.0
Marauder
Ghost_AttackImpact
]
1
0.1
0.0
PerditionTurretAttackLaunch
false
3
ScienceVessel
false
1.0
false
0
15.0
0.3
0
false
0.0
0.0
-1.4
LongboltMissileWeapon
0.5
45.0
/
0
175
Goliath
150.0
2
Reaper
true
false
true
true
true
100.0
10.0
0
[RELOAD]
SiegeTank
false
[ROUNDS]
1
100.0
true
0.5
45.0
0.05
2.0
180.0
false
false
0.005
250
Health
1
0.1
Flamethrower
1
0
1.0
0.0
[NO AMMO]
0.0
0.0
0
1
ATSLaserBatteryLMWeapon
true
0
DummyStationaryEvade
[BULLET] Projectile
[DAMAGE] Weapon Effect
[LOCATION] Initial
[BULLET] Impact
[SOUND] Weapon Impact
[TRAVEL] Horizontal
[BULLET] Projectile
[BULLET] Impact
[SOUND] Weapon Report
[TRAVEL] Angle of Attack
[SOUND] Weapon Impact
Check Point
[DAMAGE] Weapon Effect
[GRAPHIC] Weapon
[ANGLE] Facing
[BULLET] Impact
Check Point
[SOUND] Weapon Report
[BULLET] Projectile
[TRAVEL] Range
[TRAVEL] Angle of Attack
[DAMAGE] Weapon Effect
[TRAVEL] Velocity Multiplier
[TIME] Cooldown
[TRAVEL] Horizontal
[TRAVEL] Range
[POINT] Destination
[LOCATION] Initial
[TRAVEL] Angle of Attack
[TRAVEL] Vertical
[DISTANCE] Stop length
[LOCATION] Initial
[TRAVEL] Vertical
[TRAVEL] Vertical
[SOUND] Weapon Impact
[SOUND] Weapon Report
[TRAVEL] Horizontal
[POINT] Current
[TRAVEL] Vertical
[TRAVEL] Angle of Attack
[SOUND] Weapon Impact
[LOCATION] Initial
[TRAVEL] Range
[DAMAGE] Weapon Effect
[SOUND] Weapon Report
[TRAVEL] Horizontal
[TRAVEL] Range
[BULLET] Impact
Impact Type
View Type
Unit
First Person
Third Person
Terrain
[GAT] Impact
[temp] Zoom Modifier
[WEP] Number of Clips
[GAT] Range
Movement enable
[GAT] Zoom Modifier
[temp] Damage
[WEP] Spawn Location
[LOCAL] Z offset
Count
Camera FoV
Location
Location
[GAT] ID
Reloading Dialog
View
[LOCAL] Pitch angle
Units in Circle
[RIFLE] Impact
[temp] Projectile
[GAT] Impact Sound
Non-player units
[WEP] Zoom Modifier
Strafe angle distance back
[WEP] Cooldown
New Location
Constant weapon op in use?
Back Key
[WEP] Horizontal
[temp] Velocity Multiplier
[WEP] Vertical
[WEP] Impact Sound
Break loop unit
Units in Circle
[temp] Cooldown
[WEP] Damage
[WEP] Max Ammo
[ROCKET] Gunshot Sound
Break loop type
[temp] Range
Count
[ROCKET] Operator Type
Camera location local
Camera distance
Constant weapon command released?
Current Health
[RIFLE] Zoom Modifier
Current FoV
Left Key
Vertical
Back
Horizontal destination
Clip number item
Number of weapons
Break loop terrain
Maximum Health
[RIFLE] Range
Camera
Weapon name item
[FLAME] Impact Sound
[FLAME] ID
[ROCKET] Impact Sound
Constant weapon update actor?
[FLAME] Range
Forward
[temp] ID
Left
Camera destination local
Ammo count dialog
[FLAME] Gunshot Sound
Break loop unit
Camera target
Vertical
[FLAME] Cooldown
Strafe distance
Actor
[RIFLE] Velocity Multiplier
[GAT] Gunshot Sound
[ROCKET] Name
[RIFLE] Gunshot Sound
[temp] Impact
[RIFLE] Cooldown
[ROCKET] Damage
[WEP] Current Ammo
Move distance back
[LOCAL] Spawn location
[WEP] Selected Weapon ID
Break loop unit
[GAT] Cooldown
Break loop type
[ROCKET] Velocity Multiplier
Unit breaking loop
Weapon Z offset
Break loop terrain
[FLAME] Zoom Modifier
[temp] Operator Type
Location
Ammo number item
Current distance
Break loop unit
Positive stop distance
Unit breaking loop
Height
[FLAME] Damage
Units in the way
[temp] Gunshot Sound
[WEP] Operator Type
[RIFLE] Ammo / Clip
[LOCAL] Vertical
[GAT] Name
Horizontal
Yaw
[ROCKET] Cooldown
Right
[ROCKET] Range
[temp] Ammo / Clip
Non-player units
[temp] Name
Break loop type
Camera rotation local
[GAT] Damage
Horizontal
[ROCKET] Ammo / Clip
Dummy in play?
Pitch
Break loop terrain
Camera location
[ROCKET] Projectile
[FLAME] Ammo / Clip
Right Key
[RIFLE] Projectile
Horizontal
[WEP] Velocity Multiplier
Unit
Count
Destination
Horizontal destination
[WEP] Range
Move distance
Count
Destination
[WEP] Gunshot Sound
[LOCAL] Horizontal
[RIFLE] Operator Type
Vertical
[RIFLE] Name
Location
Break loop terrain
[WEP] Name
New Location
[FLAME] Velocity Multiplier
[WEP] Impact
[RIFLE] ID
[GAT] Projectile
[GAT] Operator Type
[LOCAL] Yaw angle
Shooting capable?
Unit breaking loop
Destination
[FLAME] Projectile
[ROCKET] Zoom Modifier
Destination
[GAT] Velocity Multiplier
Break loop type
[FLAME] Operator Type
[temp] Impact Sound
[RIFLE] Impact Sound
[ROCKET] Impact
[FLAME] Impact
[RIFLE] Damage
Negative stop distance
Forward Key
Count
[FLAME] Name
[GAT] Ammo / Clip
Buildings in the way
New angle
[ROCKET] ID
Actor
Unit
Strafe angle distance
Reloading Dialog Bar item
[WEP] Projectile
Actor