Coding Standards

 

This document contains a collection of comments and guidelines for writing scripts and maps for the Medal of Honor: Pacific Assault multiplayer game.

Scripts

File Headers

File headers should list the name of the file, details about what the files covers, and lists of major revisions to that file:

//

// doKoolStuff.scr

//

//

// To use in a script, set up the bomb/trigger as described

// below, and the call init on the bomb (as described by the

// function comments below) when the map starts up.When the

// bomb should be visible (i.e. the objective which involves the

// bomb is the current one), call activate on the bomb. When that

// objective is completed, call deactivate on the bomb.

//

// In the map, there must be the following:

// - A script_model, which will be the bomb/throbbox itself

// - A trigger_multiple which surrounds the immediate vacinity of //�� the bomb (in which, if the player holds 'use', the bomb will

//�� arm/disarm).

//

// 12.09.03 JABBOTT - Removed the old Kool stuff per design spec.

//������������������� changes, added elements under the new Kewl //������� ���� ��� model

// 09.12.03 DSCOTT - Original version

//

 

NOTE: the blank space is reserved, there may be copyright information that we'll have to go stuff in there later.

Function Names

Function names are always all lower case with underscores for space separations. The arguments should always use the mixed case starting with lower case naming convention.

Function Comments

The function name should always be surrounded by a pair of hyphenated lines. If the function is the first function in the beginning of a section, then the hyphenated line before the function should be a full line width (2 slashes, 77 hyphens) across. If the function is a subroutine in a particular section, then the first line should be a partial line of hyphens (2 slashes, 18 hyphens). In both cases the following line should be a partial line of hyphens (2 slashes, 18 hyphens). Comments specific to the routine (explanation of the arguments, and details on what the code does) should follow the function name.

Function Example

 

//---------------------------------------------------------------

dynamite_unplant local.player local.axisBomb:

//----------------

 

���� // This is called when a allied player presses the use key

���� // in the right area at the right time to defuse a bomb. We

���� // display a stopwatch and let it tick down... until the

���� // player is forced to not do so (dies, moves away) or the

���� // time expires.

 

���� if (self.planter != NIL && self.planter != NULL)

���������� local.axisBomb thread do_explode local.player

end

Debugging println

Final code should never contain debugging printlns that use the iprintln routine (or any of the other iprint* routines). Instead all debugging lines should use the dprintln (or any of the other dprin* routines). When someone invokes the game without the developer flag set, they should only ever see those lines intended for a player to see.

Entities

Variables

All entity variables are composed of mixed cases, starting with lower cases. For example: local.bombCountdown and self.isBombPlantedYet

Targetnames

All targetname and target values will be composed of all lower case, with multiple words separated by underscores. For example: objective_1_bomb and jeep_waypoint_4

Spawn Points

Spawn points are either labeled "allies_spawn_#" or "axis_spawn_#".

Fixed MG

The machine guns will have the targetname of "mg42". They will each have a unique �#set" attribute value. In the map they need to have two triggers associated with them, which should never overlap. The first trigger is a trigger_multiple that the gun has targetted. It also calls a setthread by the name of "reload_trigger". This trigger is always placed to the side of the gun (usually the right hand side of the gun, where the ammo clip is).The second trigger is a trigger_use that has the same "#set" attribute value as the MG and calls a setthread by the name of "trigger_use". This trigger is always placed right behind the gun.

Fixed Artillery

The artillery will have the targetname of "artillery" and they will each have a unique "#set" value. In the map they need to have three triggers associated with them, which should never overlap. The first trigger is a trigger_multiple that the artillery has targeted and also calls a setthread by the name of "reload_trigger". This trigger is always placed to the side of the artillery (usually the right hand side of the artillery). The second trigger is a trigger_use that has the same "#set" value as the artillery and also calls a setthread by the name of "trigger_use". This trigger is always placed right behind the artillery. The third trigger is a trigger_multiple with the same "#set" value as the artillery and also calls a setthread by the name of "artillery_bomb". This trigger is always placed to the left of the artillery.

 

Objectives

