HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. // ver 1.2.3 added JumpBomb model, fixed other bugs, added screen effect (c) Zombie-rus
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <fakemeta>
  6. #include <engine>
  7. #include <cstrike>
  8. #include <hamsandwich>
  9. #include <zombieplague>
  10.  
  11. #define PLUGIN "Zombie Class Deimos"
  12. #define VERSION "1.2.3"
  13. #define AUTHOR "NST Team / Zombie-rus"
  14.  
  15. new spr_skill[] = "g_tentacle"
  16. new const light_classname[] = "nst_deimos_skill"
  17.  
  18. new sprites_exp_index, sprites_trail_index
  19.  
  20. new g_wait[33], g_check[33], g_useskill[33], g_msgStatusIcon, g_zclass_deimos, g_msgScreenFade, g_msgScreenShake
  21. new g_CurWeapon[33], g_bombmodelwpn[64]
  22.  
  23. const WPN_NOT_DROP = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
  24. enum (+= 100)
  25. {
  26. TASK_WAIT = 2000,
  27. TASK_ATTACK,
  28. TASK_BOT_USE_SKILL,
  29. TASK_USE_SKILL
  30. }
  31. // IDs inside tasks
  32. #define ID_WAIT (taskid - TASK_WAIT)
  33. #define ID_ATTACK (taskid - TASK_ATTACK)
  34. #define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)
  35. #define ID_USE_SKILL (taskid - TASK_USE_SKILL)
  36.  
  37. const m_flTimeWeaponIdle = 48
  38. const m_flNextAttack = 83
  39.  
  40. new const sprites_exp[] = "sprites/deimosexp.spr"
  41. new const sprites_trail[] = "sprites/trail.spr"
  42. new const sound_skill_start[] = "zombie_plague/deimos_skill_start.wav"
  43. new const sound_skill_hit[] = "zombie_plague/deimos_skill_hit.wav"
  44. const skill_dmg = 0
  45. const skill_anim = 11
  46. const Float:skill_time_wait = 12.0
  47.  
  48. new const zclass_name[] = { "Deimos Zombi" }
  49. new const zclass_info[] = { "\w[\rEldobatja az emberek fegyoit G]" }
  50. new const zclass_model[] = { "zombie-rus_s0h2" }
  51. new const zclass_clawmodel[] = { "v_zombie-rus_s0h.mdl" }
  52. const zclass_health = 3500
  53. const zclass_speed = 240
  54. const Float:zclass_gravity = 1.0
  55. const Float:zclass_knockback = 1.0
  56.  
  57. #define OFFSET_MODELINDEX 491
  58. #define OFFSET_LINUX 5
  59.  
  60. new index, defaultindex
  61.  
  62. new const WeaponNames[][] =
  63. {
  64. "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  65. "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  66. "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  67. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  68. "weapon_ak47", "weapon_knife", "weapon_p90"
  69. }
  70.  
  71. const FFADE_IN = 0x0000
  72.  
  73. public plugin_init()
  74. {
  75. register_plugin(PLUGIN, VERSION, AUTHOR)
  76.  
  77. // msg
  78. g_msgStatusIcon = get_user_msgid("StatusIcon")
  79.  
  80. // Events
  81. register_logevent("logevent_round_start",2, "1=Round_Start")
  82. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  83. register_event("DeathMsg", "Death", "a")
  84. register_event("CurWeapon", "Event_CurrentWeapon", "be", "1=1")
  85.  
  86. for (new i = 1; i < sizeof WeaponNames; i++)
  87. if (WeaponNames[i][0]) RegisterHam(Ham_Item_Deploy, WeaponNames[i], "fw_Weapon_Deploy_Post", 1)
  88.  
  89. // FM Forwards
  90. register_forward(FM_CmdStart, "fw_CmdStart")
  91. register_forward(FM_Touch, "fw_Touch")
  92.  
  93. // Cmd
  94. register_concmd("drop", "use_skill")
  95. }
  96.  
  97. public plugin_precache()
  98. {
  99. formatex(g_bombmodelwpn, charsmax(g_bombmodelwpn), "models/zr/v_bomb_deimos2.mdl")
  100.  
  101. engfunc(EngFunc_PrecacheModel, g_bombmodelwpn)
  102.  
  103. g_zclass_deimos = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
  104.  
  105. sprites_exp_index = precache_model(sprites_exp)
  106. sprites_trail_index = precache_model(sprites_trail)
  107. precache_sound(sound_skill_start)
  108. precache_sound(sound_skill_hit)
  109.  
  110. index = precache_model("models/player/zombie-rus_s0h2/zombie-rus_s0h2.mdl")
  111. defaultindex = precache_model("models/player.mdl")
  112. }
  113.  
  114. public Event_CurrentWeapon(id) g_CurWeapon[id] = read_data(2)
  115.  
  116. public event_round_start()
  117. {
  118. for (new id=1; id<33; id++)
  119. {
  120. if (!is_user_connected(id)) continue;
  121.  
  122. reset_value_player(id)
  123. StatusIcon(id, spr_skill, 0)
  124. }
  125. }
  126.  
  127. public zp_user_infected_post(id, infector)
  128. {
  129. set_wpnmodel(id)
  130. fm_set_user_model_index(id, index)
  131. }
  132.  
  133. public zp_user_humanized_post(id, survivor)
  134. {
  135. fm_set_user_model_index(id, defaultindex)
  136. }
  137.  
  138. public logevent_round_start()
  139. {
  140. for (new id=1; id<33; id++)
  141. {
  142. if (!is_user_connected(id)) continue;
  143. if (is_user_bot(id))
  144. {
  145. if (task_exists(id+TASK_BOT_USE_SKILL)) remove_task(id+TASK_BOT_USE_SKILL)
  146. set_task(float(random_num(5,15)), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  147. }
  148. }
  149. }
  150.  
  151. public Death()
  152. {
  153. new victim = read_data(2)
  154. StatusIcon(victim, spr_skill, 0)
  155. reset_value_player(victim)
  156. }
  157.  
  158. public fw_Weapon_Deploy_Post(weapon_ent)
  159. {
  160. static id; id = get_pdata_cbase(weapon_ent, 41, 4)
  161.  
  162. static weaponid ; weaponid = cs_get_weapon_id(weapon_ent)
  163.  
  164. g_CurWeapon[id] = weaponid
  165.  
  166. replace_weapon_models(id, weaponid)
  167. }
  168.  
  169. public client_connect(id)
  170. {
  171. reset_value_player(id)
  172. }
  173.  
  174. public client_disconnect(id)
  175. {
  176. reset_value_player(id)
  177. }
  178.  
  179. reset_value_player(id)
  180. {
  181. if (task_exists(id+TASK_WAIT)) remove_task(id+TASK_WAIT)
  182. if (task_exists(id+TASK_BOT_USE_SKILL)) remove_task(id+TASK_BOT_USE_SKILL)
  183.  
  184. g_wait[id] = 0
  185. g_check[id] = 0
  186. g_useskill[id] = 0
  187. }
  188.  
  189. // bot use skill
  190.  
  191. public bot_use_skill(taskid)
  192. {
  193. new id = ID_BOT_USE_SKILL
  194. if (!is_user_bot(id)) return;
  195.  
  196. use_skill(id)
  197. if (task_exists(taskid)) remove_task(taskid)
  198. set_task(float(random_num(5,15)), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  199. }
  200.  
  201. public use_skill(id)
  202. {
  203. if (!is_user_alive(id)) return PLUGIN_CONTINUE
  204.  
  205. new health = get_user_health(id) - skill_dmg
  206. if ((zp_get_user_zombie_class(id) == g_zclass_deimos) && (zp_get_user_zombie(id)) && (!g_wait[id]) && (health>0) && (get_user_weapon(id)==CSW_KNIFE))
  207. {
  208. g_useskill[id] = 1
  209.  
  210. // set health
  211. fm_set_user_health(id, health)
  212.  
  213. // set time wait
  214. new Float:timewait = skill_time_wait
  215.  
  216. g_wait[id] = 1
  217. if (task_exists(id+TASK_WAIT)) remove_task(id+TASK_WAIT)
  218. set_task(timewait, "RemoveWait", id+TASK_WAIT)
  219. return PLUGIN_HANDLED
  220. }
  221.  
  222. return PLUGIN_CONTINUE
  223. }
  224.  
  225. public task_use_skill(taskid)
  226. {
  227. new id = ID_USE_SKILL
  228.  
  229. // play anim & sound
  230. play_weapon_anim(id, 8)
  231. set_weapons_timeidle(id, skill_time_wait)
  232. set_player_nextattack(id, 0.5)
  233. PlayEmitSound(id, sound_skill_start)
  234. entity_set_int(id, EV_INT_sequence, skill_anim)
  235.  
  236. // attack
  237. if (task_exists(id+TASK_ATTACK)) remove_task(id+TASK_ATTACK)
  238. set_task(0.5, "launch_light", id+TASK_ATTACK)
  239. }
  240.  
  241. public launch_light(taskid)
  242. {
  243. new id = ID_ATTACK
  244. if (task_exists(id+TASK_ATTACK)) remove_task(id+TASK_ATTACK)
  245.  
  246. if (!is_user_alive(id)) return;
  247.  
  248. // check
  249. new Float: fOrigin[3], Float:fAngle[3],Float: fVelocity[3]
  250. pev(id, pev_origin, fOrigin)
  251. pev(id, pev_view_ofs, fAngle)
  252. fm_velocity_by_aim(id, 2.0, fVelocity, fAngle)
  253. fAngle[0] *= -1.0
  254.  
  255. // create ent
  256. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  257. set_pev(ent, pev_classname, light_classname)
  258. engfunc(EngFunc_SetModel, ent, "models/w_hegrenade.mdl")
  259. set_pev(ent, pev_mins, Float:{-1.0, -1.0, -1.0})
  260. set_pev(ent, pev_maxs, Float:{1.0, 1.0, 1.0})
  261. set_pev(ent, pev_origin, fOrigin)
  262. fOrigin[0] += fVelocity[0]
  263. fOrigin[1] += fVelocity[1]
  264. fOrigin[2] += fVelocity[2]
  265. set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
  266. set_pev(ent, pev_gravity, 0.01)
  267. fVelocity[0] *= 1000
  268. fVelocity[1] *= 1000
  269. fVelocity[2] *= 1000
  270. set_pev(ent, pev_velocity, fVelocity)
  271. set_pev(ent, pev_owner, id)
  272. set_pev(ent, pev_angles, fAngle)
  273. set_pev(ent, pev_solid, SOLID_BBOX) //store the enitty id
  274.  
  275. // invisible ent
  276. fm_set_rendering(ent, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
  277.  
  278. // show trail
  279. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  280. write_byte(TE_BEAMFOLLOW)
  281. write_short(ent) //entity
  282. write_short(sprites_trail_index) //model
  283. write_byte(5) //10)//life
  284. write_byte(3) //5)//width
  285. write_byte(102) //r, hegrenade
  286. write_byte(45) //g, gas-grenade
  287. write_byte(145) //b
  288. write_byte(200) //brightness
  289. message_end() //move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)
  290.  
  291. //client_print(0, print_chat, "phong")
  292. return;
  293. }
  294.  
  295. public fw_Touch(ent, victim)
  296. {
  297. if (!pev_valid(ent)) return FMRES_IGNORED
  298.  
  299. new EntClassName[32]
  300. entity_get_string(ent, EV_SZ_classname, EntClassName, charsmax(EntClassName))
  301.  
  302. if (equal(EntClassName, light_classname))
  303. {
  304. light_exp(ent, victim)
  305. remove_entity(ent)
  306. return FMRES_IGNORED
  307. }
  308.  
  309. return FMRES_IGNORED
  310. }
  311.  
  312. light_exp(ent, victim)
  313. {
  314. if (!pev_valid(ent)) return;
  315.  
  316. // drop current wpn of victim
  317. new attacker = pev(ent, pev_owner)
  318. if (is_user_alive(victim) && !zp_get_user_survivor(victim) && (zp_get_user_zombie(attacker) != zp_get_user_zombie(victim)))
  319. {
  320. new wpn, wpnname[32]
  321. wpn = get_user_weapon(victim)
  322. if( !(WPN_NOT_DROP & (1<<wpn)) && get_weaponname(wpn, wpnname, charsmax(wpnname)) )
  323. {
  324. engclient_cmd(victim, "drop", wpnname)
  325.  
  326. screen_effects(victim)
  327. }
  328. }
  329.  
  330. // create effect
  331. static Float:origin[3];
  332. pev(ent, pev_origin, origin);
  333. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  334. write_byte(TE_EXPLOSION); // TE_EXPLOSION
  335. write_coord(floatround(origin[0])); // origin x
  336. write_coord(floatround(origin[1])); // origin y
  337. write_coord(floatround(origin[2])); // origin z
  338. write_short(sprites_exp_index); // sprites
  339. write_byte(40); // scale in 0.1's
  340. write_byte(30); // framerate
  341. write_byte(14); // flags
  342. message_end(); // message end
  343.  
  344. // play sound exp
  345. PlayEmitSound(ent, sound_skill_hit)
  346. }
  347.  
  348. public RemoveWait(taskid)
  349. {
  350. new id = ID_WAIT
  351. g_wait[id] = 0
  352. if (task_exists(taskid)) remove_task(taskid)
  353. }
  354.  
  355. public fw_CmdStart(id, uc_handle, seed)
  356. {
  357. if (!is_user_alive(id)) return FMRES_IGNORED
  358.  
  359. if (zp_get_user_zombie_class(id) == g_zclass_deimos && zp_get_user_zombie(id))
  360. {
  361. // show status icon help
  362. if (g_wait[id] && g_check[id] != 2)
  363. {
  364. g_check[id] = 2
  365. StatusIcon(id, spr_skill, 2)
  366. }
  367. else if (!g_wait[id] && g_check[id] != 1)
  368. {
  369. g_check[id] = 1
  370. StatusIcon(id, spr_skill, 1)
  371. }
  372.  
  373. // use skill
  374. if (g_useskill[id])
  375. {
  376. set_uc(uc_handle, UC_Buttons, IN_ATTACK2)
  377. g_useskill[id] = 0
  378. entity_set_int(id, EV_INT_sequence, skill_anim)
  379.  
  380. if (task_exists(id+TASK_USE_SKILL)) remove_task(id+TASK_USE_SKILL)
  381. set_task(0.0, "task_use_skill", id+TASK_USE_SKILL)
  382. }
  383. }
  384. else if (g_check[id])
  385. {
  386. // hide status icon
  387. g_check[id] = 0
  388. StatusIcon(id, spr_skill, 0)
  389. }
  390.  
  391. //client_print(id, print_chat, "[%i]", set_animation(id))
  392. return FMRES_IGNORED
  393. }
  394.  
  395. set_wpnmodel(id)
  396. {
  397. if (!is_user_alive(id)) return;
  398.  
  399. new wpn = get_user_weapon(id)
  400.  
  401. if (wpn == CSW_HEGRENADE || wpn == CSW_FLASHBANG || wpn == CSW_SMOKEGRENADE)
  402. {
  403. set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  404. }
  405.  
  406. }
  407.  
  408. PlayEmitSound(id, const sound[])
  409. {
  410. emit_sound(id, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  411. }
  412.  
  413. StatusIcon(id, sprname[], run)
  414. {
  415. if (!is_user_connected(id)) return;
  416.  
  417. message_begin(MSG_ONE, g_msgStatusIcon, {0,0,0}, id);
  418. write_byte(run); // status (0=hide, 1=show, 2=flash)
  419. write_string(sprname); // sprite name
  420. message_end();
  421. }
  422.  
  423. play_weapon_anim(player, anim)
  424. {
  425. set_pev(player, pev_weaponanim, anim)
  426. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
  427. write_byte(anim)
  428. write_byte(pev(player, pev_body))
  429. message_end()
  430. }
  431.  
  432. fm_velocity_by_aim(iIndex, Float:fDistance, Float:fVelocity[3], Float:fViewAngle[3])
  433. {
  434. //new Float:fViewAngle[3]
  435. pev(iIndex, pev_v_angle, fViewAngle)
  436. fVelocity[0] = floatcos(fViewAngle[1], degrees) * fDistance
  437. fVelocity[1] = floatsin(fViewAngle[1], degrees) * fDistance
  438. fVelocity[2] = floatcos(fViewAngle[0]+90.0, degrees) * fDistance
  439. return 1
  440. }
  441.  
  442. get_weapon_ent(id, weaponid)
  443. {
  444. static wname[32], weapon_ent
  445. get_weaponname(weaponid, wname, charsmax(wname))
  446. weapon_ent = fm_find_ent_by_owner(-1, wname, id)
  447. return weapon_ent
  448. }
  449. set_weapons_timeidle(id, Float:timeidle)
  450. {
  451. new entwpn = get_weapon_ent(id, get_user_weapon(id))
  452. if (pev_valid(entwpn)) set_pdata_float(entwpn, m_flTimeWeaponIdle, timeidle+3.0, 4)
  453. }
  454. set_player_nextattack(id, Float:nexttime)
  455. {
  456. set_pdata_float(id, m_flNextAttack, nexttime, 4)
  457. }
  458. // Set player's health (from fakemeta_util)
  459. stock fm_set_user_health(id, health)
  460. {
  461. (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  462. }
  463. // Set entity's rendering type (from fakemeta_util)
  464. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  465. {
  466. static Float:color[3]
  467. color[0] = float(r)
  468. color[1] = float(g)
  469. color[2] = float(b)
  470.  
  471. set_pev(entity, pev_renderfx, fx)
  472. set_pev(entity, pev_rendercolor, color)
  473. set_pev(entity, pev_rendermode, render)
  474. set_pev(entity, pev_renderamt, float(amount))
  475. }
  476. // Find entity by its owner (from fakemeta_util)
  477. stock fm_find_ent_by_owner(entity, const classname[], owner)
  478. {
  479. while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ }
  480. return entity;
  481. }
  482.  
  483. replace_weapon_models(id, weaponid)
  484. {
  485. if (zp_get_user_zombie_class(id) == g_zclass_deimos && zp_get_user_zombie(id))
  486. {
  487. switch(weaponid)
  488. {
  489. case CSW_HEGRENADE:
  490. {
  491. set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  492. }
  493. case CSW_SMOKEGRENADE:
  494. {
  495. set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  496. }
  497. case CSW_FLASHBANG:
  498. {
  499. set_pev(id, pev_viewmodel2, g_bombmodelwpn)
  500. }
  501. }
  502. }
  503. }
  504.  
  505. screen_effects(victim)
  506. {
  507. // Screen Fade
  508. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, victim)
  509. write_short ( 1<<13 ) // Duration
  510. write_short ( 1<<14 ) // Hold Time
  511. write_short ( FFADE_IN ) // Fade type
  512. write_byte ( random_num ( 50, 200 ) ) // Red amount
  513. write_byte ( random_num ( 50, 200 ) ) // Green amount
  514. write_byte ( random_num ( 50, 200 ) ) // Blue amount
  515. write_byte ( random_num ( 50, 200 ) ) // Alpha
  516. message_end ( )
  517. // Screen Shake
  518. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, victim)
  519. write_short ( 0xFFFF ) // Amplitude
  520. write_short ( 1<<13 ) // Duration
  521. write_short ( 0xFFFF ) // Frequency
  522. message_end ( )
  523. }
  524.  
  525. stock fm_set_user_model_index(id, value)
  526. {
  527. set_pdata_int(id, OFFSET_MODELINDEX, value, OFFSET_LINUX)
  528. }
  529. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  530. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1051\\ f0\\ fs16 \n\\ par }
  531. */
  532.