Advertisement
Guest User

lm

a guest
Dec 10th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.70 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <xs>
  5. #include <zombie_plague_special>
  6. #include <engine>
  7.  
  8. #if defined BIOHAZARD_SUPPORT
  9. #include <biohazard>
  10. #endif
  11.  
  12. #if defined UL_MONEY_SUPPORT
  13. #include <money_ul>
  14. #endif
  15.  
  16.  
  17. #if AMXX_VERSION_NUM < 180
  18. #assert AMX Mod X v1.8.0 or greater library required!
  19. #endif
  20.  
  21. #if defined BIOHAZARD_SUPPORT
  22. #define PLUGIN "LTM for BIOHAZARD"
  23. #define VERSION "+1.4"
  24. #else
  25. #define PLUGIN "Laser/Tripmine Entity"
  26. #define VERSION "2.3"
  27. #endif
  28. #define AUTHOR "SandStriker"
  29.  
  30. #define RemoveEntity(%1) engfunc(EngFunc_RemoveEntity,%1)
  31. //#define ACCESSLEVEL ADMIN_LEVEL_H
  32. #define TASK_PLANT 15100
  33. #define TASK_RESET 15500
  34. #define TASK_RELEASE 15900
  35.  
  36. #define LASERMINE_TEAM pev_iuser1//EV_INT_iuser1
  37. #define LASERMINE_OWNER pev_iuser2 //EV_INT_iuser3
  38. #define LASERMINE_STEP pev_iuser3
  39. #define LASERMINE_HITING pev_iuser4
  40. #define LASERMINE_COUNT pev_fuser1
  41.  
  42. #define LASERMINE_POWERUP pev_fuser2
  43. #define LASERMINE_BEAMTHINK pev_fuser3
  44.  
  45. #define LASERMINE_BEAMENDPOINT pev_vuser1
  46. #define MAX_MINES 10
  47. #define MODE_LASERMINE 0
  48. #define OFFSET_TEAM 114
  49. #define OFFSET_MONEY 115
  50. #define OFFSET_DEATH 444
  51.  
  52. #define cs_get_user_team(%1) CsTeams:get_offset_value(%1,OFFSET_TEAM)
  53. #define cs_get_user_deaths(%1) get_offset_value(%1,OFFSET_DEATH)
  54. #define cs_get_user_money(%1) get_offset_value(%1,OFFSET_MONEY)
  55. #define cs_set_user_money(%1,%2) set_offset_value(%1,OFFSET_MONEY,%2)
  56.  
  57.  
  58.  
  59. enum CsTeams {
  60. CS_TEAM_UNASSIGNED = 0,
  61. CS_TEAM_T = 1,
  62. CS_TEAM_CT = 2,
  63. CS_TEAM_SPECTATOR = 3
  64. };
  65.  
  66. enum tripmine_e {
  67. TRIPMINE_IDLE1 = 0,
  68. TRIPMINE_IDLE2,
  69. TRIPMINE_ARM1,
  70. TRIPMINE_ARM2,
  71. TRIPMINE_FIDGET,
  72. TRIPMINE_HOLSTER,
  73. TRIPMINE_DRAW,
  74. TRIPMINE_WORLD,
  75. TRIPMINE_GROUND,
  76. };
  77.  
  78. enum
  79. {
  80. POWERUP_THINK,
  81. BEAMBREAK_THINK,
  82. EXPLOSE_THINK
  83. };
  84.  
  85. enum
  86. {
  87. POWERUP_SOUND,
  88. ACTIVATE_SOUND,
  89. STOP_SOUND
  90. };
  91.  
  92. new const
  93. ENT_MODELS[] = "models/zombie_plague/LaserMines/v_laser_mine.mdl",
  94. ENT_SOUND1[] = "weapons/mine_deploy.wav",
  95. ENT_SOUND2[] = "weapons/mine_charge.wav",
  96. ENT_SOUND3[] = "weapons/mine_activate.wav",
  97. ENT_SOUND4[] = "debris/beamstart9.wav",
  98. ENT_SOUND5[] = "items/gunpickup2.wav",
  99. ENT_SOUND6[] = "debris/bustglass1.wav",
  100. ENT_SOUND7[] = "debris/bustglass2.wav",
  101. ENT_SPRITE1[] = "sprites/laserbeam.spr",
  102. ENT_SPRITE2[] = "sprites/zerogxplode.spr";
  103.  
  104. new const
  105. ENT_CLASS_NAME[] = "lasermine",
  106. //ENT_CLASS_NAME2[] = "info_target",
  107. ENT_CLASS_NAME3[] = "func_breakable";
  108.  
  109. new const
  110. #if defined BIOHAZARD_SUPPORT
  111. CHATTAG[] = "[BioLaser]",
  112. #else
  113. CHATTAG[] = "[Lasermine]",
  114. #endif
  115. //STR_MINEDETNATED[] = "Mina ta a fost detonata.",
  116. //STR_MINEDETNATED2[] = "a detonat mina ta.",
  117. STR_NOTACTIVE[] = "Laserele nu sunt activate.",
  118. STR_DONTHAVEMINE[] = "Nu ai nici un laser.",
  119. //STR_CANTDEPLOY[] = "Echipa ta nu paote planta lasere!",
  120. STR_MAXDEPLOY[] = "Numarul maxim de lasere a fost atins.",
  121. STR_MANYPPL[] = "Prea multe lasere in echipa ta...",
  122. STR_PLANTWALL[] = "Trebuie sa plantezi laserul pe zid!",
  123. STR_REF[] = "Refer to a lasermine rule with this server. say 'lasermine'",
  124. #if defined BIOHAZARD_SUPPORT
  125. STR_CBT[] = "Esti Zombie!Nu poti cumpara si planta un laser.",
  126. #else
  127. STR_CBT[] = "Echipa ta nu poate cumpara si planta lasere!",
  128. #endif
  129. STR_CANTBUY[] = "Nu poti cumpara pe acest server.",
  130. STR_HAVEMAX[] = "Ai numarul maxim de lasere.",
  131. STR_NOMONEY[] = "Nu ai destui bani sa cumperi un laser! ($",
  132. STR_NEEDED[] = "needed)",
  133. STR_DELAY[] = "Poti cumpara si planta lasere in",
  134. STR_SECONDS[] = "secunde.",
  135. STR_BOUGHT[] = "Tocmai ai cumparat un laser.",
  136. STR_STATE[] = "LaserMine Detinute:",
  137. STR_NOACCESS[] = "Nu ai acces la aceasta comanda.";
  138.  
  139. new g_EntMine;
  140. new beam, boom
  141. new
  142. g_LENABLE,g_LFMONEY,g_LAMMO,g_LDMG,
  143. g_LTMAX,g_LCOST,g_LHEALTH,g_LMODE,g_LRADIUS,g_LRDMG,g_LFF,g_LCBT;
  144. new
  145. g_LDELAY,/*g_LTHINK,*/g_LVISIBLE,
  146. g_LSTAMMO,g_LACCESS,g_LGLOW,g_LDMGMODE,g_LCLMODE,g_LCBRIGHT,g_LDSEC,g_LCMDMODE,g_LBUYMODE,g_NEMROUND,g_SURVROUND, g_SNIPROUND, g_ASSASROUND, g_PREDROUND, g_BERROUND, g_WESROUND, g_SPYROUND;
  147.  
  148. new g_dcount[33],g_nowtime,g_MaxPL
  149. new bool:g_settinglaser[33]
  150. new g_msgDeathMsg,g_msgScoreInfo,g_msgDamage,g_msgStatusText,g_msgMoney;
  151. new Float:plspeed[33]
  152. new plsetting[33]
  153. new g_havemine[33];
  154. new g_deployed[33];
  155.  
  156. public plugin_init() {
  157. register_plugin(PLUGIN, VERSION, AUTHOR);
  158.  
  159. // Add your code here...
  160. register_clcmd("+setlaser","CreateLaserMine_Progress_b");
  161. register_clcmd("-setlaser","StopCreateLaserMine");
  162. register_clcmd("+dellaser","ReturnLaserMine_Progress");
  163. register_clcmd("-dellaser","StopReturnLaserMine");
  164. register_clcmd("say","say_lasermine");
  165. register_clcmd("buy_lasermine","BuyLasermine");
  166.  
  167. #if defined BIOHAZARD_SUPPORT
  168. g_LENABLE = register_cvar("bio_ltm","1");
  169. g_LACCESS = register_cvar("bio_ltm_acs","0"); //0 all, 1 admin
  170. g_LMODE = register_cvar("bio_ltm_mode","0"); //0 lasermine, 1 tripmine
  171. g_LAMMO = register_cvar("bio_ltm_ammo","2");
  172. g_LDMG = register_cvar("bio_ltm_dmg","100000"); //laser hit dmg
  173. g_LCOST = register_cvar("bio_ltm_cost","6000");
  174. g_LFMONEY = register_cvar("bio_ltm_fragmoney","400");
  175. g_LHEALTH = register_cvar("bio_ltm_health","850");
  176. g_LTMAX = register_cvar("bio_ltm_teammax","15");
  177. g_LRADIUS = register_cvar("bio_ltm_radius","320.0");
  178. g_LRDMG = register_cvar("bio_ltm_rdmg","10000"); //radius damage
  179. g_LFF = register_cvar("bio_ltm_ff","0");
  180. g_LCBT = register_cvar("bio_ltm_cbt","ALL");
  181. g_LBUYMODE = register_cvar("bio_ltm_buymode","1");
  182. g_LDELAY = register_cvar("bio_ltm_delay","15");
  183. //g_LTHINK = register_cvar("bio_ltm_think","0.01");
  184. g_LVISIBLE = register_cvar("bio_ltm_line","1");
  185. g_LGLOW = register_cvar("bio_ltm_glow","0");
  186. g_LCBRIGHT = register_cvar("bio_ltm_bright","255"); //laser line brightness.
  187. g_LCLMODE = register_cvar("bio_ltm_color","0"); //0 is team color,1 is green
  188. g_LDMGMODE = register_cvar("bio_ltm_ldmgmode","0"); //0 - frame dmg, 1 - once dmg, 2 - 1 second dmg
  189. g_LDSEC = register_cvar("bio_ltm_ldmgseconds","1"); //mode 2 only, damage / seconds. default 1 (sec)
  190. g_LSTAMMO = register_cvar("bio_ltm_startammo","2");
  191. g_LCMDMODE = register_cvar("bio_ltm_cmdmode","1"); //0 is +USE key, 1 is bind, 2 is each.
  192. #else
  193. g_LENABLE = register_cvar("amx_ltm","1");
  194. g_LACCESS = register_cvar("amx_ltm_acs","0"); //0 all, 1 admin
  195. g_LMODE = register_cvar("amx_ltm_mode","0"); //0 lasermine, 1 tripmine
  196. g_LAMMO = register_cvar("amx_ltm_ammo","2");
  197. g_LDMG = register_cvar("amx_ltm_dmg","100000"); //laser hit dmg
  198. g_LCOST = register_cvar("amx_ltm_cost","0");
  199. g_LFMONEY = register_cvar("amx_ltm_fragmoney","400");
  200. g_LHEALTH = register_cvar("amx_ltm_health","850");
  201. g_LTMAX = register_cvar("amx_ltm_teammax","15");
  202. g_LRADIUS = register_cvar("amx_ltm_radius","320.0");
  203. g_LRDMG = register_cvar("amx_ltm_rdmg","10000"); //radius damage
  204. g_LFF = register_cvar("amx_ltm_ff","0");
  205. g_LCBT = register_cvar("amx_ltm_cbt","ALL");
  206. g_LBUYMODE = register_cvar("amx_ltm_buymode","1");
  207. g_LDELAY = register_cvar("amx_ltm_delay","15");
  208. //g_LTHINK = register_cvar("amx_ltm_think","0.01")
  209. g_LVISIBLE = register_cvar("amx_ltm_line","1");
  210. g_LGLOW = register_cvar("amx_ltm_glow","0");
  211. g_LCBRIGHT = register_cvar("amx_ltm_bright","255"); //laser line brightness.
  212. g_LCLMODE = register_cvar("amx_ltm_color","0"); //0 is team color,1 is green
  213. g_LDMGMODE = register_cvar("amx_ltm_ldmgmode","0"); //0 - frame dmg, 1 - once dmg, 2 - 1 second dmg
  214. g_LDSEC = register_cvar("amx_ltm_ldmgseconds","1"); //mode 2 only, damage / seconds. default 1 (sec)
  215. g_LSTAMMO = register_cvar("amx_ltm_startammo","2");
  216. g_LCMDMODE = register_cvar("amx_ltm_cmdmode","1"); //0 is +USE key, 1 is bind, 2 is each.
  217. g_NEMROUND = register_cvar("zp_ltm_nemround","0");
  218. g_SURVROUND = register_cvar("zp_ltm_survround","1");
  219. g_SNIPROUND = register_cvar("zp_ltm_snipround", "1");
  220. g_ASSASROUND = register_cvar("zp_ltm_assasround", "1");
  221. g_SPYROUND = register_cvar("zp_ltm_spyround", "1");
  222. g_PREDROUND = register_cvar("zp_itm_predatorround", "1");
  223. g_BERROUND = register_cvar("zp_itm_berseround", "1");
  224. g_WESROUND = register_cvar("zp_itm_weskerround", "1");
  225. #endif
  226. register_event("DeathMsg", "DeathEvent", "a");
  227. register_event("CurWeapon", "standing", "be", "1=1");
  228. register_event("ResetHUD", "delaycount", "a");
  229. register_event("ResetHUD", "newround", "b");
  230. register_event("Damage","CutDeploy_onDamage","b");
  231. g_msgDeathMsg = get_user_msgid("DeathMsg");
  232. g_msgScoreInfo = get_user_msgid("ScoreInfo");
  233. g_msgDamage = get_user_msgid("Damage");
  234. g_msgStatusText = get_user_msgid("StatusText");
  235. g_msgMoney = get_user_msgid("Money");
  236. // -- Forward.
  237. register_forward(FM_Think, "ltm_Think" );
  238. register_forward(FM_PlayerPostThink, "ltm_PostThink" );
  239. register_forward(FM_PlayerPreThink, "ltm_PreThink");
  240. RegisterHam(Ham_TakeDamage, "func_breakable", "fwHamTakeDamageBreakablePost", 1);
  241. }
  242.  
  243. public plugin_precache()
  244. {
  245. precache_sound(ENT_SOUND1);
  246. precache_sound(ENT_SOUND2);
  247. precache_sound(ENT_SOUND3);
  248. precache_sound(ENT_SOUND4);
  249. precache_sound(ENT_SOUND5);
  250. precache_sound(ENT_SOUND6);
  251. precache_sound(ENT_SOUND7);
  252. precache_model(ENT_MODELS);
  253. beam = precache_model(ENT_SPRITE1);
  254. boom = precache_model(ENT_SPRITE2);
  255.  
  256. return PLUGIN_CONTINUE;
  257. }
  258.  
  259. public plugin_modules()
  260. {
  261. require_module("fakemeta");
  262. require_module("cstrike");
  263. //require_module("fun")
  264. }
  265.  
  266. public plugin_cfg()
  267. {
  268. g_EntMine = engfunc(EngFunc_AllocString,ENT_CLASS_NAME3);
  269. arrayset(g_havemine,0,sizeof(g_havemine));
  270. arrayset(g_deployed,0,sizeof(g_deployed));
  271. g_MaxPL = get_maxplayers();
  272.  
  273. new file[64]; get_localinfo("amxx_configsdir",file,63);
  274. #if defined BIOHAZARD_SUPPORT
  275. format(file, 63, "%s/bhltm_cvars.cfg", file);
  276. #else
  277. format(file, 63, "%s/ltm_cvars.cfg", file);
  278. #endif
  279. if(file_exists(file)) server_cmd("exec %s", file), server_exec();
  280.  
  281. }
  282. public fwHamTakeDamageBreakablePost(iVictim, iInflictor, iAttacker, Float:fDamage)
  283. {
  284. if (!is_valid_ent(iVictim) || entity_get_float(iVictim, EV_FL_health) > 0.0
  285. || !is_user_connected(iAttacker))
  286. return;
  287.  
  288. static szTempString[32];
  289. entity_get_string(iVictim, EV_SZ_classname, szTempString, charsmax(szTempString));
  290.  
  291. if (!equali(szTempString, ENT_CLASS_NAME))
  292. return;
  293.  
  294. new ownerName[32];
  295. new own = pev(iVictim,LASERMINE_OWNER);
  296. zp_set_user_ammo_packs(iAttacker, zp_get_user_ammo_packs(iAttacker) + 10);
  297. get_user_name(iAttacker, szTempString, charsmax(szTempString));
  298. get_user_name(own, ownerName, charsmax(ownerName));
  299. client_print(0,print_chat,"Playerul %s a distrus lasermine-ul lui %s si a castigat 10 credite.",szTempString,ownerName);
  300. }
  301.  
  302. public delaycount(id)
  303. {
  304. g_dcount[id] = floatround(get_gametime());
  305. }
  306.  
  307. bool:CheckTime(id)
  308. {
  309. g_nowtime = floatround(get_gametime()) - g_dcount[id];
  310. if(g_nowtime >= get_pcvar_num(g_LDELAY))
  311. return true;
  312. return false;
  313. }
  314.  
  315. public CreateLaserMine_Progress_b(id)
  316. {
  317. if(get_pcvar_num(g_LCMDMODE) != 0)
  318. CreateLaserMine_Progress(id);
  319. return PLUGIN_HANDLED;
  320. }
  321.  
  322. public CreateLaserMine_Progress(id)
  323. {
  324.  
  325. if (!CreateCheck(id))
  326. return PLUGIN_HANDLED;
  327. g_settinglaser[id] = true;
  328.  
  329. message_begin( MSG_ONE, 108, {0,0,0}, id );
  330. write_byte(1);
  331. write_byte(0);
  332. message_end();
  333.  
  334. set_task(1.2, "Spawn", (TASK_PLANT + id));
  335.  
  336. return PLUGIN_HANDLED;
  337. }
  338.  
  339. public ReturnLaserMine_Progress(id)
  340. {
  341.  
  342. if (!ReturnCheck(id))
  343. return PLUGIN_HANDLED;
  344. g_settinglaser[id] = true;
  345.  
  346. message_begin( MSG_ONE, 108, {0,0,0}, id );
  347. write_byte(1);
  348. write_byte(0);
  349. message_end();
  350.  
  351. set_task(1.2, "ReturnMine", (TASK_RELEASE + id));
  352.  
  353.  
  354. return PLUGIN_HANDLED;
  355. }
  356.  
  357. public StopCreateLaserMine(id)
  358. {
  359.  
  360. DeleteTask(id);
  361. message_begin(MSG_ONE, 108, {0,0,0}, id);
  362. write_byte(0);
  363. write_byte(0);
  364. message_end();
  365.  
  366. return PLUGIN_HANDLED;
  367. }
  368.  
  369. public StopReturnLaserMine(id)
  370. {
  371.  
  372. DeleteTask(id);
  373. message_begin(MSG_ONE, 108, {0,0,0}, id);
  374. write_byte(0);
  375. write_byte(0);
  376. message_end();
  377.  
  378. return PLUGIN_HANDLED;
  379. }
  380.  
  381. public ReturnMine(id)
  382. {
  383. id -= TASK_RELEASE;
  384. new tgt,body,Float:vo[3],Float:to[3];
  385. get_user_aiming(id,tgt,body);
  386. if(!pev_valid(tgt)) return;
  387. pev(id,pev_origin,vo);
  388. pev(tgt,pev_origin,to);
  389. if(get_distance_f(vo,to) > 70.0) return;
  390.  
  391. new EntityName[32];
  392. pev(tgt, pev_classname, EntityName, 31);
  393. if(!equal(EntityName, ENT_CLASS_NAME)) return;
  394. if(pev(tgt,LASERMINE_OWNER) != id) return;
  395. RemoveEntity(tgt);
  396.  
  397. g_havemine[id] ++;
  398. g_deployed[id] --;
  399. emit_sound(id, CHAN_ITEM, ENT_SOUND5, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  400. ShowAmmo(id)
  401.  
  402. return;
  403. }
  404.  
  405. public Spawn( id )
  406. {
  407. id -= TASK_PLANT
  408. // motor
  409. new i_Ent = engfunc(EngFunc_CreateNamedEntity,g_EntMine);
  410. if(!i_Ent)
  411. {
  412. client_print(id,print_chat,"[Laesrmine Debug] Can't Create Entity");
  413. return PLUGIN_HANDLED_MAIN;
  414. }
  415. set_pev(i_Ent,pev_classname,ENT_CLASS_NAME);
  416.  
  417. engfunc(EngFunc_SetModel,i_Ent,ENT_MODELS);
  418.  
  419. set_pev(i_Ent,pev_solid,SOLID_NOT);
  420. set_pev(i_Ent,pev_movetype,MOVETYPE_FLY);
  421.  
  422. set_pev(i_Ent,pev_frame,0);
  423. set_pev(i_Ent,pev_body,3);
  424. set_pev(i_Ent,pev_sequence,TRIPMINE_WORLD);
  425. set_pev(i_Ent,pev_framerate,0);
  426.  
  427. set_pev(i_Ent,pev_takedamage,DAMAGE_YES);
  428.  
  429. set_pev(i_Ent,pev_dmg,100.0);
  430. set_user_health(i_Ent,get_pcvar_num(g_LHEALTH));
  431. new Float:vOrigin[3];
  432. new Float:vNewOrigin[3],Float:vNormal[3],Float:vTraceDirection[3],
  433. Float:vTraceEnd[3],Float:vEntAngles[3];
  434. pev( id, pev_origin, vOrigin );
  435. velocity_by_aim( id, 128, vTraceDirection );
  436. xs_vec_add( vTraceDirection, vOrigin, vTraceEnd );
  437.  
  438. engfunc( EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, id, 0 );
  439.  
  440. new Float:fFraction;
  441. get_tr2( 0, TR_flFraction, fFraction );
  442.  
  443.  
  444. // -- We hit something!
  445. if ( fFraction < 1.0 )
  446. {
  447. // -- Save results to be used later.
  448. get_tr2( 0, TR_vecEndPos, vTraceEnd );
  449. get_tr2( 0, TR_vecPlaneNormal, vNormal );
  450. }
  451.  
  452.  
  453. xs_vec_mul_scalar( vNormal, 8.0, vNormal );
  454. xs_vec_add( vTraceEnd, vNormal, vNewOrigin );
  455.  
  456. engfunc(EngFunc_SetSize, i_Ent, Float:{ -4.0, -4.0, -4.0 }, Float:{ 4.0, 4.0, 4.0 } );
  457. engfunc(EngFunc_SetOrigin, i_Ent, vNewOrigin );
  458.  
  459. // -- Rotate tripmine.
  460. vector_to_angle(vNormal,vEntAngles );
  461. set_pev(i_Ent,pev_angles,vEntAngles );
  462.  
  463. // -- Calculate laser end origin.
  464. new Float:vBeamEnd[3], Float:vTracedBeamEnd[3];
  465.  
  466. xs_vec_mul_scalar(vNormal, 8192.0, vNormal );
  467. xs_vec_add( vNewOrigin, vNormal, vBeamEnd );
  468.  
  469. engfunc( EngFunc_TraceLine, vNewOrigin, vBeamEnd, IGNORE_MONSTERS, -1, 0 );
  470.  
  471. get_tr2( 0, TR_vecPlaneNormal, vNormal );
  472. get_tr2( 0, TR_vecEndPos, vTracedBeamEnd );
  473.  
  474. // -- Save results to be used later.
  475. set_pev(i_Ent, LASERMINE_OWNER, id );
  476. set_pev(i_Ent,LASERMINE_BEAMENDPOINT,vTracedBeamEnd);
  477. set_pev(i_Ent,LASERMINE_TEAM,int:cs_get_user_team(id));
  478. new Float:fCurrTime = get_gametime();
  479.  
  480. set_pev(i_Ent,LASERMINE_POWERUP, fCurrTime + 2.5 );
  481.  
  482. set_pev(i_Ent,LASERMINE_STEP,POWERUP_THINK);
  483. set_pev(i_Ent,pev_nextthink, fCurrTime + 0.2 );
  484.  
  485. PlaySound(i_Ent,POWERUP_SOUND );
  486. g_deployed[id]++;
  487. g_havemine[id]--;
  488. DeleteTask(id);
  489. ShowAmmo(id);
  490. return 1;
  491. }
  492.  
  493. stock TeamDeployedCount(id)
  494. {
  495. //new tid[32];
  496.  
  497. static i;
  498. static CsTeams:t;t = cs_get_user_team(id);
  499. static cnt;cnt=0;
  500.  
  501. for(i = 1;i <= g_MaxPL;i++)
  502. {
  503. if(is_user_connected(i))
  504. if(t == cs_get_user_team(i))
  505. cnt += g_deployed[i];
  506. }
  507.  
  508. return cnt;
  509. }
  510.  
  511.  
  512. bool:CheckCanTeam(id)
  513. {
  514. new arg[5],CsTeam:num;
  515. get_pcvar_string(g_LCBT,arg,3);
  516. if(equali(arg,"T"))
  517. {
  518. num = CsTeam:CS_TEAM_T;
  519. }
  520. else if(equali(arg,"CT"))
  521. {
  522. num = CsTeam:CS_TEAM_CT;
  523. }
  524. else if(equali(arg,"ALL"))
  525. {
  526. num = CsTeam:CS_TEAM_UNASSIGNED;
  527. }
  528. else
  529. {
  530. num = CsTeam:CS_TEAM_UNASSIGNED;
  531. }
  532. if(num != CsTeam:CS_TEAM_UNASSIGNED && num != CsTeam:cs_get_user_team(id))
  533. return false;
  534. return true;
  535. }
  536.  
  537. bool:CanCheck(id,mode)
  538. {
  539. if( !get_pcvar_num( g_LENABLE ) )
  540. {
  541. client_print(id, print_chat, "%s %s",CHATTAG,STR_NOTACTIVE);
  542. return false;
  543. }
  544. if( get_pcvar_num(g_LACCESS) != 0)
  545. if(!(get_user_flags(id) & ADMIN_IMMUNITY))
  546. {
  547. client_print(id, print_chat, "%s %s",CHATTAG,STR_NOACCESS);
  548. return false;
  549. }
  550. if(!pev_user_alive(id)) return false;
  551. #if defined BIOHAZARD_SUPPORT
  552. if(is_user_zombie(id))
  553. {
  554. client_print(id, print_chat, "%s %s",CHATTAG,STR_CBT);
  555. return false;
  556. }
  557. #endif
  558. if (!CheckCanTeam(id))
  559. {
  560. client_print(id, print_chat, "%s %s",CHATTAG,STR_CBT);
  561. return false;
  562. }
  563. if( mode == 0)
  564. {
  565. if(g_havemine[id] <= 0)
  566. {
  567. client_print(id, print_chat, "%s %s",CHATTAG,STR_DONTHAVEMINE);
  568. return false;
  569. }
  570. }
  571. if (mode == 1)
  572. {
  573. if (get_pcvar_num(g_LBUYMODE) == 0)
  574. {
  575. client_print(id, print_chat, "%s %s",CHATTAG,STR_CANTBUY);
  576. return false;
  577. }
  578. if (g_havemine[id] >= get_pcvar_num(g_LAMMO))
  579. {
  580. client_print(id, print_chat, "%s %s",CHATTAG,STR_HAVEMAX);
  581. return false;
  582. }
  583. if (cs_get_user_money(id) < get_pcvar_num(g_LCOST))
  584. {
  585. client_print(id, print_chat, "%s %s%d %s",CHATTAG, STR_NOMONEY,get_pcvar_num(g_LCOST),STR_NEEDED);
  586. return false;
  587. }
  588. }
  589. if(!CheckTime(id))
  590. {
  591. client_print(id,print_chat, "%s %s %d %s",CHATTAG,STR_DELAY,get_pcvar_num(g_LDELAY)-g_nowtime,STR_SECONDS);
  592. return false;
  593. }
  594.  
  595. return true;
  596. }
  597.  
  598. bool:ReturnCheck( id )
  599. {
  600. if(!CanCheck(id,-1)) return false;
  601. if(g_havemine[id] + 1 > get_pcvar_num(g_LAMMO)) return false;
  602. new tgt,body,Float:vo[3],Float:to[3];
  603. get_user_aiming(id,tgt,body);
  604. if(!pev_valid(tgt)) return false;
  605. pev(id,pev_origin,vo);
  606. pev(tgt,pev_origin,to);
  607. if(get_distance_f(vo,to) > 70.0) return false;
  608.  
  609. new EntityName[32];
  610. pev(tgt, pev_classname, EntityName, 31);
  611. if(!equal(EntityName, ENT_CLASS_NAME)) return false;
  612. if(pev(tgt,LASERMINE_OWNER) != id) return false;
  613.  
  614. return true;
  615. }
  616.  
  617. bool:CreateCheck( id )
  618. {
  619. if (!CanCheck(id,0)) return false;
  620.  
  621. if(zp_is_nemesis_round() && get_pcvar_num(g_NEMROUND))
  622. {
  623. client_print(id, print_chat, "Nu poti plata Laser la runda Nemesis");
  624. return false;
  625. }
  626.  
  627. if(zp_is_survivor_round() && get_pcvar_num(g_SURVROUND))
  628. {
  629. client_print(id, print_chat, "Nu poti plata Laser la runda Survivor");
  630. return false;
  631. }
  632. if(zp_is_sniper_round() && get_pcvar_num(g_SNIPROUND))
  633. {
  634. client_print(id, print_chat, "Nu poti plata Laser la runda Sniper");
  635. return false;
  636. }
  637. if(zp_is_assassin_round() && get_pcvar_num(g_ASSASROUND))
  638. {
  639. client_print(id, print_chat, "Nu poti plata Laser la runda Assassin");
  640. return false;
  641. }
  642. if(zp_is_predator_round() && get_pcvar_num(g_PREDROUND))
  643. {
  644. client_print(id, print_chat, "Nu poti plata Laser la runda Predator");
  645. return false;
  646. }
  647. if(zp_is_berserker_round() && get_pcvar_num(g_BERROUND))
  648. {
  649. client_print(id, print_chat, "Nu poti plata Laser la runda Cutitar");
  650. return false;
  651. }
  652. if(zp_is_wesker_round() && get_pcvar_num(g_WESROUND))
  653. {
  654. client_print(id, print_chat, "Nu poti plata Laser la runda Pistolar");
  655. return false;
  656. }
  657. if(zp_is_spy_round() && get_pcvar_num(g_SPYROUND))
  658. {
  659. client_print(id, print_chat, "Nu poti plata Laser la runda Spion");
  660. return false;
  661. }
  662. if (g_deployed[id] >= get_pcvar_num(g_LAMMO))
  663. {
  664. client_print(id, print_chat, "%s %s",CHATTAG,STR_MAXDEPLOY);
  665. return false;
  666. }
  667.  
  668. //client_print(id,print_chat,"[Lasermine] your team deployed %d",TeamDeployedCount(id))
  669. if(TeamDeployedCount(id) >= get_pcvar_num(g_LTMAX))
  670. {
  671. client_print(id, print_chat, "%s %s",CHATTAG,STR_MANYPPL);
  672. return false;
  673. }
  674.  
  675. new Float:vTraceDirection[3], Float:vTraceEnd[3],Float:vOrigin[3];
  676.  
  677. pev( id, pev_origin, vOrigin );
  678. velocity_by_aim( id, 128, vTraceDirection );
  679. xs_vec_add( vTraceDirection, vOrigin, vTraceEnd );
  680.  
  681. engfunc( EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, id, 0 );
  682.  
  683. new Float:fFraction,Float:vTraceNormal[3];
  684. get_tr2( 0, TR_flFraction, fFraction );
  685.  
  686. // -- We hit something!
  687. if ( fFraction < 1.0 )
  688. {
  689. // -- Save results to be used later.
  690. get_tr2( 0, TR_vecEndPos, vTraceEnd );
  691. get_tr2( 0, TR_vecPlaneNormal, vTraceNormal );
  692.  
  693. //get_tr2( 0, TR_pHit );
  694.  
  695. return true;
  696. }
  697.  
  698. client_print(id, print_chat, "%s %s",CHATTAG,STR_PLANTWALL)
  699. DeleteTask(id);
  700. // -- Did not touched something. (not solid)
  701. return false;
  702. }
  703.  
  704. public ltm_Think( i_Ent )
  705. {
  706. if ( !pev_valid( i_Ent ) )
  707. return FMRES_IGNORED;
  708. new EntityName[32];
  709. pev( i_Ent, pev_classname, EntityName, 31);
  710. if(!get_pcvar_num(g_LENABLE)) return FMRES_IGNORED;
  711. // -- Entity is not a tripmine, ignoring the next...
  712. if ( !equal( EntityName, ENT_CLASS_NAME ) )
  713. return FMRES_IGNORED;
  714.  
  715. static Float:fCurrTime;
  716. fCurrTime = get_gametime();
  717.  
  718. switch( pev( i_Ent, LASERMINE_STEP ) )
  719. {
  720. case POWERUP_THINK :
  721. {
  722. new Float:fPowerupTime;
  723. pev( i_Ent, LASERMINE_POWERUP, fPowerupTime );
  724.  
  725. if( fCurrTime > fPowerupTime )
  726. {
  727. set_pev( i_Ent, pev_solid, SOLID_BBOX );
  728. set_pev( i_Ent, LASERMINE_STEP, BEAMBREAK_THINK );
  729.  
  730. PlaySound( i_Ent, ACTIVATE_SOUND );
  731. }
  732. if(get_pcvar_num(g_LGLOW)!=0)
  733. {
  734. if(get_pcvar_num(g_LCLMODE)==0)
  735. {
  736. switch (pev(i_Ent,LASERMINE_TEAM))
  737. {
  738. case CS_TEAM_T: set_rendering(i_Ent,kRenderFxGlowShell,255,0,0,kRenderNormal,5);
  739. case CS_TEAM_CT:set_rendering(i_Ent,kRenderFxGlowShell,0,0,255,kRenderNormal,5);
  740. }
  741. }else
  742. {
  743. set_rendering(i_Ent,kRenderFxGlowShell,0,255,0,kRenderNormal,5);
  744. }
  745. }
  746. set_pev( i_Ent, pev_nextthink, fCurrTime + 0.1 );
  747. }
  748. case BEAMBREAK_THINK :
  749. {
  750. static Float:vEnd[3],Float:vOrigin[3];
  751. pev( i_Ent, pev_origin, vOrigin );
  752. pev( i_Ent, LASERMINE_BEAMENDPOINT, vEnd );
  753.  
  754. static iHit, Float:fFraction;
  755. engfunc( EngFunc_TraceLine, vOrigin, vEnd, DONT_IGNORE_MONSTERS, i_Ent, 0 );
  756.  
  757. get_tr2( 0, TR_flFraction, fFraction );
  758. iHit = get_tr2( 0, TR_pHit );
  759.  
  760. // -- Something has passed the laser.
  761. if ( fFraction < 1.0 )
  762. {
  763. // -- Ignoring others tripmines entity.
  764. if(pev_valid(iHit))
  765. {
  766. pev( iHit, pev_classname, EntityName, 31 );
  767.  
  768. if( !equal( EntityName, ENT_CLASS_NAME ) )
  769. {
  770. set_pev( i_Ent, pev_enemy, iHit );
  771. if(get_pcvar_num(g_LMODE) == MODE_LASERMINE)
  772. CreateLaserDamage(i_Ent,iHit);
  773. else
  774. if(get_pcvar_num(g_LFF) || CsTeams:pev(i_Ent,LASERMINE_TEAM) != cs_get_user_team(iHit))
  775. set_pev( i_Ent, LASERMINE_STEP, EXPLOSE_THINK );
  776.  
  777. set_pev( i_Ent, pev_nextthink, fCurrTime + random_float( 0.1, 0.3 ) );
  778. }
  779. }
  780. }
  781. if(get_pcvar_num(g_LDMGMODE)!=0)
  782. if(pev(i_Ent,LASERMINE_HITING) != iHit)
  783. set_pev(i_Ent,LASERMINE_HITING,iHit);
  784.  
  785. // -- Tripmine is still there.
  786. if ( pev_valid( i_Ent ))
  787. {
  788. static Float:fHealth;
  789. pev( i_Ent, pev_health, fHealth );
  790.  
  791. if( fHealth <= 0.0 || (pev(i_Ent,pev_flags) & FL_KILLME))
  792. {
  793. set_pev( i_Ent, LASERMINE_STEP, EXPLOSE_THINK );
  794. set_pev( i_Ent, pev_nextthink, fCurrTime + random_float( 0.1, 0.3 ) );
  795. }
  796.  
  797. static Float:fBeamthink;
  798. pev( i_Ent, LASERMINE_BEAMTHINK, fBeamthink );
  799.  
  800. if( fBeamthink < fCurrTime && get_pcvar_num(g_LVISIBLE))
  801. {
  802. DrawLaser(i_Ent, vOrigin, vEnd );
  803. set_pev( i_Ent, LASERMINE_BEAMTHINK, fCurrTime + 0.1 );
  804. }
  805. set_pev( i_Ent, pev_nextthink, fCurrTime + 0.01 );
  806. }
  807. }
  808. case EXPLOSE_THINK :
  809. {
  810. // -- Stopping entity to think
  811. set_pev( i_Ent, pev_nextthink, 0.0 );
  812. PlaySound( i_Ent, STOP_SOUND );
  813. g_deployed[pev(i_Ent,LASERMINE_OWNER)]--;
  814. CreateExplosion( i_Ent );
  815. CreateDamage(i_Ent,get_pcvar_float(g_LRDMG),get_pcvar_float(g_LRADIUS))
  816. RemoveEntity ( i_Ent );
  817. }
  818. }
  819.  
  820. return FMRES_IGNORED;
  821. }
  822.  
  823. PlaySound( i_Ent, i_SoundType )
  824. {
  825. switch ( i_SoundType )
  826. {
  827. case POWERUP_SOUND :
  828. {
  829. emit_sound( i_Ent, CHAN_VOICE, ENT_SOUND1, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  830. emit_sound( i_Ent, CHAN_BODY , ENT_SOUND2, 0.2, ATTN_NORM, 0, PITCH_NORM );
  831. }
  832. case ACTIVATE_SOUND :
  833. {
  834. emit_sound( i_Ent, CHAN_VOICE, ENT_SOUND3, 0.5, ATTN_NORM, 1, 75 );
  835. }
  836. case STOP_SOUND :
  837. {
  838. emit_sound( i_Ent, CHAN_BODY , ENT_SOUND2, 0.2, ATTN_NORM, SND_STOP, PITCH_NORM );
  839. emit_sound( i_Ent, CHAN_VOICE, ENT_SOUND3, 0.5, ATTN_NORM, SND_STOP, 75 );
  840. }
  841. }
  842. }
  843.  
  844. DrawLaser(i_Ent, const Float:v_Origin[3], const Float:v_EndOrigin[3] )
  845. {
  846. new tcolor[3];
  847. new teamid = pev(i_Ent, LASERMINE_TEAM);
  848. if(get_pcvar_num(g_LCLMODE) == 0)
  849. {
  850. switch(teamid){
  851. case 1:{
  852. tcolor[0] = 255;
  853. tcolor[1] = 0;
  854. tcolor[2] = 0;
  855. }
  856. case 2:{
  857. tcolor[0] = 0;
  858. tcolor[1] = 0;
  859. tcolor[2] = 255;
  860. }
  861. }
  862. }else
  863. {
  864. tcolor[0] = 0;
  865. tcolor[1] = 255;
  866. tcolor[2] = 0;
  867. }
  868. message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
  869. write_byte(TE_BEAMPOINTS);
  870. engfunc(EngFunc_WriteCoord,v_Origin[0]);
  871. engfunc(EngFunc_WriteCoord,v_Origin[1]);
  872. engfunc(EngFunc_WriteCoord,v_Origin[2]);
  873. engfunc(EngFunc_WriteCoord,v_EndOrigin[0]); //Random
  874. engfunc(EngFunc_WriteCoord,v_EndOrigin[1]); //Random
  875. engfunc(EngFunc_WriteCoord,v_EndOrigin[2]); //Random
  876. write_short(beam);
  877. write_byte(0);
  878. write_byte(0);
  879. write_byte(1); //Life
  880. write_byte(5); //Width
  881. write_byte(0); //wave
  882. write_byte(tcolor[0]); // r
  883. write_byte(tcolor[1]); // g
  884. write_byte(tcolor[2]); // b
  885. write_byte(get_pcvar_num(g_LCBRIGHT));
  886. write_byte(255);
  887. message_end();
  888. }
  889. /*
  890. CreateDamage(iCurrent,DmgMAX,Float:Radius)
  891. {
  892. new AtkID = pev(iCurrent,LASERMINE_OWNER)// entity_get_int(iCurrent,LASERMINE_OWNER)
  893. new TeamID= pev(iCurrent,LASERMINE_TEAM) //entity_get_int(iCurrent,LASERMINE_INT_TEAM)
  894. new Player = -1;
  895. new Float:distance,dmg;
  896. new Float:tOrigin[3];
  897. new Float:vOrigin[3];
  898. new iHitHP,iHitTeam;
  899. pev(iCurrent,pev_origin,vOrigin);
  900. while((Player = engfunc(EngFunc_FindEntityInSphere, Player, vOrigin, Radius)) != 0)
  901. {
  902. if(is_user_alive(Player))
  903. {
  904. pev(Player,pev_origin,tOrigin)
  905. distance = get_distance_f(vOrigin, tOrigin)
  906. dmg = floatround(DmgMAX - ((DmgMAX / Radius) * distance))
  907. iHitHP = pev_user_health(Player) - dmg
  908. iHitTeam = int:bio_get_user_team(Player)
  909. if(iHitHP <= 0)
  910. {
  911. if(iHitTeam != TeamID)
  912. {
  913. cs_set_user_money(AtkID,cs_get_user_money(AtkID) + get_pcvar_num(g_LFMONEY))
  914. set_score(AtkID,Player,1,iHitHP)
  915. }else
  916. {
  917. if(get_pcvar_num(g_LFF))
  918. {
  919. cs_set_user_money(AtkID,cs_get_user_money(AtkID) - get_pcvar_num(g_LFMONEY))
  920. set_score(AtkID,Player,-1,iHitHP)
  921. }
  922. }
  923. }else
  924. {
  925. if(iHitTeam != TeamID || get_pcvar_num(g_LFF))
  926. {
  927. //set_pev(Player,pev_health,iHitHP)
  928. set_user_health(Player, iHitHP)
  929. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, {0,0,0}, Player)
  930. write_byte(dmg)
  931. write_byte(dmg)
  932. write_long(DMG_BULLET)
  933. engfunc(EngFunc_WriteCoord,vOrigin[0])
  934. engfunc(EngFunc_WriteCoord,vOrigin[1])
  935. engfunc(EngFunc_WriteCoord,vOrigin[2])
  936. message_end()
  937. }
  938. }
  939. }
  940. Player = engfunc(EngFunc_FindEntityInSphere,Player,vOrigin,Radius)
  941. }
  942. return PLUGIN_CONTINUE
  943. }
  944. */
  945. CreateDamage(iCurrent,Float:DmgMAX,Float:Radius)
  946. {
  947. // Get given parameters
  948.  
  949. new Float:vecSrc[3];
  950. pev(iCurrent, pev_origin, vecSrc);
  951.  
  952. new AtkID =pev(iCurrent,LASERMINE_OWNER);
  953. new TeamID=pev(iCurrent,LASERMINE_TEAM);
  954.  
  955. new ent = -1;
  956. new Float:tmpdmg = DmgMAX;
  957.  
  958. new Float:kickback = 0.0;
  959.  
  960. // Needed for doing some nice calculations -
  961. new Float:Tabsmin[3], Float:Tabsmax[3];
  962. new Float:vecSpot[3];
  963. new Float:Aabsmin[3], Float:Aabsmax[3];
  964. new Float:vecSee[3];
  965. new trRes;
  966. new Float:flFraction;
  967. new Float:vecEndPos[3];
  968. new Float:distance;
  969. new Float:origin[3], Float:vecPush[3];
  970. new Float:invlen;
  971. new Float:velocity[3];
  972. new iHitHP,iHitTeam;
  973. // Calculate falloff
  974. new Float:falloff;
  975. if (Radius > 0.0)
  976. {
  977. falloff = DmgMAX / Radius;
  978. } else {
  979. falloff = 1.0;
  980. }
  981.  
  982. // Find monsters and players inside a specifiec radius
  983. while((ent = engfunc(EngFunc_FindEntityInSphere, ent, vecSrc, Radius)) != 0)
  984. {
  985. if(!pev_valid(ent)) continue;
  986. if(!(pev(ent, pev_flags) & (FL_CLIENT | FL_FAKECLIENT | FL_MONSTER)))
  987. {
  988. // Entity is not a player or monster, ignore it
  989. continue;
  990. }
  991. if(!pev_user_alive(ent)) continue;
  992. // Reset data
  993. kickback = 1.0;
  994. tmpdmg = DmgMAX;
  995.  
  996. // The following calculations are provided by Orangutanz, THANKS!
  997. // We use absmin and absmax for the most accurate information
  998. pev(ent, pev_absmin, Tabsmin);
  999. pev(ent, pev_absmax, Tabsmax);
  1000. xs_vec_add(Tabsmin,Tabsmax,Tabsmin);
  1001. xs_vec_mul_scalar(Tabsmin,0.5,vecSpot);
  1002.  
  1003. pev(iCurrent, pev_absmin, Aabsmin);
  1004. pev(iCurrent, pev_absmax, Aabsmax);
  1005. xs_vec_add(Aabsmin,Aabsmax,Aabsmin);
  1006. xs_vec_mul_scalar(Aabsmin,0.5,vecSee);
  1007.  
  1008. engfunc(EngFunc_TraceLine, vecSee, vecSpot, 0, iCurrent, trRes);
  1009. get_tr2(trRes, TR_flFraction, flFraction);
  1010. // Explosion can 'see' this entity, so hurt them! (or impact through objects has been enabled xD)
  1011. if (flFraction >= 0.9 || get_tr2(trRes, TR_pHit) == ent)
  1012. {
  1013. // Work out the distance between impact and entity
  1014. get_tr2(trRes, TR_vecEndPos, vecEndPos);
  1015.  
  1016. distance = get_distance_f(vecSrc, vecEndPos) * falloff;
  1017. tmpdmg -= distance;
  1018. if(tmpdmg < 0.0)
  1019. tmpdmg = 0.0;
  1020.  
  1021. // Kickback Effect
  1022. if(kickback != 0.0)
  1023. {
  1024. xs_vec_sub(vecSpot,vecSee,origin);
  1025.  
  1026. invlen = 1.0/get_distance_f(vecSpot, vecSee);
  1027.  
  1028. xs_vec_mul_scalar(origin,invlen,vecPush);
  1029. pev(ent, pev_velocity, velocity)
  1030. xs_vec_mul_scalar(vecPush,tmpdmg,vecPush);
  1031. xs_vec_mul_scalar(vecPush,kickback,vecPush);
  1032. xs_vec_add(velocity,vecPush,velocity);
  1033.  
  1034. if(tmpdmg < 60.0)
  1035. {
  1036. xs_vec_mul_scalar(velocity,12.0,velocity);
  1037. } else {
  1038. xs_vec_mul_scalar(velocity,4.0,velocity);
  1039. }
  1040.  
  1041. if(velocity[0] != 0.0 || velocity[1] != 0.0 || velocity[2] != 0.0)
  1042. {
  1043. // There's some movement todo -
  1044. set_pev(ent, pev_velocity, velocity)
  1045. }
  1046. }
  1047.  
  1048. iHitHP = pev_user_health(ent) - floatround(tmpdmg)
  1049. iHitTeam = int:cs_get_user_team(ent)
  1050. if(iHitHP <= 0)
  1051. {
  1052. if(iHitTeam != TeamID)
  1053. {
  1054. cs_set_user_money(AtkID,cs_get_user_money(AtkID) + get_pcvar_num(g_LFMONEY))
  1055. set_score(AtkID,ent,1,iHitHP)
  1056. }else
  1057. {
  1058. if(get_pcvar_num(g_LFF))
  1059. {
  1060. cs_set_user_money(AtkID,cs_get_user_money(AtkID) - get_pcvar_num(g_LFMONEY))
  1061. set_score(AtkID,ent,-1,iHitHP)
  1062. }
  1063. }
  1064. }else
  1065. {
  1066. if(iHitTeam != TeamID || get_pcvar_num(g_LFF))
  1067. {
  1068. //set_pev(Player,pev_health,iHitHP)
  1069. set_user_health(ent, iHitHP)
  1070. engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,g_msgDamage,{0.0,0.0,0.0},ent);
  1071. write_byte(floatround(tmpdmg))
  1072. write_byte(floatround(tmpdmg))
  1073. write_long(DMG_BULLET)
  1074. engfunc(EngFunc_WriteCoord,vecSrc[0])
  1075. engfunc(EngFunc_WriteCoord,vecSrc[1])
  1076. engfunc(EngFunc_WriteCoord,vecSrc[2])
  1077. message_end()
  1078. }
  1079. }
  1080. }
  1081. }
  1082.  
  1083. return
  1084. }
  1085.  
  1086. bool:pev_user_alive(ent)
  1087. {
  1088. new deadflag = pev(ent,pev_deadflag);
  1089. if(deadflag != DEAD_NO)
  1090. return false;
  1091. return true;
  1092. }
  1093.  
  1094. CreateExplosion(iCurrent)
  1095. {
  1096.  
  1097. new Float:vOrigin[3];
  1098. pev(iCurrent,pev_origin,vOrigin);
  1099.  
  1100. message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  1101. write_byte(99); //99 = KillBeam
  1102. write_short(iCurrent);
  1103. message_end();
  1104.  
  1105. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vOrigin, 0);
  1106. write_byte(TE_EXPLOSION);
  1107. engfunc(EngFunc_WriteCoord,vOrigin[0]);
  1108. engfunc(EngFunc_WriteCoord,vOrigin[1]);
  1109. engfunc(EngFunc_WriteCoord,vOrigin[2]);
  1110. write_short(boom);
  1111. write_byte(30);
  1112. write_byte(15);
  1113. write_byte(0);
  1114. message_end();
  1115. }
  1116.  
  1117. CreateLaserDamage(iCurrent,isHit)
  1118. {
  1119. if(isHit < 0 ) return PLUGIN_CONTINUE
  1120. switch(get_pcvar_num(g_LDMGMODE))
  1121. {
  1122. case 1:
  1123. {
  1124. if(pev(iCurrent,LASERMINE_HITING) == isHit)
  1125. return PLUGIN_CONTINUE
  1126. }
  1127. case 2:
  1128. {
  1129. if(pev(iCurrent,LASERMINE_HITING) == isHit)
  1130. {
  1131. static Float:cnt
  1132. static now,htime;now = floatround(get_gametime())
  1133.  
  1134. pev(iCurrent,LASERMINE_COUNT,cnt)
  1135. htime = floatround(cnt)
  1136. if(now - htime < get_pcvar_num(g_LDSEC))
  1137. {
  1138. return PLUGIN_CONTINUE;
  1139. }else{
  1140. set_pev(iCurrent,LASERMINE_COUNT,get_gametime())
  1141. }
  1142. }else
  1143. {
  1144. set_pev(iCurrent,LASERMINE_COUNT,get_gametime())
  1145. }
  1146. }
  1147. }
  1148.  
  1149. new Float:vOrigin[3],Float:vEnd[3]
  1150. pev(iCurrent,pev_origin,vOrigin)
  1151. pev(iCurrent,pev_vuser1,vEnd)
  1152.  
  1153. new teamid = pev(iCurrent, LASERMINE_TEAM)
  1154.  
  1155. new szClassName[32]
  1156. new Alive,God
  1157. new iHitTeam,iHitHP,id
  1158. new hitscore
  1159.  
  1160.  
  1161. szClassName[0] = '^0'
  1162. pev(isHit,pev_classname,szClassName,32)
  1163.  
  1164. if((pev(isHit, pev_flags) & (FL_CLIENT | FL_FAKECLIENT | FL_MONSTER)))
  1165. {
  1166. Alive = pev_user_alive(isHit)
  1167. God = get_user_godmode(isHit)
  1168. if(!Alive || God) return PLUGIN_CONTINUE
  1169.  
  1170. iHitTeam = int:cs_get_user_team(isHit)
  1171. iHitHP = pev_user_health(isHit) - get_pcvar_num(g_LDMG)
  1172. id = pev(iCurrent,LASERMINE_OWNER)//, szNetName[32]
  1173. if(iHitHP <= 0)
  1174. {
  1175. if(iHitTeam != teamid)
  1176. {
  1177. emit_sound(isHit, CHAN_WEAPON, ENT_SOUND4, 1.0, ATTN_NORM, 0, PITCH_NORM )
  1178. hitscore = 1
  1179. cs_set_user_money(id,cs_get_user_money(id) + get_pcvar_num(g_LFMONEY))
  1180. set_score(id,isHit,hitscore,iHitHP)
  1181. }else
  1182. {
  1183. if(get_pcvar_num(g_LFF))
  1184. {
  1185. emit_sound(isHit, CHAN_WEAPON, ENT_SOUND4, 1.0, ATTN_NORM, 0, PITCH_NORM )
  1186. hitscore = -1
  1187. cs_set_user_money(id,cs_get_user_money(id) - get_pcvar_num(g_LFMONEY))
  1188. set_score(id,isHit,hitscore,iHitHP)
  1189. }
  1190. }
  1191. }else if(iHitTeam != teamid || get_pcvar_num(g_LFF))
  1192. {
  1193. emit_sound(isHit, CHAN_WEAPON, ENT_SOUND4, 1.0, ATTN_NORM, 0, PITCH_NORM )
  1194. set_user_health(isHit,iHitHP)
  1195. set_pev(iCurrent,LASERMINE_HITING,isHit);
  1196.  
  1197. engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,g_msgDamage,{0.0,0.0,0.0},isHit);
  1198. write_byte(get_pcvar_num(g_LDMG))
  1199. write_byte(get_pcvar_num(g_LDMG))
  1200. write_long(DMG_BULLET)
  1201. engfunc(EngFunc_WriteCoord,vOrigin[0])
  1202. engfunc(EngFunc_WriteCoord,vOrigin[1])
  1203. engfunc(EngFunc_WriteCoord,vOrigin[2])
  1204. message_end()
  1205. }
  1206. }else if(equal(szClassName, ENT_CLASS_NAME3))
  1207. {
  1208. new hl;
  1209. hl = pev_user_health(isHit);
  1210. set_user_health(isHit,hl-get_pcvar_num(g_LDMG));
  1211. }
  1212. return PLUGIN_CONTINUE
  1213. }
  1214.  
  1215. stock pev_user_health(id)
  1216. {
  1217. new Float:health
  1218. pev(id,pev_health,health)
  1219. return floatround(health)
  1220. }
  1221.  
  1222. stock set_user_health(id,health)
  1223. {
  1224. health > 0 ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  1225. }
  1226.  
  1227. stock get_user_godmode(index) {
  1228. new Float:val
  1229. pev(index, pev_takedamage, val)
  1230.  
  1231. return (val == DAMAGE_NO)
  1232. }
  1233.  
  1234. stock set_user_frags(index, frags)
  1235. {
  1236. set_pev(index, pev_frags, float(frags))
  1237.  
  1238. return 1
  1239. }
  1240.  
  1241. stock pev_user_frags(index)
  1242. {
  1243. new Float:frags;
  1244. pev(index,pev_frags,frags);
  1245. return floatround(frags);
  1246. }
  1247.  
  1248. set_score(id,target,hitscore,HP){
  1249.  
  1250. new idfrags = pev_user_frags(id) + hitscore// get_user_frags(id) + hitscore
  1251. set_user_frags(id,idfrags)
  1252. //set_user_frags(id, idfrags)
  1253. //entity_set_float(id, EV_FL_frags, float(idfrags))
  1254.  
  1255. new tarfrags = pev_user_frags(target) + 1 //get_user_frags(target) + 1
  1256. set_user_frags(target,tarfrags)
  1257. //set_user_frags(target,tarfrags)
  1258. //entity_set_float(target, EV_FL_frags, float(tarfrags))
  1259.  
  1260. new idteam = int:cs_get_user_team(id)
  1261. new iddeaths = cs_get_user_deaths(id)
  1262.  
  1263.  
  1264. message_begin(MSG_ALL, g_msgDeathMsg, {0, 0, 0} ,0)
  1265. write_byte(id)
  1266. write_byte(target)
  1267. write_byte(0)
  1268. write_string(ENT_CLASS_NAME)
  1269. message_end()
  1270.  
  1271. message_begin(MSG_ALL, g_msgScoreInfo)
  1272. write_byte(id)
  1273. write_short(idfrags)
  1274. write_short(iddeaths)
  1275. write_short(0)
  1276. write_short(idteam)
  1277. message_end()
  1278.  
  1279. set_msg_block(g_msgDeathMsg, BLOCK_ONCE)
  1280.  
  1281. //entity_set_float(target, EV_FL_health,float(HP))
  1282. set_user_health(target, HP)
  1283. //set_pev(target,pev_health,HP)
  1284.  
  1285. }
  1286.  
  1287. public BuyLasermine(id)
  1288. {
  1289. if( !CanCheck(id,1) ) return PLUGIN_CONTINUE
  1290. cs_set_user_money(id,cs_get_user_money(id) - get_pcvar_num(g_LCOST))
  1291. g_havemine[id]++;
  1292. client_print(id, print_chat, "%s %s",CHATTAG,STR_BOUGHT)
  1293. emit_sound(id, CHAN_ITEM, ENT_SOUND5, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1294. ShowAmmo(id)
  1295. return PLUGIN_HANDLED
  1296. }
  1297.  
  1298. ShowAmmo(id)
  1299. {
  1300. new ammo[51]
  1301. formatex(ammo, 50, "%s %i/%i",STR_STATE, g_havemine[id],get_pcvar_num(g_LAMMO))
  1302.  
  1303. message_begin(MSG_ONE, g_msgStatusText, {0,0,0}, id)
  1304. write_byte(0)
  1305. write_string(ammo)
  1306. message_end()
  1307. }
  1308.  
  1309. public showInfo(id)
  1310. {
  1311. client_print(id, print_chat, STR_REF)
  1312. }
  1313.  
  1314. public say_lasermine(id){
  1315. new said[32]
  1316. read_argv(1,said,31);
  1317. if( !get_pcvar_num( g_LENABLE ) ){
  1318. // client_print(id, print_chat, "%s Lasermines are not currently active.",CHATTAG)
  1319. return PLUGIN_CONTINUE
  1320. }
  1321.  
  1322. if (equali(said,"/buy lasermine")||equali(said,"/lm")){
  1323. BuyLasermine(id)
  1324. }else if (equali(said, "lasermine") || equali(said, "/lasermine")){
  1325. const SIZE = 1024
  1326. new msg[SIZE+1],len = 0;
  1327. len += formatex(msg[len], SIZE - len, "<html><body>")
  1328. len += formatex(msg[len], SIZE - len, "<p><b>LaserMine</b></p><br/><br/>")
  1329. len += formatex(msg[len], SIZE - len, "<p>You can be setting the mine on the wall.</p><br/>")
  1330. len += formatex(msg[len], SIZE - len, "<p>That laser will give what touched it damage.</p><br/><br/>")
  1331. len += formatex(msg[len], SIZE - len, "<p><b>LaserMine Commands</b></p><br/><br/>")
  1332. len += formatex(msg[len], SIZE - len, "<p><b>Say /buy lasermine</b> or <b>Say /lm</b> //buying lasermine<br/>")
  1333. len += formatex(msg[len], SIZE - len, "<b>buy_lasermine</b> //bind ^"F2^" buy_lasermine : using F2 buying lasermine<br/>")
  1334. len += formatex(msg[len], SIZE - len, "<b>+setlaser</b> //bind mouse3 +setlaser : using mouse3 set lasermine on wall<br/>")
  1335. len += formatex(msg[len], SIZE - len, "</body></html>")
  1336. show_motd(id, msg, "Lasermine Entity help")
  1337. return PLUGIN_CONTINUE
  1338. }
  1339. else if (containi(said, "laser") != -1) {
  1340. showInfo(id)
  1341. return PLUGIN_CONTINUE
  1342. }
  1343. return PLUGIN_CONTINUE
  1344. }
  1345.  
  1346. public standing(id)
  1347. {
  1348. if (!g_settinglaser[id])
  1349. return PLUGIN_CONTINUE
  1350.  
  1351. set_pev(id, pev_maxspeed, 1.0)
  1352. // ShowAmmo(id)
  1353.  
  1354. return PLUGIN_CONTINUE
  1355. }
  1356.  
  1357. public ltm_PostThink(id)
  1358. {
  1359. if (!g_settinglaser[id] && plsetting[id]){
  1360. resetspeed(id)
  1361. }
  1362. else if (g_settinglaser[id] && !plsetting[id]) {
  1363. pev(id, pev_maxspeed,plspeed[id])
  1364. set_pev(id, pev_maxspeed, 1.0)
  1365. }
  1366. plsetting[id] = g_settinglaser[id]
  1367. return FMRES_IGNORED
  1368. }
  1369.  
  1370. public ltm_PreThink(id)
  1371. {
  1372. // if (!pev_user_alive(id) || g_settinglaser[id] == true || is_user_bot(id) || get_pcvar_num(g_LCMDMODE) == 1)
  1373. // return;
  1374.  
  1375. // if(pev(id, pev_button ) & IN_USE && !(pev(id, pev_oldbuttons ) & IN_USE ))
  1376. // CreateLaserMine_Progress(id)
  1377.  
  1378.  
  1379. new tgt,body,Float:vo[3],Float:to[3];
  1380. get_user_aiming(id,tgt,body);
  1381. if(pev_valid(tgt)) {
  1382. pev(id,pev_origin,vo);
  1383. pev(tgt,pev_origin,to);
  1384. new EntityName[32];
  1385. pev(tgt, pev_classname, EntityName, 31);
  1386. if(equal(EntityName, ENT_CLASS_NAME)) {
  1387. new OwnerName[32];
  1388. get_user_name(pev(tgt, LASERMINE_OWNER), OwnerName, 31);
  1389. switch (pev(tgt,LASERMINE_TEAM))
  1390. {
  1391. case CS_TEAM_T: set_hudmessage(200, 0, 0, -1.0, 0.60, 0, 6.0, 1.1, 0.0, 0.0, -1)
  1392. case CS_TEAM_CT:set_hudmessage(0, 200, 230, -1.0, 0.60, 0, 6.0, 1.1, 0.0, 0.0, -1)
  1393. }
  1394. show_hudmessage(id, "Owner: %s^nViata: %d ", OwnerName, pev(tgt,pev_health))
  1395. }
  1396. }
  1397. }
  1398.  
  1399. resetspeed(id)
  1400. {
  1401. set_pev(id, pev_maxspeed, plspeed[id])
  1402. }
  1403.  
  1404. public client_putinserver(id){
  1405. g_deployed[id] = 0;
  1406. g_havemine[id] = 0;
  1407. DeleteTask(id);
  1408. return PLUGIN_CONTINUE
  1409. }
  1410.  
  1411. public client_disconnect(id){
  1412. if(!get_pcvar_num( g_LENABLE ))
  1413. return PLUGIN_CONTINUE
  1414. DeleteTask(id);
  1415. RemoveAllTripmines(id);
  1416. return PLUGIN_CONTINUE
  1417. }
  1418.  
  1419.  
  1420. public newround(id){
  1421. if(!get_pcvar_num( g_LENABLE ))
  1422. return PLUGIN_CONTINUE
  1423. pev(id, pev_maxspeed,plspeed[id])
  1424. DeleteTask(id);
  1425. RemoveAllTripmines(id);
  1426. delaycount(id);
  1427. SetStartAmmo(id);
  1428. return PLUGIN_CONTINUE
  1429. }
  1430.  
  1431. public DeathEvent(){
  1432. if(!get_pcvar_num( g_LENABLE ))
  1433. return PLUGIN_CONTINUE
  1434.  
  1435. new id = read_data(2)
  1436. if(is_user_connected(id)) DeleteTask(id);
  1437. return PLUGIN_CONTINUE
  1438. }
  1439.  
  1440. public RemoveAllTripmines( i_Owner )
  1441. {
  1442. new iEnt = g_MaxPL + 1;
  1443. new clsname[32];
  1444. while( ( iEnt = engfunc( EngFunc_FindEntityByString, iEnt, "classname", ENT_CLASS_NAME ) ) )
  1445. {
  1446. if ( i_Owner )
  1447. {
  1448. if( pev( iEnt, LASERMINE_OWNER ) != i_Owner )
  1449. continue;
  1450. clsname[0] = '^0'
  1451. pev( iEnt, pev_classname, clsname, sizeof(clsname)-1 );
  1452.  
  1453. if ( equali( clsname, ENT_CLASS_NAME ) )
  1454. {
  1455. PlaySound( iEnt, STOP_SOUND );
  1456. RemoveEntity( iEnt );
  1457. }
  1458. }
  1459. else
  1460. set_pev( iEnt, pev_flags, FL_KILLME );
  1461. }
  1462. g_deployed[i_Owner]=0;
  1463. }
  1464.  
  1465. SetStartAmmo(id)
  1466. {
  1467. new stammo = get_pcvar_num(g_LSTAMMO);
  1468. if(stammo <= 0) return PLUGIN_CONTINUE;
  1469. g_havemine[id] = (g_havemine[id] <= stammo) ? stammo : g_havemine[id];
  1470. return PLUGIN_CONTINUE;
  1471. }
  1472.  
  1473. public CutDeploy_onDamage(id)
  1474. {
  1475. if(get_user_health(id) < 1)
  1476. DeleteTask(id);
  1477. }
  1478.  
  1479. #if defined BIOHAZARD_SUPPORT
  1480. public event_infect2(id)
  1481. {
  1482. DeleteTask(id);
  1483. return PLUGIN_CONTINUE
  1484. }
  1485. #endif
  1486.  
  1487. DeleteTask(id)
  1488. {
  1489. if (task_exists((TASK_PLANT + id)))
  1490. {
  1491. remove_task((TASK_PLANT + id))
  1492. }
  1493. if (task_exists((TASK_RELEASE + id)))
  1494. {
  1495. remove_task((TASK_RELEASE + id))
  1496. }
  1497. g_settinglaser[id] = false
  1498. return PLUGIN_CONTINUE;
  1499. }
  1500.  
  1501. // Gets offset data
  1502. get_offset_value(id, type)
  1503. {
  1504. new key = -1;
  1505. switch(type)
  1506. {
  1507. case OFFSET_TEAM: key = OFFSET_TEAM;
  1508. case OFFSET_MONEY:
  1509. {
  1510. #if defined UL_MONEY_SUPPORT
  1511. return cs_get_user_money_ul(id);
  1512. #else
  1513. key = OFFSET_MONEY;
  1514. #endif
  1515. }
  1516. case OFFSET_DEATH: key = OFFSET_DEATH;
  1517. }
  1518.  
  1519. if(key != -1)
  1520. {
  1521. if(is_amd64_server()) key += 25;
  1522. return get_pdata_int(id, key);
  1523. }
  1524.  
  1525. return -1;
  1526. }
  1527.  
  1528. // Sets offset data
  1529. set_offset_value(id, type, value)
  1530. {
  1531. new key = -1;
  1532. switch(type)
  1533. {
  1534. case OFFSET_TEAM: key = OFFSET_TEAM;
  1535. case OFFSET_MONEY:
  1536. {
  1537. #if defined UL_MONEY_SUPPORT
  1538. return cs_set_user_money_ul(id, value);
  1539. #else
  1540. key = OFFSET_MONEY;
  1541.  
  1542. // Send Money message to update player's HUD
  1543. message_begin(MSG_ONE_UNRELIABLE, g_msgMoney, {0,0,0}, id);
  1544. write_long(value);
  1545. write_byte(1); // Flash (difference between new and old money)
  1546. message_end();
  1547. #endif
  1548. }
  1549. case OFFSET_DEATH: key = OFFSET_DEATH;
  1550. }
  1551.  
  1552. if(key != -1)
  1553. {
  1554. if(is_amd64_server()) key += 25;
  1555. set_pdata_int(id, key, value);
  1556. }
  1557.  
  1558. return PLUGIN_CONTINUE;
  1559. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement