Cob Extensions - Map info and maps scripts

Ext. ID Ext. Name Type Description
270 MAP_SEA_LEVEL GET returns sea level of map
271 IS_LAVA_MAP GET returns 1 if lava map
272 SURFACE_METAL GET returns SurfaceMetal value of map. if Par1 is given, new SurfaceMetal is applied
273 UNIT_AT_POSITION GET returns unit ID at given position (0 if no unit)
Parameters: PackedXZ
274 TEST_UNLOAD_POS GET returns 1 if can unload given unit at its current position
Parameters: UnitID
275 TEST_BUILD_SPOT GET check is build spot free for certain unit type at given coords
Parameters: UnitTypeCRC, PackedXZ
276 PLANT_YARD_OCCUPIED GET check is plant yard occupied by other units
Parameters: UnitID
277 UNIT_REBUILD_YARD GET rebuilds caller unit yardmap without need of recreating the unit
278 FEATURE_TYPE_AT_POS GET Returns feature type index found at given X,Z grid
Parameters: XGrid, ZGrid
279 FEATURE_INFO GET Parameters: FeatureTypeIdx, FieldType
280 GRID_INFO GET Parameters: XGrid, ZGrid, FieldType

Map scripts:

Every map can now run its own scripts. For better performance I decided to use COB engine. Create new file with map name but BOS extension and place it in maps directory. Initial script "MapMission" is called with two arguments that are used to determine game type and its difficulty.

MapMission(game_type, ai_difficulty)
  /* game_type:
  1 - Campaign
  2 - Skirmish
  3 - Multiplayer

  0 - Easy
  1 - Medium
  2 - Hard */

  if (game_type == 1)
    thisplayer = get MS_VIEW_PLAYER_ID;
    initial_gamma = get MS_SCREEN_GAMMA;

A TDF type file (also placed in maps directory) is used to store custom sounds, features and units initial missions. Example:




Sound file names are compared with ALLSOUND.TDF entries, while feature name must exist on map already in order to get MS_PLACE_FEATURE extension working.

Ext. ID Ext. Name Type Description
300 MS_MOVE_CAM_POS GET move camera to given position
Parameters: X, Z, SmoothScroll
301 MS_LOCK_CAM_TO_UNIT GET locks camera to unit with given ID (just like T key does)
Parameters: UnitID
302 MS_SHAKE GET shake camera
Parameters: X, Y, Duration
303 MS_SCREEN_GAMMA GET/SET get or set current gamma setting. 10 = 1.0
304 MS_SCREEN_FADE SET fade map area of screen to white or black. 0 = none, 1-15 to black, 16-30 to white
305 MS_DRAW_MOUSE SET enable/disable mouse draw
306 MS_DESELECT_UNITS GET deselect all units in game
307 MS_PLAY_SOUND_2D GET play sound in 2D mode
Parameters: SoundID, NetworkBroadcast
308 MS_PLAY_SOUND_3D GET play sound in 2D mode
Parameters: SoundID, PackedXZ, NetworkBroadcast
309 MS_EMIT_SMOKE GET emit smoke on map at given coordinates
Parameters: SmokeType (0 - infinite gray, 1 - gray, 2 - black), X, Z
310 MS_PLACE_FEATURE GET place a feature on map
Parameters: FeatuerTypeIdx, PackedXZ, TurnZ
311 MS_REMOVE_FEATURE GET remove feature (map feature or wreck)
Parameters: X, Z, Method (0 or 1)
312 MS_SWAP_TERRAIN SET reload terrain file with file name - CurrentMapName and postfix given in param, f.e. CurrentMapName1.tnt
Parameters: PostfixIndex
313 MS_VIEW_PLAYER_ID GET returns index of current player
314 MS_GAME_TIME GET returns game time in ticks format. 30 ticks = 1 second
315 MS_APPLY_UNIT_SCRIPT GET apply unit orders (InitialMissions style commands) from map TDF file [unitsmissions] section
Parameters: UnitID, KeyIndex
316 MS_FIRE_MAP_WEAPON GET fire map weapon
Parameters: WeaponID, PackedXZ
318 MS_AI_DIFFICULTY GET returns AI difficulty