Advertisement
Guest User

asdasda

a guest
May 3rd, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <fakemeta>
  5. #include <fakemeta_util>
  6. #include <hamsandwich>
  7. #include <zombie_eli>
  8. #include <infinitygame>
  9. #include <cstrike>
  10.  
  11. #define PLUGIN "[ZD] Zombie Class: BINLADEN"
  12. #define VERSION "1.0"
  13. #define AUTHOR "a dirty black nigger"
  14.  
  15. #define GAME_FOLDER "zombie_elimination"
  16.  
  17. #define HEALTH 1500
  18. #define ARMOR 50
  19.  
  20. #define SETTING_FILE "ZombieClass_Config.ini"
  21. #define LANG_FILE "ZombieElimination.txt"
  22.  
  23. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  24. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  25. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  26.  
  27. #define HUD_ADRENALINE_X -1.0
  28. #define HUD_ADRENALINE_Y 0.83
  29.  
  30. #define BAT_MODEL "models/zombie_elimination/bat_witch.mdl"
  31. #define BAT_PULLINGSOUND "zombie_elimination/zombie/banshee/zombi_banshee_laugh.wav" // Spawn
  32. #define BAT_FIRESOUND "zombie_elimination/zombie/banshee/banshee_pulling_fire.wav" // Fly
  33. #define BAT_DEATH "zombie_elimination/zombie/banshee/bat_no.wav" // Death
  34.  
  35. new g_zombieclass
  36. new zclass_name[16], zclass_desc[32]
  37. new Float:zclass_speed, Float:zclass_gravity
  38. new zclass_model[64], zclass_clawmodel[64]
  39.  
  40. new g_IsUserAlive, g_BotHamRegister, Float:g_SummonBats[33]
  41. new Float:CheckTime3[33], g_MaxPlayers, m_iBlood[2]
  42. new g_GameStart, g_SkillHud, g_MsgStatusIcon
  43. new g_DemonBats, g_BatHP, g_Pounce
  44. new LeapHigh, LeapSound[64], g_Leaping, g_MyPounce[33], g_TotalPounce[33], Float:Regain[33]
  45.  
  46. // Auto Skill
  47. #define AUTO_TIME random_float(15.0, 30.0)
  48. #define TASK_AUTO 4965
  49.  
  50. public plugin_init()
  51. {
  52. register_plugin(PLUGIN, VERSION, AUTHOR)
  53.  
  54. register_event("DeathMsg", "Event_Death", "a")
  55. register_think("bat", "fw_Bat_Think")
  56. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  57.  
  58. register_forward(FM_EmitSound, "fw_EmitSound")
  59. register_forward(FM_CmdStart, "fw_CmdStart")
  60.  
  61. g_SkillHud = CreateHudSyncObj(3)
  62. g_MaxPlayers = get_maxplayers()
  63. g_MsgStatusIcon = get_user_msgid("StatusIcon")
  64.  
  65. register_clcmd("drop", "CMD_Drop")
  66. register_clcmd("say get", "Get")
  67. }
  68.  
  69. public Get(id)
  70. {
  71. client_print(id, print_chat, "Info: %s - %s", zclass_model, zclass_clawmodel)
  72. }
  73.  
  74. public plugin_precache()
  75. {
  76. register_dictionary(LANG_FILE)
  77.  
  78. Load_Class_Setting()
  79. //g_zombieclass = ZombieEli_RegisterClass(zclass_name, HEALTH, ARMOR, zclass_gravity, zclass_speed, zclass_model, zclass_clawmodel, TEAM_ZOMBIE, 1)
  80.  
  81.  
  82. // Skill
  83. g_DemonBats = ZombieEli_RegisterSkill(g_zombieclass, "Demon Bats", 3)
  84. g_BatHP = ZombieEli_RegisterSkill(g_zombieclass, "Bat Health", 3)
  85. g_Pounce = ZombieEli_RegisterSkill(g_zombieclass, "Pounce", 3)
  86. }
  87.  
  88. native MyName_Is_Binladen(id)
  89. native ComeFrom_Vietnam(id)
  90. //
  91. public Load_Class_Setting()
  92. {
  93. static Temp[8]
  94.  
  95. formatex(zclass_name, sizeof(zclass_name), "%L", LANG_SERVER, "ZOMBIE_CLASS_BINLADEN_NAME")
  96. formatex(zclass_desc, sizeof(zclass_desc), "%L", LANG_SERVER, "ZOMBIE_CLASS_BINLADEN_DESC")
  97.  
  98. Setting_Load_String(SETTING_FILE, "Zombie Class", "CLASS_BINLADEN_SPEED", Temp, sizeof(Temp)); zclass_speed = str_to_float(Temp)
  99. Setting_Load_String(SETTING_FILE, "Zombie Class", "CLASS_BINLADEN_GRAVITY", Temp, sizeof(Temp)); zclass_gravity = str_to_float(Temp)
  100.  
  101. Setting_Load_String(SETTING_FILE, "Zombie Class", "CLASS_BINLADEN_MODEL", zclass_model, sizeof(zclass_model))
  102. Setting_Load_String(SETTING_FILE, "Zombie Class", "CLASS_BINLADEN_CLAWMODEL", zclass_clawmodel, sizeof(zclass_clawmodel))
  103.  
  104. // Skill
  105. LeapHigh = Setting_Load_Int(SETTING_FILE, "Zombie Light", "LEAP_HIGH")
  106. Setting_Load_String(SETTING_FILE, "Zombie Light", "LEAP_SOUND", LeapSound, sizeof(LeapSound))
  107.  
  108. m_iBlood[0] = precache_model("sprites/blood.spr")
  109. m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  110.  
  111. // Precache
  112. //precache_model(BAT_MODEL)
  113. precache_sound(BAT_PULLINGSOUND)
  114. //precache_sound(BAT_FIRESOUND)
  115. //precache_sound(BAT_DEATH)
  116.  
  117. //engfunc(EngFunc_PrecacheSound, LeapSound)
  118. }
  119.  
  120. public zeli_round_new() remove_entity_name("bat")
  121. public zeli_round_start() g_GameStart = 1
  122. public zeli_round_end() g_GameStart = 0
  123.  
  124. public zeli_user_spawned(id) Reset_Skill(id)
  125. public zeli_user_infected(id) Reset_Skill(id)
  126.  
  127. public client_disconnect(id) UnSet_BitVar(g_IsUserAlive, id)
  128. public client_putinserver(id)
  129. {
  130. if(!g_BotHamRegister && is_user_bot(id))
  131. {
  132. g_BotHamRegister = 1
  133. set_task(0.1, "Bot_RegisterHam", id)
  134. }
  135.  
  136. UnSet_BitVar(g_IsUserAlive, id)
  137. }
  138.  
  139. public Bot_RegisterHam(id)
  140. {
  141. RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
  142. }
  143.  
  144. public fw_PlayerSpawn_Post(id)
  145. {
  146. if(!is_user_alive(id))
  147. return
  148.  
  149. Set_BitVar(g_IsUserAlive, id)
  150. }
  151.  
  152. public Event_Death()
  153. {
  154. static Victim; Victim = read_data(2); UnSet_BitVar(g_IsUserAlive, Victim)
  155. }
  156.  
  157. public zeli_class_active(id, ClassID)
  158. {
  159. if(ClassID != g_zombieclass)
  160. return
  161.  
  162. Reset_Skill(id)
  163.  
  164. g_SummonBats[id] = 0.0
  165.  
  166. static SP; SP = ZombieEli_GetSP(id, g_Pounce)
  167. switch(SP)
  168. {
  169. case 1: g_TotalPounce[id] = 1
  170. case 2: g_TotalPounce[id] = 2
  171. case 3: g_TotalPounce[id] = 3
  172. default: g_TotalPounce[id] = 0
  173. }
  174.  
  175. Off(id, 0)
  176. Off(id, 1)
  177. Off(id, 2)
  178. Off(id, 3)
  179.  
  180. g_MyPounce[id] = g_TotalPounce[id]
  181. Update_Hud(id, g_MyPounce[id])
  182.  
  183. static Level; Level = ZombieEli_GetLevel(id, g_zombieclass)
  184. if(Level >= 10) MyName_Is_Binladen(id)
  185. }
  186.  
  187. public zeli_skillup(id, SkillID, NewPoint)
  188. {
  189. if(SkillID != g_Pounce) return
  190.  
  191. switch(NewPoint)
  192. {
  193. case 1: g_TotalPounce[id] = 1
  194. case 2: g_TotalPounce[id] = 2
  195. case 3: g_TotalPounce[id] = 3
  196. default: g_TotalPounce[id] = 0
  197. }
  198. }
  199.  
  200. public zeli_levelup(id, ClassID, NewLevel)
  201. {
  202. if(ClassID == g_zombieclass && NewLevel >= 10)
  203. MyName_Is_Binladen(id)
  204. }
  205.  
  206. public zeli_class_unactive(id, ClassID)
  207. {
  208. if(ClassID != g_zombieclass)
  209. return
  210.  
  211. Off(id, 0)
  212. Off(id, 1)
  213. Off(id, 2)
  214. Off(id, 3)
  215.  
  216. Reset_Skill(id)
  217. ComeFrom_Vietnam(id)
  218. }
  219.  
  220. public Reset_Skill(id)
  221. {
  222. UnSet_BitVar(g_Leaping, id)
  223. }
  224.  
  225. public CMD_Drop(id)
  226. {
  227. if(!Get_BitVar(g_IsUserAlive, id))
  228. return PLUGIN_CONTINUE
  229. if(!ZombieEli_IsZombie(id))
  230. return PLUGIN_CONTINUE
  231. if(ZombieEli_GetClass(id) != g_zombieclass)
  232. return PLUGIN_CONTINUE
  233.  
  234. static SP; SP = ZombieEli_GetSP(id, g_DemonBats)
  235. if(SP > 0)
  236. {
  237. if((pev(id, pev_flags) & FL_DUCKING) || pev(id, pev_bInDuck) || !(pev(id, pev_flags) & FL_ONGROUND))
  238. return PLUGIN_HANDLED
  239.  
  240. static Float:Cooldown
  241. switch(SP)
  242. {
  243. case 1: Cooldown = 60.0
  244. case 2: Cooldown = 45.0
  245. case 3: Cooldown = 30.0
  246. default: Cooldown = 99999.0
  247. }
  248.  
  249. if(get_gametime() - Cooldown > g_SummonBats[id])
  250. {
  251. Summons_Bats(id)
  252. g_SummonBats[id] = get_gametime()
  253. } else {
  254. client_print(id, print_center, "Remaining time for summoning bats: %i second(s)!", floatround(g_SummonBats[id] - (get_gametime() - Cooldown)))
  255. }
  256. } else {
  257. g_SummonBats[id] = 0.0
  258. client_print(id, print_center, "Train your 'Demon Bats' skill!")
  259. }
  260.  
  261. return PLUGIN_HANDLED
  262. }
  263.  
  264. public Summons_Bats(id)
  265. {
  266. ZombieEli_SetFakeAttack(id)
  267.  
  268. set_weapons_timeidle(id, 1.5)
  269. set_player_nextattack(id, 1.5)
  270.  
  271. set_weapon_anim(id, 1)
  272. set_pev(id, pev_framerate, 0.35)
  273. set_pev(id, pev_sequence, 151)
  274.  
  275. emit_sound(id, CHAN_ITEM, BAT_PULLINGSOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  276.  
  277. // Start Stamping
  278. set_task(1.0, "Create_Bats", id)
  279. }
  280.  
  281. public Create_Bats(id)
  282. {
  283. if(!Get_BitVar(g_IsUserAlive, id))
  284. return
  285. if(!ZombieEli_IsZombie(id))
  286. return
  287. if(ZombieEli_GetClass(id) != g_zombieclass)
  288. return
  289.  
  290. set_weapon_anim(id, 2)
  291.  
  292. static Bat; Bat = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  293. if(!pev_valid(Bat)) return
  294.  
  295. // Origin & Angles
  296. static Float:Origin[3]; get_position(id, 64.0, 0.0, 0.0, Origin)
  297. static Float:Angles[3]; pev(id, pev_v_angle, Angles)
  298.  
  299. Angles[0] *= -1.0
  300.  
  301. set_pev(Bat, pev_origin, Origin)
  302. set_pev(Bat, pev_angles, Angles)
  303.  
  304. // Set Bat Data
  305. set_pev(Bat, pev_takedamage, DAMAGE_YES)
  306. switch(ZombieEli_GetSP(id, g_BatHP))
  307. {
  308. case 1: set_pev(Bat, pev_health, 275.0 + 10000.0)
  309. case 2: set_pev(Bat, pev_health, 350.0 + 10000.0)
  310. case 3: set_pev(Bat, pev_health, 425.0 + 10000.0)
  311. default: set_pev(Bat, pev_health, 200.0 + 10000.0)
  312. }
  313.  
  314. set_pev(Bat, pev_classname, "bat")
  315. engfunc(EngFunc_SetModel, Bat, BAT_MODEL)
  316.  
  317. set_pev(Bat, pev_movetype, MOVETYPE_BOUNCE)
  318. set_pev(Bat, pev_solid, SOLID_SLIDEBOX)
  319. set_pev(Bat, pev_gamestate, 1)
  320.  
  321. set_pev(Bat, pev_gravity, 0.1)
  322.  
  323. static Float:mins[3]; mins[0] = -26.0; mins[1] = -26.0; mins[2] = -10.0
  324. static Float:maxs[3]; maxs[0] = 26.0; maxs[1] = 26.0; maxs[2] = 10.0
  325. engfunc(EngFunc_SetSize, Bat, mins, maxs)
  326.  
  327. // Set State
  328. set_pev(Bat, pev_iuser1, id)
  329. set_pev(Bat, pev_nextthink, get_gametime() + 0.1)
  330.  
  331. // Anim
  332. Set_Entity_Anim(Bat, 0)
  333.  
  334. // Set Next Think
  335. set_pev(Bat, pev_nextthink, get_gametime() + 0.1)
  336.  
  337. // Set Speed
  338. static Float:TargetOrigin[3], Float:Velocity[3]
  339. get_position(id, 4000.0, 0.0, 0.0, TargetOrigin)
  340. Get_SpeedVector(Origin, TargetOrigin, 240.0, Velocity)
  341.  
  342. emit_sound(Bat, CHAN_WEAPON, BAT_FIRESOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  343.  
  344. set_pev(Bat, pev_velocity, Velocity)
  345. }
  346.  
  347. public fw_Bat_Think(Ent)
  348. {
  349. if(!pev_valid(Ent)) return
  350. if((pev(Ent, pev_health) - 10000.0) <= 0.0)
  351. {
  352. static Float:Origin[3]; pev(Ent, pev_origin, Origin)
  353.  
  354. emit_sound(Ent, CHAN_BODY, BAT_DEATH, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  355.  
  356. set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
  357. set_pev(Ent, pev_flags, FL_KILLME)
  358.  
  359. return
  360. }
  361.  
  362. static id; id = pev(Ent, pev_iuser1)
  363.  
  364. if(!is_user_alive(id))
  365. {
  366. set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
  367. set_pev(Ent, pev_flags, FL_KILLME)
  368.  
  369. return
  370. }
  371.  
  372. static Enemy;
  373. Enemy = FindClosetEnemy(Ent, 1)
  374. if(!is_user_alive(Enemy)) Enemy = pev(Ent, pev_enemy)
  375. static Float:EnemyOrigin[3]
  376.  
  377. if(is_user_alive(Enemy))
  378. {
  379. pev(Enemy, pev_origin, EnemyOrigin)
  380. if(entity_range(Enemy, Ent) <= 60.0)
  381. {
  382. Aim_To2(Ent, EnemyOrigin)
  383. static Float:Angles[3]; pev(Ent, pev_angles, Angles)
  384. Angles[1] -= 45.0
  385. set_pev(Ent, pev_angles, Angles)
  386. set_pev(Ent, pev_velocity, {0.0, 0.0, 0.0})
  387.  
  388. static Float:Time; pev(Ent, pev_fuser3, Time)
  389. if(get_gametime() - 0.5 > Time)
  390. {
  391. ExecuteHamB(Ham_TakeDamage, Enemy, 0, id, 10.0, DMG_BULLET)
  392.  
  393. EnemyOrigin[2] += 16.0
  394. create_blood(EnemyOrigin)
  395.  
  396. set_pev(Ent, pev_fuser3, get_gametime())
  397. }
  398. } else {
  399. Aim_To2(Ent, EnemyOrigin)
  400. hook_ent2(Ent, EnemyOrigin, 300.0)
  401.  
  402. Set_EntAnim(Ent, 0, 1.0, 0)
  403. }
  404. } else {
  405. static Float:Vel[3], Float:Length; pev(Ent, pev_velocity, Vel)
  406. Length = vector_length(Vel)
  407.  
  408. if(!Length)
  409. {
  410. Vel[0] = random_float(250.0, -250.0)
  411. Vel[1] = random_float(250.0, -250.0)
  412.  
  413. set_pev(Ent, pev_velocity, Vel)
  414. }
  415. }
  416.  
  417. set_pev(Ent, pev_nextthink, get_gametime() + 0.1)
  418. }
  419.  
  420. public fw_CmdStart(id, UCHandle, Seed)
  421. {
  422. if(!Get_BitVar(g_IsUserAlive, id))
  423. return
  424. if(!ZombieEli_IsZombie(id))
  425. return
  426. if(ZombieEli_GetClass(id) != g_zombieclass)
  427. return
  428.  
  429. if(get_gametime() - 5.0 > Regain[id])
  430. {
  431. if(g_MyPounce[id] < g_TotalPounce[id])
  432. {
  433. g_MyPounce[id]++
  434.  
  435. Update_Hud(id, g_MyPounce[id])
  436.  
  437. Regain[id] = get_gametime()
  438. }
  439. }
  440.  
  441. if(get_gametime() - 1.0 > CheckTime3[id])
  442. {
  443. if(ZombieEli_GetLevel(id, g_zombieclass) >= 10)
  444. {
  445. static Hud[128]
  446. formatex(Hud, sizeof(Hud), "Ultimate Skill: Dragon Claw Hook", Hud)
  447.  
  448. set_hudmessage(200, 200, 200, HUD_ADRENALINE_X, HUD_ADRENALINE_Y - 0.02, 0, 1.1, 1.1, 0.0, 0.0)
  449. ShowSyncHudMsg(id, g_SkillHud, Hud)
  450. }
  451.  
  452. CheckTime3[id] = get_gametime()
  453. }
  454.  
  455. static CurButton; CurButton = get_uc(UCHandle, UC_Buttons)
  456.  
  457. if((CurButton & IN_ATTACK2))
  458. {
  459. if((pev(id, pev_flags) & FL_DUCKING) || pev(id, pev_bInDuck) || !(pev(id, pev_flags) & FL_ONGROUND))
  460. return
  461. if(get_pdata_float(id, 83, 5) > 0.0)
  462. return
  463. if(g_MyPounce[id] <= 0)
  464. return
  465.  
  466. g_MyPounce[id]--
  467. Update_Hud(id, g_MyPounce[id])
  468.  
  469. Active_Leap(id)
  470. }
  471. }
  472.  
  473. public Update_Hud(id, New)
  474. {
  475. Off(id, 0)
  476. Off(id, 1)
  477. Off(id, 2)
  478. Off(id, 3)
  479.  
  480. static AmmoSprites[33]
  481. format(AmmoSprites, sizeof(AmmoSprites), "number_%d", New)
  482.  
  483. message_begin(MSG_ONE_UNRELIABLE, g_MsgStatusIcon, {0,0,0}, id)
  484. write_byte(1)
  485. write_string(AmmoSprites)
  486. write_byte(42) // red
  487. write_byte(212) // green
  488. write_byte(255) // blue
  489. message_end()
  490. }
  491.  
  492. public Off(id, Num)
  493. {
  494. static AmmoSprites[33]
  495. format(AmmoSprites, sizeof(AmmoSprites), "number_%d", Num)
  496.  
  497. message_begin(MSG_ONE_UNRELIABLE, g_MsgStatusIcon, {0,0,0}, id)
  498. write_byte(0)
  499. write_string(AmmoSprites)
  500. write_byte(42) // red
  501. write_byte(212) // green
  502. write_byte(255) // blue
  503. message_end()
  504. }
  505.  
  506. public client_PostThink(id)
  507. {
  508. if(!Get_BitVar(g_IsUserAlive, id))
  509. return
  510. if(!Get_BitVar(g_Leaping, id))
  511. return
  512. if(!ZombieEli_IsZombie(id))
  513. return
  514.  
  515. static Float:flFallVelocity; flFallVelocity = get_pdata_float(id, 251, 5)
  516.  
  517. if(flFallVelocity && pev(id, pev_flags) & FL_ONGROUND)
  518. {
  519. Set_WeaponAnim(id, 0)
  520. UnSet_BitVar(g_Leaping, id)
  521. }
  522. }
  523.  
  524. public Active_Leap(id)
  525. {
  526. static Float:Origin1[3], Float:Origin2[3]
  527. pev(id, pev_origin, Origin1)
  528.  
  529. Set_BitVar(g_Leaping, id)
  530.  
  531. ZombieEli_SetFakeAttack(id)
  532.  
  533. // Climb Action
  534. Set_WeaponAnim(id, 2)
  535. set_pev(id, pev_sequence, 152)
  536.  
  537. set_pdata_float(id, 83, 1.0, 5)
  538.  
  539. get_position(id, 180.0, 0.0, 650.0, Origin2)
  540. static Float:Velocity[3]; Get_SpeedVector(Origin1, Origin2, float(LeapHigh), Velocity)
  541.  
  542. set_pev(id, pev_velocity, Velocity)
  543. emit_sound(id, CHAN_STATIC, LeapSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  544. }
  545.  
  546. stock set_weapon_anim(id, anim)
  547. {
  548. set_pev(id, pev_weaponanim, anim)
  549.  
  550. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
  551. write_byte(anim)
  552. write_byte(0)
  553. message_end()
  554. }
  555.  
  556. stock set_weapons_timeidle(id, Float:TimeIdle)
  557. {
  558. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_KNIFE)
  559. if(pev_valid(Ent)) set_pdata_float(Ent, 48, TimeIdle, 4)
  560. }
  561.  
  562. stock set_player_nextattack(id, Float:nexttime)
  563. {
  564. set_pdata_float(id, 83, nexttime, 5)
  565. }
  566.  
  567. stock Set_Entity_Anim(Ent, Anim)
  568. {
  569. set_pev(Ent, pev_animtime, get_gametime())
  570. set_pev(Ent, pev_sequence, Anim)
  571. set_pev(Ent, pev_framerate, 1.0)
  572. set_pev(Ent, pev_frame, 0.0)
  573. }
  574.  
  575. public FindClosetEnemy(ent, can_see)
  576. {
  577. new Float:maxdistance = 4980.0
  578. new indexid = 0
  579. new Float:current_dis = maxdistance
  580.  
  581. for(new i = 1 ;i <= g_MaxPlayers; i++)
  582. {
  583. if(can_see)
  584. {
  585. if(is_user_alive(i) && cs_get_user_team(i) == CS_TEAM_CT && can_see_fm(ent, i) && entity_range(ent, i) < current_dis)
  586. {
  587. current_dis = entity_range(ent, i)
  588. indexid = i
  589. }
  590. } else {
  591. if(is_user_alive(i) && cs_get_user_team(i) == CS_TEAM_CT && entity_range(ent, i) < current_dis)
  592. {
  593. current_dis = entity_range(ent, i)
  594. indexid = i
  595. }
  596. }
  597. }
  598.  
  599. return indexid
  600. }
  601.  
  602. public Aim_To2(iEnt, Float:vTargetOrigin[3])
  603. {
  604. if(!pev_valid(iEnt))
  605. return
  606.  
  607. static Float:Vec[3], Float:Angles[3]
  608. pev(iEnt, pev_origin, Vec)
  609.  
  610. Vec[0] = vTargetOrigin[0] - Vec[0]
  611. Vec[1] = vTargetOrigin[1] - Vec[1]
  612. Vec[2] = vTargetOrigin[2] - Vec[2]
  613. engfunc(EngFunc_VecToAngles, Vec, Angles)
  614. //Angles[0] = Angles[2] = 0.0
  615.  
  616. set_pev(iEnt, pev_v_angle, Angles)
  617. set_pev(iEnt, pev_angles, Angles)
  618. }
  619.  
  620. stock create_blood(const Float:origin[3])
  621. {
  622. // Show some blood :)
  623. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  624. write_byte(TE_BLOODSPRITE)
  625. engfunc(EngFunc_WriteCoord, origin[0])
  626. engfunc(EngFunc_WriteCoord, origin[1])
  627. engfunc(EngFunc_WriteCoord, origin[2])
  628. write_short(m_iBlood[1])
  629. write_short(m_iBlood[0])
  630. write_byte(75)
  631. write_byte(5)
  632. message_end()
  633. }
  634.  
  635. public bool:can_see_fm(entindex1, entindex2)
  636. {
  637. if (!entindex1 || !entindex2)
  638. return false
  639.  
  640. if (pev_valid(entindex1) && pev_valid(entindex1))
  641. {
  642. new flags = pev(entindex1, pev_flags)
  643. if (flags & EF_NODRAW || flags & FL_NOTARGET)
  644. {
  645. return false
  646. }
  647.  
  648. new Float:lookerOrig[3]
  649. new Float:targetBaseOrig[3]
  650. new Float:targetOrig[3]
  651. new Float:temp[3]
  652.  
  653. pev(entindex1, pev_origin, lookerOrig)
  654. pev(entindex1, pev_view_ofs, temp)
  655. lookerOrig[0] += temp[0]
  656. lookerOrig[1] += temp[1]
  657. lookerOrig[2] += temp[2]
  658.  
  659. pev(entindex2, pev_origin, targetBaseOrig)
  660. pev(entindex2, pev_view_ofs, temp)
  661. targetOrig[0] = targetBaseOrig [0] + temp[0]
  662. targetOrig[1] = targetBaseOrig [1] + temp[1]
  663. targetOrig[2] = targetBaseOrig [2] + temp[2]
  664.  
  665. engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the had of seen player
  666. if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
  667. {
  668. return false
  669. }
  670. else
  671. {
  672. new Float:flFraction
  673. get_tr2(0, TraceResult:TR_flFraction, flFraction)
  674. if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
  675. {
  676. return true
  677. }
  678. else
  679. {
  680. targetOrig[0] = targetBaseOrig [0]
  681. targetOrig[1] = targetBaseOrig [1]
  682. targetOrig[2] = targetBaseOrig [2]
  683. engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the body of seen player
  684. get_tr2(0, TraceResult:TR_flFraction, flFraction)
  685. if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
  686. {
  687. return true
  688. }
  689. else
  690. {
  691. targetOrig[0] = targetBaseOrig [0]
  692. targetOrig[1] = targetBaseOrig [1]
  693. targetOrig[2] = targetBaseOrig [2] - 17.0
  694. engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, entindex1, 0) // checks the legs of seen player
  695. get_tr2(0, TraceResult:TR_flFraction, flFraction)
  696. if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == entindex2))
  697. {
  698. return true
  699. }
  700. }
  701. }
  702. }
  703. }
  704. return false
  705. }
  706.  
  707. stock Setting_Load_Int(const filename[], const setting_section[], setting_key[])
  708. {
  709. if (strlen(filename) < 1)
  710. {
  711. log_error(AMX_ERR_NATIVE, "[ZD] Can't load settings: empty filename")
  712. return false;
  713. }
  714.  
  715. if (strlen(setting_section) < 1 || strlen(setting_key) < 1)
  716. {
  717. log_error(AMX_ERR_NATIVE, "[ZD] Can't load settings: empty section/key")
  718. return false;
  719. }
  720.  
  721. // Build customization file path
  722. new path[128]
  723. get_configsdir(path, charsmax(path))
  724. format(path, charsmax(path), "%s/ZombieElimination/%s", path, filename)
  725.  
  726. // File not present
  727. if (!file_exists(path))
  728. {
  729. static DataA[128]; formatex(DataA, sizeof(DataA), "[ZD] Can't load: %s", path)
  730. set_fail_state(DataA)
  731.  
  732. return false;
  733. }
  734.  
  735. // Open customization file for reading
  736. new file = fopen(path, "rt")
  737.  
  738. // File can't be opened
  739. if (!file)
  740. return false;
  741.  
  742. // Set up some vars to hold parsing info
  743. new linedata[1024], section[64]
  744.  
  745. // Seek to setting's section
  746. while (!feof(file))
  747. {
  748. // Read one line at a time
  749. fgets(file, linedata, charsmax(linedata))
  750.  
  751. // Replace newlines with a null character to prevent headaches
  752. replace(linedata, charsmax(linedata), "^n", "")
  753.  
  754. // New section starting
  755. if (linedata[0] == '[')
  756. {
  757. // Store section name without braces
  758. copyc(section, charsmax(section), linedata[1], ']')
  759.  
  760. // Is this our setting's section?
  761. if (equal(section, setting_section))
  762. break;
  763. }
  764. }
  765.  
  766. // Section not found
  767. if (!equal(section, setting_section))
  768. {
  769. fclose(file)
  770. return false;
  771. }
  772.  
  773. // Set up some vars to hold parsing info
  774. new key[64], current_value[32]
  775.  
  776. // Seek to setting's key
  777. while (!feof(file))
  778. {
  779. // Read one line at a time
  780. fgets(file, linedata, charsmax(linedata))
  781.  
  782. // Replace newlines with a null character to prevent headaches
  783. replace(linedata, charsmax(linedata), "^n", "")
  784.  
  785. // Blank line or comment
  786. if (!linedata[0] || linedata[0] == ';') continue;
  787.  
  788. // Section ended?
  789. if (linedata[0] == '[')
  790. break;
  791.  
  792. // Get key and value
  793. strtok(linedata, key, charsmax(key), current_value, charsmax(current_value), '=')
  794.  
  795. // Trim spaces
  796. trim(key)
  797. trim(current_value)
  798.  
  799. // Is this our setting's key?
  800. if (equal(key, setting_key))
  801. {
  802. static return_value
  803. // Return int by reference
  804. return_value = str_to_num(current_value)
  805.  
  806. // Values succesfully retrieved
  807. fclose(file)
  808. return return_value
  809. }
  810. }
  811.  
  812. // Key not found
  813. fclose(file)
  814. return false;
  815. }
  816.  
  817. stock Setting_Load_StringArray(const filename[], const setting_section[], setting_key[], Array:array_handle)
  818. {
  819. if (strlen(filename) < 1)
  820. {
  821. log_error(AMX_ERR_NATIVE, "[ZD] Can't load settings: empty filename")
  822. return false;
  823. }
  824.  
  825. if (strlen(setting_section) < 1 || strlen(setting_key) < 1)
  826. {
  827. log_error(AMX_ERR_NATIVE, "[ZD] Can't load settings: empty section/key")
  828. return false;
  829. }
  830.  
  831. if (array_handle == Invalid_Array)
  832. {
  833. log_error(AMX_ERR_NATIVE, "[ZD] Array not initialized")
  834. return false;
  835. }
  836.  
  837. // Build customization file path
  838. new path[128]
  839. get_configsdir(path, charsmax(path))
  840. format(path, charsmax(path), "%s/ZombieElimination/%s", path, filename)
  841.  
  842. // File not present
  843. if (!file_exists(path))
  844. {
  845. static DataA[128]; formatex(DataA, sizeof(DataA), "[ZD] Can't load: %s", path)
  846. set_fail_state(DataA)
  847.  
  848. return false;
  849. }
  850.  
  851. // Open customization file for reading
  852. new file = fopen(path, "rt")
  853.  
  854. // File can't be opened
  855. if (!file)
  856. return false;
  857.  
  858. // Set up some vars to hold parsing info
  859. new linedata[1024], section[64]
  860.  
  861. // Seek to setting's section
  862. while (!feof(file))
  863. {
  864. // Read one line at a time
  865. fgets(file, linedata, charsmax(linedata))
  866.  
  867. // Replace newlines with a null character to prevent headaches
  868. replace(linedata, charsmax(linedata), "^n", "")
  869.  
  870. // New section starting
  871. if (linedata[0] == '[')
  872. {
  873. // Store section name without braces
  874. copyc(section, charsmax(section), linedata[1], ']')
  875.  
  876. // Is this our setting's section?
  877. if (equal(section, setting_section))
  878. break;
  879. }
  880. }
  881.  
  882. // Section not found
  883. if (!equal(section, setting_section))
  884. {
  885. fclose(file)
  886. return false;
  887. }
  888.  
  889. // Set up some vars to hold parsing info
  890. new key[64], values[1024], current_value[128]
  891.  
  892. // Seek to setting's key
  893. while (!feof(file))
  894. {
  895. // Read one line at a time
  896. fgets(file, linedata, charsmax(linedata))
  897.  
  898. // Replace newlines with a null character to prevent headaches
  899. replace(linedata, charsmax(linedata), "^n", "")
  900.  
  901. // Blank line or comment
  902. if (!linedata[0] || linedata[0] == ';') continue;
  903.  
  904. // Section ended?
  905. if (linedata[0] == '[')
  906. break;
  907.  
  908. // Get key and values
  909. strtok(linedata, key, charsmax(key), values, charsmax(values), '=')
  910.  
  911. // Trim spaces
  912. trim(key)
  913. trim(values)
  914.  
  915. // Is this our setting's key?
  916. if (equal(key, setting_key))
  917. {
  918. // Parse values
  919. while (values[0] != 0 && strtok(values, current_value, charsmax(current_value), values, charsmax(values), ','))
  920. {
  921. // Trim spaces
  922. trim(current_value)
  923. trim(values)
  924.  
  925. // Add to array
  926. ArrayPushString(array_handle, current_value)
  927. }
  928.  
  929. // Values succesfully retrieved
  930. fclose(file)
  931. return true;
  932. }
  933. }
  934.  
  935. // Key not found
  936. fclose(file)
  937. return false;
  938. }
  939.  
  940. stock Setting_Load_String(const filename[], const setting_section[], setting_key[], return_string[], string_size)
  941. {
  942. if (strlen(filename) < 1)
  943. {
  944. log_error(AMX_ERR_NATIVE, "[ZD] Can't load settings: empty filename")
  945. return false;
  946. }
  947.  
  948. if (strlen(setting_section) < 1 || strlen(setting_key) < 1)
  949. {
  950. log_error(AMX_ERR_NATIVE, "[ZD] Can't load settings: empty section/key")
  951. return false;
  952. }
  953.  
  954. // Build customization file path
  955. new path[128]
  956. get_configsdir(path, charsmax(path))
  957. format(path, charsmax(path), "%s/ZombieElimination/%s", path, filename)
  958.  
  959. // File not present
  960. if (!file_exists(path))
  961. {
  962. static DataA[128]; formatex(DataA, sizeof(DataA), "[ZD] Can't load: %s", path)
  963. set_fail_state(DataA)
  964.  
  965. return false;
  966. }
  967.  
  968. // Open customization file for reading
  969. new file = fopen(path, "rt")
  970.  
  971. // File can't be opened
  972. if (!file)
  973. return false;
  974.  
  975. // Set up some vars to hold parsing info
  976. new linedata[1024], section[64]
  977.  
  978. // Seek to setting's section
  979. while (!feof(file))
  980. {
  981. // Read one line at a time
  982. fgets(file, linedata, charsmax(linedata))
  983.  
  984. // Replace newlines with a null character to prevent headaches
  985. replace(linedata, charsmax(linedata), "^n", "")
  986.  
  987. // New section starting
  988. if (linedata[0] == '[')
  989. {
  990. // Store section name without braces
  991. copyc(section, charsmax(section), linedata[1], ']')
  992.  
  993. // Is this our setting's section?
  994. if (equal(section, setting_section))
  995. break;
  996. }
  997. }
  998.  
  999. // Section not found
  1000. if (!equal(section, setting_section))
  1001. {
  1002. fclose(file)
  1003. return false;
  1004. }
  1005.  
  1006. // Set up some vars to hold parsing info
  1007. new key[64], current_value[128]
  1008.  
  1009. // Seek to setting's key
  1010. while (!feof(file))
  1011. {
  1012. // Read one line at a time
  1013. fgets(file, linedata, charsmax(linedata))
  1014.  
  1015. // Replace newlines with a null character to prevent headaches
  1016. replace(linedata, charsmax(linedata), "^n", "")
  1017.  
  1018. // Blank line or comment
  1019. if (!linedata[0] || linedata[0] == ';') continue;
  1020.  
  1021. // Section ended?
  1022. if (linedata[0] == '[')
  1023. break;
  1024.  
  1025. // Get key and value
  1026. strtok(linedata, key, charsmax(key), current_value, charsmax(current_value), '=')
  1027.  
  1028. // Trim spaces
  1029. trim(key)
  1030. trim(current_value)
  1031.  
  1032. // Is this our setting's key?
  1033. if (equal(key, setting_key))
  1034. {
  1035. formatex(return_string, string_size, "%s", current_value)
  1036.  
  1037. // Values succesfully retrieved
  1038. fclose(file)
  1039. return true;
  1040. }
  1041. }
  1042.  
  1043. // Key not found
  1044. fclose(file)
  1045. return false;
  1046. }
  1047.  
  1048. stock Set_WeaponAnim(id, anim)
  1049. {
  1050. set_pev(id, pev_weaponanim, anim)
  1051.  
  1052. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
  1053. write_byte(anim)
  1054. write_byte(0)
  1055. message_end()
  1056. }
  1057.  
  1058. public Set_EntAnim(ent, anim, Float:framerate, resetframe)
  1059. {
  1060. if(!pev_valid(ent))
  1061. return
  1062.  
  1063. if(!resetframe)
  1064. {
  1065. if(pev(ent, pev_sequence) != anim)
  1066. {
  1067. set_pev(ent, pev_animtime, get_gametime())
  1068. set_pev(ent, pev_framerate, framerate)
  1069. set_pev(ent, pev_sequence, anim)
  1070. }
  1071. } else {
  1072. set_pev(ent, pev_animtime, get_gametime())
  1073. set_pev(ent, pev_framerate, framerate)
  1074. set_pev(ent, pev_sequence, anim)
  1075. }
  1076. }
  1077.  
  1078. stock hook_ent2(ent, Float:VicOrigin[3], Float:speed)
  1079. {
  1080. if(!pev_valid(ent))
  1081. return
  1082.  
  1083. static Float:fl_Velocity[3], Float:EntOrigin[3], Float:distance_f, Float:fl_Time
  1084.  
  1085. pev(ent, pev_origin, EntOrigin)
  1086.  
  1087. distance_f = get_distance_f(EntOrigin, VicOrigin)
  1088. fl_Time = distance_f / speed
  1089.  
  1090. fl_Velocity[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
  1091. fl_Velocity[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
  1092. fl_Velocity[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
  1093.  
  1094. set_pev(ent, pev_velocity, fl_Velocity)
  1095. }
  1096.  
  1097. stock Get_SpeedVector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  1098. {
  1099. new_velocity[0] = origin2[0] - origin1[0]
  1100. new_velocity[1] = origin2[1] - origin1[1]
  1101. new_velocity[2] = origin2[2] - origin1[2]
  1102. new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  1103. new_velocity[0] *= (num * 2.0)
  1104. new_velocity[1] *= (num * 2.0)
  1105. new_velocity[2] *= (num / 2.0)
  1106. }
  1107.  
  1108. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  1109. {
  1110. static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  1111.  
  1112. pev(id, pev_origin, vOrigin)
  1113. pev(id, pev_view_ofs, vUp) //for player
  1114. xs_vec_add(vOrigin, vUp, vOrigin)
  1115. pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  1116.  
  1117. angle_vector(vAngle,ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  1118. angle_vector(vAngle,ANGLEVECTOR_RIGHT, vRight)
  1119. angle_vector(vAngle,ANGLEVECTOR_UP, vUp)
  1120.  
  1121. vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  1122. vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  1123. vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  1124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement