Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.00 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <fakemeta_util>
  5. #include <hamsandwich>
  6. #include <cstrike>
  7. #include <zombieplague>
  8.  
  9. #define PLUGIN "[CSO] PlasmaGun"
  10. #define VERSION "1.0"
  11. #define AUTHOR "Dias Leon"
  12.  
  13. // ================= Config =================
  14. // ZP Config
  15. #define COST 40
  16.  
  17. // Level 1 Config
  18. #define V_MODEL "models/hvz_extras/v_plasmagun.mdl"
  19. #define P_MODEL "models/hvz_extras/p_plasmagun.mdl"
  20. #define W_MODEL "models/hvz_extras/w_plasmagun.mdl"
  21.  
  22. new const WeaponSounds[7][] =
  23. {
  24. "weapons/plasmagun-1.wav",
  25. "weapons/plasmagun_exp.wav",
  26. "weapons/plasmagun_idle.wav",
  27. "weapons/plasmagun_draw.wav",
  28. "weapons/plasmagun_clipin1.wav",
  29. "weapons/plasmagun_clipin2.wav",
  30. "weapons/plasmagun_clipout.wav"
  31. }
  32.  
  33. new const WeaponResources[3][] =
  34. {
  35. "sprites/weapon_plasmagun.txt",
  36. "sprites/640hud3_2.spr",
  37. "sprites/640hud91_2.spr"
  38. }
  39.  
  40. new const WeaponFiles[2][] =
  41. {
  42. "sprites/plasmaball.spr",
  43. "sprites/plasmabomb.spr"
  44. }
  45.  
  46. new const MuzzleFlash[] = "sprites/muzzleflash27.spr"
  47.  
  48. // Level 2 Config
  49. #define DAMAGE 50
  50. #define CLIP 45
  51. #define BPAMMO 250
  52. #define SPEED 1.5
  53. #define RECOIL 0.75
  54.  
  55. #define PLASMA_SPEED 1000.0
  56. #define PLASMA_RADIUS 100.0
  57.  
  58. // Level 3 Config
  59. #define CSW_PLASMA CSW_AK47
  60. #define weapon_plasma "weapon_ak47"
  61.  
  62. #define WEAPON_EVENT "events/ak47.sc"
  63. #define WEAPON_ANIMEXT "carbine"
  64. #define WEAPON_OLD_WMODEL "models/w_ak47.mdl"
  65. #define WEAPON_SECRETCODE 1946
  66.  
  67. #define WEAPONANIM_SHOOT random_num(3, 5)
  68. #define WEAPONANIM_RELOAD 1
  69.  
  70. #define WEAPONTIME_DRAW 0.75
  71. #define WEAPONTIME_RELOAD 3.5
  72.  
  73. // Level 4 Config
  74. #define PLASMABALL_CLASSNAME "plasmaball"
  75. // ============== End of Config ==============
  76.  
  77. // MACROS
  78. #define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
  79. #define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
  80. #define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))
  81.  
  82. enum
  83. {
  84. TEAM_T = 1,
  85. TEAM_CT
  86. }
  87.  
  88. // Vars
  89. new g_PlasmaGun
  90. new g_Had_Plasma, g_WeaponClip[33], Float:g_WeaponRecoil[33][3]
  91. new g_Msg_WeaponList, g_Msg_CurWeapon, g_Msg_AmmoX
  92. new g_MuzzleFlash_SprId, g_PlasmaExp_SprId, g_weapon_event, g_HamBot, g_MaxPlayers
  93.  
  94. public plugin_init()
  95. {
  96. register_plugin(PLUGIN, VERSION, AUTHOR)
  97.  
  98. register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
  99.  
  100. register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  101. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  102. register_forward(FM_SetModel, "fw_SetModel")
  103.  
  104. register_think(PLASMABALL_CLASSNAME, "fw_Think_Plasma")
  105. register_touch(PLASMABALL_CLASSNAME, "*", "fw_Touch_Plasma")
  106.  
  107. RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack_World")
  108. RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Player")
  109. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_plasma, "fw_Weapon_PrimaryAttack")
  110. RegisterHam(Ham_Weapon_PrimaryAttack, weapon_plasma, "fw_Weapon_PrimaryAttack_Post", 1)
  111. RegisterHam(Ham_Item_Deploy, weapon_plasma, "fw_Item_Deploy_Post", 1)
  112. RegisterHam(Ham_Item_PostFrame, weapon_plasma, "fw_Item_PostFrame")
  113. RegisterHam(Ham_Weapon_Reload, weapon_plasma, "fw_Weapon_Reload")
  114. RegisterHam(Ham_Weapon_Reload, weapon_plasma, "fw_Weapon_Reload_Post", 1)
  115. RegisterHam(Ham_Item_AddToPlayer, weapon_plasma, "fw_Item_AddToPlayer_Post", 1)
  116.  
  117. g_Msg_WeaponList = get_user_msgid("WeaponList")
  118. g_Msg_CurWeapon = get_user_msgid("CurWeapon")
  119. g_Msg_AmmoX = get_user_msgid("AmmoX")
  120. g_MaxPlayers = get_maxplayers()
  121.  
  122. g_PlasmaGun = zp_register_extra_item("Винтовка Plasma Gun", COST, ZP_TEAM_HUMAN)
  123.  
  124. //register_clcmd("admin_get_plasmagun", "Get_Plasma", ADMIN_KICK)
  125. register_clcmd("weapon_plasmagun", "Hook_WeaponHud")
  126.  
  127.  
  128. RegisterHam(Ham_Spawn,"player","abc",true);
  129. }
  130.  
  131. public plugin_precache()
  132. {
  133. engfunc(EngFunc_PrecacheModel, V_MODEL)
  134. engfunc(EngFunc_PrecacheModel, P_MODEL)
  135. engfunc(EngFunc_PrecacheModel, W_MODEL)
  136.  
  137. new i
  138. for(i = 0; i < sizeof(WeaponSounds); i++)
  139. engfunc(EngFunc_PrecacheSound, WeaponSounds[i])
  140. for(i = 0; i < sizeof(WeaponResources); i++)
  141. {
  142. if(i == 0) engfunc(EngFunc_PrecacheGeneric, WeaponResources[i])
  143. else engfunc(EngFunc_PrecacheModel, WeaponResources[i])
  144. }
  145. for(i = 0; i < sizeof(WeaponFiles); i++)
  146. {
  147. if(i == 1) g_PlasmaExp_SprId = engfunc(EngFunc_PrecacheModel, WeaponFiles[i])
  148. else engfunc(EngFunc_PrecacheModel, WeaponFiles[i])
  149. }
  150.  
  151. g_MuzzleFlash_SprId = engfunc(EngFunc_PrecacheModel, MuzzleFlash)
  152. register_forward(FM_PrecacheEvent, "fw_PrecacheEvent_Post", 1)
  153. }
  154.  
  155. public fw_PrecacheEvent_Post(type, const name[])
  156. {
  157. if(equal(WEAPON_EVENT, name)) g_weapon_event = get_orig_retval()
  158. }
  159.  
  160. public client_putinserver(id)
  161. {
  162. if(!g_HamBot && is_user_bot(id))
  163. {
  164. g_HamBot = 1
  165. set_task(0.1, "Do_RegisterHam", id)
  166. }
  167. Remove_Plasma(id);
  168. }
  169.  
  170. public Do_RegisterHam(id)
  171. {
  172. RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack_Player")
  173. }
  174.  
  175. public zp_extra_item_selected(id, ItemID)
  176. {
  177. if(ItemID == g_PlasmaGun) Get_Plasma(id)
  178. }
  179.  
  180. public zp_user_infected_post(id) Remove_Plasma(id)
  181. //public zp_user_humanized_post(id) Remove_Plasma(id)
  182.  
  183. public Get_Plasma(id)
  184. {
  185. if(!is_user_alive(id))
  186. return
  187.  
  188. drop_user_slot(id, 1);
  189.  
  190. Set_BitVar(g_Had_Plasma, id)
  191. fm_give_item(id, weapon_plasma)
  192.  
  193. // Set Weapon
  194. engclient_cmd(id, weapon_plasma)
  195.  
  196. set_pev(id, pev_viewmodel2, V_MODEL)
  197. set_pev(id, pev_weaponmodel2, P_MODEL)
  198.  
  199. set_pdata_string(id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)
  200.  
  201. // Set Weapon Base
  202. static Ent; Ent = fm_get_user_weapon_entity(id, CSW_PLASMA)
  203. if(!pev_valid(Ent)) return
  204.  
  205. cs_set_weapon_ammo(Ent, CLIP)
  206. cs_set_user_bpammo(id, CSW_PLASMA, BPAMMO)
  207.  
  208. Update_AmmoHud(id, CSW_PLASMA, CLIP, BPAMMO)
  209. }
  210.  
  211. public Remove_Plasma(id)
  212. {
  213. UnSet_BitVar(g_Had_Plasma, id)
  214. }
  215.  
  216. public Hook_WeaponHud(id)
  217. {
  218. engclient_cmd(id, weapon_plasma)
  219. return PLUGIN_HANDLED
  220. }
  221.  
  222. public Event_NewRound() remove_entity_name(PLASMABALL_CLASSNAME)
  223.  
  224. public fw_Think_Plasma(Ent)
  225. {
  226. if(!pev_valid(Ent))
  227. return
  228.  
  229. static Float:RenderAmt; pev(Ent, pev_renderamt, RenderAmt)
  230.  
  231. RenderAmt += 50.0
  232. RenderAmt = float(clamp(floatround(RenderAmt), 0, 255))
  233.  
  234. set_pev(Ent, pev_renderamt, RenderAmt)
  235. set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  236. }
  237.  
  238. public fw_Touch_Plasma(Ent, Id)
  239. {
  240. if(!pev_valid(Ent))
  241. return
  242. if(pev(Ent, pev_movetype) == MOVETYPE_NONE)
  243. return
  244.  
  245. // Exp Sprite
  246. static Float:Origin[3], TE_FLAG
  247. pev(Ent, pev_origin, Origin)
  248.  
  249. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  250. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  251. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  252.  
  253. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  254. write_byte(TE_EXPLOSION)
  255. engfunc(EngFunc_WriteCoord, Origin[0])
  256. engfunc(EngFunc_WriteCoord, Origin[1])
  257. engfunc(EngFunc_WriteCoord, Origin[2])
  258. write_short(g_PlasmaExp_SprId)
  259. write_byte(7)
  260. write_byte(30)
  261. write_byte(TE_FLAG)
  262. message_end()
  263.  
  264. // Exp Sound
  265. emit_sound(Ent, CHAN_BODY, WeaponSounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  266.  
  267. // Damage
  268. Damage_Plasma(Ent, Id)
  269.  
  270. // Remove Ent
  271. set_pev(Ent, pev_movetype, MOVETYPE_NONE)
  272. set_task(0.1, "Remove_PlasmaBall", Ent)
  273. }
  274.  
  275. public Damage_Plasma(Ent, Id)
  276. {
  277. static Owner; Owner = pev(Ent, pev_iuser1)
  278. set_pev(Ent,pev_classname,"weapon_ump45")
  279. static Attacker;
  280. if(!is_user_alive(Owner))
  281. {
  282. Attacker = 0
  283. return
  284. } else Attacker = Owner
  285.  
  286. if(is_user_alive(Id) && zp_get_user_zombie(Id))
  287. ExecuteHamB(Ham_TakeDamage, Id, Ent, Attacker, float(DAMAGE), DMG_ACID)
  288.  
  289. for(new i = 1; i <= g_MaxPlayers; i++)
  290. {
  291. if(i==Id)continue;
  292. if(!is_user_alive(i))
  293. continue
  294. if(entity_range(i, Ent) > PLASMA_RADIUS)
  295. continue
  296. if(!zp_get_user_zombie(i))
  297. continue
  298.  
  299. ExecuteHamB(Ham_TakeDamage, i, Ent, Attacker, float(DAMAGE) / random_float(1.25, 1.5), DMG_ACID)
  300. }
  301. }
  302.  
  303. public Remove_PlasmaBall(Ent)
  304. {
  305. if(!pev_valid(Ent)) return
  306. engfunc(EngFunc_RemoveEntity, Ent)
  307. }
  308.  
  309. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  310. {
  311. if(!is_user_alive(id))
  312. return FMRES_IGNORED
  313. if(get_user_weapon(id) == CSW_PLASMA && Get_BitVar(g_Had_Plasma, id))
  314. set_cd(cd_handle, CD_flNextAttack, get_gametime() + 0.001)
  315.  
  316. return FMRES_HANDLED
  317. }
  318.  
  319. public fw_PlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
  320. {
  321. if (!is_user_connected(invoker))
  322. return FMRES_IGNORED
  323. if(get_user_weapon(invoker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, invoker))
  324. return FMRES_IGNORED
  325. if(eventid != g_weapon_event)
  326. return FMRES_IGNORED
  327.  
  328. engfunc(EngFunc_PlaybackEvent, flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
  329.  
  330. return FMRES_SUPERCEDE
  331. }
  332.  
  333. public fw_SetModel(entity, model[])
  334. {
  335. if(!pev_valid(entity))
  336. return FMRES_IGNORED
  337.  
  338. static Classname[32]
  339. pev(entity, pev_classname, Classname, sizeof(Classname))
  340.  
  341. if(!equal(Classname, "weaponbox"))
  342. return FMRES_IGNORED
  343.  
  344. static iOwner
  345. iOwner = pev(entity, pev_owner)
  346.  
  347. if(equal(model, WEAPON_OLD_WMODEL))
  348. {
  349. static weapon; weapon = fm_find_ent_by_owner(-1, weapon_plasma, entity)
  350.  
  351. if(!pev_valid(weapon))
  352. return FMRES_IGNORED;
  353.  
  354. if(Get_BitVar(g_Had_Plasma, iOwner))
  355. {
  356. Remove_Plasma(iOwner)
  357.  
  358. set_pev(weapon, pev_impulse, WEAPON_SECRETCODE)
  359. engfunc(EngFunc_SetModel, entity, W_MODEL)
  360.  
  361. return FMRES_SUPERCEDE
  362. }
  363. }
  364.  
  365. return FMRES_IGNORED;
  366. }
  367.  
  368. public fw_TraceAttack_World(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  369. {
  370. if(!is_user_connected(Attacker))
  371. return HAM_IGNORED
  372. if(get_user_weapon(Attacker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, Attacker))
  373. return HAM_IGNORED
  374.  
  375. return HAM_SUPERCEDE
  376. }
  377.  
  378. public fw_TraceAttack_Player(Victim, Attacker, Float:Damage, Float:Direction[3], Ptr, DamageBits)
  379. {
  380. if(!is_user_connected(Attacker))
  381. return HAM_IGNORED
  382. if(get_user_weapon(Attacker) != CSW_PLASMA || !Get_BitVar(g_Had_Plasma, Attacker))
  383. return HAM_IGNORED
  384.  
  385. return HAM_SUPERCEDE
  386. }
  387.  
  388. public fw_Weapon_PrimaryAttack(Ent)
  389. {
  390. if(!pev_valid(Ent))
  391. return
  392.  
  393. static Id; Id = pev(Ent, pev_owner)
  394. if(!Get_BitVar(g_Had_Plasma, Id))
  395. return
  396. static Ammo; Ammo = cs_get_weapon_ammo(Ent)
  397. if(Ammo <= 0) return
  398.  
  399. // Weapon Shoot
  400. Set_Weapon_Anim(Id, WEAPONANIM_SHOOT)
  401. emit_sound(Id, CHAN_WEAPON, WeaponSounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  402.  
  403. // MuzzleFlash & Effect
  404. Make_Muzzleflash(Id)
  405.  
  406. // Create Plasma Effect
  407. Create_PlasmaBall(Id)
  408.  
  409. // Speed & Recoil
  410. pev(Ent, pev_punchangle, g_WeaponRecoil[Id])
  411. }
  412.  
  413. public fw_Weapon_PrimaryAttack_Post(Ent)
  414. {
  415. if(!pev_valid(Ent))
  416. return
  417.  
  418. static Id; Id = pev(Ent, pev_owner)
  419. if(!Get_BitVar(g_Had_Plasma, Id))
  420. return
  421. static Ammo; Ammo = cs_get_weapon_ammo(Ent)
  422. if(Ammo <= 0) return
  423.  
  424. // Speed & Recoil
  425. set_pdata_float(Ent, 46, get_pdata_float(Ent, 46, 4) * SPEED, 4)
  426.  
  427. static Float:Push[3]; pev(Id, pev_punchangle, Push)
  428.  
  429. xs_vec_sub(Push, g_WeaponRecoil[Id], Push)
  430. xs_vec_mul_scalar(Push, RECOIL, Push)
  431. xs_vec_add(Push, g_WeaponRecoil[Id], Push)
  432.  
  433. set_pev(Id, pev_punchangle, Push)
  434. }
  435.  
  436. public fw_Item_Deploy_Post(Ent)
  437. {
  438. if(!pev_valid(Ent))
  439. return
  440.  
  441. static Id; Id = pev(Ent, pev_owner)
  442. if(!Get_BitVar(g_Had_Plasma, Id))
  443. return
  444.  
  445. set_pev(Id, pev_viewmodel2, V_MODEL)
  446. set_pev(Id, pev_weaponmodel2, P_MODEL)
  447.  
  448. set_pdata_string(Id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)
  449.  
  450. // Set Draw
  451. Set_Player_NextAttack(Id, WEAPONTIME_DRAW)
  452. Set_Weapon_TimeIdle(Id, CSW_PLASMA, WEAPONTIME_DRAW)
  453. }
  454.  
  455. public fw_Item_PostFrame(Ent)
  456. {
  457. if(!pev_valid(Ent))
  458. return
  459.  
  460. static Id; Id = pev(Ent, pev_owner)
  461. if(!Get_BitVar(g_Had_Plasma, Id))
  462. return
  463.  
  464. static Float:flNextAttack; flNextAttack = get_pdata_float(Id, 83, 5)
  465. static bpammo; bpammo = cs_get_user_bpammo(Id, CSW_PLASMA)
  466. static iClip; iClip = get_pdata_int(Ent, 51, 4)
  467.  
  468. if(get_pdata_int(Ent, 54, 4) && flNextAttack <= 0.0)
  469. {
  470. static temp1; temp1 = min(CLIP - iClip, bpammo)
  471.  
  472. set_pdata_int(Ent, 51, iClip + temp1, 4)
  473. cs_set_user_bpammo(Id, CSW_PLASMA, bpammo - temp1)
  474.  
  475. set_pdata_int(Ent, 54, 0, 4)
  476. }
  477. }
  478.  
  479. public fw_Weapon_Reload(Ent)
  480. {
  481. if(!pev_valid(Ent))
  482. return HAM_IGNORED
  483.  
  484. static Id; Id = pev(Ent, pev_owner)
  485. if(!Get_BitVar(g_Had_Plasma, Id))
  486. return HAM_IGNORED
  487.  
  488. g_WeaponClip[Id] = -1
  489.  
  490. static bpammo; bpammo = cs_get_user_bpammo(Id, CSW_PLASMA)
  491. static iClip; iClip = get_pdata_int(Ent, 51, 4)
  492.  
  493. if(bpammo <= 0) return HAM_SUPERCEDE
  494. if(iClip >= CLIP) return HAM_SUPERCEDE
  495.  
  496. g_WeaponClip[Id] = iClip
  497. return HAM_IGNORED
  498. }
  499.  
  500. public fw_Weapon_Reload_Post(Ent)
  501. {
  502. if(!pev_valid(Ent))
  503. return
  504.  
  505. static Id; Id = pev(Ent, pev_owner)
  506. if(!Get_BitVar(g_Had_Plasma, Id))
  507. return
  508. if(g_WeaponClip[Id] == -1)
  509. return
  510.  
  511. set_pdata_int(Ent, 51, g_WeaponClip[Id], 4)
  512. set_pdata_int(Ent, 54, 1, 4)
  513.  
  514. Set_Weapon_Anim(Id, WEAPONANIM_RELOAD)
  515. set_pdata_float(Id, 83, WEAPONTIME_RELOAD, 5)
  516. }
  517.  
  518. public fw_Item_AddToPlayer_Post(Ent, Id)
  519. {
  520. if(!pev_valid(Ent))
  521. return
  522.  
  523. if(pev(Ent, pev_impulse) == WEAPON_SECRETCODE)
  524. {
  525. Set_BitVar(g_Had_Plasma, Id)
  526. set_pev(Ent, pev_impulse, 0)
  527.  
  528. set_task(0.01, "AddToPlayer_Delay", Id)
  529.  
  530. message_begin(MSG_ONE_UNRELIABLE, g_Msg_WeaponList, _, Id)
  531. write_string(Get_BitVar(g_Had_Plasma, Id) ? "weapon_plasmagun" : "weapon_ak47")
  532. write_byte(2)
  533. write_byte(Get_BitVar(g_Had_Plasma, Id) ? 200 : 90)
  534. write_byte(-1)
  535. write_byte(-1)
  536. write_byte(0)
  537. write_byte(1)
  538. write_byte(Get_BitVar(g_Had_Plasma, Id) ? CSW_PLASMA : CSW_AK47)
  539. write_byte(0)
  540. message_end()
  541. }
  542. else if(pev(Ent, pev_impulse) == 0)
  543. {
  544. set_task(0.01, "hud", Id)
  545. message_begin(MSG_ONE_UNRELIABLE, g_Msg_WeaponList, _, Id)
  546. write_string(Get_BitVar(g_Had_Plasma, Id) ? "weapon_plasmagun" : "weapon_ak47")
  547. write_byte(2)
  548. write_byte(Get_BitVar(g_Had_Plasma, Id) ? 200 : 90)
  549. write_byte(-1)
  550. write_byte(-1)
  551. write_byte(0)
  552. write_byte(1)
  553. write_byte(Get_BitVar(g_Had_Plasma, Id) ? CSW_PLASMA : CSW_AK47)
  554. write_byte(0)
  555. message_end()
  556. }
  557.  
  558. return
  559. }
  560.  
  561. public AddToPlayer_Delay(Id)
  562. {
  563. set_pev(Id, pev_viewmodel2, V_MODEL)
  564. set_pev(Id, pev_weaponmodel2, P_MODEL)
  565.  
  566. set_pdata_string(Id, (492) * 4, WEAPON_ANIMEXT, -1 , 20)
  567. Update_AmmoHud(id, CSW_PLASMA, CLIP, BPAMMO)
  568. }
  569. public hud(Id){
  570. Update_AmmoHud(id, CSW_PLASMA, CLIP, BPAMMO)
  571. }
  572. public Create_PlasmaBall(id)
  573. {
  574. static Float:StartOrigin[3], Float:TargetOrigin[3], Float:MyVelocity[3], Float:VecLength
  575.  
  576. get_position(id, 48.0, 10.0, -5.0, StartOrigin)
  577. get_position(id, 1024.0, 0.0, 0.0, TargetOrigin)
  578.  
  579. pev(id, pev_velocity, MyVelocity)
  580. VecLength = vector_length(MyVelocity)
  581.  
  582. if(VecLength)
  583. {
  584. TargetOrigin[0] += random_float(-16.0, 16.0); TargetOrigin[1] += random_float(-16.0, 16.0); TargetOrigin[2] += random_float(-16.0, 16.0)
  585. } else {
  586. TargetOrigin[0] += random_float(-8.0, 8.0); TargetOrigin[1] += random_float(-8.0, 8.0); TargetOrigin[2] += random_float(-8.0, 8.0)
  587. }
  588.  
  589. static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
  590. if(!pev_valid(Ent)) return
  591.  
  592. // Set info for ent
  593. set_pev(Ent, pev_movetype, MOVETYPE_FLY)
  594. set_pev(Ent, pev_rendermode, kRenderTransAdd)
  595. set_pev(Ent, pev_renderamt, 10.0)
  596. set_pev(Ent, pev_iuser1, id) // Better than pev_owner
  597. set_pev(Ent, pev_iuser2, Get_SpecialTeam(id, cs_get_user_team(id)))
  598. set_pev(Ent, pev_fuser1, get_gametime() + 3.0)
  599. set_pev(Ent, pev_scale, random_float(0.1, 0.25))
  600. set_pev(Ent, pev_nextthink, halflife_time() + 0.1)
  601.  
  602. entity_set_string(Ent, EV_SZ_classname, PLASMABALL_CLASSNAME)
  603. engfunc(EngFunc_SetModel, Ent, WeaponFiles[0])
  604. set_pev(Ent, pev_mins, Float:{-1.0, -1.0, -1.0})
  605. set_pev(Ent, pev_maxs, Float:{1.0, 1.0, 1.0})
  606. set_pev(Ent, pev_origin, StartOrigin)
  607. set_pev(Ent, pev_gravity, 0.01)
  608. set_pev(Ent, pev_solid, SOLID_TRIGGER)
  609. set_pev(Ent, pev_frame, 0.0)
  610.  
  611. static Float:Velocity[3]
  612. get_speed_vector(StartOrigin, TargetOrigin, PLASMA_SPEED, Velocity)
  613. set_pev(Ent, pev_velocity, Velocity)
  614. }
  615.  
  616. public Make_Muzzleflash(id)
  617. {
  618. static Float:Origin[3], TE_FLAG
  619. get_position(id, 32.0, 6.0, -15.0, Origin)
  620.  
  621. TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
  622. TE_FLAG |= TE_EXPLFLAG_NOSOUND
  623. TE_FLAG |= TE_EXPLFLAG_NOPARTICLES
  624.  
  625. engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, Origin, id)
  626. write_byte(TE_EXPLOSION)
  627. engfunc(EngFunc_WriteCoord, Origin[0])
  628. engfunc(EngFunc_WriteCoord, Origin[1])
  629. engfunc(EngFunc_WriteCoord, Origin[2])
  630. write_short(g_MuzzleFlash_SprId)
  631. write_byte(2)
  632. write_byte(30)
  633. write_byte(TE_FLAG)
  634. message_end()
  635. }
  636.  
  637. public Update_AmmoHud(id, CSWID, Ammo, BpAmmo)
  638. {
  639. message_begin(MSG_ONE_UNRELIABLE, g_Msg_CurWeapon, _, id)
  640. write_byte(1)
  641. write_byte(CSWID)
  642. write_byte(Ammo)
  643. message_end()
  644.  
  645. message_begin(MSG_ONE_UNRELIABLE, g_Msg_AmmoX, _, id)
  646. write_byte(10)
  647. write_byte(BpAmmo)
  648. message_end()
  649. }
  650.  
  651. public Get_SpecialTeam(Ent, CsTeams:Team)
  652. {
  653. if(Team == CS_TEAM_T) return TEAM_T
  654. else if(Team == CS_TEAM_CT) return TEAM_CT
  655.  
  656. return 0
  657. }
  658.  
  659. public CsTeams:Get_PlasmaTeam(Ent)
  660. {
  661. if(pev(Ent, pev_iuser2) == TEAM_T) return CS_TEAM_T
  662. else if(pev(Ent, pev_iuser2) == TEAM_CT) return CS_TEAM_CT
  663.  
  664. return CS_TEAM_UNASSIGNED
  665. }
  666.  
  667. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  668. {
  669. new_velocity[0] = origin2[0] - origin1[0]
  670. new_velocity[1] = origin2[1] - origin1[1]
  671. new_velocity[2] = origin2[2] - origin1[2]
  672. static Float:num; num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  673. new_velocity[0] *= num
  674. new_velocity[1] *= num
  675. new_velocity[2] *= num
  676.  
  677. return 1;
  678. }
  679.  
  680. stock Set_Weapon_TimeIdle(id, WeaponId, Float:TimeIdle)
  681. {
  682. static Ent; Ent = fm_get_user_weapon_entity(id, WeaponId)
  683. if(!pev_valid(Ent)) return
  684.  
  685. set_pdata_float(Ent, 46, TimeIdle, 4)
  686. set_pdata_float(Ent, 47, TimeIdle, 4)
  687. set_pdata_float(Ent, 48, TimeIdle + 0.5, 4)
  688. }
  689.  
  690. stock Set_Player_NextAttack(id, Float:nexttime)
  691. {
  692. set_pdata_float(id, 83, nexttime, 5)
  693. }
  694.  
  695. stock Set_Weapon_Anim(id, WeaponAnim)
  696. {
  697. set_pev(id, pev_weaponanim, WeaponAnim)
  698.  
  699. message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id)
  700. write_byte(WeaponAnim)
  701. write_byte(pev(id, pev_body))
  702. message_end()
  703. }
  704.  
  705. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  706. {
  707. static Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  708.  
  709. pev(id, pev_origin, vOrigin)
  710. pev(id, pev_view_ofs, vUp) //for player
  711. xs_vec_add(vOrigin, vUp, vOrigin)
  712. pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  713.  
  714. angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  715. angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  716. angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  717.  
  718. vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  719. vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  720. vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  721. }
  722. // CBasePlayerItem
  723. #define m_pPlayer 41
  724. #define m_pNext 42
  725. #define m_iId 43
  726.  
  727. #define m_rgpPlayerItems_CBasePlayer 367
  728.  
  729. stock drop_user_slot(const iPlayer, const iSlot) {
  730. new iEntity, iNext, szWeaponName[32];
  731. iEntity = get_pdata_cbase(iPlayer, m_rgpPlayerItems_CBasePlayer + iSlot, 5);
  732. if(iEntity > 0) {
  733. do{
  734. iNext = get_pdata_cbase(iEntity, m_pNext, 4);
  735. if(get_weaponname(get_pdata_int(iEntity, m_iId, 4), szWeaponName, charsmax(szWeaponName))) {
  736. engclient_cmd(iPlayer, "drop", szWeaponName);
  737. }
  738. } while(( iEntity = iNext) > 0);
  739. }
  740. }
  741.  
  742. stock hasweapon(const iPlayer, const iSlot,const iCSW) {
  743. new iEntity, iNext, szWeaponName[32];
  744. iEntity = get_pdata_cbase(iPlayer, m_rgpPlayerItems_CBasePlayer + iSlot, 5);
  745. if(iEntity > 0) {
  746. do{
  747. iNext = get_pdata_cbase(iEntity, m_pNext, 4);
  748. if(get_pdata_int(iEntity, m_iId, 4)==iCSW) {
  749. return true;
  750. }
  751. } while(( iEntity = iNext) > 0);
  752. }
  753. return false
  754. }
  755. public abc(id){
  756. if(Get_BitVar(g_Had_Plasma, id)&&!hasweapon(id,1,CSW_PLASMA))
  757. UnSet_BitVar(g_Had_Plasma, id)
  758. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement