HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <fun>
  5. #include <engine>
  6. #include <fakemeta>
  7.  
  8. #define APACHE_ADMIN ADMIN_LEVEL_A
  9.  
  10. #define TASK_ROCKET 6740100
  11. #define TASK_BOMB 6760200
  12.  
  13. new apaches[33], camera[33], apache_speed[33], grabbed[33]
  14. new smoke, boom, laserbeam
  15. new maxplayers, maxentities
  16. new bool:wait_rocket[33], bool:wait_bomb[33], bool:wait_stealth[33], stealth[33]
  17. new gmsgNVGToggle
  18. new g_apacheactive = 0
  19.  
  20. new active,health,maxspeed2,stealthamt,stealthspeed,stealthregen,bulletdmg,bulletspeed;
  21. new rocketspeed,distance,height,beams,cost,admins,ff;
  22.  
  23. public plugin_init()
  24. {
  25. register_plugin("AMX Apache", "0.2.0", "KRoTaL, Fox-NL")
  26.  
  27. register_concmd("amx_apache", "create_apache", 0, "creates a helicopter you can control")
  28. register_concmd("amx_destroyapache", "destroy_apache", 0, "destroys the helicopter you are controlling")
  29.  
  30. register_clcmd("drop", "stop_apache")
  31. register_clcmd("nightvision", "stealth_mode")
  32.  
  33. active = register_cvar("apache_active", "1")
  34. health = register_cvar("apache_health", "1000")
  35. maxspeed2 = register_cvar("apache_maxspeed", "400")
  36. stealthamt = register_cvar("apache_stealth_amount", "40")
  37. stealthspeed = register_cvar("apache_stealth_maxspeed", "60")
  38. stealthregen = register_cvar("apache_stealth_regen", "10")
  39. bulletdmg = register_cvar("apache_bulletdmg", "10")
  40. bulletspeed = register_cvar("apache_bulletspeed", "2000")
  41. rocketspeed = register_cvar("apache_rocketspeed", "1000")
  42. distance = register_cvar("apache_dist", "70")
  43. height = register_cvar("apache_height", "20")
  44. beams = register_cvar("apache_beams", "0")
  45. cost = register_cvar("apache_cost", "5000")
  46. admins = register_cvar("apache_admins", "0")
  47. ff = register_cvar("apache_ff", "0")
  48.  
  49. register_event("DeathMsg", "death_event", "a")
  50. register_event("ResetHUD", "resethud_event", "be")
  51. register_event("CurWeapon", "check_weapon", "be", "1=1")
  52. register_logevent("new_round", 2, "0=World triggered", "1=Round_Start")
  53. register_event("TextMsg", "game_restart", "a", "1=4", "2&#Game_C", "2&#Game_w")
  54. register_event("SendAudio", "round_end", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw")
  55. register_forward(FM_EmitSound,"emitsound",0)
  56.  
  57. maxplayers = get_maxplayers() + 1
  58. maxentities = get_global_int(GL_maxEntities)
  59.  
  60. gmsgNVGToggle = get_user_msgid("NVGToggle")
  61. }
  62.  
  63. public client_connect(id)
  64. {
  65. if(task_exists(54545454+id))
  66. {
  67. remove_task(54545454+id)
  68. }
  69. apaches[id] = 0
  70. camera[id] = 0
  71. grabbed[id] = 0
  72. wait_rocket[id] = false
  73. wait_bomb[id] = false
  74. wait_stealth[id] = false
  75. stealth[id] = false
  76. }
  77.  
  78. public client_disconnect(id)
  79. {
  80. if(task_exists(54545454+id))
  81. {
  82. remove_task(54545454+id)
  83. }
  84. if(apaches[id] > 0)
  85. {
  86. emit_sound(apaches[id], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  87. remove_entity(apaches[id])
  88. apaches[id] = 0
  89. }
  90. if(camera[id] > 0)
  91. {
  92. remove_entity(camera[id])
  93. camera[id] = 0
  94. }
  95. grabbed[id] = 0
  96. wait_rocket[id] = false
  97. wait_bomb[id] = false
  98. wait_stealth[id] = false
  99. stealth[id] = false
  100. }
  101.  
  102. public new_round()
  103. {
  104. new ent
  105. while((ent = find_ent_by_class(ent,"apache_bullet")) != 0)
  106. remove_entity(ent)
  107.  
  108. ent = find_ent_by_class(-1, "apache_rocket")
  109. new tempent
  110. while(ent > 0)
  111. {
  112. tempent = find_ent_by_class(ent, "apache_rocket")
  113. emit_sound(ent, CHAN_WEAPON, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  114. //emit_sound(ent, CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  115. remove_entity(ent)
  116. ent = tempent
  117. }
  118. set_task(0.1, "set_speed", 875457545)
  119. }
  120.  
  121. public round_end()
  122. {
  123. set_task(4.0, "disable_sound", 212454212)
  124. }
  125.  
  126. public game_restart()
  127. {
  128. set_task(0.5, "disable_sound", 787454241)
  129. }
  130.  
  131. public disable_sound()
  132. {
  133. new players[32], inum, player
  134. get_players(players, inum, "a")
  135. for(new i = 0 ; i < inum ; i++)
  136. {
  137. player = players[i]
  138. if(apaches[player] > 0)
  139. {
  140. emit_sound(apaches[player], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  141. }
  142. }
  143. }
  144.  
  145. public death_event()
  146. {
  147. g_apacheactive = get_pcvar_num(active)
  148. new id = read_data(2)
  149.  
  150. if(task_exists(54545454+id))
  151. {
  152. remove_task(54545454+id)
  153. }
  154. if(apaches[id] > 0)
  155. {
  156. emit_sound(apaches[id], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  157. remove_entity(apaches[id])
  158. apaches[id] = 0
  159. }
  160. if(camera[id] > 0)
  161. {
  162. attach_view(id, id)
  163. remove_entity(camera[id])
  164. camera[id] = 0
  165. }
  166. for(new i = 1 ; i < maxplayers ; i++)
  167. {
  168. if(grabbed[i] == id)
  169. {
  170. grabbed[i] = 0
  171. }
  172. }
  173. grabbed[id] = 0
  174. wait_rocket[id] = false
  175. wait_bomb[id] = false
  176. wait_stealth[id] = false
  177. stealth[id] = false
  178. client_cmd(id, "-left")
  179. client_cmd(id, "-right")
  180. message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
  181. write_byte(0)
  182. message_end()
  183. }
  184.  
  185. public resethud_event(id)
  186. {
  187. g_apacheactive = get_pcvar_num(active)
  188. if(task_exists(54545454+id))
  189. {
  190. remove_task(54545454+id)
  191. }
  192. if(apaches[id] > 0)
  193. {
  194. new Float:apachecost = get_pcvar_float(cost)
  195. new Float:apachehealth = get_pcvar_float(health)
  196. new Float:apachecurhealth = entity_get_float(apaches[id], EV_FL_health) - 5000
  197. new payback = floatround((apachecost * apachecurhealth) / apachehealth)
  198. cs_set_user_money(id, cs_get_user_money(id) + payback, 1)
  199. emit_sound(apaches[id], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  200. remove_entity(apaches[id])
  201. apaches[id] = 0
  202. }
  203. if(camera[id] > 0)
  204. {
  205. attach_view(id, id)
  206. remove_entity(camera[id])
  207. camera[id] = 0
  208. }
  209. grabbed[id] = 0
  210. wait_rocket[id] = false
  211. wait_bomb[id] = false
  212. wait_stealth[id] = false
  213. stealth[id] = false
  214. client_cmd(id, "-left")
  215. client_cmd(id, "-right")
  216. message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
  217. write_byte(0)
  218. message_end()
  219. }
  220.  
  221. public check_weapon(id)
  222. {
  223. if(apaches[id] > 0)
  224. {
  225. client_cmd(id, "weapon_knife")
  226. set_user_maxspeed(id, -1.0)
  227. }
  228. }
  229.  
  230. public set_speed(id)
  231. {
  232. new players[32], inum, player
  233. get_players(players, inum, "a")
  234. for(new i = 0 ; i < inum ; i++)
  235. {
  236. player = players[i]
  237. if(apaches[player] > 0)
  238. {
  239. set_user_maxspeed(player, -1.0)
  240. }
  241. }
  242. }
  243.  
  244. public create_apache(id,level,cid)
  245. {
  246. if(get_pcvar_num(active) == 0)
  247. {
  248. console_print(id, "AMX Apache bekapcsolva.")
  249. return PLUGIN_HANDLED
  250. }
  251.  
  252. if(get_pcvar_num(admins) == 1)
  253. {
  254. if(!(get_user_flags(id) & APACHE_ADMIN))
  255. {
  256. console_print(id, "Nincs hozzaferesed ehez a parancshoz!.")
  257. return PLUGIN_HANDLED
  258. }
  259. }
  260.  
  261. if(apaches[id] > 0)
  262. {
  263. console_print(id, "Mar iranyitod a helikoptert.")
  264. client_print(id, print_center, "Mar iranyitod a helikoptert.")
  265. return PLUGIN_HANDLED
  266. }
  267.  
  268. if(!is_user_alive(id))
  269. {
  270. console_print(id, "Nem tudod iranyitani a helikoptert mert halott vagy!")
  271. client_print(id, print_center, "Nem tudod iranyitani a helikoptert mert halott vagy!")
  272. return PLUGIN_HANDLED
  273. }
  274.  
  275. if(!(get_user_flags(id) & APACHE_ADMIN))
  276. {
  277. new apachecost = get_pcvar_num(cost)
  278. new usermoney = cs_get_user_money(id)
  279. if(usermoney < apachecost)
  280. {
  281. console_print(id, "Nincs eleg penzed ($%i szukseges)", apachecost)
  282. client_print(id, print_center, "Nincs eleg penzed ($%i szukseges)", apachecost)
  283. return PLUGIN_HANDLED
  284. }
  285. cs_set_user_money(id, usermoney - apachecost, 1)
  286. }
  287.  
  288. new Float:origin[3]
  289. new Float:angles[3]
  290. entity_get_vector(id, EV_VEC_origin, origin)
  291. entity_get_vector(id, EV_VEC_v_angle, angles)
  292.  
  293. apaches[id] = create_entity("info_target")
  294. if(apaches[id] > 0)
  295. {
  296. entity_set_string(apaches[id], EV_SZ_classname, "amx_apache")
  297. entity_set_model(apaches[id], "models/rc_apache_final.mdl")
  298.  
  299. entity_set_size(apaches[id], Float:{-12.0,-12.0,-6.0}, Float:{12.0,12.0,6.0})
  300.  
  301. entity_set_origin(apaches[id], origin)
  302. entity_set_vector(apaches[id], EV_VEC_angles, angles)
  303.  
  304. entity_set_int(apaches[id], EV_INT_solid, 2)
  305. entity_set_int(apaches[id], EV_INT_movetype, 5)
  306. entity_set_edict(apaches[id], EV_ENT_owner, id)
  307. entity_set_int(apaches[id], EV_INT_sequence, 1)
  308. entity_set_float(apaches[id], EV_FL_takedamage, DAMAGE_AIM)
  309. entity_set_float(apaches[id], EV_FL_health, get_pcvar_float(health) + 5000.0)
  310.  
  311. apache_speed[id] = 50
  312.  
  313. new Float:velocity[3]
  314. VelocityByAim(id, apache_speed[id], velocity)
  315. entity_set_vector(apaches[id], EV_VEC_velocity, velocity)
  316.  
  317. emit_sound(apaches[id], CHAN_VOICE, "apache/ap_rotor2.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  318. }
  319.  
  320. camera[id] = create_entity("info_target")
  321. if(camera[id] > 0)
  322. {
  323. entity_set_string(camera[id], EV_SZ_classname, "camera")
  324. entity_set_int(camera[id], EV_INT_solid, SOLID_NOT)
  325. entity_set_int(camera[id], EV_INT_movetype, MOVETYPE_NOCLIP)
  326. entity_set_size(camera[id], Float:{0,0,0}, Float:{0,0,0})
  327. entity_set_model(camera[id], "models/rpgrocket.mdl")
  328. set_rendering(camera[id], kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
  329.  
  330. entity_set_origin(camera[id], origin)
  331. entity_set_vector(camera[id], EV_VEC_angles, angles)
  332.  
  333. attach_view(id, camera[id])
  334. }
  335.  
  336. engclient_cmd(id, "weapon_knife")
  337. set_user_maxspeed(id, -1.0)
  338.  
  339. if(task_exists(54545454+id))
  340. {
  341. remove_task(54545454+id)
  342. }
  343.  
  344. grabbed[id] = 0
  345. wait_rocket[id] = false
  346. wait_bomb[id] = false
  347. wait_stealth[id] = false
  348. stealth[id] = false
  349.  
  350. return PLUGIN_HANDLED
  351. }
  352.  
  353. public destroy_apache(id,level,cid)
  354. {
  355. if (!cmd_access(id,level,cid,1))
  356. {
  357. return PLUGIN_HANDLED
  358. }
  359.  
  360. if(apaches[id] > 0)
  361. {
  362. attach_view(id, id)
  363. emit_sound(apaches[id], CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  364. remove_entity(apaches[id])
  365. apaches[id] = 0
  366. set_user_maxspeed(id, 250.0)
  367. }
  368. if(camera[id] > 0)
  369. {
  370. attach_view(id, id)
  371. remove_entity(camera[id])
  372. camera[id] = 0
  373. }
  374.  
  375. if(task_exists(54545454+id))
  376. {
  377. remove_task(54545454+id)
  378. }
  379.  
  380. grabbed[id] = 0
  381. wait_rocket[id] = false
  382. wait_bomb[id] = false
  383. wait_stealth[id] = false
  384. stealth[id] = false
  385. client_cmd(id, "-left")
  386. client_cmd(id, "-right")
  387.  
  388. message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
  389. write_byte(0)
  390. message_end()
  391.  
  392. return PLUGIN_HANDLED
  393. }
  394.  
  395. public stop_apache(id)
  396. {
  397. if(apaches[id] > 0)
  398. {
  399. if(apache_speed[id] <= 30 && apache_speed[id] >= -30)
  400. {
  401. apache_speed[id] = 0
  402. }
  403. return PLUGIN_HANDLED
  404. }
  405.  
  406. return PLUGIN_CONTINUE
  407. }
  408.  
  409. public stealth_mode(id)
  410. {
  411. if(apaches[id] > 0)
  412. {
  413. if(!wait_stealth[id])
  414. {
  415. if(!stealth[id])
  416. {
  417. stealth[id] = true
  418. emit_sound(apaches[id], CHAN_VOICE, "apache/ap_rotor2.wav", 0.1, ATTN_NORM, 0, PITCH_NORM)
  419. set_rendering(apaches[id], kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, get_pcvar_num(stealthamt))
  420. message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
  421. write_byte(1)
  422. message_end()
  423. }
  424. else
  425. {
  426. stealth[id] = false
  427. emit_sound(apaches[id], CHAN_VOICE, "apache/ap_rotor2.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  428. set_rendering(apaches[id])
  429. message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
  430. write_byte(0)
  431. message_end()
  432. wait_stealth[id] = true
  433. new ids[1]
  434. ids[0] = id
  435. set_task(get_pcvar_float(stealthregen), "reset_stealth", 54545454+id, ids, 1)
  436. }
  437. }
  438. return PLUGIN_HANDLED
  439. }
  440.  
  441. return PLUGIN_CONTINUE
  442. }
  443.  
  444. public client_PreThink(id)
  445. {
  446. if(g_apacheactive == 0)
  447. {
  448. return PLUGIN_CONTINUE
  449. }
  450.  
  451. if(is_user_alive(id) && apaches[id] > 0 && camera[id] > 0)
  452. {
  453. new Float:forigin[3], Float:dist_origin[3], Float:camera_origin[3]
  454. new button, oldbutton
  455. new apacheId = apaches[id]
  456. new maxspeed
  457. new Float:frame
  458. new apache_maxspeed = get_pcvar_num(maxspeed2)
  459. new apache_stealth_maxspeed = get_pcvar_num(stealthspeed)
  460. new Float:angles[3], Float:velocity[3]
  461. new Float:apache_height = get_pcvar_float(height)
  462. new apache_bulletspeed = get_pcvar_num(bulletspeed)
  463. new apache_rocketspeed = get_pcvar_num(rocketspeed)
  464. new classname[32]
  465. new Float:aim_origin[3], Float:end_origin[3]
  466. new apache_beams = get_pcvar_num(beams)
  467. if(entity_get_float(apacheId, EV_FL_health) < 5000)
  468. {
  469. new Float:explosion[3]
  470. entity_get_vector(apacheId, EV_VEC_origin, explosion)
  471. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  472. write_byte(3)
  473. write_coord(floatround(explosion[0]))
  474. write_coord(floatround(explosion[1]))
  475. write_coord(floatround(explosion[2]))
  476. write_short(boom)
  477. write_byte(50)
  478. write_byte(15)
  479. write_byte(0)
  480. message_end()
  481.  
  482. HL_RadiusDamage(explosion,0,50.0,300.0)
  483. /*radius_damage(explosion,50,300)*/
  484.  
  485. attach_view(id, id)
  486. if(camera[id] > 0)
  487. {
  488. remove_entity(camera[id])
  489. camera[id] = 0
  490. }
  491. emit_sound(apacheId, CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  492. remove_entity(apacheId)
  493. apaches[id] = 0
  494. set_user_maxspeed(id, 250.0)
  495. if(task_exists(54545454+id))
  496. {
  497. remove_task(54545454+id)
  498. }
  499. wait_rocket[id] = false
  500. wait_stealth[id] = false
  501. stealth[id] = false
  502. client_cmd(id, "-left")
  503. client_cmd(id, "-right")
  504. message_begin(MSG_ONE, gmsgNVGToggle, {0,0,0}, id)
  505. write_byte(0)
  506. message_end()
  507. return PLUGIN_CONTINUE
  508. }
  509.  
  510. frame = entity_get_float(apacheId, EV_FL_frame)
  511. if(frame < 0.0 || frame > 254.0)
  512. {
  513. entity_set_float(apacheId, EV_FL_frame, 0.0)
  514. }
  515. else
  516. {
  517. entity_set_float(apacheId, EV_FL_frame, frame + 1.0)
  518. }
  519.  
  520. entity_get_vector(apacheId, EV_VEC_origin, forigin)
  521. button = get_user_button(id)
  522. if(button & IN_FORWARD)
  523. {
  524. apache_speed[id] += 5
  525. }
  526. if(button & IN_BACK)
  527. {
  528. apache_speed[id] -= 5
  529. }
  530. if(!stealth[id])
  531. {
  532. maxspeed = apache_maxspeed
  533. }
  534. else
  535. {
  536. maxspeed = apache_stealth_maxspeed
  537. }
  538. if(apache_speed[id] > maxspeed)
  539. {
  540. apache_speed[id] = maxspeed
  541. }
  542. if(apache_speed[id] < - 80)
  543. {
  544. apache_speed[id] = - 80
  545. }
  546.  
  547. entity_get_vector(apacheId, EV_VEC_origin, forigin)
  548. entity_get_vector(id, EV_VEC_v_angle, angles)
  549. angles[0] = - angles[0]
  550. VelocityByAim(id, apache_speed[id], velocity)
  551. entity_set_vector(apacheId, EV_VEC_angles, angles)
  552. entity_set_vector(apacheId, EV_VEC_velocity, velocity)
  553.  
  554. oldbutton = get_user_oldbutton(id)
  555. if(button & IN_JUMP)
  556. {
  557. forigin[2] += 2.0
  558. if(PointContents(forigin) != CONTENTS_SOLID)
  559. {
  560. entity_set_origin(apacheId, forigin)
  561. }
  562. }
  563. if(button & IN_DUCK)
  564. {
  565. forigin[2] -= 2.0
  566. if(PointContents(forigin) != CONTENTS_SOLID)
  567. {
  568. entity_set_origin(apacheId, forigin)
  569. }
  570. }
  571.  
  572. if(PointContents(forigin) == CONTENTS_SOLID)
  573. {
  574. forigin[2] += 10.0
  575. if(PointContents(forigin) == CONTENTS_SOLID)
  576. {
  577. forigin[2] -= 60.0
  578. }
  579. entity_set_origin(apacheId, forigin)
  580. }
  581.  
  582. VelocityByAim(id, get_pcvar_num(distance), dist_origin)
  583. camera_origin[0] = forigin[0] - dist_origin[0]
  584. camera_origin[1] = forigin[1] - dist_origin[1]
  585. camera_origin[2] = forigin[2] + apache_height
  586. entity_set_origin(camera[id], camera_origin)
  587. angles[0] = - angles[0]
  588. entity_set_vector(camera[id], EV_VEC_angles, angles)
  589.  
  590. if(button & IN_ATTACK && !(oldbutton & IN_ATTACK) && get_num_ents() < (maxentities - 50))
  591. {
  592. emit_sound(apacheId, CHAN_WEAPON, "weapons/m249-1.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  593.  
  594. new ent = create_entity("info_target")
  595. if(ent > 0)
  596. {
  597. entity_set_string(ent, EV_SZ_classname, "apache_bullet")
  598. entity_set_model(ent, "models/shell.mdl")
  599.  
  600. entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0})
  601.  
  602. entity_set_origin(ent, forigin)
  603. entity_set_vector(ent, EV_VEC_angles, angles)
  604.  
  605. entity_set_int(ent, EV_INT_solid, 1)
  606. entity_set_int(ent, EV_INT_movetype, 5)
  607. entity_set_edict(ent, EV_ENT_owner, id)
  608.  
  609. VelocityByAim(id, apache_bulletspeed, velocity)
  610. entity_set_vector(ent, EV_VEC_velocity, velocity)
  611.  
  612. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  613. write_byte(22)
  614. write_short(ent)
  615. write_short(smoke)
  616. write_byte(25)
  617. write_byte(1)
  618. write_byte(255)
  619. write_byte(255)
  620. write_byte(255)
  621. write_byte(128)
  622. message_end()
  623. }
  624. }
  625. if(button & IN_ATTACK2 && !wait_rocket[id] && get_num_ents() < (maxentities - 50))
  626. {
  627. new ent = create_entity("info_target")
  628. if(ent > 0)
  629. {
  630. entity_set_string(ent, EV_SZ_classname, "apache_rocket")
  631. entity_set_model(ent, "models/rpgrocket.mdl")
  632.  
  633. entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0})
  634.  
  635. entity_set_origin(ent, forigin)
  636. entity_set_vector(ent, EV_VEC_angles, angles)
  637.  
  638. entity_set_int(ent, EV_INT_effects, 64)
  639. entity_set_int(ent, EV_INT_solid, 1)
  640. entity_set_int(ent, EV_INT_movetype, 5)
  641. entity_set_edict(ent, EV_ENT_owner, id)
  642.  
  643. VelocityByAim(id, apache_rocketspeed, velocity)
  644. entity_set_vector(ent, EV_VEC_velocity, velocity)
  645.  
  646. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  647. write_byte(22)
  648. write_short(ent)
  649. write_short(smoke)
  650. write_byte(40)
  651. write_byte(4)
  652. write_byte(255)
  653. write_byte(0)
  654. write_byte(0)
  655. write_byte(128)
  656. message_end()
  657.  
  658. emit_sound(ent, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  659. //emit_sound(ent, CHAN_VOICE, "weapons/rocket1.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  660. }
  661. wait_rocket[id] = true
  662. set_task(2.0, "reset_rocket", id+TASK_ROCKET)
  663. }
  664. if(button & IN_RELOAD && !wait_bomb[id] && grabbed[id] == 0 && get_num_ents() < (maxentities - 50))
  665. {
  666. new ent = create_entity("info_target")
  667. if(ent > 0)
  668. {
  669. entity_set_string(ent, EV_SZ_classname, "apache_bomb")
  670. entity_set_model(ent, "models/rpgrocket.mdl")
  671.  
  672. entity_set_size(ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0})
  673.  
  674. entity_set_origin(ent, forigin)
  675. entity_set_vector(ent, EV_VEC_angles, angles)
  676.  
  677. entity_set_int(ent, EV_INT_solid, 1)
  678. entity_set_int(ent, EV_INT_movetype, 6)
  679. entity_set_edict(ent, EV_ENT_owner, id)
  680. }
  681. wait_bomb[id] = true
  682. set_task(4.0, "reset_bomb", id+TASK_BOMB)
  683. }
  684. if(button & IN_USE && !(oldbutton & IN_USE))
  685. {
  686. if(grabbed[id] == 0)
  687. {
  688. new Float:ent_origin[3]
  689. new ent = find_ent_in_sphere(-1, forigin, 60.0)
  690. while(ent > 0 && grabbed[id] == 0)
  691. {
  692. classname[0] = '^0'
  693. entity_get_string(ent, EV_SZ_classname, classname, 31)
  694. if(equal(classname, "player") || equal(classname, "grenade") || equal(classname, "weaponbox") || equal(classname, "armoury_entity") || equal(classname, "hostage_entity"))
  695. {
  696. entity_get_vector(ent, EV_VEC_origin, ent_origin)
  697. if(ent_origin[2] < forigin[2])
  698. {
  699. grabbed[id] = ent
  700. if(equal(classname, "hostage_entity"))
  701. {
  702. entity_set_int(apacheId, EV_INT_solid, 3)
  703. }
  704. }
  705. }
  706. ent = find_ent_in_sphere(ent, forigin, 60.0)
  707. }
  708. }
  709. else
  710. {
  711. classname[0] = '^0'
  712. if(is_valid_ent(grabbed[id])) {
  713. entity_get_string(grabbed[id], EV_SZ_classname, classname, 31)
  714. if(!equal(classname, "player"))
  715. {
  716. entity_set_vector(grabbed[id], EV_VEC_velocity, Float:{0,0,-20})
  717. }
  718. }
  719. grabbed[id] = 0
  720. entity_set_int(apacheId, EV_INT_solid, 2)
  721. }
  722. }
  723. if(button & IN_MOVELEFT)
  724. {
  725. client_cmd(id, "+left")
  726. }
  727. else if(oldbutton & IN_MOVELEFT)
  728. {
  729. client_cmd(id, "-left")
  730. }
  731. if(button & IN_MOVERIGHT)
  732. {
  733. client_cmd(id, "+right")
  734. }
  735. else if(oldbutton & IN_MOVERIGHT)
  736. {
  737. client_cmd(id, "-right")
  738. }
  739. if(apache_beams == 1)
  740. {
  741. VelocityByAim(id, 9999, velocity)
  742. end_origin[0] = forigin[0] + velocity[0]
  743. end_origin[1] = forigin[1] + velocity[1]
  744. end_origin[2] = forigin[2] + velocity[2]
  745. trace_line(0, forigin, end_origin, aim_origin)
  746. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0,0,0}, id)
  747. write_byte(1)
  748. write_short(apacheId)
  749. write_coord(floatround(aim_origin[0]))
  750. write_coord(floatround(aim_origin[1]))
  751. write_coord(floatround(aim_origin[2]))
  752. write_short(laserbeam)
  753. write_byte(1)
  754. write_byte(1)
  755. write_byte(1)
  756. write_byte(8)
  757. write_byte(0)
  758. write_byte(255)
  759. write_byte(0)
  760. write_byte(0)
  761. write_byte(128)
  762. write_byte(0)
  763. message_end()
  764. }
  765. if(grabbed[id] > 0 && is_valid_ent(grabbed[id]))
  766. {
  767. new Float:direction[3], Float:moveto[3], Float:grabbedorigin[3], Float:length
  768. VelocityByAim(id, 9999, velocity)
  769. end_origin[0] = forigin[0] + velocity[0]
  770. end_origin[1] = forigin[1] + velocity[1]
  771. end_origin[2] = forigin[2] + velocity[2]
  772. trace_line(0, forigin, end_origin, aim_origin)
  773.  
  774. entity_get_vector(grabbed[id], EV_VEC_origin, grabbedorigin)
  775.  
  776. direction[0] = aim_origin[0] - forigin[0]
  777. direction[1] = aim_origin[1] - forigin[1]
  778. direction[2] = aim_origin[2] - forigin[2]
  779.  
  780. length = vector_distance(aim_origin,forigin)
  781. if (!length) length = 1.0
  782.  
  783. moveto[0] = forigin[0] + direction[0] / length
  784. moveto[1] = forigin[1] + direction[1] / length
  785. classname[0] = '^0'
  786. entity_get_string(grabbed[id], EV_SZ_classname, classname, 31)
  787. if(equal(classname, "player"))
  788. {
  789. moveto[2] = (forigin[2] + direction[2] / length) - 45.0
  790. velocity[0] = (moveto[0] - grabbedorigin[0]) * 5
  791. velocity[1] = (moveto[1] - grabbedorigin[1]) * 5
  792. velocity[2] = (moveto[2] - grabbedorigin[2]) * 5
  793. }
  794. else
  795. {
  796. moveto[2] = (forigin[2] + direction[2] / length) - 15.0
  797. velocity[0] = (moveto[0] - grabbedorigin[0]) * 10
  798. velocity[1] = (moveto[1] - grabbedorigin[1]) * 10
  799. velocity[2] = (moveto[2] - grabbedorigin[2]) * 10
  800. }
  801.  
  802. entity_set_vector(grabbed[id], EV_VEC_velocity, velocity)
  803. }
  804. set_hudmessage(255, 255, 255, -2.0, 0.76, 0, 1.0, 0.01, 0.1, 0.2, 4)
  805. show_hudmessage(id, " [APACHE] Sebesseg: %i, Elet: %i", apache_speed[id], floatround(entity_get_float(apaches[id], EV_FL_health) - 5000))
  806. }
  807.  
  808. return PLUGIN_CONTINUE
  809. }
  810.  
  811. public reset_rocket(id)
  812. {
  813. wait_rocket[id-TASK_ROCKET] = false
  814. }
  815.  
  816. public reset_bomb(id)
  817. {
  818. wait_bomb[id-TASK_BOMB] = false
  819. }
  820.  
  821. public reset_stealth(ids[])
  822. {
  823. wait_stealth[ids[0]] = false
  824. }
  825.  
  826. public pfn_touch(entity1, entity2)
  827. {
  828. if(g_apacheactive == 0)
  829. {
  830. return PLUGIN_CONTINUE
  831. }
  832.  
  833. if(entity1 > 0 && is_valid_ent(entity1))
  834. {
  835. new classname[32]
  836. entity_get_string(entity1, EV_SZ_classname, classname, 31)
  837. new classname2[32]
  838. if(entity2 > 0 && is_valid_ent(entity2))
  839. {
  840. entity_get_string(entity2, EV_SZ_classname, classname2, 31)
  841. }
  842.  
  843. new attacker = entity_get_edict(entity1, EV_ENT_owner)
  844. if((equal(classname, "apache_rocket") || equal(classname, "apache_bomb")) && (entity2 == 0 || equal(classname2, "player") || equal(classname2, "amx_apache") || equal(classname2, "apache_rocket") || equal(classname2, "func_breakable") || equal(classname2, "func_pushable")))
  845. {
  846. if(entity2 > 0)
  847. {
  848. if(attacker == entity_get_edict(entity2, EV_ENT_owner))
  849. {
  850. return PLUGIN_CONTINUE
  851. }
  852. }
  853.  
  854. new Float:explosion[3]
  855. entity_get_vector(entity1, EV_VEC_origin, explosion)
  856.  
  857. if(!stealth[attacker])
  858. {
  859. /*radius_damage(explosion,200,300)*/
  860. HL_RadiusDamage(explosion,0,200.0,300.0)
  861. }
  862. else
  863. {
  864. /*radius_damage(explosion,120,300)*/
  865. HL_RadiusDamage(explosion,0,120.0,300.0)
  866. }
  867.  
  868. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  869. write_byte(3)
  870. write_coord(floatround(explosion[0]))
  871. write_coord(floatround(explosion[1]))
  872. write_coord(floatround(explosion[2]))
  873. write_short(boom)
  874. write_byte(50)
  875. write_byte(15)
  876. write_byte(0)
  877. message_end()
  878.  
  879. emit_sound(entity1, CHAN_WEAPON, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  880. //emit_sound(entity1, CHAN_VOICE, "vox/_period.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
  881.  
  882. remove_entity(entity1)
  883. }
  884. if(equal(classname, "apache_bullet"))
  885. {
  886. if(equal(classname2, "player") || equal(classname2, "amx_apache") || equal(classname2, "func_breakable") || equal(classname2, "func_pushable"))
  887. {
  888. if(entity2 > 0)
  889. {
  890. if(attacker == entity_get_edict(entity2, EV_ENT_owner))
  891. {
  892. return PLUGIN_CONTINUE
  893. }
  894. if(equal(classname2, "func_breakable") || equal(classname2, "func_pushable"))
  895. {
  896. force_use(entity2, attacker)
  897. }
  898. else
  899. {
  900. new Float:origin[3]
  901. entity_get_vector(entity2, EV_VEC_origin, origin)
  902. fakedamage(entity2, "apache_gun", get_pcvar_float(bulletdmg), DMG_BULLET)
  903. }
  904. }
  905. }
  906.  
  907. remove_entity(entity1)
  908. }
  909. if(equal(classname, "amx_apache"))
  910. {
  911. if(equal(classname2, "player") || equal(classname2, "amx_apache") || equal(classname2, "func_breakable") || equal(classname2, "func_pushable"))
  912. {
  913.  
  914. if(equal(classname2, "player") || equal(classname2, "amx_apache"))
  915. {
  916. new friendlyfire = get_pcvar_num(ff);
  917. if((friendlyfire == 1 || friendlyfire == 0 && get_user_team(attacker) != get_user_team(entity2)))
  918. {
  919. new Float:origin[3]
  920. entity_get_vector(entity2, EV_VEC_origin, origin)
  921. if(equal(classname2, "player") && get_user_health(entity2) == 1)
  922. {
  923. client_print(entity2, print_center, "Soha ne allj a rotorokhoz!!")
  924. }
  925. fakedamage(entity2, "apache", 1.0, DMG_SLASH)
  926. }
  927. }
  928. else if(equal(classname2, "func_breakable") || equal(classname2, "func_pushable"))
  929. {
  930. force_use(entity2, attacker)
  931. }
  932. }
  933. }
  934. }
  935.  
  936. return PLUGIN_CONTINUE
  937. }
  938.  
  939. public emitsound(entity, const sample[])
  940. {
  941. if(equal(sample, "common/wpn_denyselect.wav"))
  942. {
  943. return FMRES_SUPERCEDE
  944. }
  945. return FMRES_IGNORED
  946. }
  947.  
  948. public plugin_precache()
  949. {
  950. laserbeam = precache_model("sprites/laserbeam.spr")
  951. smoke = precache_model("sprites/smoke.spr")
  952. boom = precache_model("sprites/zerogxplode.spr")
  953.  
  954. precache_model("models/rc_apache_final.mdl")
  955. precache_model("models/rpgrocket.mdl")
  956. precache_model("models/shell.mdl")
  957.  
  958. precache_sound("vox/_period.wav")
  959. precache_sound("weapons/rocketfire1.wav")
  960. precache_sound("weapons/rocket1.wav")
  961. precache_sound("weapons/m249-1.wav")
  962. precache_sound("apache/ap_rotor2.wav")
  963. }
  964.  
  965. public get_num_ents()
  966. {
  967. new i, count;
  968. for(i=1;i<maxentities;i++)
  969. {
  970. if(is_valid_ent(i))
  971. count++
  972. }
  973. return count;
  974. }
  975.  
  976. ///////////////// THANKS AVALANCHE!! ///////////////////
  977.  
  978. public HL_RadiusDamage( Float:vecSrc[3], /*pevAttacker,*/ pevInflictor, Float:flDamage, Float:flRadius/*, iClassIgnore, bitsDamageType*/ )
  979. {
  980. new pEntity;
  981. new tr;
  982. new Float:flAdjustedDamage, Float:falloff;
  983. new Float:vecSpot[3];
  984.  
  985. // NEW
  986. new Float:vecAbsMin[3], Float:vecAbsMax[3], Float:vecAdjust[3],
  987. Float:vecEndPos[3], Float:flFraction, iWaterLevel, i;
  988.  
  989. if( flRadius )
  990. falloff = flDamage / flRadius;
  991. else
  992. falloff = 1.0;
  993.  
  994. new bInWater = (engfunc( EngFunc_PointContents, vecSrc ) == CONTENTS_WATER);
  995.  
  996. vecSrc[2] += 1;// in case grenade is lying on the ground
  997.  
  998. // iterate on all entities in the vicinity.
  999. while ((pEntity = engfunc( EngFunc_FindEntityInSphere, pEntity, vecSrc, flRadius )) != 0)
  1000. {
  1001. if ( pev( pEntity, pev_takedamage ) != DAMAGE_NO )
  1002. {
  1003. iWaterLevel = pev( pEntity, pev_waterlevel ); // NEW
  1004.  
  1005. // blasts don't travel into or out of water
  1006. if (bInWater && iWaterLevel == 0)
  1007. continue;
  1008. if (!bInWater && iWaterLevel == 3)
  1009. continue;
  1010.  
  1011. // OLD: vecSpot = pEntity->BodyTarget( vecSrc ); -- NEW:
  1012. pev( pEntity, pev_absmin, vecAbsMin );
  1013. pev( pEntity, pev_absmax, vecAbsMax );
  1014. for( i = 0; i < 3; i++ ) vecSpot[i] = ( vecAbsMin[i] + vecAbsMax[i] ) * 0.5;
  1015.  
  1016. engfunc( EngFunc_TraceLine, vecSrc, vecSpot, DONT_IGNORE_MONSTERS, pevInflictor, tr );
  1017.  
  1018. get_tr2( tr, TR_flFraction, flFraction ); // NEW
  1019. get_tr2( tr, TR_vecEndPos, vecEndPos ); // NEW
  1020.  
  1021. if ( flFraction == 1.0 || get_tr2( tr, TR_pHit ) == pEntity )
  1022. {// the explosion can 'see' this entity, so hurt them!
  1023. if ( get_tr2( tr, TraceResult:TR_StartSolid ) )
  1024. {
  1025. // if we're stuck inside them, fixup the position and distance
  1026. vecEndPos = vecSrc;
  1027. flFraction = 0.0;
  1028. }
  1029.  
  1030. // decrease damage for an ent that's farther from the bomb.
  1031.  
  1032. // OLD: flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length() * falloff; -- NEW:
  1033. for( i = 0; i < 3; i++ ) vecAdjust[i] = vecSrc[i] - vecEndPos[i];
  1034. flAdjustedDamage = floatsqroot(vecAdjust[0]*vecAdjust[0] + vecAdjust[1]*vecAdjust[1] + vecAdjust[2]*vecAdjust[2]) * falloff;
  1035.  
  1036. flAdjustedDamage = flDamage - flAdjustedDamage;
  1037.  
  1038. if ( flAdjustedDamage < 0.0 )
  1039. {
  1040. flAdjustedDamage = 0.0;
  1041. }
  1042.  
  1043. // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) );
  1044. take_damage( pEntity, pevInflictor, flAdjustedDamage ); // NEW
  1045. }
  1046. }
  1047. }
  1048. }
  1049.  
  1050. public take_damage( victim, attacker, Float:damage )
  1051. {
  1052. // "victim" should take "damage" damage from "attacker"
  1053. fakedamage(victim,"apache",damage,0);
  1054. }
  1055.