share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
changeset 11037 599bb42d7448
child 11642 45316b6eb4a0
equal deleted inserted replaced
11036:6e866be63b1d 11037:599bb42d7448
       
     1 ---------------------------------------------------------------
       
     2 --- HEDGE EDITOR 0.9 (for use with Hedgewars 0.9.22 and up)
       
     3 ---------------------------------------------------------------
       
     4 -- a horrible mission editor by mikade
       
     5 -- place gears like a boss
       
     6 
       
     7 -- feel free to shower me with your adoration and/or hate mail
       
     8 -- more info can be found at http://hedgewars.org/HedgeEditor
       
     9 
       
    10 -- special thanks to nemo, unC0Rr, sheepluva and koda for their assistance
       
    11 
       
    12 ---------------------------------------
       
    13 -- GETTING STARTED (for best results!)
       
    14 ---------------------------------------
       
    15 -- create a weaponset that has NO DELAYS on any weapons, and that gives you 1 ammo per crate
       
    16 
       
    17 -- (optional) copy GameLogExtractor.html, jquery-1.js
       
    18 -- into your Documents/Hedgewars/Logs folder
       
    19 
       
    20 -- (optional) copy hwpmapconverter somewhere easily accessible
       
    21 
       
    22 -- (optional) profit??
       
    23 
       
    24 ---------------------------------------
       
    25 -- CORE FEATURES as of latest version
       
    26 ---------------------------------------
       
    27 -- togglable help (press PRECISE + 1, while you have a tool (e.g. airstrike) selected)
       
    28 -- you can also the set the ScriptParameter in scheme, e.g: helpDisabled="true"
       
    29 
       
    30 -- place girders, rubberbands and custom sprites anywhere on the map.
       
    31 -- the above objects may be destructible, indestructible, icy, or bouncy.
       
    32 
       
    33 -- place mines, sticky mines, air mines, barrels, weapon crates, utility crates,
       
    34 -- health crates, targets, and cleavers anywhere on the map.
       
    35 
       
    36 -- select, reposition, modify, or delete placed objects.
       
    37 
       
    38 -- read in data from a previously generated map and allow the map to be edited/saved again
       
    39 
       
    40 -- contextual cursor and menu graphics
       
    41 -- placement sounds that are slightly more soothing
       
    42 
       
    43 -- meaningless version number
       
    44 -- extra whitespace
       
    45 -- fewer capital letters than ideal
       
    46 
       
    47 -- upon saving, all level data will be output to logs/game0.log.
       
    48 -- game0.log also includes a lot of other data so if you only want to see the relevant lines of code
       
    49 -- you can use GameLogExtractor.html to extract and prune the log into a cleaner form of data,
       
    50 -- specifically: either as an automagically generated template mission, just core data, or hwmap points.
       
    51 -- from there, please copy and paste any lines relevant to your interest into an existing
       
    52 -- (or totally empty!) script and edit them according to taste.
       
    53 
       
    54 --------------------------
       
    55 -- MODE SPECIFIC SUPPORT
       
    56 --------------------------
       
    57 -- FOR CUSTOM MISSIONS/CAMPAIGN LEVELS:
       
    58 -- the names/hats/flags/voices/graves of any teams/hogs that you use to play this script can be saved,
       
    59 -- as can (most of) the settings from your scheme and weapons selection.
       
    60 -- HOWEVER, you can also use the 'hog identity' tool to give hogs preset names/hats/weapons/health
       
    61 -- or use the 'team identity' tool to give an entire team themed names/hats.
       
    62 -- give hogs differing health by using the health modification tool
       
    63 -- create goals by tagging gears with victory/defeat/collection markers (somewhat implemented)
       
    64 -- flavor text, as well as victory/defeat conditions will be generated based on these tags.
       
    65 
       
    66 -- SHOPPA BALANCE / CONSTRUCTION MODE (partial and/or possibly decremented):
       
    67 -- Press 1-5 while repositioning hogs with the reposition tool to assign them (their position) a rank.
       
    68 -- This value will be expressed as a colour that is intended to represent how "good" or "bad"
       
    69 -- a position on the map is. These ranks/points will be output along with other game data to game0.log
       
    70 -- This data could be pasted into the ShoppaBalance script to create balances for additional maps.
       
    71 
       
    72 -- TECH RACER / HEDGE EDITOR / POINT INTERPRETER:
       
    73 -- place/remove waypoints/special points
       
    74 -- use the ScriptParameter in the frontend scheme editor to set additional options, e.g.
       
    75 -- ufoFuel=1000 (Flying Saucer will start with half the normal fuel. A value of 2000 is infinite fuel)
       
    76 -- portalDistance=15 (This is the distance portals can travel before fizzling)
       
    77 -- m=3 (load a particular map from the map library of Data/Scripts/TechMaps
       
    78 -- helpDisabled="true" (the help pop-up overlay will be disabled by default)
       
    79 
       
    80 -- when saving data, points for conversion to HWMAP are also generated and placed inside block comments.
       
    81 -- copy paste/these points at the START of a converted HWMAP and then convert the map back to HWMAP format.
       
    82 -- following the above procedure it is then possible to load the map in frontend and play it using a
       
    83 -- script like TechRacer (or HedgeEditor itself) that can interpret the points using InterpretPoints()
       
    84 
       
    85 ---------------------------------------
       
    86 -- DISCLAIMER
       
    87 ---------------------------------------
       
    88 -- well, I really just made this for myself, so it's usage might be a little complicated for others.
       
    89 -- it also probably has a million errors, and has grown rather bloated over time due to the addition of
       
    90 -- more and more features that my initial design didn't take into account.
       
    91 
       
    92 -- anyway, I've tried to make it more user-friendly by including more comments and gradually adding
       
    93 -- some basic guidelines such as those listed above, and also the in-game Help displays for each tool.
       
    94 
       
    95 -----------------------------------------
       
    96 -- GIANT "TO DO" LIST / OTHER NOTES
       
    97 -----------------------------------------
       
    98 
       
    99 -- try to prune waypoint list and portal/ufo fuel in the mission template
       
   100 -- for gamelog extractor
       
   101 
       
   102 -- I should probably check if there are tagged gears on save
       
   103 -- and if there are enable gfOneClanMode so that user can't
       
   104 -- just destroy all hogs to win map.
       
   105 -- (what happens if we lose all our hogs?)
       
   106 
       
   107 -- I might be able to make the flavor text even better (assassinate hogName) by
       
   108 -- checking if there is only 1 hog, etc.
       
   109 
       
   110 -- possibly try show landflag addcaption constantly like we do for superdelete when
       
   111 -- using girders / rubbers.
       
   112 
       
   113 -- check to what extent hog info is preserved on saving (does health/weps really save correctly?)
       
   114 -- atm I think it's only for missions so I don't think it is preserved in core data
       
   115 
       
   116 -- check if we lose a mission when the enemy collects our crate (we should)
       
   117 
       
   118 -- try and find out why we can't save the Theme, that feels really dumb
       
   119 
       
   120 -- How about a weapons profile tool that is used with team ammo
       
   121 -- and then hog identity tool would only be available if gfPerHogAmmo is set
       
   122 
       
   123 -- INVESTIGATE when you can bother to do so
       
   124 -- is airmine still missing anywhere, e.g. the weplist generated FOR THE TEMPLATE SCRIPT
       
   125 
       
   126 -- [high] 	waypoints don't reload yet
       
   127 
       
   128 -- [high] 	look into placing dud/random mines (probably needs a nil value)
       
   129 
       
   130 -- [high] 	add missing weps/utils/gears as they appear
       
   131 --			some gameflags and settings are probably missing, too (diff border types etc)
       
   132 --			some themes are also probably missing: cake, hoggywood?
       
   133 -- 			the ongameinit stuff is probaably missing something akin to numAirMines
       
   134 --			and also probably scriptParam and gravity etc.
       
   135 
       
   136 -- [med] 	add a limited form of save/load within level before mass-output
       
   137 
       
   138 -- [med] 	rework gameflag handling to use the newer API methods (done?)
       
   139 
       
   140 -- [med]	maybe incorporate portal effects / ufo tracking into the template generated script if
       
   141 -- 			you want the missions to use it
       
   142 
       
   143 -- [med]	improve ammo handling (if possible, take more scheme settings into account)
       
   144 -- 			also be sure to generate wep data so crates don't have 0 in them (done?)
       
   145 
       
   146 -- [low] 	match the user picked color to the color array
       
   147 
       
   148 -- [low] 	break up the division of labor of the tools into airstrike, minestrike, napalm, etc.
       
   149 			--[[
       
   150 			girder =		"Girder Placement Mode",
       
   151 			rubber =		"Rubber Placement Mode",
       
   152 
       
   153 			airstrike =		(target sprite) (gear placement)
       
   154 							"Mine Placement Mode",
       
   155 							"Sticky Mine Placement Mode",
       
   156 							"Air Mine Placement Mode",
       
   157 							"Barrel Placement Mode",
       
   158 							"Target Placement Mode",
       
   159 							"Cleaver Placement Mode",
       
   160 
       
   161 			drillstrike =	crate sprite (crate placement mode)
       
   162 							"Health Crate Placement Mode",
       
   163 							"Weapon Crate Placement Mode",
       
   164 							"Utility Crate Placement Mode",
       
   165 
       
   166 
       
   167 			napalm =		arrow sprite (selection/modification/deletion mode)
       
   168 							"Advanced Repositioning Mode",  -- also include a delete
       
   169 							"Tagging Mode",
       
   170 							"Hog Identity Mode",
       
   171 							"Team Identity Mode",
       
   172 							"Health Modification Mode",
       
   173 							"Sprite Testing Mode",
       
   174 							"Sprite Modification Mode",
       
   175 							"Sprite Placement Mode",
       
   176 							"Waypoint Placement Mode"
       
   177 							}]]
       
   178 
       
   179 -- [low]	improve support for ShoppaBalance and ConstructionMode, see ranking)
       
   180 
       
   181 -- [low] 	consider combining landflags
       
   182 
       
   183 -- [low] 	periodically rework the code to make it less terrible (hahahahahaha!)
       
   184 
       
   185 -- [low]	eventually incorporate scripted structures into the editor / mission mode
       
   186 
       
   187 -- [low] 	some kind of support for single team training missions
       
   188 -- 			we could possibly add gfOneClanMode and kill the other team we're playing with?
       
   189 
       
   190 -- [never?]	set all actors to heresurrectible (why did I want this?)
       
   191 
       
   192 -- [never?] more detailed goal tagging and multi-stage triggers
       
   193 
       
   194 -- [never?]	theoretically might be possible to create forts (and other grouped objects)
       
   195 --			that can be mirrored and generated/placed in a big enough space
       
   196 
       
   197 -- [never?]	add a pulsing glow thing for sprites you have selected,
       
   198 --			kind of like the invaders in SpaceInvader (currently they are just displayed as purple)
       
   199 
       
   200 -- [never?] add the thing that would be useful for this editor, but that others might use to cheat
       
   201 
       
   202 -- [never?]	improve "illegal" placement detection (pretty sure should just let people do what they want)
       
   203 
       
   204 -- [never?]	add GUIs for editing ammo, init settings, additional gear attributes
       
   205 -- 			perhaps using precise with timer to enable/disable certain features
       
   206 
       
   207 --[[ gui menu ideas that have long since been abandoned
       
   208 INITIALISATION MENU
       
   209 	--gameFlags, etc
       
   210 
       
   211 	Map
       
   212 	Theme
       
   213 	TurnTime
       
   214 	Explosives
       
   215 	MinesNum
       
   216 	CaseFreq
       
   217 	Delay
       
   218 
       
   219 	HealthCaseProb
       
   220 	HealthCaseAmount
       
   221 	DamagePercent
       
   222 	MinesTime
       
   223 	MineDudPercent
       
   224 	SuddenDeathTurns
       
   225 	WaterRise
       
   226 	HealthDecrease
       
   227 HOG MENU
       
   228 	health
       
   229 	name (can be randomly generated from the list of hog names already in localisation)
       
   230 	poisoned (true/false)
       
   231 	hat
       
   232 	hog level?
       
   233 TEAM MENU
       
   234 	name (can be randomly generated as above?) should there be an array of teams with an array of names
       
   235 	colour
       
   236 	grave
       
   237 	fort
       
   238 	voicepack
       
   239 	flag
       
   240 
       
   241 -- this below stuff is less important
       
   242 STICKY MINE MENU
       
   243 	timer?
       
   244 MINE MENU
       
   245 	timer / dud
       
   246 MEDKIT MENU / EXPLOSIVE MENU
       
   247 	health amount
       
   248 WEP AND UTIL CRATE MENU
       
   249 	contents
       
   250 
       
   251 ----------------------------------------
       
   252 -- MAP IDEAS
       
   253 ----------------------------------------
       
   254 -- try to create a portal race (limit portal distance)
       
   255 -- for portal race, include barriers that you need to drill shoot through to get lazer site crates
       
   256 
       
   257 -- try make a map that uses sinegun to jump between bouncy boxes (not easy until we get better control over landflags)
       
   258 
       
   259 -- how about a mission where you have to trap / freeze all the enemy hogs
       
   260 -- and aren't allowed to kill them?
       
   261 -- can set it on the islands map.
       
   262 -- landgun
       
   263 -- girder
       
   264 -- mudball
       
   265 -- hammer
       
   266 -- seduction? (call a hog who has firepunch into a ditch
       
   267 -- icegun (do this so you can freeze guys in an area and then blowtorch/explode an obstacle)
       
   268 -- jump across a bridge that has been mined and then bat the enemy to the other side.
       
   269 
       
   270 -- possibly the same as part of the above, possibly different, what about a heist mission
       
   271 -- the objective is to steal 3 enemy crates
       
   272 -- the first one you have to fall through an invul tunnel of sticky mines and then parachute.
       
   273 -- the second one you have to drill rocket / portal.
       
   274 -- the third one you have to underwater ufo into, but only after opening it up with an underwater bee.
       
   275 
       
   276 ]]
       
   277 
       
   278 ---------------------------------------------------------
       
   279 -- HEDGE EDITOR, SCRIPT BEGINS (Hey yo, it's about time)
       
   280 ---------------------------------------------------------
       
   281 
       
   282 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
   283 HedgewarsScriptLoad("/Scripts/Tracker.lua")
       
   284 HedgewarsScriptLoad("/Scripts/Params.lua")
       
   285 HedgewarsScriptLoad("/Scripts/TechMaps.lua")
       
   286 
       
   287 -- experimental crap
       
   288 --local destroyMap = false
       
   289 
       
   290 -----------------------------------------
       
   291 -- tracking vars for save/load purposes
       
   292 -----------------------------------------
       
   293 
       
   294 local teamCounter = 0
       
   295 local lastRecordedTeam = ""
       
   296 local hhs = {}
       
   297 
       
   298 local waypointList = {}
       
   299 local girderList = {}
       
   300 local rubberList = {}
       
   301 local spriteList = {}
       
   302 
       
   303 local mineList = {}
       
   304 local sMineList = {}
       
   305 local airMineList = {}
       
   306 local targetList = {}
       
   307 local knifeList = {}
       
   308 local explosivesList = {}
       
   309 local healthCrateList = {}
       
   310 local wepCrateList = {}
       
   311 local utilCrateList = {}
       
   312 local hogDataList = {}
       
   313 local AIHogDataList = {}
       
   314 local hFlagList = {}
       
   315 local previewDataList = {}
       
   316 
       
   317 local shoppaPointList = {}
       
   318 local shoppaPX = {}
       
   319 local shoppaPY = {}
       
   320 local shoppaPR = {}
       
   321 
       
   322 ---------------------------------
       
   323 -- crates are made of this stuff
       
   324 ---------------------------------
       
   325 
       
   326 local atkArray =
       
   327 				{
       
   328 				{amBazooka, 	"amBazooka",		2, 	loc("Bazooka")},
       
   329 				{amBee, 		"amBee",			3, 	loc("Homing Bee")},
       
   330 				{amMortar, 		"amMortar",			21, loc("Mortar")},
       
   331 				{amDrill, 		"amDrill",			28, loc("Drill Rocket")},
       
   332 				{amSnowball, 	"amSnowball",		50, loc("Mudball")},
       
   333 
       
   334 				{amGrenade,		"amGrenade",		0, 	loc("Grenade")},
       
   335 				{amClusterBomb,	"amClusterBomb",	1, 	loc("Cluster Bomb")},
       
   336 				{amMolotov, 	"amMolotov",		39, loc("Molotov Cocktail")},
       
   337 				{amWatermelon, 	"amWatermelon",		25, loc("Watermelon Bomb")},
       
   338 				{amHellishBomb,	"amHellishBomb",	26, loc("Hellish Handgrenade")},
       
   339 				{amGasBomb, 	"amGasBomb",		43, loc("Limburger")},
       
   340 
       
   341 				{amShotgun,		"amShotgun",		4, 	loc("Shotgun")},
       
   342 				{amDEagle,		"amDEagle",			9, 	loc("Desert Eagle")},
       
   343 				{amFlamethrower,"amFlamethrower",	45, loc("Flamethrower")},
       
   344 				{amSniperRifle,	"amSniperRifle",	37, loc("Sniper Rifle")},
       
   345 				{amSineGun, 	"amSineGun",		44, loc("SineGun")},
       
   346 				{amIceGun, 		"amIceGun",			53, loc("Freezer")},
       
   347 				{amLandGun,		"amLandGun",		52, loc("Land Spray")},
       
   348 
       
   349 				{amFirePunch, 	"amFirePunch",		11, loc("Shoryuken")},
       
   350 				{amWhip,		"amWhip",			12, loc("Whip")},
       
   351 				{amBaseballBat, "amBaseballBat",	13, loc("Baseball Bat")},
       
   352 				{amKamikaze, 	"amKamikaze",		22, loc("Kamikaze")},
       
   353 				{amSeduction, 	"amSeduction",		24, loc("Seduction")},
       
   354 				{amHammer,		"amHammer",			47, loc("Hammer")},
       
   355 
       
   356 				{amMine, 		"amMine",			8, 	loc("Mine")},
       
   357 				{amDynamite, 	"amDynamite",		10, loc("Dynamite")},
       
   358 				{amCake, 		"amCake",			23, loc("Cake")},
       
   359 				{amBallgun, 	"amBallgun",		29, loc("Ballgun")},
       
   360 				{amRCPlane,		"amRCPlane",		30, loc("RC Plane")},
       
   361 				{amSMine,		"amSMine",			46, loc("Sticky Mine")},
       
   362 
       
   363 				{amAirAttack,	"amAirAttack",		15, loc("Air Attack")},
       
   364 				{amMineStrike,	"amMineStrike",		16, loc("Mine Strike")},
       
   365 				{amDrillStrike,	"amDrillStrike",	49, loc("Drill Strike")},
       
   366 				{amAirMine,		"amAirMine",		56, loc("Air Mine")},
       
   367 				{amNapalm, 		"amNapalm",			27, loc("Napalm")},
       
   368 				{amPiano,		"amPiano",			42, loc("Piano Strike")},
       
   369 
       
   370 				{amKnife,		"amKnife",			54, loc("Cleaver")},
       
   371 
       
   372 				{amBirdy,		"amBirdy",			40, loc("Birdy")}
       
   373 
       
   374 				}
       
   375 
       
   376 local utilArray =
       
   377 				{
       
   378 				{amBlowTorch, 		"amBlowTorch",		17, loc("BlowTorch")},
       
   379 				{amPickHammer,		"amPickHammer",		5, 	loc("PickHammer")},
       
   380 				{amGirder, 			"amGirder",			18, loc("Girder")},
       
   381 				{amRubber, 			"amRubber",			55, loc("Rubber")},
       
   382 				{amPortalGun,		"amPortalGun",		41, loc("Personal Portal Device")},
       
   383 
       
   384 				{amRope, 			"amRope",			7, 	loc("Rope")},
       
   385 				{amParachute, 		"amParachute",		14, loc("Parachute")},
       
   386 				{amTeleport,		"amTeleport",		19, loc("Teleport")},
       
   387 				{amJetpack,			"amJetpack",		38, loc("Flying Saucer")},
       
   388 
       
   389 				{amInvulnerable,	"amInvulnerable",	33, loc("Invulnerable")},
       
   390 				{amLaserSight,		"amLaserSight",		35, loc("Laser Sight")},
       
   391 				{amVampiric,		"amVampiric",		36, loc("Vampirism")},
       
   392 
       
   393 				{amLowGravity, 		"amLowGravity",		31, loc("Low Gravity")},
       
   394 				{amExtraDamage, 	"amExtraDamage",	32, loc("Extra Damage")},
       
   395 				{amExtraTime,		"amExtraTime",		34, loc("Extra Time")},
       
   396 
       
   397 				{amResurrector, 	"amResurrector",	48, loc("Resurrector")},
       
   398 				{amTardis, 			"amTardis",			51, loc("Tardis")},
       
   399 
       
   400 				{amSwitch,			"amSwitch",			20, loc("Switch Hog")}
       
   401 				}
       
   402 
       
   403 				--skiphog is 6
       
   404 
       
   405 ----------------------------
       
   406 -- hog and map editing junk
       
   407 ----------------------------
       
   408 
       
   409 local preMadeTeam = 	{
       
   410 
       
   411 				{
       
   412 				"Clowns",
       
   413 				{"WhySoSerious","clown-copper","clown-crossed","clown","Joker"},
       
   414 				{"Baggy","Bingo","Bobo","Bozo","Buster","Chester","Copper","Heckles","Giggles","Jingo","Molly","Loopy","Patches","Tatters"},
       
   415 				"R","cm_birdy","Mobster","Rubberduck","Castle"
       
   416 				},
       
   417 
       
   418 				{
       
   419 				"Street Fighters",
       
   420 				{"sf_balrog","sf_blanka","sf_chunli","sf_guile","sf_honda","sf_ken","sf_ryu","sf_vega"},
       
   421 				{"Balrog","Blanka","Chunli","Guile","Honda","Ken","Ryu","Vega"},
       
   422 				"F","cm_balrog","Surfer","dragonball","Castle"
       
   423 				},
       
   424 
       
   425 				{
       
   426 				"Cybernetic Empire",
       
   427 				{"cyborg1","cyborg2"},
       
   428 				{"Unit 189","Unit 234","Unit 333","Unit 485","Unit 527","Unit 638","Unit 709","Unit 883"},
       
   429 				"R","cm_binary","Robot","Grave","Castle"
       
   430 				},
       
   431 
       
   432 				{
       
   433 				"Color Squad",
       
   434 				{"hair_blue","hair_green","hair_red","hair_yellow","hair_purple","hair_grey","hair_orange","hair_pink"},
       
   435 				{"Blue","Green","Red","Yellow","Purple","Grey","Orange","Pink"},
       
   436 				"F","cm_birdy","Singer","Grave","Castle"
       
   437 				},
       
   438 
       
   439 				{
       
   440 				"Fruit",
       
   441 				{"fr_apple","fr_banana","fr_lemon","fr_orange","fr_pumpkin","fr_tomato"},
       
   442 				{"Juicy","Squishy","Sweet","Sour","Bitter","Ripe","Rotten","Fruity"},
       
   443 				"R","cm_mog","Default","Cherry","Castle"
       
   444 				},
       
   445 
       
   446 				{
       
   447 				"The Police",
       
   448 				{"bobby","bobby2v","policecap","policegirl","royalguard"},
       
   449 				{"Hightower","Lassard","Callahan","Jones","Harris","Thompson","Mahoney","Hooks","Tackleberry"},
       
   450 				"R","cm_star","British","Statue","Castle"
       
   451 				},
       
   452 
       
   453 				{
       
   454 				"The Ninja-Samurai Alliance",
       
   455 				{"NinjaFull","NinjaStraight","NinjaTriangle","Samurai","StrawHat","StrawHatEyes","StrawHatFacial","naruto"},
       
   456 				{"Bushi","Tatsujin","Itami","Arashi","Shinobi","Ukemi","Godai","Kenshi","Ninpo"},
       
   457 				"R","japan","Default","octopus","Castle"
       
   458 				},
       
   459 
       
   460 				{
       
   461 				"Pokemon",
       
   462 				{"poke_ash","poke_charmander","poke_chikorita","poke_jigglypuff","poke_lugia","poke_mudkip","poke_pikachu","poke_slowpoke","poke_squirtle","poke_voltorb"},
       
   463 				{"Ash","Charmander","Chikorita","Jigglypuff","Lugia","Mudkip","Pikachu","Slowpoke","Squirtle","Voltorb"},
       
   464 				"FR","cm_pokemon","Default","pokeball","Castle"
       
   465 				},
       
   466 
       
   467 				{
       
   468 				"The Zoo",
       
   469 				{"zoo_Bat","zoo_Beaver","zoo_Bunny","zoo_Deer","zoo_Hedgehog","zoo_Moose","zoo_Pig","zoo_Porkey","zoo_Sheep","zoo_chicken","zoo_elephant","zoo_fish","zoo_frog","zoo_snail","zoo_turtle"},
       
   470 				{"Batty","Tails","Bunny","Deer","Spikes","Horns","Bacon","Porkey","Sheepy","Chicken","Trunks","Fishy","Legs","Slimer","Roshi"},
       
   471 				"FR","cm_hurrah","Default","Bone","Castle"
       
   472 				},
       
   473 
       
   474 				{
       
   475 				"The Devs",
       
   476 				{"ushanka","zoo_Sheep","bb_bob","Skull","poke_mudkip","lambda","WizardHat","sf_ryu","android","fr_lemon","mp3"},
       
   477 				{"unC0Rr", "sheepluva", "nemo", "mikade", "koda", "burp","HeneK","Tiyuri","Xeli","Displacer","szczur"},
       
   478 				"FR","hedgewars","Classic","Statue","Castle"
       
   479 				},
       
   480 
       
   481 				{
       
   482 				"Mushroom Kingdom",
       
   483 				{"sm_daisy","sm_luigi","sm_mario","sm_peach","sm_toad","sm_wario"},
       
   484 				{"Daisy","Luigi","Mario","Princess Peach","Toad","Wario"},
       
   485 				"FR","cm_birdy","Default","Badger","Castle"
       
   486 				},
       
   487 
       
   488 				{
       
   489 				"Pirates",
       
   490 				{"pirate_jack","pirate_jack_bandana"},
       
   491 				{"Rusted Diego","Fuzzy Beard","Al.Kaholic","Morris","Yumme Gunpowder","Cutlass Cain","Jim Morgan","Silver","Dubloon Devil","Ugly Mug","Fair Wind","Scallywag","Salty Dog","Bearded Beast","Timbers","Both Barrels","Jolly Roger"},
       
   492 				"R","cm_pirate","Pirate","chest","Castle"
       
   493 				},
       
   494 
       
   495 				{
       
   496 				"Gangsters",
       
   497 				{"Moustache","Cowboy","anzac","Bandit","thug","Jason","NinjaFull","chef"},
       
   498 				{"The Boss","Jimmy","Frankie","Morris","Mooney","Knives","Tony","Meals"},
       
   499 				"F","cm_anarchy","Mobster","deadhog","Castle"
       
   500 				},
       
   501 
       
   502 
       
   503 				{
       
   504 				"Twenty-Twenty",
       
   505 				{"Glasses","lambda","SunGlasses","Sniper","Terminator_Glasses","Moustache_glasses","doctor","punkman","rasta"},
       
   506 				{"Specs","Speckles","Spectator","Glasses","Glassy","Harry Potter","Goggles","Clark Kent","Goggs","Lightbender","Specs Appeal","Four Eyes"},
       
   507 				"R","cm_face","Default","eyecross","Castle"
       
   508 				},
       
   509 
       
   510 
       
   511 				{
       
   512 				"Monsters",
       
   513 				{"Skull","Jason","ShaggyYeti","Zombi","cyclops","Mummy","hogpharoah","vampirichog"},
       
   514 				{"Bones","Jason","Yeti","Zombie","Old One Eye","Ramesses","Xerxes","Count Hogula"},
       
   515 				"FR","cm_vampire","Default","octopus","Castle"
       
   516 				},
       
   517 
       
   518 				{
       
   519 				"The Iron Curtain",
       
   520 				{"ushanka","war_sovietcomrade1","war_sovietcomrade1","ushanka"},
       
   521 				{"Alex","Sergey","Vladimir","Andrey","Dimitry","Ivan","Oleg","Kostya","Anton","Eugene"},
       
   522 				"R","cm_soviet","Russian","skull","Castle"
       
   523 				},
       
   524 
       
   525 				{
       
   526 				"Desert Storm",
       
   527 				{"war_desertofficer","war_desertgrenadier1","war_desertmedic","war_desertsapper1","war_desertgrenadier2","war_desertgrenadier4","war_desertsapper2","war_desertgrenadier5"},
       
   528 				{"Brigadier Briggs","Lt. Luke","Sgt. Smith","Corporal Calvin","Frank","Joe","Sam","Donald"},
       
   529 				"F","cm_birdy","Default","Grave","Castle"
       
   530 				},
       
   531 
       
   532 				--{
       
   533 				--"Sci-Fi",
       
   534 				--{"scif_2001O","scif_2001Y","scif_BrainSlug","scif_BrainSlug2","scif_Geordi","scif_SparkssHelmet","scif_cosmonaut","scif_cyberpunk","scif_swDarthvader","scif_swStormtrooper"},
       
   535 				--{},
       
   536 				--"R","cm_birdy","Default","Grave","Castle"
       
   537 				--},
       
   538 
       
   539 
       
   540 
       
   541 
       
   542 				--
       
   543 
       
   544 				--{
       
   545 				--,
       
   546 				--{},
       
   547 				--{},
       
   548 				--"R","cm_birdy","Default","Grave","Castle"
       
   549 				--},
       
   550 
       
   551 				-- don't forget new additions need to be added to:
       
   552 				--pMode = {"Clowns","Street Fighters","Cybernetic Empire","Color Squad","Fruit","The Police","The Ninja-Samurai Alliance","Pokemon","The Zoo","The Devs","The Hospital"}
       
   553 				-- but maybe we can just get the size of this array and automatically generate a list instead
       
   554 
       
   555 
       
   556 				{
       
   557 				"The Hospital",
       
   558 				{"doctor","nurse","war_britmedic","war_desertmedic","war_germanww2medic"},
       
   559 				{"Dr. Blackwell","Dr. Drew","Dr. Harvey","Dr. Crushing","Dr. Jenner","Dr. Barnard","Dr. Parkinson","Dr. Banting","Dr. Horace","Dr. Hollows","Dr. Jung"},
       
   560 				"R","cm_birdy","Default","heart","Castle"
       
   561 				}
       
   562 
       
   563 				}
       
   564 
       
   565 
       
   566 --local menuArray =	{
       
   567 --			"Initialisation Menu", "Team Menu"
       
   568 --			}
       
   569 
       
   570 --local hatArray = 	{hahahaha, you're joking, right?}
       
   571 --[[well, here are most of them as vaguely ordered by theme, there may be some duplicates
       
   572 NoHat,
       
   573 NinjaFull,NinjaStraight,NinjaTriangle,Samurai,StrawHat,StrawHatEyes,StrawHatFacial,naruto
       
   574 sm_daisy,sm_luigi,sm_mario,sm_peach,sm_toad,sm_wario,
       
   575 ShortHair_Black,ShortHair_Brown,ShortHair_Grey,ShortHair_Red,ShortHair_Yellow
       
   576 hair_blue,hair_green,hair_red,hair_yellow,hair_purple,hair_grey,hair_orange,hair_pink
       
   577 Skull,Jason,ShaggyYeti,Zombi,cyclops,Mummy,hogpharoah,vampirichog
       
   578 cap_blue,cap_red,cap_green,cap_junior,cap_yellow,cap_thinking
       
   579 WhySoSerious,clown-copper,clown-crossed,clown,Joker
       
   580 bobby,bobby2v,policecap,policegirl,royalguard,
       
   581 spcartman,spstan,spkenny,spkyle,
       
   582 sf_balrog,sf_blanka,sf_blankatoothless,sf_chunli,sf_guile,sf_honda,sf_ken,sf_ryu,sf_vega
       
   583 Glasses,lambda,SunGlasses,Terminator_Glasses,Moustache_glasses
       
   584 Laminaria,Dragon,
       
   585 cyborg1,cyborg2,
       
   586 dish_Ladle,dish_SauceBoatSilver,dish_Teacup,dish_Teapot
       
   587 laurel,flag_french,flag_germany,flag_italy,flag_usa
       
   588 fr_apple,fr_banana,fr_lemon,fr_orange,fr_pumpkin,fr_tomato
       
   589 doctor,nurse,war_britmedic,war_desertmedic,war_germanww2medic,
       
   590 poke_ash,poke_charmander,poke_chikorita,poke_jigglypuff,
       
   591 poke_lugia,poke_mudkip,poke_pikachu,poke_slowpoke,poke_squirtle,poke_voltorb
       
   592 zoo_Bat,zoo_Beaver,zoo_Bunny,zoo_Deer,zoo_Hedgehog,zoo_Moose,zoo_Pig,zoo_Porkey,zoo_Sheep
       
   593 zoo_chicken,zoo_elephant,zoo_fish,zoo_frog,zoo_snail,zoo_turtle
       
   594 bushhider,cratehider,Disguise,
       
   595 tf_demoman,tf_scout,Sniper,
       
   596 Bandit,thug,anzac,Cowboy
       
   597 pirate_jack,pirate_jack_bandana,
       
   598 tiara,crown,royalguard
       
   599 punkman,Einstein,
       
   600 sth_Amy,sth_AmyClassic,sth_Eggman,sth_Knux,sth_Metal,sth_Shadow,sth_Sonic,sth_SonicClassic,sth_Super,sth_Tails
       
   601 vc_gakupo,vc_gumi,vc_kaito,vc_len,vc_luka,vc_meiko,vc_miku,vc_rin
       
   602 touhou_chen,touhou_marisa,touhou_patchouli,touhou_remelia,touhou_suwako,touhou_yukari,
       
   603 TeamHeadband,TeamSoldier,TeamTopHat,TeamWheatley,cap_team,hair_team,
       
   604 bb_bob,bb_bub,bb_cororon,bb_kululun,bubble,
       
   605 Viking,spartan,swordsmensquire,knight,dwarf,
       
   606 WizardHat,tophats,pinksunhat,ushanka,mexicansunbrero,HogInTheHat,
       
   607 4gsuif,
       
   608 AkuAku,
       
   609 noface,
       
   610 Coonskin3,
       
   611 Dan,
       
   612 Dauber,
       
   613 Eva_00b,Eva_00y,
       
   614 Evil,InfernalHorns,angel,
       
   615 Gasmask,
       
   616 IndianChief,Cowboy,
       
   617 MegaHogX,
       
   618 Meteorhelmet,
       
   619 Moustache,
       
   620 OldMan,
       
   621 Pantsu,
       
   622 Plunger,
       
   623 RSR,
       
   624 Rain,stormcloud,DayAndNight,
       
   625 chuckl,Rambo,RobinHood,
       
   626 Santa,snowhog,ShaggyYeti,eastertop,
       
   627 Sleepwalker,
       
   628 SparkleSuperFun,
       
   629 SunWukong,
       
   630 android,
       
   631 beefeater,
       
   632 car,
       
   633 chef,
       
   634 constructor,
       
   635 footballhelmet,
       
   636 judo,
       
   637 lamp,
       
   638 mechanicaltoy,
       
   639 mickey_ears,
       
   640 snorkel,
       
   641 quotecap,
       
   642 rasta,
       
   643 
       
   644 metalband,
       
   645 kiss_criss,kiss_frehley,kiss_simmons,kiss_stanley,mp3,Elvis
       
   646 mv_Spidey,mv_Venom,
       
   647 ntd_Falcon,ntd_Kirby,ntd_Link,ntd_Samus,
       
   648 scif_2001O,scif_2001Y,scif_BrainSlug,scif_BrainSlug2,scif_Geordi,scif_SparkssHelmet,
       
   649 scif_cosmonaut,scif_cyberpunk,scif_swDarthvader,scif_swStormtrooper,
       
   650 war_UNPeacekeeper01,war_UNPeacekeeper02,
       
   651 war_airwarden02,war_airwarden03,
       
   652 war_americanww2helmet,
       
   653 war_britmedic,war_britpthhelmet,war_britsapper,
       
   654 war_desertgrenadier1,war_desertgrenadier2,war_desertgrenadier4,war_desertgrenadier5,war_desertmedic,
       
   655 war_desertofficer,war_desertsapper1,war_desertsapper2,
       
   656 war_frenchww1gasmask,war_frenchww1helmet,
       
   657 war_germanww1helmet2,war_germanww1tankhelm,war_germanww2medic,war_germanww2pith,
       
   658 war_grenadier1,war_trenchgrenadier1,war_trenchgrenadier2,war_trenchgrenadier3,
       
   659 war_plainpith,
       
   660 war_sovietcomrade1,war_sovietcomrade2,
       
   661 war_trenchfrench01,war_trenchfrench02,]]
       
   662 
       
   663 local colorArray = 	{
       
   664 					--{0xff0000ff, "0xff0000ff", "Red"}, -- look up hw red
       
   665 					{0xff4980c1, "0xff4980c1", "Blue"},
       
   666 					{0xff1de6ba, "0xff1de6ba", "Teal"},
       
   667 					{0xffb541ef, "0xffb541ef", "Purple"},
       
   668 					{0xffe55bb0, "0xffe55bb0", "Pink"},
       
   669 					{0xff20bf00, "0xff20bf00", "Green"},
       
   670 					{0xfffe8b0e, "0xfffe8b0e", "Orange"},
       
   671 					{0xff5f3605, "0xff5f3605", "Brown"},
       
   672 					{0xffffff01, "0xffffff01", "Yellow"}
       
   673 					}
       
   674 
       
   675 local graveArray = 	{
       
   676 					"Badger", "Bone", "bp2", "bubble", "Cherry",
       
   677 					"chest", "coffin", "deadhog", "dragonball", "Duck2",
       
   678 					"Earth", "Egg", "eyecross", "Flower", "Ghost",
       
   679 					"Grave", "heart", "money", "mouton1", "octopus",
       
   680 					"plant2", "plant3", "Plinko", "pokeball", "pyramid",
       
   681 					"ring", "Rip", "Rubberduck", "Simple", "skull",
       
   682 					"star", "Status"
       
   683 					}
       
   684 
       
   685 local voiceArray = 	{
       
   686 					"British","Classic","Default","Default_es","Default_uk",
       
   687 					"HillBilly","Mobster","Pirate","Robot","Russian","Singer",
       
   688 					"Surfer"
       
   689 					}
       
   690 
       
   691 local fortArray =	{
       
   692 					"Cake", "Castle", "Earth", "EvilChicken", "Flowerhog",
       
   693 					"Hydrant", "Lego", "Plane", "Statue", "Tank",
       
   694 					"UFO", "Wood"
       
   695 					}
       
   696 
       
   697 -- non-exhaustive list of flags, feel free to choose others
       
   698 local flagArray = 	{
       
   699 					"cm_binary", "cm_birdy", "cm_earth", "cm_pirate", "cm_star",
       
   700 					"cm_hurrah", "cm_hax0r", "cm_balrog", "cm_spider", "cm_eyeofhorus"
       
   701 					}
       
   702 
       
   703 local gameFlagList =	{
       
   704 			{"gfForts", false, gfForts},
       
   705 			{"gfMultiWeapon", false, gfMultiWeapon},
       
   706 			{"gfBorder", false, gfBorder},
       
   707 			{"gfSolidLand", false, gfSolidLand},
       
   708 			{"gfDivideTeams", false, gfDivideTeams},
       
   709 			{"gfLowGravity", false, gfLowGravity},
       
   710 			{"gfLaserSight", true, gfLaserSight},
       
   711 			{"gfInvulnerable", false, gfInvulnerable},
       
   712 			{"gfMines", false, gfMines},
       
   713 			{"gfVampiric", false, gfVampiric},
       
   714 			{"gfKarma", false, gfKarma},
       
   715 			{"gfArtillery", false, gfArtillery},
       
   716 			{"gfOneClanMode", false, gfOneClanMode},
       
   717 			{"gfRandomOrder", false, gfRandomOrder},
       
   718 			{"gfKing", false, gfKing},
       
   719 			{"gfPlaceHog", false, gfPlaceHog},
       
   720 			{"gfSharedAmmo", false, gfSharedAmmo},
       
   721 			{"gfDisableGirders", false, gfDisableGirders},
       
   722 			{"gfExplosives", false, gfExplosives},
       
   723 			{"gfDisableLandObjects", false, gfDisableLandObjects},
       
   724 			{"gfAISurvival", false, gfAISurvival},
       
   725 			{"gfInfAttack", true, gfInfAttack},
       
   726 			{"gfResetWeps", false, gfResetWeps},
       
   727 			{"gfResetHealth", false, gfResetHealth},
       
   728 			{"gfPerHogAmmo", false, gfPerHogAmmo},
       
   729 			{"gfDisableWind", false, gfDisableWind},
       
   730 			{"gfMoreWind", false, gfMoreWind},
       
   731 			{"gfTagTeam", false, gfTagTeam}
       
   732 			}
       
   733 
       
   734 local themeList = 	{"Art", "Bamboo", "Bath", --[["Blox",]] "Brick", "Cake", "Castle", "Cave", "Cheese",
       
   735 		"Christmas", "City", "Compost", --[["CrazyMission", "Deepspace",]] "Desert", "Earthrise",
       
   736 		--[["Eyes",]] "Freeway", "Golf", "Halloween", "Hell", --[["HogggyWood",]] "Island", "Jungle", "Nature",
       
   737 		"Olympics", "Planes", "Sheep", "Snow", "Stage", "Underwater"
       
   738 		}
       
   739 
       
   740 local mapList = 	{
       
   741 		"Bamboo", "BambooPlinko", "Basketball", "Bath", "Blizzard", "Blox", "Bubbleflow",
       
   742 		"Battlefield", "Cake", "Castle", "Cave", "Cheese", "Cogs", "Control", "Earthrise",
       
   743 		"Eyes", "Hammock", "Hedgelove", "Hedgewars", "Hogville", "Hydrant", "Islands",
       
   744 		"Knockball", "Lonely_Island", "Mushrooms", "Octorama", "PirateFlag",
       
   745 		"Plane", "Ropes", "Ruler", "Sheep", "ShoppaKing", "Sticks", "Trash", "Tree",
       
   746 		"TrophyRace"
       
   747 		}
       
   748 
       
   749 --local spriteArray = {
       
   750 --					{sprBigDigit,			"sprBigDigit",			0}
       
   751 --					}
       
   752 
       
   753 local spriteIDArray = {sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
       
   754 sprLag, sprArrow, sprBazookaShell, sprTargetP, sprBee,
       
   755 sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
       
   756 sprMineOn, sprMineDead, sprCase, sprFAid, sprDynamite, sprPower,
       
   757 sprClusterBomb, sprClusterParticle, sprFlame,
       
   758 sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR,
       
   759 sprAMSlot, sprAMAmmos, sprAMAmmosBW, sprAMSlotKeys, sprAMCorners,
       
   760 sprFinger, sprAirBomb, sprAirplane, sprAmAirplane, sprAmGirder,
       
   761 sprHHTelepMask, sprSwitch, sprParachute, sprTarget, sprRopeNode,
       
   762 sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
       
   763 
       
   764 sprFireButton, sprArrowUp, sprArrowDown, sprArrowLeft, sprArrowRight,
       
   765 sprJumpWidget, sprAMWidget, sprPauseButton, sprTimerButton, sprTargetButton,
       
   766 
       
   767 sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
       
   768 sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
       
   769 sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath,
       
   770 sprShotgun, sprDEagle, sprHHIdle, sprMortar, sprTurnsLeft,
       
   771 sprKamikaze, sprWhip, sprKowtow, sprSad, sprWave,
       
   772 sprHurrah, sprLemonade, sprShrug, sprJuggle, sprExplPart, sprExplPart2,
       
   773 sprCakeWalk, sprCakeDown, sprWatermelon,
       
   774 sprEvilTrace, sprHellishBomb, sprSeduction, sprDress,
       
   775 sprCensored, sprDrill, sprHandDrill, sprHandBallgun, sprBalls,
       
   776 sprPlane, sprHandPlane, sprUtility, sprInvulnerable, sprVampiric, sprGirder,
       
   777 sprSpeechCorner, sprSpeechEdge, sprSpeechTail,
       
   778 sprThoughtCorner, sprThoughtEdge, sprThoughtTail,
       
   779 sprShoutCorner, sprShoutEdge, sprShoutTail,
       
   780 sprSniperRifle, sprBubbles, sprJetpack, sprHealth, sprHandMolotov, sprMolotov,
       
   781 sprSmoke, sprSmokeWhite, sprShell, sprDust, sprSnowDust, sprExplosives, sprExplosivesRoll,
       
   782 sprAmTeleport, sprSplash, sprDroplet, sprBirdy, sprHandCake, sprHandConstruction,
       
   783 sprHandGrenade, sprHandMelon, sprHandMortar, sprHandSkip, sprHandCluster,
       
   784 sprHandDynamite, sprHandHellish, sprHandMine, sprHandSeduction, sprHandVamp,
       
   785 sprBigExplosion, sprSmokeRing, sprBeeTrace, sprEgg, sprTargetBee, sprHandBee,
       
   786 sprFeather, sprPiano, sprHandSineGun, sprPortalGun, sprPortal,
       
   787 sprCheese, sprHandCheese, sprHandFlamethrower, sprChunk, sprNote,
       
   788 sprSMineOff, sprSMineOn, sprHandSMine, sprHammer,
       
   789 sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb,
       
   790 sprBulletHit, sprSnowball, sprHandSnowball, sprSnow,
       
   791 sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis,
       
   792 sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun, sprFrozenHog, sprAmRubber, sprBoing}
       
   793 
       
   794 
       
   795 local spriteTextArray = {"sprWater", "sprCloud", "sprBomb", "sprBigDigit", "sprFrame",
       
   796 "sprLag", "sprArrow", "sprBazookaShell", "sprTargetP", "sprBee",
       
   797 "sprSmokeTrace", "sprRopeHook", "sprExplosion50", "sprMineOff",
       
   798 "sprMineOn", "sprMineDead", "sprCase", "sprFAid", "sprDynamite", "sprPower",
       
   799 "sprClusterBomb", "sprClusterParticle", "sprFlame", "sprHorizont",
       
   800 "sprHorizontL", "sprHorizontR", "sprSky", "sprSkyL", "sprSkyR", "sprAMSlot",
       
   801 "sprAMAmmos", "sprAMAmmosBW", "sprAMSlotKeys", "sprAMCorners", "sprFinger",
       
   802 "sprAirBomb", "sprAirplane", "sprAmAirplane", "sprAmGirder", "sprHHTelepMask",
       
   803  "sprSwitch", "sprParachute", "sprTarget", "sprRopeNode", "sprQuestion",
       
   804  "sprPowerBar", "sprWindBar", "sprWindL", "sprWindR", "sprFireButton",
       
   805  "sprArrowUp", "sprArrowDown", "sprArrowLeft", "sprArrowRight", "sprJumpWidget",
       
   806  "sprAMWidget", "sprPauseButton", "sprTimerButton", "sprTargetButton",
       
   807  "sprFlake", "sprHandRope", "sprHandBazooka", "sprHandShotgun",
       
   808  "sprHandDEagle", "sprHandAirAttack", "sprHandBaseball", "sprPHammer",
       
   809  "sprHandBlowTorch", "sprBlowTorch", "sprTeleport", "sprHHDeath", "sprShotgun",
       
   810  "sprDEagle", "sprHHIdle", "sprMortar", "sprTurnsLeft", "sprKamikaze", "sprWhip",
       
   811  "sprKowtow", "sprSad", "sprWave", "sprHurrah", "sprLemonade", "sprShrug",
       
   812  "sprJuggle", "sprExplPart", "sprExplPart2", "sprCakeWalk", "sprCakeDown",
       
   813  "sprWatermelon", "sprEvilTrace", "sprHellishBomb", "sprSeduction", "sprDress",
       
   814  "sprCensored", "sprDrill", "sprHandDrill", "sprHandBallgun", "sprBalls", "sprPlane",
       
   815  "sprHandPlane", "sprUtility", "sprInvulnerable", "sprVampiric", "sprGirder",
       
   816  "sprSpeechCorner", "sprSpeechEdge", "sprSpeechTail", "sprThoughtCorner",
       
   817  "sprThoughtEdge", "sprThoughtTail", "sprShoutCorner", "sprShoutEdge",
       
   818  "sprShoutTail", "sprSniperRifle", "sprBubbles", "sprJetpack", "sprHealth",
       
   819  "sprHandMolotov", "sprMolotov", "sprSmoke", "sprSmokeWhite", "sprShell", "sprDust",
       
   820  "sprSnowDust", "sprExplosives", "sprExplosivesRoll", "sprAmTeleport", "sprSplash",
       
   821  "sprDroplet", "sprBirdy", "sprHandCake", "sprHandConstruction", "sprHandGrenade",
       
   822  "sprHandMelon", "sprHandMortar", "sprHandSkip", "sprHandCluster", "sprHandDynamite",
       
   823  "sprHandHellish", "sprHandMine", "sprHandSeduction", "sprHandVamp", "sprBigExplosion",
       
   824  "sprSmokeRing", "sprBeeTrace", "sprEgg", "sprTargetBee", "sprHandBee", "sprFeather",
       
   825  "sprPiano", "sprHandSineGun", "sprPortalGun", "sprPortal", "sprCheese", "sprHandCheese",
       
   826  "sprHandFlamethrower", "sprChunk", "sprNote", "sprSMineOff", "sprSMineOn", "sprHandSMine",
       
   827  "sprHammer", "sprHandResurrector", "sprCross", "sprAirDrill", "sprNapalmBomb", "sprBulletHit",
       
   828  "sprSnowball", "sprHandSnowball", "sprSnow", "sprSDFlake", "sprSDWater", "sprSDCloud",
       
   829  "sprSDSplash", "sprSDDroplet", "sprTardis", "sprSlider", "sprBotlevels", "sprHandKnife",
       
   830  "sprKnife", "sprStar", "sprIceTexture", "sprIceGun", "sprFrozenHog", "sprAmRubber", "sprBoing"}
       
   831 
       
   832  local reducedSpriteIDArray = {
       
   833   sprBigDigit, sprTarget, sprKowtow, sprBee, sprAmGirder, sprExplosion50, sprGirder,sprCustom1,sprCustom2
       
   834   }
       
   835 
       
   836   local reducedSpriteTextArray = {
       
   837   "sprBigDigit", "sprTarget", "sprKowtow", "sprBee", "sprAmGirder", "sprExplosion50", "sprGirder","sprCustom1","sprCustom2"
       
   838   }
       
   839 
       
   840 ----------------------------
       
   841 -- placement shite
       
   842 ----------------------------
       
   843 
       
   844 local landType = 0
       
   845 local superDelete = false
       
   846 local ufoGear = nil
       
   847 ufoFuel = 0
       
   848 mapID = 1
       
   849 local portalDistance = 5000/5
       
   850 local helpDisabled = false  --determines whether help popups pop up
       
   851 local CG = nil -- this is the visual gear displayed at CursorX, CursorY
       
   852 local crateSprite = nil-- this is a visual gear aid for crate placement
       
   853 local tSpr = {}
       
   854 
       
   855 local cGear = nil -- detects placement of girders and objects (using airattack)
       
   856 local curWep = amNothing
       
   857 local leftHeld = false
       
   858 local rightHeld = false
       
   859 local preciseOn = false
       
   860 
       
   861 -- primary placement categories
       
   862 local cIndex = 1 -- category index
       
   863 local cat = 	{
       
   864 				loc("Girder Placement Mode"),
       
   865 				loc("Rubber Placement Mode"),
       
   866 				loc("Mine Placement Mode"),
       
   867 				loc("Sticky Mine Placement Mode"),
       
   868 				loc("Air Mine Placement Mode"),
       
   869 				loc("Barrel Placement Mode"),
       
   870 				loc("Health Crate Placement Mode"),
       
   871 				loc("Weapon Crate Placement Mode"),
       
   872 				loc("Utility Crate Placement Mode"),
       
   873 				loc("Target Placement Mode"),
       
   874 				loc("Cleaver Placement Mode"),
       
   875 				loc("Advanced Repositioning Mode"),
       
   876 				loc("Tagging Mode"),
       
   877 				loc("Hog Identity Mode"),
       
   878 				loc("Team Identity Mode"),
       
   879 				loc("Health Modification Mode"),
       
   880 				--loc("Sprite Testing Mode"),
       
   881 				loc("Sprite Placement Mode"),
       
   882 				loc("Sprite Modification Mode"),
       
   883 				loc("Waypoint Placement Mode")
       
   884 				}
       
   885 
       
   886 
       
   887 local pMode = {}	-- pMode contains custom subsets of the main categories
       
   888 local pIndex = 1
       
   889 
       
   890 local genTimer = 0
       
   891 
       
   892 local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used
       
   893 
       
   894 local placedX = {} -- x coord of placed object
       
   895 local placedY = {} -- y coord of placed object
       
   896 local placedSpec = {} -- this is different depending on what was placed, for mines it is their time, for crates it is their content, (for girders/rubbers it used to be their rotation, and for sprites, their name, but this has been moved to different variables to allow more complex / smooth editing)
       
   897 --local placedSuperSpec = {} -- used to be used by girders/rubbers/sprites for their landFlag
       
   898 local placedType = {} -- what kind of object was placed: mine, crate, girder, rubber, barrel, etc.
       
   899 
       
   900 local placedTint = {} -- only girders/rubbers/sprites use this, it is their tint / colouration
       
   901 local placedSprite = {} -- what sprite was placed
       
   902 local placedFrame = {} -- what frame of sprite was placed (rotation for girders / rubber)
       
   903 local placedLandFlags = {}
       
   904 local placedHWMapFlag = {} -- this is what HWMapConverter uses
       
   905 local placedCount = 0 -- do we really need this?
       
   906 
       
   907 local sSprite -- sprite overlay that glows to show selected sprites
       
   908 local sCirc -- circle that appears around selected gears
       
   909 local sGear = nil
       
   910 local closestDist
       
   911 local closestGear = nil
       
   912 local closestSpriteID = nil
       
   913 
       
   914 ------------------------
       
   915 -- menu shite (more or less unused currently)
       
   916 ------------------------
       
   917 --local menuEnabled = false
       
   918 --local menuIndex = 1
       
   919 --local menu = {}
       
   920 --local subMenu = {}
       
   921 --local sMI = 1 -- sub menu index
       
   922 --local preMenuCfg
       
   923 --local postMenuCfg
       
   924 --local initMenu	=	{
       
   925 --					{"Selected Menu",	"Initialisation Menu"},
       
   926 --					{"List of Gameflags",	""},
       
   927 --					{"List of Gameflags",	""}
       
   928 --					}
       
   929 
       
   930 ------------------------
       
   931 -- SOME GENERAL METHODS
       
   932 ------------------------
       
   933 
       
   934 function BoolToString(boo)
       
   935 	if boo == true then
       
   936 		return("true")
       
   937 	else
       
   938 		return("false")
       
   939 	end
       
   940 end
       
   941 
       
   942 function GetDistFromGearToXY(gear, g2X, g2Y)
       
   943 
       
   944 	g1X, g1Y = GetGearPosition(gear)
       
   945 	q = g1X - g2X
       
   946 	w = g1Y - g2Y
       
   947 
       
   948 	return ( (q*q) + (w*w) )
       
   949 
       
   950 end
       
   951 
       
   952 ------------------------------------------------------------
       
   953 -- STUFF FOR LOADING SPECIAL POINTS / HWMAP CONVERSION
       
   954 ------------------------------------------------------------
       
   955 
       
   956 local specialPointsX = {}
       
   957 local specialPointsY = {}
       
   958 local specialPointsFlag = {}
       
   959 local specialPointsCount = 0
       
   960 
       
   961 function onSpecialPoint(x,y,flag)
       
   962     specialPointsX[specialPointsCount] = x
       
   963     specialPointsY[specialPointsCount] = y
       
   964 	specialPointsFlag[specialPointsCount] = flag
       
   965     specialPointsCount = specialPointsCount + 1
       
   966 end
       
   967 
       
   968 -- you know you could probably add multiple layers to this to get more points
       
   969 -- after the first set is expended have the last 1 be 127
       
   970 -- and then increment some other counter so like
       
   971 
       
   972 -- bobCounter = 1
       
   973 -- specialPoint(5)
       
   974 -- specialPoint(127)
       
   975 -- specialPoint(5)
       
   976 
       
   977 -- if BobCounter = 1 then
       
   978 -- 		if specialPointsFlag == 5 then createMine
       
   979 --		if specialPointFlag == 127 then bobCounter = 2
       
   980 -- elseif bobCounter == 2 then
       
   981 -- 		if specialPointsFlag == 5 then createExlosives
       
   982 -- end
       
   983 --
       
   984 
       
   985 -- this function interprets special points that have been embedded into an HWPMAP
       
   986 function InterpretPoints()
       
   987 
       
   988 	-- flags run from 0 to 127
       
   989 	for i = 0, (specialPointsCount-1) do
       
   990 
       
   991 		-- Mines
       
   992 		if specialPointsFlag[i] == 1 then
       
   993 			SetTimer(AddGear(specialPointsX[i], specialPointsY[i], gtMine, 0, 0, 0, 0), 1)
       
   994 		elseif specialPointsFlag[i] == 2 then
       
   995 			SetTimer(AddGear(specialPointsX[i], specialPointsY[i], gtMine, 0, 0, 0, 0), 1000)
       
   996 		elseif specialPointsFlag[i] == 3 then
       
   997 			SetTimer(AddGear(specialPointsX[i], specialPointsY[i], gtMine, 0, 0, 0, 0), 2000)
       
   998 		elseif specialPointsFlag[i] == 4 then
       
   999 			SetTimer(AddGear(specialPointsX[i], specialPointsY[i], gtMine, 0, 0, 0, 0), 3000)
       
  1000 		elseif specialPointsFlag[i] == 5 then
       
  1001 			SetTimer(AddGear(specialPointsX[i], specialPointsY[i], gtMine, 0, 0, 0, 0), 4000)
       
  1002 		elseif specialPointsFlag[i] == 6 then
       
  1003 			SetTimer(AddGear(specialPointsX[i], specialPointsY[i], gtMine, 0, 0, 0, 0), 5000)
       
  1004 
       
  1005 		-- Sticky Mines
       
  1006 		elseif specialPointsFlag[i] == 7 then
       
  1007 			AddGear(specialPointsX[i], specialPointsY[i], gtSMine, 0, 0, 0, 0)
       
  1008 
       
  1009 		-- Air Mines
       
  1010 		elseif specialPointsFlag[i] == 8 then
       
  1011 			AddGear(specialPointsX[i], specialPointsY[i], gtAirMine, 0, 0, 0, 0)
       
  1012 
       
  1013 		-- Health Crates
       
  1014 		elseif specialPointsFlag[i] == 9 then
       
  1015 			SetHealth(SpawnHealthCrate(specialPointsX[i],specialPointsY[i]),25)
       
  1016 		elseif specialPointsFlag[i] == 10 then
       
  1017 			SetHealth(SpawnHealthCrate(specialPointsX[i],specialPointsY[i]),50)
       
  1018 		elseif specialPointsFlag[i] == 11 then
       
  1019 			SetHealth(SpawnHealthCrate(specialPointsX[i],specialPointsY[i]),75)
       
  1020 		elseif specialPointsFlag[i] == 12 then
       
  1021 			SetHealth(SpawnHealthCrate(specialPointsX[i],specialPointsY[i]),100)
       
  1022 
       
  1023 		-- Cleaver
       
  1024 		elseif specialPointsFlag[i] == 13 then
       
  1025 			AddGear(specialPointsX[i], specialPointsY[i], gtKnife, 0, 0, 0, 0)
       
  1026 
       
  1027 		-- Target
       
  1028 		elseif specialPointsFlag[i] == 14 then
       
  1029 			AddGear(specialPointsX[i], specialPointsY[i], gtTarget, 0, 0, 0, 0)
       
  1030 
       
  1031 		--Barrels
       
  1032 		elseif specialPointsFlag[i] == 15 then
       
  1033 			SetHealth(AddGear(specialPointsX[i], specialPointsY[i], gtExplosives, 0, 0, 0, 0),1)
       
  1034 		elseif specialPointsFlag[i] == 16 then
       
  1035 			SetHealth(AddGear(specialPointsX[i], specialPointsY[i], gtExplosives, 0, 0, 0, 0),25)
       
  1036 		elseif specialPointsFlag[i] == 17 then
       
  1037 			SetHealth(AddGear(specialPointsX[i], specialPointsY[i], gtExplosives, 0, 0, 0, 0),50)
       
  1038 		elseif specialPointsFlag[i] == 18 then
       
  1039 			SetHealth(AddGear(specialPointsX[i], specialPointsY[i], gtExplosives, 0, 0, 0, 0),75)
       
  1040 		elseif specialPointsFlag[i] == 19 then
       
  1041 			SetHealth(AddGear(specialPointsX[i], specialPointsY[i], gtExplosives, 0, 0, 0, 0),100)
       
  1042 
       
  1043 		-- There are about 58+- weps / utils
       
  1044 		-- Weapon Crates
       
  1045 		elseif (specialPointsFlag[i] >= 20) and (specialPointsFlag[i] < (#atkArray+20)) then
       
  1046 			tempG = SpawnAmmoCrate(specialPointsX[i],specialPointsY[i],atkArray[specialPointsFlag[i]-19][1])
       
  1047 			setGearValue(tempG,"caseType","ammo")
       
  1048 			setGearValue(tempG,"contents",atkArray[specialPointsFlag[i]-19][2])
       
  1049 
       
  1050 
       
  1051 		-- Utility Crates
       
  1052 		elseif (specialPointsFlag[i] >= (#atkArray+20)) and (specialPointsFlag[i] < (#atkArray+20+#utilArray)) then
       
  1053 			tempG = SpawnUtilityCrate(specialPointsX[i],specialPointsY[i],utilArray[specialPointsFlag[i]-19-#atkArray][1])
       
  1054 			setGearValue(tempG,"caseType","util")
       
  1055 			setGearValue(tempG,"contents",utilArray[specialPointsFlag[i]-19-#atkArray][2])
       
  1056 
       
  1057 		--79-82 (reserved for future wep crates)
       
  1058 		--89,88,87,86 and 85,84,83,82 (reserved for the 2 custom sprites and their landflags)
       
  1059 
       
  1060 		--90-99 reserved for scripted structures
       
  1061 		--[[elseif specialPointsFlag[i] == 90 then
       
  1062 			--PlaceStruc("generator")
       
  1063 		elseif specialPointsFlag[i] == 91 then
       
  1064 			--PlaceStruc("healingstation")
       
  1065 		elseif specialPointsFlag[i] == 92 then
       
  1066 			--PlaceStruc("respawner")
       
  1067 		elseif specialPointsFlag[i] == 93 then
       
  1068 			--PlaceStruc("teleportationnode")
       
  1069 		elseif specialPointsFlag[i] == 94 then
       
  1070 			--PlaceStruc("biofilter")
       
  1071 		elseif specialPointsFlag[i] == 95 then
       
  1072 			--PlaceStruc("supportstation")
       
  1073 		elseif specialPointsFlag[i] == 96 then
       
  1074 			--PlaceStruc("constructionstation")
       
  1075 		elseif specialPointsFlag[i] == 97 then
       
  1076 			--PlaceStruc("reflectorshield")
       
  1077 		elseif specialPointsFlag[i] == 98 then
       
  1078 			--PlaceStruc("weaponfilter")]]
       
  1079 
       
  1080 		elseif specialPointsFlag[i] == 98 then
       
  1081 			portalDistance = div(specialPointsX[i],5)
       
  1082 			ufoFuel = specialPointsY[i]
       
  1083 
       
  1084 		-- Normal Girders
       
  1085 		elseif specialPointsFlag[i] == 100 then
       
  1086 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 0, 4294967295, nil, nil, nil, lfNormal)
       
  1087 		elseif specialPointsFlag[i] == 101 then
       
  1088 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 1, 4294967295, nil, nil, nil, lfNormal)
       
  1089 		elseif specialPointsFlag[i] == 102 then
       
  1090 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 2, 4294967295, nil, nil, nil, lfNormal)
       
  1091 		elseif specialPointsFlag[i] == 103 then
       
  1092 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 3, 4294967295, nil, nil, nil, lfNormal)
       
  1093 		elseif specialPointsFlag[i] == 104 then
       
  1094 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 4, 4294967295, nil, nil, nil, lfNormal)
       
  1095 		elseif specialPointsFlag[i] == 105 then
       
  1096 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 5, 4294967295, nil, nil, nil, lfNormal)
       
  1097 		elseif specialPointsFlag[i] == 106 then
       
  1098 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 6, 4294967295, nil, nil, nil, lfNormal)
       
  1099 		elseif specialPointsFlag[i] == 107 then
       
  1100 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 7, 4294967295, nil, nil, nil, lfNormal)
       
  1101 
       
  1102 		-- Invulnerable Girders
       
  1103 		elseif specialPointsFlag[i] == 108 then
       
  1104 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 0, 2516582650, nil, nil, nil, lfIndestructible)
       
  1105 		elseif specialPointsFlag[i] == 109 then
       
  1106 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 1, 2516582650, nil, nil, nil, lfIndestructible)
       
  1107 		elseif specialPointsFlag[i] == 110 then
       
  1108 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 2, 2516582650, nil, nil, nil, lfIndestructible)
       
  1109 		elseif specialPointsFlag[i] == 111 then
       
  1110 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 3, 2516582650, nil, nil, nil, lfIndestructible)
       
  1111 		elseif specialPointsFlag[i] == 112 then
       
  1112 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 4, 2516582650, nil, nil, nil, lfIndestructible)
       
  1113 		elseif specialPointsFlag[i] == 113 then
       
  1114 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 5, 2516582650, nil, nil, nil, lfIndestructible)
       
  1115 		elseif specialPointsFlag[i] == 114 then
       
  1116 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 6, 2516582650, nil, nil, nil, lfIndestructible)
       
  1117 		elseif specialPointsFlag[i] == 115 then
       
  1118 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 7, 2516582650, nil, nil, nil, lfIndestructible)
       
  1119 
       
  1120 		-- Icy Girders
       
  1121 		elseif specialPointsFlag[i] == 116 then
       
  1122 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 0, 16448250, nil, nil, nil, lfIce)
       
  1123 		elseif specialPointsFlag[i] == 117 then
       
  1124 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 1, 16448250, nil, nil, nil, lfIce)
       
  1125 		elseif specialPointsFlag[i] == 118 then
       
  1126 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 2, 16448250, nil, nil, nil, lfIce)
       
  1127 		elseif specialPointsFlag[i] == 119 then
       
  1128 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 3, 16448250, nil, nil, nil, lfIce)
       
  1129 		elseif specialPointsFlag[i] == 120 then
       
  1130 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 4, 16448250, nil, nil, nil, lfIce)
       
  1131 		elseif specialPointsFlag[i] == 121 then
       
  1132 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 5, 16448250, nil, nil, nil, lfIce)
       
  1133 		elseif specialPointsFlag[i] == 121 then
       
  1134 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 6, 16448250, nil, nil, nil, lfIce)
       
  1135 		elseif specialPointsFlag[i] == 123 then
       
  1136 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmGirder, 7, 16448250, nil, nil, nil, lfIce)
       
  1137 
       
  1138 		-- Rubber Bands
       
  1139 		elseif specialPointsFlag[i] == 124 then
       
  1140 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmRubber, 0, 4294967295, nil, nil, nil, lfBouncy)
       
  1141 		elseif specialPointsFlag[i] == 125 then
       
  1142 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmRubber, 1, 4294967295, nil, nil, nil, lfBouncy)
       
  1143 		elseif specialPointsFlag[i] == 126 then
       
  1144 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmRubber, 2, 4294967295, nil, nil, nil, lfBouncy)
       
  1145 		elseif specialPointsFlag[i] == 127 then
       
  1146 			PlaceSprite(specialPointsX[i], specialPointsY[i], sprAmRubber, 3, 4294967295, nil, nil, nil, lfBouncy)
       
  1147 
       
  1148 		-- Waypoints
       
  1149 		else -- 0 / no value
       
  1150 			PlaceWaypoint(specialPointsX[i],specialPointsY[i])
       
  1151 		end
       
  1152 
       
  1153 	end
       
  1154 
       
  1155 end
       
  1156 
       
  1157 ----------------------------
       
  1158 -- just fucking around
       
  1159 ----------------------------
       
  1160 -- ancient stuff that no longer has any relevance
       
  1161 --[[
       
  1162 function BoostVeloctiy(gear)
       
  1163 
       
  1164 	if (GetGearType(gear) == gtSMine) or
       
  1165 		(GetGearType(gear) == gtMine) or
       
  1166 		(GetGearType(gear) == gtHedgehog) then
       
  1167 
       
  1168 			dx,dy = GetGearVelocity(gear)
       
  1169 			SetGearVelocity(gear,dx*1.5,dy*1.5)
       
  1170 		end
       
  1171 
       
  1172 end
       
  1173 
       
  1174 -- use this stuff when you want to get some idea of land and/or blow up /everything/
       
  1175 function CheckGrenades(gear)
       
  1176 
       
  1177 	if GetGearType(gear) == gtGrenade then
       
  1178 		dx, dy = GetGearVelocity(gear)
       
  1179 		if (dy == 0) then
       
  1180 
       
  1181 		else
       
  1182 			DeleteGear(gear)
       
  1183 		end
       
  1184 	end
       
  1185 
       
  1186 end
       
  1187 
       
  1188 function BlowShitUpPartTwo()
       
  1189 
       
  1190 	destroyMap = false
       
  1191 	runOnGears(CheckGrenades)
       
  1192 
       
  1193 end
       
  1194 
       
  1195 function BlowShitUp()
       
  1196 
       
  1197 	destroyMap = true
       
  1198 
       
  1199 	mapWidth = 4096
       
  1200 	mapHeight = 2048
       
  1201 	blockSize = 50
       
  1202 
       
  1203 	mY = 0
       
  1204 
       
  1205 	while (mY < WaterLine) do
       
  1206 
       
  1207 		mX = 0
       
  1208 		mY = mY + 1*blockSize
       
  1209 		while (mX < mapWidth) do
       
  1210 
       
  1211 			mX = mX + (1*blockSize)
       
  1212 			gear = AddGear(mX, mY, gtGrenade, 0, 0, 0, 5000)
       
  1213 			SetState(gear, bor(GetState(gear),gstInvisible) )
       
  1214 
       
  1215 		end
       
  1216 
       
  1217 	end
       
  1218 
       
  1219 end]]
       
  1220 
       
  1221 
       
  1222 -- you know, using this it might be possible to have a self destructing track,
       
  1223 -- or a moving one.
       
  1224 -- edit: this was from the gold old days before it was possible to erase sprites)
       
  1225 --[[function BoomGirder(x,y,rot)
       
  1226 	girTime = 1
       
  1227 	if rot < 4 then
       
  1228 				AddGear(x, y, gtGrenade, 0, 0, 0, girTime)
       
  1229 	elseif rot == 4 then
       
  1230 				g = AddGear(x-45, y, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1231 				g = AddGear(x-30, y, gtGrenade, 0, 0, 0, girTime)
       
  1232 				g = AddGear(x, y, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1233 				g = AddGear(x+30, y, gtGrenade, 0, 0, 0, girTime)
       
  1234 				g = AddGear(x+45, y, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1235 	elseif rot == 5 then ------- diag
       
  1236 				g = AddGear(x+45, y+45, gtGrenade, 0, 0, 0, girTime) --n
       
  1237 				g = AddGear(x+30, y+30, gtGrenade, 0, 0, 0, girTime)
       
  1238 				g = AddGear(x, y, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1239 				g = AddGear(x-30, y-30, gtGrenade, 0, 0, 0, girTime)
       
  1240 				g = AddGear(x-45, y-45, gtGrenade, 0, 0, 0, girTime) --n
       
  1241 	elseif rot == 6 then
       
  1242 				g = AddGear(x, y-45, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1243 				g = AddGear(x, y+30, gtGrenade, 0, 0, 0, girTime)
       
  1244 				g = AddGear(x, y, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1245 				g = AddGear(x, y-30, gtGrenade, 0, 0, 0, girTime)
       
  1246 				g = AddGear(x, y+45, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1247 	elseif rot == 7 then -------
       
  1248 				g = AddGear(x+45, y-45, gtGrenade, 0, 0, 0, girTime) --n
       
  1249 				g = AddGear(x+30, y-30, gtGrenade, 0, 0, 0, girTime)
       
  1250 				g = AddGear(x, y, gtGrenade, 0, 0, 0, girTime) -- needed?
       
  1251 				g = AddGear(x-30, y+30, gtGrenade, 0, 0, 0, girTime)
       
  1252 				g = AddGear(x-45, y+45, gtGrenade, 0, 0, 0, girTime) --n
       
  1253 	end
       
  1254 end]]
       
  1255 
       
  1256 --[[function SpecialGirderPlacement(x,y,rot)
       
  1257 
       
  1258 	PlaceGirder(x, y, rot)
       
  1259 	girTime = 10000
       
  1260 
       
  1261 	if rot < 4 then
       
  1262 				AddGear(x, y, gtGrenade, 0, 0, 0, girTime)
       
  1263 	elseif rot == 4 then
       
  1264 				g = AddGear(x-30, y, gtGrenade, 0, 0, 0, girTime)
       
  1265 				g = AddGear(x+30, y, gtGrenade, 0, 0, 0, girTime)
       
  1266 	elseif rot == 5 then -------
       
  1267 				g = AddGear(x+30, y+30, gtGrenade, 0, 0, 0, girTime)
       
  1268 				g = AddGear(x-30, y-30, gtGrenade, 0, 0, 0, girTime)
       
  1269 	elseif rot == 6 then
       
  1270 				g = AddGear(x, y+30, gtGrenade, 0, 0, 0, girTime)
       
  1271 				g = AddGear(x, y-30, gtGrenade, 0, 0, 0, girTime)
       
  1272 	elseif rot == 7 then -------
       
  1273 				g = AddGear(x+30, y-30, gtGrenade, 0, 0, 0, girTime)
       
  1274 				g = AddGear(x-30, y+30, gtGrenade, 0, 0, 0, girTime)
       
  1275 	end
       
  1276 
       
  1277 end]]
       
  1278 
       
  1279 --shoppabalance crap
       
  1280 function AddShoppaPoint(x,y,c)
       
  1281 	table.insert(shoppaPX, x)
       
  1282 	table.insert(shoppaPY, y)
       
  1283 	table.insert(shoppaPR, c)
       
  1284 end
       
  1285 
       
  1286 function GetRankedColour(r)
       
  1287 	if r == 1 then
       
  1288 		return(0xFF0000FF)
       
  1289 	elseif r == 2 then
       
  1290 		return(0xFFFF00FF)
       
  1291 	elseif r == 3 then
       
  1292 		return(0x00FF00FF)
       
  1293 	elseif r == 4 then
       
  1294 		return(0x0000FFFF)
       
  1295 	elseif r == 5 then
       
  1296 		return(0xFF00FFFF)
       
  1297 	end
       
  1298 end
       
  1299 
       
  1300 -----------------------------------------
       
  1301 -- PRIMARY HEDGE EDITOR PLACEMENT STUFF
       
  1302 -----------------------------------------
       
  1303 
       
  1304 function GetClosestGear()
       
  1305 	closestDist = 999999999
       
  1306 	closestGear = nil
       
  1307 	--sGear = nil
       
  1308 	runOnGears(SelectGear)
       
  1309 	return(closestGear)
       
  1310 end
       
  1311 
       
  1312 function SelectGear(gear)
       
  1313 
       
  1314 	d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount])
       
  1315 
       
  1316 	if d < closestDist then
       
  1317 		closestDist = d
       
  1318 		closestGear = gear
       
  1319 	end
       
  1320 
       
  1321 end
       
  1322 
       
  1323 function PlaceWaypoint(x,y)
       
  1324 
       
  1325 	placedX[placedCount] = x
       
  1326 	placedY[placedCount] = y
       
  1327 	placedType[placedCount] = loc("Waypoint Placement Mode")
       
  1328 	placedLandFlags[placedCount] = nil -- use this to specify waypoint type maybe
       
  1329 	placedHWMapFlag[placedCount] = 0
       
  1330 
       
  1331 	placedSprite[placedCount] = vgtCircle
       
  1332 	placedSpec[placedCount] = AddVisualGear(x,y,vgtCircle,0,true)
       
  1333 	placedTint[placedCount] = 0xFF0000FF
       
  1334 	placedFrame[placedCount] = 1										--rad is 450
       
  1335 	SetVisualGearValues(placedSpec[placedCount], x, y, 20, 100, 1, 10, 0, 450, 5, placedTint[placedCount])
       
  1336 	placedCount = placedCount +1
       
  1337 
       
  1338 end
       
  1339 
       
  1340 function LoadSprite(pX, pY, pSprite, pFrame, pTint, p1, p2, p3, pLandFlags)
       
  1341 
       
  1342 	placedX[placedCount] = pX
       
  1343 	placedY[placedCount] = pY
       
  1344 	placedSpec[placedCount] = nil
       
  1345 
       
  1346 	if pSprite == sprAmGirder then
       
  1347 
       
  1348 		placedType[placedCount] = loc("Girder Placement Mode")
       
  1349 
       
  1350 		--newHWMapStuff
       
  1351 		if pLandFlags == lfIndestructible then	specialMod = 1
       
  1352 		elseif pLandFlags == lfIce then	specialMod = 2
       
  1353 		else specialMod = 0
       
  1354 		end
       
  1355 		placedHWMapFlag[placedCount] = pFrame+100+(8*specialMod)
       
  1356 
       
  1357 
       
  1358 	elseif pSprite == sprAmRubber then
       
  1359 
       
  1360 		placedType[placedCount] = loc("Rubber Placement Mode")
       
  1361 
       
  1362 		--newHWMapStuff
       
  1363 		if pFrame == 0 then placedHWMapFlag[placedCount] = 124
       
  1364 		elseif pFrame == 1 then placedHWMapFlag[placedCount] = 125
       
  1365 		elseif pFrame == 2 then placedHWMapFlag[placedCount] = 126
       
  1366 		elseif pFrame == 3 then placedHWMapFlag[placedCount] = 127
       
  1367 		end
       
  1368 
       
  1369 	else
       
  1370 		placedType[placedCount] = loc("Sprite Placement Mode")
       
  1371 	end
       
  1372 
       
  1373 	--placedLandFlags[placedCount] = pLandFlags
       
  1374 	if pLandFlags == lfIce then
       
  1375 		placedLandFlags[placedCount] = "lfIce"
       
  1376 	elseif pLandFlags == lfIndestructible then
       
  1377 		placedLandFlags[placedCount] = "lfIndestructible"
       
  1378 	elseif pLandFlags == lfBouncy then
       
  1379 		placedLandFlags[placedCount] = "lfBouncy"
       
  1380 	else
       
  1381 		placedLandFlags[placedCount] = "lfNormal"
       
  1382 	end
       
  1383 
       
  1384 	--placedSuperSpec[placedCount] = nil
       
  1385 
       
  1386 	placedTint[placedCount] = pTint
       
  1387 	placedFrame[placedCount] = pFrame
       
  1388 
       
  1389 	placedSprite[placedCount] = pSprite
       
  1390 
       
  1391 	PlaceSprite(pX, pY, pSprite, pFrame, pTint,	nil, nil, nil, pLandFlags)
       
  1392 
       
  1393 	placedCount = placedCount + 1
       
  1394 
       
  1395 end
       
  1396 
       
  1397 function CallPlaceSprite(pID)
       
  1398 
       
  1399 	if landType == lfIce then
       
  1400 		placedLandFlags[pID] = "lfIce"
       
  1401 		placedTint[pID] = 250 + (250*0x100) + (250*0x10000) + (0*0x1000000) -- A BGR
       
  1402 	elseif landType == lfIndestructible then
       
  1403 		placedLandFlags[pID] = "lfIndestructible"
       
  1404 		placedTint[pID] = 250 + (0*0x100) + (0*0x10000) + (150*0x1000000) -- A BGR
       
  1405 	elseif landType == lfBouncy then
       
  1406 		placedLandFlags[pID] = "lfBouncy"
       
  1407 		placedTint[pID] = 250 + (0*0x100) + (250*0x10000) + (0*0x1000000) -- A BGR
       
  1408 	else
       
  1409 		placedLandFlags[pID] = "lfNormal"
       
  1410 		--placedTint[pID] = nil
       
  1411 		placedTint[pID] = 255 + (255*0x100) + (255*0x10000) + (255*0x1000000) -- A BGR
       
  1412 	end
       
  1413 
       
  1414 	PlaceSprite(placedX[pID], placedY[pID], placedSprite[pID], placedFrame[pID],
       
  1415 		placedTint[pID],
       
  1416 		nil, -- overrite existing land
       
  1417 		nil, nil, -- this stuff specifies flipping
       
  1418 		landType)
       
  1419 
       
  1420 end
       
  1421 
       
  1422 function SelectClosestSprite()
       
  1423 
       
  1424 	closestDist = 999999999
       
  1425 	closestSpriteID = nil -- just in case
       
  1426 
       
  1427 	for i = 0, (placedCount-1) do
       
  1428 		if (placedType[i] == loc("Girder Placement Mode"))
       
  1429 			or (placedType[i] == loc("Rubber Placement Mode"))
       
  1430 			or (placedType[i] == loc("Sprite Placement Mode"))
       
  1431 		then
       
  1432 				q = placedX[i] - placedX[placedCount]
       
  1433 				w = placedY[i] - placedY[placedCount]
       
  1434 				d = ( (q*q) + (w*w) )
       
  1435 				if d < closestDist then
       
  1436 					closestDist = d
       
  1437 					closestSpriteID = i
       
  1438 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(sSprite)
       
  1439 
       
  1440 					--newTint = placedTint[i]
       
  1441 					newTint = 0xFF00FFFF
       
  1442 
       
  1443 					SetVisualGearValues(sSprite, placedX[i], placedY[i], 0, 0, g5, placedFrame[i], 10000, placedSprite[i], 10000, newTint )
       
  1444 
       
  1445 				end
       
  1446 		end
       
  1447 	end
       
  1448 
       
  1449 end
       
  1450 
       
  1451 function EraseClosestSprite()
       
  1452 	if closestSpriteID ~= nil then
       
  1453 		EraseSprite(placedX[closestSpriteID], placedY[closestSpriteID], placedSprite[closestSpriteID], placedFrame[closestSpriteID],
       
  1454                     nil, -- erase land only where the pixels match the land flag provided
       
  1455                     nil, -- only erase the provided land flags. don't touch other land flags or LandPixels
       
  1456                     nil, -- flip sprite horizontally
       
  1457                     nil, -- flip sprite vertically
       
  1458                     placedLandFlags[closestSpriteID])
       
  1459 
       
  1460 		placedX[closestSpriteID] = nil
       
  1461 		placedY[closestSpriteID] = nil
       
  1462 		placedSpec[closestSpriteID] = nil
       
  1463 		--placedSuperSpec[closestSpriteID] = nil
       
  1464 		placedType[closestSpriteID] = nil
       
  1465 		placedTint[closestSpriteID] = nil
       
  1466 		placedSprite[closestSpriteID] = nil
       
  1467 		placedFrame[closestSpriteID] = nil
       
  1468 		placedLandFlags[closestSpriteID] = nil
       
  1469 		closestSpriteID = nil
       
  1470 		SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 )
       
  1471 	end
       
  1472 end
       
  1473 
       
  1474 -- work this into the above two functions and edit them, later
       
  1475 function EraseClosestWaypoint()
       
  1476 
       
  1477 	closestDist = 999999999
       
  1478 	closestSpriteID = nil -- just in case
       
  1479 
       
  1480 	for i = 0, (placedCount-1) do
       
  1481 		if (placedType[i] == loc("Waypoint Placement Mode")) then
       
  1482 				q = placedX[i] - placedX[placedCount]
       
  1483 				w = placedY[i] - placedY[placedCount]
       
  1484 				d = ( (q*q) + (w*w) )
       
  1485 				if d < closestDist then
       
  1486 					closestDist = d
       
  1487 					closestSpriteID = i
       
  1488 					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(sSprite)
       
  1489 
       
  1490 					--newTint = placedTint[i]
       
  1491 					newTint = 0xFF00FFFF
       
  1492 
       
  1493 					SetVisualGearValues(sSprite, placedX[i], placedY[i], 0, 0, g5, placedFrame[i], 10000, placedSprite[i], 10000, newTint )
       
  1494 
       
  1495 				end
       
  1496 		end
       
  1497 	end
       
  1498 
       
  1499 	if closestSpriteID ~= nil then
       
  1500 		DeleteVisualGear(placedSpec[closestSpriteID])
       
  1501 		placedX[closestSpriteID] = nil
       
  1502 		placedY[closestSpriteID] = nil
       
  1503 		placedSpec[closestSpriteID] = nil
       
  1504 		--placedSuperSpec[closestSpriteID] = nil
       
  1505 		placedType[closestSpriteID] = nil
       
  1506 		placedTint[closestSpriteID] = nil
       
  1507 		placedSprite[closestSpriteID] = nil
       
  1508 		placedFrame[closestSpriteID] = nil
       
  1509 		placedLandFlags[closestSpriteID] = nil
       
  1510 		closestSpriteID = nil
       
  1511 		SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 )
       
  1512 	end
       
  1513 end
       
  1514 
       
  1515 
       
  1516 -- essentially called when user clicks the mouse
       
  1517 -- with girders or an airattack
       
  1518 function PlaceObject(x,y)
       
  1519 
       
  1520 	placedX[placedCount] = x
       
  1521 	placedY[placedCount] = y
       
  1522 	placedType[placedCount] = cat[cIndex]
       
  1523 	placedSpec[placedCount] = pMode[pIndex]
       
  1524 	--placedSuperSpec[placedCount] = nil
       
  1525 	placedTint[placedCount] = nil
       
  1526 	placedFrame[placedCount] = nil
       
  1527 	placedLandFlags[placedCount] = nil
       
  1528 	placedSprite[placedCount] = nil
       
  1529 	placedHWMapFlag[placedCount] = nil
       
  1530 
       
  1531 	if cat[cIndex] == loc("Girder Placement Mode") then
       
  1532 
       
  1533 		if superDelete == false then
       
  1534 			--lfObject and lfBasic
       
  1535 			placedFrame[placedCount] = CGR
       
  1536 			placedSprite[placedCount] = sprAmGirder
       
  1537 			CallPlaceSprite(placedCount)
       
  1538 
       
  1539 			if landType == lfIndestructible then	specialMod = 1
       
  1540 			elseif landType == lfIce then	specialMod = 2
       
  1541 			else specialMod = 0
       
  1542 			end
       
  1543 			placedHWMapFlag[placedCount] = CGR+100+(8*specialMod)
       
  1544 		else
       
  1545 			placedType[placedCount] = "bogus" -- we need this so we don't think we've placed a new girder and are trying to erase the things we just placed??
       
  1546 			SelectClosestSprite()
       
  1547 			EraseClosestSprite()
       
  1548 		end
       
  1549 
       
  1550 	elseif cat[cIndex] == loc("Rubber Placement Mode") then
       
  1551 
       
  1552 		if superDelete == false then
       
  1553 			placedFrame[placedCount] = CGR
       
  1554 			placedSprite[placedCount] = sprAmRubber
       
  1555 
       
  1556 			--CallPlaceSprite(placedCount)
       
  1557 			--new ermagerd
       
  1558 			placedLandFlags[placedCount] = "lfBouncy"
       
  1559 			placedTint[placedCount] = 255 + (255*0x100) + (255*0x10000) + (255*0x1000000) -- A BGR
       
  1560 			PlaceSprite(placedX[placedCount], placedY[placedCount], placedSprite[placedCount], placedFrame[placedCount],
       
  1561 				placedTint[placedCount],
       
  1562 				nil,
       
  1563 				nil, nil,
       
  1564 				landType)
       
  1565 
       
  1566 			if CGR == 0 then placedHWMapFlag[placedCount] = 124
       
  1567 			elseif CGR == 1 then placedHWMapFlag[placedCount] = 125
       
  1568 			elseif CGR == 2 then placedHWMapFlag[placedCount] = 126
       
  1569 			elseif CGR == 3 then placedHWMapFlag[placedCount] = 127
       
  1570 			end
       
  1571 		else
       
  1572 			placedType[placedCount] = "bogus"
       
  1573 			SelectClosestSprite()
       
  1574 			EraseClosestSprite()
       
  1575 		end
       
  1576 
       
  1577 	elseif cat[cIndex] == loc("Target Placement Mode") then
       
  1578 		gear = AddGear(x, y, gtTarget, 0, 0, 0, 0)
       
  1579 	elseif cat[cIndex] == loc("Cleaver Placement Mode") then
       
  1580 		gear = AddGear(x, y, gtKnife, 0, 0, 0, 0)
       
  1581 	elseif cat[cIndex] == loc("Health Crate Placement Mode") then
       
  1582 		gear = SpawnHealthCrate(x,y)
       
  1583 		SetHealth(gear, pMode[pIndex])
       
  1584 		setGearValue(gear,"caseType","med")
       
  1585 	elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
       
  1586 		gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
       
  1587 		placedSpec[placedCount] = atkArray[pIndex][2]
       
  1588 		setGearValue(gear,"caseType","ammo")
       
  1589 		setGearValue(gear,"contents",atkArray[pIndex][2])
       
  1590 	elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
       
  1591 		gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
       
  1592 		placedSpec[placedCount] = utilArray[pIndex][2]
       
  1593 		setGearValue(gear,"caseType","util")
       
  1594 		setGearValue(gear,"contents",utilArray[pIndex][2])
       
  1595 	elseif cat[cIndex] == loc("Barrel Placement Mode") then
       
  1596 		gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
       
  1597 		SetHealth(gear, pMode[pIndex])
       
  1598 	elseif cat[cIndex] == loc("Mine Placement Mode") then
       
  1599 		gear = AddGear(x, y, gtMine, 0, 0, 0, 0)
       
  1600 		SetTimer(gear, pMode[pIndex])
       
  1601 	elseif cat[cIndex] == loc("Sticky Mine Placement Mode") then
       
  1602 		gear = AddGear(x, y, gtSMine, 0, 0, 0, 0)
       
  1603 	elseif cat[cIndex] == loc("Air Mine Placement Mode") then
       
  1604 		gear = AddGear(x, y, gtAirMine, 0, 0, 0, 0)
       
  1605 		SetTimer(gear, pMode[pIndex])
       
  1606 	elseif cat[cIndex] == loc("Advanced Repositioning Mode") then
       
  1607 
       
  1608 		if pMode[pIndex] == loc("Selection Mode") then
       
  1609 			sGear = GetClosestGear()
       
  1610 		elseif pMode[pIndex] == loc("Placement Mode") then
       
  1611 			if sGear ~= nil then
       
  1612 				SetGearPosition(sGear, x, y)
       
  1613 			end
       
  1614 		elseif pMode[pIndex] == loc("Deletion Mode") then
       
  1615 			sGear = GetClosestGear()
       
  1616 			if (sGear ~= nil) and (GetGearType(sGear) ~= gtHedgehog) then
       
  1617 				DeleteGear(sGear)
       
  1618 				sGear = nil
       
  1619 			end
       
  1620 		end
       
  1621 
       
  1622 	elseif (cat[cIndex] == loc("Hog Identity Mode")) or (cat[cIndex] == loc("Team Identity Mode")) then
       
  1623 
       
  1624 		sGear = GetClosestGear()
       
  1625 		if (sGear ~= nil) and (GetGearType(sGear) == gtHedgehog) then
       
  1626 			if (cat[cIndex] == loc("Hog Identity Mode")) then
       
  1627 				SetHogProfile(sGear, pMode[pIndex])
       
  1628 			else -- set for the whole team
       
  1629 				SetTeamIdentity(sGear)
       
  1630 			end
       
  1631 		else
       
  1632 			AddCaption(loc("Please click on a hedgehog."),0xffba00ff,capgrpVolume)
       
  1633 		end
       
  1634 
       
  1635 
       
  1636 
       
  1637 	elseif cat[cIndex] == loc("Health Modification Mode") then
       
  1638 
       
  1639 		sGear = GetClosestGear()
       
  1640 		if (sGear ~= nil) and (GetGearType(sGear) == gtHedgehog) then
       
  1641 			SetHealth(sGear, pMode[pIndex])
       
  1642 		else
       
  1643 			AddCaption(loc("Please click on a hedgehog."),0xffba00ff,capgrpVolume)
       
  1644 		end
       
  1645 
       
  1646 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
       
  1647 
       
  1648 		SelectClosestSprite()
       
  1649 
       
  1650 		if closestSpriteID ~= nil then
       
  1651 			-- we have a sprite selected somewhere
       
  1652 			--if pMode[pIndex] == "Sprite Selection Mode" then
       
  1653 				-- sprite is now selected, good job
       
  1654 			--elseif pMode[pIndex] == "LandFlag Modification Mode" then
       
  1655 			if pMode[pIndex] == loc("LandFlag Modification Mode") then
       
  1656 				EraseSprite(placedX[closestSpriteID], placedY[closestSpriteID], placedSprite[closestSpriteID], placedFrame[closestSpriteID], nil, nil, nil, nil, placedLandFlags[closestSpriteID])
       
  1657 				CallPlaceSprite(closestSpriteID)
       
  1658 				closestSpriteID = nil
       
  1659 				SetVisualGearValues(sSprite, 0, 0, 0, 0, 0, 1, 10000, sprAmGirder, 10000, 0x00000000 )
       
  1660 			elseif pMode[pIndex] == loc("Sprite Erasure Mode") then
       
  1661 
       
  1662 				EraseClosestSprite()
       
  1663 
       
  1664 			end
       
  1665 		end
       
  1666 
       
  1667 
       
  1668 	elseif cat[cIndex] == loc("Tagging Mode") then
       
  1669 
       
  1670 		sGear = GetClosestGear()
       
  1671 		if sGear ~= nil then  -- used to be closestGear
       
  1672 
       
  1673 			if getGearValue(sGear,"tag") == nil then
       
  1674 
       
  1675 				if pMode[pIndex] == loc("Tag Collection Mode") then
       
  1676 					if GetGearType(sGear) == gtCase then
       
  1677 						setGearValue(sGear, "tag","collection")
       
  1678 					else
       
  1679 						AddCaption(loc("Please click on a crate."),0xffba00ff,capgrpVolume)
       
  1680 					end
       
  1681 				else
       
  1682 					if pMode[pIndex] == loc("Tag Victory Mode") then
       
  1683 						setGearValue(sGear, "tag","victory")
       
  1684 					elseif pMode[pIndex] == loc("Tag Failure Mode") then
       
  1685 						setGearValue(sGear, "tag","failure")
       
  1686 					end
       
  1687 				end
       
  1688 
       
  1689 			else
       
  1690 				-- remove tag and delete circ
       
  1691 				setGearValue(sGear, "tag", nil)
       
  1692 				DeleteVisualGear(getGearValue(sGear,"tCirc"))
       
  1693 				setGearValue(sGear, "tCirc", nil)
       
  1694 			end
       
  1695 
       
  1696 
       
  1697 
       
  1698 		end
       
  1699 
       
  1700 
       
  1701 	--elseif cat[cIndex] == loc("Sprite Testing Mode") then
       
  1702 
       
  1703 	--	frameID = 0
       
  1704 	--	visualSprite = reducedSpriteIDArray[pIndex]
       
  1705 	--	tempE = AddVisualGear(x, y, vgtStraightShot, 0, true,1)
       
  1706 	--	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  1707 	--	SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
       
  1708 
       
  1709 
       
  1710 	elseif cat[cIndex] == loc("Sprite Placement Mode") then
       
  1711 
       
  1712 		if superDelete == false then
       
  1713 			placedFrame[placedCount] = 1
       
  1714 			placedSprite[placedCount] = reducedSpriteIDArray[pIndex]
       
  1715 			CallPlaceSprite(placedCount)
       
  1716 		else
       
  1717 			placedType[placedCount] = "bogus"
       
  1718 			SelectClosestSprite()
       
  1719 			EraseClosestSprite()
       
  1720 		end
       
  1721 
       
  1722 	elseif cat[cIndex] == loc("Waypoint Placement Mode") then
       
  1723 
       
  1724 
       
  1725 		if pMode[pIndex] == loc("Waypoint Deletion Mode") then
       
  1726 			EraseClosestWaypoint()
       
  1727 		else
       
  1728 			PlaceWaypoint(x,y)
       
  1729 			placedCount = placedCount - 1
       
  1730 		end
       
  1731 
       
  1732 	end
       
  1733 
       
  1734 	placedCount = placedCount + 1
       
  1735 
       
  1736 end
       
  1737 
       
  1738 -- called when user changes primary selection
       
  1739 -- either via up/down keys
       
  1740 -- or selecting girder/airattack
       
  1741 function RedefineSubset()
       
  1742 
       
  1743 	superDelete = false -- fairly new addition
       
  1744 	landType = 0 --- fairly new addition
       
  1745 	pIndex = 1
       
  1746 	pMode = {}
       
  1747 
       
  1748 	if cat[cIndex] == loc("Girder Placement Mode") then
       
  1749 		pIndex = CGR
       
  1750 		pMode = {loc("Girder")}
       
  1751 	--	pCount = 1
       
  1752 	elseif cat[cIndex] == loc("Rubber Placement Mode") then
       
  1753 		pIndex = CGR
       
  1754 		pMode = {loc("Rubber")}
       
  1755 		landType = lfBouncy -- for now, let's not allow anything else (-- fairly new addition)
       
  1756 	--	pCount = 1???
       
  1757 	elseif cat[cIndex] == loc("Target Placement Mode") then
       
  1758 		pMode = {loc("Standard Target")}
       
  1759 	elseif cat[cIndex] == loc("Cleaver Placement Mode") then
       
  1760 		pMode = {loc("Standard Cleaver")}
       
  1761 	elseif cat[cIndex] == loc("Barrel Placement Mode") then
       
  1762 		pMode = {1,50,75,100}
       
  1763 	elseif cat[cIndex] == loc("Health Crate Placement Mode") then
       
  1764 		pMode = {25,50,75,100}
       
  1765 	elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
       
  1766 		for i = 1, #atkArray do
       
  1767 			pMode[i] = atkArray[i][4] --pMode[i] = atkArray[i][2]
       
  1768 		end
       
  1769 	elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
       
  1770 		for i = 1, #utilArray do
       
  1771 			pMode[i] = utilArray[i][4] --pMode[i] = utilArray[i][2]
       
  1772 		end
       
  1773 	elseif cat[cIndex] == loc("Mine Placement Mode") then
       
  1774 		pMode = {1,1000,2000,3000,4000,5000,0}
       
  1775 		-- 0 is dud right, or is that nil?
       
  1776 	elseif cat[cIndex] == loc("Sticky Mine Placement Mode") then
       
  1777 		pMode = {loc("Normal Sticky Mine")}
       
  1778 	elseif cat[cIndex] == loc("Air Mine Placement Mode") then
       
  1779 		pMode = {1,1000,2000,3000,4000,5000,0}
       
  1780 	elseif cat[cIndex] == loc("Advanced Repositioning Mode") then
       
  1781 		pMode = {loc("Selection Mode"),loc("Placement Mode"), loc("Deletion Mode")}
       
  1782 	elseif cat[cIndex] == loc("Tagging Mode") then
       
  1783 		pMode = {loc("Tag Victory Mode"),loc("Tag Failure Mode"),loc("Tag Collection Mode")}
       
  1784 	elseif cat[cIndex] == loc("Hog Identity Mode") then
       
  1785 		pMode = {loc("Soldier"),loc("Grenadier"),loc("Sniper"),loc("Pyro"),loc("Ninja"),loc("Commander"),loc("Chef"),loc("Engineer"),loc("Physicist"),loc("Trapper"),loc("Saint"),loc("Clown")}
       
  1786 	elseif cat[cIndex] == loc("Team Identity Mode") then
       
  1787 		pMode = {"Clowns","Street Fighters","Cybernetic Empire","Color Squad","Fruit","The Police","The Ninja-Samurai Alliance","Pokemon","The Zoo","The Devs","Mushroom Kingdom","Pirates","Gangsters","Twenty-Twenty","Monsters","The Iron Curtain","The Hospital"}
       
  1788 	elseif cat[cIndex] == loc("Health Modification Mode") then
       
  1789 		pMode = {1, 25, 30, 50, 75, 100, 120, 150, 200, 1000}
       
  1790 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
       
  1791 		--pMode = {"Sprite Selection Mode","LandFlag Modification Mode","Sprite Erasure Mode"}
       
  1792 		pMode = {loc("LandFlag Modification Mode"),loc("Sprite Erasure Mode")}
       
  1793 	elseif cat[cIndex] == loc("Sprite Testing Mode") or cat[cIndex] == loc("Sprite Placement Mode") then
       
  1794 		--for i = 1, #spriteTextArray do
       
  1795 		--	pMode[i] = spriteTextArray[i]
       
  1796 		--end
       
  1797 		for i = 1, #reducedSpriteTextArray do
       
  1798 			pMode[i] = reducedSpriteTextArray[i]
       
  1799 		end
       
  1800 	elseif cat[cIndex] == loc("Waypoint Placement Mode") then
       
  1801 		pMode = {loc("Standard Waypoint"), loc("Waypoint Deletion Mode")}
       
  1802 	end
       
  1803 
       
  1804 end
       
  1805 
       
  1806 ------------------------------------------------
       
  1807 -- LOADING AND SAVING DATA STUFF
       
  1808 ------------------------------------------------
       
  1809 
       
  1810 -- paste data you have saved previously here
       
  1811 function LoadLevelData()
       
  1812 
       
  1813 	if (mapID == nil) or (mapID == 0) then
       
  1814 		LoadMap(1)
       
  1815 	else
       
  1816 		LoadMap(mapID)
       
  1817 	end
       
  1818 
       
  1819 	for i = 1, techCount-1 do
       
  1820 		PlaceWaypoint(techX[i],techY[i])
       
  1821 	end
       
  1822 
       
  1823 end
       
  1824 
       
  1825 -- When you save your level, this function
       
  1826 -- generates the AddTeam and AddHog function calls for onGameInit()
       
  1827 function GetDataForSavingHogs(gear)
       
  1828 
       
  1829 	--AddTeam(teamname, color, grave, fort, voicepack, flag)
       
  1830 	--AddHog(hogname, botlevel, health, hat)
       
  1831 
       
  1832 	--this is a quick hack so that the human team(s) will always be
       
  1833 	--given the first move ahead of the AI
       
  1834 	tempDataList = {}
       
  1835 	if GetHogLevel(gear) == 0 then
       
  1836 		tempDataList = hogDataList
       
  1837 	else
       
  1838 		tempDataList = AIHogDataList
       
  1839 	end
       
  1840 
       
  1841 	if GetHogTeamName(gear) ~= lastRecordedTeam then
       
  1842 
       
  1843 		teamCounter = teamCounter + 1
       
  1844 		if teamCounter == 9 then
       
  1845 			teamCounter = 1
       
  1846 		end
       
  1847 
       
  1848 		-- try match team colour to the colours recorded in the colour array
       
  1849 
       
  1850 		tColor = 0x00000000
       
  1851 		for i = 1, #colorArray do
       
  1852 			if GetClanColor(GetHogClan(gear)) == colorArray[i][1] then
       
  1853 				tColor = colorArray[i][2]
       
  1854 			end
       
  1855 		end
       
  1856 
       
  1857 		-- no match, just give him a default colour from the array, then
       
  1858 		if tColor == 0x00000000 then
       
  1859 			tColor = colorArray[teamCounter][2]
       
  1860 		end
       
  1861 
       
  1862 
       
  1863 		-- there is used to be no way to read this data, so
       
  1864 		-- I was assigning teams a random grave, fort, flag and voice
       
  1865 		-- but now we should be able to get the real thing
       
  1866 		-- so let's do it if they haven't used one of the preset teams
       
  1867 		if getGearValue(gear,"grave") == nil then
       
  1868 			tFort = fortArray[1+GetRandom(#fortArray)]
       
  1869 			tGrave = GetHogGrave(gear)
       
  1870 			tFlag = GetHogFlag(gear)
       
  1871 			tVoice = GetHogVoicepack(gear)
       
  1872 			--tGrave = graveArray[1+GetRandom(#graveArray)]
       
  1873 			--tFlag = flagArray[1+GetRandom(#flagArray)]
       
  1874 			--tVoice = voiceArray[1+GetRandom(#voiceArray)]
       
  1875 		else
       
  1876 			tGrave = getGearValue(gear,"grave")
       
  1877 			tFort = getGearValue(gear,"fort")
       
  1878 			tFlag = getGearValue(gear,"flag")
       
  1879 			tVoice = getGearValue(gear,"voice")
       
  1880 		end
       
  1881 
       
  1882 		lastRecordedTeam = GetHogTeamName(gear)
       
  1883 
       
  1884 		table.insert(tempDataList, "")
       
  1885 		table.insert	(tempDataList,
       
  1886 						"	AddTeam(\"" ..
       
  1887 						GetHogTeamName(gear) .."\"" ..
       
  1888 						", " .. "\"" ..tColor .. "\"" ..
       
  1889 						--		--", " .. colorArray[teamCounter][2] ..
       
  1890 						", " .. "\"" .. tGrave .. "\"" ..
       
  1891 						", " .. "\"" .. tFort .. "\"" ..
       
  1892 						", " .. "\"" .. tVoice .. "\"" ..
       
  1893 						", " .. "\"" .. tFlag .. "\"" ..
       
  1894 						")"
       
  1895 						)
       
  1896 
       
  1897 	end
       
  1898 
       
  1899 	table.insert(hhs, gear)
       
  1900 
       
  1901 	table.insert	(tempDataList,	"	hhs[" .. #hhs .."] = AddHog(\"" ..
       
  1902 					GetHogName(gear) .. "\", " ..
       
  1903 					GetHogLevel(gear) .. ", " ..
       
  1904 					GetHealth(gear) .. ", \"" ..
       
  1905 					GetHogHat(gear) .. "\"" ..
       
  1906 					")"
       
  1907 			)
       
  1908 
       
  1909 	table.insert	(tempDataList,"	SetGearPosition(hhs[" .. #hhs .. "], " .. GetX(gear) .. ", " .. GetY(gear) .. ")")
       
  1910 
       
  1911 	if getGearValue(gear,"tag") ~= nil then
       
  1912 		table.insert	(tempDataList,"	setGearValue(hhs[" .. #hhs .. "], \"tag\", \"" .. getGearValue(gear,"tag") .. "\")")
       
  1913 	end
       
  1914 
       
  1915 	-- save the ammo values for each gear, we will call this later
       
  1916 	-- when we want to output it to console
       
  1917 
       
  1918 	if getGearValue(gear,"ranking") ~= nil then
       
  1919 		table.insert(shoppaPointList, "AddShoppaPoint(" .. GetX(gear) .. ", " .. GetY(gear) .. ", " .. getGearValue(gear,"ranking") .. ")")
       
  1920 	end
       
  1921 
       
  1922 	for i = 1, #atkArray do
       
  1923 		setGearValue(gear, atkArray[i][1], GetAmmoCount(gear, atkArray[i][1]))
       
  1924 	end
       
  1925 
       
  1926 	for i = 1, #utilArray do
       
  1927 		setGearValue(gear, utilArray[i][1], GetAmmoCount(gear, utilArray[i][1]))
       
  1928 	end
       
  1929 
       
  1930 	if GetHogLevel(gear) == 0 then
       
  1931 		hogDataList = tempDataList
       
  1932 	else
       
  1933 		AIHogDataList = tempDataList
       
  1934 	end
       
  1935 
       
  1936 end
       
  1937 
       
  1938 -- output hog and team data to the console
       
  1939 function SaveHogData()
       
  1940 
       
  1941 	runOnHogs(GetDataForSavingHogs)
       
  1942 
       
  1943 	WriteLnToConsole("	------ TEAM LIST ------")
       
  1944 
       
  1945 	for i = 1, #hogDataList do
       
  1946 		WriteLnToConsole(hogDataList[i])
       
  1947 	end
       
  1948 
       
  1949 	for i = 1, #AIHogDataList do
       
  1950 		WriteLnToConsole(AIHogDataList[i])
       
  1951 	end
       
  1952 
       
  1953 	WriteLnToConsole("")
       
  1954 
       
  1955 	if #shoppaPointList > 0 then
       
  1956 		WriteLnToConsole("	------ SHOPPA POINT LIST ------")
       
  1957 		for i = 1, #shoppaPointList do
       
  1958 			WriteLnToConsole(shoppaPointList[i])
       
  1959 		end
       
  1960 	end
       
  1961 
       
  1962 
       
  1963 end
       
  1964 
       
  1965 -- generates an onGameInit() template with scheme data, team adds, and hogs
       
  1966 function SaveConfigData()
       
  1967 
       
  1968 	WriteLnToConsole("function onGameInit()")
       
  1969 	WriteLnToConsole("")
       
  1970 
       
  1971 	temp = "	EnableGameFlags(gfDisableWind"
       
  1972 	for i = 1, #gameFlagList do
       
  1973 		if gameFlagList[i][2] == true then
       
  1974 			temp = temp .. ", ".. gameFlagList[i][1]
       
  1975 		end
       
  1976 	end
       
  1977 
       
  1978 	WriteLnToConsole("	ClearGameFlags()")
       
  1979 	WriteLnToConsole(temp .. ")")
       
  1980 
       
  1981 	WriteLnToConsole("	Map = \"" .. Map .. "\"")
       
  1982 	WriteLnToConsole("	Theme = \"" .. "Nature" .. "\"")
       
  1983 	WriteLnToConsole("	TurnTime = " .. TurnTime)
       
  1984 	WriteLnToConsole("	Explosives = " .. Explosives)
       
  1985 	WriteLnToConsole("	MinesNum = " .. MinesNum)
       
  1986 	WriteLnToConsole("	CaseFreq = " .. CaseFreq)
       
  1987 	WriteLnToConsole("	Delay = " .. Delay)
       
  1988 
       
  1989 	WriteLnToConsole("	HealthCaseProb = " .. HealthCaseProb)
       
  1990 	WriteLnToConsole("	HealthCaseAmount = " .. HealthCaseAmount)
       
  1991 	WriteLnToConsole("	DamagePercent = " .. DamagePercent)
       
  1992 	WriteLnToConsole("	MinesTime = " .. MinesTime)
       
  1993 	WriteLnToConsole("	MineDudPercent  = " .. MineDudPercent)
       
  1994 	WriteLnToConsole("	SuddenDeathTurns = " .. SuddenDeathTurns)
       
  1995 	WriteLnToConsole("	WaterRise = " .. WaterRise)
       
  1996 	WriteLnToConsole("	HealthDecrease = " .. HealthDecrease)
       
  1997 
       
  1998 	--WriteLnToConsole("	Ready = " .. Ready)
       
  1999 	--WriteLnToConsole("	AirMinesNum = " .. AirMinesNum)
       
  2000 	--WriteLnToConsole("	ScriptParam = " .. ScriptParam)
       
  2001 	--WriteLnToConsole("	GetAwayTime = " .. GetAwayTime)
       
  2002 
       
  2003 	WriteLnToConsole("")
       
  2004 
       
  2005 	SaveHogData()
       
  2006 
       
  2007 	WriteLnToConsole("")
       
  2008 	WriteLnToConsole("end")
       
  2009 
       
  2010 end
       
  2011 
       
  2012 -- output gear data as special points to be placed in a converted HWMAP, readable by InterpretPoints()
       
  2013 function ConvertGearDataToHWPText()
       
  2014 
       
  2015 	WriteLnToConsole("")
       
  2016 	WriteLnToConsole("--BEGIN HWMAP CONVERTER POINTS--")
       
  2017 	WriteLnToConsole("-- You can paste this data into the HWMAP converter if needed.")
       
  2018 	WriteLnToConsole("--[[")
       
  2019 	WriteLnToConsole("")
       
  2020 
       
  2021 	for i = 1, #hFlagList do
       
  2022 		WriteLnToConsole(hFlagList[i])
       
  2023 	end
       
  2024 
       
  2025 	WriteLnToConsole("")
       
  2026 	WriteLnToConsole("]]")
       
  2027 	WriteLnToConsole("--END HWMAP CONVERTER POINTS--")
       
  2028 	WriteLnToConsole("")
       
  2029 
       
  2030 end
       
  2031 
       
  2032 -- sigh
       
  2033 -- gradually got more bloated with the addition of hwpoint tracking and
       
  2034 -- distinction betweeen the need to track victory/win conditions or not
       
  2035 function GetDataForGearSaving(gear)
       
  2036 
       
  2037 	temp = nil
       
  2038 	specialFlag = nil
       
  2039 	arrayList = nil
       
  2040 
       
  2041 	if GetGearType(gear) == gtMine then
       
  2042 
       
  2043 		if (getGearValue(gear, "tag") ~= nil) then
       
  2044 			temp = 	"	tempG = AddGear(" ..
       
  2045 				GetX(gear) .. ", " ..
       
  2046 				GetY(gear) .. ", gtMine, 0, 0, 0, 0)"
       
  2047 			table.insert(mineList, temp)
       
  2048 			table.insert(mineList, "	SetTimer(tempG, " .. GetTimer(gear) .. ")")
       
  2049 			table.insert(mineList, "	setGearValue(tempG, \"tag\", \"" .. getGearValue(gear,"tag") .. "\")")
       
  2050 		else
       
  2051 
       
  2052 			temp = 	"	SetTimer(" .. "AddGear(" ..
       
  2053 				GetX(gear) .. ", " ..
       
  2054 				GetY(gear) .. ", gtMine, 0, 0, 0, 0)" .. ", " ..
       
  2055 				GetTimer(gear) ..")"
       
  2056 			table.insert(mineList, temp)
       
  2057 
       
  2058 		end
       
  2059 
       
  2060 		if 		GetTimer(gear) == 1 then specialFlag = 1
       
  2061 		elseif	GetTimer(gear) == 1000 then specialFlag = 2
       
  2062 		elseif	GetTimer(gear) == 2000 then specialFlag = 3
       
  2063 		elseif	GetTimer(gear) == 3000 then specialFlag = 4
       
  2064 		elseif	GetTimer(gear) == 4000 then specialFlag = 5
       
  2065 		elseif	GetTimer(gear) == 5000 then specialFlag = 6
       
  2066 		end
       
  2067 
       
  2068 	elseif GetGearType(gear) == gtSMine then
       
  2069 
       
  2070 		arrayList = sMineList
       
  2071 		temp = 	"	tempG = AddGear(" ..
       
  2072 				GetX(gear) .. ", " ..
       
  2073 				GetY(gear) .. ", gtSMine, 0, 0, 0, 0)"
       
  2074 		table.insert(sMineList, temp)
       
  2075 		specialFlag = 7
       
  2076 
       
  2077 	elseif GetGearType(gear) == gtAirMine then
       
  2078 
       
  2079 		if (getGearValue(gear, "tag") ~= nil) then
       
  2080 			temp = 	"	tempG = AddGear(" ..
       
  2081 				GetX(gear) .. ", " ..
       
  2082 				GetY(gear) .. ", gtAirMine, 0, 0, 0, 0)"
       
  2083 			table.insert(airMineList, temp)
       
  2084 			table.insert(airMineList, "	SetTimer(tempG, " .. GetTimer(gear) .. ")")
       
  2085 			table.insert(airMineList, "	setGearValue(tempG, \"tag\", \"" .. getGearValue(gear,"tag") .. "\")")
       
  2086 		else
       
  2087 
       
  2088 			temp = 	"	SetTimer(" .. "AddGear(" ..
       
  2089 				GetX(gear) .. ", " ..
       
  2090 				GetY(gear) .. ", gtAirMine, 0, 0, 0, 0)" .. ", " ..
       
  2091 				GetTimer(gear) ..")"
       
  2092 			table.insert(airMineList, temp)
       
  2093 
       
  2094 		end
       
  2095 
       
  2096 		table.insert(previewDataList, "	PreviewPlacedGear(" .. GetX(gear) ..", " ..	GetY(gear) .. ")")
       
  2097 		specialFlag = 8
       
  2098 
       
  2099 	elseif GetGearType(gear) == gtExplosives then
       
  2100 
       
  2101 		if (getGearValue(gear, "tag") ~= nil) then
       
  2102 			temp = 	"	tempG = AddGear(" ..
       
  2103 				GetX(gear) .. ", " ..
       
  2104 				GetY(gear) .. ", gtExplosives, 0, 0, 0, 0)"
       
  2105 			table.insert(explosivesList, temp)
       
  2106 			table.insert(explosivesList, "	SetHealth(tempG, " .. GetHealth(gear) .. ")")
       
  2107 			table.insert(explosivesList, "	setGearValue(tempG, \"tag\", \"" .. getGearValue(gear,"tag") .. "\")")
       
  2108 		else
       
  2109 
       
  2110 			temp = 	"	SetHealth(" .. "AddGear(" ..
       
  2111 				GetX(gear) .. ", " ..
       
  2112 				GetY(gear) .. ", gtExplosives, 0, 0, 0, 0)" .. ", " ..
       
  2113 				GetHealth(gear) ..")"
       
  2114 			table.insert(explosivesList, temp)
       
  2115 
       
  2116 		end
       
  2117 
       
  2118 		table.insert(previewDataList, "	PreviewPlacedGear(" .. GetX(gear) ..", " ..	GetY(gear) .. ")")
       
  2119 
       
  2120 		if 		GetHealth(gear) == 1 then specialFlag = 15
       
  2121 		elseif	GetHealth(gear) == 25 then specialFlag = 16
       
  2122 		elseif	GetHealth(gear) == 50 then specialFlag = 17
       
  2123 		elseif	GetHealth(gear) == 75 then specialFlag = 18
       
  2124 		elseif	GetHealth(gear) == 100 then specialFlag = 19
       
  2125 		end
       
  2126 
       
  2127 	elseif GetGearType(gear) == gtTarget then
       
  2128 
       
  2129 		arrayList = targetList
       
  2130 		temp = 	"	tempG = AddGear(" ..
       
  2131 				GetX(gear) .. ", " ..
       
  2132 				GetY(gear) .. ", gtTarget, 0, 0, 0, 0)"
       
  2133 		table.insert(targetList, temp)
       
  2134 		specialFlag = 14
       
  2135 
       
  2136 	elseif GetGearType(gear) == gtKnife then
       
  2137 
       
  2138 		arrayList = knifeList
       
  2139 		temp = 	"	tempG = AddGear(" ..
       
  2140 				GetX(gear) .. ", " ..
       
  2141 				GetY(gear) .. ", gtKnife, 0, 0, 0, 0)"
       
  2142 		table.insert(knifeList, temp)
       
  2143 		specialFlag = 13
       
  2144 
       
  2145 	elseif GetGearType(gear) == gtCase then
       
  2146 
       
  2147 		table.insert(previewDataList, "	PreviewPlacedGear(" .. GetX(gear) ..", " ..	GetY(gear) .. ")")
       
  2148 
       
  2149 		if (GetHealth(gear) ~= nil) and (GetHealth(gear) ~= 0) then
       
  2150 
       
  2151 			if (getGearValue(gear, "tag") ~= nil) then
       
  2152 				temp = 	"	tempG = SpawnHealthCrate(" ..
       
  2153 					GetX(gear) ..", " ..
       
  2154 					GetY(gear) ..
       
  2155 					")"
       
  2156 				table.insert(healthCrateList, temp)
       
  2157 				table.insert(healthCrateList, "	SetHealth(tempG, " .. GetHealth(gear) .. ")")
       
  2158 				table.insert(healthCrateList, "	setGearValue(tempG, \"tag\", \"" .. getGearValue(gear,"tag") .. "\")")
       
  2159 			else
       
  2160 				temp = 	"	SetHealth(SpawnHealthCrate(" ..
       
  2161 					GetX(gear) ..", " ..
       
  2162 					GetY(gear) ..
       
  2163 					"), " ..
       
  2164 					GetHealth(gear) ..")"
       
  2165 				table.insert(healthCrateList, temp)
       
  2166 			end
       
  2167 
       
  2168 			if 		GetHealth(gear) == 25 then specialFlag = 9
       
  2169 			elseif	GetHealth(gear) == 50 then specialFlag = 10
       
  2170 			elseif	GetHealth(gear) == 75 then specialFlag = 11
       
  2171 			elseif	GetHealth(gear) == 100 then specialFlag = 12
       
  2172 			end
       
  2173 
       
  2174 		elseif getGearValue(gear,"caseType") == "ammo" then
       
  2175 
       
  2176 			arrayList = wepCrateList
       
  2177 			temp = 	"	tempG = SpawnAmmoCrate(" ..
       
  2178 					GetX(gear) ..", " ..
       
  2179 					GetY(gear) ..", " ..
       
  2180 					getGearValue(gear,"contents") ..
       
  2181 					")"
       
  2182 			table.insert(wepCrateList, temp)
       
  2183 
       
  2184 			tempV = getGearValue(gear,"contents")
       
  2185 			for i = 1, #atkArray do
       
  2186 				if tempV == atkArray[i][2] then
       
  2187 					specialFlag = i + 19
       
  2188 				end
       
  2189 			end
       
  2190 
       
  2191 			--dammit, we probably need two more entries if we want to allow editing of existing maps
       
  2192 			table.insert(wepCrateList, "	setGearValue(tempG, \"caseType\", \"" .. getGearValue(gear,"caseType") .. "\")")
       
  2193 			table.insert(wepCrateList, "	setGearValue(tempG, \"contents\", \"" .. getGearValue(gear,"contents") .. "\")")
       
  2194 
       
  2195 
       
  2196 		elseif getGearValue(gear,"caseType") == "util" then
       
  2197 
       
  2198 			arrayList = utilCrateList
       
  2199 			temp = 	"	tempG = SpawnUtilityCrate(" ..
       
  2200 					GetX(gear) ..", " ..
       
  2201 					GetY(gear) ..", " ..
       
  2202 					getGearValue(gear,"contents") ..
       
  2203 					")"
       
  2204 			table.insert(utilCrateList, temp)
       
  2205 
       
  2206 			tempV = getGearValue(gear,"contents")
       
  2207 			for i = 1, #utilArray do
       
  2208 				if tempV == utilArray[i][2] then
       
  2209 					specialFlag = i + 19 + #atkArray
       
  2210 				end
       
  2211 			end
       
  2212 
       
  2213 			--dammit, we probably need two more entries if we want to allow editing of existing maps
       
  2214 			table.insert(utilCrateList, "	setGearValue(tempG, \"caseType\", \"" .. getGearValue(gear,"caseType") .. "\")")
       
  2215 			table.insert(utilCrateList, "	setGearValue(tempG, \"contents\", \"" .. getGearValue(gear,"contents") .. "\")")
       
  2216 
       
  2217 		end
       
  2218 
       
  2219 	end
       
  2220 
       
  2221 	-- add tracking of simple win/lose for simpler gears that have a tempG = listed above
       
  2222 	if (getGearValue(gear, "tag") ~= nil) and (arrayList ~= nil) then
       
  2223 		table.insert(arrayList, "	setGearValue(tempG, \"tag\", \"" .. getGearValue(gear,"tag") .. "\")")
       
  2224 	end
       
  2225 
       
  2226 	-- this creates a big, messy list of special flags for use in hwmaps
       
  2227 	if specialFlag ~= nil then
       
  2228 		table.insert(hFlagList, "	" .. GetX(gear) .. " " .. GetY(gear) .. " " .. specialFlag)
       
  2229 	end
       
  2230 
       
  2231 end
       
  2232 
       
  2233 -- generate a title and list all the gears if there is at least 1 of them in the list
       
  2234 function AppendGearList(gearList, consoleLine)
       
  2235 	if #gearList > 0 then
       
  2236 		WriteLnToConsole(consoleLine)
       
  2237 		for i = 1, #gearList do
       
  2238 			WriteLnToConsole(gearList[i])
       
  2239 		end
       
  2240 		WriteLnToConsole("")
       
  2241 	end
       
  2242 end
       
  2243 
       
  2244 -- new attempt at doing shit a bit cleaner:
       
  2245 -- it may be a bit verbose, but this should generate a comprehensive, human-readable
       
  2246 -- list of gears, broken up into sections and output it to the console
       
  2247 function SaveGearData()
       
  2248 
       
  2249 	runOnGears(GetDataForGearSaving)
       
  2250 
       
  2251 	AppendGearList(healthCrateList, "	------ HEALTH CRATE LIST ------")
       
  2252 	AppendGearList(wepCrateList, "	------ AMMO CRATE LIST ------")
       
  2253 	AppendGearList(utilCrateList, "	------ UTILITY CRATE LIST ------")
       
  2254 	AppendGearList(explosivesList, "	------ BARREL LIST ------")
       
  2255 	AppendGearList(mineList, "	------ MINE LIST ------")
       
  2256 	AppendGearList(sMineList, "	------ STICKY MINE LIST ------")
       
  2257 	AppendGearList(airMineList, "	------ AIR MINE LIST ------")
       
  2258 	AppendGearList(targetList, "	------ TARGET LIST ------")
       
  2259 	AppendGearList(knifeList, "	------ CLEAVER LIST ------")
       
  2260 
       
  2261 end
       
  2262 
       
  2263 function DoAmmoLoop(i)
       
  2264 
       
  2265 	for x = 1, #atkArray do
       
  2266 		if getGearValue(hhs[i],atkArray[x][1]) ~= 0 then
       
  2267 			WriteLnToConsole("	AddAmmo(hhs[" .. i .. "], " .. atkArray[x][2] .. ", " .. getGearValue(hhs[i],atkArray[x][1]) .. ")")
       
  2268 		end
       
  2269 	end
       
  2270 
       
  2271 	for x = 1, #utilArray do
       
  2272 		if getGearValue(hhs[i],utilArray[x][1]) ~= 0 then
       
  2273 			WriteLnToConsole("	AddAmmo(hhs[" .. i .. "], " .. utilArray[x][2] .. ", " .. getGearValue(hhs[i],utilArray[x][1]) .. ")")
       
  2274 		end
       
  2275 	end
       
  2276 
       
  2277 	WriteLnToConsole("")
       
  2278 
       
  2279 end
       
  2280 
       
  2281 -- this is called when a tagged gear is deleted during a mission
       
  2282 -- it determines if the game is ready to conclude in victory/defeat
       
  2283 function CheckForConclusion(gear)
       
  2284 
       
  2285 	-- failure gears must always all be protected, so if any of them are destroyed the player loses
       
  2286 	if getGearValue(gear,"tag") == "failure" then
       
  2287 		EndGameIn("failure")
       
  2288 	else
       
  2289 
       
  2290 		-- the presence of other tagged gears means that the goal of this mission is not
       
  2291 		-- simply to kill every hedgehog. Thus, we need to count the remaining tagged objects
       
  2292 		-- to see how close we are to completing the mission successfully.
       
  2293 		victoryObj = 0
       
  2294 		failObj = 0
       
  2295 		collectObj = 0
       
  2296 		runOnGears(CheckForConditions)
       
  2297 
       
  2298 		if GetGearType(gear) ~= gtCase then
       
  2299 
       
  2300 			-- non-crates can only be tagged as victory or failure, and as this wasn't tagged
       
  2301 			-- "failure" in our earlier check, this must be a victory tagged gear. Let's adust
       
  2302 			-- the number of objects accordingly as it's in the process of being destroyed.
       
  2303 			victoryObj = victoryObj - 1
       
  2304 
       
  2305 			-- if there are no objectives left to complete, end the game in victory
       
  2306 			if (victoryObj == 0) and (collectObj == 0) then
       
  2307 				EndGameIn("victory")
       
  2308 			end
       
  2309 
       
  2310 		else
       
  2311 			-- this crate was deleted, but was it collected or destroyed, and how does that match
       
  2312 			-- the goals of our mission?
       
  2313 			if (GetGearMessage(gear) == 256) and (getGearValue(gear,"tag") == "collection") then
       
  2314 				if GetHogLevel(CurrentHedgehog) == 0 then
       
  2315 					-- the enemy stole our crate
       
  2316 					EndGameIn("failure")
       
  2317 				else
       
  2318 					collectObj = collectObj - 1
       
  2319 					if (victoryObj == 0) and (collectObj == 0) then
       
  2320 						EndGameIn("victory")
       
  2321 					end
       
  2322 				end
       
  2323 			elseif (GetGearMessage(gear) == 0) and (getGearValue(gear,"tag") == "victory") then
       
  2324 				victoryObj = victoryObj - 1
       
  2325 				if (victoryObj == 0) and (collectObj == 0) then
       
  2326 					EndGameIn("victory")
       
  2327 				end
       
  2328 			else
       
  2329 				-- unfortunately, we messed up our mission.
       
  2330 				EndGameIn("failure")
       
  2331 			end
       
  2332 
       
  2333 		end
       
  2334 
       
  2335 	end
       
  2336 
       
  2337 end
       
  2338 
       
  2339 ---------------------------------
       
  2340 -- THE BIG ONE
       
  2341 ---------------------------------
       
  2342 -- saving process starts here
       
  2343 -- saves all level data to logs/game0.log and generates a simple script template
       
  2344 function SaveLevelData()
       
  2345 
       
  2346 	WriteLnToConsole("------ BEGIN SCRIPT ------")
       
  2347 	WriteLnToConsole("-- Copy and Paste this text into an empty text file, and save it as")
       
  2348 	WriteLnToConsole("-- YOURTITLEHERE.lua, in your Data/Missions/Training/ folder.")
       
  2349 
       
  2350 	WriteLnToConsole("")
       
  2351 
       
  2352 	WriteLnToConsole("HedgewarsScriptLoad(\"/Scripts/Locale.lua\")")
       
  2353 	WriteLnToConsole("HedgewarsScriptLoad(\"/Scripts/Tracker.lua\")")
       
  2354 
       
  2355 	WriteLnToConsole("")
       
  2356 	WriteLnToConsole("local hhs = {}")
       
  2357 	--WriteLnToConsole("local ufoGear = nil")
       
  2358 	WriteLnToConsole("")
       
  2359 
       
  2360 	WriteLnToConsole("local wepArray = {")
       
  2361 	WriteLnToConsole("		amBazooka, amBee, amMortar, amDrill, amSnowball,")
       
  2362 	WriteLnToConsole("		amGrenade, amClusterBomb, amMolotov, amWatermelon, amHellishBomb, amGasBomb,")
       
  2363 	WriteLnToConsole("		amShotgun, amDEagle, amSniperRifle, amSineGun, amLandGun, amIceGun,")
       
  2364 	WriteLnToConsole("		amFirePunch, amWhip, amBaseballBat, amKamikaze, amSeduction, amHammer,")
       
  2365 	WriteLnToConsole("		amMine, amDynamite, amCake, amBallgun, amRCPlane, amSMine, amAirMine,")
       
  2366 	WriteLnToConsole("		amAirAttack, amMineStrike, amDrillStrike, amNapalm, amPiano, amBirdy,")
       
  2367 	WriteLnToConsole("		amBlowTorch, amPickHammer, amGirder, amRubber, amPortalGun,")
       
  2368 	WriteLnToConsole("		amRope, amParachute, amTeleport, amJetpack,")
       
  2369 	WriteLnToConsole("		amInvulnerable, amLaserSight, amVampiric,")
       
  2370 	WriteLnToConsole("		amLowGravity, amExtraDamage, amExtraTime, amResurrector, amTardis, amSwitch")
       
  2371 	WriteLnToConsole("	}")
       
  2372 	WriteLnToConsole("")
       
  2373 
       
  2374 
       
  2375 	SaveConfigData()
       
  2376 
       
  2377 
       
  2378 	WriteLnToConsole("")
       
  2379 	WriteLnToConsole("function LoadHogWeapons()")
       
  2380 	WriteLnToConsole("")
       
  2381 
       
  2382 	if band(GameFlags, gfPerHogAmmo) ~= 0 then -- per hog ammo
       
  2383 		for i = 1, #hhs do
       
  2384 			DoAmmoLoop(i)
       
  2385 		end
       
  2386 
       
  2387 	else	-- team-based ammo
       
  2388 
       
  2389 		teamCounter = 0
       
  2390 		lastRecordedTeam = ""
       
  2391 		for i = 1, #hhs do
       
  2392 
       
  2393 			if GetHogTeamName(hhs[i]) ~= lastRecordedTeam then
       
  2394 				lastRecordedTeam = GetHogTeamName(hhs[i])
       
  2395 				teamCounter = teamCounter + 1
       
  2396 				if teamCounter == 9 then
       
  2397 					teamCounter = 1
       
  2398 				end
       
  2399 				DoAmmoLoop(i)
       
  2400 			end
       
  2401 
       
  2402 		end
       
  2403 
       
  2404 	end
       
  2405 
       
  2406 
       
  2407 	WriteLnToConsole("end")
       
  2408 	WriteLnToConsole("")
       
  2409 
       
  2410 	WriteLnToConsole("")
       
  2411 	WriteLnToConsole("function LoadSprite(pX, pY, pSprite, pFrame, pTint, p1, p2, p3, pLandFlags)")
       
  2412 	WriteLnToConsole("	PlaceSprite(pX, pY, pSprite, pFrame, pTint, p1, p2, p3, pLandFlags)")
       
  2413 	WriteLnToConsole("end")
       
  2414 	WriteLnToConsole("")
       
  2415 
       
  2416 	WriteLnToConsole("")
       
  2417 	WriteLnToConsole("function LoadGearData()")
       
  2418 	WriteLnToConsole("")
       
  2419 
       
  2420 	WriteLnToConsole("	--BEGIN CORE DATA--")
       
  2421 	WriteLnToConsole("")
       
  2422 
       
  2423 	WriteLnToConsole("	------ PORTAL DISTANCE and UFO FUEL ------")
       
  2424 	WriteLnToConsole("	ufoFuel = " .. ufoFuel)
       
  2425 	WriteLnToConsole("	portalDistance = " .. portalDistance*5)
       
  2426 	table.insert(hFlagList, "	" .. portalDistance*5 .. " " .. ufoFuel .. " " .. 98)
       
  2427 	WriteLnToConsole("")
       
  2428 
       
  2429 	for i = 0, (placedCount-1) do
       
  2430 		if placedType[i] == loc("Waypoint Placement Mode") then
       
  2431 			table.insert(waypointList,
       
  2432 			"	AddWayPoint(" ..
       
  2433 				placedX[i] ..", " ..
       
  2434 				placedY[i] ..")"
       
  2435 				)
       
  2436 			table.insert(hFlagList, "	" .. placedX[i] .. " " .. placedY[i] .. " " .. "0")
       
  2437 			table.insert(previewDataList, "	PreviewWayPoint(" .. placedX[i] ..", " ..	placedY[i] .. ")")
       
  2438 		end
       
  2439 	end
       
  2440 
       
  2441 	for i = 0, (placedCount-1) do
       
  2442 		if placedType[i] == loc("Girder Placement Mode") then
       
  2443 			table.insert(girderList,
       
  2444 			"	LoadSprite(" ..
       
  2445 				placedX[i] ..", " ..
       
  2446 				placedY[i] ..", sprAmGirder, " ..
       
  2447 				placedFrame[i] ..			-- the rotation/frame
       
  2448 				", " ..
       
  2449 				placedTint[i] ..", " .. -- "nil, " .. -- color
       
  2450 				"nil, nil, nil, " ..
       
  2451 				placedLandFlags[i] .. ")" --the landType
       
  2452 				)
       
  2453 			table.insert(hFlagList, "	" .. placedX[i] .. " " .. placedY[i] .. " " .. placedHWMapFlag[i])
       
  2454 			table.insert(previewDataList, "	PreviewGirder(" .. placedX[i] ..", " ..	placedY[i] .. ", " .. placedFrame[i] .. ")")
       
  2455 		end
       
  2456 	end
       
  2457 
       
  2458 	for i = 0, (placedCount-1) do
       
  2459 		if placedType[i] == loc("Rubber Placement Mode") then
       
  2460 			table.insert(rubberList,
       
  2461 				"	LoadSprite(" ..
       
  2462 				placedX[i] ..", " ..
       
  2463 				placedY[i] ..", sprAmRubber, " ..
       
  2464 				placedFrame[i] ..
       
  2465 				", " ..
       
  2466 				placedTint[i] ..", " .. -- "nil, " .. -- color
       
  2467 				"nil, nil, nil, " ..
       
  2468 				"lfBouncy)" --placedLandFlags[i] .. ")" --the landType
       
  2469 				)
       
  2470 			table.insert(hFlagList, "	" .. placedX[i] .. " " .. placedY[i] .. " " .. placedHWMapFlag[i])
       
  2471 			table.insert(previewDataList, "	PreviewRubber(" .. placedX[i] ..", " ..	placedY[i] .. ", " .. placedFrame[i] .. ")")
       
  2472 		end
       
  2473 	end
       
  2474 
       
  2475 	for i = 0, (placedCount-1) do
       
  2476 		if placedType[i] == loc("Sprite Placement Mode") then
       
  2477 				table.insert(spriteList,
       
  2478 				"	LoadSprite(" ..
       
  2479 				placedX[i] ..", " ..
       
  2480 				placedY[i] ..", " .. placedSprite[i] .. ", " ..
       
  2481 				placedFrame[i] .. -- I think this is the frame, can't remember
       
  2482 				", " ..
       
  2483 				placedTint[i] ..", " .. -- "nil, " .. -- color
       
  2484 				"nil, nil, nil, " ..
       
  2485 				placedLandFlags[i] .. ")" --the landType
       
  2486 				)
       
  2487 		end
       
  2488 	end
       
  2489 
       
  2490 	AppendGearList(waypointList, "	------ WAYPOINT LIST ------")
       
  2491 	AppendGearList(girderList, "	------ GIRDER LIST ------")
       
  2492 	AppendGearList(rubberList, "	------ RUBBER LIST ------")
       
  2493 	AppendGearList(spriteList, "	------ SPRITE LIST ------")
       
  2494 
       
  2495 	SaveGearData()
       
  2496 
       
  2497 	WriteLnToConsole("	--END CORE DATA--")
       
  2498 
       
  2499 
       
  2500 	WriteLnToConsole("")
       
  2501 	WriteLnToConsole("	LoadHogWeapons()")
       
  2502 	WriteLnToConsole("")
       
  2503 	WriteLnToConsole("end")
       
  2504 	WriteLnToConsole("")
       
  2505 
       
  2506 	WriteLnToConsole("")
       
  2507 	WriteLnToConsole("function onGameStart()")
       
  2508 	WriteLnToConsole("")
       
  2509 	WriteLnToConsole("	LoadGearData()")
       
  2510 	WriteLnToConsole("	DetermineMissionGoal()")
       
  2511 	WriteLnToConsole("")
       
  2512 	WriteLnToConsole("end")
       
  2513 	WriteLnToConsole("")
       
  2514 
       
  2515 	WriteLnToConsole("")
       
  2516 	WriteLnToConsole("function onNewTurn()")
       
  2517 	WriteLnToConsole("	--insert code according to taste")
       
  2518 	WriteLnToConsole("end")
       
  2519 	WriteLnToConsole("")
       
  2520 
       
  2521 	WriteLnToConsole("")
       
  2522 	WriteLnToConsole("function onGameTick()")
       
  2523 	WriteLnToConsole("	runOnGears(UpdateTagCircles)")
       
  2524 	WriteLnToConsole("end")
       
  2525 	WriteLnToConsole("")
       
  2526 
       
  2527 	WriteLnToConsole("function UpdateTagCircles(gear)")
       
  2528 	WriteLnToConsole("	if getGearValue(gear,\"tag\") ~= nil then")
       
  2529 	WriteLnToConsole("		if getGearValue(gear,\"tCirc\") == nil then")
       
  2530 	WriteLnToConsole("			setGearValue(gear, \"tCirc\",AddVisualGear(0,0,vgtCircle,0,true))")
       
  2531 	WriteLnToConsole("		end")
       
  2532 	WriteLnToConsole("")
       
  2533 	WriteLnToConsole("		if getGearValue(gear,\"tag\") == \"victory\" then")
       
  2534 	WriteLnToConsole("			SetVisualGearValues(getGearValue(gear,\"tCirc\"), GetX(gear), GetY(gear), 100, 255, 1, 10, 0, 150, 3, 0xff0000ff)")
       
  2535 	WriteLnToConsole("		elseif getGearValue(gear,\"tag\") == \"failure\" then")
       
  2536 	WriteLnToConsole("			SetVisualGearValues(getGearValue(gear,\"tCirc\"), GetX(gear), GetY(gear), 100, 255, 1, 10, 0, 150, 3, 0x00ff00ff)")
       
  2537 	WriteLnToConsole("		elseif getGearValue(gear,\"tag\") == \"collection\" then")
       
  2538 	WriteLnToConsole("			SetVisualGearValues(getGearValue(gear,\"tCirc\"), GetX(gear), GetY(gear), 100, 255, 1, 10, 0, 150, 3, 0x0000ffff)")
       
  2539 	WriteLnToConsole("		end")
       
  2540 	WriteLnToConsole("	end")
       
  2541 	WriteLnToConsole("end")
       
  2542 	WriteLnToConsole("")
       
  2543 
       
  2544 	WriteLnToConsole("function CheckForConditions(gear)")
       
  2545 	WriteLnToConsole("	if getGearValue(gear,\"tag\") == \"victory\" then")
       
  2546 	WriteLnToConsole("		victoryObj = victoryObj +1")
       
  2547 	WriteLnToConsole("	elseif getGearValue(gear,\"tag\") == \"failure\" then")
       
  2548 	WriteLnToConsole("		failObj = failObj +1")
       
  2549 	WriteLnToConsole("	elseif getGearValue(gear,\"tag\") == \"collection\" then")
       
  2550 	WriteLnToConsole("		collectObj = collectObj +1")
       
  2551 	WriteLnToConsole("	end")
       
  2552 	WriteLnToConsole("end")
       
  2553 	WriteLnToConsole("")
       
  2554 
       
  2555 	WriteLnToConsole("function CheckForConclusion(gear)")
       
  2556 	WriteLnToConsole("")
       
  2557 	WriteLnToConsole("	if getGearValue(gear,\"tag\") == \"failure\" then ")
       
  2558 	WriteLnToConsole("		EndGameIn(\"failure\")")
       
  2559 	WriteLnToConsole("	else ")
       
  2560 	WriteLnToConsole("")
       
  2561 	WriteLnToConsole("		victoryObj = 0")
       
  2562 	WriteLnToConsole("		failObj = 0")
       
  2563 	WriteLnToConsole("		collectObj = 0")
       
  2564 	WriteLnToConsole("		runOnGears(CheckForConditions)")
       
  2565 	WriteLnToConsole("")
       
  2566 	WriteLnToConsole("		if GetGearType(gear) ~= gtCase then")
       
  2567 	WriteLnToConsole("")
       
  2568 	WriteLnToConsole("			victoryObj = victoryObj - 1 ")
       
  2569 	WriteLnToConsole("")
       
  2570 	WriteLnToConsole("			if (victoryObj == 0) and (collectObj == 0) then")
       
  2571 	WriteLnToConsole("				EndGameIn(\"victory\")")
       
  2572 	WriteLnToConsole("			end")
       
  2573 	WriteLnToConsole("")
       
  2574 	WriteLnToConsole("		else")
       
  2575 	WriteLnToConsole("")
       
  2576 	WriteLnToConsole("			if (GetGearMessage(gear) == 256) and (getGearValue(gear,\"tag\") == \"collection\") then ")
       
  2577 	WriteLnToConsole("				if GetHogLevel(CurrentHedgehog) ~= 0 then")
       
  2578 	WriteLnToConsole("					EndGameIn(\"failure\")")
       
  2579 	WriteLnToConsole("				else")
       
  2580 	WriteLnToConsole("					collectObj = collectObj - 1")
       
  2581 	WriteLnToConsole("					if (victoryObj == 0) and (collectObj == 0) then")
       
  2582 	WriteLnToConsole("						EndGameIn(\"victory\")")
       
  2583 	WriteLnToConsole("					end")
       
  2584 	WriteLnToConsole("				end")
       
  2585 	WriteLnToConsole("			elseif (GetGearMessage(gear) == 0) and (getGearValue(gear,\"tag\") == \"victory\") then")
       
  2586 	WriteLnToConsole("				victoryObj = victoryObj - 1")
       
  2587 	WriteLnToConsole("				if (victoryObj == 0) and (collectObj == 0) then ")
       
  2588 	WriteLnToConsole("					EndGameIn(\"victory\")")
       
  2589 	WriteLnToConsole("				end")
       
  2590 	WriteLnToConsole("			else")
       
  2591 	WriteLnToConsole("				EndGameIn(\"failure\")")
       
  2592 	WriteLnToConsole("			end")
       
  2593 	WriteLnToConsole("")
       
  2594 	WriteLnToConsole("		end")
       
  2595 	WriteLnToConsole("")
       
  2596 	WriteLnToConsole("	end")
       
  2597 	WriteLnToConsole("")
       
  2598 	WriteLnToConsole("end")
       
  2599 	WriteLnToConsole("")
       
  2600 
       
  2601 	WriteLnToConsole("function DetermineMissionGoal()")
       
  2602 	WriteLnToConsole("")
       
  2603 	WriteLnToConsole("	victoryObj = 0")
       
  2604 	WriteLnToConsole("	failObj = 0")
       
  2605 	WriteLnToConsole("	collectObj = 0")
       
  2606 	WriteLnToConsole("	vComment = \"\"")
       
  2607 	WriteLnToConsole("	fComment = \"\"")
       
  2608 	WriteLnToConsole("	collectComment = \"\"")
       
  2609 	WriteLnToConsole("")
       
  2610 	WriteLnToConsole("	runOnGears(CheckForConditions)")
       
  2611 	WriteLnToConsole("")
       
  2612 	WriteLnToConsole("	if victoryObj > 0 then ")
       
  2613 	WriteLnToConsole("		if victoryObj == 1 then ")
       
  2614 	WriteLnToConsole("			vComment = loc(\"Destroy the red target\")")
       
  2615 	WriteLnToConsole("		else ")
       
  2616 	WriteLnToConsole("			vComment = loc(\"Destroy the red targets\")")
       
  2617 	WriteLnToConsole("		end")
       
  2618 --	WriteLnToConsole("	else")
       
  2619 --	WriteLnToConsole("		vComment = loc(\"Destroy the enemy.\")")
       
  2620 	WriteLnToConsole("	end")
       
  2621 	WriteLnToConsole("")
       
  2622 	WriteLnToConsole("	if collectObj > 0 then ")
       
  2623 	WriteLnToConsole("		if collectObj == 1 then ")
       
  2624 	WriteLnToConsole("			collectComment = loc(\"Collect the blue target\")")
       
  2625 	WriteLnToConsole("		else ")
       
  2626 	WriteLnToConsole("			collectComment = loc(\"Collect all the blue targets\")")
       
  2627 	WriteLnToConsole("		end")
       
  2628 	WriteLnToConsole("	end")
       
  2629 	WriteLnToConsole("")
       
  2630 	WriteLnToConsole("	if (collectObj == 0) and (victoryObj == 0) then")
       
  2631 	WriteLnToConsole("		vComment = loc(\"Destroy the enemy.\")")
       
  2632 	WriteLnToConsole("	end")
       
  2633 	WriteLnToConsole("")
       
  2634 	WriteLnToConsole("	if failObj > 0 then ")
       
  2635 	WriteLnToConsole("		if failObj == 1 then ")
       
  2636 	WriteLnToConsole("			fComment = loc(\"The green target must survive\")")
       
  2637 	WriteLnToConsole("		else ")
       
  2638 	WriteLnToConsole("			fComment = loc(\"The green targets must survive\")")
       
  2639 	WriteLnToConsole("		end")
       
  2640 	WriteLnToConsole("	end")
       
  2641 	WriteLnToConsole("")
       
  2642 	WriteLnToConsole("	ShowMission(loc(\"User Challenge\"), loc(\"Mission Goals\") .. \":\", collectComment .. \"|\" .. vComment .. \"|\" .. fComment, 0, 0)")
       
  2643 	WriteLnToConsole("")
       
  2644 	WriteLnToConsole("end")
       
  2645 
       
  2646 	WriteLnToConsole("")
       
  2647 	WriteLnToConsole("function isATrackedGear(gear)")
       
  2648 	WriteLnToConsole("	if 	(GetGearType(gear) == gtHedgehog) or")
       
  2649 	WriteLnToConsole("		(GetGearType(gear) == gtExplosives) or")
       
  2650 	WriteLnToConsole("		(GetGearType(gear) == gtMine) or")
       
  2651 	WriteLnToConsole("		(GetGearType(gear) == gtSMine) or")
       
  2652 	WriteLnToConsole("		(GetGearType(gear) == gtAirMine) or")
       
  2653 	WriteLnToConsole("		(GetGearType(gear) == gtTarget) or")
       
  2654 	WriteLnToConsole("		(GetGearType(gear) == gtKnife) or")
       
  2655 	WriteLnToConsole("		(GetGearType(gear) == gtPortal) or")
       
  2656 	WriteLnToConsole("		(GetGearType(gear) == gtCase)")
       
  2657 	WriteLnToConsole("	then")
       
  2658 	WriteLnToConsole("		return(true)")
       
  2659 	WriteLnToConsole("	else")
       
  2660 	WriteLnToConsole("		return(false)")
       
  2661 	WriteLnToConsole("	end")
       
  2662 	WriteLnToConsole("end")
       
  2663 	WriteLnToConsole("")
       
  2664 
       
  2665 	WriteLnToConsole("")
       
  2666 	WriteLnToConsole("function onGearAdd(gear)")
       
  2667 
       
  2668 	--WriteLnToConsole("	if GetGearType(gear) == gtJetpack then")
       
  2669 	--WriteLnToConsole("		ufoGear = gear")
       
  2670 	--WriteLnToConsole("		if (ufoFuel ~= 0) then")
       
  2671 	--WriteLnToConsole("			SetHealth(ufoGear, ufoFuel)")
       
  2672 	--WriteLnToConsole("		end")
       
  2673 	--WriteLnToConsole("	end")
       
  2674 
       
  2675 	WriteLnToConsole("	if isATrackedGear(gear) then")
       
  2676 	WriteLnToConsole("		trackGear(gear)")
       
  2677 	--WriteLnToConsole("		if GetGearType(gear) == gtPortal then")
       
  2678 	--WriteLnToConsole("			setGearValue(gear,\"life\",portalDistance)")
       
  2679 	--WriteLnToConsole("		end")
       
  2680 
       
  2681 	WriteLnToConsole("	end")
       
  2682 	WriteLnToConsole("end")
       
  2683 	WriteLnToConsole("")
       
  2684 
       
  2685 	WriteLnToConsole("")
       
  2686 	WriteLnToConsole("function EndGameIn(c)")
       
  2687 	WriteLnToConsole("")
       
  2688 	WriteLnToConsole("	teamCounter = 0")
       
  2689 	WriteLnToConsole("	lastRecordedTeam = \"\" ")
       
  2690 	WriteLnToConsole("	for i = 1, #hhs do")
       
  2691 	WriteLnToConsole("")
       
  2692 	WriteLnToConsole("		if GetHogTeamName(hhs[i]) ~= lastRecordedTeam then --er, is this okay without nill checks?")
       
  2693 	WriteLnToConsole("")
       
  2694 	WriteLnToConsole("			lastRecordedTeam = GetHogTeamName(hhs[i])")
       
  2695 	WriteLnToConsole("			teamCounter = teamCounter + 1")
       
  2696 	WriteLnToConsole("			if teamCounter == 9 then")
       
  2697 	WriteLnToConsole("				teamCounter = 1")
       
  2698 	WriteLnToConsole("			end")
       
  2699 	WriteLnToConsole("")
       
  2700 	WriteLnToConsole("			if (c ==  \"victory\") and (GetHogLevel(hhs[i]) ~= 0) then")
       
  2701 	WriteLnToConsole("				DismissTeam(GetHogTeamName(hhs[i]))")
       
  2702 	WriteLnToConsole("				ShowMission(loc(\"User Challenge\"), loc(\"MISSION SUCCESSFUL\"), loc(\"Congratulations!\"), 0, 0)")
       
  2703 	WriteLnToConsole("			elseif (c ==  \"failure\") and (GetHogLevel(hhs[i]) == 0) then")
       
  2704 	WriteLnToConsole("				DismissTeam(GetHogTeamName(hhs[i]))")
       
  2705 	WriteLnToConsole("				ShowMission(loc(\"User Challenge\"), loc(\"MISSION FAILED\"), loc(\"Oh no! Just try again!\"), -amSkip, 0)")
       
  2706 	WriteLnToConsole("			elseif (c ==  \"victory\") and (GetHogLevel(hhs[i]) == 0) then")
       
  2707 	WriteLnToConsole("				PlaySound(sndVictory,hhs[i]) -- check if we actually need this")
       
  2708 	WriteLnToConsole("			end")
       
  2709 	WriteLnToConsole("")
       
  2710 	WriteLnToConsole("		end")
       
  2711 	WriteLnToConsole("")
       
  2712 	WriteLnToConsole("	end")
       
  2713 	WriteLnToConsole("")
       
  2714 	WriteLnToConsole("end")
       
  2715 	WriteLnToConsole("")
       
  2716 
       
  2717 	WriteLnToConsole("")
       
  2718 	WriteLnToConsole("function onGearDelete(gear)")
       
  2719 	WriteLnToConsole("")
       
  2720 	WriteLnToConsole("	--insert code according to taste")
       
  2721 	--WriteLnToConsole("	if GetGearType(gear) == gtJetpack then")
       
  2722 	--WriteLnToConsole("		ufoGear = nil")
       
  2723 	--WriteLnToConsole("	end")
       
  2724 	WriteLnToConsole("")
       
  2725 	WriteLnToConsole("	if isATrackedGear(gear) then")
       
  2726 	WriteLnToConsole("")
       
  2727 	WriteLnToConsole("		if getGearValue(gear,\"tag\") ~= nil then")
       
  2728 	WriteLnToConsole("			CheckForConclusion(gear)")
       
  2729 	WriteLnToConsole("		end")
       
  2730 
       
  2731 	--WriteLnToConsole("		if getGearValue(gear,\"tag\") == \"failure\" then")
       
  2732 	--WriteLnToConsole("			EndGameIn(\"failure\")")
       
  2733 	--WriteLnToConsole("		elseif getGearValue(gear,\"tag\") == \"victory\" then")
       
  2734 	--WriteLnToConsole("			EndGameIn(\"victory\")")
       
  2735 	--WriteLnToConsole("		end")
       
  2736 	WriteLnToConsole("")
       
  2737 	WriteLnToConsole("		if getGearValue(gear, \"tCirc\") ~= nil then")
       
  2738 	WriteLnToConsole("			DeleteVisualGear(getGearValue(gear, \"tCirc\"))")
       
  2739 	WriteLnToConsole("		end")
       
  2740 	WriteLnToConsole("")
       
  2741 	WriteLnToConsole("		trackDeletion(gear)")
       
  2742 	WriteLnToConsole("")
       
  2743 	WriteLnToConsole("	end")
       
  2744 	WriteLnToConsole("")
       
  2745 	WriteLnToConsole("end")
       
  2746 	WriteLnToConsole("")
       
  2747 
       
  2748 	WriteLnToConsole("")
       
  2749 	WriteLnToConsole("--enable and/or alter code according to taste")
       
  2750 	WriteLnToConsole("function onAmmoStoreInit()")
       
  2751 	WriteLnToConsole("")
       
  2752 
       
  2753 	WriteLnToConsole("	for i = 1, #wepArray do")
       
  2754 	WriteLnToConsole("		SetAmmo(wepArray[i], 0, 0, 0, 1)")
       
  2755 	WriteLnToConsole("	end")
       
  2756 	WriteLnToConsole("")
       
  2757 	--WriteLnToConsole("	SetAmmo(amBazooka, 2, 0, 0, 0)")
       
  2758 	--WriteLnToConsole("	SetAmmo(amGrenade, 1, 0, 0, 0)")
       
  2759 	--WriteLnToConsole("	SetAmmo(amRope, 9, 0, 0, 0)")
       
  2760 	WriteLnToConsole("	SetAmmo(amSkip, 9, 0, 0, 0)")
       
  2761 	WriteLnToConsole("")
       
  2762 	WriteLnToConsole("end")
       
  2763 	WriteLnToConsole("")
       
  2764 
       
  2765 	WriteLnToConsole("------ END GENERATED MISSION ------")
       
  2766 
       
  2767 	-- at this point, generation for the missions/training output is intended to stop
       
  2768 
       
  2769 	WriteLnToConsole("")
       
  2770 	WriteLnToConsole("function GeneratePreviewData()")
       
  2771 	WriteLnToConsole("")
       
  2772 	for i = 1, #previewDataList do
       
  2773 		WriteLnToConsole(previewDataList[i])
       
  2774 	end
       
  2775 	WriteLnToConsole("")
       
  2776 	WriteLnToConsole("end")
       
  2777 	WriteLnToConsole("")
       
  2778 
       
  2779 	ConvertGearDataToHWPText()
       
  2780 
       
  2781 	WriteLnToConsole("------ END GENERATED SCRIPT ------")
       
  2782 
       
  2783 	AddCaption(loc("Level Data Saved!"))
       
  2784 
       
  2785 end
       
  2786 
       
  2787 ----------------------------------
       
  2788 -- some special effects handling
       
  2789 ----------------------------------
       
  2790 function SmokePuff(x,y,c)
       
  2791 	tempE = AddVisualGear(x, y, vgtSmoke, 0, false)
       
  2792 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  2793 	SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, 1, g9, c )
       
  2794 end
       
  2795 
       
  2796 function HandleGearBasedRankingEffects(gear)
       
  2797 	if getGearValue(gear, "ranking") ~= nil then
       
  2798 		SmokePuff(GetX(gear), GetY(gear),GetRankedColour(getGearValue(gear, "ranking")))
       
  2799 	end
       
  2800 end
       
  2801 
       
  2802 function HandleRankingEffects()
       
  2803 	for i = 1, #shoppaPX do
       
  2804 		SmokePuff(shoppaPX[i], shoppaPY[i], GetRankedColour(shoppaPR[i]))
       
  2805 	end
       
  2806 	runOnHogs(HandleGearBasedRankingEffects)
       
  2807 end
       
  2808 
       
  2809 function UpdateTagCircles(gear)
       
  2810 
       
  2811 	if getGearValue(gear,"tag") ~= nil then
       
  2812 
       
  2813 		if cat[cIndex] == loc("Tagging Mode") then
       
  2814 
       
  2815 			-- generate circs for tagged gears that don't have a circ yet (new)
       
  2816 			if getGearValue(gear,"tCirc") == nil then
       
  2817 				setGearValue(gear, "tCirc",AddVisualGear(0,0,vgtCircle,0,true))
       
  2818 			end
       
  2819 
       
  2820 			if getGearValue(gear,"tag") == "victory" then
       
  2821 				SetVisualGearValues(getGearValue(gear,"tCirc"), GetX(gear), GetY(gear), 100, 255, 1, 10, 0, 150, 3, 0xff0000ff)
       
  2822 			elseif getGearValue(gear,"tag") == "failure" then
       
  2823 				SetVisualGearValues(getGearValue(gear,"tCirc"), GetX(gear), GetY(gear), 100, 255, 1, 10, 0, 150, 3, 0x00ff00ff)
       
  2824 			elseif getGearValue(gear,"tag") == "collection" then
       
  2825 				SetVisualGearValues(getGearValue(gear,"tCirc"), GetX(gear), GetY(gear), 100, 255, 1, 10, 0, 150, 3, 0x0000ffff)
       
  2826 			end
       
  2827 
       
  2828 		else
       
  2829 			SetVisualGearValues(getGearValue(gear,"tCirc"), GetX(gear), GetY(gear), 0, 1, 1, 10, 0, 1, 1, 0x00000000)
       
  2830 		end
       
  2831 
       
  2832 	end
       
  2833 
       
  2834 end
       
  2835 
       
  2836 -- handle short range portal gun
       
  2837 function PortalEffects(gear)
       
  2838 
       
  2839 	if GetGearType(gear) == gtPortal then
       
  2840 
       
  2841 		tag = GetTag(gear)
       
  2842 		if tag == 0 then
       
  2843 			col = 0xfab02aFF -- orange ball
       
  2844 		elseif tag == 1 then
       
  2845 			col = 0x00FF00FF -- orange portal
       
  2846 		elseif tag == 2 then
       
  2847 			col = 0x364df7FF  -- blue ball
       
  2848 		elseif tag == 3 then
       
  2849 			col = 0xFFFF00FF  -- blue portal
       
  2850 		end
       
  2851 
       
  2852 		if (tag == 0) or (tag == 2) then -- i.e ball form
       
  2853 			tempE = AddVisualGear(GetX(gear), GetY(gear), vgtDust, 0, true)
       
  2854 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  2855 			SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, 1, g9, col )
       
  2856 
       
  2857 			remLife = getGearValue(gear,"life")
       
  2858 			remLife = remLife - 1
       
  2859 			setGearValue(gear, "life", remLife)
       
  2860 
       
  2861 			if remLife == 0 then
       
  2862 
       
  2863 				tempE = AddVisualGear(GetX(gear)+15, GetY(gear), vgtSmoke, 0, true)
       
  2864 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  2865 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  2866 
       
  2867 				tempE = AddVisualGear(GetX(gear)-15, GetY(gear), vgtSmoke, 0, true)
       
  2868 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  2869 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  2870 
       
  2871 				tempE = AddVisualGear(GetX(gear), GetY(gear)+15, vgtSmoke, 0, true)
       
  2872 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  2873 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  2874 
       
  2875 				tempE = AddVisualGear(GetX(gear), GetY(gear)-15, vgtSmoke, 0, true)
       
  2876 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  2877 				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, col )
       
  2878 
       
  2879 
       
  2880 				PlaySound(sndVaporize)
       
  2881 				DeleteGear(gear)
       
  2882 
       
  2883 			end
       
  2884 
       
  2885 		end
       
  2886 
       
  2887 	end
       
  2888 
       
  2889 end
       
  2890 
       
  2891 function updateHelp()
       
  2892 
       
  2893 	if (GetCurAmmoType() ~= amGirder) and (GetCurAmmoType() ~= amRubber) and (GetCurAmmoType() ~= amAirAttack) then
       
  2894 
       
  2895 		ShowMission	(
       
  2896 				loc("HEDGE EDITOR"),
       
  2897 				loc("(well... kind of...)"),
       
  2898 				loc("Place Girder: Girder") .. "|" ..
       
  2899 				loc("Place Rubber: Rubber") .. "|" ..
       
  2900 				loc("Place Gear: Air Attack") .. "|" ..
       
  2901 				loc("Change Selection: [Up], [Down], [Left], [Right]") .. "|" ..
       
  2902 				loc("Toggle Help: Precise+1 (While a tool is selected)") .. "|" ..
       
  2903 				" " .. "|" ..
       
  2904 				loc("COMMANDS: (Use while no weapon is selected)") .. "|" ..
       
  2905 				loc("Save Level: Precise+4") .. "|" ..
       
  2906 				loc("Toggle Editing Weapons and Tools: Precise+2") .. "|" ..
       
  2907 				" " .. "|" ..
       
  2908 				--" " .. "|" ..
       
  2909 				"", 4, 5000
       
  2910 				)
       
  2911 						--4
       
  2912 	elseif cat[cIndex] == loc("Girder Placement Mode") then
       
  2913 
       
  2914 		ShowMission	(
       
  2915 				loc("GIRDER PLACEMENT MODE"),
       
  2916 				loc("Use this mode to place girders"),
       
  2917 				loc("Place Girder: [Left Click]") .. "|" ..
       
  2918 				loc("Change Rotation: [Left], [Right]") .. "|" ..
       
  2919 				loc("Change LandFlag: [1], [2], [3], [4]") .. "|" ..
       
  2920 				" " .. "|" ..
       
  2921 				loc("1 - Normal Girder") .. "|" ..
       
  2922 				loc("2 - Indestructible Girder") .. "|" ..
       
  2923 				loc("3 - Icy Girder") .. "|" ..
       
  2924 				loc("4 - Bouncy Girder") .. "|" ..
       
  2925 				" " .. "|" ..
       
  2926 				loc("Deletion Mode: [5]") .. "|" ..
       
  2927 				loc("Toggle Help: Precise+1") .. "|" ..
       
  2928 				"", -amGirder, 60000
       
  2929 				)
       
  2930 
       
  2931 	elseif cat[cIndex] == loc("Rubber Placement Mode") then
       
  2932 
       
  2933 		ShowMission	(
       
  2934 				loc("RUBBER PLACEMENT MODE"),
       
  2935 				loc("Use this mode to place rubberbands"),
       
  2936 				loc("Place Object: [Left Click]") .. "|" ..
       
  2937 				loc("Change Rotation: [Left], [Right]") .. "|" ..
       
  2938 				--"Change LandFlag: [1], [2], [3]" .. "|" ..
       
  2939 				--" " .. "|" ..
       
  2940 				loc("1 - Normal Rubber") .. "|" ..
       
  2941 				--"2 - Indestructible Rubber" .. "|" ..
       
  2942 				--"3 - Icy Rubber" .. "|" ..
       
  2943 				" " .. "|" ..
       
  2944 				loc("Deletion Mode: [5]") .. "|" ..
       
  2945 				loc("Toggle Help: Precise+1") .. "|" ..
       
  2946 				"", -amRubber, 60000
       
  2947 				)
       
  2948 
       
  2949 	elseif cat[cIndex] == loc("Barrel Placement Mode") then
       
  2950 
       
  2951 		ShowMission	(
       
  2952 				loc("BARREL PLACEMENT MODE"),
       
  2953 				loc("Use this mode to place barrels"),
       
  2954 				loc("Place Object: [Left Click]") .. "|" ..
       
  2955 				loc("Change Health: [Left], [Right]") .. "|" ..
       
  2956 				" " .. "|" ..
       
  2957 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  2958 				loc("Toggle Help: Precise+1") .. "|" ..
       
  2959 				"", 8, 60000
       
  2960 				)
       
  2961 
       
  2962 	elseif cat[cIndex] == loc("Cleaver Placement Mode") then
       
  2963 
       
  2964 		ShowMission	(
       
  2965 				loc("CLEAVER MINE PLACEMENT MODE"),
       
  2966 				loc("Use this mode to place cleavers"),
       
  2967 				loc("Place Object: [Left Click]") .. "|" ..
       
  2968 				" " .. "|" ..
       
  2969 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  2970 				loc("Toggle Help: Precise+1") .. "|" ..
       
  2971 				"", -amKnife, 60000
       
  2972 				)
       
  2973 
       
  2974 	elseif cat[cIndex] == loc("Target Placement Mode") then
       
  2975 
       
  2976 		ShowMission	(
       
  2977 				loc("TARGET MINE PLACEMENT MODE"),
       
  2978 				loc("Use this mode to place targets"),
       
  2979 				loc("Place Object: [Left Click]") .. "|" ..
       
  2980 				" " .. "|" ..
       
  2981 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  2982 				loc("Toggle Help: Precise+1") .. "|" ..
       
  2983 				"", 1, 60000
       
  2984 				)
       
  2985 
       
  2986 	elseif cat[cIndex] == loc("Waypoint Placement Mode") then
       
  2987 
       
  2988 		ShowMission	(
       
  2989 				loc("WAYPOINT PLACEMENT MODE"),
       
  2990 				loc("Use this mode to waypoints"),
       
  2991 				loc("Place Waypoint: [Left Click]") .. "|" ..
       
  2992 				" " .. "|" ..
       
  2993 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  2994 				loc("Toggle Help: Precise+1") .. "|" ..
       
  2995 				"", -amAirAttack, 60000
       
  2996 				)
       
  2997 
       
  2998 	elseif cat[cIndex] == loc("Mine Placement Mode") then
       
  2999 
       
  3000 		ShowMission	(
       
  3001 				loc("MINE PLACEMENT MODE"),
       
  3002 				loc("Use this mode to place mines"),
       
  3003 				loc("Place Object: [Left Click]") .. "|" ..
       
  3004 				loc("Change Timer (in milliseconds): [Left], [Right]") .. "|" ..
       
  3005 				" " .. "|" ..
       
  3006 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3007 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3008 				"", -amMine, 60000
       
  3009 				)
       
  3010 
       
  3011 	elseif cat[cIndex] == loc("Sticky Mine Placement Mode") then
       
  3012 
       
  3013 		ShowMission	(
       
  3014 				loc("STiCKY MINE PLACEMENT MODE"),
       
  3015 				loc("Use this mode to place sticky mines"),
       
  3016 				loc("Place Object: [Left Click]") .. "|" ..
       
  3017 				" " .. "|" ..
       
  3018 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3019 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3020 				"", -amSMine, 60000
       
  3021 				)
       
  3022 
       
  3023 	elseif cat[cIndex] == loc("Air Mine Placement Mode") then
       
  3024 
       
  3025 		ShowMission	(
       
  3026 				loc("AIR MINE PLACEMENT MODE"),
       
  3027 				loc("Use this mode to place air mines"),
       
  3028 				loc("Place Object: [Left Click]") .. "|" ..
       
  3029 				" " .. "|" ..
       
  3030 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3031 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3032 				"", -amAirMine, 60000
       
  3033 				)
       
  3034 
       
  3035 	elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
       
  3036 
       
  3037 		ShowMission	(
       
  3038 				"WEAPON CRATE PLACEMENT MODE",
       
  3039 				loc("Use this mode to place weapon crates"),
       
  3040 				loc("Place Object: [Left Click]") .. "|" ..
       
  3041 				loc("Change Content: [Left], [Right]") .. "|" ..
       
  3042 				" " .. "|" ..
       
  3043 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3044 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3045 				"", 7, 60000
       
  3046 				)
       
  3047 
       
  3048 	elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
       
  3049 
       
  3050 		ShowMission	(
       
  3051 				loc("UTILITY CRATE PLACEMENT MODE"),
       
  3052 				loc("Use this mode to place utility crates"),
       
  3053 				loc("Place Object: [Left Click]") .. "|" ..
       
  3054 				loc("Change Content: [Left], [Right]") .. "|" ..
       
  3055 				" " .. "|" ..
       
  3056 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3057 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3058 				"", 5, 60000
       
  3059 				)
       
  3060 
       
  3061 	elseif cat[cIndex] == loc("Health Crate Placement Mode") then
       
  3062 
       
  3063 		ShowMission	(
       
  3064 				loc("HEALTH CRATE PLACEMENT MODE"),
       
  3065 				loc("Use this mode to place utility crates"),
       
  3066 				loc("Place Object: [Left Click]") .. "|" ..
       
  3067 				loc("Change Health Boost: [Left], [Right]") .. "|" ..
       
  3068 				" " .. "|" ..
       
  3069 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3070 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3071 				"", 6, 60000
       
  3072 				)
       
  3073 
       
  3074 	elseif cat[cIndex] == loc("Advanced Repositioning Mode") then
       
  3075 
       
  3076 		ShowMission	(
       
  3077 				loc("ADVANCED REPOSITIONING MODE"),
       
  3078 				loc("Use this mode to select and reposition gears"),
       
  3079 				loc("[Left], [Right]: Change between selection and placement mode.") .. "|" ..
       
  3080 				" " .. "|" ..
       
  3081 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3082 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3083 				"", -amAirAttack, 60000
       
  3084 				)
       
  3085 
       
  3086 	elseif cat[cIndex] == loc("Sprite Modification Mode") then
       
  3087 
       
  3088 		ShowMission	(
       
  3089 				loc("SPRITE MODIFICATION MODE"),
       
  3090 				"",
       
  3091 				"Use this mode to select, modify, or delete existing girders," .. "|" ..
       
  3092 				"rubbers, or sprites." .. "|" ..
       
  3093 				"[Left], [Right]: Change between land-flag" .. "|" ..
       
  3094 				--"[Left], [Right]: Change between selection, land-flag" .. "|" ..
       
  3095 				"modification, and deletion modes." .. "|" ..
       
  3096 				"While in modification mode, you can " .. "|" ..
       
  3097 				"change land-flag by clicking on an object." .. "|" ..
       
  3098 				loc("Set LandFlag: [1], [2], [3], [4]") .. "|" ..
       
  3099 				" " .. "|" ..
       
  3100 				loc("1 - Normal Land") .. "|" ..
       
  3101 				loc("2 - Indestructible Land") .. "|" ..
       
  3102 				loc("3 - Icy Land") .. "|" ..
       
  3103 				loc("4 - Bouncy Land") .. "|" ..
       
  3104 				" " .. "|" ..
       
  3105 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3106 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3107 				"", -amAirAttack, 60000
       
  3108 				)
       
  3109 
       
  3110 	elseif cat[cIndex] == loc("Sprite Placement Mode") then
       
  3111 
       
  3112 		ShowMission	(
       
  3113 				loc("SPRITE PLACEMENT MODE"),
       
  3114 				loc("Use this mode to place custom sprites."),
       
  3115 				loc("[Left], [Right]: Change sprite selection") .. "|" ..
       
  3116 				loc("Set LandFlag: [1], [2], [3], [4]") .. "|" ..
       
  3117 				" " .. "|" ..
       
  3118 				loc("1 - Normal Land") .. "|" ..
       
  3119 				loc("2 - Indestructible Land") .. "|" ..
       
  3120 				loc("3 - Icy Land") .. "|" ..
       
  3121 				loc("4 - Bouncy Land") .. "|" ..
       
  3122 				" " .. "|" ..
       
  3123 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3124 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3125 				"", 2, 60000
       
  3126 				)
       
  3127 
       
  3128 	--elseif cat[cIndex] == loc("Sprite Testing Mode") then
       
  3129 
       
  3130 	--	ShowMission	(
       
  3131 	--			"SPRITE TESTING MODE",
       
  3132 	--			"Use this mode to test sprites before you place them.",
       
  3133 	--			"Place Temporary Visual Test: [Left Click]" .. "|" ..
       
  3134 	--			"[Left], [Right]: Change between sprites." .. "|" ..
       
  3135 	--			" " .. "|" ..
       
  3136 	--			loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3137 	--			loc("Toggle Help: Precise+1") .. "|" ..
       
  3138 	--			"", 3, 60000
       
  3139 	--			)
       
  3140 
       
  3141 	elseif cat[cIndex] == loc("Tagging Mode") then
       
  3142 
       
  3143 		ShowMission	(
       
  3144 				loc("TAGGING MODE"),
       
  3145 				loc("Use this mode to tag gears for win/lose conditions."),
       
  3146 				loc("Tag Gear: [Left Click]") .. "|" ..
       
  3147 				loc("[Left], [Right]: Change between tagging modes.") .. "|" ..
       
  3148 				" " .. "|" ..
       
  3149 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3150 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3151 				"", 3, 60000
       
  3152 				)
       
  3153 	elseif cat[cIndex] == loc("Hog Identity Mode") then
       
  3154 
       
  3155 		ShowMission	(
       
  3156 				loc("HOG IDENTITY MODE"),
       
  3157 				loc("Use this mode to give a hog a preset identity and weapons."),
       
  3158 				loc("Set Identity: [Left Click]") .. "|" ..
       
  3159 				loc("[Left], [Right]: Change between identities.") .. "|" ..
       
  3160 				" " .. "|" ..
       
  3161 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3162 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3163 				"", 3, 60000
       
  3164 				)
       
  3165 
       
  3166 	elseif cat[cIndex] == loc("Team Identity Mode") then
       
  3167 
       
  3168 		ShowMission	(
       
  3169 				loc("TEAM IDENTITY MODE"),
       
  3170 				loc("Use this mode to give an entire team themed hats and names."),
       
  3171 				loc("Set Identity: [Left Click]") .. "|" ..
       
  3172 				loc("[Left], [Right]: Change between identities.") .. "|" ..
       
  3173 				" " .. "|" ..
       
  3174 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3175 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3176 				"", 3, 60000
       
  3177 				)
       
  3178 
       
  3179 	elseif cat[cIndex] == loc("Health Modification Mode") then
       
  3180 
       
  3181 		ShowMission	(
       
  3182 				loc("HEALTH MODIFICATION MODE"),
       
  3183 				loc("Use this mode to set the health of hogs."),
       
  3184 				loc("Set Health: [Left Click]") .. "|" ..
       
  3185 				loc("[Left], [Right]: Change health value.") .. "|" ..
       
  3186 				" " .. "|" ..
       
  3187 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
       
  3188 				loc("Toggle Help: Precise+1") .. "|" ..
       
  3189 				"", 3, 60000
       
  3190 				)
       
  3191 
       
  3192 	end
       
  3193 
       
  3194 
       
  3195 	if helpDisabled == true then
       
  3196 		HideMission()
       
  3197 	end
       
  3198 
       
  3199 end
       
  3200 
       
  3201 -- called in onGameTick()
       
  3202 function HandleHedgeEditor()
       
  3203 
       
  3204 	if CurrentHedgehog ~= nil then
       
  3205 
       
  3206 		genTimer = genTimer + 1
       
  3207 
       
  3208 
       
  3209 		tSprCol = 0x00000000
       
  3210 		tempFrame = 0
       
  3211 		xDisplacement = 42
       
  3212 		yDisplacement = 42
       
  3213 
       
  3214 		if (curWep == amAirAttack) then
       
  3215 
       
  3216 			--wowaweewa, holyeeeee shite this is badly hacked (please rewrite when less lazy/morefeatures)
       
  3217 			dCol = 0xFFFFFFFF
       
  3218 			dFrame = 0
       
  3219 			dAngle = 0
       
  3220 			if (cat[cIndex] == loc("Mine Placement Mode")) then
       
  3221 				dSprite = sprBotlevels--sprMineOff
       
  3222 				dFrame = 1
       
  3223 			elseif (cat[cIndex] == loc("Sticky Mine Placement Mode")) then
       
  3224 				dSprite = sprBotlevels--sprSMineOff
       
  3225 				dFrame = 2
       
  3226 			elseif (cat[cIndex] == loc("Air Mine Placement Mode")) then
       
  3227 				dSprite = sprAirMine
       
  3228 			elseif (cat[cIndex] == loc("Barrel Placement Mode")) then
       
  3229 				dSprite = sprExplosives
       
  3230 			elseif (cat[cIndex] == loc("Health Crate Placement Mode")) then
       
  3231 				dSprite = sprFAid
       
  3232 			elseif (cat[cIndex] == loc("Weapon Crate Placement Mode")) then
       
  3233 				dSprite = sprCase
       
  3234 			elseif (cat[cIndex] == loc("Utility Crate Placement Mode")) then
       
  3235 				dSprite = sprUtility
       
  3236 			elseif (cat[cIndex] == loc("Target Placement Mode")) then
       
  3237 				dSprite = sprTarget
       
  3238 			elseif (cat[cIndex] == loc("Cleaver Placement Mode")) then
       
  3239 				dAngle = 270
       
  3240 				dSprite = sprKnife
       
  3241 			elseif (cat[cIndex] == loc("Sprite Placement Mode")) then
       
  3242 				dSprite = reducedSpriteIDArray[pIndex]
       
  3243 				dFrame = 1
       
  3244 			else
       
  3245 				dCol = 0xFFFFFF00
       
  3246 				dSprite = sprArrow
       
  3247 			end
       
  3248 
       
  3249 			if CG == nil then
       
  3250 				CG = AddVisualGear(CursorX, CursorY, vgtStraightShot,0,true,3)
       
  3251 			end
       
  3252 			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(CG)
       
  3253 			SetVisualGearValues(CG, CursorX, CursorY, 0, 0, dAngle, dFrame, 1000, dSprite, 1000, dCol)
       
  3254 
       
  3255 
       
  3256 
       
  3257 			if crateSprite == nil then
       
  3258 				crateSprite = AddVisualGear(CursorX, CursorY-35, vgtStraightShot,0,true,3)
       
  3259 				for i = 1, 4 do
       
  3260 					tSpr[i] = AddVisualGear(CursorX, CursorY-35, vgtStraightShot,0,true,3)
       
  3261 				end
       
  3262 			end
       
  3263 
       
  3264 
       
  3265 			if (cat[cIndex] == loc("Weapon Crate Placement Mode")) or (cat[cIndex] == loc("Utility Crate Placement Mode")) then
       
  3266 				if (cat[cIndex] == loc("Weapon Crate Placement Mode")) then
       
  3267 					tArr = atkArray
       
  3268 				else
       
  3269 					tArr = utilArray
       
  3270 				end
       
  3271 
       
  3272 				tSprCol = 0xFFFFFFFF
       
  3273 				tempFrame = tArr[pIndex][3]
       
  3274 
       
  3275 			end
       
  3276 
       
  3277 		else
       
  3278 			if CG ~= nil then
       
  3279 				SetVisualGearValues(CG, 0, 0, 0, 0, 0, 0, 1000, sprArrow, 1000, 0xFFFFFF00)
       
  3280 			end
       
  3281 		end
       
  3282 
       
  3283 		SetVisualGearValues(crateSprite, CursorX+xDisplacement, CursorY+yDisplacement, 0, 0, dAngle, tempFrame, 1000, sprAMAmmos, 1000, tSprCol)
       
  3284 		SetVisualGearValues(tSpr[1], CursorX+xDisplacement-2, CursorY+yDisplacement-2, 0, 0, dAngle, 10, 1000, sprTarget, 1000, tSprCol)
       
  3285 		SetVisualGearValues(tSpr[2], CursorX+xDisplacement-2, CursorY+yDisplacement+2, 0, 0, dAngle, 10, 1000, sprTarget, 1000, tSprCol)
       
  3286 		SetVisualGearValues(tSpr[3], CursorX+xDisplacement+2, CursorY+yDisplacement-2, 0, 0, dAngle, 10, 1000, sprTarget, 1000, tSprCol)
       
  3287 		SetVisualGearValues(tSpr[4], CursorX+xDisplacement+2, CursorY+yDisplacement+2, 0, 0, dAngle, 10, 1000, sprTarget, 1000, tSprCol)
       
  3288 
       
  3289 
       
  3290 		if genTimer >= 100 then
       
  3291 
       
  3292 			genTimer = 0
       
  3293 
       
  3294 			--if destroyMap == true then
       
  3295 			--	BlowShitUpPartTwo()
       
  3296 			--end
       
  3297 
       
  3298 			curWep = GetCurAmmoType()
       
  3299 
       
  3300 			HandleRankingEffects()
       
  3301 			runOnGears(PortalEffects)
       
  3302 
       
  3303 			-- change to girder mode on weapon swap
       
  3304 			if (cIndex ~= 1) and (curWep == amGirder) then
       
  3305 				cIndex = 1
       
  3306 				RedefineSubset()
       
  3307 				updateHelp()
       
  3308 			elseif (cIndex ~=2) and (curWep == amRubber) then
       
  3309 				cIndex = 2
       
  3310 				RedefineSubset()
       
  3311 				updateHelp()
       
  3312 			-- change to generic mode if girder no longer selected
       
  3313 			elseif (cIndex == 1) and (curWep ~= amGirder) then
       
  3314 				cIndex = 3 -- was 2
       
  3315 				RedefineSubset()
       
  3316 				--updateHelp()
       
  3317 			elseif (cIndex == 2) and (curWep ~= amRubber) then
       
  3318 				cIndex = 3 --new
       
  3319 				RedefineSubset()
       
  3320 				--updateHelp()
       
  3321 
       
  3322 			end
       
  3323 
       
  3324 			-- update display selection criteria
       
  3325 			if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
       
  3326 				AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
       
  3327 				AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
       
  3328 				if superDelete == true then
       
  3329 					AddCaption(loc("Warning: Deletition Mode Active"),0xffba00ff,capgrpAmmoinfo)
       
  3330 				end
       
  3331 			end
       
  3332 
       
  3333 
       
  3334 			if sSprite ~= nil then
       
  3335 				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(sSprite)
       
  3336 				SetVisualGearValues(sSprite, g1, g2, 0, 0, g5, g6, 10000, g8, 10000, g10 )
       
  3337 				--AddCaption(g7)
       
  3338 			end
       
  3339 
       
  3340 		end
       
  3341 
       
  3342 	end
       
  3343 
       
  3344 
       
  3345 	if (ufoFuel ~= 0) then
       
  3346 		if ufoFuel == 2000 then
       
  3347 			SetHealth(ufoGear, 2000)
       
  3348 		end
       
  3349 	end
       
  3350 
       
  3351 	-- kinda lazy, but at least we don't have to do elaborate tacking elsewhere
       
  3352 	SetVisualGearValues(sCirc, 0, 0, 0, 1, 1, 10, 0, 1, 1, 0x00000000)
       
  3353 	--update selected gear display
       
  3354 	if (cat[cIndex] == loc("Advanced Repositioning Mode")) and (sGear ~= nil) then
       
  3355 		SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 100, 255, 1, 10, 0, 300, 3, 0xff00ffff)
       
  3356 	elseif (cat[cIndex] == loc("Sprite Modification Mode")) and (sSprite ~= nil) then
       
  3357 		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(sSprite)
       
  3358 		SetVisualGearValues(sSprite, g1, g2, 0, 0, g5, g6, 10000, g8, 10000, g10 )
       
  3359 	elseif (cat[cIndex] == loc("Tagging Mode")) then
       
  3360 		if (sGear ~= nil) or (closestGear ~= nil) then
       
  3361 			--recently disabled
       
  3362 			--SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 0, 1, 1, 10, 0, 1, 1, 0x00000000)
       
  3363 			closestGear = nil
       
  3364 			sGear = nil
       
  3365 		end
       
  3366 	end
       
  3367 
       
  3368 
       
  3369 	runOnGears(UpdateTagCircles)
       
  3370 
       
  3371 
       
  3372 	-- some kind of target detected, tell me your story
       
  3373 	if cGear ~= nil then
       
  3374 
       
  3375 		x,y = GetGearTarget(cGear)
       
  3376 
       
  3377 		if GetGearType(cGear) == gtAirAttack then
       
  3378 			DeleteGear(cGear)
       
  3379 			PlaceObject(x, y)
       
  3380 		elseif GetGearType(cGear) == gtGirder then
       
  3381 
       
  3382 			CGR = GetState(cGear)
       
  3383 
       
  3384 			-- improve rectangle test based on CGR when you can be bothered
       
  3385 			--if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
       
  3386 			--	AddCaption(loc("Invalid Girder Placement"),0xffba00ff,capgrpVolume)
       
  3387 			--else
       
  3388 				PlaceObject(x, y)
       
  3389 			--end
       
  3390 
       
  3391 			-- this allows the girder tool to be used like a mining laser
       
  3392 
       
  3393 		--[[
       
  3394 
       
  3395 			if CGR < 4 then
       
  3396 				AddGear(x, y, gtGrenade, 0, 0, 0, 1)
       
  3397 			elseif CGR == 4 then
       
  3398 				g = AddGear(x-30, y, gtGrenade, 0, 0, 0, 1)
       
  3399 				g = AddGear(x+30, y, gtGrenade, 0, 0, 0, 1)
       
  3400 			elseif CGR == 5 then -------
       
  3401 				g = AddGear(x+30, y+30, gtGrenade, 0, 0, 0, 1)
       
  3402 				g = AddGear(x-30, y-30, gtGrenade, 0, 0, 0, 1)
       
  3403 			elseif CGR == 6 then
       
  3404 				g = AddGear(x, y+30, gtGrenade, 0, 0, 0, 1)
       
  3405 				g = AddGear(x, y-30, gtGrenade, 0, 0, 0, 1)
       
  3406 			elseif CGR == 7 then -------
       
  3407 				g = AddGear(x+30, y-30, gtGrenade, 0, 0, 0, 1)
       
  3408 				g = AddGear(x-30, y+30, gtGrenade, 0, 0, 0, 1)
       
  3409 			end
       
  3410 ]]
       
  3411 		end
       
  3412 
       
  3413 	end
       
  3414 
       
  3415 end
       
  3416 
       
  3417 --------------------------------------------------
       
  3418 -- EVENT HANDLERS
       
  3419 --------------------------------------------------
       
  3420 
       
  3421 function commandMode()
       
  3422 	if (preciseOn == true) and ((GetCurAmmoType() == amNothing) or (GetCurAmmoType() == amSkip)) then
       
  3423 		return(true)
       
  3424 	else
       
  3425 		return(false)
       
  3426 	end
       
  3427 end
       
  3428 
       
  3429 function onTimer(s)
       
  3430 
       
  3431 	superDelete = false
       
  3432 	if (commandMode() == true) and (s == 4) then
       
  3433 		SaveLevelData() -- positions of crates, etc
       
  3434 	elseif (commandMode() == true) and (s == 2) then
       
  3435 		if GetAmmoCount(CurrentHedgehog, amAirAttack) == 100 then
       
  3436 			SetEditingWeps(0)
       
  3437 			AddCaption(loc("The editor weapons and tools have been removed!"))
       
  3438 		else
       
  3439 			SetEditingWeps(100)
       
  3440 			AddCaption(loc("The editor weapons and tools have been added!"))
       
  3441 		end
       
  3442 	elseif (preciseOn == true) and (s == 1) then
       
  3443 		if (GetCurAmmoType() == amGirder) or  (GetCurAmmoType() == amRubber) or  (GetCurAmmoType() == amAirAttack) then
       
  3444 			helpDisabled = not(helpDisabled)
       
  3445 			AddCaption("Help Disabled: " .. BoolToString(helpDisabled),0xffba00ff,capgrpVolume)
       
  3446 			updateHelp()
       
  3447 		end
       
  3448 	elseif (cat[cIndex] == loc("Sprite Placement Mode")) or (cat[cIndex] == loc("Girder Placement Mode")) or (cat[cIndex] == loc("Rubber Placement Mode")) or (cat[cIndex] == loc("Sprite Modification Mode")) then
       
  3449 
       
  3450 		if (cat[cIndex] == loc("Rubber Placement Mode")) and (s ~= 5) then
       
  3451 			landType = lfBouncy
       
  3452 			AddCaption(loc("Bouncy Land"),0xffba00ff,capgrpAmmoinfo)
       
  3453 		elseif s == 1 then
       
  3454 			landType = 0
       
  3455 			AddCaption(loc("Normal Land"),0xffba00ff,capgrpAmmoinfo)
       
  3456 		elseif s == 2 then
       
  3457 			landType = lfIndestructible
       
  3458 			AddCaption(loc("Indestructible Land"),0xffba00ff,capgrpAmmoinfo)
       
  3459 		elseif s == 3 then
       
  3460 			landType = lfIce
       
  3461 			AddCaption(loc("Icy Land"),0xffba00ff,capgrpAmmoinfo)
       
  3462 		elseif (s == 4) then --and (cat[cIndex] == "Sprite Placement Mode") then
       
  3463 			landType = lfBouncy
       
  3464 			AddCaption(loc("Bouncy Land"),0xffba00ff,capgrpAmmoinfo)
       
  3465 		elseif (s == 5) and (cat[cIndex] ~= loc("Sprite Modification Mode")) then
       
  3466 			superDelete = true
       
  3467 			-- this and the above should probably be shown in another place where the other
       
  3468 			-- two add captions are displayed for this kinda thing
       
  3469 			--AddCaption(loc("Warning: Deletition Mode Active"),0xffba00ff,capgrpAmmoinfo)
       
  3470 		end
       
  3471 	elseif pMode[pIndex] == loc("Selection Mode") then
       
  3472 		setGearValue(sGear, "ranking", s)
       
  3473 	end
       
  3474 
       
  3475 end
       
  3476 
       
  3477 function onPrecise()
       
  3478 
       
  3479 	preciseOn = true
       
  3480 
       
  3481 	--ParseCommand("voicepack " .. "Surfer")
       
  3482 	--AddCaption(GetHogGrave(CurrentHedgehog))
       
  3483 
       
  3484 	--if (pMode[pIndex] == "Selection Mode") and (closestGear ~= nil) then
       
  3485 	--	menuEnabled = not(menuEnabled)
       
  3486 		--showmenu
       
  3487 	--end
       
  3488 
       
  3489 	--BlowShitUp()
       
  3490 
       
  3491 --[[
       
  3492 	frameID = 1
       
  3493 	visualSprite = sprAmGirder--reducedSpriteIDArray[pIndex]
       
  3494 	--visualSprite = spriteIDArray[pIndex]
       
  3495 	tempE = AddVisualGear(1, 1, vgtStraightShot, 0, true,1)
       
  3496 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
       
  3497 	SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
       
  3498 
       
  3499 ]]
       
  3500 
       
  3501 end
       
  3502 
       
  3503 function onPreciseUp()
       
  3504 	preciseOn = false
       
  3505 end
       
  3506 
       
  3507 --[[function onLJump()
       
  3508 end
       
  3509 
       
  3510 function onHJump()
       
  3511 end]]
       
  3512 
       
  3513 --[[function UpdateMenu()
       
  3514 
       
  3515 	preMenuCfg = loc("Use the arrow keys to navigate this menu") .. "|"
       
  3516 	postMenuCfg = loc("Press [Fire] to accept this configuration.")
       
  3517 
       
  3518 	menu = 	{
       
  3519 			loc("Walls Required") .. ": " .. #wTouched .. "|",
       
  3520 			loc("Surf Before Crate") .. ": " .. BoolToCfgTxt(requireSurfer) .. "|",
       
  3521 			loc("Attack From Rope") .. ": " .. BoolToCfgTxt(AFR) .. "|",
       
  3522 			loc("Super Weapons") .. ": " .. BoolToCfgTxt(allowCrazyWeps) .. "|"
       
  3523 			}
       
  3524 end
       
  3525 
       
  3526 function HandleStartingStage()
       
  3527 
       
  3528 	temp = menu[menuIndex]
       
  3529 	menu[menuIndex] = "--> " .. menu[menuIndex]
       
  3530 
       
  3531 	missionComment = ""
       
  3532 	for i = 1, #menu do
       
  3533 		missionComment = missionComment .. menu[i]
       
  3534 	end
       
  3535 
       
  3536 	ShowMission	(
       
  3537 				loc("HEDGE EDITOR") .. " 0.4",
       
  3538 				loc("Edit gear properties"),
       
  3539 				preMenuCfg..
       
  3540 				missionComment ..
       
  3541 				postMenuCfg ..
       
  3542 				--" " .. "|" ..
       
  3543 				"", 4, 300000
       
  3544 				)
       
  3545 
       
  3546 	menu[menuIndex] = temp
       
  3547 
       
  3548 end
       
  3549 
       
  3550 function UpdateMenuCategoryOrSomething()
       
  3551 	temp = menu[1]
       
  3552 	menu = {}
       
  3553 	if temp == "Initialisation Menu" then
       
  3554 		for i = 1, #initMenuArray do
       
  3555 			menu[i] = initMenuArray[i] .. ": " .. initMenuArray[2]
       
  3556 		end
       
  3557 	elseif temp == "GameFlag Menu" then
       
  3558 		for i = 1, #gameFlagList do
       
  3559 			menu[i] = gameFlagList[1] .. ": " .. BoolToStr(gameFlagList[2])
       
  3560 		end
       
  3561 	elseif temp == "Ammo Menu" then
       
  3562 		for i  = 1, #atkArray do	--except, this should be per hog, not overall :(
       
  3563 			--menu[i] = atkArray[i][2] .. ": " .. atkArray[i][3]
       
  3564 			menu[i] = atkArray[i][2] .. ": " .. getGearValue(sGear,atkArray[i][1])
       
  3565 		end
       
  3566 		-- you should run through all the hogs and assign them ammo values based on the
       
  3567 		-- ammo set, yea, let's write that function in 5th
       
  3568 		for i = #menu, #utilArray do
       
  3569 		end
       
  3570 	end
       
  3571 end
       
  3572 
       
  3573 function doMenuShit(d)
       
  3574 
       
  3575 	if d == "up" then
       
  3576 		menuIndex = menuIndex -1
       
  3577 		if 	menuIndex == 0 then
       
  3578 			menuIndex = #menu
       
  3579 		end
       
  3580 	elseif d == "down" then
       
  3581 		menuIndex = menuIndex +1
       
  3582 		if menuIndex > #menu then
       
  3583 			menuIndex = 1
       
  3584 		end
       
  3585 	elseif d == "left" then
       
  3586 
       
  3587 	elseif d == "right" then
       
  3588 
       
  3589 	end
       
  3590 
       
  3591 end]]
       
  3592 
       
  3593 ---------------------------------------------------------------
       
  3594 -- Cycle through selection subsets (by changing pIndex, pMode)
       
  3595 -- i.e 	health of barrels, medikits,
       
  3596 --		timer of mines
       
  3597 --		contents of crates etc.
       
  3598 ---------------------------------------------------------------
       
  3599 function onLeft()
       
  3600 
       
  3601 	leftHeld = true
       
  3602 	rightHeld = false
       
  3603 
       
  3604 	--if menuEnabled == true then
       
  3605 		--doMenuShit("left")
       
  3606 
       
  3607 	--else -- normal case
       
  3608 
       
  3609 		pIndex = pIndex - 1
       
  3610 		if pIndex == 0 then
       
  3611 			pIndex = #pMode
       
  3612 		end
       
  3613 
       
  3614 		if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
       
  3615 			AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
       
  3616 		end
       
  3617 
       
  3618 	--end
       
  3619 
       
  3620 end
       
  3621 
       
  3622 function onRight()
       
  3623 
       
  3624 	leftHeld = false
       
  3625 	rightHeld = true
       
  3626 
       
  3627 	--if menuEnabled == true then
       
  3628 		--doMenuShit("right")
       
  3629 
       
  3630 	--else -- normal case
       
  3631 
       
  3632 		pIndex = pIndex + 1
       
  3633 		if pIndex > #pMode then
       
  3634 			pIndex = 1
       
  3635 		end
       
  3636 
       
  3637 		if (curWep == amGirder) or (curWep == amRubber) or (curWep == amAirAttack) then
       
  3638 			AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
       
  3639 		end
       
  3640 
       
  3641 	--end
       
  3642 
       
  3643 end
       
  3644 
       
  3645 ---------------------------------------------------------
       
  3646 -- Cycle through primary categories (by changing cIndex)
       
  3647 -- i.e 	mine, sticky mine, barrels
       
  3648 --		health/weapon/utility crate, placement of gears
       
  3649 ---------------------------------------------------------
       
  3650 function onUp()
       
  3651 
       
  3652 	--if menuEnabled == true then
       
  3653 		--doMenuShit("up")
       
  3654 
       
  3655 	--elseif (curWep ~= amGirder) then
       
  3656 	if (curWep ~= amGirder) then
       
  3657 		--AddCaption(cIndex)
       
  3658 		cIndex = cIndex - 1
       
  3659 		if (cIndex == 1) or (cIndex == 2) then --1	--we no longer hit girder by normal means
       
  3660 			cIndex = #cat
       
  3661 		end
       
  3662 
       
  3663 		RedefineSubset()
       
  3664 		updateHelp()
       
  3665 
       
  3666 	end
       
  3667 
       
  3668 end
       
  3669 
       
  3670 function onDown()
       
  3671 
       
  3672 	--if menuEnabled == true then
       
  3673 		--doMenuShit("down")
       
  3674 
       
  3675 	--elseif (curWep ~= amGirder) then
       
  3676 	if (curWep ~= amGirder) then
       
  3677 		cIndex = cIndex + 1
       
  3678 		if cIndex > #cat then
       
  3679 			cIndex = 3	 -- 2 ----we no longer hit girder by normal means
       
  3680 		end
       
  3681 
       
  3682 		RedefineSubset()
       
  3683 		updateHelp()
       
  3684 
       
  3685 	end
       
  3686 
       
  3687 end
       
  3688 
       
  3689 function onParameters()
       
  3690 
       
  3691     parseParams()
       
  3692 
       
  3693 	ufoFuel = tonumber(params["ufoFuel"])
       
  3694 	if ufoFuel == nil then
       
  3695 		ufoFuel = 0
       
  3696 	end
       
  3697 
       
  3698 	mapID = tonumber(params["m"])
       
  3699 
       
  3700 	--15 is a good short range portal, for what it's worth
       
  3701 	if tonumber(params["portalDistance"]) ~= nil then
       
  3702 		portalDistance = div(tonumber(params["portalDistance"]),5)
       
  3703 	end
       
  3704 
       
  3705 	if portalDistance == nil then
       
  3706 		portalDistance = 5000
       
  3707 	end
       
  3708 
       
  3709 	if params["helpDisabled"] == "true" then
       
  3710 		helpDisabled = true
       
  3711 	end
       
  3712 
       
  3713 	if mapID == nil then
       
  3714 		mapID = 1
       
  3715 	end
       
  3716 
       
  3717 end
       
  3718 
       
  3719 function onGameInit()
       
  3720 
       
  3721 	-- perhaps we can get some of this better info in parsecommandoverride
       
  3722 	--Map = "Islands"
       
  3723 	--Theme = "Deepspace"
       
  3724 	--Seed = "{bacb2f87-f316-4691-a333-3bcfc4fb3d88}"
       
  3725 	--MapGen = 0 -- 0:generated map, 1:generated maze, 2:hand drawn map
       
  3726 	--TemplateFilter = 5	-- small=1,med=2,large=3,cavern=4,wacky=5
       
  3727 
       
  3728 	if mapID == nil then
       
  3729 		mapID = 1
       
  3730 	end
       
  3731 
       
  3732 	-- read gameflags and assign their values to the gameflaglist array
       
  3733 	for i = 1, #gameFlagList do
       
  3734 		if band(GameFlags, gameFlagList[i][3]) ~= 0 then
       
  3735 			gameFlagList[i][2] = true
       
  3736 		else
       
  3737 			gameFlagList[i][2] = false
       
  3738 		end
       
  3739 	end
       
  3740 
       
  3741 	Explosives = 0
       
  3742 	MinesNum = 0
       
  3743 
       
  3744 	--GameFlags = GameFlags + gfInfAttack
       
  3745 	EnableGameFlags(gfInfAttack, gfDisableWind)
       
  3746 
       
  3747 	RedefineSubset()
       
  3748 
       
  3749 end
       
  3750 
       
  3751 function onGameStart()
       
  3752 
       
  3753 	trackTeams()
       
  3754 
       
  3755 
       
  3756 	InterpretPoints()
       
  3757 	LoadLevelData()
       
  3758 
       
  3759 	ShowMission	(
       
  3760 				loc("HEDGE EDITOR"),
       
  3761 				loc("(well... kind of...)"),
       
  3762 				loc("Place Girder: Girder") .. "|" ..
       
  3763 				loc("Place Rubber: Rubber") .. "|" ..
       
  3764 				loc("Place Gear: Air Attack") .. "|" ..
       
  3765 				loc("Change Selection: [Up], [Down], [Left], [Right]") .. "|" ..
       
  3766 				loc("Toggle Help: Precise+1 (While a tool is selected)") .. "|" ..
       
  3767 				" " .. "|" ..
       
  3768 				loc("COMMANDS: (Use while no weapon is selected)") .. "|" ..
       
  3769 				loc("Save Level: Precise+4") .. "|" ..
       
  3770 				loc("Toggle Editing Weapons and Tools: Precise+2") .. "|" ..
       
  3771 				" " .. "|" ..
       
  3772 				--" " .. "|" ..
       
  3773 				"", 4, 5000
       
  3774 				)
       
  3775 
       
  3776 
       
  3777 	sCirc = AddVisualGear(0,0,vgtCircle,0,true)
       
  3778 	SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0xffba00ff)
       
  3779 
       
  3780 
       
  3781 	frameID = 1
       
  3782 	visualSprite = sprAmGirder
       
  3783 	sSprite = AddVisualGear(0, 0, vgtStraightShot, 0, true,1)
       
  3784 	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(sSprite)
       
  3785 	SetVisualGearValues(sSprite, 1, 1, 0, 0, g5, frameID, 20000, visualSprite, 20000, g10 )
       
  3786 
       
  3787 	SetAmmoDelay(amAirAttack,0)
       
  3788 	SetAmmoDelay(amGirder,0)
       
  3789 	SetAmmoDelay(amRubber,0)
       
  3790 	--SetAmmoDelay(amNapalm,0)
       
  3791 	--SetAmmoDelay(amDrillStrike,0)
       
  3792 	--SetAmmoDelay(amMineStrike,0)
       
  3793 
       
  3794 end
       
  3795 
       
  3796 function SetEditingWeps(ammoCount)
       
  3797 
       
  3798 	AddAmmo(CurrentHedgehog, amAirAttack, ammoCount)
       
  3799 	AddAmmo(CurrentHedgehog, amGirder, ammoCount)
       
  3800 	AddAmmo(CurrentHedgehog, amRubber, ammoCount)
       
  3801 	--AddAmmo(CurrentHedgehog, amPortalGun, ammoCount)
       
  3802 	AddAmmo(CurrentHedgehog, amTeleport, ammoCount)
       
  3803 	AddAmmo(CurrentHedgehog, amRope, ammoCount)
       
  3804 	--AddAmmo(CurrentHedgehog, amJetpack, ammoCount)
       
  3805 	--AddAmmo(CurrentHedgehog, amParachute, ammoCount)
       
  3806 	AddAmmo(CurrentHedgehog, amSwitch, 100) --ammoCount
       
  3807 	AddAmmo(CurrentHedgehog, amSkip, 100)
       
  3808 
       
  3809 end
       
  3810 
       
  3811 function clearAmmo(gear)
       
  3812 	for i = 1, #atkArray do
       
  3813 		AddAmmo(gear,atkArray[i][1],0)
       
  3814 	end
       
  3815 	for i = 1, #utilArray do
       
  3816 		AddAmmo(gear,utilArray[i][1],0)
       
  3817 	end
       
  3818 end
       
  3819 
       
  3820 -- the below two functions allow you to set up a themed team.
       
  3821 -- one day, it'd be nice to be able to set their voice/flag/grave
       
  3822 -- ingame at this point, too, but for now, this is impossible
       
  3823 function SetTeamIdentity(gear)
       
  3824 	tName = pMode[pIndex]
       
  3825 	hIndex = 1
       
  3826 	hArr = {}
       
  3827 	for i = 1,#preMadeTeam[pIndex][2] do
       
  3828 		table.insert(hArr,preMadeTeam[pIndex][2][i])
       
  3829 	end
       
  3830 	nArr = {}
       
  3831 	for i = 1,#preMadeTeam[pIndex][3] do
       
  3832 		table.insert(nArr,preMadeTeam[pIndex][3][i])
       
  3833 	end
       
  3834 	SetHogTeamName(gear, tName)
       
  3835 	--runOnHogsInTeam(AssignTeam(gear),tName)
       
  3836 	runOnHogs(AssignTeam)
       
  3837 end
       
  3838 
       
  3839 function AssignTeam(gear)
       
  3840 
       
  3841 	if GetHogTeamName(gear) == tName then
       
  3842 
       
  3843 		setGearValue(gear,"flag",preMadeTeam[pIndex][5])
       
  3844 		setGearValue(gear,"voice",preMadeTeam[pIndex][6])
       
  3845 		setGearValue(gear,"grave",preMadeTeam[pIndex][7])
       
  3846 		setGearValue(gear,"fort",preMadeTeam[pIndex][8])
       
  3847 
       
  3848 		if preMadeTeam[pIndex][4] == "R" then -- random team
       
  3849 
       
  3850 			if #hArr > 0 then
       
  3851 				--if there are unchosen hats left, choose one
       
  3852 				--then remove it from the available list of hats
       
  3853 				i = 1+GetRandom(#hArr)
       
  3854 				SetHogHat(gear,hArr[i])
       
  3855 				table.remove(hArr,i)
       
  3856 			else
       
  3857 				-- choose any hat randomly
       
  3858 				SetHogHat(gear,preMadeTeam[pIndex][2][1+GetRandom(#preMadeTeam[pIndex][2])])
       
  3859 			end
       
  3860 
       
  3861 			if #nArr > 0 then
       
  3862 				i = 1+GetRandom(#nArr)
       
  3863 				SetHogName(gear,nArr[i])
       
  3864 				table.remove(nArr,i)
       
  3865 			else
       
  3866 				SetHogName(gear,preMadeTeam[pIndex][3][1+GetRandom(#preMadeTeam[pIndex][3])])
       
  3867 			end
       
  3868 
       
  3869 		elseif preMadeTeam[pIndex][4] == "F" then -- fixed team w/ exactly 8 guys
       
  3870 			SetHogName(gear,preMadeTeam[pIndex][3][hIndex])
       
  3871 			SetHogHat(gear,preMadeTeam[pIndex][2][hIndex])
       
  3872 			hIndex = hIndex +1
       
  3873 		else -- FR fixed random team with more or less than 8 guys
       
  3874 
       
  3875 			if #hArr > 0 then
       
  3876 				i = 1+GetRandom(#hArr)
       
  3877 				SetHogHat(gear,hArr[i])
       
  3878 				SetHogName(gear,nArr[i])
       
  3879 				table.remove(hArr,i)
       
  3880 				table.remove(nArr,i)
       
  3881 			else
       
  3882 				SetHogHat(gear,"NoHat")
       
  3883 				SetHogName(gear,"Uninspiring hog")
       
  3884 			end
       
  3885 
       
  3886 		end
       
  3887 
       
  3888 	end
       
  3889 
       
  3890 end
       
  3891 
       
  3892 -- allows you to set a sort of identity and weapon profile for a given hog
       
  3893 -- this should only really be used when perHogAmmo is enabled
       
  3894 function SetHogProfile(gear, pro)
       
  3895 
       
  3896 	clearAmmo(gear)
       
  3897 
       
  3898 	if pro == loc("Sniper") then
       
  3899 
       
  3900 		SetHogName(gear,"Sniper")
       
  3901 		SetHogHat(gear, "Sniper")
       
  3902 		SetHealth(gear, 50)
       
  3903 		AddAmmo(gear, amSniperRifle, 100)
       
  3904 		AddAmmo(gear, amDEagle, 100)
       
  3905 
       
  3906 	elseif pro == loc("Pyro") then
       
  3907 
       
  3908 		SetHogName(gear,loc("Pyro"))
       
  3909 		SetHogHat(gear, "Gasmask")
       
  3910 		SetHealth(gear, 80)
       
  3911 		AddAmmo(gear, amFlamethrower, 100)
       
  3912 		AddAmmo(gear, amMolotov, 100)
       
  3913 		AddAmmo(gear, amNapalm, 1)
       
  3914 
       
  3915 	elseif pro == loc("Soldier") then
       
  3916 
       
  3917 		SetHogName(gear,loc("Soldier"))
       
  3918 		--SetHogHat(gear, "war_americanww2helmet")
       
  3919 		SetHogHat(gear, "TeamSoldier")
       
  3920 		SetHealth(gear, 100)
       
  3921 		AddAmmo(gear, amBazooka, 100)
       
  3922 		AddAmmo(gear, amShotgun, 100)
       
  3923 		AddAmmo(gear, amMortar, 100)
       
  3924 
       
  3925 	elseif pro == loc("Grenadier") then
       
  3926 
       
  3927 		SetHogName(gear,loc("Grenadier"))
       
  3928 		SetHogHat(gear, "war_desertgrenadier1")
       
  3929 		SetHealth(gear, 100)
       
  3930 		AddAmmo(gear, amGrenade, 100)
       
  3931 		AddAmmo(gear, amClusterBomb, 100)
       
  3932 		AddAmmo(gear, amGasBomb, 100)
       
  3933 
       
  3934 	elseif pro == loc("Chef") then
       
  3935 
       
  3936 		SetHogName(gear,loc("Chef"))
       
  3937 		SetHogHat(gear, "chef")
       
  3938 		SetHealth(gear, 65)
       
  3939 		AddAmmo(gear, amGasBomb, 100)
       
  3940 		AddAmmo(gear, amKnife, 100)
       
  3941 		AddAmmo(gear, amCake, 1)
       
  3942 		--AddAmmo(gear, amWatermelon, 1)
       
  3943 
       
  3944 	elseif pro == loc("Ninja") then
       
  3945 
       
  3946 		SetHogName(gear,loc("Ninja"))
       
  3947 		SetHogHat(gear, "NinjaFull")
       
  3948 		SetHealth(gear, 80)
       
  3949 		AddAmmo(gear, amRope, 100)
       
  3950 		AddAmmo(gear, amFirePunch, 100)
       
  3951 		AddAmmo(gear, amParachute, 1)
       
  3952 
       
  3953 	elseif pro == loc("Commander") then
       
  3954 
       
  3955 		SetHogName(gear,loc("Commander"))
       
  3956 		SetHogHat(gear, "sf_vega")
       
  3957 		SetHealth(gear, 120)
       
  3958 		AddAmmo(gear, amDEagle, 100)
       
  3959 		AddAmmo(gear, amAirAttack, 2)
       
  3960 		AddAmmo(gear, amNapalm, 1)
       
  3961 		AddAmmo(gear, amDrillStrike, 1)
       
  3962 		AddAmmo(gear, amMineStrike, 1)
       
  3963 
       
  3964 	elseif pro == loc("Engineer") then
       
  3965 
       
  3966 		SetHogName(gear,loc("Engineer"))
       
  3967 		SetHogHat(gear, "Glasses")
       
  3968 		SetHealth(gear, 45)
       
  3969 		AddAmmo(gear, amGirder, 4)
       
  3970 		AddAmmo(gear, amRubber, 2)
       
  3971 		AddAmmo(gear, amLandGun, 2)
       
  3972 		AddAmmo(gear, amBlowTorch, 100)
       
  3973 		AddAmmo(gear, amPickHammer, 100)
       
  3974 
       
  3975 	elseif pro == loc("Physicist") then
       
  3976 
       
  3977 		SetHogName(gear,loc("Physicist"))
       
  3978 		SetHogHat(gear, "lambda")
       
  3979 		SetHealth(gear, 80)
       
  3980 		AddAmmo(gear, amIceGun, 2)
       
  3981 		AddAmmo(gear, amSineGun, 100)
       
  3982 		AddAmmo(gear, amBee, 2)
       
  3983 		AddAmmo(gear, amLowGravity, 100)
       
  3984 
       
  3985 	elseif pro == loc("Trapper") then
       
  3986 
       
  3987 		SetHogName(gear,loc("Trapper"))
       
  3988 		SetHogHat(gear, "Skull")
       
  3989 		SetHealth(gear, 100)
       
  3990 		AddAmmo(gear, amMine, 100)
       
  3991 		AddAmmo(gear, amSMine, 4)
       
  3992 		AddAmmo(gear, amAirMine, 2)
       
  3993 		AddAmmo(gear, amMolotov, 100)
       
  3994 
       
  3995 	elseif pro == loc("Saint") then
       
  3996 
       
  3997 		SetHogName(gear,loc("Saint"))
       
  3998 		SetHogHat(gear, "angel")
       
  3999 		SetHealth(gear, 200)
       
  4000 		AddAmmo(gear, amSeduction, 100)
       
  4001 		AddAmmo(gear, amInvulnerable, 100)
       
  4002 		AddAmmo(gear, amIceGun, 2)
       
  4003 		AddAmmo(gear, amHammer, 100)
       
  4004 		AddAmmo(gear, amResurrector, 100)
       
  4005 
       
  4006 	elseif pro == loc("Clown") then
       
  4007 
       
  4008 		SetHogName(gear,loc("Clown"))
       
  4009 		SetHogHat(gear, "clown-copper")
       
  4010 		SetHealth(gear, 70)
       
  4011 		AddAmmo(gear, amBaseballBat, 100)
       
  4012 		AddAmmo(gear, amGasBomb, 100)
       
  4013 		AddAmmo(gear, amBallgun, 1)
       
  4014 		AddAmmo(gear, amKamikaze, 1)
       
  4015 		--AddAmmo(gear, amPiano, 1)
       
  4016 
       
  4017 	-- some other ideas/roles
       
  4018 	-- relocator: portal, teleport, tardis, extra time, lasersite
       
  4019 	-- vampire: vampire, whip, birdy, extra damage, seduction
       
  4020 	-- flyboy: rc plane, deagle, whip, parachute, kamikaze
       
  4021 	-- demo: drill, dynamite, mine, smine, blowtorch
       
  4022 	-- alien: ufo, sine-gun, drill rocket
       
  4023 	-- terminator: tardis, shotgun, cake, girder
       
  4024 	-- yeti: ice-gun, firepunch, blowtorch
       
  4025 
       
  4026 	end
       
  4027 
       
  4028 	AddAmmo(gear, amSwitch, 100)
       
  4029 	AddAmmo(gear, amSkip, 100)
       
  4030 
       
  4031 end
       
  4032 
       
  4033 function onNewTurn()
       
  4034 
       
  4035 	-- regardless of our other ammo, give stuff that is useful for editing
       
  4036 	SetEditingWeps(100)
       
  4037 	if GetHogLevel(CurrentHedgehog) == 0 then
       
  4038 		TurnTimeLeft = -1	-- is that turntime in your pocket? :D
       
  4039 	else
       
  4040 		TurnTimeLeft = 1 -- skip the computer's turn
       
  4041 	end
       
  4042 
       
  4043 end
       
  4044 
       
  4045 function onGameTick()
       
  4046 	HandleHedgeEditor()
       
  4047 end
       
  4048 
       
  4049 function isATrackedGear(gear)
       
  4050 	if 	(GetGearType(gear) == gtHedgehog) or
       
  4051 		(GetGearType(gear) == gtGrenade) or
       
  4052 		(GetGearType(gear) == gtExplosives) or
       
  4053 		(GetGearType(gear) == gtTarget) or
       
  4054 		(GetGearType(gear) == gtKnife) or
       
  4055 		(GetGearType(gear) == gtMine) or
       
  4056 		(GetGearType(gear) == gtSMine) or
       
  4057 		(GetGearType(gear) == gtPortal) or
       
  4058 		(GetGearType(gear) == gtAirMine) or
       
  4059 		(GetGearType(gear) == gtCase)
       
  4060 	then
       
  4061 		return(true)
       
  4062 	else
       
  4063 		return(false)
       
  4064 	end
       
  4065 end
       
  4066 
       
  4067 -- track hedgehogs and placement gears
       
  4068 function onGearAdd(gear)
       
  4069 
       
  4070 	if GetGearType(gear) == gtJetpack then
       
  4071 		ufoGear = gear
       
  4072 		if (ufoFuel ~= 0) then
       
  4073 			SetHealth(ufoGear, ufoFuel)
       
  4074 		end
       
  4075 	end
       
  4076 
       
  4077 	if GetGearType(gear) == gtHedgehog then
       
  4078 		--table.insert(hhs, gear)
       
  4079 	elseif (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtGirder) then
       
  4080 		cGear = gear
       
  4081 	end
       
  4082 
       
  4083 	if isATrackedGear(gear) then
       
  4084 		trackGear(gear)
       
  4085 
       
  4086 		if GetGearType(gear) == gtPortal then
       
  4087 			setGearValue(gear,"life",portalDistance)
       
  4088 		end
       
  4089 
       
  4090 	end
       
  4091 
       
  4092 end
       
  4093 
       
  4094 function onGearDelete(gear)
       
  4095 
       
  4096 	if GetGearType(gear) == gtJetpack then
       
  4097 		ufoGear = nil
       
  4098 	end
       
  4099 
       
  4100 	if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtGirder) then
       
  4101 		cGear = nil
       
  4102 	end
       
  4103 
       
  4104 	if isATrackedGear(gear) then
       
  4105 
       
  4106 		if getGearValue(gear, "tCirc") ~= nil then
       
  4107 			DeleteVisualGear(getGearValue(gear, "tCirc"))
       
  4108 		end
       
  4109 
       
  4110 		trackDeletion(gear)
       
  4111 
       
  4112 	end
       
  4113 
       
  4114 end
       
  4115