HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <zombieplague>
  5. #include <xs>
  6.  
  7. #define PLUGIN "DJB Zombie Class Banchee"
  8. #define VERSION "1.0"
  9. #define AUTHOR "Csoldjb"
  10.  
  11. new const zclass_name[] = "Kísértet Zombi"
  12. new const zclass_info[] = "| G -> Denevér Támadás"
  13. new const zclass_model[] = "witch_zombi_origin"
  14. new const zclass_clawmodel[] = "v_knife_witch_zombi.mdl"
  15. const zclass_health = 1800
  16. const zclass_speed = 190
  17. const Float:zclass_gravity = 1.0
  18. const Float:zclass_knockback = 1.0
  19.  
  20. new const SOUND_FIRE[] = "zombie_plague/zombi_banshee_pulling_fire.wav"
  21. new const SOUND_BAT_HIT[] = "zombie_plague/zombi_banshee_laugh.wav"
  22. new const SOUND_BAT_MISS[] = "zombie_plague/zombi_banshee_pulling_fail.wav"
  23. new const MODEL_BAT[] = "models/zombie_plague/bat_witch.mdl"
  24. new const BAT_CLASSNAME[] = "banchee_bat"
  25. new spr_skull
  26.  
  27. const Float:banchee_skull_bat_speed = 600.0
  28. const Float:banchee_skull_bat_flytime = 3.0
  29. const Float:banchee_skull_bat_catch_time = 3.0
  30. const Float:banchee_skull_bat_catch_speed = 100.0
  31. const Float:bat_timewait = 14.0
  32.  
  33. new g_stop[33]
  34. new g_bat_time[33]
  35. new g_bat_stat[33]
  36. new g_bat_enemy[33]
  37. new Float:g_temp_speed[33]
  38.  
  39. new idclass_banchee
  40. new g_maxplayers
  41. new g_roundend
  42. new g_msgSayText
  43.  
  44. enum (+= 100)
  45. {
  46. TASK_BOT_USE_SKILL = 2367,
  47. TASK_REMOVE_STAT
  48. }
  49.  
  50. #define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)
  51. #define ID_TASK_REMOVE_STAT (taskid - TASK_REMOVE_STAT)
  52.  
  53. public plugin_precache()
  54. {
  55. precache_sound(SOUND_FIRE)
  56. precache_sound(SOUND_BAT_HIT)
  57. precache_sound(SOUND_BAT_MISS)
  58.  
  59. precache_model(MODEL_BAT)
  60.  
  61. spr_skull = precache_model("sprites/ef_bat.spr")
  62.  
  63. idclass_banchee = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
  64. }
  65.  
  66. public plugin_init()
  67. {
  68. register_plugin(PLUGIN, VERSION, AUTHOR)
  69.  
  70. register_event("HLTV", "EventHLTV", "a", "1=0", "2=0")
  71. register_event("DeathMsg", "EventDeath", "a")
  72. register_logevent("logevent_round_end", 2, "1=Round_End")
  73.  
  74. register_clcmd("drop", "cmd_bat")
  75.  
  76. register_forward(FM_PlayerPreThink,"fw_PlayerPreThink")
  77.  
  78. RegisterHam(Ham_Touch,"info_target","EntityTouchPost",1)
  79. RegisterHam(Ham_Think,"info_target","EntityThink")
  80.  
  81. g_maxplayers = get_maxplayers()
  82. g_msgSayText = get_user_msgid("SayText")
  83. }
  84.  
  85. public client_putinserver(id)
  86. {
  87. reset_value_player(id)
  88. }
  89.  
  90. public client_disconnect(id)
  91. {
  92. reset_value_player(id)
  93. }
  94.  
  95. public EventHLTV()
  96. {
  97. g_roundend = 0
  98.  
  99. for(new id = 1; id <= g_maxplayers; id++)
  100. {
  101. if (!is_user_connected(id)) continue;
  102.  
  103. reset_value_player(id)
  104. }
  105. }
  106.  
  107. public logevent_round_end()
  108. {
  109. g_roundend = 1
  110. }
  111.  
  112. public EventDeath()
  113. {
  114. new id = read_data(2)
  115.  
  116. reset_value_player(id)
  117. }
  118.  
  119. public zp_user_infected_post(id)
  120. {
  121. reset_value_player(id)
  122.  
  123. if(zp_get_user_nemesis(id)) return;
  124.  
  125. if(zp_get_user_zombie_class(id) == idclass_banchee)
  126. {
  127. if(is_user_bot(id))
  128. {
  129. set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  130. return
  131. }
  132.  
  133. zp_colored_print(id, "^x04[ZP]^x01 Kísértet Zombi vagy.^x01A^x04 'Denevér Támadás'^x01 képességed, ^x04 %.1f ^x01másodpercenként használhatod.", bat_timewait)
  134. }
  135. }
  136.  
  137. public zp_user_humanized_post(id)
  138. {
  139. reset_value_player(id)
  140. }
  141.  
  142. public cmd_bat(id)
  143. {
  144. if(g_roundend) return PLUGIN_CONTINUE
  145.  
  146. if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE
  147.  
  148. if(zp_get_user_zombie_class(id) == idclass_banchee && !g_bat_time[id])
  149. {
  150. g_bat_time[id] = 1
  151.  
  152. set_task(bat_timewait,"clear_stat",id+TASK_REMOVE_STAT)
  153.  
  154. new ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
  155.  
  156. if(!pev_valid(ent)) return PLUGIN_HANDLED
  157.  
  158. new Float:vecAngle[3],Float:vecOrigin[3],Float:vecVelocity[3],Float:vecForward[3]
  159. fm_get_user_startpos(id,5.0,2.0,-1.0,vecOrigin)
  160. pev(id,pev_angles,vecAngle)
  161.  
  162. engfunc(EngFunc_MakeVectors,vecAngle)
  163. global_get(glb_v_forward,vecForward)
  164.  
  165. velocity_by_aim(id,floatround(banchee_skull_bat_speed),vecVelocity)
  166.  
  167. set_pev(ent,pev_origin,vecOrigin)
  168. set_pev(ent,pev_angles,vecAngle)
  169. set_pev(ent,pev_classname,BAT_CLASSNAME)
  170. set_pev(ent,pev_movetype,MOVETYPE_FLY)
  171. set_pev(ent,pev_solid,SOLID_BBOX)
  172. engfunc(EngFunc_SetSize,ent,{-20.0,-15.0,-8.0},{20.0,15.0,8.0})
  173.  
  174. engfunc(EngFunc_SetModel,ent,MODEL_BAT)
  175. set_pev(ent,pev_animtime,get_gametime())
  176. set_pev(ent,pev_framerate,1.0)
  177. set_pev(ent,pev_owner,id)
  178. set_pev(ent,pev_velocity,vecVelocity)
  179. set_pev(ent,pev_nextthink,get_gametime()+banchee_skull_bat_flytime)
  180. emit_sound(ent, CHAN_WEAPON, SOUND_FIRE, 1.0, ATTN_NORM, 0, PITCH_NORM)
  181.  
  182. g_stop[id] = ent
  183.  
  184. PlayWeaponAnimation(id, 2)
  185. pev(id, pev_maxspeed, g_temp_speed[id])
  186. set_pev(id,pev_maxspeed,0.1)
  187.  
  188. return PLUGIN_HANDLED
  189. }
  190.  
  191. return PLUGIN_CONTINUE
  192. }
  193.  
  194. public fw_PlayerPreThink(id)
  195. {
  196. if(!is_user_alive(id)) return FMRES_IGNORED
  197.  
  198. if(g_bat_stat[id])
  199. {
  200. new owner = g_bat_enemy[id], Float:ownerorigin[3]
  201. pev(owner,pev_origin,ownerorigin)
  202. static Float:vec[3]
  203. aim_at_origin(id,ownerorigin,vec)
  204. engfunc(EngFunc_MakeVectors, vec)
  205. global_get(glb_v_forward, vec)
  206. vec[0] *= banchee_skull_bat_catch_speed
  207. vec[1] *= banchee_skull_bat_catch_speed
  208. vec[2] = 0.0
  209. set_pev(id,pev_velocity,vec)
  210. }
  211.  
  212. return FMRES_IGNORED
  213. }
  214.  
  215. public EntityThink(ent)
  216. {
  217. if(!pev_valid(ent)) return HAM_IGNORED
  218.  
  219. new classname[32]
  220. pev(ent,pev_classname,classname,31)
  221.  
  222. if(equal(classname,BAT_CLASSNAME))
  223. {
  224. static Float:origin[3];
  225. pev(ent,pev_origin,origin);
  226.  
  227. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  228. write_byte(TE_EXPLOSION); // TE_EXPLOSION
  229. write_coord(floatround(origin[0])); // origin x
  230. write_coord(floatround(origin[1])); // origin y
  231. write_coord(floatround(origin[2])); // origin z
  232. write_short(spr_skull); // sprites
  233. write_byte(40); // scale in 0.1's
  234. write_byte(30); // framerate
  235. write_byte(14); // flags
  236. message_end(); // message end
  237.  
  238. emit_sound(ent, CHAN_WEAPON, SOUND_BAT_MISS, 1.0, ATTN_NORM, 0, PITCH_NORM)
  239.  
  240. new owner = pev(ent, pev_owner)
  241. g_stop[owner] = 0
  242. set_pev(owner,pev_maxspeed,g_temp_speed[owner])
  243.  
  244. engfunc(EngFunc_RemoveEntity,ent)
  245. }
  246.  
  247. return HAM_IGNORED
  248. }
  249.  
  250. public EntityTouchPost(ent,ptd)
  251. {
  252. if(!pev_valid(ent)) return HAM_IGNORED
  253.  
  254. new classname[32]
  255. pev(ent,pev_classname,classname,31)
  256.  
  257. if(equal(classname,BAT_CLASSNAME))
  258. {
  259. if(!pev_valid(ptd))
  260. {
  261. static Float:origin[3];
  262. pev(ent,pev_origin,origin);
  263.  
  264. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  265. write_byte(TE_EXPLOSION); // TE_EXPLOSION
  266. write_coord(floatround(origin[0])); // origin x
  267. write_coord(floatround(origin[1])); // origin y
  268. write_coord(floatround(origin[2])); // origin z
  269. write_short(spr_skull); // sprites
  270. write_byte(40); // scale in 0.1's
  271. write_byte(30); // framerate
  272. write_byte(14); // flags
  273. message_end(); // message end
  274.  
  275. emit_sound(ent, CHAN_WEAPON, SOUND_BAT_MISS, 1.0, ATTN_NORM, 0, PITCH_NORM)
  276.  
  277. new owner = pev(ent, pev_owner)
  278. g_stop[owner] = 0
  279. set_pev(owner,pev_maxspeed,g_temp_speed[owner])
  280.  
  281. engfunc(EngFunc_RemoveEntity,ent)
  282.  
  283. return HAM_IGNORED
  284. }
  285.  
  286. new owner = pev(ent,pev_owner)
  287.  
  288. if(0 < ptd && ptd <= g_maxplayers && is_user_alive(ptd) && ptd != owner)
  289. {
  290. g_bat_enemy[ptd] = owner
  291.  
  292. set_pev(ent,pev_nextthink,get_gametime()+banchee_skull_bat_catch_time)
  293. set_task(banchee_skull_bat_catch_time,"clear_stat2",ptd+TASK_REMOVE_STAT)
  294. set_pev(ent,pev_movetype,MOVETYPE_FOLLOW)
  295. set_pev(ent,pev_aiment,ptd)
  296.  
  297. emit_sound(owner, CHAN_VOICE, SOUND_BAT_HIT, 1.0, ATTN_NORM, 0, PITCH_NORM)
  298.  
  299. g_bat_stat[ptd] = 1
  300. }
  301. }
  302.  
  303. return HAM_IGNORED
  304. }
  305.  
  306. public clear_stat(taskid)
  307. {
  308. new id = ID_TASK_REMOVE_STAT
  309.  
  310. g_bat_stat[id] = 0
  311. g_bat_time[id] = 0
  312.  
  313. zp_colored_print(id, "^x04[ZP]^x01 A 'Denevér Támadás'^x04 Képességed^x01 újra használhatod.")
  314. }
  315.  
  316. public clear_stat2(idx)
  317. {
  318. new id = idx-TASK_REMOVE_STAT
  319.  
  320. g_bat_enemy[id] = 0
  321. g_bat_stat[id] = 0
  322. }
  323.  
  324. public bot_use_skill(taskid)
  325. {
  326. new id = ID_BOT_USE_SKILL
  327.  
  328. if (!is_user_alive(id)) return;
  329.  
  330. cmd_bat(id)
  331.  
  332. set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  333. }
  334.  
  335. fm_get_user_startpos(id,Float:forw,Float:right,Float:up,Float:vStart[])
  336. {
  337. new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  338.  
  339. pev(id, pev_origin, vOrigin)
  340. pev(id, pev_v_angle, vAngle)
  341.  
  342. engfunc(EngFunc_MakeVectors, vAngle)
  343.  
  344. global_get(glb_v_forward, vForward)
  345. global_get(glb_v_right, vRight)
  346. global_get(glb_v_up, vUp)
  347.  
  348. vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  349. vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  350. vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  351. }
  352.  
  353. aim_at_origin(id, Float:target[3], Float:angles[3])
  354. {
  355. static Float:vec[3]
  356. pev(id,pev_origin,vec)
  357. vec[0] = target[0] - vec[0]
  358. vec[1] = target[1] - vec[1]
  359. vec[2] = target[2] - vec[2]
  360. engfunc(EngFunc_VecToAngles,vec,angles)
  361. angles[0] *= -1.0
  362. angles[2] = 0.0
  363. }
  364.  
  365. PlayWeaponAnimation(id, animation)
  366. {
  367. set_pev(id, pev_weaponanim, animation)
  368. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id)
  369. write_byte(animation)
  370. write_byte(pev(id, pev_body))
  371. message_end()
  372. }
  373.  
  374. reset_value_player(id)
  375. {
  376. g_stop[id] = 0
  377. g_bat_time[id] = 0
  378. g_bat_stat[id] = 0
  379. g_bat_enemy[id] = 0
  380.  
  381. remove_task(id+TASK_BOT_USE_SKILL)
  382. remove_task(id+TASK_REMOVE_STAT)
  383. }
  384.  
  385. zp_colored_print(target, const message[], any:...)
  386. {
  387. static buffer[512], i, argscount
  388. argscount = numargs()
  389.  
  390. if (!target)
  391. {
  392. static player
  393. for (player = 1; player <= g_maxplayers; player++)
  394. {
  395. if (!is_user_connected(player))
  396. continue;
  397.  
  398. static changed[5], changedcount
  399. changedcount = 0
  400.  
  401. for (i = 2; i < argscount; i++)
  402. {
  403. if (getarg(i) == LANG_PLAYER)
  404. {
  405. setarg(i, 0, player)
  406. changed[changedcount] = i
  407. changedcount++
  408. }
  409. }
  410.  
  411. vformat(buffer, charsmax(buffer), message, 3)
  412.  
  413. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
  414. write_byte(player)
  415. write_string(buffer)
  416. message_end()
  417.  
  418. for (i = 0; i < changedcount; i++)
  419. setarg(changed[i], 0, LANG_PLAYER)
  420. }
  421. }
  422. else
  423. {
  424. vformat(buffer, charsmax(buffer), message, 3)
  425.  
  426. message_begin(MSG_ONE, g_msgSayText, _, target)
  427. write_byte(target)
  428. write_string(buffer)
  429. message_end()
  430. }
  431. }
  432. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  433. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  434. */
  435.