HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <zombieplague>
  3. #include <fakemeta>
  4. #include <engine>
  5. #include <hamsandwich>
  6. #include <cstrike>
  7. #include <xs>
  8.  
  9. // Task offsets
  10. enum (+= 100) {
  11. TASK_BURN
  12. }
  13.  
  14. // IDs inside tasks
  15. #define ID_BURN (taskid - TASK_BURN)
  16.  
  17. #define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && is_user_alive(%1))
  18.  
  19. new const zclass_name[] = { "Husk Zombi" }
  20. new const zclass_info[] = { "Tuz Golyo(R)" }
  21. new const zclass_model[] = { "Husk" }
  22. new const zclass_clawmodel[] = { "v_husk_hands.mdl" }
  23. const zclass_health = 8700
  24. const zclass_speed = 200
  25. const Float:zclass_gravity = 0.7
  26. const Float:zclass_knockback = 1.0
  27.  
  28. new g_Husk
  29. new g_trailSpr
  30. new const fire_model[] = "sprites/3dmflared.spr"
  31.  
  32. // Cooldown hook
  33. new Float:g_iLastFire[33]
  34.  
  35. new cvar_firespeed, cvar_firecooldown, cvar_firedamage, cvar_fireduration, cvar_fireslowdown, cvar_fireradius, cvar_firesurvivor
  36. new g_smokeSpr, g_flameSpr, g_exploSpr
  37. new g_burning_duration[33] // burning task duration
  38. new g_maxplayers
  39. new attacker
  40.  
  41. public plugin_init()
  42. {
  43. register_plugin("[ZP] Zombie Class: Zombie Husk", "0.2", "DJHD!")
  44.  
  45. cvar_firespeed = register_cvar("zp_husk_fire_speed", "700")
  46. cvar_firecooldown = register_cvar("zp_husk_fire_cooldown", "15.0")
  47. cvar_firedamage = register_cvar("zp_husk_fire_damage", "2")
  48. cvar_fireduration = register_cvar("zp_husk_fire_duration", "5")
  49. cvar_fireslowdown = register_cvar("zp_husk_fire_slowdown", "0.5")
  50. cvar_fireradius = register_cvar("zp_husk_fire_radius", "220.0")
  51. cvar_firesurvivor = register_cvar("zp_husk_fire_survivor", "1")
  52.  
  53. register_forward(FM_Touch, "fw_Touch")
  54. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  55.  
  56. // HAM Forwards
  57. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  58. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  59.  
  60. g_maxplayers = get_maxplayers()
  61. }
  62.  
  63. public plugin_precache()
  64. {
  65. g_Husk = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
  66.  
  67. engfunc(EngFunc_PrecacheModel, fire_model)
  68.  
  69. g_trailSpr = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr")
  70. g_smokeSpr = engfunc(EngFunc_PrecacheModel, "sprites/black_smoke3.spr")
  71. g_flameSpr = engfunc(EngFunc_PrecacheModel, "sprites/flame.spr")
  72. g_exploSpr = engfunc(EngFunc_PrecacheModel, "sprites/zerogxplode.spr")
  73.  
  74. engfunc(EngFunc_PrecacheSound, "zombie_plague/husk_pre_fire.wav")
  75. engfunc(EngFunc_PrecacheSound, "zombie_plague/husk_wind_down.wav")
  76. engfunc(EngFunc_PrecacheSound, "zombie_plague/husk_fireball_fire.wav")
  77. engfunc(EngFunc_PrecacheSound, "zombie_plague/husk_fireball_loop.wav")
  78. engfunc(EngFunc_PrecacheSound, "zombie_plague/husk_fireball_explode.wav")
  79. }
  80.  
  81. public zp_user_infected_post(id, infector)
  82. {
  83. if (zp_get_user_zombie_class(id) == g_Husk)
  84. {
  85. if(zp_get_user_nemesis(id))
  86. return
  87.  
  88. g_iLastFire[id] = 0.0
  89.  
  90. print_chatColor(id, "\g[ZP]\n Tuzgolyot loves: \g^"R^"\n.")
  91. }
  92. }
  93.  
  94. public fw_PlayerPreThink(id)
  95. {
  96. if(!is_user_alive(id))
  97. return;
  98.  
  99. static iButton; iButton = pev(id, pev_button)
  100. static iOldButton; iOldButton = pev(id, pev_oldbuttons)
  101.  
  102. if(zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_Husk) && !zp_get_user_nemesis(id))
  103. {
  104. if((iButton & IN_RELOAD) && !(iOldButton & IN_RELOAD))
  105. {
  106. if(get_gametime() - g_iLastFire[id] < get_pcvar_float(cvar_firecooldown))
  107. {
  108. print_chatColor(id, "\g[ZP]\n Meg varnod kell \g%.1f\n ,hogy ujra tudj \gTuzgolyot\n loni", get_pcvar_float(cvar_firecooldown)-(get_gametime() - g_iLastFire[id]))
  109. return;
  110. }
  111.  
  112. g_iLastFire[id] = get_gametime()
  113.  
  114. message_begin(MSG_ONE, get_user_msgid("BarTime"), _, id)
  115. write_byte(1)
  116. write_byte(0)
  117. message_end()
  118.  
  119. emit_sound(id, CHAN_ITEM, "zombie_plague/husk_pre_fire.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  120.  
  121. set_task(1.0, "MakeFire", id)
  122. }
  123.  
  124. if(iOldButton & IN_RELOAD && !(iButton & IN_RELOAD))
  125. {
  126. if(task_exists(id))
  127. {
  128. print_chatColor(id, "\g[ZP]\n Ahhoz,hogy \gTuzgolyot\n tudj loni(Nyomd meg az \g^"R^"\n billentyut)")
  129. g_iLastFire[id] = 0.0
  130. emit_sound(id, CHAN_ITEM, "zombie_plague/husk_wind_down.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  131. }
  132.  
  133. message_begin(MSG_ONE, get_user_msgid("BarTime"), _, id)
  134. write_byte(0)
  135. write_byte(0)
  136. message_end()
  137.  
  138. remove_task(id)
  139. }
  140. }
  141. }
  142.  
  143. // Ham Player Spawn Post Forward
  144. public fw_PlayerSpawn_Post(id)
  145. {
  146. // Not alive or didn't join a team yet
  147. if (!is_user_alive(id) || !cs_get_user_team(id))
  148. return;
  149.  
  150. // Remove previous tasks
  151. remove_task(id+TASK_BURN)
  152. }
  153.  
  154. // Ham Player Killed Forward
  155. public fw_PlayerKilled(victim, attacker, shouldgib)
  156. {
  157. // Stop burning
  158. if (!zp_get_user_zombie(victim))
  159. remove_task(victim+TASK_BURN)
  160. }
  161.  
  162. public client_disconnect(id)
  163. remove_task(id+TASK_BURN)
  164.  
  165. public MakeFire(id)
  166. {
  167. new Float:Origin[3]
  168. new Float:vAngle[3]
  169. new Float:flVelocity[3]
  170.  
  171. // Get position from eyes
  172. get_user_eye_position(id, Origin)
  173.  
  174. // Get View Angles
  175. entity_get_vector(id, EV_VEC_v_angle, vAngle)
  176.  
  177. new NewEnt = create_entity("info_target")
  178.  
  179. entity_set_string(NewEnt, EV_SZ_classname, "fireball")
  180.  
  181. entity_set_model(NewEnt, fire_model)
  182.  
  183. entity_set_size(NewEnt, Float:{ -1.5, -1.5, -1.5 }, Float:{ 1.5, 1.5, 1.5 })
  184.  
  185. entity_set_origin(NewEnt, Origin)
  186.  
  187. // Set Entity Angles (thanks to Arkshine)
  188. make_vector(vAngle)
  189. entity_set_vector(NewEnt, EV_VEC_angles, vAngle)
  190.  
  191. entity_set_int(NewEnt, EV_INT_solid, SOLID_BBOX)
  192.  
  193. entity_set_float(NewEnt, EV_FL_scale, 0.3)
  194. entity_set_int(NewEnt, EV_INT_spawnflags, SF_SPRITE_STARTON)
  195. entity_set_float(NewEnt, EV_FL_framerate, 25.0)
  196. set_rendering(NewEnt, kRenderFxNone, 0, 0, 0, kRenderTransAdd, 255)
  197.  
  198. entity_set_int(NewEnt, EV_INT_movetype, MOVETYPE_FLY)
  199. entity_set_edict(NewEnt, EV_ENT_owner, id)
  200.  
  201. // Set Entity Velocity
  202. velocity_by_aim(id, get_pcvar_num(cvar_firespeed), flVelocity)
  203. entity_set_vector(NewEnt, EV_VEC_velocity, flVelocity)
  204.  
  205. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  206. write_byte(TE_BEAMFOLLOW) // TE id
  207. write_short(NewEnt) // entity
  208. write_short(g_trailSpr) // sprite
  209. write_byte(5) // life
  210. write_byte(6) // width
  211. write_byte(255) // r
  212. write_byte(0) // g
  213. write_byte(0) // b
  214. write_byte(255) // brightness
  215. message_end()
  216.  
  217. set_task(0.2, "effect_fire", NewEnt, _, _, "b")
  218.  
  219. emit_sound(id, CHAN_ITEM, "zombie_plague/husk_fireball_fire.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  220. emit_sound(NewEnt, CHAN_ITEM, "zombie_plague/husk_fireball_loop.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  221. }
  222.  
  223. public effect_fire(entity)
  224. {
  225. if (!pev_valid(entity))
  226. {
  227. remove_task(entity)
  228. return;
  229. }
  230.  
  231. // Get origin
  232. static Float:originF[3]
  233. pev(entity, pev_origin, originF)
  234.  
  235. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  236. write_byte(17)
  237. engfunc(EngFunc_WriteCoord, originF[0]) // x
  238. engfunc(EngFunc_WriteCoord, originF[1]) // y
  239. engfunc(EngFunc_WriteCoord, originF[2]+30) // z
  240. write_short(g_flameSpr)
  241. write_byte(5) // byte (scale in 0.1's) 188 - era 65
  242. write_byte(200) // byte (framerate)
  243. message_end()
  244.  
  245. // Smoke
  246. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  247. write_byte(5)
  248. engfunc(EngFunc_WriteCoord, originF[0]) // x
  249. engfunc(EngFunc_WriteCoord, originF[1]) // y
  250. engfunc(EngFunc_WriteCoord, originF[2]) // z
  251. write_short(g_smokeSpr) // short (sprite index)
  252. write_byte(13) // byte (scale in 0.1's)
  253. write_byte(15) // byte (framerate)
  254. message_end()
  255.  
  256. // Colored Aura
  257. engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0)
  258. write_byte(TE_DLIGHT) // TE id
  259. engfunc(EngFunc_WriteCoord, originF[0]) // x
  260. engfunc(EngFunc_WriteCoord, originF[0]) // y
  261. engfunc(EngFunc_WriteCoord, originF[0]) // z
  262. write_byte(25) // radius
  263. write_byte(255) // r
  264. write_byte(128) // g
  265. write_byte(0) // b
  266. write_byte(2) // life
  267. write_byte(3) // decay rate
  268. message_end()
  269. }
  270.  
  271. // Touch Forward
  272. public fw_Touch(ent, id)
  273. {
  274. if (!pev_valid(ent))
  275. return PLUGIN_HANDLED
  276.  
  277. new class[32]
  278. pev(ent, pev_classname, class, charsmax(class))
  279.  
  280. if(equal(class, "fireball"))
  281. {
  282. attacker = entity_get_edict(ent, EV_ENT_owner)
  283. husk_touch(ent)
  284. engfunc(EngFunc_RemoveEntity, ent)
  285. return PLUGIN_HANDLED
  286. }
  287. return PLUGIN_HANDLED
  288. }
  289.  
  290. public husk_touch(ent)
  291. {
  292. if (!pev_valid(ent))
  293. return;
  294.  
  295. // Get origin
  296. static Float:originF[3]
  297. pev(ent, pev_origin, originF)
  298.  
  299. // Explosion
  300. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  301. write_byte(TE_EXPLOSION)
  302. engfunc(EngFunc_WriteCoord, originF[0]) // x
  303. engfunc(EngFunc_WriteCoord, originF[1]) // y
  304. engfunc(EngFunc_WriteCoord, originF[2]) // z
  305. write_short(g_exploSpr)
  306. write_byte(40) // byte (scale in 0.1's) 188 - era 65
  307. write_byte(25) // byte (framerate)
  308. write_byte(TE_EXPLFLAG_NOSOUND) // byte flags
  309. message_end()
  310.  
  311. emit_sound(ent, CHAN_ITEM, "zombie_plague/husk_fireball_explode.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  312.  
  313. // Collisions
  314. static victim
  315. victim = -1
  316.  
  317. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, get_pcvar_float(cvar_fireradius))) != 0)
  318. {
  319. // Only effect alive zombies
  320. if (!is_user_valid_alive(victim) || zp_get_user_zombie(victim) || !get_pcvar_num(cvar_firesurvivor) && zp_get_user_survivor(victim))
  321. continue;
  322.  
  323. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("Damage"), _, victim)
  324. write_byte(0) // damage save
  325. write_byte(0) // damage take
  326. write_long(DMG_BURN) // damage type
  327. write_coord(0) // x
  328. write_coord(0) // y
  329. write_coord(0) // z
  330. message_end()
  331.  
  332. g_burning_duration[victim] += get_pcvar_num(cvar_fireduration) * 5
  333.  
  334. // Set burning task on victim if not present
  335. if (!task_exists(victim+TASK_BURN))
  336. set_task(0.2, "burning_flame", victim+TASK_BURN, _, _, "b")
  337. }
  338. }
  339.  
  340. // Burning Flames
  341. public burning_flame(taskid)
  342. {
  343. // Get player origin and flags
  344. static origin[3], flags
  345. get_user_origin(ID_BURN, origin)
  346. flags = pev(ID_BURN, pev_flags)
  347.  
  348. // in water - burning stopped
  349. if (zp_get_user_zombie(ID_BURN) || (flags & FL_INWATER) || g_burning_duration[ID_BURN] < 1)
  350. {
  351. // Smoke sprite
  352. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  353. write_byte(TE_SMOKE) // TE id
  354. write_coord(origin[0]) // x
  355. write_coord(origin[1]) // y
  356. write_coord(origin[2]-50) // z
  357. write_short(g_smokeSpr) // sprite
  358. write_byte(random_num(15, 20)) // scale
  359. write_byte(random_num(10, 20)) // framerate
  360. message_end()
  361.  
  362. // Task not needed anymore
  363. remove_task(taskid);
  364. return;
  365. }
  366.  
  367. if ((pev(ID_BURN, pev_flags) & FL_ONGROUND) && get_pcvar_float(cvar_fireslowdown) > 0.0)
  368. {
  369. static Float:velocity[3]
  370. pev(ID_BURN, pev_velocity, velocity)
  371. xs_vec_mul_scalar(velocity, get_pcvar_float(cvar_fireslowdown), velocity)
  372. set_pev(ID_BURN, pev_velocity, velocity)
  373. }
  374.  
  375. // Get player's health
  376. static health
  377. health = pev(ID_BURN, pev_health)
  378.  
  379. if (health > get_pcvar_float(cvar_firedamage))
  380. fm_set_user_health(ID_BURN, health - floatround(get_pcvar_float(cvar_firedamage)))
  381. else
  382. death_message(attacker, ID_BURN, "fireball", 1)
  383.  
  384. // Flame sprite
  385. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  386. write_byte(TE_SPRITE) // TE id
  387. write_coord(origin[0]+random_num(-5, 5)) // x
  388. write_coord(origin[1]+random_num(-5, 5)) // y
  389. write_coord(origin[2]+random_num(-10, 10)) // z
  390. write_short(g_flameSpr) // sprite
  391. write_byte(random_num(5, 10)) // scale
  392. write_byte(200) // brightness
  393. message_end()
  394.  
  395. // Decrease burning duration counter
  396. g_burning_duration[ID_BURN]--
  397. }
  398.  
  399.  
  400. // Death message
  401. public death_message(Killer, Victim, const Weapon [], ScoreBoard)
  402. {
  403. // Block death msg
  404. set_msg_block(get_user_msgid("DeathMsg"), BLOCK_SET)
  405. ExecuteHamB(Ham_Killed, Victim, Killer, 0)
  406. set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
  407.  
  408. // Death
  409. make_deathmsg(Killer, Victim, 0, Weapon)
  410.  
  411. // Update score board
  412. if (ScoreBoard)
  413. {
  414. message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
  415. write_byte(Killer) // id
  416. write_short(pev(Killer, pev_frags)) // frags
  417. write_short(cs_get_user_deaths(Killer)) // deaths
  418. write_short(0) // class?
  419. write_short(get_user_team(Killer)) // team
  420. message_end()
  421.  
  422. message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
  423. write_byte(Victim) // id
  424. write_short(pev(Victim, pev_frags)) // frags
  425. write_short(cs_get_user_deaths(Victim)) // deaths
  426. write_short(0) // class?
  427. write_short(get_user_team(Victim)) // team
  428. message_end()
  429. }
  430. }
  431.  
  432. /*================================================================================
  433. [Stocks]
  434. =================================================================================*/
  435.  
  436. // Color Chat
  437. stock print_chatColor(const id,const input[], any:...)
  438. {
  439. new msg[191], players[32], count = 1;
  440. vformat(msg,190,input,3);
  441. replace_all(msg,190,"\g","^4");// green
  442. replace_all(msg,190,"\n","^1");// normal
  443. replace_all(msg,190,"\t","^3");// team
  444.  
  445. if (id) players[0] = id; else get_players(players,count,"ch");
  446. for (new i=0;i<count;i++)
  447. if (is_user_connected(players[i]))
  448. {
  449. message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
  450. write_byte(players[i]);
  451. write_string(msg);
  452. message_end();
  453. }
  454. }
  455.  
  456. stock get_user_eye_position(id, Float:flOrigin[3])
  457. {
  458. static Float:flViewOffs[3]
  459. entity_get_vector(id, EV_VEC_view_ofs, flViewOffs)
  460. entity_get_vector(id, EV_VEC_origin, flOrigin)
  461. xs_vec_add(flOrigin, flViewOffs, flOrigin)
  462. }
  463.  
  464. stock make_vector(Float:flVec[3])
  465. {
  466. flVec[0] -= 30.0
  467. engfunc(EngFunc_MakeVectors, flVec)
  468. flVec[0] = -(flVec[0] + 30.0)
  469. }
  470.  
  471. // Set player's health (from fakemeta_util)
  472. stock fm_set_user_health(id, health)
  473. {
  474. (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  475. }
  476. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  477. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang11274\\ f0\\ fs16 \n\\ par }
  478. */
  479.