MaHuJa/Sandbox – User

From Bohemia Interactive Community
< User:MaHuJa
Revision as of 14:36, 1 March 2007 by MaHuJa (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This article assumes you are somewhat familiar with mission editing - without scripting.

Getting started with ArmAscript

Oneliners in the editor

The most basic form of scripting is the oneline scripts in various init fields, trigger on (de-)activation fields, and waypoint activation fields in the editor itself.

Example: Destroying a tank

A mission requires the player, and his two helpers, to get a tank parked a little behind the engagement area, and reinforce the front with it. However, as they approach the tank, it blows up. Now they have to find and punish the saboteurs. And perhaps go back to the front to help out in any way they can.

These steps can achieve that:

  • Create the player squad
  • Create the tank, name it "theTank"
  • Create a couple saboteurs hiding in some bushes a couple hundred meters nearby - preferrably not with line of sight to the tank so that they could start shooting the player early.
  • Create a trigger near to the tank (almost on top of) with both sizes set to 150. Set it to "west" "present". In the "on activation" field, type in the following:
theTank setdamage 1

Congratulations, you've just written your first script.

The demonstration mission itself needs a few things more, but which aren't important for this tutorial.

  • Briefing, all of that
  • Waypoints for the player group
  • Notification of changed goals
  • Victory condition triggers

Customized ammobox

Create an ammobox. (Give it the name ammo_one) In its init line, fill in

clearweaponcargo this; clearmagazinecargo this; this addweaponcargo ["m16a2",2]; this addmagazinecargo ["30Rnd_556x45_Stanag",30]

You've just created an ammobox that will contain two m16 rifles and 30 magazines for them. For the "scripting names" of weapons and ammunition, see here. For unofficial addons, the names are usually listed in a readme.

Whenever you are editing an object, like an ammobox, "this" has the special meaning of "this particular object". If you write the same thing for an "ammo_two" the lines there will not change the content of ammo_one. This allows copy/paste to be used to write it once and paste it everywhere, and it will affect the object it has been copied to. Had you written

clearweaponcargo ammo_one

instead, you'd always be clearing the contents of that first crate.


Script files

.