Junior Member
|
11-02-2023
, 14:48
Issue with lasermine knockback
|
#1
|
I'm using this Lasermine plugin that I found on the internet,
The main points it has are:
1- It has a menu to Setlaser, Dellaser
2- Has the ability to project the mine before deploy it
Then I found a Tripmine plugin that has the functionality of Tripmine... (Knockback instead of lasermine)
So I wanted to take knockback function of knockback into the first one...
The problem is the knockback works only in some places while other places it does not
Heres an example:
In zm_ice_attack3 in this place it doesn't work
And here it works
And I get this in the server console
Code:
--------------------------------------------------
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1158.714477 -558.471862 -1125.948486
flFraction: 0.526434
Velocity: -468.660858 -1460.798461 -512.902282
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 5793.572265 -2792.359375 -5629.742187
flFraction: 0.526434
Velocity: -2343.304199 -7303.992187 -2564.511474
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 24333.003906 -11727.909179 -23644.917968
flFraction: 0.526434
Velocity: -9841.877929 -30676.767578 -10770.948242
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 98490.726562 -47470.109375 -95705.617187
flFraction: 0.526434
Velocity: -39836.171875 -124167.867187 -43596.695312
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 395121.625000 -190438.906250 -383948.406250
flFraction: 0.526434
Velocity: -159813.343750 -498132.281250 -174899.687500
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1581645.250000 -762314.125000 -1536919.625000
flFraction: 0.526434
Velocity: -639722.062500 -1993989.875000 -700111.625000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 6327739.500000 -3049815.000000 -6148804.500000
flFraction: 0.526434
Velocity: -2559357.000000 -7977420.500000 -2800959.500000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 25312116.000000 -12199818.000000 -24596344.000000
flFraction: 0.526434
Velocity: -10237897.000000 -31911142.000000 -11204351.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 101249624.000000 -48799832.000000 -98386504.000000
flFraction: 0.526434
Velocity: -40952056.000000 -127646032.000000 -44817916.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 404999648.000000 -195199888.000000 -393547136.000000
flFraction: 0.526434
Velocity: -163808688.000000 -510585600.000000 -179272176.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1619999744.000000 -780800128.000000 -1574189696.000000
flFraction: 0.526434
Velocity: -655235200.000000 -2042343808.000000 -717089216.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 6480000000.000000 -3123201024.000000 -6296759808.000000
flFraction: 0.526434
Velocity: -2620941312.000000 -8169376768.000000 -2868357376.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 25920002048.000000 -12492805120.000000 -25187041280.000000
flFraction: 0.526434
Velocity: -10483765248.000000 -32677509120.000000 -11473430528.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 103680008192.000000 -49971220480.000000 -100748165120.000000
flFraction: 0.526434
Velocity: -41935060992.000000 -130710036480.000000 -45893722112.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 414720032768.000000 -199884881920.000000 -402992660480.000000
flFraction: 0.526434
Velocity: -167740243968.000000 -522840145920.000000 -183574888448.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1658880131072.000000 -799539527680.000000 -1611970641920.000000
flFraction: 0.526434
Velocity: -670960975872.000000 -2091360583680.000000 -734299553792.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 6635520524288.000000 -3198158110720.000000 -6447882567680.000000
flFraction: 0.526434
Velocity: -2683843903488.000000 -8365442334720.000000 -2937198215168.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 26542082097152.000000 -12792632442880.000000 -25791530270720.000000
flFraction: 0.526434
Velocity: -10735375613952.000000 -33461769338880.000000 -11748792860672.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 106168328388608.000000 -51170529771520.000000 -103166121082880.000000
flFraction: 0.526434
Velocity: -42941502455808.000000 -133847077355520.000000 -46995171442688.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 424673313554432.000000 -204682119086080.000000 -412664484331520.000000
flFraction: 0.526434
Velocity: -171766009823232.000000 -535388309422080.000000 -187980685770752.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1698693254217728.000000 -818728476344320.000000 -1650657937326080.000000
flFraction: 0.526434
Velocity: -687064039292928.000000 -2141553237688320.000000 -751922743083008.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 6794773016870912.000000 -3274913905377280.000000 -6602631749304320.000000
flFraction: 0.526434
Velocity: -2748256157171712.000000 -8566212950753280.000000 -3007690972332032.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 27179092067483640.000000 -13099655621509120.000000 -26410526997217280.000000
flFraction: 0.526434
Velocity: -10993024628686840.000000 -34264851803013120.000000 -12030763889328120.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 108716368269934500.000000 -52398622486036480.000000 -105642107988869100.000000
flFraction: 0.526434
Velocity: -43972098514747390.000000 -137059407212052400.000000 -48123055557312510.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 434865473079738300.000000 -209594489944145900.000000 -422568431955476400.000000
flFraction: 0.526434
Velocity: -175888394058989500.000000 -548237628848209900.000000 -192492222229250000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1739461892318953000.000000 -838377959776583600.000000 -1690273727821905000.000000
flFraction: 0.526434
Velocity: -703553576235958200.000000 -2192950515392839000.000000 -769968888917000100.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 6957847569275813000.000000 -3353511839106334000.000000 -6761094911287623000.000000
flFraction: 0.526434
Velocity: -2814214304943833000.000000 -8771802061571358000.000000 -3079875555668000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 27831390277103250000.000000 -13414047356425330000.000000 -27044379645150490000.000000
flFraction: 0.526434
Velocity: -11256857219775330000.000000 -35087208246285430000.000000 -12319502222672000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 111325561108413000000.000000 -53656189425701350000.000000 -108177518580601900000.000000
flFraction: 0.526434
Velocity: -45027428879101320000.000000 -140348832985141700000.000000 -49278008890688010000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 445302244433652000000.000000 -214624757702805400000.000000 -432710074322407900000.000000
flFraction: 0.526434
Velocity: -180109715516405300000.000000 -561395331940566900000.000000 -197112035562752000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1781208977734608000000.000000 -858499030811221600000.000000 -1730840297289631000000.000000
flFraction: 0.526434
Velocity: -720438862065621200000.000000 -2245581327762267000000.000000 -788448142251008100000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 7124835910938433000000.000000 -3433996123244886000000.000000 -6923361189158526000000.000000
flFraction: 0.526434
Velocity: -2881755448262485000000.000000 -8982325311049071000000.000000 -3153792569004032000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 28499343643753730000000.000000 -13735984492979540000000.000000 -27693444756634100000000.000000
flFraction: 0.526434
Velocity: -11527021793049940000000.000000 -35929301244196280000000.000000 -12615170276016130000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 113997374575014900000000.000000 -54943937971918190000000.000000 -110773779026536400000000.000000
flFraction: 0.526434
Velocity: -46108087172199760000000.000000 -143717204976785100000000.000000 -50460681104064520000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 455989498300059700000000.000000 -219775751887672700000000.000000 -443095116106145700000000.000000
flFraction: 0.526434
Velocity: -184432348688799000000000.000000 -574868819907140500000000.000000 -201842724416258100000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1823957993200238000000000.000000 -879103007550691000000000.000000 -1772380464424582000000000.000000
flFraction: 0.526434
Velocity: -737729394755196200000000.000000 -2299475279628562000000000.000000 -807370897665032400000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 7295831972800955000000000.000000 -3516412030202764000000000.000000 -7089521857698330000000000.000000
flFraction: 0.526434
Velocity: -2950917579020784000000000.000000 -9197901118514249000000000.000000 -3229483590660129000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 29183327891203810000000000.000000 -14065648120811050000000000.000000 -28358087430793320000000000.000000
flFraction: 0.526434
Velocity: -11803670316083130000000000.000000 -36791604474056990000000000.000000 -12917934362640510000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 116733311564815200000000000.000000 -56262592483244220000000000.000000 -113432349723173200000000000.000000
flFraction: 0.526434
Velocity: -47214681264332550000000000.000000 -147166417896227900000000000.000000 -51671737450562070000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 466933246259261100000000000.000000 -225050369932976800000000000.000000 -453729398892693100000000000.000000
flFraction: 0.526434
Velocity: -188858725057330200000000000.000000 -588665671584911900000000000.000000 -206686949802248200000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1867732985037044000000000000.000000 -900201479731907400000000000.000000 -1814917595570772000000000000.000000
flFraction: 0.526434
Velocity: -755434900229320900000000000.000000 -2354662686339647000000000000.000000 -826747799208993100000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 7470931940148178000000000000.000000 -3600805918927629000000000000.000000 -7259670382283090000000000000.000000
flFraction: 0.526434
Velocity: -3021739600917283000000000000.000000 -9418650745358591000000000000.000000 -3306991196835972000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 29883727760592710000000000000.000000 -14403223675710520000000000000.000000 -29038681529132360000000000000.000000
flFraction: 0.526434
Velocity: -12086958403669130000000000000.000000 -37674602981434360000000000000.000000 -13227964787343890000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 119534911042370800000000000000.000000 -57612894702842080000000000000.000000 -116154726116529400000000000000.000000
flFraction: 0.526434
Velocity: -48347833614676530000000000000.000000 -150698411925737400000000000000.000000 -52911859149375560000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 478139644169483400000000000000.000000 -230451578811368300000000000000.000000 -464618904466117800000000000000.000000
flFraction: 0.526434
Velocity: -193391334458706100000000000000.000000 -602793647702949800000000000000.000000 -211647436597502200000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1912558576677933000000000000000.000000 -921806315245473400000000000000.000000 -1858475617864471000000000000000.000000
flFraction: 0.526434
Velocity: -773565337834824600000000000000.000000 -2411174590811799000000000000000.000000 -846589746390009000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 7650234306711734000000000000000.000000 -3687225260981893000000000000000.000000 -7433902471457884000000000000000.000000
flFraction: 0.526434
Velocity: -3094261351339298000000000000000.000000 -9644698363247197000000000000000.000000 -3386358985560035000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 30600937226846940000000000000000.000000 -14748901043927570000000000000000.000000 -29735609885831540000000000000000.000000
flFraction: 0.526434
Velocity: -12377045405357190000000000000000.000000 -38578793452988780000000000000000.000000 -13545435942240140000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 122403748907387700000000000000000.000000 -58995604175710300000000000000000.000000 -118942439543326100000000000000000.000000
flFraction: 0.526434
Velocity: -49508181621428770000000000000000.000000 -154315173811955100000000000000000.000000 -54181743768960580000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 489614995629551000000000000000000.000000 -235982416702841100000000000000000.000000 -475769758173304600000000000000000.000000
flFraction: 0.526434
Velocity: -198032726485715000000000000000000.000000 -617260695247820600000000000000000.000000 -216726975075842200000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 1958459982518204000000000000000000.000000 -943929666811364600000000000000000.000000 -1903079032693218000000000000000000.000000
flFraction: 0.526434
Velocity: -792130905942860300000000000000000.000000 -2469042780991282000000000000000000.000000 -866907900303369100000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 7833839930072817000000000000000000.000000 -3775718667245459000000000000000000.000000 -7612316130772875000000000000000000.000000
flFraction: 0.526434
Velocity: -3168523623771441000000000000000000.000000 -9876171123965129000000000000000000.000000 -3467631601213477000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 31335359720291260000000000000000000.000000 -15102874668981830000000000000000000.000000 -30449264523091500000000000000000000.000000
flFraction: 0.526434
Velocity: -12674094495085760000000000000000000.000000 -39504684495860520000000000000000000.000000 -13870526404853900000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 125341438881165000000000000000000000.000000 -60411498675927340000000000000000000.000000 -121797058092365900000000000000000000.000000
flFraction: 0.526434
Velocity: -50696377980343060000000000000000000.000000 -158018737983442000000000000000000000.000000 -55482105619415630000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 501365755524660300000000000000000000.000000 -241645994703709300000000000000000000.000000 -487188232369463900000000000000000000.000000
flFraction: 0.526434
Velocity: -202785511921372200000000000000000000.000000 -632074951933768300000000000000000000.000000 -221928422477662500000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 2005463022098640000000000000000000000.000000 -966583978814837500000000000000000000.000000 -1948752929477855000000000000000000000.000000
flFraction: 0.526434
Velocity: -811142047685489000000000000000000000.000000 -2528299807735073000000000000000000000.000000 -887713689910650100000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 8021852088394563000000000000000000000.000000 -3866335915259349000000000000000000000.000000 -7795011717911422000000000000000000000.000000
flFraction: 0.526434
Velocity: -3244568190741956000000000000000000000.000000 -10113199230940290000000000000000000000.000000 -3550854759642600000000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 32087408353578250000000000000000000000.000000 -15465343661037390000000000000000000000.000000 -31180046871645690000000000000000000000.000000
flFraction: 0.526434
Velocity: -12978272762967820000000000000000000000.000000 -40452796923761170000000000000000000000.000000 -14203419038570400000000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 128349633414313000000000000000000000000.000000 -61861374644149600000000000000000000000.000000 -124720187486582700000000000000000000000.000000
flFraction: 0.526434
Velocity: -51913091051871290000000000000000000000.000000 -161811187695044600000000000000000000000.000000 -56813676154281600000000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -247445498576598300000000000000000000000.000000 -0.000000
flFraction: 0.526434
Velocity: -207652364207485100000000000000000000000.000000 -0.000000 -227254704617126400000000000000000000000.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
vecSrc: -104.143745 -200.031250 116.146583
Falloff: 1.480000
flFraction: 0.458965
Velocity: 0.000000 -0.000000 -0.000000
flFraction: 0.526434
Velocity: -0.000000 -0.000000 -0.000000
PM Got a NaN velocity 0
PM Got a NaN velocity 1
PM Got a NaN velocity 2
PM Got a NaN velocity 0
PM Got a NaN velocity 1
PM Got a NaN velocity 2
Here's the code and thanks for the help in advance:
Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <zombieplague>
// Item Name
new const ITEM_NAME[] = "Lasermines";
// Item Cost
const ITEM_COST = 20;
// Constants
const m_pOwner = EV_INT_iuser1;
const m_pBeam = EV_INT_iuser2;
const m_rgpDmgTime = EV_INT_iuser3;
const m_flPowerUp = EV_FL_starttime;
const m_vecEnd = EV_VEC_endpos;
const m_flSparks = EV_FL_ltime;
const MAXPLAYERS = 32;
new limit[33]
const OFFSET_CSMENUCODE = 205;
// Enums
enum _:tripmine_e
{
TRIPMINE_IDLE1 = 0,
TRIPMINE_IDLE2,
TRIPMINE_ARM1,
TRIPMINE_ARM2,
TRIPMINE_FIDGET,
TRIPMINE_HOLSTER,
TRIPMINE_DRAW,
TRIPMINE_WORLD,
TRIPMINE_GROUND,
};
enum
{
BEAM_POINTS = 0,
BEAM_ENTPOINT,
BEAM_ENTS,
BEAM_HOSE,
};
// Tasks
const TASK_SETLASER = 100;
const TASK_DELLASER = 200;
const TASK_IDLE = 300;
// Variables
new g_iMsgBarTime;
new g_iTripmine[MAXPLAYERS+1], g_iTripmineHealth[MAXPLAYERS+1][100], bool:g_bCantPlant[MAXPLAYERS+1];
new g_iTripmineId, cvar_tripmine_health, cvar_tripmine_bonus;
new CvarDamage, CvarRadius, CvarKbForce;
new g_iMsgSayTxt
new boom
new const Spr_Explode[] = "sprites/zerogxplode.spr"
public plugin_init()
{
register_plugin("[ZP] Extra Item: Laser Tripmine", "1.0", "Lost-Souls")
// Register Message
g_iMsgBarTime = get_user_msgid("BarTime");
// Register Event
register_event("HLTV", "EventNewRound", "a", "1=0", "2=0");
// Register Item
g_iTripmineId = zp_register_extra_item(ITEM_NAME, ITEM_COST, ZP_TEAM_HUMAN);
// Register Forwards
RegisterHam(Ham_Killed, "player", "CBasePlayer_Killed_Post", 1);
RegisterHam(Ham_TakeDamage, "player", "CBasePlayer_TakeDamage_Pre");
RegisterHam(Ham_TakeDamage, "info_target", "Tripmine_TakeDamage_Pre");
RegisterHam(Ham_TakeDamage, "info_target", "Tripmine_TakeDamage_Post", 1);
RegisterHam(Ham_Killed, "info_target", "Tripmine_Killed_Post", 1);
register_forward(FM_OnFreeEntPrivateData, "OnFreeEntPrivateData");
register_forward(FM_TraceLine, "Tripmine_ShowInfo_Post", 1);
// Register Think
register_think("zp_tripmine", "Tripmine_Think");
// Register Cvars
cvar_tripmine_health = register_cvar("zp_tripmine_health", "455");
cvar_tripmine_bonus = register_cvar("zp_tripmine_bonus", "3");
g_iMsgSayTxt = get_user_msgid("SayText")
// Register Binds
register_concmd("+setlaser", "CmdSetLaser");
register_concmd("-setlaser", "CmdUnsetLaser");
register_concmd("+dellaser", "CmdDelLaser");
register_concmd("-dellaser", "CmdUndelLaser");
// Register Commands
register_clcmd("say /lm", "showMenuLasermine");
register_clcmd("say_team /lm", "showMenuLasermine");
CvarDamage = register_cvar("tripmine_damage", "444")
CvarRadius = register_cvar("tripmine_radius", "300")
CvarKbForce = register_cvar("tripmine_kb_force", "5")
}
public plugin_precache()
{
precache_model("models/TM_Server/Lasermine/lasermine.mdl");
precache_model("sprites/laserbeam.spr");
precache_sound("weapons/mine_deploy.wav");
precache_sound("weapons/mine_charge.wav");
precache_sound("weapons/mine_activate.wav");
precache_sound("debris/beamstart9.wav");
precache_model("sprites/zerogxplode.spr");
boom = precache_model(Spr_Explode);
}
// The first three public fuctions below make sure that this plugin won't stop running if the modules below ain't running
public plugin_natives()
{
set_module_filter("moduleFilter")
set_native_filter("nativeFilter")
}
public moduleFilter(const szModule[])
{
return PLUGIN_CONTINUE;
}
public nativeFilter(const szName[], iId, iTrap)
{
if (!iTrap)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public client_disconnected(this)
{
g_iTripmine[this] = 0;
Tripmine_Kill(this);
}
public EventNewRound()
{
new pTripmine = -1;
while ((pTripmine = find_ent_by_class(pTripmine, "zp_tripmine")) != 0)
remove_entity(pTripmine);
arrayset(g_iTripmine, 0, sizeof g_iTripmine);
new rgpPlayers[MAXPLAYERS], iPlayersCount, pPlayer;
get_players(rgpPlayers, iPlayersCount);
for (new i = 0; i < iPlayersCount; i++)
{
pPlayer = rgpPlayers[i];
limit[pPlayer] = 0
Tripmine_Kill(pPlayer);
}
}
public CmdSetLaser(this)
{
if (!is_user_alive(this))
return PLUGIN_HANDLED;
if (zp_get_user_zombie(this))
return PLUGIN_HANDLED;
if (task_exists(this+TASK_SETLASER))
return PLUGIN_HANDLED;
if (!g_iTripmine[this])
{
client_printcolor(this, "!y[!gZP!y] You do not have lasermines to plant");
return PLUGIN_HANDLED;
}
if (task_exists(this+TASK_DELLASER))
return PLUGIN_HANDLED;
new rgpData[1];
new pTripmine = rgpData[0] = Tripmine_Spawn(this);
Tripmine_RelinkTripmine(pTripmine);
if (g_bCantPlant[this])
{
client_printcolor(this, "!y[!gZP!y] You Can't plant a !gLasermine !yat this location!");
Tripmine_Kill(this);
return PLUGIN_HANDLED;
}
set_task(0.27, "TaskIdle", this+TASK_IDLE, rgpData, sizeof rgpData, "b");
set_task(1.0, "TaskSetLaser", this+TASK_SETLASER, rgpData, sizeof rgpData);
BarTime(this, 1);
emit_sound(this, CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
return PLUGIN_HANDLED;
}
public CmdUnsetLaser(this)
{
if (!task_exists(this+TASK_SETLASER))
return PLUGIN_HANDLED;
Tripmine_Kill(this);
return PLUGIN_HANDLED;
}
public CmdDelLaser(this)
{
if (!is_user_alive(this))
return PLUGIN_HANDLED;
if (zp_get_user_zombie(this))
return PLUGIN_HANDLED;
if (task_exists(this+TASK_SETLASER))
return PLUGIN_HANDLED;
new iBody, pEnt;
get_user_aiming(this, pEnt, iBody, 128);
if (!is_valid_ent(pEnt))
return PLUGIN_HANDLED;
new szClassName[32];
entity_get_string(pEnt, EV_SZ_classname, szClassName, charsmax(szClassName));
if (!equal(szClassName, "zp_tripmine"))
return PLUGIN_HANDLED;
if (entity_get_int(pEnt, m_pOwner) != this)
return PLUGIN_HANDLED;
new rgpData[1];
rgpData[0] = pEnt;
set_task(1.0, "TaskDelLaser", this+TASK_DELLASER, rgpData, sizeof rgpData);
set_task(0.27, "TaskIdle", this+TASK_IDLE, rgpData, sizeof rgpData, "b");
BarTime(this, 1);
emit_sound(this, CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
return PLUGIN_HANDLED;
}
public CmdUndelLaser(this)
{
if (!task_exists(this+TASK_DELLASER))
return PLUGIN_HANDLED;
Tripmine_Kill(this);
return PLUGIN_HANDLED;
}
public TaskIdle(rgpData[], iTaskId)
{
new Float:vecVelocity[3], pEnt, iBody;
new pPlayer = iTaskId - TASK_IDLE;
get_user_aiming(pPlayer, pEnt, iBody, 128);
entity_get_vector(pPlayer, EV_VEC_velocity, vecVelocity);
if (vector_length(vecVelocity) > 6.0 || task_exists(pPlayer+TASK_DELLASER) && rgpData[0] != pEnt)
Tripmine_Kill(pPlayer);
}
public TaskSetLaser(rgpData[], iTaskId)
{
new pPlayer = iTaskId - TASK_SETLASER;
if (g_bCantPlant[pPlayer])
{
client_printcolor(pPlayer, "!y[!gZP!y] Couldn't plant a !gLasermine!");
Tripmine_Kill(pPlayer);
return;
}
g_iTripmine[pPlayer] -= 1;
if (!g_iTripmine[pPlayer])
client_printcolor(pPlayer, "!y[!gZP!y] You do not have any more lasermines");
else
client_printcolor(pPlayer, "!y[!gZP!y] You have !g%d !ymore Lasermine(s) to plant", g_iTripmine[pPlayer]);
new pBeam = entity_get_int(rgpData[0], m_pBeam);
remove_task(pPlayer+TASK_IDLE);
entity_set_vector(pBeam, EV_VEC_rendercolor, Float:{150.0, 0.0, 0.0});
entity_set_int(pBeam, EV_INT_effects, entity_get_int(pBeam, EV_INT_effects) | EF_NODRAW);
Tripmine_Render(rgpData[0]);
entity_set_float(rgpData[0], EV_FL_nextthink, get_gametime() + 2.5);
entity_set_float(rgpData[0], m_flPowerUp, 1.0);
entity_set_int(rgpData[0], EV_INT_rendermode, kRenderNormal);
emit_sound(rgpData[0], CHAN_VOICE, "weapons/mine_deploy.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
emit_sound(rgpData[0], CHAN_BODY, "weapons/mine_charge.wav", 0.2, ATTN_NORM, 0, PITCH_NORM);
}
public TaskDelLaser(rgpData[], iTaskId)
{
if (!is_valid_ent(rgpData[0]))
return;
new pPlayer = iTaskId - TASK_DELLASER;
g_iTripmineHealth[pPlayer][g_iTripmine[pPlayer]] = floatround(entity_get_float(rgpData[0], EV_FL_health));
remove_entity(rgpData[0]);
remove_task(pPlayer+TASK_IDLE);
emit_sound(pPlayer, CHAN_ITEM, "weapons/c4_disarmed.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
g_iTripmine[pPlayer]++;
}
public zp_user_humanized_post(this)
{
g_iTripmine[this] = 0;
Tripmine_Kill(this);
new Array:hDmgTime = Array:entity_get_int(this, m_rgpDmgTime);
remove_entity(entity_get_int(this, m_pBeam));
ArrayDestroy(hDmgTime);
}
public zp_user_infected_post(this)
{
g_iTripmine[this] = 0;
Tripmine_Kill(this);
new Array:hDmgTime = Array:entity_get_int(this, m_rgpDmgTime);
remove_entity(entity_get_int(this, m_pBeam));
ArrayDestroy(hDmgTime);
}
public remove_preview(id)
{
g_iTripmine[id] = 0;
Tripmine_Kill(id);
new Array:hDmgTime = Array:entity_get_int(id, m_rgpDmgTime);
remove_entity(entity_get_int(id, m_pBeam));
ArrayDestroy(hDmgTime);
}
public zp_extra_item_selected(pPlayer, iItemId)
{
if (iItemId != g_iTripmineId)
return;
new iHealth = get_pcvar_num(cvar_tripmine_health);
g_iTripmineHealth[pPlayer][g_iTripmine[pPlayer]] = iHealth;
g_iTripmine[pPlayer] += 1;
limit[pPlayer]++
client_printcolor(pPlayer, "!y[!gZP!y] You Bought !g%d !yLasermine!y!", g_iTripmine[pPlayer]);
client_printcolor(pPlayer, "!y[!gZP!y] To Plant !yLasermine type on console !g'bind key +setlaser'!y!");
client_printcolor(pPlayer, "!y[!gZP!y] To Remove !yLasermine type on console !g'bind key +dellaser'!y!");
}
public CBasePlayer_Killed_Post(this)
{
g_iTripmine[this] = 0;
Tripmine_Kill(this);
}
public CBasePlayer_TakeDamage_Pre(this, pInflictor, pAttacker, Float:flDamage)
{
if (!FClassnameIs(pInflictor, "zp_tripmine_exp"))
return HAM_IGNORED;
if (!zp_get_user_zombie(this))
return HAM_SUPERCEDE;
SetHamParamInteger(5, DMG_GENERIC);
SetHamParamEntity(3, entity_get_int(pInflictor, EV_INT_iuser1));
SetHamParamFloat(4, floatmax(flDamage * 6.0, 600.0));
return HAM_HANDLED;
}
public OnFreeEntPrivateData(this)
{
new szClassName[32];
entity_get_string(this, EV_SZ_classname, szClassName, charsmax(szClassName));
if (!equal(szClassName, "zp_tripmine"))
return FMRES_IGNORED;
new Array:hDmgTime = Array:entity_get_int(this, m_rgpDmgTime);
remove_entity(entity_get_int(this, m_pBeam));
ArrayDestroy(hDmgTime);
return FMRES_IGNORED;
}
Tripmine_Spawn(pOwner)
{
new pTripmine = create_entity("info_target");
new Array:hDmgTime = ArrayCreate(1, 1);
for (new i = 0; i < MAXPLAYERS+1; i++)
ArrayPushCell(hDmgTime, 0.0);
entity_set_int(pTripmine, EV_INT_movetype, MOVETYPE_FLY);
entity_set_int(pTripmine, EV_INT_solid, SOLID_NOT);
entity_set_model(pTripmine, "models/TM_Server/Lasermine/lasermine.mdl");
entity_set_int(pTripmine, EV_INT_body, 11);
entity_set_int(pTripmine, EV_INT_sequence, TRIPMINE_WORLD);
entity_set_string(pTripmine, EV_SZ_classname, "zp_tripmine");
entity_set_size(pTripmine, Float:{-8.0, -8.0, -8.0}, Float:{8.0, 8.0, 8.0});
entity_set_int(pTripmine, EV_INT_rendermode, kRenderTransAdd);
entity_set_float(pTripmine, EV_FL_renderamt, 200.0);
entity_set_int(pTripmine, m_pOwner, pOwner);
entity_set_int(pTripmine, m_rgpDmgTime, _:hDmgTime);
entity_set_float(pTripmine, EV_FL_health, float(g_iTripmineHealth[pOwner][g_iTripmine[pOwner] - 1]));
entity_set_float(pTripmine, EV_FL_max_health, 455.0);
entity_set_float(pTripmine, EV_FL_nextthink, get_gametime() + 0.02);
new pBeam = Beam_BeamCreate("sprites/laserbeam.spr", 6.0);
Beam_EntsInit(pBeam, pTripmine, pOwner);
entity_set_vector(pBeam, EV_VEC_rendercolor, Float:{150.0, 0.0, 0.0});
entity_set_float(pBeam, EV_FL_frame, 10.0);
entity_set_float(pBeam, EV_FL_animtime, 255.0);
entity_set_float(pBeam, EV_FL_renderamt, 200.0);
entity_set_int(pTripmine, m_pBeam, pBeam);
entity_set_int(pBeam, EV_INT_effects, entity_get_int(pBeam, EV_INT_effects));
return pTripmine;
}
public Tripmine_TakeDamage_Pre(this, pInflictor, pAttacker)
{
if (!FClassnameIs(this, "zp_tripmine"))
return HAM_IGNORED;
if (!is_user_alive(pAttacker))
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
public Tripmine_TakeDamage_Post(this, pInflictor, pAttacker)
{
if (!FClassnameIs(this, "zp_tripmine"))
return;
if (GetHamReturnStatus() == HAM_SUPERCEDE)
return;
Tripmine_Render(this);
}
public Tripmine_Killed_Post(this, pAttacker)
{
if (!FClassnameIs(this, "zp_tripmine"))
return;
if (!is_user_alive(pAttacker))
return;
new szName[32];
get_user_name(pAttacker, szName, charsmax(szName));
new iBonus = get_pcvar_num(cvar_tripmine_bonus);
zp_set_user_ammo_packs(pAttacker, zp_get_user_ammo_packs(pAttacker) + iBonus);
client_printcolor(0, "!y[!gLgK!y] !g%s !yhas won !g3 !yAmmoPacks for destroying a !gLasermine!y!", szName, iBonus);
Lasermine_Explosion(this);
Lasermine_Radius_Damage(this);
}
/*------------------------------------------------------------------------------------
[Set Damage Effects]
-------------------------------------------------------------------------------------*/
// Radius Damage
Lasermine_Radius_Damage(i_Ent) {
if(!is_entity_pdata_valid(i_Ent)) return PLUGIN_HANDLED;
static Float:originF[3], Float:g_radius, g_damage, victim, attacker;
pev(i_Ent, pev_origin, originF)
g_radius = get_pcvar_float(CvarRadius)
g_damage = get_pcvar_num(CvarDamage)
victim = -1
attacker = pev(i_Ent, m_pBeam)
while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, g_radius)) != 0) {
Lasermine_Knockback(i_Ent, get_pcvar_float(CvarDamage), get_pcvar_float(CvarRadius))
}
return PLUGIN_CONTINUE
}
// Knockback
Lasermine_Knockback(iCurrent, Float:Amount, Float:Radius) {
if (!is_entity_pdata_valid(iCurrent))
return;
// Get given parameters
static Float:vecSrc[3];
entity_get_vector(iCurrent, EV_VEC_origin, vecSrc);
new ent = -1, Float:tmpdmg = Amount, Float:kickback = 0.0;
// Debug: Print the source vector
server_print("vecSrc: %f %f %f", vecSrc[0], vecSrc[1], vecSrc[2]);
// Needed for doing some nice calculations :P
static Float:Tabsmin[3], Float:Tabsmax[3], Float:vecSpot[3], Float:Aabsmin[3], Float:Aabsmax[3], Float:vecSee[3], trRes;
static Float:flFraction, Float:vecEndPos[3], Float:distance, Float:origin[3], Float:vecPush[3], Float:invlen, Float:velocity[3];
// Calculate falloff
static Float:falloff;
if (Radius > 0.0)
falloff = Amount / Radius;
else
falloff = 1.0;
// Debug: Print falloff value
server_print("Falloff: %f", falloff);
// Find monsters and players inside a specific radius
while ((ent = engfunc(EngFunc_FindEntityInSphere, ent, vecSrc, Radius)) != 0) {
if (!is_user_alive(ent))
continue;
/*if (pev(iCurrent, m_pOwner) != ent)
continue;*/
kickback = 1.0;
tmpdmg = Amount;
// The following calculations are provided by Orangutanz, THANKS!
// We use absmin and absmax for the most accurate information
pev(ent, pev_absmin, Tabsmin);
pev(ent, pev_absmax, Tabsmax);
xs_vec_add(Tabsmin, Tabsmax, Tabsmin);
xs_vec_mul_scalar(Tabsmin, 0.5, vecSpot);
pev(iCurrent, pev_absmin, Aabsmin);
pev(iCurrent, pev_absmax, Aabsmax);
xs_vec_add(Aabsmin, Aabsmax, Aabsmin);
xs_vec_mul_scalar(Aabsmin, 0.5, vecSee);
engfunc(EngFunc_TraceLine, vecSee, vecSpot, 0, iCurrent, trRes);
get_tr2(trRes, TR_flFraction, flFraction);
// Debug: Print flFraction value
server_print("flFraction: %f", flFraction);
// Explosion can 'see' this entity, so hurt them! (or impact through objects has been enabled xD)
if (flFraction >= 0.9 || get_tr2(trRes, TR_pHit) == ent) {
// Work out the distance between impact and entity
get_tr2(trRes, TR_vecEndPos, vecEndPos);
distance = get_distance_f(vecSrc, vecEndPos) * falloff;
tmpdmg -= distance;
if (tmpdmg < 0.0)
tmpdmg = 0.0;
// Kickback Effect
if (kickback != 0.0) {
xs_vec_sub(vecSpot, vecSee, origin);
invlen = 1.0 / get_distance_f(vecSpot, vecSee);
xs_vec_mul_scalar(origin, invlen, vecPush);
pev(ent, pev_velocity, velocity);
xs_vec_mul_scalar(vecPush, tmpdmg, vecPush);
xs_vec_mul_scalar(vecPush, kickback, vecPush);
xs_vec_add(velocity, vecPush, velocity);
if (tmpdmg < 60.0)
xs_vec_mul_scalar(velocity, 12.0, velocity);
else
xs_vec_mul_scalar(velocity, 4.0, velocity);
if (velocity[0] != 0.0 || velocity[1] != 0.0 || velocity[2] != 0.0)
set_pev(ent, pev_velocity, velocity);
// Debug: Print velocity
server_print("Velocity: %f %f %f", velocity[0], velocity[1], velocity[2]);
}
}
}
return;
}
// Knockback
/*Lasermine_Knockback(iCurrent,Float:Amount,Float:Radius) {
if(!is_entity_pdata_valid(iCurrent))
return;
// Get given parameters
static Float:vecSrc[3]; entity_get_vector(iCurrent, EV_VEC_origin, vecSrc);
new ent = -1, Float: tmpdmg = Amount, Float:kickback = 0.0;
// Needed for doing some nice calculations :P
static Float:Tabsmin[3], Float:Tabsmax[3], Float:vecSpot[3], Float:Aabsmin[3], Float:Aabsmax[3], Float:vecSee[3], trRes;
static Float:flFraction, Float:vecEndPos[3], Float:distance, Float:origin[3], Float:vecPush[3], Float:invlen, Float:velocity[3];
// Calculate falloff
static Float:falloff;
if (Radius > 0.0) falloff = Amount / Radius;
else falloff = 1.0;
// Find monsters and players inside a specifiec radius
while((ent = engfunc(EngFunc_FindEntityInSphere, ent, vecSrc, Radius)) != 0) {
if(!is_user_alive(ent))
continue;
kickback = 1.0; tmpdmg = Amount;
// The following calculations are provided by Orangutanz, THANKS!
// We use absmin and absmax for the most accurate information
pev(ent, pev_absmin, Tabsmin); pev(ent, pev_absmax, Tabsmax);
xs_vec_add(Tabsmin,Tabsmax,Tabsmin); xs_vec_mul_scalar(Tabsmin,0.5,vecSpot);
pev(iCurrent, pev_absmin, Aabsmin); pev(iCurrent, pev_absmax, Aabsmax);
xs_vec_add(Aabsmin,Aabsmax,Aabsmin); xs_vec_mul_scalar(Aabsmin,0.5,vecSee);
engfunc(EngFunc_TraceLine, vecSee, vecSpot, 0, iCurrent, trRes);
get_tr2(trRes, TR_flFraction, flFraction);
// Explosion can 'see' this entity, so hurt them! (or impact through objects has been enabled xD)
if (flFraction >= 0.9 || get_tr2(trRes, TR_pHit) == ent) {
// Work out the distance between impact and entity
get_tr2(trRes, TR_vecEndPos, vecEndPos);
distance = get_distance_f(vecSrc, vecEndPos) * falloff;
tmpdmg -= distance;
if(tmpdmg < 0.0) tmpdmg = 0.0;
// Kickback Effect
if(kickback != 0.0) {
xs_vec_sub(vecSpot,vecSee,origin);
invlen = 1.0/get_distance_f(vecSpot, vecSee);
xs_vec_mul_scalar(origin,invlen,vecPush);
pev(ent, pev_velocity, velocity)
xs_vec_mul_scalar(vecPush,tmpdmg,vecPush);
xs_vec_mul_scalar(vecPush,kickback,vecPush);
xs_vec_add(velocity,vecPush,velocity);
if(tmpdmg < 60.0) xs_vec_mul_scalar(velocity,12.0,velocity);
else xs_vec_mul_scalar(velocity,4.0,velocity);
if(velocity[0] != 0.0 || velocity[1] != 0.0 || velocity[2] != 0.0) set_pev(ent, pev_velocity, velocity);
}
}
}
return
}*/
// Explosion
Lasermine_Explosion(iCurrent) {
if(!is_entity_pdata_valid(iCurrent)) return;
static Float:vOrigin[3]; pev(iCurrent,pev_origin,vOrigin);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(99); //99 = KillBeam
write_short(iCurrent);
message_end();
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vOrigin, 0);
write_byte(TE_EXPLOSION);
engfunc(EngFunc_WriteCoord,vOrigin[0]);
engfunc(EngFunc_WriteCoord,vOrigin[1]);
engfunc(EngFunc_WriteCoord,vOrigin[2]);
write_short(boom);
write_byte(30);
write_byte(15);
write_byte(0);
message_end();
}
stock is_entity_pdata_valid(ent)
{
if(pev_valid(ent) == 2)
return 1
return 0
}
/*ExplosionCreate(const Float:vecOrigin[3], iMagnitude, pAttacker = 0, id1)
{
new szMagnitude[11];
new pExplosion = create_entity("env_explosion");
formatex(szMagnitude, charsmax(szMagnitude), "%3d", iMagnitude);
entity_set_origin(pExplosion, vecOrigin);
entity_set_int(pExplosion, EV_INT_iuser1, pAttacker);
entity_set_string(pExplosion, EV_SZ_classname, "zp_tripmine_exp");
DispatchKeyValue(pExplosion, "iMagnitude", szMagnitude);
DispatchSpawn(pExplosion);
force_use(pExplosion, pExplosion);
new id2 = pev(id1, m_pOwner)
if(!is_user_connected(id2)) return;
new Float:vOrigin[3]
pev(id1, pev_origin, vOrigin)
new victim = -1
while((victim = engfunc(EngFunc_FindEntityInSphere, victim, vOrigin, get_pcvar_float(CvarRadius))) != 0)
{
if(!is_user_alive(victim)) continue;
if((victim != id2) && !zp_get_user_zombie(victim)) continue;
new Float:fOrigin[3], Float:fDistance, Float:fDamage
pev(victim, pev_origin, fOrigin)
fDistance = get_distance_f(fOrigin, vOrigin)
fDamage = get_pcvar_float(CvarDamage) - floatmul(get_pcvar_float(CvarDamage), floatdiv(fDistance, get_pcvar_float(CvarRadius)))
fDamage *= EstimateTakeHurt(vOrigin, victim, 0)
if(fDamage < 0.1) continue;
ManageEffectAction(victim, fOrigin, vOrigin, fDistance, fDamage * get_pcvar_float(CvarKbForce))
if(zp_get_user_zombie(victim) && (pev(victim, pev_takedamage) == 2.0))
{
ExecuteHamB(Ham_TakeDamage, victim, id1, id2, fDamage, DMG_BULLET)
}
}
}*/
public Tripmine_Think(this)
{
static Float:flGameTime;
flGameTime = get_gametime();
if (entity_get_int(this, EV_INT_renderfx) == kRenderFxGlowShell)
{
static pBeam, Array:hDmgTime, Float:vecEnd[3], Float:vecSrc[3];
pBeam = entity_get_int(this, m_pBeam);
hDmgTime = Array:entity_get_int(this, m_rgpDmgTime);
entity_get_vector(this, EV_VEC_origin, vecSrc);
entity_get_vector(this, m_vecEnd, vecEnd);
if (entity_get_float(this, m_flPowerUp) == 1.0)
{
static Float:vecAngles[3], Float:vecDir[3];
entity_get_vector(this, EV_VEC_angles, vecAngles);
entity_get_vector(this, EV_VEC_origin, vecSrc);
MakeAimVectors(vecAngles);
global_get(glb_v_forward, vecDir);
xs_vec_mul_scalar(vecDir, 2048.0, vecDir);
xs_vec_add(vecSrc, vecDir, vecEnd);
entity_set_int(pBeam, EV_INT_effects, entity_get_int(pBeam, EV_INT_effects) & ~EF_NODRAW);
Beam_PointEntInit(pBeam, vecEnd, this);
entity_set_int(this, EV_INT_solid, SOLID_BBOX);
entity_set_float(this, EV_FL_takedamage, DAMAGE_YES);
entity_set_vector(this, m_vecEnd, vecEnd);
entity_set_float(this, m_flPowerUp, 0.0);
emit_sound(this, CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 0, 75);
}
engfunc(EngFunc_TraceLine, vecSrc, vecEnd, IGNORE_MONSTERS, this, 0);
static Float:flFraction;
get_tr2(0, TR_flFraction, flFraction);
if (flFraction < 1.0)
{
get_tr2(0, TR_vecEndPos, vecEnd);
entity_set_vector(pBeam, EV_VEC_origin, vecEnd);
Beam_RelinkBeam(pBeam);
}
static Float:vecAbsMin[3], Float:vecAbsMax[3];
vecAbsMin[0] = floatmin(vecEnd[0], vecSrc[0]);
vecAbsMin[1] = floatmin(vecEnd[1], vecSrc[1]);
vecAbsMin[2] = floatmin(vecEnd[2], vecSrc[2]);
vecAbsMax[0] = floatmax(vecEnd[0], vecSrc[0]);
vecAbsMax[1] = floatmax(vecEnd[1], vecSrc[1]);
vecAbsMax[2] = floatmax(vecEnd[2], vecSrc[2]);
static i, Float:flLastDamageTime, rgpPlayers[MAXPLAYERS], iPlayersCount, pPlayer, pOwner;
iPlayersCount = 0;
pOwner = entity_get_int(this, m_pOwner);
PlayersInBox(rgpPlayers, iPlayersCount, vecAbsMin, vecAbsMax);
for (i = 0; i < iPlayersCount; i++)
{
pPlayer = rgpPlayers[i];
if (!zp_get_user_zombie(pPlayer))
continue;
flLastDamageTime = ArrayGetCell(hDmgTime, pPlayer);
if (flGameTime - flLastDamageTime < 1.0)
continue;
ArraySetCell(hDmgTime, pPlayer, flGameTime);
entity_get_vector(pPlayer, EV_VEC_origin, vecSrc);
ExecuteHam(Ham_TakeDamage, pPlayer, this, pOwner, 70.0, DMG_GENERIC | DMG_ALWAYSGIB);
emit_sound(pPlayer, CHAN_BODY, "debris/beamstart9.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
if (flGameTime - entity_get_float(this, m_flSparks) >= 1.0)
{
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecEnd, 0);
{
write_byte(TE_SPARKS);
engfunc(EngFunc_WriteCoord, vecEnd[0]);
engfunc(EngFunc_WriteCoord, vecEnd[1]);
engfunc(EngFunc_WriteCoord, vecEnd[2]);
}
message_end();
entity_set_float(this, m_flSparks, flGameTime);
}
}
else
Tripmine_RelinkTripmine(this);
entity_set_float(this, EV_FL_nextthink, flGameTime + 0.023);
}
Tripmine_RelinkTripmine(this)
{
static hTr, pOwner, pBeam, pHit, Float:vecPlaneNormal[3], Float:vecSrc[3], Float:vecEnd[3];
pOwner = entity_get_int(this, m_pOwner);
pBeam = entity_get_int(this, m_pBeam);
GetGunPosition(pOwner, vecSrc);
GetAimPosition(pOwner, 128, vecEnd);
hTr = create_tr2();
engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, pOwner, hTr);
static iBody, Float:flVecColor[3], Float:flFraction, Float:vecAngles[3], Float:vecVelocity[3];
get_tr2(hTr, TR_flFraction, flFraction);
pHit = max(get_tr2(hTr, TR_pHit), 0);
velocity_by_aim(pOwner, 128, vecVelocity);
xs_vec_neg(vecVelocity, vecVelocity);
vector_to_angle(vecVelocity, vecAngles);
g_bCantPlant[pOwner] = true;
iBody = 11;
xs_vec_set(flVecColor, 150.0, 0.0, 0.0);
if (flFraction < 1.0)
{
get_tr2(hTr, TR_vecPlaneNormal, vecPlaneNormal);
get_tr2(hTr, TR_vecEndPos, vecEnd);
xs_vec_mul_scalar(vecPlaneNormal, 8.0, vecPlaneNormal);
xs_vec_add(vecEnd, vecPlaneNormal, vecEnd);
if (!pHit)
{
vector_to_angle(vecPlaneNormal, vecAngles);
g_bCantPlant[pOwner] = false;
iBody = 15;
xs_vec_set(flVecColor, 0.0, 150.0, 0.0);
}
}
entity_set_vector(pBeam, EV_VEC_rendercolor, flVecColor);
entity_set_vector(this, EV_VEC_angles, vecAngles);
entity_set_int(this, EV_INT_body, iBody);
entity_set_origin(this, vecEnd);
free_tr2(hTr);
}
Tripmine_Kill(pOwner)
{
new pTripmine = -1;
new bool:bIsConnected = bool:(is_user_connected(pOwner));
while ((pTripmine = find_ent_by_class(pTripmine, "zp_tripmine")))
{
if (entity_get_int(pTripmine, m_pOwner) != pOwner)
continue;
if (!bIsConnected)
entity_set_int(pTripmine, m_pOwner, pTripmine);
if (entity_get_int(pTripmine, EV_INT_rendermode) != kRenderTransAdd)
continue;
remove_entity(pTripmine);
break;
}
remove_task(pOwner+TASK_SETLASER);
remove_task(pOwner+TASK_DELLASER);
remove_task(pOwner+TASK_IDLE);
if (bIsConnected)
BarTime(pOwner, 0);
}
Tripmine_Render(this)
{
new Float:vecColor[3];
new iPercent = floatround((entity_get_float(this, EV_FL_health) / entity_get_float(this, EV_FL_max_health)) * 100.0);
vecColor[0] = float(clamp(255 - iPercent * 3, 0, 255));
vecColor[1] = float(clamp(3 * iPercent, 0, 255));
entity_set_int(this, EV_INT_body, 1);
entity_set_int(this, EV_INT_renderfx, kRenderFxGlowShell);
entity_set_vector(this, EV_VEC_rendercolor, vecColor);
entity_set_float(this, EV_FL_renderamt, 25.0);
}
PlayersInBox(rgpPlayers[MAXPLAYERS], &iPlayersCount, const Float:vecMins[3], const Float:vecMaxs[3])
{
static i, _rgpPlayers[MAXPLAYERS], Float:vecAbsMin[3], Float:vecAbsMax[3], _iPlayersCount, pPlayer;
_iPlayersCount = 0;
get_players(_rgpPlayers, _iPlayersCount, "a");
for (i = 0; i < _iPlayersCount; i++)
{
pPlayer = _rgpPlayers[i];
entity_get_vector(pPlayer, EV_VEC_absmin, vecAbsMin);
entity_get_vector(pPlayer, EV_VEC_absmax, vecAbsMax);
if (vecMins[0] > vecAbsMax[0] || vecMins[1] > vecAbsMax[1] || vecMins[2] > vecAbsMax[2] ||
vecMaxs[0] < vecAbsMin[0] || vecMaxs[1] < vecAbsMin[1] || vecMaxs[2] < vecAbsMin[2])
continue;
rgpPlayers[iPlayersCount] = pPlayer;
iPlayersCount++;
}
}
Beam_BeamCreate(const szSpriteName[], Float:flWidth)
{
new pBeam = create_entity("env_beam");
Beam_BeamInit(pBeam, szSpriteName, flWidth);
return pBeam;
}
Beam_BeamInit(this, const szSpriteName[], Float:flWidth)
{
entity_set_int(this, EV_INT_flags, entity_get_int(this, EV_INT_flags) | FL_CUSTOMENTITY);
entity_set_vector(this, EV_VEC_rendercolor, Float:{255.0, 255.0, 255.0});
entity_set_float(this, EV_FL_renderamt, 255.0);
entity_set_int(this, EV_INT_body, 0);
entity_set_float(this, EV_FL_frame, 0.0);
entity_set_float(this, EV_FL_animtime, 0.0);
entity_set_model(this, szSpriteName);
entity_set_float(this, EV_FL_scale, flWidth);
entity_set_int(this, EV_INT_skin, 0);
entity_set_int(this, EV_INT_sequence, 0);
entity_set_int(this, EV_INT_rendermode, 0);
}
Beam_EntsInit(this, pStartEnt, pEndEnt)
{
entity_set_int(this, EV_INT_rendermode, (entity_get_int(this, EV_INT_rendermode) & 0xF0) | (BEAM_ENTS & 0x0F));
entity_set_int(this, EV_INT_sequence, (pStartEnt & 0x0FFF) | ((entity_get_int(this, EV_INT_sequence) & 0xF000) << 12));
entity_set_edict(this, EV_ENT_owner, pStartEnt);
entity_set_int(this, EV_INT_skin, (pEndEnt & 0x0FFF) | ((entity_get_int(this, EV_INT_skin) & 0xF000) << 12));
entity_set_edict(this, EV_ENT_aiment, pEndEnt);
entity_set_int(this, EV_INT_sequence, (entity_get_int(this, EV_INT_sequence) & 0x0FFF) | ((0 & 0xF) << 12));
entity_set_int(this, EV_INT_skin, (entity_get_int(this, EV_INT_skin) & 0x0FFF) | ((0 & 0xF) << 12));
Beam_RelinkBeam(this);
}
Beam_PointEntInit(this, const Float:vecStart[3], pEndEnt)
{
entity_set_int(this, EV_INT_rendermode, (entity_get_int(this, EV_INT_rendermode) & 0xF0) | (BEAM_ENTPOINT & 0x0F));
entity_set_vector(this, EV_VEC_origin, vecStart);
entity_set_int(this, EV_INT_skin, (pEndEnt & 0x0FFF) | ((entity_get_int(this, EV_INT_skin) & 0xF000) << 12));
entity_set_edict(this, EV_ENT_aiment, pEndEnt);
entity_set_int(this, EV_INT_sequence, (entity_get_int(this, EV_INT_sequence) & 0x0FFF) | ((0 & 0xF) << 12));
entity_set_int(this, EV_INT_skin, (entity_get_int(this, EV_INT_skin) & 0x0FFF) | ((0 & 0xF) << 12));
Beam_RelinkBeam(this);
}
Beam_RelinkBeam(this)
{
new Float:vecStartPos[3], Float:vecOrigin[3], Float:vecEndPos[3], Float:vecMins[3], Float:vecMaxs[3];
Beam_GetStartPos(this, vecStartPos);
Beam_GetEndPos(this, vecEndPos);
vecMins[0] = floatmin(vecStartPos[0], vecEndPos[0]);
vecMins[1] = floatmin(vecStartPos[1], vecEndPos[1]);
vecMins[2] = floatmin(vecStartPos[2], vecEndPos[2]);
vecMaxs[0] = floatmax(vecStartPos[0], vecEndPos[0]);
vecMaxs[1] = floatmax(vecStartPos[1], vecEndPos[1]);
vecMaxs[2] = floatmax(vecStartPos[2], vecEndPos[2]);
entity_get_vector(this, EV_VEC_origin, vecOrigin);
xs_vec_sub(vecMins, vecOrigin, vecMins);
xs_vec_sub(vecMaxs, vecOrigin, vecMaxs);
entity_set_vector(this, EV_VEC_mins, vecMins);
entity_set_vector(this, EV_VEC_maxs, vecMaxs);
entity_set_size(this, vecMins, vecMaxs);
entity_set_origin(this, vecOrigin);
}
Beam_GetStartPos(this, Float:vecDest[3])
{
if ((entity_get_int(this, EV_INT_rendermode) & 0x0F) == BEAM_ENTS)
{
new pEnt = (entity_get_int(this, EV_INT_sequence) & 0xFFF);
entity_get_vector(pEnt, EV_VEC_origin, vecDest);
return;
}
entity_get_vector(this, EV_VEC_origin, vecDest);
}
Beam_GetEndPos(this, Float:vecDest[3])
{
new iBeamType = (entity_get_int(this, EV_INT_rendermode) & 0x0F);
if (iBeamType == BEAM_HOSE || iBeamType == BEAM_POINTS)
{
entity_get_vector(this, EV_VEC_angles, vecDest);
return;
}
new pEnt = max((entity_get_int(this, EV_INT_skin) & 0xFFF), 0);
if (pEnt)
{
entity_get_vector(pEnt, EV_VEC_origin, vecDest);
return;
}
entity_get_vector(this, EV_VEC_angles, vecDest);
}
GetAimPosition(this, iDistance, Float:vecDest[3])
{
static Float:vecVelocity[3], Float:vecSrc[3];
GetGunPosition(this, vecSrc);
velocity_by_aim(this, iDistance, vecVelocity);
xs_vec_add(vecSrc, vecVelocity, vecDest);
}
GetGunPosition(this, Float:vecDest[3])
{
static Float:vecViewOfs[3], Float:vecSrc[3];
entity_get_vector(this, EV_VEC_view_ofs, vecViewOfs);
entity_get_vector(this, EV_VEC_origin, vecSrc);
xs_vec_add(vecSrc, vecViewOfs, vecDest);
}
BarTime(this, iTime)
{
message_begin(MSG_ONE, g_iMsgBarTime, .player = this)
{
write_short(iTime);
}
message_end();
}
MakeAimVectors(const Float:vecAngles[3])
{
new Float:vecTmpAngles[3];
xs_vec_set(vecTmpAngles, vecAngles[0], vecAngles[1], vecAngles[2]);
vecTmpAngles[0] = -vecTmpAngles[0];
engfunc(EngFunc_MakeVectors, vecTmpAngles);
}
Float:EstimateTakeHurt(Float:fPoint[3], ent, ignored)
{
new Float:fOrigin[3], Float:fFraction, tr
pev(ent, pev_origin, fOrigin)
engfunc(EngFunc_TraceLine, fPoint, fOrigin, DONT_IGNORE_MONSTERS, ignored, tr)
get_tr2(tr, TR_flFraction, fFraction)
if(fFraction == 1.0 || get_tr2(tr, TR_pHit) == ent) return 1.0;
return 0.6;
}
ManageEffectAction(iEnt, Float:fEntOrigin[3], Float:fPoint[3], Float:fDistance, Float:fDamage)
{
new Float:Velocity[3]
pev(iEnt, pev_velocity, Velocity)
new Float:fTime = floatdiv(fDistance, fDamage)
new Float:fVelocity[3]
fVelocity[0] = floatdiv((fEntOrigin[0] - fPoint[0]), fTime) + Velocity[0]*0.5
fVelocity[1] = floatdiv((fEntOrigin[1] - fPoint[1]), fTime) + Velocity[1]*0.5
fVelocity[2] = floatdiv((fEntOrigin[2] - fPoint[2]), fTime) + Velocity[2]*0.5
set_pev(iEnt, pev_velocity, fVelocity)
return 1;
}
RemoveEntitySafe(ent)
{
set_pev(ent, pev_flags, FL_KILLME)
dllfunc(DLLFunc_Think, ent)
}
FClassnameIs(this, szClassName[])
{
new _szClassName[32];
if (!is_valid_ent(this))
return 0;
entity_get_string(this, EV_SZ_classname, _szClassName, charsmax(_szClassName));
if (equali(szClassName, _szClassName))
return 1;
return 0;
}
public showMenuLasermine(id)
{
new menuid = menu_create("\yLasermine Menu", "menuLasermine");
menu_additem(menuid, "Buy/place from Extra Items.");
menu_additem(menuid, "Remove a Lasermine");
menu_display(id, menuid, 0);
}
public menuLasermine(id, menuid, item)
{
if (!is_user_alive(id))
return PLUGIN_HANDLED;
if (zp_get_user_zombie(id))
return PLUGIN_HANDLED;
switch(item)
{
case MENU_EXIT:
{
menu_destroy(menuid);
return PLUGIN_HANDLED;
}
case 0:
{
if (!g_iTripmine[id])
{
client_printcolor(id, "!y[!gLgK!y] Couldn't buy a !gLasermine!y!");
showMenuLasermine(id);
return PLUGIN_HANDLED;
}
if (g_iTripmine[id])
{
CmdSetLaser(id);
}
showMenuLasermine(id);
}
case 1:
{
CmdDelLaser(id);
showMenuLasermine(id);
}
}
return PLUGIN_HANDLED;
}
stock print_colored(const index, const input [ ], const any:...)
{
new message[191]
vformat(message, 190, input, 3)
replace_all(message, 190, "!y", "^1")
replace_all(message, 190, "!t", "^3")
replace_all(message, 190, "!g", "^4")
if(index)
{
//print to single person
message_begin(MSG_ONE, g_iMsgSayTxt, _, index)
write_byte(index)
write_string(message)
message_end()
}
else
{
//print to all players
new players[32], count, i, id
get_players(players, count, "ch")
for( i = 0; i < count; i ++ )
{
id = players[i]
if(!is_user_connected(id)) continue;
message_begin(MSG_ONE_UNRELIABLE, g_iMsgSayTxt, _, id)
write_byte(id)
write_string(message)
message_end()
}
}
}
public Tripmine_ShowInfo_Post(Float:flVecStart[3], Float:flVecEnd[3], Conditions, this, Trace)
{
if (!is_user_connected(this) || !is_user_alive(this))
return FMRES_IGNORED;
static iHit;
iHit = get_tr2(Trace, TR_pHit);
if (pev_valid(iHit))
{
if (pev(iHit, pev_deadflag) == DEAD_NO)
{
new szClassName[32], szName[32];
pev(iHit, pev_classname, szClassName, charsmax(szClassName))
if (equali(szClassName, "zp_tripmine"))
{
static iOwner, iHealth;
iOwner = pev(iHit, pev_iuser1);
iHealth = pev(iHit, pev_health);
get_user_name(iOwner, szName, charsmax(szName));
set_hudmessage(0, 0, 255, -1.0, 0.60, 0, 6.0, 0.4, 0.0, 0.0, -1);
show_hudmessage(this, "", szName, iHealth);
}
}
}
return FMRES_IGNORED;
}
stock client_printcolor(const id,const input[], any:...)
{
new msg[191], players[32], count = 1; vformat(msg,190,input,3);
replace_all(msg,190,"!g","^4"); // green
replace_all(msg,190,"!y","^1"); // normal
replace_all(msg,190,"!t","^3"); // team
if (id) players[0] = id; else get_players(players,count,"ch");
for (new i=0;i<count;i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
|
|