Advertisement
Guest User

Inżynier cod mod

a guest
Aug 14th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.53 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <codmod>
  6. #include <fakemeta>
  7. #include <engine>
  8. #include <fakemeta_util>
  9. #include <hamsandwich>
  10. #include <cstrike>
  11. #include <xs>
  12.  
  13. #define SENTRY_THINK 0.3
  14.  
  15. #define OFFSET_WPN_LINUX 4
  16. #define OFFSET_WPN_WIN 41
  17.  
  18. #define fm_point_contents(%1) engfunc(EngFunc_PointContents, %1)
  19.  
  20. #define fm_DispatchSpawn(%1) dllfunc(DLLFunc_Spawn, %1)
  21.  
  22. new const nazwa_klasy[] = "Inzynier [VIP]";
  23. new const opis_klasy[] = "Moze stawiac dzialko";
  24. new bronie_klasy = 1<<CSW_MAC10 | 1<<CSW_P90;
  25. new zdrowie_klasy = 20;
  26. new kondycja_klasy = 35;
  27. new inteligencja_klasy = -5;
  28. new wytrzymalosc_klasy = -10;
  29.  
  30. new bool:ma_klase[33];
  31. new bool:ma_dzialko[33];
  32. new gMenuDzialko[33]
  33.  
  34. new g_maxplayers;
  35.  
  36. new mdl_gib_build1
  37. new mdl_gib_build2
  38. new mdl_gib_build3
  39. new mdl_gib_build4
  40.  
  41. static const Nazwy_broni[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
  42. "weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
  43. "weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
  44. "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
  45. "weapon_ak47", "weapon_knife", "weapon_p90" }
  46.  
  47. new pcvarPercent,pcvarHealth,pcvarDamage;
  48.  
  49. public plugin_init()
  50. {
  51. register_plugin(nazwa_klasy, "0.1", "DarkGL & Szymek");
  52.  
  53. register_event("HLTV", "NowaRunda", "a", "1=0", "2=0");
  54.  
  55. cod_register_class(nazwa_klasy, opis_klasy, bronie_klasy, zdrowie_klasy, kondycja_klasy, inteligencja_klasy, wytrzymalosc_klasy);
  56.  
  57. RegisterHam(Ham_Spawn, "player", "DajNoweDzialko", 1);
  58. RegisterHam(Ham_TakeDamage, "func_breakable", "fwHamTakeDamage" );
  59. RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack_Building")
  60.  
  61. for (new i = 1; i < sizeof Nazwy_broni; i++)
  62. {
  63. if (Nazwy_broni[i][0]) RegisterHam(Ham_Item_Deploy, Nazwy_broni[i], "ham_ItemDeploy_Post", 1)
  64. }
  65.  
  66. register_think("sentry_shot","sentry_shot")
  67.  
  68. g_maxplayers = get_maxplayers();
  69.  
  70. pcvarPercent = register_cvar("inzynier_percent","4")
  71. pcvarHealth = register_cvar("inzynier_health","600")
  72. pcvarDamage = register_cvar("inzynier_damage","15.0");
  73. }
  74.  
  75. public plugin_precache()
  76. {
  77. precache_sound("sentry_shoot.wav");
  78.  
  79. precache_model("models/v_tfc_spanner.mdl")
  80. precache_model("models/base2.mdl")
  81. precache_model("models/sentry2.mdl")
  82.  
  83. mdl_gib_build1 = engfunc(EngFunc_PrecacheModel,"models/mbarrel.mdl")
  84. mdl_gib_build2 = engfunc(EngFunc_PrecacheModel,"models/computergibs.mdl")
  85. mdl_gib_build3 = engfunc(EngFunc_PrecacheModel,"models/metalplategibs.mdl")
  86. mdl_gib_build4 = engfunc(EngFunc_PrecacheModel,"models/cindergibs.mdl")
  87.  
  88. precache_sound("debris/bustmetal1.wav");
  89. precache_sound("debris/bustmetal2.wav");
  90. }
  91.  
  92. public fwHamTakeDamage( this, idinflictor, idattacker, Float:damage, damagebits ) {
  93. static classname[ 20 ];
  94. pev( this, pev_classname, classname, 19 );
  95.  
  96. if( ( equal( classname, "sentry_shot" ) || equal( classname, "sentry_base" ) ) && is_user_connected( idattacker ) && get_user_team(pev(this,pev_iuser1)) == get_user_team(idattacker) ){
  97. return HAM_SUPERCEDE;
  98. }
  99. return HAM_IGNORED;
  100.  
  101. }
  102.  
  103. public NowaRunda()
  104. {
  105. remove_entity_name("sentry_base")
  106. remove_entity_name("sentry_shot")
  107. }
  108.  
  109. public cod_class_enabled(id)
  110. {
  111.  
  112. ma_klase[id] = true;
  113. return COD_CONTINUE;
  114. }
  115.  
  116. public cod_class_disabled(id)
  117. {
  118. ma_klase[id] = false;
  119. }
  120.  
  121. public OpcjeDzialka(id)
  122. {
  123. new menu,newmenu,menupage
  124. player_menu_info(id,menu,newmenu,menupage);
  125. if(menu > 0 || newmenu != -1)
  126. {
  127. return PLUGIN_CONTINUE;
  128. }
  129.  
  130. gMenuDzialko[id] = menu_create("Dzialo", "OpcjeDziala_Handle");
  131. menu_additem(gMenuDzialko[id],"Postaw dzialo");
  132. menu_additem(gMenuDzialko[id],"Zniszcz dzialo");
  133.  
  134. menu_setprop(gMenuDzialko[id],MPROP_NUMBER_COLOR,"\r")
  135. menu_display(id,gMenuDzialko[id]);
  136. return PLUGIN_CONTINUE;
  137. }
  138.  
  139. public OpcjeDziala_Handle(id,menu,item)
  140. {
  141. if(item == MENU_EXIT || !is_user_alive(id))
  142. {
  143. menu_destroy(menu);
  144. return PLUGIN_CONTINUE;
  145. }
  146. switch(item)
  147. {
  148. case 0:
  149. {
  150. if(ma_klase[id] && ma_dzialko[id])
  151. {
  152. new Float:Origin[3]
  153. pev(id, pev_origin, Origin)
  154. new Float:vNewOrigin[3]
  155. new Float:vTraceDirection[3]
  156. new Float:vTraceEnd[3]
  157. new Float:vTraceResult[3]
  158. velocity_by_aim(id, 64, vTraceDirection) // get a velocity in the directino player is aiming, with a multiplier of 64...
  159. vTraceEnd[0] = vTraceDirection[0] + Origin[0]
  160. vTraceEnd[1] = vTraceDirection[1] + Origin[1]
  161. vTraceEnd[2] = vTraceDirection[2] + Origin[2]
  162. fm_trace_line(id, Origin, vTraceEnd, vTraceResult)
  163. vNewOrigin[0] = vTraceResult[0]
  164. vNewOrigin[1] = vTraceResult[1]
  165. vNewOrigin[2] = Origin[2]
  166. if(!(StawDzialo(vNewOrigin,id)))
  167. {
  168. client_print(id, print_center, "Nie mozesz tu postawic dziala!")
  169. }
  170. else
  171. {
  172. ma_dzialko[id] = false;
  173. }
  174. }
  175. }
  176. case 1:
  177. {
  178. new iEnt = -1;
  179. while((iEnt = find_ent_by_class(iEnt,"sentry_shot")) != 0)
  180. {
  181. if(pev_valid(iEnt) && pev(iEnt,pev_iuser1) == id)
  182. {
  183. FX_Demolish(iEnt)
  184. remove_entity(iEnt);
  185. }
  186. }
  187. iEnt = -1;
  188. while((iEnt = find_ent_by_class(iEnt,"sentry_base")) != 0)
  189. {
  190. if(pev_valid(iEnt) && pev(iEnt,pev_iuser1) == id)
  191. {
  192. FX_Demolish(iEnt)
  193. remove_entity(iEnt);
  194. }
  195. }
  196. }
  197. }
  198. menu_destroy(menu);
  199. return PLUGIN_CONTINUE;
  200. }
  201.  
  202. public bool:StawDzialo(Float:origin[3],id)
  203. {
  204. if (fm_point_contents(origin) != CONTENTS_EMPTY || is_hull_default(origin, 32.0))
  205. {
  206. return false
  207. }
  208. new Float:hitPoint[3], Float:originDown[3]
  209. originDown = origin
  210. originDown[2] = -5000.0
  211. fm_trace_line(0, origin, originDown, hitPoint)
  212. new Float:DistanceFromGround = vector_distance(origin, hitPoint)
  213.  
  214. new Float:difference = 36.0 - DistanceFromGround
  215. if (difference < -1 * 10.0 || difference > 10.0) return false
  216.  
  217. new sentry_base = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_breakable"))
  218. if (!sentry_base){
  219. return false
  220. }
  221. set_pev(sentry_base, pev_classname, "sentry_base")
  222.  
  223. engfunc(EngFunc_SetModel, sentry_base, "models/base2.mdl")
  224. engfunc(EngFunc_SetSize, sentry_base, {-16.0, -16.0, 0.0}, {16.0, 16.0, 25.0})
  225. engfunc(EngFunc_SetOrigin, sentry_base, origin)
  226. new Float:fAngle[3];
  227. pev(id, pev_v_angle, fAngle)
  228. fAngle[0] = 0.0
  229. fAngle[1] += 180.0
  230. fAngle[2] = 0.0
  231. set_pev(sentry_base, pev_angles, fAngle)
  232. set_pev(sentry_base, pev_solid, SOLID_BBOX)
  233. set_pev(sentry_base, pev_movetype, MOVETYPE_TOSS)
  234. set_pev(sentry_base, pev_iuser1, id)
  235. set_pev(sentry_base, pev_iuser2, 0)
  236. set_pev(sentry_base, pev_iuser3, 0)
  237.  
  238. return true;
  239. }
  240.  
  241. public ham_ItemDeploy_Post(weapon_ent)
  242. {
  243. static owner
  244. owner = get_pdata_cbase(weapon_ent, OFFSET_WPN_WIN, OFFSET_WPN_LINUX);
  245.  
  246. static weaponid
  247. weaponid = cs_get_weapon_id(weapon_ent)
  248.  
  249. if(!is_user_alive(owner))
  250. {
  251. return HAM_IGNORED;
  252. }
  253.  
  254. static menu,newmenu,menupage
  255. player_menu_info(owner,menu,newmenu,menupage);
  256.  
  257. if(gMenuDzialko[owner] && newmenu == gMenuDzialko[owner])
  258. {
  259. show_menu(owner,0,"^n");
  260. gMenuDzialko[owner] = 0;
  261. }
  262.  
  263. if(weaponid == CSW_KNIFE && ma_klase[owner])
  264. {
  265. entity_set_string(owner, EV_SZ_viewmodel, "models/v_tfc_spanner.mdl")
  266. OpcjeDzialka(owner);
  267. }
  268. return HAM_IGNORED;
  269. }
  270.  
  271.  
  272. stock FX_Demolish(build)
  273. {
  274. if(!pev_valid(build)) return;
  275.  
  276. new Float:forigin[3],iorigin[3],i
  277. pev(build, pev_origin, forigin)
  278. FVecIVec(forigin,iorigin)
  279.  
  280. for(i = 1;i <= 1;i++)
  281. {
  282. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  283. write_byte(TE_MODEL)
  284. write_coord(iorigin[0])
  285. write_coord(iorigin[1])
  286. write_coord(iorigin[2])
  287. write_coord(random_num(-150,150))
  288. write_coord(random_num(-150,150))
  289. write_coord(random_num(150,350))
  290. write_angle(random_num(0,360))
  291. write_short(mdl_gib_build1)
  292. write_byte(0) // bounce
  293. write_byte(10) // life
  294. message_end()
  295. }
  296. for(i = 1;i <= 1;i++)
  297. {
  298. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  299. write_byte(TE_MODEL)
  300. write_coord(iorigin[0])
  301. write_coord(iorigin[1])
  302. write_coord(iorigin[2])
  303. write_coord(random_num(-150,150))
  304. write_coord(random_num(-150,150))
  305. write_coord(random_num(150,350))
  306. write_angle(random_num(0,360))
  307. write_short(mdl_gib_build2)
  308. write_byte(0) // bounce
  309. write_byte(10) // life
  310. message_end()
  311. }
  312. for(i = 1;i <= 1;i++)
  313. {
  314. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  315. write_byte(TE_MODEL)
  316. write_coord(iorigin[0])
  317. write_coord(iorigin[1])
  318. write_coord(iorigin[2])
  319. write_coord(random_num(-150,150))
  320. write_coord(random_num(-150,150))
  321. write_coord(random_num(150,350))
  322. write_angle(random_num(0,360))
  323. write_short(mdl_gib_build3)
  324. write_byte(0) // bounce
  325. write_byte(10) // life
  326. message_end()
  327. }
  328. for(i = 1;i <= 1;i++)
  329. {
  330. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  331. write_byte(TE_MODEL)
  332. write_coord(iorigin[0])
  333. write_coord(iorigin[1])
  334. write_coord(iorigin[2])
  335. write_coord(random_num(-150,150))
  336. write_coord(random_num(-150,150))
  337. write_coord(random_num(150,350))
  338. write_angle(random_num(0,360))
  339. write_short(mdl_gib_build4)
  340. write_byte(0) // bounce
  341. write_byte(10) // life
  342. message_end()
  343. }
  344. }
  345.  
  346.  
  347.  
  348.  
  349. public DajNoweDzialko(id)
  350. {
  351. if(!is_user_connected(id) || !is_user_alive(id))
  352. return PLUGIN_CONTINUE;
  353.  
  354. if(ma_klase[id])
  355. {
  356. ma_dzialko[id] = true;
  357. }
  358. return PLUGIN_CONTINUE;
  359. }
  360.  
  361. set_animation(id, anim) {
  362. set_pev(id, pev_weaponanim, anim)
  363.  
  364. message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id)
  365. write_byte(anim)
  366. write_byte(pev(id, pev_body))
  367. message_end()
  368. }
  369.  
  370. public fw_TraceAttack_Building(id, enemy, Float:damage, Float:direction[3], tracehandle, damagetype){
  371. if (!(1 <= enemy <= g_maxplayers) || get_user_weapon(enemy) != CSW_KNIFE || !is_user_alive(enemy))
  372. {
  373. return HAM_IGNORED
  374. }
  375. new classname[24]
  376. pev(id, pev_classname, classname, sizeof classname - 1)
  377. new weapon = get_user_weapon(enemy)
  378. if(weapon == CSW_KNIFE && ma_klase[enemy] && pev(id,pev_iuser1) == enemy && equal(classname,"sentry_base") && pev(id,pev_iuser2) < 100){
  379. set_pev(id,pev_iuser2,pev(id,pev_iuser2)+get_pcvar_num(pcvarPercent) > 100 ? 100 : pev(id,pev_iuser2)+get_pcvar_num(pcvarPercent));
  380. set_animation(enemy,8);
  381. if(pev(id,pev_iuser2) >= 100 && !pev(id,pev_iuser3)){
  382. client_print(enemy,print_center,"%d %%",pev(id,pev_iuser2))
  383. set_pev(id,pev_iuser3,stawdzialo2(id));
  384. }
  385. else
  386. {
  387. client_print(enemy,print_center,"%d %%",pev(id,pev_iuser2))
  388. }
  389.  
  390. }
  391. return HAM_IGNORED
  392. }
  393.  
  394.  
  395. public stawdzialo2(ent)
  396. {
  397. new Float:origin[3];
  398. pev(ent,pev_origin,origin);
  399. new sentry_shot2 = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_breakable"))
  400. if (!sentry_shot2)
  401. {
  402. return 0
  403. }
  404. new szHealth[16]
  405. get_pcvar_string(pcvarHealth,szHealth,charsmax(szHealth))
  406.  
  407. fm_set_kvd(sentry_shot2, "health", szHealth, "func_breakable")
  408. fm_set_kvd(sentry_shot2, "material", "6", "func_breakable")
  409. fm_DispatchSpawn(sentry_shot2)
  410.  
  411. set_pev(sentry_shot2, pev_classname, "sentry_shot")
  412.  
  413. engfunc(EngFunc_SetModel, sentry_shot2, "models/sentry2.mdl")
  414. engfunc(EngFunc_SetSize, sentry_shot2, {-16.0, -16.0, 0.0}, {16.0, 16.0, 20.0})
  415. origin[2] += 25.0;
  416. engfunc(EngFunc_SetOrigin, sentry_shot2, origin)
  417. new Float:fAngle[3];
  418. pev(pev(ent,pev_iuser1), pev_v_angle, fAngle)
  419. fAngle[0] = 0.0
  420. fAngle[1] += 180.0
  421. fAngle[2] = 0.0
  422. set_pev(sentry_shot2, pev_angles, fAngle)
  423. set_pev(sentry_shot2, pev_solid, SOLID_BBOX)
  424. set_pev(sentry_shot2, pev_movetype, MOVETYPE_TOSS)
  425. set_pev(sentry_shot2, pev_iuser1, pev(ent,pev_iuser1))
  426. set_pev(sentry_shot2, pev_iuser2, ent)
  427.  
  428. set_pev( sentry_shot2, pev_sequence, 0 );
  429. set_pev( sentry_shot2, pev_animtime, get_gametime() );
  430. set_pev( sentry_shot2, pev_framerate, 1.0 );
  431.  
  432. set_pev(sentry_shot2, pev_nextthink, get_gametime() + SENTRY_THINK)
  433. return sentry_shot2;
  434. }
  435.  
  436. public sentry_find_player(ent)
  437. {
  438. new Float:fOrigin[3],Float:fOrigin2[3],Float:distance = 999999.0,Float:hitOrigin[3],iCloseId = 0,iOwner = 0;
  439. iOwner = pev(ent,pev_iuser1)
  440. pev(ent,pev_origin,fOrigin)
  441. for(new i = 1;i<33;i++)
  442. {
  443. if(!is_user_alive(i) || get_user_team(i) == get_user_team(iOwner))
  444. {
  445. continue;
  446. }
  447. pev(i, pev_origin, fOrigin2)
  448. new hitent = fm_trace_line(ent, fOrigin, fOrigin2, hitOrigin)
  449. if(distance > vector_distance(fOrigin,fOrigin2) && hitent == i)
  450. {
  451. distance = vector_distance(fOrigin,fOrigin2)
  452. iCloseId = i;
  453. }
  454. }
  455. return iCloseId;
  456. }
  457.  
  458. public sentry_shot(ent)
  459. {
  460. if(!pev_valid(ent))
  461. {
  462. return PLUGIN_CONTINUE;
  463. }
  464. if(entity_get_float(ent,EV_FL_health) <= 0.0)
  465. {
  466. if(pev_valid(pev(ent,pev_iuser2)))
  467. {
  468. remove_entity(pev(ent,pev_iuser2));
  469. }
  470. remove_entity(ent);
  471. return PLUGIN_CONTINUE;
  472. }
  473. new iFind = 0;
  474. if((iFind = sentry_find_player(ent)))
  475. {
  476. remove_task(ent+45676);
  477. turntotarget(ent,iFind);
  478. sentry_shot3(ent,iFind);
  479. set_task(0.5,"stop_anim",ent+45676)
  480. }
  481. set_pev(ent, pev_nextthink, get_gametime() + SENTRY_THINK)
  482. return PLUGIN_CONTINUE;
  483. }
  484.  
  485. public sentry_shot3(ent,target)
  486. {
  487. new Float:sentryOrigin[3], Float:targetOrigin[3], Float:hitOrigin[3]
  488. pev(ent, pev_origin, sentryOrigin)
  489. sentryOrigin[2] += 18.0
  490. pev(target, pev_origin, targetOrigin)
  491. targetOrigin[0] += random_float(-16.0, 16.0)
  492. targetOrigin[1] += random_float(-16.0, 16.0)
  493. targetOrigin[2] += random_float(-16.0, 16.0)
  494. new hit = fm_trace_line(ent, sentryOrigin, targetOrigin, hitOrigin)
  495. if(hit == target)
  496. {
  497. knockback_explode(target, sentryOrigin, 5.0)
  498. ExecuteHam(Ham_TakeDamage, target, 0, pev(ent,pev_iuser1),get_pcvar_float(pcvarDamage) , 1);
  499. set_pev( ent, pev_sequence, 1 );
  500. set_pev( ent, pev_animtime, get_gametime() );
  501. set_pev( ent, pev_framerate, 1.0 );
  502. }
  503. FX_Trace(sentryOrigin, hitOrigin)
  504. engfunc(EngFunc_EmitSound, ent, CHAN_STATIC, "sentry_shoot.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  505. }
  506.  
  507. public stop_anim(ent){
  508. ent -= 45676;
  509. if(pev_valid(ent)){
  510. set_pev( ent, pev_sequence, 0 );
  511. set_pev(ent, pev_animtime, get_gametime() );
  512. set_pev( ent, pev_framerate, 1.0 );
  513. }
  514. }
  515.  
  516. public knockback_explode(id, const Float:exp_origin[3], Float:force)
  517. {
  518. if(!is_user_alive(id)) return
  519.  
  520. if(force == 0.0) return
  521.  
  522. new Float:old_velocity[3], Float:velocity[3], Float:id_origin[3], Float:output[3]
  523. pev(id, pev_origin, id_origin);
  524. get_speed_vector(exp_origin, id_origin, force, velocity);
  525. pev(id, pev_velocity, old_velocity);
  526. xs_vec_add(velocity, old_velocity, output)
  527. set_pev(id, pev_velocity, output)
  528. }
  529.  
  530. public turntotarget(ent, target)
  531. {
  532. if (target)
  533. {
  534. new Float:closestOrigin[3],Float:sentryOrigin[3]
  535. pev(target, pev_origin, closestOrigin)
  536. pev(ent, pev_origin, sentryOrigin)
  537. new Float:newAngle[3]
  538. pev(ent, pev_angles, newAngle)
  539. new Float:x = closestOrigin[0] - sentryOrigin[0]
  540. new Float:z = closestOrigin[1] - sentryOrigin[1]
  541.  
  542. new Float:radians = floatatan(z/x, radian)
  543. newAngle[1] = radians * 180.0 / 3.14159
  544. if (closestOrigin[0] < sentryOrigin[0])
  545. newAngle[1] -= 180.0
  546.  
  547. new Float:h = closestOrigin[2] - sentryOrigin[2]
  548. new Float:b = vector_distance(sentryOrigin, closestOrigin)
  549. radians = floatatan(h/b, radian)
  550. new Float:degs = radians * 180.0 / 3.14159
  551. new Float:RADIUS = 830.0
  552. new Float:degreeByte = RADIUS/256.0
  553. new Float:tilt = 127.0 - degreeByte * degs
  554. set_pev(ent, pev_angles, newAngle)
  555. set_pev(ent, pev_controller_1, floatround(tilt))
  556. }
  557. }
  558.  
  559. stock FX_Trace(const Float:idorigin[3], const Float:targetorigin[3])
  560. {
  561. new id[3],target[3]
  562. FVecIVec(idorigin,id)
  563. FVecIVec(targetorigin,target)
  564. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  565. write_byte(6)//TE_TRACER
  566. write_coord(id[0])
  567. write_coord(id[1])
  568. write_coord(id[2])
  569. write_coord(target[0])
  570. write_coord(target[1])
  571. write_coord(target[2])
  572. message_end()
  573. }
  574.  
  575. stock bool:is_hull_default(Float:origin[3], const Float:BOUNDS){
  576. new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
  577. traceEnds[0][0] = origin[0] - BOUNDS
  578. traceEnds[0][1] = origin[1] - BOUNDS
  579. traceEnds[0][2] = origin[2] - BOUNDS
  580.  
  581. traceEnds[1][0] = origin[0] - BOUNDS
  582. traceEnds[1][1] = origin[1] - BOUNDS
  583. traceEnds[1][2] = origin[2] + BOUNDS
  584.  
  585. traceEnds[2][0] = origin[0] + BOUNDS
  586. traceEnds[2][1] = origin[1] - BOUNDS
  587. traceEnds[2][2] = origin[2] + BOUNDS
  588.  
  589. traceEnds[3][0] = origin[0] + BOUNDS
  590. traceEnds[3][1] = origin[1] - BOUNDS
  591. traceEnds[3][2] = origin[2] - BOUNDS
  592.  
  593. traceEnds[4][0] = origin[0] - BOUNDS
  594. traceEnds[4][1] = origin[1] + BOUNDS
  595. traceEnds[4][2] = origin[2] - BOUNDS
  596.  
  597. traceEnds[5][0] = origin[0] - BOUNDS
  598. traceEnds[5][1] = origin[1] + BOUNDS
  599. traceEnds[5][2] = origin[2] + BOUNDS
  600.  
  601. traceEnds[6][0] = origin[0] + BOUNDS
  602. traceEnds[6][1] = origin[1] + BOUNDS
  603. traceEnds[6][2] = origin[2] + BOUNDS
  604.  
  605. traceEnds[7][0] = origin[0] + BOUNDS
  606. traceEnds[7][1] = origin[1] + BOUNDS
  607. traceEnds[7][2] = origin[2] - BOUNDS
  608.  
  609. for (new i = 0; i < 8; i++) {
  610. if (fm_point_contents(traceEnds[i]) != CONTENTS_EMPTY)
  611. return true
  612.  
  613. hitEnt = fm_trace_line(0, origin, traceEnds[i], traceHit)
  614. if (hitEnt != 0)
  615. return true
  616. for (new j = 0; j < 3; j++)
  617. if (traceEnds[i][j] != traceHit[j])
  618. return true
  619. }
  620. return false
  621. }
  622.  
  623. stock get_speed_vector(const Float:origin1[3], const Float:origin2[3], Float:force, Float:new_velocity[3])
  624. {
  625. new_velocity[0] = origin2[0] - origin1[0]
  626. new_velocity[1] = origin2[1] - origin1[1]
  627. new_velocity[2] = origin2[2] - origin1[2]
  628. new Float:num = floatsqroot(force*force / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  629. new_velocity[0] *= num
  630. new_velocity[1] *= num
  631. new_velocity[2] *= num
  632.  
  633. return 1;
  634. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement