Setup Mission Objects - RaynorD/cav_ranges GitHub Wiki

Aside from the targets themselves, a range has several support objects which serve different functions. These objects (and the targets) must be set to very specific names in the editor. Before proceeding you should have decided on a range tag for your range in the previous article, since it will be used in the name of every object on the range.

Why use special names?

Naming the objects a standard format allows the scripts to access the range objects in an organized manner, without having to maintain a separate list in a script somewhere.

Note: Spaces have been added to the name formats to improve readability and formatting, remove them for the actual name.

Control Object

control object

The control or "brain" object for the range. This object is what the actions to control the range are added to (also available as player actions), and is also used to store script variables. There is only one ctrl object per range. It can be any kind of object, but I'd recommend something that indicates interaction. Location does not matter.

Name format: (range tag) _ ctrl
Example: gr_ctrl

Trigger Area

Trigger Area

A trigger encompassing the whole area that players may occupy while using or observing the range. When a player enters this trigger, the UI showing that range's info will appear. Don't overlap triggers for different ranges, otherwise multiple UIs could try to open at once and the timespace continuum may implode. There is only one trigger per range. The trigger must have the following settings:

  • Activation = Any Player
  • Activation Type = Present
  • Repeatable = True

Name format: (range tag) _ trg
Example: gr_trg

Shooting Positions

Shooting pos

Each lane has a shooting position. The closest player to this object within a few meters is shown as the shooter on the range UI, and included in the chat log when a range is completed. Currently it is purely cosmetic. The object can be anything, I have used actual shooting positions (ShootingPos_F) and helper spheres (Sign_Sphere100cm_F, etc) set to hidden.

Name format: (range tag) _ shootingPos _ l (lane #)
Example: gr_shootingPos_l3

Targets

targets

A target, gets shot at. If using the "targets" range mode, a popup target (that uses the "terc" animation to popup) must be used. If using the "spawn" mode, anything that can die can be used.

Name format: (range tag) _ target _ l (lane #) _ t (target #)
Example: gr_target_l3_t6

Loudspeakers

speakers
Speakers which will play (via global say3d) any sounds that you specify in the range sequence. They are optional. Per say3d description, you can use sounds in the main config or ones you define in cfgSounds in description.ext. You can have any number of speakers, but they must be named consecutively to be detected. The index here is not the lane index, just the index of speaker it is on that range. They can be any type of object, but I'd recommend one that makes sense to make very loud noises.

Name format: (range tag) _ speaker _ (index)
Example: gr_speaker_1, gr_speaker_2, etc

Instructors

instructors
instructors

The ability to control the ranges is limited to certain players designated as "instructors". By default, the actions are only added to the control object, but there is a range option to also add a collapsing player action menu as displayed in the second image above.

Place the following code in the init field of a playable unit to make that player an instructor:
this setVariable ["cav_ranges_instructor", true];


Example Range

To conclude, let's create an example range listing all its named objects. Let's say it's an automatic rifle range, so let's set the range tag to "ar" in the range init. It will have 2 lanes with 3 targets each.

ar_ctrl
ar_trg
  
ar_shootingPos_l1
ar_shootingPos_l2
  
ar_target_l1_t1
ar_target_l1_t2
ar_target_l1_t3
  
ar_target_l2_t1
ar_target_l2_t2
ar_target_l2_t3

You're done!

Once your objects are setup, all that's left is to complete the createRange call, and your range will be fully functional. For examples of the createRange call, see createRange examples.

If you're having problems, see troubleshooting.