home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / crate.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  5.8 KB  |  249 lines

  1. //**************************************************************************
  2. //*** will setup all specified crates in the editor spawn items
  3. //*** syntax --------------------------------
  4. //*** item_crate
  5. //**************************************************************************
  6. item_crate:
  7.  
  8. if ($item_crate == NULL)
  9. {
  10.     println "^~^~^ No item crates in the level!!"
  11.     goto item_crate_end
  12. }
  13.  
  14. for (local.i = 1; local.i <= $item_crate.size ; local.i ++)
  15. {
  16.            $item_crate[local.i] thread item_crate_spawn local.i
  17. }
  18.  
  19. item_crate_end:
  20. end
  21.  
  22.  
  23. //**************************************************************************
  24. //*** thread to spawn the desired item per crate
  25. //*** syntax --------------------------------
  26. //*** <crate> item_crate_spawn <array index>
  27. //**************************************************************************
  28. item_crate_spawn local.index:
  29.  
  30. //*** find out what should be spawned
  31. switch (local.self.item)
  32. {
  33.     case "ammo_pistol":
  34.         local.item = "items/item_pistol_ammobox"
  35.         local.set_angle = "0 0 0"
  36.         break
  37.         
  38.     case "ammo_rifle":
  39.         local.item = "items/item_rifle_ammobox"
  40.         local.set_angle = "0 0 0"
  41.         break
  42.         
  43.     case "ammo_smg":
  44.         local.item = "items/item_smg_ammobox"
  45.         local.set_angle = "0 0 0"
  46.         break
  47.         
  48.     case "ammo_mg":
  49.         local.item = "items/item_mg_ammobox"
  50.         local.set_angle = "0 0 0"
  51.         break
  52.         
  53.     case "ammo_heavy":
  54.         local.item = "items/item_heavy_ammobox"
  55.         local.set_angle = "90 0 0"
  56.         break
  57.         
  58.     case "ammo_grenade":
  59.         local.item = "items/item_grenade_ammobox"
  60.         local.set_angle = "0 0 0"
  61.         break
  62.         
  63.     case "health_100":
  64.         local.item = "items/item_100_healthbox"
  65.         local.set_angle = "0 0 0"
  66.         break
  67.         
  68.     case "health_50":
  69.         local.item = "items/item_50_healthbox"
  70.         local.set_angle = "0 0 0"
  71.         break
  72.         
  73.     case "health_25":
  74.         local.item = "items/item_25_healthbox"
  75.         local.set_angle = "0 0 0"
  76.         break
  77.  
  78.     default:
  79.         local.item = NIL
  80.         local.set_angle = NIL
  81.         break
  82. }
  83.  
  84. //*** check if an item is desired
  85. if (local.item != NIL )
  86. {
  87.         //*** set temp variables
  88.         local.spawn_origin = local.self.origin
  89.         local.spawn_targetname = (local.self.targetname + "_item_" + local.index)
  90.         
  91.         //*** wait till the crate is destroyed
  92.         local.self waittill death
  93.  
  94.     //*** spawn the item
  95.         spawn local.item targetname local.spawn_targetname angles local.set_angle
  96.         local.spawn_targetname = $(local.self.targetname + "_item_" + local.index)
  97.         
  98.         //*** reset the items origin
  99.         local.spawn_targetname.angles = local.set_angle
  100.         local.spawn_targetname.origin = local.spawn_origin
  101.  
  102. end
  103.  
  104.  
  105. //**************************************************************************
  106. //*** will setup all specified crates in the editor for explosive crates
  107. //*** syntax --------------------------------
  108. //*** explosive_crate
  109. //**************************************************************************
  110. explosive_crate:
  111.  
  112. if ($explosive_crate == NULL)
  113. {
  114.     println "^~^~^ No explosive crates in the level!!"
  115.     goto explosive_crate_done
  116. }
  117.  
  118. for (local.i = 1; local.i <= $explosive_crate.size ; local.i ++)
  119. {
  120.            $explosive_crate[local.i] thread explosive_crate_spawn local.i
  121. }
  122.  
  123. explosive_crate_done:
  124. end
  125.  
  126.  
  127. //**************************************************************************
  128. //*** thread for the explosive crate
  129. //*** syntax --------------------------------
  130. //*** <crate> explosive_crate_spawn <array index>
  131. //**************************************************************************
  132. explosive_crate_spawn local.index:
  133.  
  134. //*** set temp variables
  135. local.spawn_origin = local.self.origin
  136. local.spawn_targetname = (local.self.targetname + "_explosive_" + local.index)
  137.  
  138. if (local.self.dmg != NIL)
  139. {
  140.     local.dmg = local.self.dmg
  141. }
  142. else
  143. {
  144.     local.dmg = 250
  145. }
  146.  
  147. if (local.self.radius != NIL)
  148. {
  149.     local.radius = local.self.radius
  150. }
  151. else
  152. {
  153.     local.radius = 256
  154. }
  155.  
  156. //*** wait till the crate is destroyed
  157. local.self waittill death
  158.  
  159. //*** spawn the item
  160. spawn "animate/fx_explosion_mine" targetname local.spawn_targetname angle "-1"
  161. local.spawn_targetname = $(local.self.targetname + "_explosive_" + local.index)
  162.  
  163. //*** reset the items origin
  164. local.spawn_targetname.origin = local.spawn_origin
  165.  
  166. local.spawn_targetname anim start
  167.  
  168. //*** damage the player  <origin> <damage> <radius> [consitent]
  169. radiusdamage local.spawn_targetname.origin local.dmg local.radius
  170.  
  171. //*** get the distance to the player
  172. local.distance = vector_length (local.self.origin - $player.origin)
  173. local.check_distance = (local.radius * 1.5)
  174. local.outter_distance = (local.radius * 2.5)
  175.  
  176. //*** shake his view
  177. if (local.distance <= local.check_distance)  //*** inner distance check
  178. {
  179.     if (local.dmg <= 150)
  180.         {
  181.             thread jitter_small
  182.         }
  183.     else
  184.     {
  185.         thread jitter_normal
  186.     }
  187. }
  188. else if (local.distance <= local.outter_distance)  //*** outter distance check
  189. {
  190.     if (local.dmg <= 150)
  191.         {
  192.             thread jitter_tiny
  193.         }
  194.     else
  195.     {
  196.         thread jitter_small
  197.     }
  198. }
  199.  
  200. wait (randomint 3 + 4)
  201.  
  202. //*** delete the effect out of the world now that it's done
  203. local.spawn_targetname remove
  204.  
  205. end
  206.  
  207.  
  208. //******************************
  209. // jitter effect
  210. // jitter_normal
  211. //******************************
  212. jitter_normal:
  213.  
  214. waitexec global/earthquake.scr .4 3 0 0
  215.  
  216. waitexec global/earthquake.scr .5 1 0 0
  217.  
  218. //waitexec global/earthquake.scr .5 1 0 0
  219.  
  220. end
  221.  
  222.  
  223. //*********************************
  224. // jitter effect
  225. // jitter_small
  226. //*********************************
  227. jitter_small:
  228.  
  229. waitexec global/earthquake.scr .3 1.5 0 0
  230.  
  231. waitexec global/earthquake.scr .35 .75 0 0
  232.  
  233. //waitexec global/earthquake.scr .5 1 0 0
  234.  
  235. end
  236.  
  237.  
  238. //*********************************
  239. // jitter effect
  240. // jitter_tiny
  241. //*********************************
  242. jitter_tiny:
  243.  
  244. waitexec global/earthquake.scr 1 .3 0 0
  245.  
  246. //waitexec global/earthquake.scr .5 1 0 0
  247.  
  248. end