home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 89 / CDPowerplay89Disc1.iso / Demos / ui_hulk_demo_en.exe / Disk1 / data1.cab / App_Levels / init.lua < prev   
Encoding:
Text File  |  2003-05-09  |  66.0 KB  |  1,968 lines

  1. -- Init.Lua
  2. -- ***********************************************************************************************
  3. -- ***********************************************************************************************
  4. -- **
  5. -- **  Global variables
  6. -- **
  7. -- ***********************************************************************************************
  8. -- ***********************************************************************************************
  9.  
  10. -- globally define 'true' and 'false'
  11. true = 1
  12. false = nil
  13.  
  14. -- mission states.  Defined in code in scenariomanager.hpp
  15. MISSION_INPROGRESS = 0
  16. MISSION_FAILING    = 1
  17. MISSION_FAILED     = 2
  18. MISSION_SUCCESS    = 3
  19. MISSION_SUCCEEDED  = 4
  20. MISSION_ABORT      = 5
  21.  
  22. -- agent states.  agent.hpp
  23.  
  24. AGENT_NONDOMINANT = 0
  25. AGENT_CONTROLLER  = 1
  26. AGENT_OCCUPATION  = 2
  27. AGENT_CURIOUS     = 3
  28. AGENT_COMBAT      = 4
  29. AGENT_PANIC       = 5
  30. AGENT_WANDER      = 6
  31. AGENT_MADMAN      = 7
  32.  
  33. -- Pathfinder info:  is a roomgrid cell passable or impassable?.  DEFINED IN roomgrid.hpp
  34. DENSITY_IMPASSABLE = 0;
  35. DENSITY_PASSABLE = 1;
  36.  
  37. -- game difficulty levels.  gameflowmanager.hpp
  38. DIFFICULTY_EASY    = 0
  39. DIFFICULTY_NORMAL  = 1
  40. DIFFICULTY_HARD    = 2
  41.  
  42. -- controller types. controller.hpp
  43. CONTROLLER_GAMEPAD  = 0
  44. CONTROLLER_KEYBOARD = 1
  45. CONTROLLER_MOUSE    = 2
  46. CONTROLLER_NONE     = 3
  47.  
  48. -- controller game buttons. controller.hpp
  49. GAME_CONTROLLER_BUTTON_A = 0
  50. GAME_CONTROLLER_BUTTON_B = 1
  51. GAME_CONTROLLER_BUTTON_X = 2
  52. GAME_CONTROLLER_BUTTON_Y = 3
  53. GAME_CONTROLLER_BUTTON_START = 4
  54. GAME_CONTROLLER_BUTTON_SELECT = 5
  55. GAME_CONTROLLER_BUTTON_BACK = 6
  56. GAME_CONTROLLER_BUTTON_TRIGGER_LEFT = 7
  57. GAME_CONTROLLER_BUTTON_TRIGGER_RIGHT = 8
  58.  
  59. -- controller sim buttons. controller.hpp
  60.  
  61. SIM_CONTROLLER_BUTTON_PUNCH = 0
  62. SIM_CONTROLLER_BUTTON_GAMMA = 1
  63. SIM_CONTROLLER_BUTTON_ACTION = 2
  64. SIM_CONTROLLER_BUTTON_JUMP = 3
  65. SIM_CONTROLLER_BUTTON_FREELOOK = 4
  66. SIM_CONTROLLER_BUTTON_TARGET = 5
  67. SIM_CONTROLLER_BUTTON_START = 6
  68.  
  69. -- controller game axes. controller.hpp
  70.  
  71. GAME_CONTROLLER_AXIS_PRIMARY = 0
  72. GAME_CONTROLLER_AXIS_SECONDARY = 1
  73.  
  74. -- controller sim axes. controller.hpp
  75.  
  76. SIM_CONTROLLER_AXIS_MOVEMENT = 0
  77. SIM_CONTROLLER_AXIS_CHANGETARGET = 1
  78.  
  79. -- controller axis indices. controller.hpp
  80.  
  81. CONTROLLER_AXIS_INDEX_X = 0
  82. CONTROLLER_AXIS_INDEX_Y = 1
  83.  
  84. --function gfm_GetDifficulty()
  85. --    return DIFFICULTY_NORMAL
  86. --end
  87.  
  88. --function gfm_SetDifficulty()
  89. --end
  90.  
  91.  
  92. -- added global tuned health pickup values
  93. -- second stage tuning, if required, will take place in the scenario scripts for each level
  94.  
  95. spm_SetMajorHealthBonus (15)
  96. spm_SetMinorHealthBonus (5)
  97. spm_SetMajorRageBonus (20)
  98. spm_SetMinorRageBonus  (10)
  99.  
  100. -- Sound Triggers for "low" health
  101.  
  102. snd_Set_UserHealthDown( 70 )
  103. snd_Set_UserHealthNearDeath( 35 )
  104.  
  105. -- Destroy Smart Props falling out of the level
  106.  
  107. spm_SetDoYCheck( true )
  108. spm_SetYCheck( -250 )
  109.  
  110.  
  111. -- Health on various levels
  112. HULK_HEALTH_ON_BOSS_LEVELS  = 850
  113. HULK_HEALTH_ON_MADMAN_LEVEL = 800
  114. HULK_HEALTH_ON_HL_LEVEL     = 680
  115. -- Half-life's health on C1L5 is multiplied by this number
  116. HL_HEALTH_MOD_ON_C1L5       = 1.1
  117.  
  118. -- Set up combo feedback
  119. -- eurostile extended bold     
  120. -- Explanation:  up to '3' is BLANK, 3-5 is COMBO_1, etc.
  121. --      sm_AddComboGrade( 3, "BLANK" )
  122. --      sm_AddComboGrade( 5, "TBS_COMBO_1" )    -- ANGRY!
  123. sm_ResetComboSystem()
  124. sm_AddComboGrade( 3, "BLANK" )
  125. sm_AddComboGrade( 5, "TBS_COMBO_1" )    -- ANGRY!
  126. sm_AddComboGrade( 8, "TBS_COMBO_7" )    -- FIERCE!
  127. sm_AddComboGrade( 12, "TBS_COMBO_4" )    -- ENRAGED!
  128. sm_AddComboGrade( 18, "TBS_COMBO_3" )   -- SAVAGE!
  129. sm_AddComboGrade( 25, "TBS_COMBO_2")    -- FURIOUS!
  130. sm_AddComboGrade( 50, "TBS_COMBO_5" )   -- INCREDIBLE!
  131. sm_SetComboTimerLimit( 0.85 )
  132. sm_SetComboHitText( "TBS_COMBO_HITS_4" )
  133. sm_SetBonusPointText( "TBS_CHALLENGE_HUD_POINTS" )
  134. sm_SetBonusPointSingularText( "TBS_CHALLENGE_HUD_POINTS_3" )
  135. sm_SetBonusTimeText( "TBS_CHALLENGE_HUD_TIME" )
  136.  
  137.  
  138. -- KMC:  needed for little hack.  If this number is > 0, then play a dram-cam on Hulk's electrocution node.
  139. -- Right now (and probably forever), this is only true in C1L5, the first time Hulk punches Half-life.
  140. -- I define it here so that, when the fight tree asks for it, it's at least always defined
  141. hulk_electrocution_cam = 0
  142.  
  143. -- ***********************************************************************************************
  144. -- ***********************************************************************************************
  145.  
  146.  
  147. function get_level()
  148.  
  149.     local chapter = gfm_GetChapter()
  150.     local level = gfm_GetLevel()
  151.     whichlevel = "C" .. chapter .. "L" .. level
  152. --  write( "get_level() returning " .. whichlevel .. "\n" )
  153.     return whichlevel
  154.  
  155. end
  156.  
  157. -- Collectable FUNCTIONS ---------------------------------------------------------------------------
  158.  
  159. -- "global" variables for the collectable checks
  160. npc_collectable_slider = 2
  161.     -- 0 = no collectables
  162.  
  163. npc_collectable_chance = 0 -- THIS MUST BE ZERO :)
  164.  
  165. npc_collectable_minor_major = {} -- Add this to the chance for a Major collectable ..  + is a bonus , - is a penalty
  166.  
  167. npc_collectable_default_minor_major = 15 -- Default chance for EVERYONE to have a major.
  168.  
  169. npc_collectable_minor_major[DIFFICULTY_EASY] = 10
  170. npc_collectable_minor_major[DIFFICULTY_NORMAL] = 0
  171. npc_collectable_minor_major[DIFFICULTY_HARD] = -10
  172.  
  173. npc_collectable_minor_major["assaulter"] = 0
  174. npc_collectable_minor_major["shocktroop"] = -5
  175. npc_collectable_minor_major["unarmedsoldier"] = -15
  176. npc_collectable_minor_major["missilesoldier"] = 25
  177. npc_collectable_minor_major["shockshielder"] = 15
  178. npc_collectable_minor_major["leader_bot"] = 50
  179.  
  180. npc_collectable_minor_major["alpha_guard"] = 0
  181. npc_collectable_minor_major["gamma_guard"] = 30
  182. npc_collectable_minor_major["alpha_missilesoldier"] = 25
  183. npc_collectable_minor_major["alpha_shockshielder"] = 15
  184. npc_collectable_minor_major["alpha_shocktroop"] = 15
  185. npc_collectable_minor_major["gamma_elite"] = 40
  186.  
  187. npc_collectable_minor_major["scientist"] = -75
  188.  
  189. npc_collectable_minor_major["gamma_dog"] = 20
  190.  
  191. npc_collectable_minor_major["half_life"] = 100
  192. npc_collectable_minor_major["mad_man"] = 100
  193. npc_collectable_minor_major["flux"] = 100
  194. npc_collectable_minor_major["ravage"] = 100
  195. npc_collectable_minor_major["leader"] = 100
  196.  
  197. npc_collectable_minor_major["colonel_ryker"] = -100
  198.  
  199. npc_collectable_minor_major["tank"] = 75
  200. npc_collectable_minor_major["blackhawk"] = -100
  201. npc_collectable_minor_major["apache"] = -100
  202. npc_collectable_minor_major["blackhawk_leader"] = -100
  203. npc_collectable_minor_major["apache_leader"] = -100
  204.  
  205. npc_collectable_health_rage = {} 
  206.  
  207. npc_collectable_default_health_rage = 60 -- The chance of the collectable being HEALTH
  208.  
  209. npc_collectable_health_rage[DIFFICULTY_EASY] = 10
  210. npc_collectable_health_rage[DIFFICULTY_NORMAL] = 0
  211. npc_collectable_health_rage[DIFFICULTY_HARD] = -10
  212.  
  213. npc_collectable_health_rage["assaulter"] = 0
  214. npc_collectable_health_rage["shocktroop"] = 0
  215. npc_collectable_health_rage["unarmedsoldier"] =0
  216. npc_collectable_health_rage["missilesoldier"] = 5
  217. npc_collectable_health_rage["shockshielder"] = 5
  218. npc_collectable_health_rage["leader_bot"] = 10
  219.  
  220. npc_collectable_health_rage["alpha_guard"] = 0
  221. npc_collectable_health_rage["gamma_guard"] = 10
  222. npc_collectable_health_rage["alpha_missilesoldier"] = 5
  223. npc_collectable_health_rage["alpha_shockshielder"] = 5
  224. npc_collectable_health_rage["alpha_shocktroop"] = 5
  225. npc_collectable_health_rage["gamma_elite"] = 15
  226.  
  227. npc_collectable_health_rage["scientist"] = 0
  228.  
  229. npc_collectable_health_rage["gamma_dog"] = 5
  230.  
  231. npc_collectable_health_rage["half_life"] = 50
  232. npc_collectable_health_rage["mad_man"] = 25
  233. npc_collectable_health_rage["flux"] = 25
  234. npc_collectable_health_rage["ravage"] = 25
  235. npc_collectable_health_rage["leader"] = 25
  236.  
  237. npc_collectable_health_rage["colonel_ryker"] = -100
  238.  
  239. npc_collectable_health_rage["tank"] = 50
  240. npc_collectable_health_rage["blackhawk"] = 0
  241. npc_collectable_health_rage["apache"] = 0
  242. npc_collectable_health_rage["blackhawk_leader"] = 0
  243. npc_collectable_health_rage["apache_leader"] = 0
  244.  
  245. npc_collectable_minor_major["C0L1"] = 0
  246.  
  247. npc_collectable_minor_major["C1L1"] = 0
  248. npc_collectable_minor_major["C1L2"] = 0
  249. npc_collectable_minor_major["C1L3"] = 0
  250. npc_collectable_minor_major["C1L4"] = 0
  251. npc_collectable_minor_major["C1L5"] = 0
  252.  
  253. npc_collectable_minor_major["C2L1"] = 0
  254. npc_collectable_minor_major["C2L2"] = 0
  255. npc_collectable_minor_major["C2L4"] = 0
  256. npc_collectable_minor_major["C2L5"] = 0
  257.  
  258. npc_collectable_minor_major["C3L1"] = 0
  259. npc_collectable_minor_major["C3L2"] = 0
  260. npc_collectable_minor_major["C3L3"] = 0
  261. npc_collectable_minor_major["C3L4"] = 0
  262.  
  263. npc_collectable_minor_major["C4L1"] = 0
  264. npc_collectable_minor_major["C4L2"] = 0
  265. npc_collectable_minor_major["C4L3"] = 0
  266. npc_collectable_minor_major["C4L4"] = 0
  267.  
  268. npc_collectable_minor_major["C5L1"] = 0
  269. npc_collectable_minor_major["C5L2"] = 0
  270. npc_collectable_minor_major["C5L3"] = 0
  271. npc_collectable_minor_major["C5L4"] = 0
  272.  
  273. npc_collectable_minor_major["C9L1"] = 0
  274. npc_collectable_minor_major["C9L2"] = 0
  275. npc_collectable_minor_major["C9L3"] = 0
  276. npc_collectable_minor_major["C9L4"] = 0
  277. npc_collectable_minor_major["C9L5"] = 0
  278. npc_collectable_minor_major["C9L6"] = 0
  279. npc_collectable_minor_major["C9L7"] = 0
  280.  
  281. npc_collectable_minor_major["default"] = 0
  282.  
  283. npc_collectable_health_rage["C0L1"] = 0
  284.  
  285. npc_collectable_health_rage["C1L1"] = 0
  286. npc_collectable_health_rage["C1L2"] = 0
  287. npc_collectable_health_rage["C1L3"] = 0
  288. npc_collectable_health_rage["C1L4"] = 0
  289. npc_collectable_health_rage["C1L5"] = 0
  290.  
  291. npc_collectable_health_rage["C2L1"] = 0
  292. npc_collectable_health_rage["C2L2"] = 0
  293. npc_collectable_health_rage["C2L4"] = 0
  294. npc_collectable_health_rage["C2L5"] = 0
  295.  
  296. npc_collectable_health_rage["C3L1"] = 0
  297. npc_collectable_health_rage["C3L2"] = 0
  298. npc_collectable_health_rage["C3L3"] = 0
  299. npc_collectable_health_rage["C3L4"] = 0
  300.  
  301. npc_collectable_health_rage["C4L1"] = 0
  302. npc_collectable_health_rage["C4L2"] = 0
  303. npc_collectable_health_rage["C4L3"] = 0
  304. npc_collectable_health_rage["C4L4"] = 0
  305.  
  306. npc_collectable_health_rage["C5L1"] = 0
  307. npc_collectable_health_rage["C5L2"] = 0
  308. npc_collectable_health_rage["C5L3"] = 0
  309. npc_collectable_health_rage["C5L4"] = 0
  310.  
  311. npc_collectable_health_rage["C9L1"] = 0
  312. npc_collectable_health_rage["C9L2"] = 0
  313. npc_collectable_health_rage["C9L3"] = 0
  314. npc_collectable_health_rage["C9L4"] = 0
  315. npc_collectable_health_rage["C9L5"] = 0
  316. npc_collectable_health_rage["C9L6"] = 0
  317. npc_collectable_health_rage["C9L7"] = 0
  318.  
  319. npc_collectable_health_rage["default"] = 0
  320.  
  321. function npc_collectable_assign (name, template )
  322.  
  323.     local difficulty = DIFFICULTY_NORMAL
  324.     if gfm_GetDifficulty == nil then
  325.         difficulty = DIFFICULTY_NORMAL
  326.     else
  327.         difficulty = gfm_GetDifficulty()
  328.     end
  329. --    if difficulty == nil then
  330. --        write( "DIFFICULTY == nil !\n" )
  331. --    else
  332. --       write( "Difficulty was okay.  Value of " .. difficulty .. "\n" )
  333. --    end
  334.  
  335.     level = get_level()
  336. --    write( "Name = " .. name .. "   Template = " .. template .. "\n" )
  337.  
  338.     mm_chance = npc_collectable_default_minor_major + npc_collectable_minor_major[difficulty] + npc_collectable_minor_major[template] + npc_collectable_minor_major[level]
  339.     hr_chance = npc_collectable_default_health_rage + npc_collectable_health_rage[difficulty] + npc_collectable_health_rage[template] + npc_collectable_health_rage[level]
  340.  
  341.     --debug ("[OMGc] " ..  name .. " says mm: " .. mm_chance .. " hr: " .. hr_chance)
  342.  
  343.     if random (1,100) <= mm_chance then
  344.         major = 1
  345.     else
  346.         major = 0
  347.     end
  348.  
  349.     if random (1,100) <= hr_chance then
  350.         health = 1
  351.     else
  352.         health = 0
  353.     end
  354.  
  355.     if major == 1 and health == 1 then
  356.             am_SetActorCollectable( name, 1 )
  357.             --debug ("[OMGc] " ..  name .. " new system: Major Health")
  358.     end
  359.  
  360.     if major == 0 and health == 1 then
  361.             am_SetActorCollectable( name, 2 )
  362.             --debug ("[OMGc] " ..  name .. " new system:  Minor Health")
  363.     end
  364.  
  365.     if major == 1 and health == 0 then
  366.             am_SetActorCollectable( name, 3 )
  367.             --debug ("[OMGc] " ..  name .. " new system:  Major Rage")
  368.     end
  369.  
  370.     if major == 0 and health == 0 then
  371.             am_SetActorCollectable( name, 4 )
  372.             --debug ("[OMGc] " ..  name .. " new system:  Minor Rage")
  373.     end
  374.  
  375. end
  376.  
  377. function npc_collectable_assign_banner ( name, template )
  378.  
  379. end
  380.  
  381. -----------------------------------------------------------------------------------------------------------
  382.  
  383. -- a nice string representation of things
  384. function string_val_single(v)
  385.     local retstr = ''
  386.     debug("grrr");
  387.     if type(v) == 'table' then
  388.         retstr = retstr .. "{ ";
  389.         for ind,val in v do 
  390.             debug(level, ind, val)
  391.             retstr = retstr .. format("[%s] = ", string_val(ind))
  392.             if type(val) == 'table' then
  393.                 retstr = retstr .. string_val(val, 1)
  394.                 retstr = retstr .. ", "
  395.             else
  396.                 retstr = retstr .. format("%s, ", string_val(val))
  397.             end
  398.         end
  399.         retstr = retstr .. "}"
  400.     elseif type(v) == 'string' then
  401.         retstr = "'" .. gsub(v,"([\\'])", "\\%1") .. "'"
  402.     elseif type(v) == 'number' then
  403.         retstr = tostring(v)
  404.     else
  405.         retstr = format("<%s>", tostring(v))
  406.     end
  407.     return retstr
  408. end
  409.  
  410. level = 0
  411. function string_val(...)
  412.     local retstr = ''
  413.     for i = 1, arg.n, 1 do 
  414.         if i > 1 then retstr = retstr .. ', ' end
  415.         level = level + 1
  416.         retstr = retstr .. string_val_single(arg[i])
  417.         level = level - 1
  418.     end
  419.     return retstr
  420. end
  421.  
  422. function print_globals()
  423.     -- g is a table of all global variables
  424.     local g = globals()
  425.     for ind,val in g do
  426.         -- ick!  What if val is a table ? ? ?  urk ...   I'm not even handling strings, although I don't think that's a problem...
  427.         if type( val ) == 'number' then
  428.             debug( ind, val )
  429. --            sh_StoreGlobal( ind, val )
  430.         end
  431.     end
  432.     write( "End of print_globals\n" )
  433. end
  434.  
  435. -- ***********************************************************************************************
  436. -- ***********************************************************************************************
  437. -- **
  438. -- **        Global helper functions, in-sim specific
  439. -- **        i.e. do NOT call these from the front-end!
  440. -- **
  441. -- ***********************************************************************************************
  442. -- ***********************************************************************************************
  443.  
  444. ---------------------------------------------------------------
  445. -- Generate an actor at the specified locator
  446. ---------------------------------------------------------------
  447. function GenerateActor( model, locator, team, path, leashed, name )
  448.     success = am_CreateActor( model, locator, team, path, leashed, name )
  449.     if success == nil then
  450.         write( name .. " could NOT be generated.\n" )
  451.     else
  452.         write( name .. " has been generated.\n" )
  453.         if(am_GetEnemyCount()> 10) then
  454.             write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  455.             am_KillEnemy(1)
  456.         end
  457.     end
  458.     return success
  459. end
  460.  
  461. ---------------------------------------------------------------
  462. -- Generate a PropActor ex: autogun, spotlight
  463. -- templatename   : name of the base actor 
  464. -- propname       : name of the SmartProp instance associated to that Actor
  465. -- Aim Joint name : name of the aim Joint, (it's the Muzzle for the autoguns, and the light source in the SpotLight
  466. -- patrolpathname : name of the PatrolPath, needes for spotlight objects only
  467. ---------------------------------------------------------------
  468. function GeneratePropActor( templatename, propname, aimjointname, patrolpathname )
  469.     success = am_CreatePropActor( templatename, propname, aimjointname,  patrolpathname )
  470.     if success == nil then
  471.         write( propname .. " could NOT be generated.\n" )
  472.     else
  473.         write( propname .. " has been generated.\n" )
  474.     end
  475.     return success
  476. end
  477.  
  478. ---------------------------------------------------------------
  479. -- Move an actor to the specified locator
  480. ---------------------------------------------------------------
  481. function MoveActorToLocator( actor, locator )
  482.     local locExists = tvm_DoesLocatorExist( locator )
  483.     if locExists ~= nil then
  484.         v = tvm_GetLocatorPosition( locator )
  485.         am_SetActorPosition( actor, v )
  486.         orientation = tvm_GetLocatorOrientation( locator )
  487.         write( "MoveActorToLocator:  orientation = " .. orientation .. "\n" )
  488.         am_SetActorOrientation( actor, orientation )
  489.     else
  490.         write ("MoveActorToLocator:  Unable to locate " .. locator .. "\n")
  491.     end
  492. end    
  493.  
  494. ---------------------------------------------------------------
  495. -- Make an actor face the specified locator
  496. ---------------------------------------------------------------
  497. function OrientActorToLocator( actor, locator )
  498.     if locator == nil or actor == nil then
  499.         return
  500.     end
  501.     local locExists = tvm_DoesLocatorExist( locator )
  502.     if locExists ~= nil then
  503.         local actorPos = am_GetActorPosition( actor )
  504.         local locatorPos = tvm_GetLocatorPosition( locator )
  505.         local actorToLocator = VectorSub( locatorPos, actorPos )
  506.         local orientation = util_GetWorldOrientation( actorToLocator.x, actorToLocator.z )
  507.         am_SetActorOrientation( actor, orientation )
  508.         write( "OrientActorToLocator:  orientation = " .. orientation .. "\n" )
  509.     else
  510.         write ("OrientActorToLocator:  Unable to locate " .. locator .. "\n")
  511.     end
  512. end
  513.  
  514.  
  515. ---------------------------------------------------------------
  516. -- Wait for X seconds
  517. ---------------------------------------------------------------
  518. function Wait( seconds )
  519.     local timeElapsed = 0
  520.     while timeElapsed < seconds do
  521.         timeElapsed = timeElapsed + time_GetElapsedTime()
  522.         yield()
  523.     end
  524. end
  525.  
  526.  
  527. ---------------------------------------------------------------
  528. --  Wait for there to be less then or exactly X enemies left alive
  529. --  Example usage:
  530. --            Wait_EnemyCount( 0 )    -->        wait for all enemies to die
  531. --          Wait_EnemyCount( 4 )    -->        wait for there to be 4 or less enemies left alive
  532. ---------------------------------------------------------------
  533. function Wait_EnemyCount( count )
  534.     while am_GetEnemyCount() > count do
  535.         yield()
  536.     end
  537. end
  538.  
  539.  
  540. ---------------------------------------------------------------
  541. --  Wait for the given actor (string) to enter the specified trigger_volume (string)
  542. --  Example usage:
  543. --        Wait_ActorInTriggerVolume( "hulk", "C1L2R2_tv_u2" )
  544. ---------------------------------------------------------------
  545. function Wait_ActorInTriggerVolume( actor, trigger_volume )
  546.     write("Waiting for " .. actor .. " to enter volume " .. trigger_volume .. "... \n")
  547.     while tvm_IsActorInTriggerVolume( actor, trigger_volume ) == nil do
  548.         yield()
  549.     end
  550.     write("done\n")
  551. end
  552.  
  553.  
  554. ---------------------------------------------------------------
  555. --  Wait for there to be less then or exactly X enemies left alive, 
  556. --  OR for the given actor (string) to enter the specified trigger_volume (string)
  557. --  Example usage:
  558. --        Wait_EnemyCount_or_ActorInTriggerVolume( 4, "hulk", "C1L2R2_tv_u2" )
  559. ---------------------------------------------------------------
  560. function Wait_EnemyCount_or_ActorInTriggerVolume( count, actor, trigger_volume )
  561.     write("Waiting for " .. actor .. " to enter volume " .. trigger_volume .. " or enemy count <= " .. count .. "...")
  562.     while am_GetEnemyCount() > count and tvm_IsActorInTriggerVolume( actor, trigger_volume ) == nil do
  563.         yield()
  564.     end
  565.     write("done\n")
  566.     if( am_GetEnemyCount() <= count) then
  567.         write ("Enemy count = " .. count .. "\n")
  568.     end
  569.     if( tvm_IsActorInTriggerVolume( actor, trigger_volume ) ~= nil ) then
  570.         write (actor .. " in trigger volume" .. trigger_volume .. "\n")
  571.     end
  572. end
  573.  
  574.  
  575. ---------------------------------------------------------------
  576. --  Play an FMV, and wait for the FMV to finish
  577. --  Example usage:
  578. --        Wait_PlayMovie( "SC1_3" )
  579. ---------------------------------------------------------------
  580. function Wait_PlayMovie( fmv )
  581.     yield()
  582.     nism_FadeToBlack(1)
  583.     Wait(1)
  584.     write( "Playing FMV <" .. fmv .. ">.  Waiting for end...\n" )
  585.     fmvm_PlayMovieWithAudio( fmv, 2000 )
  586.     while fmvm_IsPlaying() do
  587.         yield()
  588.     end
  589.     nism_FadeToBlack(0)
  590.     nism_FadeFromBlack(1)
  591.     write("FMV done.\n")
  592. end
  593.  
  594. function Wait_PlayMovieNoFadeIn( fmv )
  595.     yield()
  596.     write( "Playing FMV <" .. fmv .. ">.  Waiting for end...\n" )
  597.     fmvm_PlayMovieWithAudio( fmv, 2000 )
  598. --    fmvm_PlayMovie( fmvWithPath, 2000 )
  599.     while fmvm_IsPlaying() do
  600.         yield() 
  601.     end
  602.     nism_FadeToBlack(0)
  603.     nism_FadeFromBlack(1)
  604.     write("FMV done.\n")
  605. end
  606.  
  607.  
  608.  
  609. ---------------------------------------------------------------
  610. --  Play an FMV.  
  611. --  Example usage:
  612. --        PlayMovie( "SC1_3" )
  613. ---------------------------------------------------------------
  614. function PlayMovie( fmv )
  615.     yield()
  616.     write( "Playing FMV <" .. fmv .. ">.\n" )
  617.     fmvm_PlayMovieWithAudio( fmv, 2000 )
  618. end
  619.  
  620.  
  621. function BeginMovieMode()
  622.   hud_ShowHUD(nil)
  623.   hud_ShowMessages(nil)
  624.   nism_LetterBoxOn()
  625. end
  626.  
  627. function EndMovieMode()
  628.   hud_ShowHUD(true)
  629.   hud_ShowMessages(true)
  630.   nism_LetterBoxOff()
  631. end
  632.  
  633.  
  634.  
  635.  
  636. ---------------------------------------------------------------
  637. --  Play an NIS, and wait for the NIS to finish
  638. --  Example usage:
  639. --        Wait_PlayNIS( "c1l1_nis_01" )
  640. ---------------------------------------------------------------
  641. function Wait_PlayNIS( nis )
  642.     write( "Playing NIS <" .. nis .. ">.  Waiting for end...\n" )
  643.     BeginMovieMode()
  644.     nism_Play( nis, 2000 )
  645.     while nism_IsPlaying() do
  646.         yield()
  647.     end
  648.     nism_Unload( nis )
  649.     EndMovieMode()
  650.     write("NIS done.\n")
  651. end
  652.  
  653. function Wait_PlayNIS_Callback( nis, callback, frame )
  654.     write( "Playing NIS <" .. nis .. ">.  Waiting for end...\n" )
  655.     BeginMovieMode()
  656.     nism_Play( nis, 2000 )
  657.     nism_SetLuaCallback(callback, frame);
  658.     while nism_IsPlaying() do
  659.         yield()
  660.     end
  661.     nism_Unload( nis )
  662.     EndMovieMode()
  663.     write("NIS done.\n")
  664. end
  665.  
  666. function PlayNIS( nis )
  667.     write( "Playing NIS <" .. nis .. ">.\n")
  668.     BeginMovieMode()
  669.     nism_Play( nis, 2000 )
  670. end
  671.  
  672. function PlayNISAtLocator( nis, loc )
  673.     write( "Playing NIS <" .. nis .. ">.\n" )
  674.     BeginMovieMode()
  675.     nism_PlayAtLocator( nis, loc, 2000 )
  676. end
  677.  
  678. function PlayNISNoSkip( nis )
  679.     write( "Playing NIS <" .. nis .. ">.\n" )
  680.     BeginMovieMode()
  681.     nism_Play( nis, -1 ) -- -1 means no skip allowed
  682. end
  683.  
  684. function WaitNIS( nis )
  685.     write( "Waiting on NIS <" .. nis .. ">.\n")
  686.     while nism_IsPlaying() do
  687.         yield()
  688.     end
  689.     nism_Unload( nis )
  690.     EndMovieMode()
  691.     write("NIS done.\n")
  692. end
  693.  
  694.  
  695.  
  696. ---------------------------------------------------------------
  697. --  Play an NIS, and wait for the NIS to finish, but dont allow the user to skip
  698. --  Example usage:
  699. --        Wait_PlayNISNoSkip( "c1l1_nis_01" )
  700. ---------------------------------------------------------------
  701. function Wait_PlayNISNoSkip( nis )
  702.     write( "Playing NIS <" .. nis .. ">.  Waiting for end...\n" )
  703.     BeginMovieMode()
  704.     nism_Play( nis, -1 ) -- -1 means no skip allowed
  705.     while nism_IsPlaying() do
  706.         yield()
  707.     end
  708.     nism_Unload( nis )
  709.     EndMovieMode()
  710.     write("NIS done.\n")
  711. end
  712.  
  713. ---------------------------------------------------------------
  714. --  Play an NIS at specified locator, and wait for the NIS to finish
  715. --  Example usage:
  716. --        Wait_PlayNIS( "c1l1_nis_02", "C1L1_loc_nis02" )
  717. ---------------------------------------------------------------
  718. function Wait_PlayNISAtLocator( nis, loc )
  719.     write( "Playing NIS <" .. nis .. ">.  Waiting for end...\n" )
  720.     BeginMovieMode()
  721.     nism_PlayAtLocator( nis, loc, 2000 )
  722.     while nism_IsPlaying() do
  723.         yield()
  724.     end
  725.     nism_Unload( nis )
  726.     EndMovieMode()
  727.     write("NIS done.\n")
  728. end
  729.  
  730.  
  731.  
  732.  
  733. ---------------------------------------------------------------
  734. --
  735. --  NOT CURRENTLY BEING USED!  
  736. --  I created this function when I thought that the occupation agent
  737. --  invoked the path script *every* frame.  In fact, it only calls the
  738. --  path script when it reaches a way point.  Oh well.  At least we
  739. --  used first-class functions for a brief moment.
  740. --                 --kmc
  741. --  
  742. --
  743. --  Generic function to call for paths. 
  744. --  Designers, you don't want to look at this.  Only use it.  :)
  745. --
  746. --  The second parameter (waypoint_function) is a function.  The intent is that this
  747. --  function gets called whenever we're at a waypoint.  It takes "actor" (string) and way point number
  748. --  as parameters, and doesn't have a return value.
  749. --
  750. --  Here's a sample function that you could pass, for a path with 3 way points:
  751. --
  752. --        function waypoint_function( actor, waypoint )
  753. --            if waypoint == 0 then
  754. --                write( "Actor <" .. actor .. "> has reached waypoint 0.\n" )
  755. --                am_AdvanceWayPoint( actor )
  756. --
  757. --            elseif waypoint == 1 then
  758. --                write( "Actor <" .. actor .. "> has reached waypoint 1.\n" )
  759. --                am_AdvanceWayPoint( actor )
  760. --
  761. --            elseif waypoint == 2 then
  762. --                write( "Actor <" .. actor .. "> has reached the end of the path.\n" )
  763. --                am_Unleash( actor )
  764. --
  765. --            else
  766. --                -- what the?!  There are only 2 way points in this path... ?
  767. --                error( "C1L2R2_spwnpat_u2:  invalid path.\n" )
  768. --            end
  769. --        end
  770. --
  771. ---------------------------------------------------------------
  772. function DoPath_DONOTUSE( actor, waypoint_function )
  773.     -- Get the last and next way points.  
  774.     -- If they are the same, then we are AT a way point.  If not, we are on our way...
  775.     local last_way_point = am_GetLastWayPoint( actor )
  776.     local next_way_point = am_GetNextWayPoint( actor )
  777.     
  778.     -- Check to see if we're at a way point or in transition
  779.     if last_way_point == next_way_point then
  780.         waypoint_function( actor, last_way_point )
  781.     end
  782. end
  783.  
  784.  
  785. -- ***********************************************************************************************
  786. -- ***********************************************************************************************
  787. -- **
  788. -- **        Global helper functions
  789. -- **       Can be used anywhere
  790. -- **
  791. -- ***********************************************************************************************
  792. -- ***********************************************************************************************
  793.  
  794. ---------------------------------------------------------------
  795. -- Distance between two rmt::Vectors
  796. ---------------------------------------------------------------
  797. function VectorDistance( v, w )
  798.     local dx = v.x - w.x
  799.     local dy = v.y - w.y
  800.     local dz = v.z - w.z
  801.     local dist = (dx^2 + dy^2 + dz^2)^0.5
  802.     return dist
  803. end
  804.  
  805. ---------------------------------------------------------------
  806. -- Vector addition
  807. ---------------------------------------------------------------
  808. function VectorAdd( v, w )
  809.     local retval = Vector( v )
  810.     retval.x = retval.x + w.x
  811.     retval.y = retval.y + w.y
  812.     retval.z = retval.z + w.z
  813.     return retval
  814. end
  815.  
  816. ---------------------------------------------------------------
  817. -- Vector substraction
  818. ---------------------------------------------------------------
  819. function VectorSub( v, w )
  820.     local retval = Vector( v )
  821.     retval.x = retval.x - w.x
  822.     retval.y = retval.y - w.y
  823.     retval.z = retval.z - w.z
  824.     return retval
  825. end
  826.  
  827. ---------------------------------------------------------------
  828. -- Vector scale
  829. ---------------------------------------------------------------
  830. function VectorScale( v, scale )
  831.     local retval = Vector( v )
  832.     retval.x = retval.x * scale
  833.     retval.y = retval.y * scale
  834.     retval.z = retval.z * scale
  835.     return retval
  836. end
  837.  
  838. -------------------------------------------------------------
  839. --  Enemy Generators
  840. -------------------------------------------------------------
  841. --  bsmedley - augest 6th 2002
  842. -------------------------------------------------------------
  843.  
  844. -- kmc
  845. -- 1st line:    "I'd like to make sure I have <count> free slots.  Kill anyone that's been off-camera for <exptime> seconds or more."
  846. -- 2nd line:    "Hey!  I really need those <count> free slots!  Since there still aren't enough, kill ANYONE that is off-camera.  Period."
  847. -- 3rd line:    "Cripes!  I STILL don't have <count> free slots?!  Screw it.  Give me <count> slots, even if it means killing enemies that are on camera."
  848. -- I love reading Kevin's comments.  CRIPES!
  849.  
  850. function FreeEnemySlots( count, exptime )
  851.     if am_FreeEnemySlots( count, exptime ) < count then
  852.         if am_FreeEnemySlots( count, 0.001 ) < count then
  853.             am_FreeEnemySlots( count, -1 )
  854.         end
  855.     end
  856. end
  857.  
  858. function generate_wave( nameprefix, unit, template, team, number)
  859. -- Generate a Wave
  860.     debug("[OMGgw]Generating " .. number .. " of " .. template)
  861.     write ("Generating " .. number .. " of " .. template .. "\n")
  862.     local spawned = 0
  863.     for element = 1,10 do
  864.         local name = nameprefix .. "_" .. unit .. "_g" .. element
  865.         local locator = nameprefix .. "_eg_" .. unit .. "_g" .. element
  866.         local leashed = nil
  867.         local path = "none"
  868.         if tvm_DoesLocatorExist( locator ) then
  869.             success = am_CreateActor( template, locator, team, path, leashed, name )
  870.             if success == nil then
  871.                 write( name .. " - " .. template .. " could NOT be generated.\n" )
  872.             else
  873.                 spawned = spawned + 1
  874.                 write( spawned .. "> " .. name .. " has been generated\n" )
  875.                 debug("[OMGgw]" .. spawned .. "> " .. name .. " has been generated")
  876.                 if npc_collectable_slider ~= 0 then
  877.                     npc_collectable_assign(name,template)
  878.                 end
  879.                 if(am_GetEnemyCount()> 10) then
  880.                     write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  881.                     am_FreeEnemySlots ( 1, -1 )
  882.                 end -- enemy count
  883.                 if spawned == number then 
  884.                     return spawned
  885.                 end
  886.             end -- success
  887.         end -- locator exist
  888.     end -- for loop
  889.     if spawned ~= number then
  890.         write ("--- Warning unable to generate requested number enemies ---\n")
  891.     end
  892.     return spawned
  893. end
  894.  
  895. function generate_wave_pathed( nameprefix, unit, template, team, number, onleash )
  896. -- Generate a Wave
  897.     debug("[OMGgw]Generating " .. number .. " of " .. template)
  898.     write ("Generating " .. number .. " of " .. template .. "\n")
  899.     local spawned = 0
  900.     for element = 1,10 do
  901.         local name = nameprefix .. "_" .. unit .. "_g" .. element
  902.         local locator = nameprefix .. "_eg_" .. unit .. "_g" .. element
  903.         if onleash == 1 then
  904.             leashed = 1
  905.         else
  906.             leashed = nil
  907.         end
  908.         local path = nameprefix .. "_spwnpat_" .. unit .. "_g" .. element
  909.         if tvm_DoesLocatorExist( locator ) then
  910.             success = am_CreateActor( template, locator, team, path, leashed, name )
  911.             if success == nil then
  912.                 write( name .. " could NOT be generated.\n" )
  913.             else
  914.                 spawned = spawned + 1
  915.                 am_SetAlertStatus(name,3)
  916.                 write( spawned .. "> " .. name .. " has been generated\n" )
  917.                 debug("[OMGgw]" .. spawned .. "> " .. name .. " has been generated")
  918.                 if npc_collectable_slider ~= 0 then
  919.                     npc_collectable_assign(name,template)
  920.                 end
  921.                 if(am_GetEnemyCount()> 10) then
  922.                     write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  923.                     am_FreeEnemySlots ( 1, -1 )
  924.                 end -- enemy count
  925.                 if spawned == number then 
  926.                     return spawned
  927.                 end
  928.             end -- success
  929.         end -- locator exist
  930.     end -- for loop
  931.     if spawned ~= number then
  932.         write ("--- Warning unable to generate requested number enemies ---\n")
  933.     end
  934.     return spawned
  935. end
  936.  
  937. function generate_wave_pathed_banner( nameprefix, unit, template, team, number, onleash )
  938. -- Generate a Wave
  939.     write ("Generating " .. number .. " of " .. template .. "\n")
  940.     local spawned = 0
  941.     for element = 1,10 do
  942.         local name = nameprefix .. "_" .. unit .. "_g" .. element
  943.         local locator = nameprefix .. "_eg_" .. unit .. "_g" .. element
  944.         if onleash == 1 then
  945.             leashed = 1
  946.         else
  947.             leashed = nil
  948.         end
  949.         local path = nameprefix .. "_spwnpat_" .. unit .. "_g" .. element
  950.         if tvm_DoesLocatorExist( locator ) then
  951.             success = am_CreateActor( template, locator, team, path, leashed, name )
  952.             if success == nil then
  953.                 write( name .. " could NOT be generated.\n" )
  954.             else
  955.                 spawned = spawned + 1
  956.       --          if npc_collectable_slider ~= 0 then
  957.         --            npc_collectable_assign_banner(name,template)
  958.          --       end
  959.                 write( spawned .. "> " .. name .. " has been generated\n" )
  960.                 if(am_GetEnemyCount()> 10) then
  961.                     write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  962.                     am_FreeEnemySlots ( 1, -1 )
  963.                 end -- enemy count
  964.                 if spawned == number then 
  965.                     return spawned
  966.                 end
  967.             end -- success
  968.         end -- locator exist
  969.     end -- for loop
  970.     if spawned ~= number then
  971.         write ("--- Warning unable to generate requested number enemies ---\n")
  972.     end
  973.     return spawned
  974. end
  975.  
  976. function generate_solo (nameprefix, unit, template, team, ident)
  977.  
  978. -- Generate a Single Enemy
  979.  
  980.     local name = nameprefix .. "_" .. unit .. "_g" .. ident
  981.     local locator = nameprefix .. "_eg_" .. unit .. "_g" .. ident
  982.     local leashed = nil
  983.     local path = "none"
  984.     if tvm_DoesLocatorExist( locator ) then
  985.         success = am_CreateActor( template, locator, team, path, leashed, name )
  986.         if success == nil then
  987.             write( name .. " could NOT be generated.\n" )
  988.             return 0
  989.         else
  990.             write( name .. " has been generated\n" )
  991.                 if npc_collectable_slider ~= 0 then
  992.                     npc_collectable_assign(name,template)
  993.                 end
  994.             if(am_GetEnemyCount() > 10) then
  995.                 write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  996.                 am_FreeEnemySlots ( 1, -1 )
  997.             end -- enemy count
  998.             return 1
  999.         end -- success
  1000.     end -- locator exist
  1001.  
  1002.     return 0
  1003. end
  1004.  
  1005. function generate_solo_pathed (nameprefix, unit, template, team, ident, onleash )
  1006.  
  1007. -- Generate a Single Enemy leashed to a Path
  1008.  
  1009.     local name = nameprefix .. "_" .. unit .. "_g" .. ident
  1010.     local locator = nameprefix .. "_eg_" .. unit .. "_g" .. ident
  1011.     
  1012.     if onleash == 1 then
  1013.         leashed = 1
  1014.     else
  1015.         leashed = nil
  1016.     end
  1017.     local path = nameprefix .. "_spwnpat_" .. unit .. "_g" .. ident
  1018.     if tvm_DoesLocatorExist( locator ) then
  1019.         success = am_CreateActor( template, locator, team, path, leashed, name )
  1020.         if success == nil then
  1021.             write( name .. " could NOT be generated.\n" )
  1022.             return 0
  1023.         else
  1024.             write( name .. " has been generated\n" )
  1025.             am_SetAlertStatus(name,3)
  1026.                 if npc_collectable_slider ~= 0 then
  1027.                     npc_collectable_assign(name,template)
  1028.                 end
  1029.             if(am_GetEnemyCount()> 10) then
  1030.                 write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  1031.                 am_FreeEnemySlots ( 1, -1 )
  1032.             end -- enemy count
  1033.             return 1
  1034.         end -- success
  1035.     else
  1036.         print('WARNING: localtor', locator, 'does not exists')
  1037.     end -- locator exist
  1038.  
  1039.     return 0
  1040. end
  1041.  
  1042. function generate_solo_pathed_banner (nameprefix, unit, template, team, ident, onleash )
  1043.  
  1044. -- Generate a Single Enemy leashed to a Path
  1045.  
  1046.     local name = nameprefix .. "_" .. unit .. "_g" .. ident
  1047.     local locator = nameprefix .. "_eg_" .. unit .. "_g" .. ident
  1048.  
  1049.     if onleash == 1 then
  1050.         leashed = 1
  1051.     else
  1052.         leashed = nil
  1053.     end
  1054.     local path = nameprefix .. "_spwnpat_" .. unit .. "_g" .. ident
  1055.     if tvm_DoesLocatorExist( locator ) then
  1056.         success = am_CreateActor( template, locator, team, path, leashed, name )
  1057.         if success == nil then
  1058.             write( name .. " could NOT be generated.\n" )
  1059.             return 0
  1060.         else
  1061.             write( name .. " has been generated\n" )
  1062.      --       if npc_collectable_slider ~= 0 then
  1063.       --          npc_collectable_assign_banner(name,template)
  1064.        --     end
  1065.             if(am_GetEnemyCount()> 10) then
  1066.                 write( "--- WARNING: " .. am_GetEnemyCount() .." Enemies created ---\n")
  1067.                 am_FreeEnemySlots ( 1, -1 )
  1068.             end -- enemy count
  1069.             return 1
  1070.         end -- success
  1071.     else
  1072.         print('WARNING: localtor', locator, 'does not exists')
  1073.     end -- locator exist
  1074.  
  1075.     return 0
  1076. end
  1077.  
  1078. function respawn_wave ( nameprefix, unit, template, team, number )
  1079.  
  1080.     local numGenerated = 0
  1081.     for element = 1,number do
  1082.         local name = nameprefix .. "_" .. unit .. "_g" .. element
  1083.         if am_FindActorIndex(name) == -1 then
  1084.             total_spawns = total_spawns +1
  1085.             write ("Total Spawns: " .. total_spawns .. "--> ")
  1086.             numGenerated = numGenerated + generate_solo ( nameprefix, unit, template, team, element )
  1087.             am_UpdateKnownPlayerPos( name )
  1088.         end
  1089.     end
  1090.  
  1091.     return numGenerated
  1092. end
  1093.  
  1094. function respawn_wave_pathed ( nameprefix, unit, template, team, number )
  1095.  
  1096.     for element = 1,number do
  1097.         local name = nameprefix .. "_" .. unit .. "_g" .. element
  1098.         if am_FindActorIndex(name) == -1 then
  1099.             total_spawns = total_spawns +1
  1100.             write ("Total Spawns: " .. total_spawns .. "--> ")
  1101.             generate_solo_pathed ( nameprefix, unit, template, team, element, 1 )
  1102.             am_UpdateKnownPlayerPos( name )
  1103.  
  1104.         end
  1105.     end
  1106.  
  1107. end
  1108.  
  1109.  
  1110. -------------------------------------------------------------
  1111. --- End of Enemy Generators
  1112. -------------------------------------------------------------
  1113.  
  1114. -------------------------------------------------------------
  1115. --- FindPlayer_Wave
  1116. --- bsmedley aug 1st 2002
  1117. -------------------------------------------------------------
  1118.  
  1119. function findplayer_wave (nameprefix, unit, number)
  1120.  
  1121.     for element = 1,number do
  1122.         local name = nameprefix .. "_" .. unit .. "_g" .. element
  1123.         if am_FindActorIndex(name) ~= -1 then
  1124.             am_UpdateKnownPlayerPos(name)
  1125.         end
  1126.     end
  1127.  
  1128. end
  1129. -------------------------------------------------------------
  1130.  
  1131.  
  1132. function cameraCutToActor( name )
  1133.  
  1134.     local pos = am_GetActorPosition( name )
  1135.     cm_SetScriptCamStaticV( 45, 0, pos, 5 )
  1136.     cm_SetScriptCamShot( 75, 3, nil )
  1137.     cm_SwitchToScriptCamera(nil,nil)
  1138.  
  1139. end
  1140.  
  1141. function WaitForScriptCamera()
  1142.     while cm_IsScriptCameraPlaying() do
  1143.         yield()
  1144.     end
  1145. end
  1146.  
  1147. -- return a string that will represt the name of an actor using the actor 
  1148. -- naming convention for our levels
  1149. function ActorName(roomprefix, unit, instance)
  1150.     return roomprefix .. "_" .. unit .. "_g" .. instance
  1151. end
  1152.  
  1153. --
  1154. -- Controller button mapping initialization for the Keyboard
  1155. --
  1156. -- Default GAME buttons and axes are used by the frontend
  1157. -- Default SIM buttons and axes are used during gameplay
  1158.  
  1159. -- Game button maps
  1160. -- Format is: controller type,
  1161. --            controller button (i.e, function),
  1162. --            DirectInput button name,
  1163. --            input point number
  1164. --
  1165. -- A single game button (function) may have more than one input point (key mapped to
  1166. -- the function). The number of input points is not configurable via init.lua
  1167.  
  1168. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_A, "Enter", 0)
  1169. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_A, "Space", 1)
  1170. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_B, "Esc", 0)
  1171. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_Y, "Delete", 0)
  1172. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_BACK, "Esc", 0)
  1173. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_START, "Enter", 0)
  1174. --com_SetDefaultGameButtonMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_BUTTON_START, "Space", 1)
  1175.  
  1176. -- Game axis maps
  1177. -- Format is: controller type,
  1178. --            axis type,
  1179. --            axis index
  1180. --            input point number
  1181. --            DirectInput button name,
  1182. --
  1183. -- A single game axis has 3 input points.
  1184. -- The number of input points is not configurable via init.lua
  1185.  
  1186. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_PRIMARY, CONTROLLER_AXIS_INDEX_X, 0, "Right")
  1187. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_PRIMARY, CONTROLLER_AXIS_INDEX_X, 2, "Left")
  1188. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_PRIMARY, CONTROLLER_AXIS_INDEX_Y, 0, "Up")
  1189. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_PRIMARY, CONTROLLER_AXIS_INDEX_Y, 2, "Down")
  1190.  
  1191. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_SECONDARY, CONTROLLER_AXIS_INDEX_X, 0, "Num 6")
  1192. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_SECONDARY, CONTROLLER_AXIS_INDEX_X, 2, "Num 4")
  1193. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_SECONDARY, CONTROLLER_AXIS_INDEX_Y, 0, "Num 8")
  1194. --com_SetDefaultGameAxisMap(CONTROLLER_KEYBOARD, GAME_CONTROLLER_AXIS_SECONDARY, CONTROLLER_AXIS_INDEX_Y, 2, "Num 2")
  1195.  
  1196. -- Sim button maps
  1197. -- Format is: controller type,
  1198. --            controller button (i.e, function),
  1199. --            DirectInput button name,
  1200. --            input point number
  1201. --
  1202. -- A single game button (function) may have more than one input point (key mapped to
  1203. -- the function). The number of input points is not configurable via init.lua
  1204.  
  1205. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_PUNCH, "Num 4", 0)
  1206. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_GAMMA, "Num 8", 0)
  1207. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_ACTION, "Num 6", 0)
  1208. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_JUMP, "Space", 0)
  1209. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_JUMP, "Ctrl", 1)
  1210. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_FREELOOK, "Right Shift", 0)
  1211. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_FREELOOK, "Num Enter", 1)
  1212. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_TARGET, "Num 0", 0)
  1213. --com_SetDefaultSimButtonMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_BUTTON_START, "Esc", 0)
  1214.  
  1215. -- Sim axis maps
  1216. -- Format is: controller type,
  1217. --            axis type,
  1218. --            axis index
  1219. --            input point number
  1220. --            DirectInput button name,
  1221. --
  1222. -- A single game axis has 3 input points.
  1223. -- The number of input points is not configurable via init.lua
  1224.  
  1225. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_MOVEMENT, CONTROLLER_AXIS_INDEX_X, 0, "D")
  1226. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_MOVEMENT, CONTROLLER_AXIS_INDEX_X, 2, "A")
  1227. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_MOVEMENT, CONTROLLER_AXIS_INDEX_Y, 0, "W")
  1228. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_MOVEMENT, CONTROLLER_AXIS_INDEX_Y, 2, "S")
  1229. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_CHANGETARGET, CONTROLLER_AXIS_INDEX_X, 0, "Right")
  1230. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_CHANGETARGET, CONTROLLER_AXIS_INDEX_X, 2, "Left")
  1231. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_CHANGETARGET, CONTROLLER_AXIS_INDEX_Y, 0, "Up")
  1232. --com_SetDefaultSimAxisMap(CONTROLLER_KEYBOARD, SIM_CONTROLLER_AXIS_CHANGETARGET, CONTROLLER_AXIS_INDEX_Y, 2, "Down")
  1233.  
  1234. -- pass in 1 to reset once only upon first launching the game
  1235. -- DO NOT pass in 0 unless you REALLY really want this done each time
  1236. -- init.lua is read
  1237. -- This actually sets the controller mappings to be the default mappings
  1238. com_ResetToDefaultMapping(1)
  1239.  
  1240. -- Load screens
  1241. -- Format is      Level,  ImageFileName,     Title,           Text,                   Hint,                       Justicication (0 left, 1 centre, 2 right)
  1242. SetLoadScreenInfo("C0L1", "C0L1_loadscreen", "TBS_C0L1_NAME", "TBS_LOAD_TEXT_SUB2_1", "TBS_OBJECTIVE_REMINDER_1", 2)
  1243.  
  1244. SetLoadScreenInfo("C1L1", "C1L1_loadscreen", "TBS_C1L1_NAME", "TBS_LOAD_TEXT_SUB2_2", "TBS_FREEZE_HINT",          0)
  1245. SetLoadScreenInfo("C1L2", "C1L2_loadscreen", "TBS_C1L2_NAME", "TBS_LOAD_TEXT_SUB2_3", "TBS_HELIHINT1",            2)
  1246. SetLoadScreenInfo("C1L3", "C1L3_loadscreen", "TBS_C1L3_NAME", "TBS_LOAD_TEXT_SUB2_4", "TBS_SMASH_WALLS_HINT",     0)
  1247. SetLoadScreenInfo("C1L4", "C1L4_loadscreen", "TBS_C1L4_NAME", "TBS_LOAD_TEXT_SUB2_5", "TBS_PUNCHBACK",            2)
  1248. SetLoadScreenInfo("C1L5", "C1L5_loadscreen", "TBS_C1L5_NAME", "TBS_LOAD_TEXT_SUB2_6", "TBS_HL_GENERATORS",        2)
  1249.  
  1250. SetLoadScreenInfo("C2L1", "C2L1_loadscreen", "TBS_C2L1_NAME", "TBS_LOAD_TEXT_SUB2_7", "TBS_COMBO_SNEAK_GRAPPLE",  0)
  1251. SetLoadScreenInfo("C2L2", "C2L2_loadscreen", "TBS_C2L2_NAME", "TBS_LOAD_TEXT_SUB2_8", "TBS_COMBO_TIMING",         2)
  1252. SetLoadScreenInfo("C2L4", "C2L4b_loadscreen", "TBS_C2L4_NAME", "TBS_LOAD_TEXT_SUB2_10", "TBS_OBJECTIVE_REMINDER_22", 0)
  1253. SetLoadScreenInfo("C2L5", "C2L4_loadscreen", "TBS_C2L5_NAME", "TBS_LOAD_TEXT_SUB2_11", "TBS_DESTROY_CONSOLES",    0)
  1254.  
  1255. SetLoadScreenInfo("C3L1", "C3L1_loadscreen", "TBS_C3L1_NAME", "TBS_LOAD_TEXT_SUB2_12", "TBS_OBJECTIVE_REMINDER_26", 0)
  1256. SetLoadScreenInfo("C3L2", "C3L2_loadscreen", "TBS_C3L2_NAME", "TBS_LOAD_TEXT_SUB2_13", "TBS_RAGEMODE_START",      2)
  1257. SetLoadScreenInfo("C3L3", "C3L3_loadscreen", "TBS_C3L3_NAME", "TBS_LOAD_TEXT_SUB2_14", "TBS_TANKHINT1",           0)
  1258. SetLoadScreenInfo("C3L4", "C3L4_loadscreen", "TBS_C3L4_NAME", "TBS_LOAD_TEXT_SUB2_15", "TBS_FLUX_DAMAGE",         0)
  1259.  
  1260. SetLoadScreenInfo("C4L1", "C4L1_loadscreen", "TBS_C4L1_NAME", "TBS_LOAD_TEXT_SUB2_16", "TBS_FIGHT_4_RAGE",        2)
  1261. SetLoadScreenInfo("C4L2", "C4L2_loadscreen", "TBS_C4L2_NAME", "TBS_LOAD_TEXT_SUB2_17", "TBS_RAGE_DAMAGE_2",       2)
  1262. SetLoadScreenInfo("C4L3", "C4L3_loadscreen", "TBS_C4L3_NAME", "TBS_LOAD_TEXT_SUB2_19", "TBS_OBJECTIVE_REMINDER_41", 1)
  1263. SetLoadScreenInfo("C4L4", "C4L4_loadscreen", "TBS_C4L4_NAME", "TBS_LOAD_TEXT_SUB2_20", "TBS_RAVAGE_TACTICS",      0)
  1264.  
  1265. SetLoadScreenInfo("C5L1", "C5L1_loadscreen", "TBS_C5L1_NAME", "TBS_LOAD_TEXT_SUB2_22", "TBS_OBJECTIVE_REMINDER_49", 2)
  1266. SetLoadScreenInfo("C5L2", "C5L1b_loadscreen", "TBS_C5L1_NAME", "TBS_LOAD_TEXT_SUB2_22", "TBS_OBJECTIVE_REMINDER_49", 1)
  1267. SetLoadScreenInfo("C5L3", "C5L2_loadscreen", "TBS_C5L2_NAME", "TBS_LOAD_TEXT_SUB2_23", "TBS_LEADER_TACTICS_1",    0)
  1268. SetLoadScreenInfo("C5L4", "C5L3_loadscreen", "TBS_C5L3_NAME", "TBS_LOAD_TEXT_SUB2_24", "TBS_OBJECTIVE_REMINDER_53", 2)
  1269.  
  1270. SetLoadScreenInfo("C9L1", "C9L1_loadscreen", "TBS_CHALLENGE_FE_ENDURANCE_MODE_1", "TBS_CHALLENGE1_Title", "", 1)
  1271. SetLoadScreenInfo("C9L2", "C9L2_loadscreen", "TBS_CHALLENGE_FE_TIME_ATTACK_MODE_1", "TBS_CHALLENGE2_Title", "", 0)
  1272. SetLoadScreenInfo("C9L3", "C9L3_loadscreen", "TBS_MENU_ITEM_CHALLENGE_FE_HULK_SMASH_MODE", "TBS_CHALLENGE3_Body1", "", 2)
  1273. SetLoadScreenInfo("C9L5", "C9L4_loadscreen", "TBS_CHALLENGE_FE_ENDURANCE_MODE_2", "TBS_CHALLENGE1_Title", "", 0)
  1274. SetLoadScreenInfo("C9L6", "C9L5_loadscreen", "TBS_CHALLENGE_FE_TIME_ATTAC_MODE_2", "TBS_CHALLENGE2_Title", "", 0)
  1275.  
  1276. -- Set Level Load Times
  1277. -- SetLevelLoadTime(ps2, xbox, gamecube, other)  (Just kidding Katrina! :)
  1278. -- Tune this later
  1279.  
  1280. -- SetLevelLoadTime("C0L1", 12.9, 12.9, 12.9, 12.9)
  1281. -- SetLevelLoadTime("C1L1", 10.0, 10.0, 10.0, 10.0)
  1282. -- SetLevelLoadTime("C1L2", 13.1, 13.1, 13.1, 13.1)
  1283. -- SetLevelLoadTime("C1L3", 14.5, 14.5, 14.5, 14.5)
  1284. -- SetLevelLoadTime("C1L4", 14.7, 14.7, 14.7, 14.7)
  1285. -- SetLevelLoadTime("C1L5", 11.2, 11.2, 11.2, 11.2)
  1286. -- SetLevelLoadTime("C2L1", 11.3, 11.3, 11.3, 11.3)
  1287. -- SetLevelLoadTime("C2L2", 15.9, 15.9, 15.9, 15.9)
  1288. -- SetLevelLoadTime("C2L4", 14.5, 14.5, 14.5, 14.5)
  1289. -- SetLevelLoadTime("C2L5", 14.1, 14.1, 14.1, 14.1)
  1290. -- SetLevelLoadTime("C3L1", 12.6, 12.6, 12.6, 12.6)
  1291. -- SetLevelLoadTime("C3L2", 15.3, 15.3, 15.3, 15.3)
  1292. -- SetLevelLoadTime("C3L3", 13.8, 13.8, 13.8, 13.8)
  1293. -- SetLevelLoadTime("C3L4", 11.0, 11.0, 11.0, 11.0)
  1294. -- SetLevelLoadTime("C4L1", 12.0, 12.0, 12.0, 12.0)
  1295. -- SetLevelLoadTime("C4L2", 16.2, 16.2, 16.2, 16.2)
  1296. -- SetLevelLoadTime("C4L3", 12.9, 12.9, 12.9, 12.9)
  1297. -- SetLevelLoadTime("C4L4", 12.6, 12.6, 12.6, 12.6)
  1298. -- SetLevelLoadTime("C5L1", 12.3, 12.3, 12.3, 12.3)
  1299. -- SetLevelLoadTime("C5L2", 13.1, 13.1, 13.1, 13.1)
  1300. -- SetLevelLoadTime("C5L3", 13.1, 13.1, 13.1, 13.1)
  1301. -- SetLevelLoadTime("C5L4", 13.1, 13.1, 13.1, 13.1)
  1302. -- SetLevelLoadTime("C9L1", 12.8, 12.8, 12.8, 12.8)
  1303. -- SetLevelLoadTime("C9L2", 12.4, 12.4, 12.4, 12.4)
  1304. -- SetLevelLoadTime("C9L3", 12.1, 12.1, 12.1, 12.1)
  1305. -- SetLevelLoadTime("C9L4", 12.0, 12.0, 12.0, 12.0)
  1306. -- SetLevelLoadTime("C9L5", 14.2, 14.2, 14.2, 14.2)
  1307.  
  1308. SetLevelSelectInfo("C0L1", "TBS_C0L1_TEXT", 0, 0, 1)
  1309. SetLevelSelectInfo("C1L1", "TBS_C1L1_TEXT", 1, 1, 1)
  1310. SetLevelSelectInfo("C1L2", "TBS_C1L2_TEXT", 2, 1, 2)
  1311. SetLevelSelectInfo("C1L3", "TBS_C1L3_TEXT", 3, 1, 3)
  1312. SetLevelSelectInfo("C1L4", "TBS_C1L4_TEXT", 4, 1, 4)
  1313. SetLevelSelectInfo("C1L5", "TBS_C1_BOSS_TEXT", 5, 1, 5)
  1314. SetLevelSelectInfo("C2L1", "TBS_C2L1_TEXT", 6, 2, 1)
  1315. SetLevelSelectInfo("C2L2", "TBS_C2L2_TEXT", 7, 2, 2)
  1316. SetLevelSelectInfo("C2L4", "TBS_C2L4_TEXT", 8, 2, 4)
  1317. SetLevelSelectInfo("C2L5", "TBS_C2_BOSS_TEXT", 9, 2, 5)
  1318. SetLevelSelectInfo("C3L1", "TBS_C3L1_TEXT", 10, 3, 1)
  1319. SetLevelSelectInfo("C3L2", "TBS_C3L2_TEXT", 11, 3, 2)
  1320. SetLevelSelectInfo("C3L3", "TBS_C3L3_TEXT", 12, 3, 3)
  1321. SetLevelSelectInfo("C3L4", "TBS_C3_BOSS_TEXT", 13, 3, 4)
  1322. SetLevelSelectInfo("C4L1", "TBS_C4L1_TEXT", 14, 4, 1)
  1323. SetLevelSelectInfo("C4L2", "TBS_C4L2_TEXT", 15, 4, 2)
  1324. SetLevelSelectInfo("C4L3", "TBS_C4L3_TEXT", 16, 4, 3)
  1325. SetLevelSelectInfo("C4L4", "TBS_C4_BOSS_TEXT", 17, 4, 4)
  1326. SetLevelSelectInfo("C5L1", "TBS_C5L1_TEXT", 18, 5, 1)
  1327. SetLevelSelectInfo("C5L2", "", -1, -1, -1)
  1328. SetLevelSelectInfo("C5L3", "TBS_C5_BOSS_TEXT", 20, 5, 3)
  1329. SetLevelSelectInfo("C5L4", "TBS_C5L2_TEXT", 21, 5, 4)
  1330. SetLevelSelectInfo("C9L1", " ", 22, 9, 1)
  1331. SetLevelSelectInfo("C9L2", " ", 23, 9, 2)
  1332. SetLevelSelectInfo("C9L3", " ", 24, 9, 3)
  1333. SetLevelSelectInfo("C9L5", " ", 25, 9, 5)
  1334. SetLevelSelectInfo("C9L6", " ", 26, 9, 6)
  1335.  
  1336. -- spm_SetDestructionEffectName(class, materialEnum, effectName)
  1337. -- class: 0 == club, 1 == small, 2 == large, 3 == heavy
  1338. --spm_SetDestructionEffectName(0, -1, "hulk_knockdownground_fx_grp")
  1339. spm_SetDestructionEffectName(0, -1, "breakable_sml_lrg_grp")
  1340. spm_SetDestructionEffectName(1, -1, "breakable_cyangrp")
  1341. spm_SetDestructionEffectName(2, -1, "breakable_cyangrp")
  1342. spm_SetDestructionEffectName(3, -1, "breakable_cyangrp")
  1343.  
  1344. function LibC3L3Cam(dist)
  1345.     hulkPosition = am_GetActorPosition("hulk");
  1346.     cm_SetScriptCamStaticV( 60, 90, hulkPosition, dist );
  1347.     cm_SwitchToScriptCamera(false,false,false);
  1348.     cm_SetScriptCamShot( 90, 1000, true );
  1349. end
  1350.  
  1351. function LibC3L3Cam(dist)
  1352.     hulkPosition = am_GetActorPosition("hulk");
  1353.     cm_SetScriptCamStaticV( 60, 90, hulkPosition, dist );
  1354.     cm_SwitchToScriptCamera(false,false,false);
  1355.     cm_SetScriptCamShot( 90, 1000, true );
  1356. end
  1357.  
  1358.  
  1359. function LibTestGen(number, template, localNameprefix)
  1360.  
  1361.     if(number>0) then
  1362.     
  1363.         for dude = 1,number do
  1364.             
  1365.             locatorIndex =  mod(dude, 3) + 1
  1366.             local locator = localNameprefix .. "_g" .. locatorIndex            
  1367.             local name = "dudeTest" .. dude
  1368.  
  1369.             am_CreateActor( template, locator, "C1L3R3", "none", false, name );
  1370.     
  1371.             print(name, ' at ',locatorIndex)
  1372.         end     
  1373.     end
  1374. end
  1375.  
  1376. function LibDogs(dogs)
  1377.     LibTestGen(dogs,  "gamma_dog", "C1L3R3_eg_u3")
  1378. end
  1379.  
  1380. function LibRob(robs)
  1381.     LibTestGen(robs,  "leader_bot", "C1L3R3_eg_u3")
  1382. end
  1383.  
  1384. function LibGamma(gamma)
  1385.     LibTestGen(gamma,  "gamma_guard", "C1L3R3_eg_u3")
  1386. end
  1387.  
  1388. function LibRobC1(robs)
  1389.     LibTestGen(robs,  "leader_bot", "C3L2RX_Lib")
  1390. end
  1391.  
  1392. -- COUNT TEMPLATE --------------------------------------------
  1393.  
  1394. function count_template  ( template )
  1395.  
  1396.     count = 0
  1397.     for i = 0, (am_GetEnemyCount()-1) do
  1398.         name = am_GetEnemyName( i )
  1399.         if am_IsActorUsingTemplate( name, template ) then
  1400.             count = count + 1
  1401.         end
  1402.     end
  1403.  
  1404.     return count
  1405.  
  1406. end
  1407.  
  1408. --- GET NAME BASED ON TEMPLATE CALLS -------------------
  1409.  
  1410. function soldiername ()
  1411.  
  1412.     local soldierlist = {}
  1413.     local soldiernumbers = 0
  1414.  
  1415.     for i = 0, (am_GetEnemyCount()-1) do
  1416.         name = am_GetEnemyName( i )
  1417.         if am_IsActorUsingTemplate (name, "assaulter") or
  1418.         am_IsActorUsingTemplate (name, "shocktroop") or
  1419.         am_IsActorUsingTemplate (name, "missilesoldier") or
  1420.         am_IsActorUsingTemplate (name, "shockshielder") or
  1421.         am_IsActorUsingTemplate (name, "unarmedsoldier")
  1422.         then
  1423.             soldiernumbers = soldiernumbers + 1
  1424.             soldierlist[soldiernumbers] = name
  1425.         end
  1426.     end
  1427.  
  1428.     if soldiernumbers == 0 then
  1429.         return ""
  1430.     else
  1431.         pickone = random (1,soldiernumbers)
  1432.         return soldierlist[pickone]
  1433.     end
  1434.  
  1435. end
  1436.  
  1437. function alphaname ()
  1438.  
  1439.     local soldierlist = {}
  1440.     local soldiernumbers = 0
  1441.  
  1442.     for i = 0, (am_GetEnemyCount()-1) do
  1443.         name = am_GetEnemyName( i )
  1444.         if am_IsActorUsingTemplate (name, "alpha_guard") or
  1445.         am_IsActorUsingTemplate (name, "alpha_shocktroop") or
  1446.         am_IsActorUsingTemplate (name, "alpha_missilesoldier") or
  1447.         am_IsActorUsingTemplate (name, "alpha_shockshielder")
  1448.         then
  1449.             soldiernumbers = soldiernumbers + 1
  1450.             soldierlist[soldiernumbers] = name
  1451.         end
  1452.     end
  1453.  
  1454.     if soldiernumbers == 0 then
  1455.         return ""
  1456.     else
  1457.         pickone = random (1,soldiernumbers)
  1458.         return soldierlist[pickone]
  1459.     end
  1460.  
  1461. end
  1462.  
  1463. function gammaname ()
  1464.  
  1465.     local soldierlist = {}
  1466.     local soldiernumbers = 0
  1467.  
  1468.     for i = 0, (am_GetEnemyCount()-1) do
  1469.         name = am_GetEnemyName( i )
  1470.         if am_IsActorUsingTemplate (name, "gamma_guard") or
  1471.         am_IsActorUsingTemplate (name, "gamma_elite")
  1472.         then
  1473.             soldiernumbers = soldiernumbers + 1
  1474.             soldierlist[soldiernumbers] = name
  1475.         end
  1476.     end
  1477.  
  1478.     if soldiernumbers == 0 then
  1479.         return ""
  1480.     else
  1481.         pickone = random (1,soldiernumbers)
  1482.         return soldierlist[pickone]
  1483.     end
  1484.  
  1485. end
  1486.  
  1487. function shieldername ()
  1488.  
  1489.     local soldierlist = {}
  1490.     local soldiernumbers = 0
  1491.  
  1492.     for i = 0, (am_GetEnemyCount()-1) do
  1493.         name = am_GetEnemyName( i )
  1494.         if am_IsActorUsingTemplate (name, "shockshielder") or
  1495.         am_IsActorUsingTemplate (name, "alpha_shockshielder")
  1496.         then
  1497.             soldiernumbers = soldiernumbers + 1
  1498.             soldierlist[soldiernumbers] = name
  1499.         end
  1500.     end
  1501.  
  1502.     if soldiernumbers == 0 then
  1503.         return ""
  1504.     else
  1505.         pickone = random (1,soldiernumbers)
  1506.         return soldierlist[pickone]
  1507.     end
  1508.  
  1509. end
  1510.  
  1511. ---------------  DIALOGUE CALLS ---------------------------------
  1512.  
  1513. function dia_shockshielder ( name )
  1514.     return
  1515. end
  1516.  
  1517. function dia_soldier_gettingbackup ( name ) 
  1518.     return
  1519. end
  1520.  
  1521. function dia_soldier_needbackup( name )
  1522.     return
  1523. end
  1524.  
  1525. function dia_soldier_spawn ( name )
  1526.  
  1527.     if random(1,4) == 1 then
  1528.         debug ("[DIA] 1 in 4 .. no comment")
  1529.         return
  1530.     end
  1531.  
  1532.     local pickone = random(1,62)
  1533.  
  1534.     if pickone == 1 then
  1535.         dialogue = "SolHulkCh1_031" 
  1536.     elseif pickone == 2 then
  1537.         dialogue = "SolHulkCh1_036" 
  1538.     elseif pickone == 3 then
  1539.         dialogue = "SolHulkCh1_061" 
  1540.     elseif pickone == 4 then
  1541.         dialogue = "SolHulkCh1_062" 
  1542.     elseif pickone == 5 then
  1543.         dialogue = "SolHulkCh1_063" 
  1544.     elseif pickone == 6 then
  1545.         dialogue = "SolHulkCh1_064" 
  1546.     elseif pickone == 7 then
  1547.         dialogue = "SolHulkCh1_065" 
  1548.     elseif pickone == 8 then
  1549.         dialogue = "SolHulkCh1_089" 
  1550.     elseif pickone == 9 then
  1551.         dialogue = "SolSolCh1_010" 
  1552.     elseif pickone == 10 then
  1553.         dialogue = "SolSolCh1_011" 
  1554.     elseif pickone == 11 then
  1555.         dialogue = "SolSolCh1_012" 
  1556.     elseif pickone == 12 then
  1557.         dialogue = "SolSolCh1_013" 
  1558.     elseif pickone == 13 then
  1559.         dialogue = "SolSolCh1_014" 
  1560.     elseif pickone == 14 then
  1561.         dialogue = "SolSolCh1_015" 
  1562.     elseif pickone == 15 then
  1563.         dialogue = "SolSolCh1_019" 
  1564.     elseif pickone == 16 then
  1565.         dialogue = "SolSolCh1_020" 
  1566.     elseif pickone == 17 then
  1567.         dialogue = "SolSolCh1_021" 
  1568.     elseif pickone == 18 then
  1569.         dialogue = "SolSolCh1_025" 
  1570.     elseif pickone == 19 then
  1571.         dialogue = "SolSolCh1_026" 
  1572.     elseif pickone == 20 then
  1573.         dialogue = "SolSolCh1_027" 
  1574.     elseif pickone == 21 then
  1575.         dialogue = "SolSolCh1_028" 
  1576.     elseif pickone == 22 then
  1577.         dialogue = "SolSolCh1_030" 
  1578.     elseif pickone == 23 then
  1579.         dialogue = "SolHulkCh3_004" 
  1580.     elseif pickone == 24 then
  1581.         dialogue = "SolHulkCh3_049" 
  1582.     elseif pickone == 25 then
  1583.         dialogue = "SolHulkCh3_050" 
  1584.     elseif pickone == 26 then
  1585.         dialogue = "SolHulkCh3_061" 
  1586.     elseif pickone == 27 then
  1587.         dialogue = "SolHulkCh3_062" 
  1588.     elseif pickone == 28 then
  1589.         dialogue = "SolHulkCh3_063" 
  1590.     elseif pickone == 29 then
  1591.         dialogue = "SolHulkCh3_064" 
  1592.     elseif pickone == 30 then
  1593.         dialogue = "SolHulkCh3_065" 
  1594.     elseif pickone == 31 then
  1595.         dialogue = "SolHulkCh3_090" 
  1596.     elseif pickone == 32 then
  1597.         dialogue = "SolHulkCh3_091" 
  1598.     elseif pickone == 33 then
  1599.         dialogue = "SolHulkCh3_092" 
  1600.     elseif pickone == 34 then
  1601.         dialogue = "SolHulkCh3_056" 
  1602.     elseif pickone == 35 then
  1603.         dialogue = "SolHulkCh3_050" 
  1604.     elseif pickone == 36 then
  1605.         dialogue = "SolHulkCh3_004" 
  1606.     elseif pickone == 37 then
  1607.         dialogue = "SolHulkCh3_001" 
  1608.     elseif pickone == 38 then
  1609.         dialogue = "SolHulkCh3_082" 
  1610.     elseif pickone == 39 then
  1611.         dialogue = "SolHulkCh3_083" 
  1612.     elseif pickone == 40 then
  1613.         dialogue = "SolHulkCh3_092" 
  1614.     elseif pickone == 41 then
  1615.         dialogue = "SolHulkCh3_095" 
  1616.     elseif pickone == 42 then
  1617.         dialogue = "SolSolCh3_010" 
  1618.     elseif pickone == 43 then
  1619.         dialogue = "SolSolCh3_011" 
  1620.     elseif pickone == 44 then
  1621.         dialogue = "SolSolCh3_013" 
  1622.     elseif pickone == 45 then
  1623.         dialogue = "SolSolCh3_014" 
  1624.     elseif pickone == 46 then
  1625.         dialogue = "SolSolCh3_015" 
  1626.     elseif pickone == 47 then
  1627.         dialogue = "SolSolCh3_016" 
  1628.     elseif pickone == 48 then
  1629.         dialogue = "SolSolCh3_019" 
  1630.     elseif pickone == 49 then
  1631.         dialogue = "SolSolCh3_020" 
  1632.     elseif pickone == 50 then
  1633.         dialogue = "SolSolCh3_021" 
  1634.     elseif pickone == 51 then
  1635.         dialogue = "SolSolCh3_025" 
  1636.     elseif pickone == 52 then
  1637.         dialogue = "SolSolCh3_026" 
  1638.     elseif pickone == 53 then
  1639.         dialogue = "SolSolCh3_033" 
  1640.     elseif pickone == 54 then
  1641.         dialogue = "SolSolCh3_037" 
  1642.     elseif pickone == 55 then
  1643.         dialogue = "SolSolCh3_039" 
  1644.     elseif pickone == 56 then
  1645.         dialogue = "SolSolCh3_039" 
  1646.     elseif pickone == 57 then
  1647.         dialogue = "SolSolCh3_056" 
  1648.     elseif pickone == 58 then
  1649.         dialogue = "SolSolCh3_057" 
  1650.     elseif pickone == 59 then
  1651.         dialogue = "SolSolCh3_067" 
  1652.     elseif pickone == 60 then
  1653.         dialogue = "SolSolCh3_068" 
  1654.     elseif pickone == 61 then
  1655.         dialogue = "SolSolCh3_069" 
  1656.     elseif pickone == 62 then
  1657.         dialogue = "SolBanCh1_149" 
  1658.     end
  1659.  
  1660.     snd_PlayActorDialogue ( dialogue, name )
  1661.     debug ("[DIA]Spawn: " .. name .. " " .. dialogue)
  1662.  
  1663. end
  1664.  
  1665. function dia_alpha_needbackup( name )
  1666.     return
  1667. end
  1668.  
  1669. function dia_alpha_gettingbackup( name )
  1670.     return
  1671. end
  1672.  
  1673. function dia_alpha_spawn( name )
  1674.  
  1675.     if random(1,4) == 1 then
  1676.         debug ("[DIA] 1 in 4 .. no comment")
  1677.         return
  1678.     end
  1679.  
  1680.     local pickone = random(1,24)
  1681.  
  1682.     if pickone == 1 then
  1683.         dialogue = "AlphBanCh2_35" 
  1684.     elseif pickone == 2 then
  1685.         dialogue = "AlphBanCh2_36" 
  1686.     elseif pickone == 3 then
  1687.         dialogue = "AlphBanCh2_63" 
  1688.     elseif pickone == 4 then
  1689.         dialogue = "AlphBanCh4_01" 
  1690.     elseif pickone == 5 then
  1691.         dialogue = "AlphBanCh4_02" 
  1692.     elseif pickone == 6 then
  1693.         dialogue = "AlphHulkCh2_001" 
  1694.     elseif pickone == 7 then
  1695.         dialogue = "AlphHulkCh2_002" 
  1696.     elseif pickone == 8 then
  1697.         dialogue = "AlphHulkCh2_003" 
  1698.     elseif pickone == 9 then
  1699.         dialogue = "AlphHulkCh2_004" 
  1700.     elseif pickone == 10 then
  1701.         dialogue = "AlphHulkCh2_005" 
  1702.     elseif pickone == 11 then
  1703.         dialogue = "AlphHulkCh2_056" 
  1704.     elseif pickone == 12 then
  1705.         dialogue = "AlphHulkCh2_057" 
  1706.     elseif pickone == 13 then
  1707.         dialogue = "AlphHulkCh2_058" 
  1708.     elseif pickone == 14 then
  1709.         dialogue = "AlphHulkCh2_059" 
  1710.     elseif pickone == 15 then
  1711.         dialogue = "AlphHulkCh2_060" 
  1712.     elseif pickone == 16 then
  1713.         dialogue = "AlphHulkCh2_061" 
  1714.     elseif pickone == 17 then
  1715.         dialogue = "AlphHulkCh2_062" 
  1716.     elseif pickone == 18 then
  1717.         dialogue = "AlphHulkCh2_063" 
  1718.     elseif pickone == 19 then
  1719.         dialogue = "AlphHulkCh2_065" 
  1720.     elseif pickone == 20 then
  1721.         dialogue = "AlphHulkCh2_072"
  1722.     elseif pickone == 21 then
  1723.         dialogue = "AlphHulkCh2_075" 
  1724.     elseif pickone == 22 then
  1725.         dialogue = "AlphHulkCh2_090" 
  1726.     elseif pickone == 23 then
  1727.         dialogue = "AlphHulkCh4_001" 
  1728.     elseif pickone == 24 then
  1729.         dialogue = "AlphHulkCh4_002" 
  1730.     end
  1731.  
  1732.     snd_PlayActorDialogue ( dialogue, name )
  1733.     debug ("[DIA]Alpha Spawn " .. dialogue .. " " .. name)
  1734.  
  1735. end
  1736.  
  1737. function dia_gamma_spawn( name )
  1738.  
  1739.     if random(1,4) == 1 then
  1740.         debug ("[DIA] 1 in 4 .. no comment")
  1741.         return
  1742.     end
  1743.  
  1744.     local pickone = random(1,59)
  1745.  
  1746.     if pickone == 1 then
  1747.         dialogue = "GamHulkCh4_01" 
  1748.     elseif pickone == 2 then
  1749.         dialogue = "GamHulkCh4_03" 
  1750.     elseif pickone == 3 then
  1751.         dialogue = "GamHulkCh4_31" 
  1752.     elseif pickone == 4 then
  1753.         dialogue = "GamHulkCh4_32" 
  1754.     elseif pickone == 5 then
  1755.         dialogue = "GamHulkCh4_33" 
  1756.     elseif pickone == 6 then
  1757.         dialogue = "GamHulkCh4_40" 
  1758.     elseif pickone == 7 then
  1759.         dialogue = "GamBanCh4_37" 
  1760.     elseif pickone == 8 then
  1761.         dialogue = "GamBanCh4_38" 
  1762.     elseif pickone == 9 then
  1763.         dialogue = "GamBanCh4_39" 
  1764.     elseif pickone == 10 then
  1765.         dialogue = "GamBanCh4_40" 
  1766.     elseif pickone == 11 then
  1767.         dialogue = "GamBanCh4_41" 
  1768.     elseif pickone == 12 then
  1769.         dialogue = "GamBanCh4_43" 
  1770.     elseif pickone == 13 then
  1771.         dialogue = "GamBanCh4_44" 
  1772.     elseif pickone == 14 then
  1773.         dialogue = "GamBanCh4_45" 
  1774.     elseif pickone == 15 then
  1775.         dialogue = "GamBanCh4_47" 
  1776.     elseif pickone == 16 then
  1777.         dialogue = "GamBanCh4_02" 
  1778.     elseif pickone == 17 then
  1779.         dialogue = "GamBanCh4_03" 
  1780.     elseif pickone == 18 then
  1781.         dialogue = "GamBanCh4_04" 
  1782.     elseif pickone == 19 then
  1783.         dialogue = "GamBanCh4_14" 
  1784.     elseif pickone == 20 then
  1785.         dialogue = "GamBanCh4_15"
  1786.     elseif pickone == 21 then
  1787.         dialogue = "GamBanCh4_23" 
  1788.     elseif pickone == 22 then
  1789.         dialogue = "GamBanCh4_29" 
  1790.     elseif pickone == 23 then
  1791.         dialogue = "GamBanCh4_31" 
  1792.     elseif pickone == 24 then
  1793.         dialogue = "GamBanCh4_32" 
  1794.     elseif pickone == 25 then
  1795.         dialogue = "GamBanCh4_33" 
  1796.     elseif pickone == 26 then
  1797.         dialogue = "GamBanCh4_49" 
  1798.     elseif pickone == 27 then
  1799.         dialogue = "GamBanCh4_50" 
  1800.     elseif pickone == 28 then
  1801.         dialogue = "GamBanCh4_51" 
  1802.     elseif pickone == 29 then
  1803.         dialogue = "GamBanCh4_54" 
  1804.     elseif pickone == 30 then
  1805.         dialogue = "GamBanCh4_55"
  1806.     elseif pickone == 31 then
  1807.         dialogue = "GamBanCh4_59"
  1808.     elseif pickone == 32 then
  1809.         dialogue = "GamElBan_01" 
  1810.     elseif pickone == 33 then
  1811.         dialogue = "GamElBan_02" 
  1812.     elseif pickone == 34 then
  1813.         dialogue = "GamElBan_03" 
  1814.     elseif pickone == 35 then
  1815.         dialogue = "GamElBan_26" 
  1816.     elseif pickone == 36 then
  1817.         dialogue = "GamElBan_22" 
  1818.     elseif pickone == 37 then
  1819.         dialogue = "GamElBan_2" 
  1820.     elseif pickone == 38 then
  1821.         dialogue = "GamElBan_28" 
  1822.     elseif pickone == 39 then
  1823.         dialogue = "GamElBan_37" 
  1824.     elseif pickone == 40 then
  1825.         dialogue = "GamElBan_38"
  1826.     elseif pickone == 41 then
  1827.         dialogue = "GamElBan_39"
  1828.     elseif pickone == 42 then
  1829.         dialogue = "GamElBan_40" 
  1830.     elseif pickone == 43 then
  1831.         dialogue = "GamElBan_41" 
  1832.     elseif pickone == 44 then
  1833.         dialogue = "GamElBan_42" 
  1834.     elseif pickone == 45 then
  1835.         dialogue = "GamElBan_4" 
  1836.     elseif pickone == 46 then
  1837.         dialogue = "GamElBan_44" 
  1838.     elseif pickone == 47 then
  1839.         dialogue = "GamElBan_45" 
  1840.     elseif pickone == 48 then
  1841.         dialogue = "GamElBan_55" 
  1842.     elseif pickone == 49 then
  1843.         dialogue = "GamElBan_56" 
  1844.     elseif pickone == 50 then
  1845.         dialogue = "GamElBan_57"
  1846.     elseif pickone == 51 then
  1847.         dialogue = "GamElBan_58"
  1848.     elseif pickone == 52 then
  1849.         dialogue = "GamElBan_59" 
  1850.     elseif pickone == 53 then
  1851.         dialogue = "GamElHulk_01" 
  1852.     elseif pickone == 54 then
  1853.         dialogue = "GamElHulk_02" 
  1854.     elseif pickone == 55 then
  1855.         dialogue = "GamElHulk_03" 
  1856.     elseif pickone == 56 then
  1857.         dialogue = "GamElHulk_21" 
  1858.     elseif pickone == 57 then
  1859.         dialogue = "GamElHulk_31" 
  1860.     elseif pickone == 58 then
  1861.         dialogue = "GamElHulk_32" 
  1862.     elseif pickone == 59 then
  1863.         dialogue = "GamElHulk_33" 
  1864.     end
  1865.  
  1866.     snd_PlayActorDialogue ( dialogue, name )
  1867.     debug ("[DIA]Alpha Spawn " .. dialogue .. " " .. name)
  1868.  
  1869. end
  1870.  
  1871. function dia_gamma_needbackup ( name ) 
  1872.     return
  1873. end
  1874.  
  1875. function dia_gamma_gettingbackup( name )
  1876.     return
  1877. end
  1878.  
  1879. ---------- soak globals to affect behaviors
  1880. soak_kill_C0L1 = 1
  1881. soak_kill_C1L1 = 1
  1882. soak_kill_C1L2 = 1
  1883. soak_kill_C1L3 = 1
  1884. soak_kill_C1L4 = 1
  1885. soak_kill_C1L5 = 1
  1886. soak_kill_C2L1 = 1
  1887. soak_kill_C2L2 = 1
  1888. soak_kill_C2L4 = 1
  1889. soak_kill_C2L5 = 1
  1890. soak_kill_C3L1 = 1
  1891. soak_kill_C3L2 = 1
  1892. soak_kill_C3L3 = 1
  1893. soak_kill_C3L4 = 1
  1894. soak_kill_C4L1 = 1
  1895. soak_kill_C4L2 = 1
  1896. soak_kill_C4L3 = 1
  1897. soak_kill_C4L4 = 1
  1898. soak_kill_C5L1 = 1
  1899. soak_kill_C5L2 = 1
  1900. soak_kill_C5L3 = 1
  1901. soak_kill_C5L4 = 1
  1902. soak_kill_C9L1 = 1
  1903. soak_kill_C9L2 = 1
  1904. soak_kill_C9L3 = 1
  1905. soak_kill_C9L5 = 1
  1906. soak_kill_C9L6 = 1
  1907.  
  1908.  
  1909. C0L1_timer = 10
  1910. C1L1_timer = 5
  1911. C1L2_timer = 5
  1912. C1L3_timer = 5
  1913. C1L4_timer = 5
  1914. C1L5_timer = 10
  1915. C2L1_timer = 5
  1916. C2L2_timer = 5
  1917. C2L4_timer = 5
  1918. C2L5_timer = 10
  1919. C3L1_timer = 5
  1920. C3L2_timer = 5
  1921. C3L3_timer = 5
  1922. C3L4_timer = 10
  1923. C4L1_timer = 5
  1924. C4L2_timer = 5
  1925. C4L3_timer = 5
  1926. C4L4_timer = 10
  1927. C5L1_timer = 5
  1928. C5L2_timer = 5
  1929. C5L3_timer = 5
  1930. C5L4_timer = 5
  1931. C9L1_timer = 10
  1932. C9L2_timer = 10
  1933. C9L3_timer = 10
  1934. C9L5_timer = 10
  1935. C9L6_timer = 10
  1936.  
  1937. C2L2_loop = 0
  1938. C2L4_loop = 0
  1939. C3L2_loop = 0
  1940. C4L2_loop = 0
  1941.  
  1942.  
  1943. function moveActorToVolume( actor, volume )
  1944.     volExists = tvm_DoesVolumeExist( volume )
  1945.     write ("<SOAK> MoveActorToVol"..volume.."\n")
  1946.     if volExists ~= nil then
  1947.         v = tvm_GetVolumePosition( volume )
  1948.         am_SetActorPosition( actor, v )
  1949.         cm_ResetGameCamera()
  1950.         am_SetCharacterHealth( "hulk", 900 )
  1951.     else
  1952.         write ("Unable to locate volume " .. volume .. "\n")
  1953.     end
  1954. end  
  1955. function moveActorToLoc( actor, x,y,z )
  1956.     write ("<SOAK> MoveActorToLoc\n")
  1957.     v = tvm_GetVolumePosition( "" )    -- create vector
  1958.     v.x = x
  1959.     v.y = y
  1960.     v.z = z
  1961.     am_SetActorPosition( actor, v )
  1962.     cm_ResetGameCamera()
  1963.     am_SetActorOrientation("hulk",random(360))
  1964.     am_SetCharacterHealth( "hulk", 900 )
  1965. end  
  1966. -- Valid level list
  1967. AddValidLevel("C0L1");
  1968.