./hud_reticules.lua

  1. local HUD_RETICULE_OVERHEAT_RED 		= { R = 230/255, G = 5/255, B = 5/255} 
  2. local HUD_RETICULE_OVERHEAT_LIGHT 	= { R = 230/255, G = 109/255, B = 33/255} 
  3. local HUD_RETICULE_CHARGE_MAX 		= { R = 69/255, G = 185/255, B = 10/255} 
  4. local HUD_RETICULE_CHARGE_MIN 		= { R = 178/255, G = 218/255, B = 19/255} 
  5.  
  6.  
  7. local HUD_RETICULE_RING_SIZE_DIF 	= .44		--This is the scale difference between the small and large ring... 
  8.  
  9. local RET_CONFIG_NONE					= 0 
  10. local RET_CONFIG_PISTOL 				= 1 
  11. local RET_CONFIG_HOLT55					= 2 
  12. local RET_CONFIG_SHOTGUN 				= 3 
  13. local RET_CONFIG_SUB_RIFLE 			= 4 
  14. local RET_CONFIG_RIFLE 					= 5 
  15. local RET_CONFIG_RPG 					= 6 
  16. local RET_CONFIG_RPG_ANNIHILATOR 	= 7 
  17. local RET_CONFIG_THROWN 				= 8 
  18. local RET_CONFIG_SNIPER				 	= 9 
  19. local RET_CONFIG_PRESSURE			 	= 10 
  20.  
  21. local RET_SPREAD_DEFAULT			 	= 0 
  22. local RET_SPREAD_RIFLE				 	= 1 
  23. local RET_SPREAD_SMG				 		= 2 
  24. local RET_SPREAD_SNIPER				 	= 3 
  25.  
  26. local RET_CROSS_SIZE_NONE				= 0  
  27. local RET_CROSS_SIZE_SMALL 			= 1 
  28. local RET_CROSS_SIZE_LARGE 			= 2 
  29.  
  30. local RET_HIT_MAX							= 5 
  31.  
  32. Hud_reticules = { 
  33. 	configs = { 
  34. 		[RET_CONFIG_NONE] = { 
  35. 			dot = {false, false}, 
  36. 			ring = {false, false}, 
  37. 			ring_split = {false, false}, 
  38. 			cross = {false, false}, 
  39. 			cross_size = nil, 
  40. 			cross_orientation = nil, 
  41. 			spread = false, 
  42. 			spread_style = RET_SPREAD_DEFAULT, 
  43. 			sniper = false, 
  44. 			pressure = false, 
  45. 		}, 
  46. 		[RET_CONFIG_PISTOL] = { 
  47. 			dot = {true, false}, 
  48. 			ring = {true, true}, 
  49. 			ring_split = {false, false}, 
  50. 			cross = {false, false}, 
  51. 			cross_size = nil, 
  52. 			cross_orientation = nil, 
  53. 			spread = false, 
  54. 			spread_style = RET_SPREAD_DEFAULT, 
  55. 			sniper = false, 
  56. 			pressure = false, 
  57. 		}, 
  58. 		[RET_CONFIG_HOLT55] = { 
  59. 			dot = {false, false}, 
  60. 			ring = {true, true}, 
  61. 			ring_split = {false, false}, 
  62. 			cross = {false, false}, 
  63. 			cross_size = nil, 
  64. 			cross_orientation = nil, 
  65. 			spread = true, 
  66. 			spread_style = RET_SPREAD_DEFAULT, 
  67. 			sniper = false, 
  68. 			pressure = false, 
  69. 		}, 
  70. 		[RET_CONFIG_SHOTGUN] = { 
  71. 			dot = {false, false}, 
  72. 			ring = {true, true}, 
  73. 			ring_split = {false, false}, 
  74. 			cross = {false, false}, 
  75. 			cross_size = nil, 
  76. 			cross_orientation = nil, 
  77. 			spread = false, 
  78. 			spread_style = RET_CONFIG_SHOTGUN, 
  79. 			sniper = false, 
  80. 			pressure = false, 
  81. 		}, 
  82. 		[RET_CONFIG_SUB_RIFLE] = { 
  83. 			dot = {false, false}, 
  84. 			ring = {true, true}, 
  85. 			ring_split = {false, false}, 
  86. 			cross = {true, true}, 
  87. 			cross_size = RET_CROSS_SIZE_SMALL, 
  88. 			cross_orientation = 0, 
  89. 			spread = true, 
  90. 			spread_style = RET_SPREAD_SMG, 
  91. 			sniper = false, 
  92. 			pressure = false, 
  93. 		}, 
  94. 		[RET_CONFIG_RIFLE] = { 
  95. 			dot = {false, false}, 
  96. 			ring = {false, false}, 
  97. 			ring_split = {false, false}, 
  98. 			cross = {true, true}, 
  99. 			cross_size = RET_CROSS_SIZE_LARGE, 
  100. 			cross_orientation = 0, 
  101. 			spread = true, 
  102. 			spread_style = RET_SPREAD_DEFAULT, 
  103. 			sniper = false, 
  104. 			pressure = false, 
  105. 		}, 
  106. 		[RET_CONFIG_RPG] = { 
  107. 			dot = {false, false}, 
  108. 			ring = {false, false}, 
  109. 			ring_split = {false, false}, 
  110. 			cross = {true, true}, 
  111. 			cross_size = RET_CROSS_SIZE_LARGE, 
  112. 			cross_orientation = 1, 
  113. 			spread = false, 
  114. 			spread_style = RET_SPREAD_DEFAULT, 
  115. 			sniper = false, 
  116. 			pressure = false, 
  117. 		}, 
  118. 		[RET_CONFIG_RPG_ANNIHILATOR] = { 
  119. 			dot = {false, false}, 
  120. 			ring = {false, false}, 
  121. 			ring_split = {false, false}, 
  122. 			cross = {true, true}, 
  123. 			cross_size = RET_CROSS_SIZE_LARGE, 
  124. 			cross_orientation = 1, 
  125. 			spread = false, 
  126. 			spread_style = RET_SPREAD_DEFAULT, 
  127. 			sniper = false, 
  128. 			pressure = false, 
  129. 		}, 
  130. 		[RET_CONFIG_THROWN] = { 
  131. 			dot = {false, false}, 
  132. 			ring = {false, false}, 
  133. 			ring_split = {true, true}, 
  134. 			cross = {false, false}, 
  135. 			cross_size = nil, 
  136. 			cross_orientation = nil, 
  137. 			spread = false, 
  138. 			spread_style = RET_SPREAD_DEFAULT, 
  139. 			sniper = false, 
  140. 			pressure = false, 
  141. 		}, 
  142. 		[RET_CONFIG_SNIPER] = { 
  143. 			dot = {false, false}, 
  144. 			ring = {false, false}, 
  145. 			ring_split = {false, false}, 
  146. 			cross = {true, true}, 
  147. 			cross_size = "large", 
  148. 			cross_orientation = 0, 
  149. 			spread = false, 
  150. 			spread_style = RET_SPREAD_SNIPER, 
  151. 			sniper = true, 
  152. 			pressure = false, 
  153. 		}, 
  154. 		[RET_CONFIG_PRESSURE] = { 
  155. 			dot = {false, false}, 
  156. 			ring = {true, true}, 
  157. 			ring_split = {false, false}, 
  158. 			cross = {false, false}, 
  159. 			cross_size = nil, 
  160. 			cross_orientation = nil, 
  161. 			spread = false, 
  162. 			spread_style = RET_SPREAD_DEFAULT, 
  163. 			sniper = false, 
  164. 			pressure = true, 
  165. 		} 
  166. 	}, 
  167. 	categories = { 
  168. 		["WPNCAT_MELEE"] = RET_CONFIG_NONE, 
  169. 		["WPNCAT_PISTOL"] = RET_CONFIG_PISTOL, 
  170. 		["WPNCAT_SHOTGUN"] = RET_CONFIG_SHOTGUN, 
  171. 		["WPNCAT_SUB_MACHINE_GUN"] = RET_CONFIG_SUB_RIFLE, 
  172. 		["WPNCAT_RIFLE"] = RET_CONFIG_RIFLE, 
  173. 		["WPNCAT_SPECIAL"] = RET_CONFIG_SHOTGUN, 
  174. 		["WPNCAT_THROWN"] = RET_CONFIG_THROWN, 
  175. 		["WPNCAT_HAVOK"] = RET_CONFIG_THROWN, 
  176. 	}, 
  177. 	wpn_names = { 
  178. 		["stun_gun"] = RET_CONFIG_PISTOL, 
  179. 		["Holt_55"] = RET_CONFIG_HOLT55, 
  180. 		["pepper_spray"] = RET_CONFIG_SHOTGUN, 
  181. 		["fireext"] = RET_CONFIG_SHOTGUN, 
  182. 		["minigun"] = RET_CONFIG_SHOTGUN, 
  183. 		["rpg_annihilator"] = RET_CONFIG_RPG_ANNIHILATOR, 
  184. 		["rpg_launcher"] = RET_CONFIG_RPG, 
  185. 		["mcmanus2010"] = RET_CONFIG_SNIPER, 
  186. 		["bean_bag_gun"] = RET_CONFIG_PISTOL, 
  187. 		["truck_2dr_septic01_Rear"] = RET_CONFIG_PRESSURE, 
  188. 		["truck_2dr_septic01_Front"] = RET_CONFIG_PRESSURE, 
  189. 		["truck_2dr_fire01"] = RET_CONFIG_PRESSURE, 
  190. 		["sp_novelty01"] = RET_CONFIG_PRESSURE, 
  191. 		 
  192. 		["sp_tank01_w"] = RET_CONFIG_RIFLE, 
  193. 		["sp_tank01_w2"] = RET_CONFIG_RIFLE, 
  194. 		["sp_tank02_w"] = RET_CONFIG_RIFLE, 
  195. 		["sp_tank03_w"] = RET_CONFIG_RIFLE, 
  196. 		["sp_tank03_w2"] = RET_CONFIG_RIFLE, 
  197. 	}, 
  198. 	elements = { 
  199. 		reticule_h = -1, 
  200. 		dot_h = -1, 
  201. 		cross_h = -1, 
  202. 		cross_n_h = -1, 
  203. 		cross_e_h = -1, 
  204. 		cross_s_h = -1, 
  205. 		cross_w_h = -1, 
  206. 		ring_small_h = -1, 
  207. 		ring_large_h = -1, 
  208. 		ring_mask_nw_h = -1, 
  209. 		ring_mask_ne_h = -1, 
  210. 		ring_mask_sw_h = -1, 
  211. 		ring_mask_se_h = -1, 
  212. 		ring_split_h = -1, 
  213. 		sniper_h = -1, 
  214. 		sniper_cross_w_h = -1, 
  215. 		sniper_cross_s_h = -1, 
  216. 		sniper_cross_e_h = -1, 
  217. 		sniper_dir_grp_h = -1, 
  218. 		sniper_dir_bmp_h = -1, 
  219. 		friendly_h = -1, 
  220. 		pressure_grp_h = -1, 
  221. 		pressure_fill_h = -1, 
  222. 	}, 
  223. 	status = { 
  224. 		wpn_name = -1, 
  225. 		config = -1, 
  226. 		highlight = -1, 
  227. 		wpn_spread = -1, 
  228. 		fine_aim = -1, 
  229. 		y_screen_coord = -1, 
  230. 	},  
  231. 	spread_style = { 
  232. 		[RET_SPREAD_DEFAULT] = { 
  233. 			cross_mag_min = 3, 
  234. 			cross_mag_max = 6, 
  235. 			cross_mag_fineaim_min = -1, 
  236. 			cross_mag_fineaim_max = 16, 
  237. 			ring_alpha = .67,  
  238. 			ring_alpha_highlight = .9, 
  239. 			ring_min = 1,--0.7, 
  240. 			ring_max = 2.3, 
  241. 			ring_fineaim_min = 0.85,--0.5, 
  242. 			ring_fineaim_max = 1.8, 
  243. 			ring_mask_min = 0, 
  244. 			ring_mask_max = 20, 
  245. 			ring_mask_fineaim_min = 0, 
  246. 			ring_mask_fineaim_max = 20, 
  247. 		}, 
  248. 		[RET_SPREAD_SMG] = { 
  249. 			cross_mag_min = 1, 
  250. 			cross_mag_max = 8, 
  251. 			cross_mag_fineaim_min = -1, 
  252. 			cross_mag_fineaim_max = 8, 
  253. 			ring_alpha = .67,  
  254. 			ring_alpha_highlight = .9, 
  255. 			ring_min = 1, 
  256. 			ring_max = 1.2,--2.3, 
  257. 			ring_fineaim_min = .85, 
  258. 			ring_fineaim_max = 1.2, 
  259. 			ring_mask_min = 0, 
  260. 			ring_mask_max = 10, 
  261. 			ring_mask_fineaim_min = 0, 
  262. 			ring_mask_fineaim_max = 8, 
  263. 		}, 
  264. 		[RET_CONFIG_SHOTGUN] = { 
  265. 			cross_mag_min = 1, 
  266. 			cross_mag_max = 19, 
  267. 			cross_mag_fineaim_min = -1, 
  268. 			cross_mag_fineaim_max = 16, 
  269. 			ring_alpha = .67,  
  270. 			ring_alpha_highlight = .9, 
  271. 			ring_min = 1.6, 
  272. 			ring_max = 2.3, 
  273. 			ring_fineaim_min = 1.2, 
  274. 			ring_fineaim_max = 1.8, 
  275. 			ring_mask_min = 0, 
  276. 			ring_mask_max = 20, 
  277. 			ring_mask_fineaim_min = 0, 
  278. 			ring_mask_fineaim_max = 20, 
  279. 		}, 
  280. 		[RET_SPREAD_SNIPER] = { 
  281. 			cross_mag_min = 15, 
  282. 			cross_mag_max = 25, 
  283. 			cross_mag_fineaim_min =  15, 
  284. 			cross_mag_fineaim_max =  25, 
  285. 			ring_alpha = .67,  
  286. 			ring_alpha_highlight = .9, 
  287. 			ring_min = 1, 
  288. 			ring_max = 2.3, 
  289. 			ring_fineaim_min = .85, 
  290. 			ring_fineaim_max = 1.8, 
  291. 			ring_mask_min = 0, 
  292. 			ring_mask_max = 20, 
  293. 			ring_mask_fineaim_min = 0, 
  294. 			ring_mask_fineaim_max = 20, 
  295. 		} 
  296. 	}, 
  297. 	pressure = { 
  298. 		cur_value = -1, 
  299. 		start_angle = 3.147, 
  300. 		end_angle = 0 
  301. 	}, 
  302. 	overheat = { 
  303. 		is_overheated = -1, 
  304. 		pct = -1, 
  305. 		x_scale = 1, 
  306. 		y_scale = 1, 
  307. 	} 
  308. } 
  309.  
  310. Hud_sniper_arrows = {} 
  311.  
  312. Hud_hit_data = {} 
  313.  
  314. Hud_current_hit_index = 0 
  315.  
  316.  
  317.  
  318. function hud_reticules_init() 
  319. 	--Reticules 
  320. 	 
  321. 	--Reticule Base for positioning(Controlled by game code) and doing master fades 
  322. 	local h = vint_object_find("reticules") 
  323. 	Hud_reticules.elements.reticule_base_h = h 
  324. 	 
  325. 	--Contains all the reticules but seperated from the persistant reticule which is used for fading. 
  326. 	local h = vint_object_find("reticule_container", h) 
  327. 	Hud_reticules.elements.reticule_h = h 
  328. 	 
  329. 	--Deep Reticule Parts 
  330. 	Hud_reticules.elements.dot_h = vint_object_find("dot", h) 
  331. 	Hud_reticules.elements.ring_small_h = vint_object_find("ring_small", h) 
  332. 	Hud_reticules.elements.ring_large_h = vint_object_find("ring_large", h) 
  333. 	Hud_reticules.elements.ring_split_h = vint_object_find("ring_split", h) 
  334. 	Hud_reticules.elements.ring_mask_nw_h  = vint_object_find("mask_nw", h) 
  335. 	Hud_reticules.elements.ring_mask_ne_h  = vint_object_find("mask_ne", h) 
  336. 	Hud_reticules.elements.ring_mask_sw_h  = vint_object_find("mask_sw", h) 
  337. 	Hud_reticules.elements.ring_mask_se_h  = vint_object_find("mask_se", h) 
  338. 	Hud_reticules.elements.cross_h = vint_object_find("cross", h) 
  339. 	Hud_reticules.elements.friendly_h = vint_object_find("friendly", h) 
  340. 	 
  341. 	--pressure group 
  342. 	Hud_reticules.elements.pressure_grp_h =  vint_object_find("pressure_grp", h) 
  343. 	Hud_reticules.elements.pressure_fill_h =  vint_object_find("pressure_fill", h) 
  344. 	 
  345. 	--Cross Hairs 
  346. 	h = Hud_reticules.elements.cross_h  
  347. 	Hud_reticules.elements.cross_n_h = vint_object_find("n", h) 
  348. 	Hud_reticules.elements.cross_e_h = vint_object_find("e", h) 
  349. 	Hud_reticules.elements.cross_s_h = vint_object_find("s", h) 
  350. 	Hud_reticules.elements.cross_w_h = vint_object_find("w", h) 
  351. 	 
  352. 	--Sniper! 
  353. 	Hud_reticules.elements.sniper_h = vint_object_find("sniper") 
  354. 	Hud_reticules.elements.sniper_dir_grp_h = vint_object_find("sniper_dir_grp") 
  355. 	Hud_reticules.elements.sniper_dir_bmp_h = vint_object_find("sniper_dir_bmp") 
  356. 	h = Hud_reticules.elements.sniper_h  
  357. 	 
  358. 	Hud_reticules.elements.sniper_cross_w_h = vint_object_find("cross_w", h) 
  359. 	Hud_reticules.elements.sniper_cross_s_h = vint_object_find("cross_s", h) 
  360. 	Hud_reticules.elements.sniper_cross_e_h = vint_object_find("cross_e", h) 
  361. 	 
  362. 	--Persistant Reticules 
  363. 	Hud_reticules.elements.dot_persistant_h = vint_object_find("dot_persistant") 
  364. 	 
  365. 	--Hit indication 
  366. 	Hud_reticules.elements.ret_hit_grp_h = vint_object_find("ret_hit") 
  367. 	Hud_reticules.elements.ret_hit_anim = vint_object_find("reticule_hit_anim") 
  368. 	 
  369. 	--Data subscriptions	 
  370. 	 
  371. 	--Sniper Directional Indicators 
  372. 	vint_datagroup_add_subscription("sniper_dir_arrows", "update", "hud_sniper_dir_update") 
  373. 	vint_datagroup_add_subscription("sniper_dir_arrows", "insert", "hud_sniper_dir_add") 
  374. 	vint_datagroup_add_subscription("sniper_dir_arrows", "remove", "hud_sniper_dir_remove") 
  375. 	 
  376. 	--Hit Indicators 
  377. 	vint_datagroup_add_subscription("sr2_local_player_hit_indicator", "insert", "Hud_hit_add") 
  378. end 
  379.  
  380. function Hud_reticule_process_hit(bullet_hit) 
  381. 	--process a hit 
  382. 	if bullet_hit then 
  383. 		lua_play_anim(Hud_reticules.elements.ret_hit_anim,0) 
  384. 	end 
  385. end 
  386.  
  387. --#################################################################### 
  388. --Reticules 
  389. --#################################################################### 
  390. function Hud_reticule_update(wpn_name, wpn_category, reticule_highlight )  
  391. 	 
  392. 	local reticule_layout_type = RET_CONFIG_NONE 
  393. 	 
  394. 	if wpn_name == nil then 
  395. 		--Use default layout type  
  396. 	else 
  397. 		--Check weapon name first 
  398. 		reticule_layout_type = Hud_reticules.wpn_names[wpn_name] 
  399. 	 
  400. 		--If we didn't find a match then use default category 
  401. 		if reticule_layout_type == nil then 
  402. 			reticule_layout_type = Hud_reticules.categories[wpn_category] 
  403. 		end 
  404. 	end 
  405. 	 
  406. 	if wpn_category == "WPNCAT_MELEE" or wpn_category == nil then 
  407. 		if wpn_name == "stun_gun" then 
  408. 			vint_set_property(Hud_reticules.elements.reticule_h, "visible", true) 
  409. 			vint_set_property(Hud_reticules.elements.dot_persistant_h, "visible", true) 
  410. 		else 
  411. 			vint_set_property(Hud_reticules.elements.ret_hit_grp_h, "visible", false) 
  412. 			vint_set_property(Hud_reticules.elements.reticule_h, "visible", false) 
  413. 			vint_set_property(Hud_reticules.elements.dot_persistant_h, "visible", false) 
  414. 		end 
  415. 	else 
  416. 		vint_set_property(Hud_reticules.elements.ret_hit_grp_h, "visible", true) 
  417. 		vint_set_property(Hud_reticules.elements.reticule_h, "visible", true) 
  418. 		vint_set_property(Hud_reticules.elements.dot_persistant_h, "visible", true) 
  419. 	end 
  420.  
  421. 	local reticule_layout = Hud_reticules.configs[reticule_layout_type] 
  422. 	local spread_style = Hud_reticules.spread_style[Hud_reticules.configs[reticule_layout_type].spread_style] 
  423. 	 
  424. 	--Error Check 
  425.  	if reticule_layout == nil then 
  426. 		return 
  427. 	end 
  428.  
  429. 	--Process reticule highlighting 
  430. 	if reticule_highlight == "friendly" then 
  431.  
  432. 		--Tint Sniper reticules for friendly 
  433. 		vint_set_property(Hud_reticules.elements.sniper_cross_w_h, "tint", .164, .63, .18) 
  434. 		vint_set_property(Hud_reticules.elements.sniper_cross_s_h, "tint", .164, .63, .18) 
  435. 		vint_set_property(Hud_reticules.elements.sniper_cross_e_h, "tint", .164, .63, .18) 
  436. 		 
  437. 	elseif reticule_highlight == "enemy" then 
  438. 		 
  439. 		local r_0 = .89 
  440. 		if reticule_layout.dot[2] == true then 
  441. 			vint_set_property(Hud_reticules.elements.dot_h, "tint", r_0, 0, 0) 
  442. 		else 
  443. 			vint_set_property(Hud_reticules.elements.dot_h, "tint", 1, 1, 1) 
  444. 		end 
  445. 		 
  446. 		if reticule_layout.ring[2] == true then 
  447. 			vint_set_property(Hud_reticules.elements.ring_small_h, "tint", r_0, 0, 0) 
  448. 			vint_set_property(Hud_reticules.elements.ring_large_h, "tint", r_0, 0, 0) 
  449. 			 
  450. 			vint_set_property(Hud_reticules.elements.ring_small_h, "alpha", spread_style.ring_alpha_highlight) 
  451. 			vint_set_property(Hud_reticules.elements.ring_large_h, "alpha", spread_style.ring_alpha_highlight) 
  452. 			 
  453. 		else 
  454. 			vint_set_property(Hud_reticules.elements.ring_small_h, "tint", 1, 1, 1) 
  455. 			vint_set_property(Hud_reticules.elements.ring_large_h, "tint", 1, 1, 1) 
  456. 			 
  457. 			vint_set_property(Hud_reticules.elements.ring_small_h, "alpha", spread_style.ring_alpha) 
  458. 			vint_set_property(Hud_reticules.elements.ring_large_h, "alpha", spread_style.ring_alpha) 
  459. 			 
  460. 		end 
  461. 				 
  462. 		if reticule_layout.ring_split[2] == true then 
  463. 			vint_set_property(Hud_reticules.elements.ring_split_h, "tint", r_0, 0, 0) 
  464. 		else 
  465. 			vint_set_property(Hud_reticules.elements.ring_split_h, "tint", 1, 1, 1) 
  466. 		end 
  467. 		 
  468. 		if reticule_layout.cross[2] == true then 
  469. 			vint_set_property(Hud_reticules.elements.cross_h, "tint", r_0, 0, 0) 
  470. 		else 
  471. 			vint_set_property(Hud_reticules.elements.cross_h, "tint", 1, 1, 1) 
  472. 		end 
  473. 		 
  474. 		--Tint Sniper reticules for Enemy 
  475. 		vint_set_property(Hud_reticules.elements.sniper_cross_w_h, "tint", r_0, 0, 0) 
  476. 		vint_set_property(Hud_reticules.elements.sniper_cross_s_h, "tint", r_0, 0, 0) 
  477. 		vint_set_property(Hud_reticules.elements.sniper_cross_e_h, "tint", r_0, 0, 0) 
  478. 		 
  479. 	elseif reticule_highlight == "none" then 
  480. 	 
  481. 		vint_set_property(Hud_reticules.elements.dot_h, "tint", 1, 1, 1) 
  482. 		vint_set_property(Hud_reticules.elements.ring_small_h, "tint", 1, 1, 1) 
  483. 		vint_set_property(Hud_reticules.elements.ring_large_h, "tint", 1, 1, 1) 
  484. 		vint_set_property(Hud_reticules.elements.ring_split_h, "tint", 1, 1, 1) 
  485. 		vint_set_property(Hud_reticules.elements.cross_h, "tint", 1, 1, 1) 
  486. 		 
  487. 		--Tint Sniper reticules 
  488. 		vint_set_property(Hud_reticules.elements.sniper_cross_w_h, "tint", .25, .25, .25) 
  489. 		vint_set_property(Hud_reticules.elements.sniper_cross_s_h, "tint", .25, .25, .25) 
  490. 		vint_set_property(Hud_reticules.elements.sniper_cross_e_h, "tint", .25, .25, .25) 
  491. 	end	 
  492. 	 
  493. 	--Toggle between friendly reticule and standard reticule parts 
  494. 	if reticule_highlight == "friendly" and reticule_layout_type ~= "none" then 
  495. 		--Display friendly reticule and hide other parts 
  496. 		vint_set_property(Hud_reticules.elements.friendly_h, "visible", true)  
  497. 		vint_set_property(Hud_reticules.elements.dot_h, "visible", false) 
  498. 		vint_set_property(Hud_reticules.elements.ring_small_h, "visible",false) 
  499. 		vint_set_property(Hud_reticules.elements.ring_large_h, "visible", false) 
  500. 		vint_set_property(Hud_reticules.elements.ring_split_h, "visible", false) 
  501. 		vint_set_property(Hud_reticules.elements.cross_h, "visible", false) 
  502. 	 
  503. 	else 
  504. 		--Hide friendly reticule and display the proper parts 
  505. 		vint_set_property(Hud_reticules.elements.friendly_h, "visible", false) 	 
  506. 		vint_set_property(Hud_reticules.elements.dot_h, "visible", reticule_layout.dot[1]) 
  507. 		vint_set_property(Hud_reticules.elements.ring_small_h, "visible", reticule_layout.ring[1]) 
  508. 		vint_set_property(Hud_reticules.elements.ring_large_h, "visible", reticule_layout.ring[1]) 
  509. 		vint_set_property(Hud_reticules.elements.ring_split_h, "visible", reticule_layout.ring_split[1]) 
  510. 		vint_set_property(Hud_reticules.elements.cross_h, "visible", reticule_layout.cross[1]) 
  511.  
  512. 		--Cross Size 
  513. 		if reticule_layout.cross_size == "large" then 
  514. 			--Set all bitmaps to the large size 
  515. 			vint_set_property(Hud_reticules.elements.cross_n_h, "image", "ui_hud_reticule_cross_large") 
  516. 			vint_set_property(Hud_reticules.elements.cross_e_h, "image", "ui_hud_reticule_cross_large") 
  517. 			vint_set_property(Hud_reticules.elements.cross_s_h, "image", "ui_hud_reticule_cross_large") 
  518. 			vint_set_property(Hud_reticules.elements.cross_w_h, "image", "ui_hud_reticule_cross_large") 
  519. 			vint_set_property(Hud_reticules.elements.cross_n_h, "offset", -8, -24) 
  520. 			vint_set_property(Hud_reticules.elements.cross_e_h, "offset", -8, -24) 
  521. 			vint_set_property(Hud_reticules.elements.cross_s_h, "offset", -8, -24) 
  522. 			vint_set_property(Hud_reticules.elements.cross_w_h, "offset", -8, -24) 
  523. 			 
  524. 		elseif reticule_layout.cross_size == "small" then 
  525. 			--Set all bitmaps to small size 
  526. 			vint_set_property(Hud_reticules.elements.cross_n_h, "image", "ui_hud_reticule_cross_small") 
  527. 			vint_set_property(Hud_reticules.elements.cross_e_h, "image", "ui_hud_reticule_cross_small") 
  528. 			vint_set_property(Hud_reticules.elements.cross_s_h, "image", "ui_hud_reticule_cross_small") 
  529. 			vint_set_property(Hud_reticules.elements.cross_w_h, "image", "ui_hud_reticule_cross_small") 
  530. 			vint_set_property(Hud_reticules.elements.cross_n_h, "offset", -8, -19) 
  531. 			vint_set_property(Hud_reticules.elements.cross_e_h, "offset", -8, -19) 
  532. 			vint_set_property(Hud_reticules.elements.cross_s_h, "offset", -8, -19) 
  533. 			vint_set_property(Hud_reticules.elements.cross_w_h, "offset", -8, -19) 
  534. 		end                                                         
  535. 		 
  536. 		--Cross Orientation 
  537. 		if reticule_layout.cross_orientation == 0 then 
  538. 			--Standard Orientation 
  539. 			vint_set_property(Hud_reticules.elements.cross_h, "rotation", 0) 
  540. 		elseif reticule_layout.cross_orientation == 1 then 
  541. 			--45 Degree Rotation 
  542. 			vint_set_property(Hud_reticules.elements.cross_h, "rotation", 0.785398163) 
  543. 		end 
  544. 		 
  545. 	end 
  546. 	 
  547. 	--Show pressure gauge? 
  548. 	--we don't have any pressure weapons in SR3, yet 
  549. 	--[[if reticule_layout.pressure == true then 
  550. 		vint_set_property(Hud_reticules.elements.pressure_grp_h, "visible", true) 
  551. 	else 
  552. 		vint_set_property(Hud_reticules.elements.pressure_grp_h, "visible", true)--false) 
  553. 	end]] 
  554. 	 
  555. 	--Store reticule status to internal data sets 
  556. 	Hud_reticules.status.wpn_name = wpn_name 
  557. 	Hud_reticules.status.highlight = reticule_highlight 
  558. 	Hud_reticules.status.config = reticule_layout_type 
  559. end 
  560.  
  561. function hud_reticule_spread_update(wpn_spread, show_spread) 
  562.  
  563. 	--debug_print("vint", "show_spread" .. var_to_string(show_spread) .. "\n") 
  564. 	 
  565. 	local fine_aim = Hud_weapon_status.fine_aim_transition 
  566. 	local spread_style = Hud_reticules.spread_style[Hud_reticules.configs[Hud_reticules.status.config].spread_style] 
  567. 	 
  568. 	if spread_style == nil then 
  569. 		--debug_print("vint", "Spread Style \"" .. Hud_reticules.configs[Hud_reticules.status.config].spread_style .. "\" not found in Hud_reticules.spread_style\n") 
  570. 		spread_style = Hud_reticules.spread_style[RET_SPREAD_DEFAULT] 
  571. 	end 
  572. 	 
  573. 	--Spread for to calculate crosshairs 
  574. 	local pixel_spread 
  575. 	 
  576. 	local cross_mag_min = spread_style.cross_mag_min 
  577. 	local cross_mag_max = spread_style.cross_mag_max 
  578. 	 
  579. 	cross_mag_min = cross_mag_min - ((cross_mag_min - spread_style.cross_mag_fineaim_min) * fine_aim) 
  580. 	cross_mag_max = cross_mag_max - ((cross_mag_max - spread_style.cross_mag_fineaim_max) * fine_aim) 
  581. 	 
  582. 	--debug_print("vint", "fine_aim: " .. fine_aim .. "\n") 
  583. 	--debug_print("vint", "cross_mag_min: " .. cross_mag_min .. "\n") 
  584. 	--debug_print("vint", "cross_mag_max: " .. cross_mag_max .. "\n") 
  585. 	 
  586. 	if show_spread == true then 
  587. 		pixel_spread = wpn_spread * cross_mag_max + cross_mag_min 
  588. 	else 
  589. 		pixel_spread = cross_mag_min 
  590. 	end 
  591. 	 
  592. 	vint_set_property(Hud_reticules.elements.cross_n_h, "anchor", 0, -pixel_spread) 
  593. 	vint_set_property(Hud_reticules.elements.cross_e_h, "anchor", pixel_spread, 0) 
  594. 	vint_set_property(Hud_reticules.elements.cross_s_h, "anchor", 0, pixel_spread) 
  595. 	vint_set_property(Hud_reticules.elements.cross_w_h, "anchor", -pixel_spread, 0) 
  596. 	 
  597. 	--If the reticule is highlighted over an enemy then the ring alpha is stronger 
  598. 	local ring_alpha = 0 
  599. 	if Hud_reticules.status.highlight == "enemy" then 
  600. 		ring_alpha = spread_style.ring_alpha_highlight 
  601. 	else 
  602. 		ring_alpha = spread_style.ring_alpha 
  603. 	end 
  604.  
  605. 	local ring_small_min = spread_style.ring_min  
  606. 	local ring_small_max = spread_style.ring_max 
  607. 	local ring_large_min = spread_style.ring_min * HUD_RETICULE_RING_SIZE_DIF 
  608. 	local ring_large_max = spread_style.ring_max * HUD_RETICULE_RING_SIZE_DIF 
  609. 	local ring_mask_min = spread_style.ring_mask_min 
  610. 	local ring_mask_max = spread_style.ring_mask_max 
  611. 	 
  612. 	local ring_small_fineaim_min = spread_style.ring_fineaim_min  
  613. 	local ring_small_fineaim_max = spread_style.ring_fineaim_max  
  614. 	local ring_large_fineaim_min = spread_style.ring_fineaim_min * HUD_RETICULE_RING_SIZE_DIF 
  615. 	local ring_large_fineaim_max = spread_style.ring_fineaim_max * HUD_RETICULE_RING_SIZE_DIF 
  616. 	local ring_mask_fineaim_min = spread_style.ring_mask_fineaim_min 
  617. 	local ring_mask_fineaim_max = spread_style.ring_mask_fineaim_max 
  618. 	 
  619. 	--Fine aim calculations 
  620. 	ring_small_min = ring_small_min  - ((ring_small_min 	- ring_small_fineaim_min) * fine_aim) 
  621. 	ring_small_max = ring_small_max  - ((ring_small_max 	- ring_small_fineaim_max) * fine_aim) 
  622. 	ring_large_min = ring_large_min  - ((ring_large_min 	- ring_large_fineaim_min) * fine_aim) 
  623. 	ring_large_max = ring_large_max  - ((ring_large_max 	- ring_large_fineaim_max) * fine_aim) 
  624. 	ring_mask_min 	= ring_mask_min 	- ((ring_mask_min 	- ring_mask_fineaim_min) * fine_aim) 
  625. 	ring_mask_max 	= ring_mask_max  	- ((ring_mask_max 	- ring_mask_fineaim_max) * fine_aim) 
  626. 	                                                       
  627. 	local ring_small_scale, ring_small_alpha, ring_large_scale, ring_large_alpha, ring_mask_offset 
  628. 	 
  629. 	if show_spread == true then 
  630. 		ring_small_scale = ring_small_min + wpn_spread * (ring_small_max - ring_small_min) 
  631. 		ring_small_alpha = ring_alpha - (wpn_spread * 1.5) * ring_alpha 
  632. 	 
  633. 		if ring_small_alpha < 0 then 
  634. 			ring_small_alpha = 0 
  635. 		end 
  636.  
  637. 		ring_large_scale = ring_large_min + wpn_spread * (ring_large_max - ring_large_min) 
  638. 		ring_large_alpha = (wpn_spread * 1.5) * ring_alpha 
  639. 		 
  640. 		if ring_large_alpha > ring_alpha then 
  641. 			ring_large_alpha = ring_alpha 
  642. 		end 
  643. 		 
  644. 		ring_mask_offset = ring_mask_min + wpn_spread * (ring_mask_max - ring_mask_min) 
  645. 		 
  646. 	else 
  647. 		--No Spread 
  648. 		ring_small_scale = ring_small_min 
  649. 		ring_small_alpha = ring_alpha 
  650. 		ring_large_scale = ring_large_min 
  651. 		ring_large_alpha = 0 
  652. 		ring_mask_offset = 0  
  653. 	end 
  654. 	 
  655. 	--Ring Cropping		 
  656. 	vint_set_property(Hud_reticules.elements.ring_mask_nw_h, "anchor", -ring_mask_offset, -ring_mask_offset) 
  657. 	vint_set_property(Hud_reticules.elements.ring_mask_ne_h, "anchor", ring_mask_offset, -ring_mask_offset) 
  658. 	vint_set_property(Hud_reticules.elements.ring_mask_sw_h, "anchor", -ring_mask_offset, ring_mask_offset) 
  659. 	vint_set_property(Hud_reticules.elements.ring_mask_se_h, "anchor", ring_mask_offset, ring_mask_offset)		 
  660. 	 
  661. 	--Ring Scaling 
  662. 	vint_set_property(Hud_reticules.elements.ring_small_h, "scale", ring_small_scale, ring_small_scale) 
  663. 	vint_set_property(Hud_reticules.elements.ring_small_h, "alpha", ring_small_alpha) 
  664. 	vint_set_property(Hud_reticules.elements.ring_large_h, "scale", ring_large_scale, ring_large_scale) 
  665. 	vint_set_property(Hud_reticules.elements.ring_large_h, "alpha", ring_large_alpha) 
  666. 	 
  667. 	--Dim for fine aim 
  668. 	--No more dimming because the vignette has been altered 
  669. --	local fine_aim_alpha =  fine_aim * .2 + .3 
  670. --	vint_set_property(Hud_vignettes.fine_aim_dim.grp_h, "alpha", fine_aim_alpha) 
  671. 	 
  672. 	Hud_reticules.status.fine_aim = fine_aim 
  673. end 
  674.  
  675. --#####################################################################  
  676. --Sniper Directional Indicators 
  677. --##################################################################### 
  678. function hud_sniper_dir_update(di_h) 
  679. 	local rotation = vint_dataitem_get(di_h) 
  680. 	 
  681. 	--Find the arrow to update 
  682. 	for index, value in pairs(Hud_sniper_arrows) do 
  683. 		if index == di_h then 
  684. 			--Found now update the rotation 
  685. 			vint_set_property(value.arrow_h, "rotation", rotation) 
  686. 			break 
  687. 		end 
  688. 	end 
  689. end 
  690.  
  691. function hud_sniper_dir_add(di_h) 
  692. 	 
  693. 	--TODO: look through the table to make sure we don't have one already 
  694. 	--Clone bitmap 
  695. 	local arrow_clone_h = vint_object_clone(Hud_reticules.elements.sniper_dir_bmp_h) 
  696. 	 
  697. 	vint_set_property(arrow_clone_h, "visible", true) 
  698. 	 
  699. 	--Add handle to data object 
  700. 	Hud_sniper_arrows[di_h] = { 
  701. 		arrow_h = arrow_clone_h 
  702. 	} 
  703. 	 
  704. 	--update the sniper arrow 
  705. 	hud_sniper_dir_update(di_h) 
  706. end 
  707.  
  708. function hud_sniper_dir_remove(di_h) 
  709. 	--Find the arrow to remove 
  710. 	for index, value in pairs(Hud_sniper_arrows) do 
  711. 		if index == di_h then 
  712. 			vint_object_destroy(value.arrow_h) 
  713. 			Hud_sniper_arrows[index] = nil 
  714. 			break 
  715. 		end 
  716. 	end 
  717. end 
  718.  
  719. function hud_reticule_update_pressure(pressure_value) 
  720. 	if pressure_value == nil then 
  721. 		return 
  722. 	end 
  723. 	--invert value 
  724. 	pressure_value = 1 - pressure_value 
  725. 	--TODO: Update pressure 
  726. 	if pressure_value ~= Hud_reticules.pressure.cur_value then 
  727. 		--calculate angle and set property 
  728. 		local angle = Hud_reticules.pressure.start_angle * pressure_value 
  729. 		vint_set_property(Hud_reticules.elements.pressure_fill_h, "start_angle", angle) 
  730. 		Hud_reticules.pressure.cur_value = pressure_value 
  731. 	end 
  732. end 
  733.  
  734. function hud_reticule_change_position(x_screen_coord, y_screen_coord) 
  735. 	--Change the y screen anchor of the reticule 
  736. 	if Hud_reticules.status.y_screen_coord ~= y_screen_coord or Hud_reticules.status.x_screen_coord ~= x_screen_coord then 
  737. 		vint_set_property(Hud_reticules.elements.reticule_base_h, "anchor", x_screen_coord, y_screen_coord) 
  738. 		hud_cruise_control_update_pos(x_screen_coord, y_screen_coord) 
  739. 		hud_hits_updates_pos(x_screen_coord, y_screen_coord) 
  740. 		Hud_reticules.status.x_screen_coord = x_screen_coord  
  741. 		Hud_reticules.status.y_screen_coord = y_screen_coord  
  742. 	end 
  743. end 
  744.  
  745.  
  746.  
  747. --#####################################################################  
  748. --hud_reticule_spread_update() 
  749. -- 
  750. --Updates the opacity of the reticule 
  751. --##################################################################### 
  752. function hud_reticule_opacity_update(opacity)  
  753.  
  754. 	local persistant_opacity = (1 - opacity) * .67 
  755. 	 
  756. 	vint_set_property(Hud_reticules.elements.dot_persistant_h, "alpha", persistant_opacity) 
  757. 	vint_set_property(Hud_reticules.elements.reticule_h, "alpha", opacity) 
  758. end 
  759.  
  760. --#####################################################################  
  761. -- Overheat Meter 
  762. --##################################################################### 
  763. function hud_reticule_overheat_update(pct, is_overheated) 
  764. 	 
  765. 	local anim_h = vint_object_find("reticule_overheat_flash_anim",0,HUD_DOC_HANDLE) 
  766. 	local twn_h = vint_object_find("overheat_twn_h") 
  767.  
  768. 	if pct ~= Hud_reticules.overheat.pct then 
  769. 		if pct == 0 then 
  770. 			vint_set_property(Hud_reticules.elements.pressure_grp_h, "visible", false) 
  771. 		else 
  772. 			vint_set_property(Hud_reticules.elements.pressure_grp_h, "visible", true) 
  773. 			 
  774. 			--get a short handle to the weapon name 
  775. 			local wpn_name = Hud_reticules.status.wpn_name 
  776. 			 
  777. 			--check if we have a charge weapon 
  778. 			local charge = false 
  779. 			if wpn_name == "Special-SonicGun" or wpn_name == "Special-CyberCannon" then 
  780. 				charge = true 
  781. 			end 
  782. 			 
  783. 			local r,g,b 
  784. 			--set meter color based on charge or overheat 
  785. 			if charge then 
  786. 				--charge 
  787. 				r = (HUD_RETICULE_CHARGE_MAX.R - HUD_RETICULE_OVERHEAT_RED.R) * pct	+ HUD_RETICULE_OVERHEAT_RED.R 
  788. 				g = (HUD_RETICULE_CHARGE_MAX.G - HUD_RETICULE_OVERHEAT_RED.G) * pct	+ HUD_RETICULE_OVERHEAT_RED.G 
  789. 				b = (HUD_RETICULE_CHARGE_MAX.B - HUD_RETICULE_OVERHEAT_RED.B) * pct	+ HUD_RETICULE_OVERHEAT_RED.B 
  790. 			else 
  791. 				--overheat 
  792. 				r = (HUD_RETICULE_OVERHEAT_RED.R - HUD_RETICULE_OVERHEAT_LIGHT.R) * pct	+ HUD_RETICULE_OVERHEAT_LIGHT.R 
  793. 				g = (HUD_RETICULE_OVERHEAT_RED.G - HUD_RETICULE_OVERHEAT_LIGHT.G) * pct	+ HUD_RETICULE_OVERHEAT_LIGHT.G 
  794. 				b = (HUD_RETICULE_OVERHEAT_RED.B - HUD_RETICULE_OVERHEAT_LIGHT.B) * pct	+ HUD_RETICULE_OVERHEAT_LIGHT.B 
  795. 			end 
  796. 			 
  797. 			--if meter is full then flash tint 
  798. 			if pct >= 1.0 then 
  799. 				if charge then 
  800. 					--change to charge colors 
  801. 					vint_set_property(twn_h,"start_value",HUD_RETICULE_CHARGE_MAX.R,HUD_RETICULE_CHARGE_MAX.G,HUD_RETICULE_CHARGE_MAX.B) 
  802. 					vint_set_property(twn_h,"end_value",HUD_RETICULE_CHARGE_MIN.R,HUD_RETICULE_CHARGE_MIN.G,HUD_RETICULE_CHARGE_MIN.B) 
  803. 				else 
  804. 					--change to overheat colors 
  805. 					vint_set_property(twn_h,"start_value",HUD_RETICULE_OVERHEAT_RED.R,HUD_RETICULE_OVERHEAT_RED.G,HUD_RETICULE_OVERHEAT_RED.B) 
  806. 					vint_set_property(twn_h,"end_value",HUD_RETICULE_OVERHEAT_LIGHT.R,HUD_RETICULE_OVERHEAT_LIGHT.G,HUD_RETICULE_OVERHEAT_LIGHT.B) 
  807. 				end 
  808. 				--colors are set, play the animation 
  809. 				lua_play_anim(anim_h,0,HUD_DOC_HANDLE) 
  810. 			elseif is_overheated == false then 
  811. 				--stop the animation and handle colors dynamically 
  812. 				vint_set_property(anim_h, "is_paused", true) 
  813. 				vint_set_property(Hud_reticules.elements.pressure_fill_h, "tint", r, g, b) 
  814. 			end 
  815.  
  816. 			local overheat_value = 1 - pct 
  817. 			if overheat_value ~= Hud_reticules.overheat.pct then 
  818. 				--calculate angle and set property 
  819. 				local angle = Hud_reticules.pressure.start_angle * overheat_value 
  820. 				vint_set_property(Hud_reticules.elements.pressure_fill_h, "start_angle", angle) 
  821. 			end 
  822. 		end 
  823. 		 
  824. 		Hud_reticules.overheat.is_overheated = is_overheated 
  825. 		Hud_reticules.overheat.pct = pct	 
  826. 	end 
  827. 	 
  828. 	 
  829. end 
  830.  
  831. --[[ 
  832. NOT USED ANYMORE BUT IT COULD COME BACK LATER 
  833. function hud_reticule_process_hit() 
  834. 	--we got a hit so add to the index 
  835. 	Hud_current_hit_index = Hud_current_hit_index + 1 
  836. 	 
  837. 	--we don't want too many going, cap it at RET_HIT_MAX 
  838. 	if Hud_current_hit_index > RET_HIT_MAX then 
  839. 		Hud_current_hit_index = 1 
  840. 	end 
  841. 	 
  842. 	--clear out the table 
  843. 	if Hud_hit_data[Hud_current_hit_index] ~= nil then 
  844. 		vint_object_destroy(Hud_hit_data[Hud_current_hit_index].image_h) 
  845. 		vint_object_destroy(Hud_hit_data[Hud_current_hit_index].anim_h) 
  846. 		Hud_hit_data[Hud_current_hit_index] = {}  
  847. 	end 
  848. 	 
  849. 	--create the clones and store them 
  850. 	local image_h = vint_object_find("hit_ring") 
  851. 	local anim_h = vint_object_find("reticule_hit_anim") 
  852. 	local image_clone_h = vint_object_clone(image_h) 
  853. 	local anim_clone_h = vint_object_clone(anim_h) 
  854. 	 
  855. 	--Hud_hit_data[Hud_current_hit_index].image_h = image_clone_h 
  856. 	--Hud_hit_data[Hud_current_hit_index].anim_h = anim_clone_h 
  857. 	 
  858. 	--turn on the clone 
  859. 	vint_set_property(image_clone_h, "visible", true) 
  860. 	 
  861. 	--retarget the new animation to the new image 
  862. 	vint_set_property(anim_clone_h, "target_handle", image_clone_h) 
  863. 	 
  864. 	--play the animation 
  865. 	lua_play_anim(anim_clone_h,0) 
  866. end--]] 
  867.