Each objective is built around a trigger. This trigger is always named "objective_#". This trigger usually calls a setthread by the name of "use_trigger_#". If there are multiple triggers that do different things then they would be named "objective_#_#" and call "use_thread_#_#". For example, the 2nd switch on the last objective would have a use trigger named "objective_4_2". If there are moving parts associated with an objective, they are named "objective_#_handle" or "objective_#_#_handle" if there are multiple independent objects that move for any objective.

Vehicles

Vehicle entities must have a targetname of "mpvehicle". Vehicles take the following attribute value pairs:

 

$pathName����������� // targetname of the start of vehicle's // path

$team��������������� // "allies" or "axis"

#autoDrive���������� // 0 or 1, vehicle drives forward as soon // as driver gets in and ignores any��� // forward-backward key presses by the// user

#hasDriverSlot������ // 0 or 1

#driverCanDismount�� // 0 or 1, whether driver can press use // key to get out of vehicle

#ejectDriverAtPathBreak��� // 0 or 1, at a path break, automatically // stop vehicle and kick driver out���� // (useful when setting driverCanDismount // to 0)

#rejectDriverAfterEject��� // 0 or 1, after driver is auto-ejected, // don't let him back in

#numTurretSlots����� // 0 to whatever

#canReverse��������� // 0 or 1, gets defaulted to 0 when���� // autoDrive is true; whether user can// hold back key to reverse

$bodyType����������� // currently defaults to "jeep";������� // determines destroyed version model

#canRespawn��������� // 0 or 1

#respawnTime�������� // default = 20 (seconds)

#slotRadius��������� // distance player must be to a slot to // engage it; default = 100

#grossSlotRadius���� // distance at which slot-checking����� // takes place; should be somewhat large; // say, twice the "radius" of the������ // vehicle's extents, allowing for slot // radii; default = 512

#minSlotFacingAngle// how narrowly you must be facing����� // towards slot to engage it;default = // 45 (degrees)

#forwardSpeed������� // default = 200

#reverseSpeed������� // default = 75

#accel�������������� // default = 75

#reachDistance������ // for vehicle-path code; default = 256

#lookAhead���������� // for vehicle-path code; default = 256

#damageHindersMobility���� // 0 or 1

#hasDynaChargeSlot�� // 0 or 1; position is given a default// position in code, for now

Vehicle paths

Vehicle path nodes must link vehicle nodes along entire path, even across initial breakages; path can loop back to origin if desired. Vehicle path nodes take the following attribute value pairs:

 

$namedBreakage// specify if linkage to next node should be// breakable by in-map event or obstacle (like // the gate in our Tunisia proto level), in�� // script; if specified, then this specifies a // name used in the following statement������ // ("breakageName"):

waitthread global/mp_vehicles.scr::MendPathBreak "breakageName"

$nextAutoWayPoint��� // name of another node at which to break the // path once vehicle arrives at this one;���� // basically, you can have sort of a sequence // of stop points for vehicles with "autoDrive" // turned on;set #initBroken to 1 for the�� // first in the series;vehicle will drive to // that waypoint then stop (possibly ejecting // driver, see params for vehicles up above);// next time vehicle is directed to drive���� // (e.g., When driver gets back in), current// linkage will be re-mended, and the next one // down the path will be broken

#initBroken���� // 0 or 1, for named breakages or auto-������ // waypoints, linkage to next node starts off // broken when the map starts up

Mapping

Setthread

Since setthread calls function names, all values of entity setthread attributes should be of the all lowercase separated by underscore format. For example:

 

setthread trigger_blow_up_gate

setthread use_weapon

Targetname and Target

Since all entities are named with the all lowercase separated by underscore format, all targetname and target attributes should have values in this format. Note that target and targetname do not require the dollar sign infront of them. For example:

 

target���� objective_1

targetname big_gun_of_doom

Entity attributes

All other entity attributes should be in the mixed case beginning with lower case format. For example:

 

$partisan������ aMemberOfTheResistance

$hospitalSide�� axis

$cigarette����� dangerousForYourHealth