HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <zombieplague>
  5.  
  6. #define PLUGIN "[ZP] Addon: Evolucio"
  7. #define VERSION "1.0"
  8. #define AUTHOR "Dias"
  9.  
  10. #define TASK_GLOWSHELL 123123
  11. #define TASK_SHOWHUD 321321
  12.  
  13. #define HUD_DELAY_TIME 0.25
  14.  
  15. new g_sync_hud1, g_sync_hud2
  16. new g_level[33]
  17. const MAX_LEVEL_HUMAN = 10
  18.  
  19. // Human Evolution Vars + Config
  20. new const levelup_sound[] = "zombie_plague/levelup.wav"
  21. new id_sprites_levelup
  22. new const sprites_effects_levelup[] = "sprites/zombie_plague/levelup.spr"
  23.  
  24. new Float:XDAMAGE[11] = {
  25. 1.0,
  26. 1.1,
  27. 1.2,
  28. 1.3,
  29. 1.4,
  30. 1.5,
  31. 1.6,
  32. 1.7,
  33. 1.8,
  34. 1.9,
  35. 2.0
  36. }
  37.  
  38. public plugin_init()
  39. {
  40. register_plugin(PLUGIN, VERSION, AUTHOR)
  41.  
  42. register_event("DeathMsg", "event_death", "a")
  43. register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  44.  
  45. RegisterHam(Ham_Spawn, "player", "fw_spawn_post", 1)
  46. RegisterHam(Ham_TakeDamage, "player", "fw_takedamage")
  47.  
  48. g_sync_hud1 = CreateHudSyncObj(18)
  49. g_sync_hud2 = CreateHudSyncObj(19)
  50. }
  51.  
  52. public plugin_precache()
  53. {
  54. engfunc(EngFunc_PrecacheSound, levelup_sound)
  55.  
  56. // Precache Sprites
  57. id_sprites_levelup = precache_model(sprites_effects_levelup)
  58. }
  59.  
  60. public zp_user_humanized_post(id)
  61. {
  62. fw_spawn_post(id)
  63. }
  64.  
  65. public zp_user_infected_post(id)
  66. {
  67. g_level[id] = 0
  68.  
  69. set_hudmessage(0, 0, 0, -1.0, 0.83, 0, 2.0, 2.0)
  70. ShowSyncHudMsg(id, g_sync_hud1, "")
  71.  
  72. remove_task(id+TASK_GLOWSHELL)
  73. remove_task(id+TASK_SHOWHUD)
  74. }
  75.  
  76. public event_newround()
  77. {
  78. static id
  79. for (id = 1; id <= get_maxplayers(); id++)
  80. {
  81. if (is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && !zp_get_user_survivor(id))
  82. {
  83. g_level[id] = 0
  84. }
  85. }
  86. }
  87.  
  88. public event_death()
  89. {
  90. new attacker = read_data(1)
  91. new victim = read_data(2)
  92.  
  93. // Zombie Die
  94. if (zp_get_user_zombie(victim) && !zp_get_user_zombie(attacker))
  95. {
  96. UpdateLevelTeamHuman()
  97. }
  98. }
  99.  
  100. public fw_spawn_post(id)
  101. {
  102. if (is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && !zp_get_user_survivor(id))
  103. {
  104. set_task(HUD_DELAY_TIME, "show_hud", id+TASK_SHOWHUD, _, _, "b")
  105. }
  106. }
  107.  
  108. public fw_takedamage(victim, inflictor, attacker, Float:damage, damagetype)
  109. {
  110. if(damagetype & DMG_GENERIC || victim == attacker || !is_user_alive(victim) || !is_user_connected(attacker))
  111. return HAM_IGNORED
  112.  
  113. if((damagetype & (1<<24)) && zp_get_user_zombie(attacker))
  114. return HAM_IGNORED
  115.  
  116. if(!zp_get_user_zombie(attacker) && !zp_get_user_nemesis(attacker) && !zp_get_user_survivor(attacker))
  117. {
  118. if (g_level[attacker])
  119. {
  120. new Float: xdmg = XDAMAGE[g_level[attacker]]
  121. damage *= xdmg
  122. }
  123.  
  124. SetHamParamFloat(4, damage)
  125. }
  126.  
  127. return HAM_HANDLED
  128. }
  129.  
  130. public show_hud(taskid)
  131. {
  132. new id = taskid - TASK_SHOWHUD
  133.  
  134. if (is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && !zp_get_user_survivor(id))
  135. {
  136. show_hud_text(id)
  137. } else {
  138. set_hudmessage(0, 0, 0, -1.0, 0.83, 0, 2.0, 2.0)
  139. ShowSyncHudMsg(id, g_sync_hud1, "")
  140.  
  141. remove_task(taskid)
  142. remove_task(id+TASK_GLOWSHELL)
  143. }
  144. }
  145.  
  146. public UpdateLevelTeamHuman()
  147. {
  148. static id
  149. for (id = 1; id <= get_maxplayers(); id++)
  150. {
  151. if (is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && !zp_get_user_survivor(id))
  152. {
  153. UpdateLevelHuman(id, 1)
  154. }
  155. }
  156.  
  157. return 1
  158. }
  159.  
  160. public UpdateLevelHuman(id, num)
  161. {
  162. // update level
  163. g_level[id] += num
  164. if (g_level[id] > MAX_LEVEL_HUMAN)
  165. {
  166. g_level[id] = MAX_LEVEL_HUMAN
  167. }
  168. else
  169. {
  170. // Play Sound
  171. PlaySound2(id, levelup_sound)
  172.  
  173. // Effect
  174. EffectLevelUp(id)
  175.  
  176. // show hudtext
  177. set_hudmessage(0, 255, 0, -1.0, 0.40, 1, 5.0, 5.0)
  178. ShowSyncHudMsg(id, g_sync_hud2, "Level Up to %i !!!", g_level[id])
  179. }
  180. }
  181.  
  182. public EffectLevelUp(id)
  183. {
  184. if (!is_user_alive(id)) return;
  185.  
  186. // get origin
  187. static Float:origin[3]
  188. pev(id, pev_origin, origin)
  189.  
  190. // set color
  191. new color[3]
  192. color[0] = get_color_level(id, 0)
  193. color[1] = get_color_level(id, 1)
  194. color[2] = get_color_level(id, 2)
  195.  
  196. // create effect
  197. engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, origin, 0)
  198. write_byte(TE_BEAMCYLINDER) // TE id
  199. engfunc(EngFunc_WriteCoord, origin[0]) // x
  200. engfunc(EngFunc_WriteCoord, origin[1]) // y
  201. engfunc(EngFunc_WriteCoord, origin[2]) // z
  202. engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  203. engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  204. engfunc(EngFunc_WriteCoord, origin[2]+100.0) // z axis
  205. write_short(id_sprites_levelup) // sprite
  206. write_byte(0) // startframe
  207. write_byte(0) // framerate
  208. write_byte(4) // life
  209. write_byte(60) // width
  210. write_byte(0) // noise
  211. write_byte(color[0]) // red
  212. write_byte(color[1]) // green
  213. write_byte(color[2]) // blue
  214. write_byte(200) // brightness
  215. write_byte(0) // speed
  216. message_end()
  217.  
  218. // create glow shell
  219. fm_set_rendering(id)
  220. fm_set_rendering(id, kRenderFxGlowShell, color[0], color[1], color[2], kRenderNormal, 0)
  221. if (task_exists(id+TASK_GLOWSHELL)) remove_task(id+TASK_GLOWSHELL)
  222. set_task(10.0, "RemoveGlowShell", id+TASK_GLOWSHELL)
  223. }
  224.  
  225. public RemoveGlowShell(taskid)
  226. {
  227. new id = taskid - TASK_GLOWSHELL
  228. fm_set_rendering(id)
  229.  
  230. if(task_exists(taskid)) remove_task(taskid)
  231. }
  232.  
  233. public show_hud_text(id)
  234. {
  235. static level_color[3]
  236.  
  237. level_color[0] = get_color_level(id, 0)
  238. level_color[1] = get_color_level(id, 1)
  239. level_color[2] = get_color_level(id, 2)
  240.  
  241. set_hudmessage(level_color[0], level_color[1], level_color[2], -1.0, 0.83, 0, 2.0, 2.0)
  242.  
  243. if(g_level[id] == 0)
  244. {
  245. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 100%%^n[--------------------]")
  246. } else if(g_level[id] == 1) {
  247. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 110%%^n[++------------------]")
  248. } else if(g_level[id] == 2) {
  249. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 120%%^n[++++----------------]")
  250. } else if(g_level[id] == 3) {
  251. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 130%%^n[++++++--------------]")
  252. } else if(g_level[id] == 4) {
  253. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 140%%^n[++++++++------------]")
  254. } else if(g_level[id] == 5) {
  255. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 150%%^n[++++++++++----------]")
  256. } else if(g_level[id] == 6) {
  257. ShowSyncHudMsg(id, g_sync_hud1, "Szit: 160%%^n[++++++++++++--------]")
  258. } else if(g_level[id] == 7) {
  259. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 170%%^n[++++++++++++++------]")
  260. } else if(g_level[id] == 8) {
  261. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 180%%^n[++++++++++++++++----]")
  262. } else if(g_level[id] == 9) {
  263. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 190%%^n[++++++++++++++++++--]")
  264. } else if(g_level[id] == 10) {
  265. ShowSyncHudMsg(id, g_sync_hud1, "Szint: 200%%^n[++++++++++++++++++++]")
  266. }
  267. }
  268.  
  269. stock get_color_level(id, num)
  270. {
  271. new color[3]
  272.  
  273. switch (g_level[id])
  274. {
  275. case 1: color = {0,177,0}
  276. case 2: color = {0,177,0}
  277. case 3: color = {0,177,0}
  278. case 4: color = {137,191,20}
  279. case 5: color = {137,191,20}
  280. case 6: color = {250,229,0}
  281. case 7: color = {250,229,0}
  282. case 8: color = {243,127,1}
  283. case 9: color = {243,127,1}
  284. case 10: color = {255,3,0}
  285. case 11: color = {127,40,208}
  286. case 12: color = {127,40,208}
  287. case 13: color = {127,40,208}
  288. default: color = {0,177,0}
  289. }
  290.  
  291. return color[num];
  292. }
  293.  
  294. stock PlaySound2(id, const sound[])
  295. {
  296. client_cmd(id, "spk ^"%s^"", sound)
  297. }
  298.  
  299. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  300. {
  301. static Float:color[3]
  302. color[0] = float(r)
  303. color[1] = float(g)
  304. color[2] = float(b)
  305.  
  306. set_pev(entity, pev_renderfx, fx)
  307. set_pev(entity, pev_rendercolor, color)
  308. set_pev(entity, pev_rendermode, render)
  309. set_pev(entity, pev_renderamt, float(amount))
  310. }
  311.