3DTryg.inc 260 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889
  1. /*************************************************************************************************************************************
  2. * *
  3. * )( 3DTryg Functions )( *
  4. * *
  5. * Copyright © 2017 Abyss Morgan. All rights reserved. *
  6. * Contributors: Crayder, IllidanS4, Nero_3D, RyDeR, Zoutdaxv, hesambia, Neil Lamoureux, Ivan_Ino, Ralfie, Unrea1 *
  7. * *
  8. * Download: https://github.com/AbyssMorgan/SA-MP/tree/master/include/SAM *
  9. * Publication: http://forum.sa-mp.com/showthread.php?t=591010 *
  10. * Website: http://8.ct8.pl *
  11. * *
  12. * Plugins: MapAndreas, ColAndreas, YSF, Streamer, FCNPC, VehicleStreamer *
  13. * Modules: FoxForeach, Foreach *
  14. * Internal Modules: Stream3D, Actor, ATM, Anims, VehicleCollision *
  15. * *
  16. * File Version: 4.5.2 *
  17. * SA:MP Version: 0.3.7 (REQUIRE) *
  18. * MapAndreas Version: 1.2.1 *
  19. * ColAndreas Version: 1.4.0 *
  20. * YSF Version: R19 (kurta999) *
  21. * Streamer Version: 2.9.1 *
  22. * VehicleStreamer Version: 2.9.1 *
  23. * FCNPC Version: 1.7.4 *
  24. * *
  25. * //3DTryg Collision Precision: *
  26. * 1. ColAndreas - The most accurate precision with ColAndreas plugin. *
  27. * 2. MapAndreas - Average precision with MapAndreas plugin. *
  28. * *
  29. * //Foreach Types: *
  30. * 1. FoxForeach *
  31. * 2. YSIForeach *
  32. * 3. GetPlayerPoolSize *
  33. * *
  34. * //Compiler Options: *
  35. * DISABLE_3D_TRYG_INIT //Use before 3DTryg.inc for disable MapAndreas/ColAndreas Auto Init *
  36. * DISABLE_3D_TRYG_ATM //Use before 3DTryg.inc for disable ATM Module *
  37. * DISABLE_3D_TRYG_ACTOR //Use before 3DTryg.inc for disable Actors Module *
  38. * DISABLE_3D_TRYG_FOXFOREACH //Use before 3DTryg.inc for disable FoxForeach Module *
  39. * DISABLE_3D_TRYG_YSIFOREACH //Use before 3DTryg.inc for disable Foreach Module *
  40. * DISABLE_3D_TRYG_VEHICLECOL //Use before 3DTryg.inc for disable VehicleCollision Module *
  41. * DISABLE_3D_TRYG_MAPANDREAS //Use before 3DTryg.inc for disable MapAndreas Module *
  42. * DISABLE_3D_TRYG_COLANDREAS //Use before 3DTryg.inc for disable ColAndreas Module *
  43. * DISABLE_3D_TRYG_YSF //Use before 3DTryg.inc for disable YSF Module *
  44. * DISABLE_3D_TRYG_STREAMER //Use before 3DTryg.inc for disable Streamer Module *
  45. * DISABLE_3D_TRYG_FCNPC //Use before 3DTryg.inc for disable FCNPC Module *
  46. * DISABLE_3D_TRYG_VEHSTREAMER //Use before 3DTryg.inc for disable VehicleStreamer Module *
  47. * ENABLE_3D_TRYG_YSI_SUPPORT //Use before 3DTryg.inc for enable YSI Support (use only when 3DTryg say error for this) *
  48. * ENABLE_3D_TRYG_STREAM3D //Use before 3DTryg.inc for enable Stream3D Module *
  49. * ENABLE_3D_TRYG_ANIMS //Use before 3DTryg.inc for enable Anims Module *
  50. * *
  51. * //Complementary Functions:
  52. * Float:sqrtN(Float:value,Float:exponent);
  53. * abs(value);
  54. * Float:fabs(Float:value);
  55. * power(value,Float:exponent);
  56. * IsEven(value);
  57. * Float:Tryg3D::RandomFloat(Float:min,Float:max,accuracy=4);
  58. *
  59. * //Internal Functions:
  60. * single_clock(max,id); //For GetRandomPointOnClock parameter rz
  61. * even_clock(max,id); //For GetRandomPointOnClock parameter rz
  62. * uneven_clock(max,id); //For GetRandomPointOnClock parameter rz
  63. * NLTZ(value); //NotLessThanZero
  64. * NMTZ(value); //NotMoreThanZero
  65. * Float:NLTZF(Float:value); //NotLessThanZeroFloat
  66. * Float:NMTZF(Float:value); //NotMoreThanZeroFloat
  67. * NLTV(value,min); //NotLessThanValue
  68. * NMTV(value,max); //NotMoreThanValue
  69. * Float:NLTVF(Float:value,Float:min); //NotLessThanValueFloat
  70. * Float:NMTVF(Float:value,Float:max); //NotMoreThanValueFloat
  71. * CompRotation(rotation,&crotation=0);
  72. * DeCompRotation(rotation,&crotation=0);
  73. * Float:CompRotationFloat(Float:rotation,&Float:crotation=0.0);
  74. * Float:DeCompRotationFloat(Float:rotation,&Float:crotation=0.0);
  75. * IsRotationTest(Float:rotation,Float:r_min,Float:r_max);
  76. * Tryg3D::GivePlayerDamage(targetid,Float:amount,playerid,weaponid,bodypart);
  77. * Tryg3D::GetWeaponDamage(weaponid);
  78. * Tryg3D::SwapInt(variable1,variable2);
  79. * Tryg3D::IsPlayerSpawned(playerid);
  80. * Tryg3D::GetActiveTime();
  81. *
  82. * //General Functions:
  83. * CountPlayers(bool:isplayer=true,bool:isnpc=true);
  84. * CountActors();
  85. * CountVisibleActors(playerid);
  86. * CountVisibleVehicles(playerid);
  87. * CountVisiblePlayers(playerid,bool:isplayer=true,bool:isnpc=true);
  88. * RecoilFloat(Float:value,Float:recoil);
  89. * RecoilVector(&Float:vx,&Float:vy,&Float:vz,Float:sx,Float:sy,Float:sz);
  90. * Float:ShiftDegreeToRadian(Float:deg);
  91. * Float:ShiftDegreeToRadianEx(Float:deg);
  92. * Float:ShiftDegreeToGrades(Float:deg);
  93. * Float:ShiftRadianToDegree(Float:rad);
  94. * Float:ShiftRadianToDegreeEx(Float:rad);
  95. * Float:ShiftRadianToGrades(Float:rad);
  96. * Float:ShiftGradesToDegree(Float:grad);
  97. * Float:ShiftGradesToRadian(Float:grad);
  98. * GetRandomHit(Float:x,Float:y,Float:z,range,&Float:tx,&Float:ty,&Float:tz);
  99. * Float:GetDistanceBetweenPoints1D(Float:x1,Float:x2);
  100. * Float:GetDistanceBetweenPoints2D(Float:x1,Float:y1,Float:x2,Float:y2);
  101. * Float:GetDistanceBetweenPoints3D(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2);
  102. * GetPointInFront2D(Float:x,Float:y,Float:rz,Float:radius,&Float:tx,&Float:ty);
  103. * GetPointInFront3D(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  104. * GetPointInFront3DEx(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  105. * Float:GetPointInFrontOfPlayer(playerid,&Float:tx,&Float:ty,Float:radius);
  106. * Float:GetPointInFrontOfCamera2D(playerid,&Float:tx,&Float:ty,Float:radius);
  107. * GetPointInFrontOfCamera3D(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
  108. * GetRotationFor2Point2D(Float:x,Float:y,Float:tx,Float:ty,&Float:rz);
  109. * GetRotationFor2Point3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:rx,&Float:rz);
  110. * GetMoveTime(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:speed,&rtime=0);
  111. * GetSpeedForMoveTime(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:speed,rtime);
  112. * GetVehicleRotation(vehicleid,&Float:rx,&Float:ry,&Float:rz);
  113. * Float:GetPointInFrontOfVehicle2D(vehicleid,&Float:tx,&Float:ty,Float:radius);
  114. * GetPointInFrontOfVehicle3D(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
  115. * GetPlayerCameraRotation(playerid,&Float:rx,&Float:rz);
  116. * SetPlayerCameraRotation(playerid,Float:rx,Float:rz);
  117. * Float:GetPlayerCameraZAngle(playerid,&Float:rz=0.0);
  118. * SetPlayerCameraZAngle(playerid,Float:rz);
  119. * GetPointFor2Point2D(Float:x1,Float:y1,Float:x2,Float:y2,Float:percent_size,&Float:tx,&Float:ty);
  120. * GetPointFor2Point3D(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2,Float:percent_size,&Float:tx,&Float:ty,&Float:tz);
  121. * GetPointFor2Point2DEx(Float:x1,Float:y1,Float:x2,Float:y2,Float:distance,&Float:tx,&Float:ty);
  122. * GetPointFor2Point3DEx(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2,Float:distance,&Float:tx,&Float:ty,&Float:tz);
  123. * ShiftVectorToRotation(Float:vx,Float:vy,Float:vz,&Float:rx,&Float:rz);
  124. * ShiftRotationToVector(Float:rx,Float:rz,&Float:vx,&Float:vy,&Float:vz);
  125. * GetPointToPointVector(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:vx,&Float:vy,&Float:vz);
  126. * Float:GetRandomPointOnClock(Float:x,Float:y,Float:radius,&Float:tx,&Float:ty,&Float:trz,Float:rz=INVALID_ROTATION);
  127. * GetRandomPointInCircle(Float:x,Float:y,Float:radius,&Float:tx,&Float:ty);
  128. * GetRandomPointInCylinder2D(Float:x,Float:y,Float:minz,Float:maxz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  129. * GetRandomPointInCylinder3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  130. * GetRandomPointInSphere(Float:x,Float:y,Float:z,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  131. * GetRandomPointInRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy,&Float:tx,&Float:ty);
  132. * GetRandomPointInCube(Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz,&Float:tx,&Float:ty,&Float:tz);
  133. * GetRandomPointInPolygon(Float:points[],&Float:tx,&Float:ty,maxpoints=sizeof(points));
  134. * GetRandomPointInCircularSector(Float:x,Float:y,Float:rz,Float:radius,Float:view_angle,&Float:tx,&Float:ty);
  135. * GetRandomPointInSphericalSector(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz,&Float:tx,&Float:ty,&Float:tz);
  136. * GetRandomPointInCone3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius,&Float:tx,&Float:ty,&Float:tz);
  137. * GetRandomPointInCube3D(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z,&Float:tx,&Float:ty,&Float:tz);
  138. * GetRandomPointInEllipse(Float:cx,Float:cy,Float:size_x,Float:size_y,&Float:tx,&Float:ty);
  139. * GetRandomPointInEllipticalCyl2D(Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y,&Float:tx,&Float:ty,&Float:tz);
  140. * GetRandomPointOnCircle(Float:x,Float:y,Float:radius,&Float:tx,&Float:ty);
  141. * GetRandomPointOnCylinder2D(Float:x,Float:y,Float:minz,Float:maxz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  142. * GetRandomPointOnCylinder3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  143. * GetRandomPointOnSphere(Float:x,Float:y,Float:z,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  144. * GetRandomPointOnRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy,&Float:tx,&Float:ty);
  145. * GetRandomPointOnCube(Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz,&Float:tx,&Float:ty,&Float:tz);
  146. * GetRandomPointOnCircularSector(Float:x,Float:y,Float:rz,Float:radius,Float:view_angle,&Float:tx,&Float:ty);
  147. * GetRandomPointOnSphericalSector(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz,&Float:tx,&Float:ty,&Float:tz);
  148. * GetRandomPointOnCone3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius,&Float:tx,&Float:ty,&Float:tz);
  149. * GetRandomPointOnCube3D(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z,&Float:tx,&Float:ty,&Float:tz);
  150. * GetRandomPointOnEllipse(Float:cx,Float:cy,Float:size_x,Float:size_y,&Float:tx,&Float:ty);
  151. * GetRandomPointOnEllipticalCyl2D(Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y,&Float:tx,&Float:ty,&Float:tz);
  152. * IsPointBetween2Points2D(Float:px,Float:py,Float:xA,Float:yA,Float:xB,Float:yB);
  153. * IsPointBetween2Points3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB);
  154. * IsPointNearly2Points2D(Float:px,Float:py,Float:xA,Float:yA,Float:xB,Float:yB,Float:maxdist);
  155. * IsPointNearly2Points3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:maxdist);
  156. * IsPointInCircle(Float:px,Float:py,Float:x,Float:y,Float:radius);
  157. * IsPointInCylinder3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius);
  158. * IsPointInCylinder2D(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:minz,Float:maxz,Float:radius);
  159. * IsPointInSphere(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:radius);
  160. * IsPointInRectangle(Float:x,Float:y,Float:minx,Float:miny,Float:maxx,Float:maxy);
  161. * IsPointInCube(Float:x,Float:y,Float:z,Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz);
  162. * IsPointInPolygon(Float:x,Float:y,Float:points[],maxpoints=sizeof(points));
  163. * IsPointInCircularSector(Float:px,Float:py,Float:x,Float:y,Float:rz,Float:radius,Float:view_angle);
  164. * IsPointInSphericalSector(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz);
  165. * IsPointInCone3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius);
  166. * IsPointInCube3D(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z);
  167. * IsPointInEllipse(Float:px,Float:py,Float:cx,Float:cy,Float:size_x,Float:size_y);
  168. * IsPointInEllipticalCylinder2D(Float:px,Float:py,Float:pz,Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y);
  169. * IsPointInSphericalSectorEx(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz,bool:testLOS=true,bool:veh_col=false);
  170. * IsProbable(chance);
  171. * Float:CalculatePercent(Float:value,Float:maxvalue);
  172. * Float:GetPlayerTargetAngle(playerid,Float:x,Float:y,&Float:rz=0.0);
  173. * Float:SetPlayerTargetAngle(playerid,Float:x,Float:y,&Float:rz=0.0);
  174. * Float:GetPlayerTargetPlayerAngle(playerid,targetid,&Float:rz=0.0);
  175. * Float:SetPlayerTargetPlayerAngle(playerid,targetid,&Float:rz=0.0);
  176. * Float:GetVehicleSpeed(vehicleid);
  177. * SetVehicleSpeed(vehicleid,Float:speed);
  178. * Float:GetPlayerSpeed(playerid);
  179. * CreateDynamicExplosion(Float:x,Float:y,Float:z,type,Float:radius,worldid=-1,interiorid=-1,playerid=-1,Float:distance=200.0);
  180. * CreateDynamicExplosionDMG(Float:x,Float:y,Float:z,type,Float:radius,worldid = -1,interiorid = -1,playerid = -1,Float:distance = 200.0,Float:damage=82.5,Float:vehicle_damage=82.5,byplayerid=INVALID_PLAYER_ID);
  181. * SendFakeDamageInRadius(weaponid,bodypart,Float:damage,Float:vehicle_damage,Float:x,Float:y,Float:z,Float:radius,worldid = -1,interiorid = -1,playerid = -1,byplayerid=INVALID_PLAYER_ID);
  182. * GetVehicleFlags(vehicleid);
  183. * GetVehicleDefaultFlagsByModel(modelid);
  184. * GetVehicleFlagsByModel(modelid);
  185. * SetVehicleFlagsByModel(modelid,value);
  186. * ToggleVehicleModelFlag(modelid,flag,bool:toggle);
  187. * IsVehicleFlag(value,flag);
  188. * GetWeaponShotPos(playerid,hittype,&Float:fx,&Float:fy,&Float:fz);
  189. * SetPlayerLookAtPlayer(playerid,targetid,cut=CAMERA_CUT);
  190. * GetPlayerCameraLookAt(playerid,&Float:x,&Float:y,&Float:z);
  191. * IsPlayerLookAtSky(playerid);
  192. * GetQuatUpVector(Float:qw,Float:qx,Float:qy,Float:qz,&Float:vx,&Float:vy,&Float:vz);
  193. * Float:GetLineSize2D(Float:points[][],maxpoints=sizeof(points));
  194. * Float:GetLineSize3D(Float:points[][],maxpoints=sizeof(points));
  195. * IsVehicleInRangeOfPoint(vehicleid,Float:range,Float:x,Float:y,Float:z);
  196. * IsActorInRangeOfPoint(actorid,Float:range,Float:x,Float:y,Float:z);
  197. * IsObjectInRangeOfPoint(objectid,Float:range,Float:x,Float:y,Float:z);
  198. * ShiftLineRotation(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,Float:rx,Float:ry,Float:rz,&Float:nX,&Float:nY,&Float:nZ);
  199. * ShiftLineRotationVector(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,Float:rx,Float:ry,Float:rz,&Float:nX,&Float:nY,&Float:nZ);
  200. * Float:GetEllipseRadius(Float:x,Float:y,Float:angle);
  201. * GetArcPoints3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:ry,Float:height,Float:points[][],max_points=sizeof(points));
  202. * GetArcPointsFloor3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:spread,Float:points[][],max_points=sizeof(points));
  203. * GetArcPointsCellar3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:spread,Float:points[][],max_points=sizeof(points));
  204. * GetArcPointsLarboard3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:spread,Float:points[][],max_points=sizeof(points));
  205. * GetArcPointsStarboard3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:spread,Float:points[][],max_points=sizeof(points));
  206. * Float:GetDistanceFromPointToLine(Float:px,Float:py,Float:pz,Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,&Float:iX=0.0,&Float:iY=0.0,&Float:iZ=0.0);
  207. * ShiftOffsetToPosition(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:offset_x,Float:offset_y,Float:offset_z,&Float:tx,&Float:ty,&Float:tz);
  208. * ShiftPositionToOffset(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,&Float:offset_x,&Float:offset_y,&Float:offset_z,Float:tx,Float:ty,Float:tz);
  209. * Tryg3D::EulerToQuat(Float:rx,Float:ry,Float:rz,&Float:qw,&Float:qx,&Float:qy,&Float:qz);
  210. * Tryg3D::QuatToEuler(&Float:rx,&Float:ry,&Float:rz,Float:qw,Float:qx,Float:qy,Float:qz);
  211. * ShiftVectorRotation(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,&Float:tx,&Float:ty,&Float:tz);
  212. * GetCube3DPoint(OrientationCube3D:orientation,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z,&Float:tx,&Float:ty,&Float:tz);
  213. * IsPlayerFakeSpectating(playerid,bool:force_disable=true);
  214. * GenerateGangZone(Float:x,Float:y,Float:radius,&Float:minx,&Float:miny,&Float:maxx,&Float:maxy);
  215. * Float:GetCameraTargetDistance(Float:CamX,Float:CamY,Float:CamZ,Float:ObjX,Float:ObjY,Float:ObjZ,Float:FrX,Float:FrY,Float:FrZ);
  216. * IsPlayerAimingAt(playerid,Float:x,Float:y,Float:z,Float:radius);
  217. * IPL_CreateObject(modelid,Float:x,Float:y,Float:z,Float:qx,Float:qy,Float:qz,Float:qw,Float:drawdistance=0.0);
  218. *
  219. * //Universal Functions:
  220. * GetInvalidElementID(Item3D_Type:item_type);
  221. * GetElementPos(elementid,Item3D_Type:element_type,&Float:x,&Float:y,&Float:z);
  222. * GetElementVirtualWorld(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type);
  223. * GetElementRotationQuat(elementid,Item3D_Type:element_type,&Float:qw,&Float:qx,&Float:qy,&Float:qz);
  224. * GetElementUpVector(elementid,Item3D_Type:element_type,&Float:vx,&Float:vy,&Float:vz);
  225. * GetElementUpPos(elementid,Item3D_Type:element_type,Float:radius,&Float:x,&Float:y,&Float:z,bool:reverse=false);
  226. * Float:GetElementsDistance(elementid,Item3D_Type:element_type,targetid,Item3D_Type:target_type);
  227. * Float:GetElementDistanceFromPoint(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z);
  228. * IsElementOnPlayerScreen(playerid,targetid,Item3D_Type:target_type=item_player,element_orientation:orientation=o_front,Float:rx=INVALID_ROTATION,Float:rz=INVALID_ROTATION,Float:vrx=VERTICAL_CAMERA_RADIUS,Float:vrz=HORIZONTAL_CAMERA_RADIUS,bool:testLOS=true,bool:testVW=true,bool:veh_col=false);
  229. * IsElementOnFakeScreen(Float:x,Float:y,Float:z,targetid,Item3D_Type:target_type,Float:rx,Float:rz,Float:vrx=VERTICAL_CAMERA_RADIUS,Float:vrz=HORIZONTAL_CAMERA_RADIUS,bool:testLOS=true,bool:veh_col=false);
  230. * IsElementInCircle(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:radius);
  231. * IsElementInCylinder3D(elementid,Item3D_Type:element_type,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius);
  232. * IsElementInCylinder2D(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:minz,Float:maxz,Float:radius);
  233. * IsElementInSphere(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z,Float:radius);
  234. * IsElementInRectangle(elementid,Item3D_Type:element_type,Float:minx,Float:miny,Float:maxx,Float:maxy);
  235. * IsElementInCube(elementid,Item3D_Type:element_type,Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz);
  236. * IsElementInPolygon(elementid,Item3D_Type:element_type,Float:points[],maxpoints=sizeof(points));
  237. * IsElementInCircularSector(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:rz,Float:radius,Float:view_angle);
  238. * IsElementInSphericalSector(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz);
  239. * IsElementInCone(elementid,Item3D_Type:element_type,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius);
  240. * IsElementInCube3D(elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z);
  241. * GetElementToPointVector(elementid,Item3D_Type:element_type,Float:tx,Float:ty,Float:tz,&Float:vx,&Float:vy,&Float:vz);
  242. * GetElementRotatedVector(elementid,Item3D_Type:element_type,Float:tx,Float:ty,Float:tz,&Float:vx,&Float:vy,&Float:vz,bool:return_vector=true,Float:rx=0.0,Float:ry=0.0,Float:rz=0.0);
  243. * GetElementOrientationPos(elementid,Item3D_Type:element_type,element_orientation:orientation,Float:distance,&Float:tx,&Float:ty,&Float:tz);
  244. * IsElementInEllipse(elementid,Item3D_Type:element_type,Float:cx,Float:cy,Float:size_x,Float:size_y);
  245. * IsElementInEllipticalCylinder2D(elementid,Item3D_Type:element_type,Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y);
  246. *
  247. * //Universal Functions (ColAndreas):
  248. * IsBetweenElementsIsWall(elementid,Item3D_Type:element_type,targetid,Item3D_Type:target_type);
  249. * IsBetweenElementToPointIsWall(Float:x,Float:y,Float:z,targetid,Item3D_Type:target_type);
  250. * GetElementCollisionFlags(elementid,Item3D_Type:element_type);
  251. * IsPlayerInRangeOfElement(playerid,Float:range,targetid,Item3D_Type:target_type=item_player,bool:testLOS=true,bool:veh_col=false);
  252. * IsElementInRangeOfPoint(Float:x,Float:y,Float:z,Float:range,targetid,Item3D_Type:target_type=item_player,bool:testLOS=true,bool:veh_col=false);
  253. * IsElementInRangeOfElement(elementid,Item3D_Type:element_type,Float:range,targetid,Item3D_Type:target_type=item_player,bool:testLOS=true,bool:veh_col=false);
  254. * GetElementOrientationPosCol(elementid,Item3D_Type:element_type,element_orientation:orientation,Float:distance,&Float:tx,&Float:ty,&Float:tz);
  255. * IsPointInWaterOrientOfElement(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:radius,element_orientation:orientation=o_front);
  256. *
  257. * //Universal Functions (Stream3D):
  258. * IsElementInStream(elementid,Item3D_Type:element_type,Stream:StreamData[Stream3D]);
  259. *
  260. * //Universal Functions (Streamer):
  261. * IsElementInDynamicArea(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,STREAMER_TAG_AREA areaid);
  262. * GetElementsInDynamicArea(STREAMER_TAG_AREA areaid,Item3D_Type:element_type,element_list[],max_element=sizeof(element_list));
  263. *
  264. * //ScreenToWorld Functions:
  265. * ScreenToWorld(playerid,Float:screenX,Float:screenY,&Float:vX,&Float:vY,&Float:vZ);
  266. * WorldToScreen(playerid,Float:x,Float:y,Float:z,&Float:screenX,&Float:screenY);
  267. * ScreenToWorldCol(playerid,Float:distance,Float:screenX,Float:screenY,&Float:vX,&Float:vY,&Float:vZ);
  268. * Tryg3D::NormCrossProduct(&Float:x,&Float:y,&Float:z,Float:v1x,Float:v1y,Float:v1z,Float:v2x,Float:v2y,Float:v2z);
  269. *
  270. * //Nero_3D Rotations Functions:
  271. * Tryg3D::GetRotationMatrixEuler(Float:matrix[][],Float:rx,Float:ry,Float:rz,T3D:eulermode:mode=T3D:euler_default);
  272. * Tryg3D::MatrixRotate(Float:matrix[][],Float:oX,Float:oY,Float:oZ,&Float:x,&Float:y,&Float:z);
  273. * Tryg3D::QuatRotate(Float:qw,Float:qx,Float:qy,Float:qz,Float:oX,Float:oY,Float:oZ,&Float:tx,&Float:ty,&Float:tz);
  274. * Tryg3D::GetQuatFromEuler(Float:rx,Float:ry,Float:rz,&Float:qw,&Float:qx,&Float:qy,&Float:qz,T3D:eulermode:mode=T3D:euler_default);
  275. * Tryg3D::EulerRotate(Float:rX,Float:rY,Float:rZ,Float:oX,Float:oY,Float:oZ,&Float:tx,&Float:ty,&Float:tz,T3D:eulermode:mode=T3D:euler_default);
  276. *
  277. * //VehiclePartPosition Functions:
  278. * GetVehiclePartPos(vehicleid,partid,&Float:tx,&Float:ty,&Float:tz,Float:offset_x=0.0,Float:offset_y=0.0,Float:offset_z=0.0);
  279. * GetDynamicVehiclePartPos(vehicleid,partid,&Float:tx,&Float:ty,&Float:tz,Float:offset_x=0.0,Float:offset_y=0.0,Float:offset_z=0.0);
  280. *
  281. * //VehicleCollision Functions:
  282. * IsVehicleCollisionEnabled();
  283. * Tryg3D::InitVehicleCollision(); //OnGameModeInit / OnFilterScriptInit
  284. * Tryg3D::ExitVehicleCollision();
  285. * Tryg3D::SyncVehicleCollision(vehicleid); //EVF -> OnVehicleCreated
  286. * MovePointColWithVehicle(Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ,&Float:x,&Float:y,&Float:z);
  287. * MovePointColWithVehicleCut(Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ,&Float:x,&Float:y,&Float:z,Float:cut_size=0.0);
  288. * IsBetweenElementToPointIsVeh(Float:x,Float:y,Float:z,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type);
  289. * IsBetweenElementsIsVeh(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type);
  290. *
  291. * //Extended Functions:
  292. * Tryg3D::GetModuleName(Tryg3D::Module:moduleid);
  293. * Tryg3D::GetModules(&modules_count=0);
  294. * Tryg3D::IsModuleLoaded(Tryg3D::Module:moduleid);
  295. * Tryg3D::GetErrorCount();
  296. * Tryg3D::ResetErrorCount();
  297. * Tryg3D::SetStreamDistance(Float:streamdistance); //default 300.0
  298. * Float:Tryg3D::GetStreamDistance();
  299. * Tryg3D::GetActiveCount();
  300. * Tryg3D::GetVersion(value);
  301. *
  302. * //Animation Functions:
  303. * IsPlayerSkydiving(playerid);
  304. * IsPlayerUsingParachute(playerid);
  305. * IsPlayerAiming(playerid);
  306. * IsPlayerStay(playerid);
  307. * IsPlayerRunning(playerid);
  308. * IsPlayerSwim(playerid);
  309. * IsPlayerJump(playerid);
  310. * IsPlayerParaFall(playerid);
  311. * IsPlayerParaGlide(playerid);
  312. * IsPlayerFall(playerid);
  313. *
  314. * //ATM Module Functions:
  315. * randomex(min,max);
  316. * Tryg3D::KeyPressed(key);
  317. * Tryg3D::KeyReleased(key);
  318. * Tryg3D::KeyHolding(key);
  319. * Tryg3D::GetSAMIncludeVersion(value,name[],maxdest=sizeof(name));
  320. * Tryg3D::DisableADMLogging(bool:disable);
  321. * Tryg3D::SecToTimeDay(second); //Use: %d:%02d:%02d:%02d
  322. * Tryg3D::MSToTimeDay(millisecond); //Use: %d:%02d:%02d:%02d
  323. * Tryg3D::SecToTime(second); //Use: %02d:%02d:%02d
  324. * Tryg3D::MSToTime(millisecond); //Use: %02d:%02d:%02d
  325. * Tryg3D::SecToTimeMini(second); //Use: %02d:%02d
  326. * Tryg3D::MSToTimeMini(millisecond); //Use: %02d:%02d
  327. *
  328. * //Streamer Functions:
  329. * IsDynamicObjectInRangeOfPoint(objectid,Float:range,Float:x,Float:y,Float:z);
  330. * SetPlayerAbsolutePosition(playerid,Float:x,Float:y,Float:z,Float:angle,worldid=-1,interiorid=-1,compensatedtime=-1,freezeplayer=1);
  331. * SetPlayerAbsolutePositionVeh(playerid,Float:x,Float:y,Float:z,Float:angle,worldid=-1,interiorid=-1,compensatedtime=-1,freezeplayer=1);
  332. * IsDynamicActorInRangeOfPoint(actorid,Float:range,Float:x,Float:y,Float:z);
  333. * IsVehicleFullyInDynamicArea(vehicleid,areaid);
  334. * GetRandomPointInDynamicArea(STREAMER_TAG_AREA areaid,&Float:tx,&Float:ty,&Float:tz);
  335. * IPL_CreateDynamicObject(modelid,Float:x,Float:y,Float:z,Float:qx,Float:qy,Float:qz,Float:qw,worldid=-1,interiorid=-1,playerid=-1,Float:streamdistance=STREAMER_OBJECT_SD,Float:drawdistance=STREAMER_OBJECT_DD,STREAMER_TAG_AREA areaid=STREAMER_TAG_AREA -1,priority=0);
  336. *
  337. * //MapAndreas Functions:
  338. * Float:MapAndreasFindZ(Float:x,Float:y,&Float:z=0.0);
  339. * GetGroundRotation(Float:x,Float:y,Float:size,&Float:rx,&Float:ry);
  340. * GetPointInFrontOnGround(Float:x,Float:y,Float:z,Float:rx,Float:rz,&Float:tx,&Float:ty,&Float:tz,Float:max_distance);
  341. * IsPointInWater(Float:x,Float:y,Float:z=0.0);
  342. *
  343. * //MapAndreas Extended Functions:
  344. * Tryg3D::IsMapAndreasInit();
  345. * Tryg3D::SafeMapAndreasInit(mode=MAP_ANDREAS_MODE_FULL,name[]="",len=sizeof(name));
  346. *
  347. * //ColAndreas Functions:
  348. * MovePointCol(Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ,&Float:x,&Float:y,&Float:z);
  349. * MovePointColCutLine(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,&Float:x,&Float:y,&Float:z,Float:cut_size=0.0);
  350. * MovePointColCutLineEx(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,&Float:x,&Float:y,&Float:z,Float:cut_size=0.0);
  351. * GetPointInFront3DCol(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  352. * GetPointInFront3DColEx(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz);
  353. * Float:GetPointInFrontOfPlayerCol(playerid,&Float:tx,&Float:ty,Float:radius);
  354. * Float:GetPointInFrontOfCamera2DCol(playerid,&Float:tx,&Float:ty,Float:radius);
  355. * GetPointInFrontOfCamera3DCol(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
  356. * Float:GetPointInFrontOfVehicle2DCol(vehicleid,&Float:tx,&Float:ty,Float:radius);
  357. * GetPointInFrontOfVehicle3DCol(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
  358. * GetGroundRotation(Float:x,Float:y,Float:size,&Float:rx,&Float:ry);
  359. * GetPointInFrontOnGround(Float:x,Float:y,Float:z,Float:rx,Float:rz,&Float:tx,&Float:ty,&Float:tz,Float:max_distance);
  360. * GetPointCollisionFlags(Float:x,Float:y,Float:z,interiorid=0);
  361. * IsCollisionFlag(value,flag);
  362. * Float:UndergroundFindZ(Float:x,Float:y,&Float:z=0.0);
  363. * Float:InteriorFindZ(Float:px,Float:py,Float:pz=1000.0,Float:size=2.0,&Float:z=0.0);
  364. * IsPointInWater(Float:x,Float:y,Float:z=0.0);
  365. * IsPointInUnderwater(Float:x,Float:y,Float:z);
  366. * IsPointInUnderground(Float:x,Float:y,Float:z);
  367. * IsPointInAir(Float:x,Float:y,Float:z,bool:interior=false,Float:max_distance=2.2);
  368. * IsPointInGround(Float:x,Float:y,Float:z,bool:interior=false,Float:max_distance=2.2);
  369. * IsBetweenPlayersIsWall(playerid,targetid);
  370. * IsBetweenPlayerToPointIsWall(playerid,Float:x,Float:y,Float:z);
  371. * GetPointInWallForPoint(Float:x,Float:y,Float:z,Float:radius,&Float:tx,&Float:ty,&Float:tz,Float:sector=90.0);
  372. * GetWallRotation(Float:sx,Float:sy,Float:sz,Float:ex,Float:ey,Float:ez,&Float:rx,&Float:rz,&Float:px=0.0,&Float:py=0.0,&Float:pz=0.0,Float:size=1.0,Float:cut_size=0.0);
  373. * Float:MapAndreasFindZ(Float:x,Float:y,&Float:z=0.0);
  374. *
  375. * //ColAndreas Extended Functions:
  376. * Tryg3D::IsColAndreasInit();
  377. * Tryg3D::SafeColAndreasInit();
  378. *
  379. * //ColAndreas Callbacks:
  380. * OnColAndreasRemoveBuilding();
  381. *
  382. * //YSF Functions:
  383. * Float:GetPlayerHydraReactorRX(playerid);
  384. * IsPlayerHydraReactorBoost(playerid);
  385. * GetPlayerRotation(playerid,&Float:rx,&Float:ry,&Float:rz);
  386. * CountTextDraw();
  387. * CountPlayerTextDraw(playerid);
  388. * CountVisibleTextDraw(playerid);
  389. * CountVisiblePlayerTextDraw(playerid);
  390. * CountGangZone();
  391. * CountVisibleGangZone(playerid);
  392. * CountPlayerGangZone(playerid);
  393. * CountVisiblePlayerGangZone(playerid);
  394. * IsVehicleOnSpawn(vehicleid,Float:check_radius=1.0);
  395. * IsPlayerOnSpawn(playerid,Float:check_radius=1.0);
  396. * GetRandomPointInGangZone(zoneid,&Float:tx,&Float:ty);
  397. * GetRandomPointInPlayerGangZone(playerid,zoneid,&Float:tx,&Float:ty);
  398. *
  399. * //FCNPC Functions:
  400. * Float:FCNPC::GetPointInFront(npcid,&Float:tx,&Float:ty,Float:radius);
  401. * FCNPC::InRangeOfPoint(npcid,Float:range,Float:x,Float:y,Float:z);
  402. * Float:FCNPC::GetSpeed(npcid);
  403. * Float:FCNPC::GetTargetAngle(npcid,Float:x,Float:y,&Float:rz=0.0);
  404. * Float:FCNPC::SetTargetAngle(npcid,Float:x,Float:y,&Float:rz=0.0);
  405. * FCNPC::SetVehicleRotation(npcid,Float:rx,Float:ry,Float:rz);
  406. * FCNPC::SetVehicleTargetRotation(npcid,Float:tx,Float:ty,Float:tz,Float:ry=0.0);
  407. * FCNPC::GoToAir(npcid,Float:x,Float:y,Float:z,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,Float:dist_offset=0.0,stopdelay=250);
  408. *
  409. * //FCNPC Functions (ColAndreas):
  410. * Float:FCNPC::GetPointInFrontCol(npcid,&Float:tx,&Float:ty,Float:radius);
  411. * FCNPC::GoToCol(npcid,Float:x,Float:y,Float:z,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas=false,Float:cut_size=0.0,bool:setangle=true,Float:dist_offset=0.0,stopdelay=250);
  412. * FCNPC::GoToPlayerCol(npcid,playerid,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas=false,Float:cut_size=0.0,bool:setangle=true,Float:dist_offset=0.0,stopdelay=250);
  413. * FCNPC::GoToPlayerOnGroundCol(npcid,playerid,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas=false,Float:cut_size=1.0,Float:climbing=2.0,bool:setangle=true,Float:dist_offset=0.0,stopdelay=250);
  414. * FCNPC::GoToAirCol(npcid,Float:x,Float:y,Float:z,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,Float:cut_size=0.0,Float:dist_offset=0.0,stopdelay=250);
  415. * FCNPC::RandomMoveInDynamicArea(npcid,STREAMER_TAG_AREA areaid,Float:climbing=2.0,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas=false,bool:setangle=true,Float:dist_offset=0.0,stopdelay=250);
  416. * FCNPC::RandomMoveInStream(npcid,Stream:StreamData[Stream3D],Float:climbing=2.0,type=FCNPC_MOVE_TYPE_AUTO,Float:speed=FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas=false,bool:setangle=true,Float:dist_offset=0.0,stopdelay=250);
  417. * FCNPC::SetAbsolutePosition(npcid,Float:x,Float:y,Float:z,Float:angle,worldid=-1,interiorid=-1,compensatedtime=-1,freezeplayer=1);
  418. * FCNPC::SetFloorPos(npcid);
  419. *
  420. * //Stream3D Functions:
  421. * StreamCreate(variable);
  422. * StreamType:GetStreamType(Stream:StreamData[Stream3D]);
  423. * Stream:ConvertAreaToStream(areaid);
  424. * Stream:StreamCircle(Float:x,Float:y,Float:radius);
  425. * Stream:StreamCylinder3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius);
  426. * Stream:StreamCylinder2D(Float:x,Float:y,Float:minz,Float:maxz,Float:radius);
  427. * Stream:StreamSphere(Float:x,Float:y,Float:z,Float:radius);
  428. * Stream:StreamRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy);
  429. * Stream:StreamCube(Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz);
  430. * Stream:StreamCircularSector(Float:x,Float:y,Float:rz,Float:radius,Float:view_angle);
  431. * Stream:StreamSphericalSector(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz);
  432. * Stream:StreamCone3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius);
  433. * Stream:StreamCube3D(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z);
  434. * Stream:StreamEllipse(Float:cx,Float:cy,Float:size_x,Float:size_y);
  435. * Stream:StreamEllipticalCylinder2D(Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y);
  436. * IsValidStream(Stream:StreamData[Stream3D]);
  437. * IsPointInStream(Float:x,Float:y,Float:z,Stream:StreamData[Stream3D]);
  438. * GetRandomPointInStream(Stream:StreamData[Stream3D],&Float:x,&Float:y,&Float:z);
  439. * GetRandomPointOnStream(Stream:StreamData[Stream3D],&Float:x,&Float:y,&Float:z);
  440. * IsVehicleFullyInStream(vehicleid,Stream:StreamData[Stream3D]);
  441. *
  442. * //VehicleStreamer Functions:
  443. * GetDynamicVehicleFlags(vehicleid);
  444. * Float:GetDynamicVehicleSpeed(vehicleid);
  445. * Float:GetPointInFrontOfDynVeh2D(vehicleid,&Float:tx,&Float:ty,Float:radius);
  446. * GetPointInFrontOfDynVeh3D(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
  447. * IsDynVehInRangeOfPoint(vehicleid,Float:range,Float:x,Float:y,Float:z);
  448. * IsDynVehFullyInDynamicArea(vehicleid,areaid);
  449. * Float:GetPointInFrontOfDynVeh2DCol(vehicleid,&Float:tx,&Float:ty,Float:radius);
  450. * GetPointInFrontOfDynVeh3DCol(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
  451. * IsDynamicVehicleOnSpawn(vehicleid,Float:check_radius=1.0);
  452. * IsDynamicVehicleFullyInStream(vehicleid,Stream:StreamData[Stream3D]);
  453. * GetDynamicVehicleRotation(vehicleid,&Float:rx,&Float:ry,&Float:rz);
  454. *
  455. * //Functions extra names:
  456. * Tryg3D::MapAndreasFindZ -> ColAndreas::FindZ_For2DCoord / MapAndreasFindZ
  457. *
  458. * //Deprecated Functions:
  459. * GetDistanceBetweenPoints -> GetDistanceBetweenPoints3D
  460. * GetPlayersDistance -> GetElementsDistance
  461. * GetVehiclesDistance -> GetElementsDistance
  462. * GetObjectsDistance -> GetElementsDistance
  463. * GetActorDistanceFromPoint -> GetElementDistanceFromPoint
  464. * GetObjectDistanceFromPoint -> GetElementDistanceFromPoint
  465. * GetDistanceBetweenPlayers -> GetElementsDistance
  466. * GetDistanceBetweenVehicles -> GetElementsDistance
  467. * GetDistanceBetweenObjects -> GetElementsDistance
  468. * GetPlayerActorDistance -> GetElementsDistance
  469. * GetPlayerVehicleDistance -> GetElementsDistance
  470. * GetPlayerObjectDistance -> GetElementsDistance
  471. * IsPlayerInCircle -> IsElementIn...
  472. * IsPlayerInCylinder3D -> IsElementIn...
  473. * IsPlayerInCylinder2D -> IsElementIn...
  474. * IsPlayerInSphere -> IsElementIn...
  475. * IsPlayerInRectangle -> IsElementIn...
  476. * IsPlayerInCube -> IsElementIn...
  477. * IsPlayerInPolygon -> IsElementIn...
  478. * IsPlayerInCircularSector -> IsElementIn...
  479. * IsPlayerInSphericalSector -> IsElementIn...
  480. * IsPlayerInCone -> IsElementIn...
  481. * IsPlayerInCube3D -> IsElementIn...
  482. * IsPlayerInEllipse -> IsElementIn...
  483. * IsPlayerInEllipticalCylinder2D -> IsElementInEllipticalCylinder2D
  484. * GetPlayerCollisionFlags -> GetElementCollisionFlags
  485. * GetVehicleCollisionFlags -> GetElementCollisionFlags
  486. * IsPointInWaterFrontOfPlayer -> IsPointInWaterOrientOfElement
  487. * *
  488. * //Symbols: *
  489. * FLOAT_PI - pi constant value *
  490. * FLOAT_EULER - Euler number *
  491. * FLOAT_NAN - Float NaN *
  492. * FLOAT_DEFECT - Float defect (Arc Test) *
  493. * FLOAT_INFINITY - Float Infinity *
  494. * VBTP - Value Bigger Than Possible *
  495. * VLTP - Value Lower Than Possible *
  496. * *
  497. * //Definitions: *
  498. * VERTICAL_CAMERA_RADIUS - (modifiable) *
  499. * HORIZONTAL_CAMERA_RADIUS - (modifiable) *
  500. * INVALID_ROTATION - (modifiable) *
  501. * MAX_POLYGON_POINTS - (modifiable) *
  502. * VEHICLE_SPEED_MULTIPLIER - (modifiable) *
  503. * PLAYER_SPEED_MULTIPLIER - (modifiable) *
  504. * INVALID_MOVE_TIME - (modifiable) *
  505. * INVALID_MOVE_SPEED - (modifiable) *
  506. * INVALID_VIRTUAL_WORLD *
  507. * *
  508. * //Position Flags: *
  509. * POSITION_FLAG_WORLD *
  510. * POSITION_FLAG_INTERIOR *
  511. * POSITION_FLAG_AIR *
  512. * POSITION_FLAG_GROUND *
  513. * POSITION_FLAG_WATER *
  514. * POSITION_FLAG_UNDERWATER *
  515. * POSITION_FLAG_UNDERGROUND *
  516. * *
  517. * //Vehicle Flags: *
  518. * VF_STREET VF_AIRBORNE VF_NATATORIAL VF_MILITARY VF_TRAIN VF_RC VF_CARRIAGE *
  519. * VF_AIRPLANE VF_HELICOPTER VF_BIKES VF_TRAILER VF_TOWABLE VF_POLICE *
  520. * *
  521. * //Vehicle Parts: *
  522. * VEHICLE_PART_RFTIRE - Right Front tire *
  523. * VEHICLE_PART_LFTIRE - Left Front tire *
  524. * VEHICLE_PART_RRTIRE - Right Rear tire *
  525. * VEHICLE_PART_LRTIRE - Left Rear tire *
  526. * VEHICLE_PART_HOOD - In Front *
  527. * VEHICLE_PART_TRUNK - Behind *
  528. * VEHICLE_PART_ROOF - Roof *
  529. * VEHICLE_PART_CHASSIS - Chassis *
  530. * VEHICLE_PART_PETROLCAP - Petrolcap *
  531. * *
  532. * enum 'element_orientation' *
  533. * # o_left - Orientation Left *
  534. * # o_right - Orientation Right *
  535. * # o_up - Orientation UP *
  536. * # o_down - Orientation Down *
  537. * # o_front - Orientation Front *
  538. * # o_back - Orientation Back *
  539. * *
  540. * enum 'Item3D_Type' *
  541. * # item_player *
  542. * # item_npc *
  543. * # item_actor *
  544. * # item_object *
  545. * # item_vehicle *
  546. * # item_dynamic_object *
  547. * # item_dynamic_pickup *
  548. * # item_dynamic_cp *
  549. * # item_dynamic_racecp *
  550. * # item_dynamic_mapicon *
  551. * # item_dynamic_3dtext *
  552. * # item_dynamic_actor *
  553. * # item_dynamic_vehicle *
  554. * # item_fcnpc *
  555. * *
  556. * enum 'Vectors3D' *
  557. * # Float: T3D:X - Position X *
  558. * # Float: T3D:Y - Position Y *
  559. * # Float: T3D:Z - Position Z *
  560. * # Float: T3D:A - Angle *
  561. * *
  562. * enum 'Float3D' *
  563. * # Float: T3D:X - Position X *
  564. * # Float: T3D:Y - Position Y *
  565. * # Float: T3D:Z - Position Z *
  566. * # Float: T3D:rX - Rotation X *
  567. * # Float: T3D:rY - Rotation Y *
  568. * # Float: T3D:rZ - Rotation Z *
  569. * # Float: T3D:tX - Target Position X *
  570. * # Float: T3D:tY - Target Position Y *
  571. * # Float: T3D:tZ - Target Position Z *
  572. * # T3D:VW - Virtual World ID *
  573. * # T3D:INT - Interior ID *
  574. * # Float: T3D:SPEED - Speed *
  575. * *
  576. * enum 'LongFloat3D' *
  577. * # Float: T3D:X - Position X *
  578. * # Float: T3D:Y - Position Y *
  579. * # Float: T3D:Z - Position Z *
  580. * # Float: T3D:rX - Rotation X *
  581. * # Float: T3D:rY - Rotation Y *
  582. * # Float: T3D:rZ - Rotation Z *
  583. * # Float: T3D:tX - Target Position X *
  584. * # Float: T3D:tY - Target Position Y *
  585. * # Float: T3D:tZ - Target Position Z *
  586. * # Float: T3D:trX - Target Rotation X *
  587. * # Float: T3D:trY - Target Rotation Y *
  588. * # Float: T3D:trZ - Target Rotation Z *
  589. * # Float: T3D:VecX - Vector Position X *
  590. * # Float: T3D:VecY - Vector Position Y *
  591. * # Float: T3D:VecZ - Vector Position Z *
  592. * # T3D:VW - Virtual World ID *
  593. * # T3D:INT - Interior ID *
  594. * # Float: T3D:SPEED - Speed *
  595. * *
  596. * enum 'StreamType' *
  597. * # s_invalid *
  598. * # s_circle *
  599. * # s_cylinder2d *
  600. * # s_cylinder3d *
  601. * # s_sphere *
  602. * # s_rectangle *
  603. * # s_cube2d *
  604. * # s_cube3d *
  605. * # s_circularsector *
  606. * # s_sphericalsector *
  607. * # s_cone *
  608. * # s_ellipse *
  609. * # s_ellipticalcyl2d *
  610. * *
  611. * enum 'OrientationCube3D' *
  612. * # o_left_back_down *
  613. * # o_right_back_down *
  614. * # o_right_front_down *
  615. * # o_left_front_down *
  616. * # o_left_back_up *
  617. * # o_right_back_up *
  618. * # o_right_front_up *
  619. * # o_left_front_up *
  620. * *
  621. * enum 'Tryg3D::Module' *
  622. * # TRYG3D_MODULEID_MAPANDREAS *
  623. * # TRYG3D_MODULEID_COLANDREAS *
  624. * # TRYG3D_MODULEID_YSF *
  625. * # TRYG3D_MODULEID_STREAMER *
  626. * # TRYG3D_MODULEID_FOXFOREACH *
  627. * # TRYG3D_MODULEID_YSIFOREACH *
  628. * # TRYG3D_MODULEID_FCNPC *
  629. * # TRYG3D_MODULEID_STREAM3D *
  630. * # TRYG3D_MODULEID_ACTOR *
  631. * # TRYG3D_MODULEID_ATM *
  632. * # TRYG3D_MODULEID_ANIMS *
  633. * # TRYG3D_MODULEID_VEHSTREAMER *
  634. * # TRYG3D_MODULEID_VEHICLECOL *
  635. * *
  636. *************************************************************************************************************************************/
  637. /*
  638. //Check Version 3DTryg.inc
  639. #if !defined _3D_Tryg
  640. #error [ADM] You need 3DTryg.inc v4.5.2 (github.com/AbyssMorgan/SA-MP/blob/master/include/SAM/3DTryg.inc)
  641. #elseif !defined Tryg3D_Version
  642. #error [ADM] Update you 3DTryg.inc to v4.5.2 (github.com/AbyssMorgan/SA-MP/blob/master/include/SAM/3DTryg.inc)
  643. #elseif (Tryg3D_Version < 40502)
  644. #error [ADM] Update you 3DTryg.inc to v4.5.2 (github.com/AbyssMorgan/SA-MP/blob/master/include/SAM/3DTryg.inc)
  645. #endif
  646. */
  647. /************************************************************************************************************************************
  648. * *
  649. * Version *
  650. * *
  651. ************************************************************************************************************************************/
  652. #if defined _3D_Tryg
  653. #endinput
  654. #endif
  655. #define _3D_Tryg
  656. #define Tryg3D_Version (40502) //a.b.c 10000*a+100*b+c
  657. #define Tryg3D_SAMP_Version "0.3.7"
  658. #if (!defined GetPlayerPoolSize || !defined GetSVarInt)
  659. #error [ADM] This include requires SA:MP version 0.3.7 (github.com/AbyssMorgan/SA-MP/blob/master/samp/include)
  660. #endif
  661. #if defined _Text_Draw_Ex
  662. #error [ADM] Please remove deprecated file TextDrawEx.inc (already implemented)
  663. #endif
  664. #if defined _Map_Andreas_Ex
  665. #error [ADM] Please remove deprecated file MapAndreasEx.inc (already implemented)
  666. #endif
  667. #if defined _INC_VEHPARTS
  668. #error [ADM] Please remove deprecated file VehiclePartPosition.inc (already implemented, check: GetVehiclePartPos)
  669. #endif
  670. //Update Checker
  671. #if !defined HTTP
  672. #tryinclude <a_http>
  673. #endif
  674. #if !defined HTTP
  675. #error [ADM] Please include a_http.inc before 3DTryg.inc
  676. #endif
  677. #if defined _EVF_include
  678. #error [ADM] Please include EVF.inc after 3DTryg.inc for improvements
  679. #endif
  680. /************************************************************************************************************************************
  681. * *
  682. * Modules *
  683. * *
  684. ************************************************************************************************************************************/
  685. //Detect MapAndreas Plugin
  686. #if ((defined MapAndreas_FindZ_For2DCoord) && (!defined DISABLE_3D_TRYG_MAPANDREAS))
  687. #define Tryg3D_MapAndreas
  688. #define Tryg3D_MapAndreasVersion (10201) //a.b.c 10000*a+100*b+c
  689. #define Tryg3D_Module_MapAndreas (1)
  690. #if (!defined MapAndreas_GetAddress)
  691. #error [ADM] You need MapAndreas v1.2.1 (github.com/AbyssMorgan/SA-MP/tree/master/plugins)
  692. #endif
  693. #else
  694. #define Tryg3D_Module_MapAndreas (0)
  695. #endif
  696. //Detect ColAndreas Plugin
  697. #if ((defined COLANDREAS_VERSION) && (!defined COLANDREAS))
  698. #define COLANDREAS COLANDREAS_VERSION
  699. #endif
  700. #if ((defined COLANDREAS) && (!defined DISABLE_3D_TRYG_COLANDREAS))
  701. #define Tryg3D_ColAndreas
  702. #define Tryg3D_ColAndreasVersion (10400) //a.b.c 10000*a+100*b+c
  703. #define Tryg3D_Module_ColAndreas (1)
  704. #if !defined COLANDREAS_VERSION
  705. #define COLANDREAS_VERSION (0)
  706. #endif
  707. #else
  708. #define Tryg3D_Module_ColAndreas (0)
  709. #endif
  710. //Detect YSF Plugin
  711. #if ((defined _YSF_included) && (!defined DISABLE_3D_TRYG_YSF))
  712. #define Tryg3D_YSF
  713. #define Tryg3D_Module_YSF (1)
  714. #if (!defined RemovePlayerForPlayer)
  715. #error [ADM] You need YSF R19 (github.com/kurta999/YSF/releases)
  716. #endif
  717. #else
  718. #define Tryg3D_Module_YSF (0)
  719. #endif
  720. //Detect Streamer Plugin
  721. #if ((defined Streamer_AppendArrayData) && (defined INVALID_STREAMER_ID) && (!defined DISABLE_3D_TRYG_STREAMER))
  722. #define Tryg3D_Streamer
  723. #define Tryg3D_StreamerVersion (0x291)
  724. #define Tryg3D_Module_Streamer (1)
  725. #if (!defined STREAMER_TYPE_ACTOR)
  726. #error [ADM] You need Streamer v2.9.1 (github.com/samp-incognito/samp-streamer-plugin/releases)
  727. #endif
  728. #else
  729. #define Tryg3D_Module_Streamer (0)
  730. #endif
  731. //Detect Streamer Plugin
  732. #if ((defined Tryg3D_Streamer) && (defined STREAMER_TYPE_VEHICLE) && (!defined DISABLE_3D_TRYG_VEHSTREAMER))
  733. #define Tryg3D_VehicleStreamer
  734. #define Tryg3D_Module_VehicleStreamer (1)
  735. #else
  736. #define Tryg3D_Module_VehicleStreamer (0)
  737. #endif
  738. //Detect FoxForeach Include
  739. //Detect YSIForeach Include
  740. #if ((defined _FoX_Foreach) && (!defined DISABLE_3D_TRYG_FOXFOREACH))
  741. #define Tryg3D_Foreach(%0) FoxForeach(%0,Character)
  742. #define Tryg3D_FoxForeach
  743. #define Tryg3D_Module_FoxForeach (1)
  744. #define Tryg3D_Module_YSIForeach (0)
  745. #elseif ((defined _FOREACH_LOCAL_VERSION) && (!defined DISABLE_3D_TRYG_YSIFOREACH))
  746. #define Tryg3D_Foreach(%0) foreach(new %0 : Character)
  747. #define Tryg3D_YSIForeach
  748. #define Tryg3D_Module_FoxForeach (0)
  749. #define Tryg3D_Module_YSIForeach (1)
  750. #else
  751. #define Tryg3D_Foreach(%0) for(new %0 = 0, p_%0 = GetPlayerPoolSize(); %0 <= p_%0; %0++) if(IsPlayerConnected(%0))
  752. #define Tryg3D_Module_FoxForeach (0)
  753. #define Tryg3D_Module_YSIForeach (0)
  754. #endif
  755. #define Tryg3DForeach Tryg3D_Foreach
  756. //Detect FCNPC Plugin
  757. #if ((defined _FCNPC_included) && (defined FCNPC_INCLUDE_VERSION) && (!defined DISABLE_3D_TRYG_FCNPC))
  758. #define Tryg3D_FCNPC
  759. #define Tryg3D_FCNPC_Version (174) //a.b.c 100*a+10*b+c
  760. #define Tryg3D_Module_FCNPC (1)
  761. #if (FCNPC_INCLUDE_VERSION < Tryg3D_FCNPC_Version)
  762. #error [ADM] You need FCNPC v1.7.4 (github.com/ziggi/FCNPC/releases)
  763. #endif
  764. #else
  765. #define Tryg3D_Module_FCNPC (0)
  766. #endif
  767. //Detect Stream3D Module
  768. #if defined ENABLE_3D_TRYG_STREAM3D
  769. #define Tryg3D_Stream3D
  770. #define Tryg3D_Module_Stream3D (1)
  771. #else
  772. #define Tryg3D_Module_Stream3D (0)
  773. #endif
  774. //Detect a_actor Include
  775. #if ((defined _actor_included) && (!defined DISABLE_3D_TRYG_ACTOR))
  776. #define Tryg3D_Actor
  777. #define Tryg3D_Module_Actor (1)
  778. #else
  779. #define Tryg3D_Module_Actor (0)
  780. #endif
  781. //Detect ATM Module
  782. #if !defined DISABLE_3D_TRYG_ATM
  783. #define Tryg3D_ATM
  784. #define Tryg3D_Module_ATM (1)
  785. #else
  786. #define Tryg3D_Module_ATM (0)
  787. #endif
  788. //Detect Anims Module
  789. #if defined ENABLE_3D_TRYG_ANIMS
  790. #define Tryg3D_Anims
  791. #define Tryg3D_Module_Anims (1)
  792. #else
  793. #define Tryg3D_Module_Anims (0)
  794. #endif
  795. //Detect VehicleCollision Module
  796. #if ((defined Tryg3D_Streamer) && (defined Tryg3D_ColAndreas) && (!defined DISABLE_3D_TRYG_VEHICLECOL))
  797. #define Tryg3D_VehicleCollision
  798. #define Tryg3D_Module_VehicleCollision (1)
  799. #else
  800. #define Tryg3D_Module_VehicleCollision (0)
  801. #endif
  802. //Detect i_quat Include by IllidanS4
  803. #if ((defined GetVehicleRotation) && (defined VectorRelToAbsQuat))
  804. #define Tryg3D_i_quat
  805. #endif
  806. #if (defined _INC_y_utils && defined RandomFloat && !defined ENABLE_3D_TRYG_YSI_SUPPORT)
  807. #error [ADM] Include collision detected 'YSI/YSI_Core/y_utils.inc' use #define ENABLE_3D_TRYG_YSI_SUPPORT before 3DTryg.inc for fix this
  808. #endif
  809. #define Tryg3D_Function:: stock
  810. #define Tryg3D_Deprecated:: stock
  811. #define Tryg3D_Public::%0(%1) forward %0(%1); public %0(%1)
  812. #define T3D: v3D
  813. #define Tryg3D:: Tryg3D_
  814. #define FCNPC:: FCNPC_
  815. #define ColAndreas:: CA_
  816. #define Streamer:: Streamer_
  817. /************************************************************************************************************************************
  818. * *
  819. * Symbols *
  820. * *
  821. ************************************************************************************************************************************/
  822. #if !defined TRYG3D_ELEMENT_TAG
  823. #define TRYG3D_ELEMENT_TAG {Text3D,DynamicObject,DynamicPickup,DynamicCP,DynamicRaceCP,DynamicMapIcon,DynamicText3D,DynamicArea,DynamicActor,DynamicVehicle,_}:
  824. #endif
  825. #if !defined FLOAT_PI
  826. #define FLOAT_PI (3.14159265358979323846)
  827. #endif
  828. #if !defined FLOAT_EULER
  829. #define FLOAT_EULER (2.718281828459)
  830. #endif
  831. #if !defined FLOAT_NAN
  832. #define FLOAT_NAN (Float:0xFFFFFFFF)
  833. #endif
  834. #if !defined FLOAT_DEFECT
  835. #define FLOAT_DEFECT (0.000001)
  836. #endif
  837. #if !defined INVALID_ROTATION
  838. #define INVALID_ROTATION (-1000.0)
  839. #endif
  840. #if !defined VBTP
  841. #define VBTP (0x7FFFFFFF)
  842. #endif
  843. #if !defined VLTP
  844. #define VLTP (0x80000000)
  845. #endif
  846. #if !defined FLOAT_INFINITY
  847. #define FLOAT_INFINITY (Float:0x7F800000)
  848. #endif
  849. #if !defined MAX_POLYGON_POINTS
  850. #define MAX_POLYGON_POINTS (256)
  851. #endif
  852. #if !defined VEHICLE_SPEED_MULTIPLIER
  853. #define VEHICLE_SPEED_MULTIPLIER (170.0)
  854. #endif
  855. #if !defined PLAYER_SPEED_MULTIPLIER
  856. #define PLAYER_SPEED_MULTIPLIER (1.0)
  857. #endif
  858. #if !defined INVALID_MOVE_TIME
  859. #define INVALID_MOVE_TIME (-1)
  860. #endif
  861. #if !defined INVALID_MOVE_SPEED
  862. #define INVALID_MOVE_SPEED (-1.0)
  863. #endif
  864. #if !defined VERTICAL_CAMERA_RADIUS
  865. #define VERTICAL_CAMERA_RADIUS (55.0) // 27.5 * 2
  866. #endif
  867. #if !defined HORIZONTAL_CAMERA_RADIUS
  868. #define HORIZONTAL_CAMERA_RADIUS (70.0) // 35.0 * 2
  869. #endif
  870. #if !defined INVALID_VIRTUAL_WORLD
  871. #define INVALID_VIRTUAL_WORLD (-2000)
  872. #endif
  873. //Vehicle Flags
  874. #define VF_STREET (0b0000000000000001)
  875. #define VF_AIRBORNE (0b0000000000000010)
  876. #define VF_NATATORIAL (0b0000000000000100)
  877. #define VF_MILITARY (0b0000000000001000)
  878. #define VF_TRAIN (0b0000000000010000)
  879. #define VF_RC (0b0000000000100000)
  880. #define VF_CARRIAGE (0b0000000001000000)
  881. #define VF_AIRPLANE (0b0000000010000000)
  882. #define VF_HELICOPTER (0b0000000100000000)
  883. #define VF_BIKES (0b0000001000000000)
  884. #define VF_TRAILER (0b0000010000000000)
  885. #define VF_TOWABLE (0b0000100000000000)
  886. #define VF_POLICE (0b0001000000000000)
  887. //Player Position Flag
  888. #if defined Tryg3D_ColAndreas
  889. #define POSITION_FLAG_WORLD (0b0000000000000001)
  890. #define POSITION_FLAG_INTERIOR (0b0000000000000010)
  891. #define POSITION_FLAG_AIR (0b0000000000000100)
  892. #define POSITION_FLAG_GROUND (0b0000000000001000)
  893. #define POSITION_FLAG_WATER (0b0000000000010000)
  894. #define POSITION_FLAG_UNDERWATER (0b0000000000100000)
  895. #define POSITION_FLAG_UNDERGROUND (0b0000000001000000)
  896. #endif
  897. #if (!defined VEHICLE_PART_RFTIRE)
  898. #define VEHICLE_PART_RFTIRE (1) // Right Front tire
  899. #define VEHICLE_PART_LFTIRE (2) // Left Front tire
  900. #define VEHICLE_PART_RRTIRE (3) // Right Rear tire
  901. #define VEHICLE_PART_LRTIRE (4) // Left Rear tire
  902. #define VEHICLE_PART_HOOD (5) // In Front
  903. #define VEHICLE_PART_TRUNK (6) // Behind
  904. #endif
  905. #define VEHICLE_PART_ROOF (7) // Roof
  906. #define VEHICLE_PART_CHASSIS (8) // Chassis
  907. #define VEHICLE_PART_PETROLCAP (9) // Petrolcap
  908. /************************************************************************************************************************************
  909. * *
  910. * Enums/Variables *
  911. * *
  912. ************************************************************************************************************************************/
  913. //Tryg3D Plugin Module List
  914. enum Tryg3D_Module {
  915. TRYG3D_MODULEID_MAPANDREAS,
  916. TRYG3D_MODULEID_COLANDREAS,
  917. TRYG3D_MODULEID_YSF,
  918. TRYG3D_MODULEID_STREAMER,
  919. TRYG3D_MODULEID_FOXFOREACH,
  920. TRYG3D_MODULEID_YSIFOREACH,
  921. TRYG3D_MODULEID_FCNPC,
  922. TRYG3D_MODULEID_STREAM3D,
  923. TRYG3D_MODULEID_ACTOR,
  924. TRYG3D_MODULEID_ATM,
  925. TRYG3D_MODULEID_ANIMS,
  926. TRYG3D_MODULEID_VEHSTREAMER,
  927. TRYG3D_MODULEID_VEHICLECOL
  928. }
  929. enum element_orientation {
  930. o_left,
  931. o_right,
  932. o_up,
  933. o_down,
  934. o_front,
  935. o_back
  936. }
  937. enum Item3D_Type {
  938. item_player,
  939. item_npc,
  940. item_actor,
  941. item_object,
  942. item_vehicle,
  943. item_dynamic_object,
  944. item_dynamic_pickup,
  945. item_dynamic_cp,
  946. item_dynamic_racecp,
  947. item_dynamic_mapicon,
  948. item_dynamic_3dtext,
  949. item_dynamic_actor,
  950. item_dynamic_vehicle,
  951. item_fcnpc
  952. }
  953. enum Vectors3D {
  954. Float:T3D:X, Float:T3D:Y, Float:T3D:Z, Float:T3D:A
  955. }
  956. enum Float3D {
  957. Float:T3D:X, Float:T3D:Y, Float:T3D:Z,
  958. Float:T3D:rX, Float:T3D:rY, Float:T3D:rZ,
  959. Float:T3D:tX, Float:T3D:tY, Float:T3D:tZ,
  960. T3D:VW, T3D:INT, Float:T3D:SPEED
  961. }
  962. enum LongFloat3D {
  963. Float:T3D:X, Float:T3D:Y, Float:T3D:Z,
  964. Float:T3D:rX, Float:T3D:rY, Float:T3D:rZ,
  965. Float:T3D:tX, Float:T3D:tY, Float:T3D:tZ,
  966. Float:T3D:trX, Float:T3D:trY, Float:T3D:trZ,
  967. Float:T3D:VecX, Float:T3D:VecY, Float:T3D:VecZ,
  968. T3D:VW, T3D:INT, Float:T3D:SPEED
  969. }
  970. enum OrientationCube3D {
  971. o_left_back_down,
  972. o_right_back_down,
  973. o_right_front_down,
  974. o_left_front_down,
  975. o_left_back_up,
  976. o_right_back_up,
  977. o_right_front_up,
  978. o_left_front_up
  979. }
  980. #if defined Tryg3D_Stream3D
  981. enum StreamType {
  982. s_invalid,
  983. s_circle,
  984. s_cylinder2d,
  985. s_cylinder3d,
  986. s_sphere,
  987. s_rectangle,
  988. s_cube2d,
  989. s_cube3d,
  990. s_circularsector,
  991. s_sphericalsector,
  992. s_cone,
  993. s_ellipse,
  994. s_ellipticalcyl2d
  995. }
  996. enum Stream3D {
  997. StreamType:T3D:type,
  998. Float:T3D:X, Float:T3D:Y, Float:T3D:Z,
  999. Float:T3D:minX, Float:T3D:minY, Float:T3D:minZ,
  1000. Float:T3D:maxX, Float:T3D:maxY, Float:T3D:maxZ,
  1001. Float:T3D:R
  1002. }
  1003. #endif
  1004. static const Float:Cube3DOffset[OrientationCube3D][3] = {
  1005. {-1.0,-1.0,-1.0}, //left - back - down
  1006. {1.0,-1.0,-1.0}, //right - back - down
  1007. {1.0,1.0,-1.0}, //right - front - down
  1008. {-1.0,1.0,-1.0}, //left - front - down
  1009. {-1.0,-1.0,1.0}, //left - back - up
  1010. {1.0,-1.0,1.0}, //right - back - up
  1011. {1.0,1.0,1.0}, //right - front - up
  1012. {-1.0,1.0,1.0} //left - front - up
  1013. };
  1014. new Float:Tryg3D::StreamDistance = 300.0;
  1015. new const Float:Tryg3D::WeaponDamage[] = {
  1016. 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,82.5,0.0,1.0,9.9,46.2,0.0,8.25,13.2,46.2,3.3,3.3,4.95,6.6,8.25,
  1017. 9.9,9.9,6.6,24.75,41.25,82.5,82.5,1.0,46.2,82.5,0.0,0.33,0.33,0.0,0.0,0.0,0.0,0.0,2.64,9.9,330.0,82.5,1.0,1.0,165.0
  1018. };
  1019. new Tryg3D::VehicleFlags[212],
  1020. Tryg3D::DeatchTick[MAX_PLAYERS];
  1021. #if !defined isnull
  1022. #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  1023. #endif
  1024. #if !defined CreateExplosionForPlayer
  1025. native CreateExplosionForPlayer(playerid,Float:X,Float:Y,Float:Z,type,Float:Radius);
  1026. #endif
  1027. #if !defined IsValidVehicle
  1028. native IsValidVehicle(vehicleid);
  1029. #endif
  1030. /************************************************************************************************************************************
  1031. * *
  1032. * MapAndreas Update *
  1033. * *
  1034. ************************************************************************************************************************************/
  1035. #if defined Tryg3D_ColAndreas
  1036. #define Tryg3D_MapAndreasFindZ CA_FindZ_For2DCoord
  1037. #elseif defined Tryg3D_MapAndreas
  1038. Tryg3D::Function:: Float:Tryg3D::MapAndreasFindZ(Float:x,Float:y,&Float:z=0.0){
  1039. if(x <= -3000.0 || x >= 3000.0 || y <= -3000.0 || y >= 3000.0){
  1040. z = 0.0;
  1041. } else {
  1042. MapAndreas_FindZ_For2DCoord(x,y,z);
  1043. }
  1044. return z;
  1045. }
  1046. #endif
  1047. #if defined Tryg3D_VehicleCollision
  1048. /************************************************************************************************************************************
  1049. * *
  1050. * Vehicle Collision Module *
  1051. * *
  1052. ************************************************************************************************************************************/
  1053. #define VCOLLISION_EXTRA_ID_OFFSET (800000)
  1054. new STREAMER_TAG_AREA Tryg3D::VehicleCollisionZone[MAX_VEHICLES],
  1055. bool:Tryg3D::VehicleCollisionSystem = false;
  1056. //Hook: OnVehicleSpawn
  1057. public OnVehicleSpawn(vehicleid){
  1058. if(Tryg3D::VehicleCollisionSystem){
  1059. Tryg3D::SyncVehicleCollision(vehicleid);
  1060. }
  1061. #if defined Tryg3D_OnVehicleSpawn
  1062. Tryg3D_OnVehicleSpawn(vehicleid);
  1063. #endif
  1064. return 1;
  1065. }
  1066. #if defined Tryg3D_OnVehicleSpawn
  1067. forward Tryg3D_OnVehicleSpawn(vehicleid);
  1068. #endif
  1069. #if defined _ALS_OnVehicleSpawn
  1070. #undef OnVehicleSpawn
  1071. #else
  1072. #define _ALS_OnVehicleSpawn
  1073. #endif
  1074. #define OnVehicleSpawn Tryg3D_OnVehicleSpawn
  1075. #endif
  1076. /************************************************************************************************************************************
  1077. * *
  1078. * Complementary Functions *
  1079. * *
  1080. ************************************************************************************************************************************/
  1081. #define abs(%0) (((%0) < 0)?(-(%0)):((%0)))
  1082. #define fabs(%0) (((%0) < 0.0)?(-(%0)):((%0)))
  1083. #define sqrtN(%0,%1) floatpower((%0),(1.0/(%1)))
  1084. #define IsEven(%0) ((((%0) % 2) == 0)?(true):(false))
  1085. #define power(%0,%1) (floatround(floatpower((%0),(%1))))
  1086. //Author: hesambia random.inc
  1087. Tryg3D::Function:: Float:Tryg3D::RandomFloat(Float:min,Float:max,accuracy = 4){
  1088. if(min >= max) return 0.0;
  1089. if(min < 0.0 || max < 0.0) return 0.0;
  1090. if(accuracy < 1 || accuracy > 6) accuracy = 4;
  1091. new T3D:divValue = floatround(floatpower(10.0,accuracy));
  1092. return random(floatround(max)-floatround(min))+min+(random(T3D:divValue)/T3D:divValue);
  1093. }
  1094. #if (defined ENABLE_3D_TRYG_YSI_SUPPORT)
  1095. #if !defined RandomFloat
  1096. #define RandomFloat Tryg3D_RandomFloat
  1097. #endif
  1098. #else
  1099. #define RandomFloat Tryg3D_RandomFloat
  1100. #endif
  1101. /************************************************************************************************************************************
  1102. * *
  1103. * Internal Functions *
  1104. * *
  1105. ************************************************************************************************************************************/
  1106. #define single_clock(%1,%2) ((360.0/(%1))*(%2))
  1107. #define even_clock(%1,%2) ((360.0/(%1))*(2*(%2)))
  1108. #define uneven_clock(%1,%2) ((360.0/(%1))*((2*(%2))-1))
  1109. #define NLTZ(%0) (((%0) < 0)?(0):(%0))
  1110. #define NMTZ(%0) (((%0) > 0)?(0):(%0))
  1111. #define NLTZF(%0) (((%0) < 0.0)?(0.0):(%0))
  1112. #define NMTZF(%0) (((%0) > 0.0)?(0.0):(%0))
  1113. #define NLTV(%0,%1) (((%0) < (%1))?(%1):(%0))
  1114. #define NMTV(%0,%1) (((%0) > (%1))?(%1):(%0))
  1115. #define NLTVF(%0,%1) (((%0) < (%1))?(%1):(%0))
  1116. #define NMTVF(%0,%1) (((%0) > (%1))?(%1):(%0))
  1117. //swapvars by Crayder
  1118. #define Tryg3D_SwapInt(%0,%1) (((%0) ^= (%1)), ((%1) ^= (%0)), ((%0) ^= (%1)))
  1119. #define Tryg3D_GetWeaponDamage(%0) Tryg3D::WeaponDamage[(%0)]
  1120. Tryg3D::Function:: CompRotation(rotation,&crotation=0){
  1121. crotation = rotation;
  1122. while(crotation < 0) crotation += 360;
  1123. while(crotation >= 360) crotation -= 360;
  1124. return crotation;
  1125. }
  1126. Tryg3D::Function:: Float:CompRotationFloat(Float:rotation,&Float:crotation=0.0){
  1127. crotation = rotation;
  1128. while(crotation < 0.0) crotation += 360.0;
  1129. while(crotation >= 360.0) crotation -= 360.0;
  1130. return crotation;
  1131. }
  1132. Tryg3D::Function:: DeCompRotation(rotation,&crotation=0){
  1133. crotation = rotation;
  1134. while(crotation >= 180) crotation -= 360;
  1135. while(crotation < -180) crotation += 360;
  1136. return crotation;
  1137. }
  1138. Tryg3D::Function:: Float:DeCompRotationFloat(Float:rotation,&Float:crotation=0.0){
  1139. crotation = rotation;
  1140. while(crotation >= 180.0) crotation -= 360.0;
  1141. while(crotation < -180.0) crotation += 360.0;
  1142. return crotation;
  1143. }
  1144. Tryg3D::Function:: IsRotationTest(Float:rotation,Float:r_min,Float:r_max){
  1145. rotation = CompRotationFloat(rotation);
  1146. r_min = CompRotationFloat(r_min);
  1147. r_max = CompRotationFloat(r_max);
  1148. if(r_min > r_max){
  1149. if((rotation >= 0.0 && rotation <= r_max) || (rotation >= r_min && rotation <= 360.0)) return 1;
  1150. } else {
  1151. if(rotation >= r_min && rotation <= r_max) return 1;
  1152. }
  1153. return 0;
  1154. }
  1155. Tryg3D::Function:: Tryg3D::IsPlayerSpawned(playerid){
  1156. new T3D:pstate = GetPlayerState(playerid);
  1157. if(T3D:pstate != 1 && T3D:pstate != 2 && T3D:pstate != 3) return false;
  1158. return true;
  1159. }
  1160. Tryg3D::Function:: Tryg3D::GivePlayerDamage(targetid,Float:amount,playerid,weaponid,bodypart){
  1161. if(targetid == INVALID_PLAYER_ID) return 0;
  1162. if(Tryg3D::DeatchTick[targetid] != 0 && GetTickCount() < Tryg3D::DeatchTick[targetid]) return 0;
  1163. #if defined Tryg3D_FCNPC
  1164. if(IsPlayerNPC(targetid) && FCNPC::IsValid(targetid)){
  1165. new Float:T3D:health,Float:T3D:armour;
  1166. T3D:health = FCNPC::GetHealth(targetid);
  1167. T3D:armour = FCNPC::GetArmour(targetid);
  1168. CallRemoteFunction("FCNPC_OnGiveDamage","ddddf",targetid,playerid,weaponid,bodypart,amount);
  1169. CallRemoteFunction("FCNPC_OnTakeDamage","ddddf",targetid,playerid,weaponid,bodypart,amount);
  1170. if(T3D:armour >= amount){
  1171. FCNPC::SetArmour(targetid,T3D:armour-amount);
  1172. } else if(T3D:armour < amount){
  1173. amount -= T3D:armour;
  1174. FCNPC::SetArmour(targetid,0.0);
  1175. if(T3D:health-amount <= 0.0){
  1176. CallRemoteFunction("OnPlayerDeath","ddd",targetid,playerid,weaponid);
  1177. CallRemoteFunction("FCNPC_OnDeath","ddd",targetid,playerid,weaponid);
  1178. Tryg3D::DeatchTick[targetid] = GetTickCount()+200;
  1179. FCNPC::Respawn(targetid);
  1180. } else {
  1181. FCNPC::SetHealth(targetid,T3D:health-amount);
  1182. }
  1183. } else {
  1184. if(T3D:health-amount <= 0.0){
  1185. CallRemoteFunction("OnPlayerDeath","ddd",targetid,playerid,weaponid);
  1186. CallRemoteFunction("FCNPC_OnDeath","ddd",targetid,playerid,weaponid);
  1187. Tryg3D::DeatchTick[targetid] = GetTickCount()+200;
  1188. FCNPC::Respawn(targetid);
  1189. } else {
  1190. FCNPC::SetHealth(targetid,T3D:health-amount);
  1191. }
  1192. }
  1193. } else {
  1194. #endif
  1195. new Float:T3D:health,Float:T3D:armour;
  1196. GetPlayerArmour(targetid,T3D:armour);
  1197. GetPlayerHealth(targetid,T3D:health);
  1198. CallRemoteFunction("OnPlayerGiveDamage","ddfdd",playerid,targetid,amount,weaponid,bodypart);
  1199. CallRemoteFunction("OnPlayerTakeDamage","ddfdd",targetid,playerid,amount,weaponid,bodypart);
  1200. if(T3D:armour >= amount){
  1201. SetPlayerArmour(targetid,T3D:armour-amount);
  1202. } else if(T3D:armour < amount){
  1203. amount -= T3D:armour;
  1204. SetPlayerArmour(targetid,0.0);
  1205. if(T3D:health-amount <= 0.0){
  1206. CallRemoteFunction("OnPlayerDeath","ddd",targetid,playerid,weaponid);
  1207. Tryg3D::DeatchTick[targetid] = GetTickCount()+200;
  1208. SpawnPlayer(targetid);
  1209. } else {
  1210. SetPlayerHealth(targetid,T3D:health-amount);
  1211. }
  1212. } else {
  1213. if(T3D:health-amount <= 0.0){
  1214. CallRemoteFunction("OnPlayerDeath","ddd",targetid,playerid,weaponid);
  1215. Tryg3D::DeatchTick[targetid] = GetTickCount()+200;
  1216. SpawnPlayer(targetid);
  1217. } else {
  1218. SetPlayerHealth(targetid,T3D:health-amount);
  1219. }
  1220. }
  1221. #if defined Tryg3D_FCNPC
  1222. }
  1223. #endif
  1224. return 1;
  1225. }
  1226. /************************************************************************************************************************************
  1227. * *
  1228. * Ivan_Ino VehiclePartPosition Functions *
  1229. * Code anti-collision: YES *
  1230. * *
  1231. ************************************************************************************************************************************/
  1232. Tryg3D::Function:: Tryg3D::GetPartPos(modelid,partid,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,&Float:tx,&Float:ty,&Float:tz,Float:offset_x=0.0,Float:offset_y=0.0,Float:offset_z=0.0){
  1233. new Float:ox,Float:oy,Float:oz;
  1234. switch(partid){
  1235. case VEHICLE_PART_RFTIRE: {
  1236. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_WHEELSFRONT,ox,oy,oz);
  1237. }
  1238. case VEHICLE_PART_LFTIRE: {
  1239. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_WHEELSFRONT,ox,oy,oz);
  1240. ox *= (-1);
  1241. offset_x *= (-1);
  1242. }
  1243. case VEHICLE_PART_RRTIRE: {
  1244. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_WHEELSREAR,ox,oy,oz);
  1245. }
  1246. case VEHICLE_PART_LRTIRE: {
  1247. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_WHEELSREAR,ox,oy,oz);
  1248. ox *= (-1);
  1249. offset_x *= (-1);
  1250. }
  1251. case VEHICLE_PART_HOOD: {
  1252. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_SIZE,ox,oy,oz);
  1253. oy /= 2.0;
  1254. ox = oz = 0.0;
  1255. }
  1256. case VEHICLE_PART_TRUNK: {
  1257. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_SIZE,ox,oy,oz);
  1258. oy /= (-2.0);
  1259. offset_y *= (-1);
  1260. ox = oz = 0.0;
  1261. }
  1262. case VEHICLE_PART_ROOF: {
  1263. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_SIZE,ox,oy,oz);
  1264. oz /= 2.0;
  1265. ox = oy = 0.0;
  1266. }
  1267. case VEHICLE_PART_CHASSIS: {
  1268. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_SIZE,ox,oy,oz);
  1269. oz /= (-2.0);
  1270. offset_z *= (-1);
  1271. ox = oy = 0.0;
  1272. }
  1273. case VEHICLE_PART_PETROLCAP: {
  1274. GetVehicleModelInfo(modelid,VEHICLE_MODEL_INFO_PETROLCAP,ox,oy,oz);
  1275. }
  1276. }
  1277. ox += offset_x;
  1278. oy += offset_y;
  1279. oz += offset_z;
  1280. ShiftOffsetToPosition(x,y,z, rx,ry,rz, ox,oy,oz, tx,ty,tz);
  1281. }
  1282. //Original by Ivan_Ino Updated by Abyss Morgan SRC:https://github.com/Ino42O/VehiclePartPosition/blob/master/VehiclePartPosition.inc
  1283. Tryg3D::Function:: GetVehiclePartPos(vehicleid,partid,&Float:tx,&Float:ty,&Float:tz,Float:offset_x=0.0,Float:offset_y=0.0,Float:offset_z=0.0){
  1284. new Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz;
  1285. GetVehiclePos(vehicleid,x,y,z);
  1286. Tryg3D::GetVehicleRotation(vehicleid,rx,ry,rz);
  1287. GetVehicleZAngle(vehicleid,rz);
  1288. Tryg3D::GetPartPos(GetVehicleModel(vehicleid),partid,x,y,z,rx,ry,rz,tx,ty,tz,offset_x,offset_y,offset_z);
  1289. }
  1290. #if defined Tryg3D_VehicleStreamer
  1291. //Original by Ivan_Ino Updated by Abyss Morgan SRC:https://github.com/Ino42O/DynamicVehiclePartPosition/blob/master/DynamicVehiclePartPosition.inc
  1292. Tryg3D::Function:: GetDynamicVehiclePartPos(STREAMER_TAG_VEHICLE vehicleid,partid,&Float:tx,&Float:ty,&Float:tz,Float:offset_x=0.0,Float:offset_y=0.0,Float:offset_z=0.0){
  1293. new Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz;
  1294. GetDynamicVehiclePos(vehicleid,x,y,z);
  1295. GetDynamicVehicleRotation(vehicleid,rx,ry,rz);
  1296. GetDynamicVehicleZAngle(vehicleid,rz);
  1297. Tryg3D::GetPartPos(GetDynamicVehicleModel(vehicleid),partid,x,y,z,rx,ry,rz,tx,ty,tz,offset_x,offset_y,offset_z);
  1298. }
  1299. #endif
  1300. /************************************************************************************************************************************
  1301. * *
  1302. * Nero_3D ScreenToWorld Functions *
  1303. * Updates: Crayder, Ralfie *
  1304. * *
  1305. ************************************************************************************************************************************/
  1306. static Float:cInGameX = 0.7,
  1307. Float:cInGameY = 0.525,
  1308. Float:cInGameYw = 0.4, // Widescreen
  1309. Float:cOnScreenX = 640.0,
  1310. Float:cOnScreenY = 448.0;
  1311. Tryg3D::Function:: Tryg3D::NormCrossProduct(&Float:x,&Float:y,&Float:z,Float:v1x,Float:v1y,Float:v1z,Float:v2x,Float:v2y,Float:v2z){
  1312. x = v1y * v2z - v2y * v1z;
  1313. y = v1z * v2x - v2z * v1x;
  1314. z = v1x * v2y - v2x * v1y;
  1315. v1x = VectorSize(x,y,z);
  1316. x /= v1x;
  1317. y /= v1x;
  1318. z /= v1x;
  1319. }
  1320. Tryg3D::Function:: ScreenToWorld(playerid,Float:screenX,Float:screenY,&Float:vX,&Float:vY,&Float:vZ){
  1321. if((0.0 <= screenX <= cOnScreenX) && (0.0 <= screenY <= cOnScreenY) && GetPlayerCameraFrontVector(playerid,vX,vY,vZ)){
  1322. new Float:pX = ((screenX / cOnScreenX) - 0.5) * 2.0 * cInGameX,
  1323. Float:pZ = ((screenY / cOnScreenY) - 0.5) * 2.0 * ((GetPlayerCameraAspectRatio(playerid) > 1.375) ? cInGameYw : cInGameY),
  1324. Float:nXx, Float:nYx, Float:nZx,
  1325. Float:nXz, Float:nYz, Float:nZz;
  1326. Tryg3D::NormCrossProduct(nXx,nYx,nZx,vX,vY,vZ,0.0,0.0,1.0); //front vector (x) z vector
  1327. Tryg3D::NormCrossProduct(nXz,nYz,nZz,vX,vY,vZ,nXx,nYx,nZx); //front vector (x) right vector
  1328. vX += nXx * pX + nXz * pZ;
  1329. vY += nYx * pX + nYz * pZ;
  1330. vZ += nZx * pX + nZz * pZ;
  1331. return 1;
  1332. }
  1333. return 0;
  1334. }
  1335. Tryg3D::Function:: WorldToScreen(playerid,Float:x,Float:y,Float:z,&Float:screenX,&Float:screenY){
  1336. new Float:vX, Float:vY, Float:vZ,
  1337. Float:cX, Float:cY, Float:cZ,
  1338. Float:nXx, Float:nYx, Float:nZx,
  1339. Float:nXz, Float:nYz, Float:nZz;
  1340. if(GetPlayerCameraPos(playerid,cX,cY,cZ)){
  1341. GetPlayerCameraFrontVector(playerid,vX,vY,vZ);
  1342. Tryg3D::NormCrossProduct(nXx,nYx,nZx,vX,vY,vZ,0.0,0.0,1.0);
  1343. Tryg3D::NormCrossProduct(nXz,nYz,nZz,vX,vY,vZ,nXx,nYx,nZx);
  1344. // Distance, can be both positive and negative
  1345. screenX = (vX * (x - cX) + vY * (y - cY) + vZ * (z - cZ) ) / ((vX * vX) + (vY * vY) + (vZ * vZ));
  1346. if((_: screenX & (1 << (cellbits - 1))) == 0) { // only positive values
  1347. z = (((z - cZ) / screenX) - vZ) / nZz;
  1348. x = (((x - cX) / screenX) - vX - (z * nXz)) / nXx;
  1349. screenX = ((x / (cInGameX * 2.0)) + 0.5) * cOnScreenX;
  1350. screenY = ((z / (((GetPlayerCameraAspectRatio(playerid) > 1.375) ? cInGameYw : cInGameY) * 2.0)) + 0.5) * cOnScreenY;
  1351. return ((0.0 <= screenX <= cOnScreenX) && (0.0 <= screenY <= cOnScreenY));
  1352. }
  1353. }
  1354. return 0;
  1355. }
  1356. #if defined Tryg3D_ColAndreas
  1357. Tryg3D::Function:: ScreenToWorldCol(playerid,Float:distance,Float:screenX,Float:screenY,&Float:wX,&Float:wY,&Float:wZ){
  1358. if(ScreenToWorld(playerid,screenX,screenY,wX,wY,wZ)){
  1359. new Float:cX,Float:cY,Float:cZ;
  1360. GetPlayerCameraPos(playerid,cX,cY,cZ);
  1361. wX = cX + (wX * distance);
  1362. wY = cY + (wY * distance);
  1363. wZ = cZ + (wZ * distance);
  1364. return ColAndreas::RayCastLine(cX,cY,cZ,wX,wY,wZ + 0.001,wX,wY,wZ) + 1;
  1365. }
  1366. return 0;
  1367. }
  1368. #endif
  1369. /************************************************************************************************************************************
  1370. * *
  1371. * Nero_3D Rotations Functions *
  1372. * Code anti-collision: YES *
  1373. * *
  1374. ************************************************************************************************************************************/
  1375. enum T3D:eulermode {
  1376. // Proper / Classic Euler angles
  1377. T3D:euler_xzx,
  1378. T3D:euler_xyx,
  1379. T3D:euler_yxy,
  1380. T3D:euler_yzy,
  1381. T3D:euler_zyz,
  1382. T3D:euler_zxz,
  1383. // Tait-Bryan angles
  1384. T3D:euler_xzy,
  1385. T3D:euler_xyz,
  1386. T3D:euler_yxz,
  1387. T3D:euler_yzx,
  1388. T3D:euler_zyx, // pitch roll yaw
  1389. T3D:euler_zxy // sa-mp
  1390. }
  1391. const T3D:eulermode: T3D:euler_default = T3D:euler_zxy;
  1392. //GetRotationMatrixFromEuler by Nero_3D
  1393. Tryg3D::Function:: Tryg3D::GetRotationMatrixEuler(Float:matrix[][],Float:rx,Float:ry,Float:rz,T3D:eulermode:mode=T3D:euler_default){
  1394. // could be done with matrix multiplication but would be slower
  1395. new Float:cosX = floatcos(rx,degrees),
  1396. Float:cosY = floatcos(ry,degrees),
  1397. Float:cosZ = floatcos(rz,degrees),
  1398. Float:sinX = floatsin(rx,degrees),
  1399. Float:sinY = floatsin(ry,degrees),
  1400. Float:sinZ = floatsin(rz,degrees);
  1401. switch(mode){
  1402. //Proper Euler angles - 1(rx), 2(ry), 3(rz)
  1403. case T3D:euler_xzx: {
  1404. matrix[0][0] = cosY;
  1405. matrix[0][1] = -cosZ * sinY;
  1406. matrix[0][2] = sinY * sinZ;
  1407. matrix[1][0] = cosX * sinY;
  1408. matrix[1][1] = cosX * cosY * cosZ - sinX * sinZ;
  1409. matrix[1][2] = -cosZ * sinX - cosX * cosY * sinZ;
  1410. matrix[2][0] = sinX * sinY;
  1411. matrix[2][1] = cosX * sinZ + cosY * cosZ * sinX;
  1412. matrix[2][2] = cosX * cosZ - cosY * sinX * sinZ;
  1413. }
  1414. case T3D:euler_xyx: {
  1415. matrix[0][0] = cosY;
  1416. matrix[0][1] = sinY * sinZ;
  1417. matrix[0][2] = cosZ * sinY;
  1418. matrix[1][0] = sinX * sinY;
  1419. matrix[1][1] = cosX * cosZ - cosY * sinX * sinZ;
  1420. matrix[1][2] = -cosX * sinZ - cosY * cosZ * sinX;
  1421. matrix[2][0] = -cosX * sinY;
  1422. matrix[2][1] = cosZ * sinX + cosX * cosY * sinZ;
  1423. matrix[2][2] = cosX * cosY * cosZ - sinX * sinZ;
  1424. }
  1425. case T3D:euler_yxy: {
  1426. matrix[0][0] = cosX * cosZ - cosY * sinX * sinZ;
  1427. matrix[0][1] = sinX * sinY;
  1428. matrix[0][2] = cosX * sinZ + cosY * cosZ * sinX;
  1429. matrix[1][0] = sinY * sinZ;
  1430. matrix[1][1] = cosY;
  1431. matrix[1][2] = -cosZ * sinY;
  1432. matrix[2][0] = -cosZ * sinX - cosX * cosY * sinZ;
  1433. matrix[2][1] = cosX * sinY;
  1434. matrix[2][2] = cosX * cosY * cosZ - sinX * sinZ;
  1435. }
  1436. case T3D:euler_yzy: {
  1437. matrix[0][0] = cosX * cosY * cosZ - sinX * sinZ;
  1438. matrix[0][1] = -cosX * sinY;
  1439. matrix[0][2] = cosZ * sinX + cosX * cosY * sinZ;
  1440. matrix[1][0] = cosZ * sinY;
  1441. matrix[1][1] = cosY;
  1442. matrix[1][2] = sinY * sinZ;
  1443. matrix[2][0] = -cosX * sinZ - cosY * cosZ * sinX;
  1444. matrix[2][1] = sinX * sinY;
  1445. matrix[2][2] = cosX * cosZ - cosY * sinX * sinZ;
  1446. }
  1447. case T3D:euler_zyz: {
  1448. matrix[0][0] = cosX * cosY * cosZ - sinX * sinZ;
  1449. matrix[0][1] = -cosZ * sinX - cosX * cosY * sinZ;
  1450. matrix[0][2] = cosX * sinY;
  1451. matrix[1][0] = cosX * sinZ + cosY * cosZ * sinX;
  1452. matrix[1][1] = cosX * cosZ - cosY * sinX * sinZ;
  1453. matrix[1][2] = sinX * sinY;
  1454. matrix[2][0] = -cosZ * sinY;
  1455. matrix[2][1] = sinY * sinZ;
  1456. matrix[2][2] = cosY;
  1457. }
  1458. case T3D:euler_zxz: {
  1459. matrix[0][0] = cosX * cosZ - cosY * sinX * sinZ;
  1460. matrix[0][1] = -cosX * sinZ - cosY * cosZ * sinX;
  1461. matrix[0][2] = sinX * sinY;
  1462. matrix[1][0] = cosZ * sinX + cosX * cosY * sinZ;
  1463. matrix[1][1] = cosX * cosY * cosZ - sinX * sinZ;
  1464. matrix[1][2] = -cosX * sinY;
  1465. matrix[2][0] = sinY * sinZ;
  1466. matrix[2][1] = cosZ * sinY;
  1467. matrix[2][2] = cosY;
  1468. }
  1469. //Tait-Bryan angles - X(rx), Y(ry), Z(rz)
  1470. case T3D:euler_xzy: {
  1471. matrix[0][0] = cosZ * cosY;
  1472. matrix[0][1] = -sinZ;
  1473. matrix[0][2] = cosZ * sinY;
  1474. matrix[1][0] = sinX * sinY + cosX * cosY * sinZ;
  1475. matrix[1][1] = cosX * cosZ;
  1476. matrix[1][2] = cosX * sinZ * sinY - cosY * sinX;
  1477. matrix[2][0] = cosY * sinX * sinZ - cosX * sinY;
  1478. matrix[2][1] = cosZ * sinX;
  1479. matrix[2][2] = cosX * cosY + sinX * sinZ * sinY;
  1480. }
  1481. case T3D:euler_xyz: {
  1482. matrix[0][0] = cosY * cosZ;
  1483. matrix[0][1] = -cosY * sinZ;
  1484. matrix[0][2] = sinY;
  1485. matrix[1][0] = cosX * sinZ + cosZ * sinX * sinY;
  1486. matrix[1][1] = cosX * cosZ - sinX * sinY * sinZ;
  1487. matrix[1][2] = -cosY * sinX;
  1488. matrix[2][0] = sinX * sinZ - cosX * cosZ * sinY;
  1489. matrix[2][1] = cosZ * sinX + cosX * sinY * sinZ;
  1490. matrix[2][2] = cosX * cosY;
  1491. }
  1492. case T3D:euler_yxz: {
  1493. matrix[0][0] = cosY * cosZ + sinY * sinX * sinZ;
  1494. matrix[0][1] = cosZ * sinY * sinX - cosY * sinZ;
  1495. matrix[0][2] = cosX * sinY;
  1496. matrix[1][0] = cosX * sinZ;
  1497. matrix[1][1] = cosX * cosZ;
  1498. matrix[1][2] = -sinX;
  1499. matrix[2][0] = cosY * sinX * sinZ - cosZ * sinY;
  1500. matrix[2][1] = cosY * cosZ * sinX + sinY * sinZ;
  1501. matrix[2][2] = cosY * cosX;
  1502. }
  1503. case T3D:euler_yzx: {
  1504. matrix[0][0] = cosY * cosZ;
  1505. matrix[0][1] = sinY * sinX - cosY * cosX * sinZ;
  1506. matrix[0][2] = cosX * sinY + cosY * sinZ * sinX;
  1507. matrix[1][0] = sinZ;
  1508. matrix[1][1] = cosZ * cosX;
  1509. matrix[1][2] = -cosZ * sinX;
  1510. matrix[2][0] = -cosZ * sinY;
  1511. matrix[2][1] = cosY * sinX + cosX * sinY * sinZ;
  1512. matrix[2][2] = cosY * cosX - sinY * sinZ * sinX;
  1513. }
  1514. case T3D:euler_zyx: { // pitch roll yaw
  1515. matrix[0][0] = cosZ * cosY;
  1516. matrix[0][1] = cosZ * sinY * sinX - cosX * sinZ;
  1517. matrix[0][2] = sinZ * sinX + cosZ * cosX * sinY;
  1518. matrix[1][0] = cosY * sinZ;
  1519. matrix[1][1] = cosZ * cosX + sinZ * sinY * sinX;
  1520. matrix[1][2] = cosX * sinZ * sinY - cosZ * sinX;
  1521. matrix[2][0] = -sinY;
  1522. matrix[2][1] = cosY * sinX;
  1523. matrix[2][2] = cosY * cosX;
  1524. }
  1525. case T3D:euler_zxy: { // sa-mp
  1526. matrix[0][0] = cosZ * cosY - sinZ * sinX * sinY;
  1527. matrix[0][1] = -sinZ * cosX;
  1528. matrix[0][2] = cosZ * sinY + sinZ * sinX * cosY;
  1529. matrix[1][0] = sinZ * cosY + cosZ * sinX * sinY;
  1530. matrix[1][1] = cosZ * cosX;
  1531. matrix[1][2] = sinZ * sinY - cosZ * sinX * cosY;
  1532. matrix[2][0] = -cosX * sinY;
  1533. matrix[2][1] = sinX;
  1534. matrix[2][2] = cosX * cosY;
  1535. }
  1536. }
  1537. }
  1538. //MatrixRotate by Nero_3D
  1539. Tryg3D::Function:: Tryg3D::MatrixRotate(Float:matrix[][],Float:oX,Float:oY,Float:oZ,&Float:x,&Float:y,&Float:z){
  1540. x += oX * matrix[0][0] + oY * matrix[0][1] + oZ * matrix[0][2]; // M * v | v = [oX, oY, oZ]
  1541. y += oX * matrix[1][0] + oY * matrix[1][1] + oZ * matrix[1][2];
  1542. z += oX * matrix[2][0] + oY * matrix[2][1] + oZ * matrix[2][2];
  1543. }
  1544. //GetQuatFromEuler by Nero_3D
  1545. Tryg3D::Function:: Tryg3D::GetQuatFromEuler(Float:rx,Float:ry,Float:rz,&Float:qw,&Float:qx,&Float:qy,&Float:qz,T3D:eulermode:mode=T3D:euler_default){
  1546. rx /= 2.0; // could be done with multiplication but would be slower
  1547. ry /= 2.0;
  1548. rz /= 2.0;
  1549. new Float:cosX = floatcos(rx,degrees),
  1550. Float:cosY = floatcos(ry,degrees),
  1551. Float:cosZ = floatcos(rz,degrees),
  1552. Float:sinX = floatsin(rx,degrees),
  1553. Float:sinY = floatsin(ry,degrees),
  1554. Float:sinZ = floatsin(rz,degrees);
  1555. switch(mode) {
  1556. case T3D:euler_xzx: {
  1557. qw = sinX * cosY * sinZ - cosX * cosY * cosZ;
  1558. qx = cosX * cosY * sinZ + sinX * cosY * cosZ;
  1559. qy = cosX * sinY * sinZ - sinX * sinY * cosZ;
  1560. qz = cosX * sinY * cosZ + sinX * sinY * sinZ;
  1561. }
  1562. case T3D:euler_xyx: {
  1563. qw = sinX * cosY * sinZ - cosX * cosY * cosZ;
  1564. qx = cosX * cosY * sinZ + sinX * cosY * cosZ;
  1565. qy = cosX * sinY * cosZ + sinX * sinY * sinZ;
  1566. qz = sinX * sinY * cosZ - cosX * sinY * sinZ;
  1567. }
  1568. case T3D:euler_yxy: {
  1569. qw = sinX * cosY * sinZ - cosX * cosY * cosZ;
  1570. qx = cosX * sinY * cosZ + sinX * sinY * sinZ;
  1571. qy = cosX * cosY * sinZ + sinX * cosY * cosZ;
  1572. qz = cosX * sinY * sinZ - sinX * sinY * cosZ;
  1573. }
  1574. case T3D:euler_yzy: {
  1575. qw = sinX * cosY * sinZ - cosX * cosY * cosZ;
  1576. qx = sinX * sinY * cosZ - cosX * sinY * sinZ;
  1577. qy = cosX * cosY * sinZ + sinX * cosY * cosZ;
  1578. qz = cosX * sinY * cosZ + sinX * sinY * sinZ;
  1579. }
  1580. case T3D:euler_zyz: {
  1581. qw = sinX * cosY * sinZ - cosX * cosY * cosZ;
  1582. qx = cosX * sinY * sinZ - sinX * sinY * cosZ;
  1583. qy = cosX * sinY * cosZ + sinX * sinY * sinZ;
  1584. qz = cosX * cosY * sinZ + sinX * cosY * cosZ;
  1585. }
  1586. case T3D:euler_zxz: {
  1587. qw = sinX * cosY * sinZ - cosX * cosY * cosZ;
  1588. qx = cosX * sinY * cosZ + sinX * sinY * sinZ;
  1589. qy = sinX * sinY * cosZ - cosX * sinY * sinZ;
  1590. qz = cosX * cosY * sinZ + sinX * cosY * cosZ;
  1591. }
  1592. case T3D:euler_xzy: {
  1593. qw = cosX * cosY * cosZ + sinX * sinY * sinZ;
  1594. qx = cosX * sinY * sinZ - sinX * cosY * cosZ;
  1595. qy = sinX * cosY * sinZ - cosX * sinY * cosZ;
  1596. qz = -(cosX * cosY * sinZ + sinX * sinY * cosZ);
  1597. }
  1598. case T3D:euler_xyz: {
  1599. qw = sinX * sinY * sinZ - cosX * cosY * cosZ;
  1600. qx = sinX * cosY * cosZ + cosX * sinY * sinZ;
  1601. qy = cosX * sinY * cosZ - sinX * cosY * sinZ;
  1602. qz = cosX * cosY * sinZ + sinX * sinY * cosZ;
  1603. }
  1604. case T3D:euler_yxz: {
  1605. qw = cosX * cosY * cosZ + sinX * sinY * sinZ;
  1606. qx = -(sinX * cosY * cosZ + cosX * sinY * sinZ);
  1607. qy = sinX * cosY * sinZ - cosX * sinY * cosZ;
  1608. qz = sinX * sinY * cosZ - cosX * cosY * sinZ;
  1609. }
  1610. case T3D:euler_yzx: {
  1611. qw = sinX * sinY * sinZ - cosX * cosY * cosZ;
  1612. qx = sinX * cosY * cosZ + cosX * sinY * sinZ;
  1613. qy = cosX * sinY * cosZ + sinX * cosY * sinZ;
  1614. qz = cosX * cosY * sinZ - sinX * sinY * cosZ;
  1615. }
  1616. case T3D:euler_zyx: {
  1617. qw = cosX * cosY * cosZ + sinX * sinY * sinZ;
  1618. qx = cosX * sinY * sinZ - sinX * cosY * cosZ;
  1619. qy = -(cosX * sinY * cosZ + sinX * cosY * sinZ);
  1620. qz = sinX * sinY * cosZ - cosX * cosY * sinZ;
  1621. }
  1622. case T3D:euler_zxy: {
  1623. qw = sinX * sinY * sinZ - cosX * cosY * cosZ;
  1624. qx = sinX * cosY * cosZ - cosX * sinY * sinZ;
  1625. qy = cosX * sinY * cosZ + sinX * cosY * sinZ;
  1626. qz = cosX * cosY * sinZ + sinX * sinY * cosZ;
  1627. }
  1628. }
  1629. }
  1630. //QuatRotate by Nero_3D
  1631. Tryg3D::Function:: Tryg3D::QuatRotate(Float:qw,Float:qx,Float:qy,Float:qz,Float:oX,Float:oY,Float:oZ,&Float:tx,&Float:ty,&Float:tz){
  1632. // wikipedia suggest this formula (a x b - cross prudct)
  1633. // v + 2*r x (r x v + w*v) | q = w,r
  1634. // 15 muls, 15 adds, 9 saves, 42 loads
  1635. // but I used this one because it more compact (a.b - dot product)
  1636. // 2*((r.v)*r + (0.5 - (|r.r|^2))*v + w * (r x v)) | q = w,r
  1637. // 22 muls, 12 adds, 5 saves, 38 loads
  1638. new Float:dot = qx * oX + qy * oY + qz * oZ,
  1639. Float:abs = qw * qw - 0.5;
  1640. tx += 2.0 * (dot * qx + abs * oX + qw * (qz * oY - qy * oZ));
  1641. ty += 2.0 * (dot * qy + abs * oY + qw * (qx * oZ - qz * oX));
  1642. tz += 2.0 * (dot * qz + abs * oZ + qw * (qy * oX - qx * oY));
  1643. }
  1644. //EulerRotate by Nero_3D
  1645. Tryg3D::Function:: Tryg3D::EulerRotate(Float:rx,Float:ry,Float:rz,Float:oX,Float:oY,Float:oZ,&Float:tx,&Float:ty,&Float:tz,T3D:eulermode:mode=T3D:euler_default){
  1646. Tryg3D::GetQuatFromEuler(rx,ry,rz,Float:mode,rx,ry,rz,mode);
  1647. Tryg3D::QuatRotate(Float:mode,rx,ry,rz,oX,oY,oZ,tx,ty,tz);
  1648. }
  1649. /************************************************************************************************************************************
  1650. * *
  1651. * General Functions *
  1652. * *
  1653. ************************************************************************************************************************************/
  1654. #define GetDistanceBetweenPoints1D(%1,%2) VectorSize((%1)-(%2),0.0,0.0)
  1655. #define GetDistanceBetweenPoints2D(%1,%2,%3,%4) VectorSize((%1)-(%3),(%2)-(%4),0.0)
  1656. #define GetDistanceBetweenPoints3D(%1,%2,%3,%4,%5,%6) VectorSize((%1)-(%4),(%2)-(%5),(%3)-(%6))
  1657. #define CalculatePercent(%0,%1) (((%0)/(%1))*100.0)
  1658. #define ShiftDegreeToRadian(%0) ((%0)*((FLOAT_PI*2)/360.0))
  1659. #define ShiftDegreeToRadianEx(%0) ((360.0-CompRotationFloat(%0))*(-((FLOAT_PI*2)/360.0)))
  1660. #define ShiftDegreeToGrades(%0) ((%0)*(10.0/9.0))
  1661. #define ShiftRadianToDegree(%0) ((%0)/((FLOAT_PI*2)/360.0))
  1662. #define ShiftRadianToDegreeEx(%0) (CompRotationFloat(floatabs(((%0)/((FLOAT_PI*2)/360.0))+360.0)))
  1663. #define ShiftRadianToGrades(%0) (ShiftDegreeToGrades(ShiftRadianToDegree(%0)))
  1664. #define ShiftGradesToDegree(%0) ((%0)*0.9)
  1665. #define ShiftGradesToRadian(%0) (ShiftDegreeToRadian(ShiftGradesToDegree(%0)))
  1666. #define ShiftRotationToVector(%0,%1,%2,%3,%4) (GetPointInFront3D(0.0,0.0,0.0,(%0),(%1),1.0,(%2),(%3),(%4)))
  1667. #define RecoilFloat(%0,%1) (((%0) >= 0.0)?((%0)+(%1)):((%0)-(%1)))
  1668. //old code version made by Zoutdaxv (modified version)
  1669. #define GetRotationFor2Point2D(%0,%1,%2,%3,%4) (CompRotationFloat((atan2((%3)-(%1),(%2)-(%0))-90.0),(%4)))
  1670. #define IsPointInCylinder2D(%0,%1,%2,%3,%4,%5,%6,%7) IsPointInCylinder3D((%0),(%1),(%2),(%3),(%4),(%5),(%3),(%4),(%6),(%7))
  1671. #define GetRandomPointOnCircle(%0,%1,%2,%3,%4) GetPointInFront2D((%0),(%1),Tryg3D_RandomFloat(0.0,360.0),(%2),(%3),(%4))
  1672. #define IsVehicleInRangeOfPoint(%0,%1,%2,%3,%4) (GetVehicleDistanceFromPoint((%0),(%2),(%3),(%4)) <= (%1))
  1673. #define ShiftVectorToRotation(%0,%1,%2,%3,%4) CompRotationFloat(-(acos(%2)-90.0),(%3)), CompRotationFloat((atan2((%1),(%0))-90.0),(%4))
  1674. #define IsPointInCircle(%0,%1,%2,%3,%4) (GetDistanceBetweenPoints2D((%0),(%1),(%2),(%3)) <= (%4))
  1675. #define IsPointInSphere(%0,%1,%2,%3,%4,%5,%6) (GetDistanceBetweenPoints3D((%0),(%1),(%2),(%3),(%4),(%5)) <= (%6))
  1676. #define IsPointInRectangle(%1,%2,%3,%4,%5,%6) (((%1) >= (%3) && (%1) <= (%5)) && ((%2) >= (%4) && (%2) <= (%6)))
  1677. #define IsPointInCube(%1,%2,%3,%4,%5,%6,%7,%8,%9) (((%1) >= (%4) && (%1) <= (%7)) && ((%2) >= (%5) && (%2) <= (%8)) && ((%3) >= (%6) && (%3) <= (%9)))
  1678. #define GetPlayerCameraLookAt(%0,%1,%2,%3) GetPointInFrontOfCamera3D((%0),(%1),(%2),(%3),5.0)
  1679. #define IsProbable(%0) ((random(100)+1) <= (%0))
  1680. #define GetVehicleFlags(%0) GetVehicleFlagsByModel(GetVehicleModel(%0))
  1681. #define IsVehicleFlag(%0,%1) ((%0) & (%1))
  1682. //Universal boost
  1683. #define GetObjectDistanceFromPoint(%0,%1,%2,%3) GetElementDistanceFromPoint((%0),item_object,(%1),(%2),(%3))
  1684. #define IsObjectInRangeOfPoint(%0,%1,%2,%3,%4) (GetElementDistanceFromPoint((%0),item_object,(%2),(%3),(%4)) <= (%1))
  1685. #define GetPlayerObjectDistance(%1,%2) GetElementsDistance((%1),item_player,(%1),item_object)
  1686. #define GetDistanceBetweenPlayers(%1,%2) GetElementsDistance((%1),item_player,(%2),item_player)
  1687. #define GetDistanceBetweenVehicles(%1,%2) GetElementsDistance((%1),item_vehicle,(%2),item_vehicle)
  1688. #define GetDistanceBetweenObjects(%1,%2) GetElementsDistance((%1),item_object,(%2),item_object)
  1689. #define GetPlayerVehicleDistance(%1,%2) GetElementsDistance((%1),item_player,(%2),item_object)
  1690. #define IsPlayerInCircle(%0,%1,%2,%3) IsElementInCircle((%0),item_player,(%1),(%2),(%3))
  1691. #define IsPlayerInCylinder3D(%0,%1,%2,%3,%4,%5,%6,%7) IsElementInCylinder3D((%0),item_player,(%1),(%2),(%3),(%4),(%5),(%6),(%7))
  1692. #define IsPlayerInCylinder2D(%0,%1,%2,%3,%4,%5) IsElementInCylinder2D((%0),item_player,(%1),(%2),(%3),(%4),(%5))
  1693. #define IsPlayerInSphere(%0,%1,%2,%3,%4) IsElementInSphere((%0),item_player,(%1),(%2),(%3),(%4))
  1694. #define IsPlayerInRectangle(%0,%1,%2,%3,%4) IsElementInRectangle((%0),item_player,(%1),(%2),(%3),(%4))
  1695. #define IsPlayerInCube(%0,%1,%2,%3,%4,%5,%6) IsElementInCube((%0),item_player,(%1),(%2),(%3),(%4),(%5),(%6))
  1696. #define IsPlayerInPolygon(%0,%1) IsElementInPolygon((%0),item_player,(%1))
  1697. #define IsPlayerInCircularSector(%0,%1,%2,%3,%4,%5) IsElementInCircularSector((%0),item_player,(%1),(%2),(%3),(%4),(%5))
  1698. #define IsPlayerInCone(%0,%1,%2,%3,%4,%5,%6,%7,%8) IsElementInCone((%0),item_player,(%1),(%2),(%3),(%4),(%5),(%6),(%7),(%8))
  1699. #define IsPlayerInCube3D(%0,%1,%2,%3,%4,%5,%6,%7,%8,%9) IsElementInCube3D((%0),item_player,(%1),(%2),(%3),(%4),(%5),(%6),(%7),(%8),(%9))
  1700. #define IsPlayerInEllipse(%0,%1,%2,%3,%4) IsElementInEllipse((%0),item_player,(%1),(%2),(%3),(%4))
  1701. #define IsPlayerInEllipticalCylinder2D(%0,%1,%2,%3,%4,%5,%6) IsElementInEllipticalCylinder2D((%0),item_player,(%1),(%2),(%3),(%4),(%5),(%6))
  1702. #define IsPlayerInSphericalSector(%0,%1,%2,%3,%4,%5,%6,%7,%8) IsElementInSphericalSector((%0),item_player,(%1),(%2),(%3),(%4),(%5),(%6),(%7),(%8))
  1703. #define GetArcPointsFloor3D(%0,%1,%2,%3,%4,%5,%6,%7) GetArcPoints3D((%0),(%1),(%2),(%3),(%4),(%5),0.0,(%6),(%7))
  1704. #define GetArcPointsCellar3D(%0,%1,%2,%3,%4,%5,%6,%7) GetArcPoints3D((%0),(%1),(%2),(%3),(%4),(%5),180.0,(%6),(%7))
  1705. #define GetArcPointsStarboard3D(%0,%1,%2,%3,%4,%5,%6,%7) GetArcPoints3D((%0),(%1),(%2),(%3),(%4),(%5),90.0,(%6),(%7))
  1706. #define GetArcPointsLarboard3D(%0,%1,%2,%3,%4,%5,%6,%7) GetArcPoints3D((%0),(%1),(%2),(%3),(%4),(%5),270.0,(%6),(%7))
  1707. #define GetArcPointsFloor2D(%0,%1,%2,%3,%4,%5,%6) GetArcPointsFloor3D((%0),(%1),(%2),(%3),(%4),(%2),(%5),(%6))
  1708. #define GetArcPointsCellar2D(%0,%1,%2,%3,%4,%5,%6) GetArcPointsCellar3D((%0),(%1),(%2),(%3),(%4),(%2),(%5),(%6))
  1709. #define GetArcPointsLarboard2D(%0,%1,%2,%3,%4,%5,%6) GetArcPointsLarboard3D((%0),(%1),(%2),(%3),(%4),(%2),(%5),(%6))
  1710. #define GetArcPointsStarboard2D(%0,%1,%2,%3,%4,%5,%6) GetArcPointsStarboard3D((%0),(%1),(%2),(%3),(%4),(%2),(%5),(%6))
  1711. Tryg3D::Function:: Tryg3D::EulerToQuat(Float:rx,Float:ry,Float:rz,&Float:qw,&Float:qx,&Float:qy,&Float:qz){
  1712. rx /= 2.0;
  1713. ry /= 2.0;
  1714. rz /= 2.0;
  1715. new Float:cosX = floatcos(rx,degrees),
  1716. Float:cosY = floatcos(ry,degrees),
  1717. Float:cosZ = floatcos(rz,degrees),
  1718. Float:sinX = floatsin(rx,degrees),
  1719. Float:sinY = floatsin(ry,degrees),
  1720. Float:sinZ = floatsin(rz,degrees);
  1721. qw = sinX * sinY * sinZ - cosX * cosY * cosZ;
  1722. qx = sinX * cosY * cosZ - cosX * sinY * sinZ;
  1723. qy = cosX * sinY * cosZ + sinX * cosY * sinZ;
  1724. qz = cosX * cosY * sinZ + sinX * sinY * cosZ;
  1725. }
  1726. Tryg3D::Function:: Tryg3D::QuatToEuler(&Float:rx,&Float:ry,&Float:rz,Float:qw,Float:qx,Float:qy,Float:qz){
  1727. CompRotationFloat(asin(2*qy*qz-2*qx*qw),rx);
  1728. CompRotationFloat(-atan2(qx*qz+qy*qw,0.5-qx*qx-qy*qy),ry);
  1729. CompRotationFloat(-atan2(qx*qy+qz*qw,0.5-qx*qx-qz*qz),rz);
  1730. }
  1731. //GetVehicleRotation Created by IllidanS4
  1732. Tryg3D::Function:: Tryg3D::GetVehicleRotation(vehicleid,&Float:rx,&Float:ry,&Float:rz){
  1733. new Float:qw,Float:qx,Float:qy,Float:qz;
  1734. GetVehicleRotationQuat(vehicleid,qw,qx,qy,qz);
  1735. Tryg3D::QuatToEuler(rx,ry,rz,qw,qx,qy,qz);
  1736. }
  1737. #if !defined Tryg3D_i_quat
  1738. #define GetVehicleRotation Tryg3D_GetVehicleRotation
  1739. #endif
  1740. Tryg3D::Function:: Float:GetEllipseRadius(Float:x,Float:y,Float:angle){
  1741. if(x <= 0.0) return -1.0;
  1742. new Float:theta = atan((y/x)*floattan(CompRotationFloat(angle),degrees));
  1743. return floatsqroot((floatpower(x,2.0)*floatpower(floatsin(theta,degrees),2.0))+(floatpower(y,2.0)*floatpower(floatcos(theta,degrees),2.0)));
  1744. }
  1745. Tryg3D::Function:: Float:GetLineSize2D(Float:points[][],maxpoints=sizeof(points)){
  1746. if(maxpoints < 2) return 0.0;
  1747. new Float:T3D:distance = 0.0;
  1748. for(new i = 1; i < maxpoints; i++){
  1749. T3D:distance += GetDistanceBetweenPoints2D(points[i-1][0],points[i-1][1],points[i][0],points[i][1]);
  1750. }
  1751. return T3D:distance;
  1752. }
  1753. Tryg3D::Function:: Float:GetLineSize3D(Float:points[][],maxpoints=sizeof(points)){
  1754. if(maxpoints < 2) return 0.0;
  1755. new Float:T3D:distance = 0.0;
  1756. for(new i = 1; i < maxpoints; i++){
  1757. T3D:distance += GetDistanceBetweenPoints3D(points[i-1][0],points[i-1][1],points[i-1][2],points[i][0],points[i][1],points[i][2]);
  1758. }
  1759. return T3D:distance;
  1760. }
  1761. Tryg3D::Function:: RecoilVector(&Float:vx,&Float:vy,&Float:vz,Float:sx,Float:sy,Float:sz){
  1762. vx = RecoilFloat(vx,sx), vy = RecoilFloat(vy,sy), vz = RecoilFloat(vz,sz);
  1763. }
  1764. Tryg3D::Function:: SetPlayerLookAtPlayer(playerid,targetid,cut = CAMERA_CUT){
  1765. new Float:x,Float:y,Float:z;
  1766. GetPlayerPos(targetid,x,y,z);
  1767. SetPlayerCameraLookAt(playerid,x,y,z,cut);
  1768. }
  1769. Tryg3D::Function:: GetVehicleDefaultFlagsByModel(modelid){
  1770. new flag_value = 0;
  1771. switch(modelid){
  1772. case 425,548,417,487,497,563,469,447,488: flag_value += VF_AIRBORNE + VF_HELICOPTER;
  1773. case 460,476,511,512,520,593,592,553,519,513,577: flag_value += VF_AIRBORNE + VF_AIRPLANE;
  1774. case 539: flag_value += VF_AIRBORNE;
  1775. }
  1776. switch(modelid){
  1777. case 425,520,432: flag_value += VF_MILITARY;
  1778. }
  1779. switch(modelid){
  1780. case 472,473,493,595,484,430,453,452,446,454,539,447,460: flag_value += VF_NATATORIAL;
  1781. }
  1782. switch(modelid){
  1783. case 441,464,465,501,564,594: flag_value += VF_RC;
  1784. }
  1785. switch(modelid){
  1786. case 471,468,586,463,523,521,461,522,581,448,462,510,481,509: flag_value += VF_BIKES;
  1787. }
  1788. switch(modelid){
  1789. case 435,450,584,590,591,606,607,608,610,611: flag_value += VF_TRAILER;
  1790. }
  1791. switch(modelid){
  1792. case 449,537,538: flag_value += VF_TRAIN;
  1793. }
  1794. switch(modelid){
  1795. case 569,570,590: flag_value += VF_CARRIAGE;
  1796. }
  1797. if(modelid == 539 || ((flag_value & VF_NATATORIAL != VF_NATATORIAL) && (flag_value & VF_AIRBORNE != VF_AIRBORNE))) flag_value += VF_STREET;
  1798. switch(modelid){
  1799. case 437,544,431,407,408,570,569,538,537,449,532,524,403,514,515,443,435,433,432,406: { }
  1800. default: {
  1801. if(flag_value&VF_NATATORIAL!=VF_NATATORIAL && flag_value&VF_AIRBORNE!=VF_AIRBORNE && flag_value&VF_RC!=VF_RC && flag_value&VF_BIKES!=VF_BIKES){
  1802. flag_value += VF_TOWABLE;
  1803. }
  1804. }
  1805. }
  1806. switch(modelid){
  1807. case 416,523,427,490,407,544,596,598,597,599: flag_value += VF_POLICE;
  1808. }
  1809. return flag_value;
  1810. }
  1811. Tryg3D::Function:: GetVehicleFlagsByModel(modelid){
  1812. if(!(400 <= modelid <= 611)) return 0;
  1813. return Tryg3D::VehicleFlags[modelid - 400];
  1814. }
  1815. Tryg3D::Function:: SetVehicleFlagsByModel(modelid,value){
  1816. if(!(400 <= modelid <= 611)) return 0;
  1817. Tryg3D::VehicleFlags[modelid - 400] = value;
  1818. return 1;
  1819. }
  1820. Tryg3D::Function:: ToggleVehicleModelFlag(modelid,flag,bool:toggle){
  1821. if(!(400 <= modelid <= 611)) return 0;
  1822. if(toggle){
  1823. Tryg3D::VehicleFlags[modelid - 400] |= flag;
  1824. } else {
  1825. Tryg3D::VehicleFlags[modelid - 400] &= ~flag;
  1826. }
  1827. return 1;
  1828. }
  1829. Tryg3D::Function:: CountPlayers(bool:isplayer=true,bool:isnpc=true){
  1830. new T3D:count = 0;
  1831. Tryg3D::Foreach(i){
  1832. if(IsPlayerNPC(i)){
  1833. if(isnpc) T3D:count++;
  1834. } else {
  1835. if(isplayer) T3D:count++;
  1836. }
  1837. }
  1838. return T3D:count;
  1839. }
  1840. Tryg3D::Function:: CountVisiblePlayers(playerid,bool:isplayer=true,bool:isnpc=true){
  1841. new T3D:count = 0;
  1842. Tryg3D::Foreach(i){
  1843. if(i != playerid && IsPlayerStreamedIn(i,playerid)){
  1844. if(IsPlayerNPC(i)){
  1845. if(isnpc) T3D:count++;
  1846. } else {
  1847. if(isplayer) T3D:count++;
  1848. }
  1849. }
  1850. }
  1851. return T3D:count;
  1852. }
  1853. Tryg3D::Function:: CountVisibleVehicles(playerid){
  1854. new T3D:count = 0;
  1855. for(new i = 0, j = GetVehiclePoolSize(); i <= j; i++){
  1856. if(IsValidVehicle(i) && IsVehicleStreamedIn(i,playerid)){
  1857. T3D:count++;
  1858. }
  1859. }
  1860. return T3D:count;
  1861. }
  1862. Tryg3D::Function:: GetRandomHit(Float:x,Float:y,Float:z,range,&Float:tx,&Float:ty,&Float:tz){
  1863. tx = x + (random(range * 2 + 1) - range);
  1864. ty = y + (random(range * 2 + 1) - range);
  1865. tz = z + (random(range * 2 + 1) - range);
  1866. }
  1867. //Old code version, Updated by Nero_3D
  1868. Tryg3D::Function:: GetPointInFront2D(Float:x,Float:y,Float:rz,Float:radius,&Float:tx,&Float:ty){
  1869. tx = x - (radius * floatsin(rz,degrees));
  1870. ty = y + (radius * floatcos(rz,degrees));
  1871. }
  1872. Tryg3D::Function:: GetRotationFor2Point3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:rx,&Float:rz){
  1873. new Float:radius = GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz);
  1874. if(radius <= 0.0) return 0;
  1875. CompRotationFloat(-(acos((tz-z)/radius)-90.0),rx);
  1876. CompRotationFloat((atan2(ty-y,tx-x)-90.0),rz);
  1877. return 1;
  1878. }
  1879. //new code version support 3D made by Abyss Morgan, Update by Nero_3D
  1880. Tryg3D::Function:: GetPointInFront3D(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  1881. tx = x - (radius * floatcos(rx,degrees) * floatsin(rz,degrees));
  1882. ty = y + (radius * floatcos(rx,degrees) * floatcos(rz,degrees));
  1883. tz = z + (radius * floatsin(rx,degrees));
  1884. }
  1885. Tryg3D::Function:: GetPointInFront3DEx(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  1886. new Float:vx,Float:vy,Float:vz,Float:trx,Float:trz;
  1887. Tryg3D::EulerRotate(rx,ry,rz,0.0,1.0,0.0,vx,vy,vz,T3D:euler_zyx);
  1888. GetRotationFor2Point3D(0.0,0.0,0.0,vx,vy,vz,trx,trz);
  1889. GetPointInFront3D(x,y,z,trx,trz,radius,tx,ty,tz);
  1890. }
  1891. Tryg3D::Function:: Float:GetPointInFrontOfPlayer(playerid,&Float:tx,&Float:ty,Float:radius){
  1892. new Float:rz;
  1893. GetPlayerPos(playerid,tx,ty,rz);
  1894. if(IsPlayerInAnyVehicle(playerid)){
  1895. GetVehicleZAngle(GetPlayerVehicleID(playerid),rz);
  1896. } else {
  1897. GetPlayerFacingAngle(playerid,rz);
  1898. }
  1899. GetPointInFront2D(tx,ty,rz,radius,tx,ty);
  1900. return rz;
  1901. }
  1902. Tryg3D::Function:: GetPlayerCameraRotation(playerid,&Float:rx,&Float:rz){
  1903. new Float:mx,Float:my,Float:mz;
  1904. GetPlayerCameraFrontVector(playerid,mx,my,mz);
  1905. CompRotationFloat(-(acos(mz)-90.0),rx);
  1906. CompRotationFloat((atan2(my,mx)-90.0),rz);
  1907. }
  1908. Tryg3D::Function:: SetPlayerCameraRotation(playerid,Float:rx,Float:rz){
  1909. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz;
  1910. GetPlayerCameraPos(playerid,x,y,z);
  1911. GetPointInFront3D(x,y,z,rx,rz,1.0,tx,ty,tz);
  1912. SetPlayerCameraLookAt(playerid,tx,ty,tz);
  1913. }
  1914. Tryg3D::Function:: Float:GetPlayerCameraZAngle(playerid,&Float:rz=0.0){
  1915. new Float:mx,Float:my,Float:mz;
  1916. GetPlayerCameraFrontVector(playerid,mx,my,mz);
  1917. CompRotationFloat((atan2(my,mx)-90.0),rz);
  1918. return rz;
  1919. }
  1920. Tryg3D::Function:: SetPlayerCameraZAngle(playerid,Float:rz){
  1921. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:rx,Float:T3D:tmp;
  1922. GetPlayerCameraPos(playerid,x,y,z);
  1923. GetPlayerCameraRotation(playerid,rx,T3D:tmp);
  1924. GetPointInFront3D(x,y,z,rx,rz,1.0,tx,ty,tz);
  1925. SetPlayerCameraLookAt(playerid,tx,ty,tz);
  1926. }
  1927. Tryg3D::Function:: Float:GetPointInFrontOfCamera2D(playerid,&Float:tx,&Float:ty,Float:radius){
  1928. new Float:x,Float:y,Float:rz;
  1929. GetPlayerCameraPos(playerid,x,y,rz);
  1930. GetPlayerCameraZAngle(playerid,rz);
  1931. GetPointInFront2D(x,y,rz,radius,tx,ty);
  1932. return rz;
  1933. }
  1934. Tryg3D::Function:: GetMoveTime(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:speed,&rtime=0){
  1935. if(speed <= 0.0){
  1936. rtime = INVALID_MOVE_TIME;
  1937. } else {
  1938. rtime = floatround((GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz)/speed)*1000.0);
  1939. }
  1940. return rtime;
  1941. }
  1942. Tryg3D::Function:: Float:GetVehicleSpeed(vehicleid){
  1943. new Float:x,Float:y,Float:z;
  1944. GetVehicleVelocity(vehicleid,x,y,z);
  1945. return floatmul(VectorSize(x,y,z),VEHICLE_SPEED_MULTIPLIER);
  1946. }
  1947. Tryg3D::Function:: SetVehicleSpeed(vehicleid,Float:speed){
  1948. new Float:rx,Float:ry,Float:rz,Float:vx,Float:vy,Float:vz;
  1949. Tryg3D::GetVehicleRotation(vehicleid,rx,ry,rz);
  1950. GetPointInFront3DEx(0.0,0.0,0.0,rx,ry,rz,(speed / VEHICLE_SPEED_MULTIPLIER),vx,vy,vz);
  1951. SetVehicleVelocity(vehicleid,vx,vy,vz);
  1952. }
  1953. Tryg3D::Function:: Float:GetPlayerSpeed(playerid){
  1954. new Float:x,Float:y,Float:z;
  1955. GetPlayerVelocity(playerid,x,y,z);
  1956. return floatmul(VectorSize(x,y,z),PLAYER_SPEED_MULTIPLIER);
  1957. }
  1958. Tryg3D::Function:: GetSpeedForMoveTime(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:speed,rtime){
  1959. if(rtime/1000.0 <= 0.0){
  1960. speed = INVALID_MOVE_SPEED;
  1961. } else {
  1962. speed = (GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz)/(rtime/1000.0));
  1963. }
  1964. }
  1965. Tryg3D::Function:: ShiftVectorRotation(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,&Float:tx,&Float:ty,&Float:tz){
  1966. //Normalizing, but isn`t needed for the matrix rotation
  1967. new Float:dist = VectorSize(x,y,z);
  1968. if(dist <= 0.0){
  1969. tx = x, ty = y, tz = z;
  1970. return 0;
  1971. }
  1972. x /= dist, y /= dist, z /= dist;
  1973. //Get rotation matrix from degrees
  1974. new Float:T3D:matrix[3][3];
  1975. Tryg3D::GetRotationMatrixEuler(T3D:matrix,rx,ry,rz);
  1976. Tryg3D::MatrixRotate(T3D:matrix,x,y,z,tx,ty,tz);
  1977. return 1;
  1978. }
  1979. Tryg3D::Function:: ShiftOffsetToPosition(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:offset_x,Float:offset_y,Float:offset_z,&Float:tx,&Float:ty,&Float:tz){
  1980. new Float:px,Float:py,Float:pz;
  1981. if(!ShiftVectorRotation(offset_x,offset_y,offset_z,rx,ry,rz,px,py,pz)){
  1982. tx = x, ty = y, tz = z;
  1983. } else {
  1984. GetRotationFor2Point3D(0.0,0.0,0.0,px,py,pz,rx,rz);
  1985. GetPointInFront3D(x,y,z,rx,rz,VectorSize(offset_x,offset_y,offset_z),tx,ty,tz);
  1986. }
  1987. }
  1988. Tryg3D::Function:: ShiftPositionToOffset(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,&Float:offset_x,&Float:offset_y,&Float:offset_z,Float:tx,Float:ty,Float:tz){
  1989. new Float:px,Float:py,Float:pz,Float:trx,Float:trz,Float:dist = GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz);
  1990. if(!GetRotationFor2Point3D(x,y,z,tx,ty,tz,trx,trz)){
  1991. offset_x = x, offset_y = y, offset_z = z;
  1992. } else {
  1993. new Float:ex,Float:ey,Float:ez;
  1994. GetPointInFront3D(0.0,0.0,0.0,trx,trz,1.0,px,py,pz);
  1995. ShiftVectorRotation(px,py,pz,CompRotationFloat(-rx),CompRotationFloat(-ry),CompRotationFloat(-rz),ex,ey,ez);
  1996. GetPointFor2Point3DEx(0.0,0.0,0.0,ex,ey,ez,dist,offset_x,offset_y,offset_z);
  1997. }
  1998. }
  1999. //QuatUpVector by Nero_3D
  2000. Tryg3D::Function:: GetQuatUpVector(Float:qw,Float:qx,Float:qy,Float:qz,&Float:vx,&Float:vy,&Float:vz){
  2001. vx = 2.0*(qy*qw+qz*qx);
  2002. vy = 2.0*(qz*qy-qx*qw);
  2003. vz = 1.0-(2.0*(qx*qx+qy*qy));
  2004. }
  2005. Tryg3D::Function:: GetArcPoints3D(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:ry,Float:height,Float:points[][],max_points = sizeof(points)){
  2006. if(max_points < 3) return 0;
  2007. if(height <= 0.0) return 0;
  2008. new Float:rx,Float:rz;
  2009. if(!GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz)) return 0;
  2010. CompRotationFloat(ry,ry);
  2011. new Float:px, Float:py, Float:pz,
  2012. Float:cx, Float:cy, Float:cz,
  2013. Float:center_dist = (GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz)/2.0),
  2014. Float:mercury = (180.0/max_points),
  2015. Float:omega,
  2016. idx = 0;
  2017. GetPointInFront3D(x,y,z,rx,rz,center_dist,cx,cy,cz);
  2018. for(new i = max_points-1; i >= 0; i--){
  2019. CompRotationFloat(180.0-(mercury*idx),omega);
  2020. GetPointInFront3D(0.0,0.0,0.0,omega,0.0,GetEllipseRadius(height,center_dist,omega),px,py,pz);
  2021. ShiftOffsetToPosition(cx,cy,cz,rx,ry,rz,px,py,pz,points[idx][0],points[idx][1],points[idx][2]);
  2022. idx++;
  2023. }
  2024. return 1;
  2025. }
  2026. Tryg3D::Function:: GetPointToPointVector(Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,&Float:vx,&Float:vy,&Float:vz){
  2027. new Float:rx,Float:rz;
  2028. if(GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz)){
  2029. ShiftRotationToVector(rx,rz,vx,vy,vz);
  2030. return 1;
  2031. } else {
  2032. vx = vy = vz = 0.0;
  2033. return 0;
  2034. }
  2035. }
  2036. Tryg3D::Function:: Float:GetPlayerTargetAngle(playerid,Float:x,Float:y,&Float:rz=0.0){
  2037. new Float:mx,Float:my;
  2038. GetPlayerPos(playerid,mx,my,rz);
  2039. GetRotationFor2Point2D(mx,my,x,y,rz);
  2040. return rz;
  2041. }
  2042. Tryg3D::Function:: Float:SetPlayerTargetAngle(playerid,Float:x,Float:y,&Float:rz=0.0){
  2043. new Float:mx,Float:my;
  2044. GetPlayerPos(playerid,mx,my,rz);
  2045. GetRotationFor2Point2D(mx,my,x,y,rz);
  2046. SetPlayerFacingAngle(playerid,rz);
  2047. return rz;
  2048. }
  2049. Tryg3D::Function:: Float:GetPlayerTargetPlayerAngle(playerid,targetid,&Float:rz=0.0){
  2050. new Float:mx,Float:my,Float:x,Float:y;
  2051. GetPlayerPos(playerid,mx,my,rz);
  2052. GetPlayerPos(targetid,x,y,rz);
  2053. GetRotationFor2Point2D(mx,my,x,y,rz);
  2054. return rz;
  2055. }
  2056. Tryg3D::Function:: Float:SetPlayerTargetPlayerAngle(playerid,targetid,&Float:rz=0.0){
  2057. new Float:mx,Float:my,Float:x,Float:y;
  2058. GetPlayerPos(playerid,mx,my,rz);
  2059. GetPlayerPos(targetid,x,y,rz);
  2060. GetRotationFor2Point2D(mx,my,x,y,rz);
  2061. SetPlayerFacingAngle(playerid,rz);
  2062. return rz;
  2063. }
  2064. Tryg3D::Function:: CreateDynamicExplosion(Float:x,Float:y,Float:z,type,Float:radius,worldid = -1,interiorid = -1,playerid = -1,Float:distance = 200.0){
  2065. if(playerid == -1){
  2066. Tryg3D::Foreach(i){
  2067. new Float:px, Float:py, Float:pz;
  2068. if(IsPlayerInAnyVehicle(i)){
  2069. GetVehiclePos(GetPlayerVehicleID(i),px,py,pz);
  2070. } else {
  2071. GetPlayerPos(i,px,py,pz);
  2072. }
  2073. if((GetPlayerInterior(i) == interiorid || interiorid == -1) && (GetPlayerVirtualWorld(i) == worldid || worldid == -1) && (VectorSize(px-x,py-y,pz-z) <= distance)){
  2074. CreateExplosionForPlayer(i,x,y,z,type,radius);
  2075. }
  2076. }
  2077. } else {
  2078. if(IsPlayerConnected(playerid)){
  2079. new Float:px, Float:py, Float:pz;
  2080. if(IsPlayerInAnyVehicle(playerid)){
  2081. GetVehiclePos(GetPlayerVehicleID(playerid),px,py,pz);
  2082. } else {
  2083. GetPlayerPos(playerid,px,py,pz);
  2084. }
  2085. if((GetPlayerInterior(playerid) == interiorid || interiorid == -1) && (GetPlayerVirtualWorld(playerid) == worldid || worldid == -1) && (VectorSize(px-x,py-y,pz-z) <= distance)){
  2086. CreateExplosionForPlayer(playerid,x,y,z,type,radius);
  2087. }
  2088. }
  2089. }
  2090. }
  2091. Tryg3D::Function:: CreateDynamicExplosionDMG(Float:x,Float:y,Float:z,type,Float:radius,worldid = -1,interiorid = -1,playerid = -1,Float:distance = 200.0,Float:damage=82.5,Float:vehicle_damage=82.5,byplayerid=INVALID_PLAYER_ID){
  2092. new Float:T3D:health,Float:T3D:armour,T3D:vid;
  2093. if(playerid == -1){
  2094. Tryg3D::Foreach(i){
  2095. new Float:px, Float:py, Float:pz;
  2096. if(IsPlayerInAnyVehicle(i)){
  2097. GetVehiclePos(GetPlayerVehicleID(i),px,py,pz);
  2098. } else {
  2099. GetPlayerPos(i,px,py,pz);
  2100. }
  2101. if((GetPlayerInterior(i) == interiorid || interiorid == -1) && (GetPlayerVirtualWorld(i) == worldid || worldid == -1) && (VectorSize(px-x,py-y,pz-z) <= distance)){
  2102. if(IsPlayerInRangeOfPoint(i,radius,x,y,z)){
  2103. if(IsPlayerInAnyVehicle(i)){
  2104. T3D:vid = GetPlayerVehicleID(i);
  2105. GetVehicleHealth(T3D:vid,T3D:health);
  2106. CreateExplosionForPlayer(i,x,y,z,type,radius);
  2107. if(i != byplayerid) SetVehicleHealth(T3D:vid,NLTZF(T3D:health-vehicle_damage));
  2108. } else {
  2109. GetPlayerHealth(i,T3D:health);
  2110. GetPlayerArmour(i,T3D:armour);
  2111. SetPlayerHealth(i,765.0); //anti death in explosion
  2112. CreateExplosionForPlayer(i,x,y,z,type,radius);
  2113. SetPlayerHealth(i,T3D:health);
  2114. SetPlayerArmour(i,T3D:armour);
  2115. if(i != byplayerid) Tryg3D::GivePlayerDamage(i,damage,byplayerid,51,3);
  2116. }
  2117. } else {
  2118. CreateExplosionForPlayer(i,x,y,z,type,radius);
  2119. }
  2120. }
  2121. }
  2122. } else {
  2123. if(IsPlayerConnected(playerid)){
  2124. new Float:px, Float:py, Float:pz;
  2125. if(IsPlayerInAnyVehicle(playerid)){
  2126. GetVehiclePos(GetPlayerVehicleID(playerid),px,py,pz);
  2127. } else {
  2128. GetPlayerPos(playerid,px,py,pz);
  2129. }
  2130. if((GetPlayerInterior(playerid) == interiorid || interiorid == -1) && (GetPlayerVirtualWorld(playerid) == worldid || worldid == -1) && (VectorSize(px-x,py-y,pz-z) <= distance)){
  2131. if(IsPlayerInRangeOfPoint(playerid,radius,x,y,z)){
  2132. if(IsPlayerInAnyVehicle(playerid)){
  2133. T3D:vid = GetPlayerVehicleID(playerid);
  2134. GetVehicleHealth(T3D:vid,T3D:health);
  2135. CreateExplosionForPlayer(playerid,x,y,z,type,radius);
  2136. if(playerid != byplayerid) SetVehicleHealth(T3D:vid,NLTZF(T3D:health-vehicle_damage));
  2137. } else {
  2138. GetPlayerHealth(playerid,T3D:health);
  2139. GetPlayerArmour(playerid,T3D:armour);
  2140. SetPlayerHealth(playerid,765.0); //anti death in explosion
  2141. CreateExplosionForPlayer(playerid,x,y,z,type,radius);
  2142. SetPlayerHealth(playerid,T3D:health);
  2143. SetPlayerArmour(playerid,T3D:armour);
  2144. if(playerid != byplayerid) Tryg3D::GivePlayerDamage(playerid,damage,byplayerid,51,3);
  2145. }
  2146. } else {
  2147. CreateExplosionForPlayer(playerid,x,y,z,type,radius);
  2148. }
  2149. }
  2150. }
  2151. }
  2152. }
  2153. Tryg3D::Function:: SendFakeDamageInRadius(weaponid,bodypart,Float:damage,Float:vehicle_damage,Float:x,Float:y,Float:z,Float:radius,worldid = -1,interiorid = -1,playerid = -1,byplayerid=INVALID_PLAYER_ID){
  2154. new Float:T3D:health,T3D:vid;
  2155. if(playerid == -1){
  2156. Tryg3D::Foreach(i){
  2157. new Float:px, Float:py, Float:pz;
  2158. if(IsPlayerInAnyVehicle(i)){
  2159. GetVehiclePos(GetPlayerVehicleID(i),px,py,pz);
  2160. } else {
  2161. GetPlayerPos(i,px,py,pz);
  2162. }
  2163. if((GetPlayerInterior(i) == interiorid || interiorid == -1) && (GetPlayerVirtualWorld(i) == worldid || worldid == -1) && (VectorSize(px-x,py-y,pz-z) <= radius)){
  2164. if(IsPlayerInAnyVehicle(i)){
  2165. T3D:vid = GetPlayerVehicleID(i);
  2166. GetVehicleHealth(T3D:vid,T3D:health);
  2167. if(i != byplayerid) SetVehicleHealth(T3D:vid,NLTZF(T3D:health-vehicle_damage));
  2168. } else {
  2169. if(i != byplayerid) Tryg3D::GivePlayerDamage(i,damage,byplayerid,weaponid,bodypart);
  2170. }
  2171. }
  2172. }
  2173. } else {
  2174. if(IsPlayerConnected(playerid)){
  2175. new Float:px, Float:py, Float:pz;
  2176. if(IsPlayerInAnyVehicle(playerid)){
  2177. GetVehiclePos(GetPlayerVehicleID(playerid),px,py,pz);
  2178. } else {
  2179. GetPlayerPos(playerid,px,py,pz);
  2180. }
  2181. if((GetPlayerInterior(playerid) == interiorid || interiorid == -1) && (GetPlayerVirtualWorld(playerid) == worldid || worldid == -1) && (VectorSize(px-x,py-y,pz-z) <= radius)){
  2182. if(IsPlayerInAnyVehicle(playerid)){
  2183. T3D:vid = GetPlayerVehicleID(playerid);
  2184. GetVehicleHealth(T3D:vid,T3D:health);
  2185. if(playerid != byplayerid) SetVehicleHealth(T3D:vid,NLTZF(T3D:health-vehicle_damage));
  2186. } else {
  2187. if(playerid != byplayerid) Tryg3D::GivePlayerDamage(playerid,damage,byplayerid,weaponid,bodypart);
  2188. }
  2189. }
  2190. }
  2191. }
  2192. }
  2193. Tryg3D::Function:: GetWeaponShotPos(playerid,hittype,&Float:fx,&Float:fy,&Float:fz){
  2194. new Float:ox,Float:oy,Float:oz;
  2195. switch(hittype){
  2196. case BULLET_HIT_TYPE_VEHICLE, BULLET_HIT_TYPE_OBJECT, BULLET_HIT_TYPE_PLAYER_OBJECT, BULLET_HIT_TYPE_PLAYER: {
  2197. GetPlayerLastShotVectors(playerid,ox,oy,oz,fx,fy,fz);
  2198. }
  2199. }
  2200. }
  2201. //Original code by Crayder
  2202. Tryg3D::Function:: ShiftLineRotation(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,Float:rx,Float:ry,Float:rz,&Float:nX,&Float:nY,&Float:nZ){
  2203. //Get difference
  2204. eX -= sX, eY -= sY, eZ -= sZ;
  2205. //Get rotation matrix from degrees
  2206. new Float:T3D:matrix[3][3];
  2207. Tryg3D::GetRotationMatrixEuler(T3D:matrix,rx,ry,rz);
  2208. Tryg3D::MatrixRotate(T3D:matrix,eX,eY,eZ,nX,nY,nZ);
  2209. }
  2210. //Original code by Crayder
  2211. Tryg3D::Function:: ShiftLineRotationVector(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,Float:rx,Float:ry,Float:rz,&Float:nX,&Float:nY,&Float:nZ){
  2212. //Get difference
  2213. eX -= sX, eY -= sY, eZ -= sZ;
  2214. //Normalizing, but isn`t needed for the matrix rotation
  2215. new Float:dist = VectorSize(eX,eY,eZ);
  2216. if(dist <= 0.0){
  2217. nX = eX, nY = eY, nZ = eZ;
  2218. return 0;
  2219. }
  2220. eX /= dist, eY /= dist, eZ /= dist;
  2221. //Get rotation matrix from degrees
  2222. new Float:T3D:matrix[3][3];
  2223. Tryg3D::GetRotationMatrixEuler(T3D:matrix,rx,ry,rz);
  2224. Tryg3D::MatrixRotate(T3D:matrix,eX,eY,eZ,nX,nY,nZ);
  2225. return 1;
  2226. }
  2227. Tryg3D::Function:: GetCube3DPoint(OrientationCube3D:orientation,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z,&Float:tx,&Float:ty,&Float:tz){
  2228. ShiftOffsetToPosition(x,y,z,rx,ry,rz,(Cube3DOffset[orientation][0]*size_x),(Cube3DOffset[orientation][1]*size_y),(Cube3DOffset[orientation][2]*size_z),tx,ty,tz);
  2229. }
  2230. Tryg3D::Function:: Float:GetPointInFrontOfVehicle2D(vehicleid,&Float:tx,&Float:ty,Float:radius){
  2231. new Float:rz,Float:x,Float:y;
  2232. GetVehiclePos(vehicleid,x,y,rz);
  2233. GetVehicleZAngle(vehicleid,rz);
  2234. GetPointInFront2D(x,y,rz,radius,tx,ty);
  2235. return rz;
  2236. }
  2237. Tryg3D::Function:: GetPointInFrontOfVehicle3D(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0){
  2238. new Float:ry,Float:x,Float:y,Float:z;
  2239. GetVehiclePos(vehicleid,x,y,z);
  2240. Tryg3D::GetVehicleRotation(vehicleid,rx,ry,rz);
  2241. GetPointInFront3D(x,y,z,rx,rz,radius,tx,ty,tz);
  2242. }
  2243. Tryg3D::Function:: GetPointInFrontOfCamera3D(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0){
  2244. new Float:x,Float:y,Float:z;
  2245. GetPlayerCameraPos(playerid,x,y,z);
  2246. GetPlayerCameraRotation(playerid,rx,rz);
  2247. GetPointInFront3D(x,y,z,rx,rz,radius,tx,ty,tz);
  2248. }
  2249. Tryg3D::Function:: IsPlayerLookAtSky(playerid){
  2250. new Float:rx,Float:rz;
  2251. GetPlayerCameraRotation(playerid,rx,rz);
  2252. return (rx > 0.0 && rx <= 90.0);
  2253. }
  2254. Tryg3D::Function:: GetPointFor2Point2D(Float:x1,Float:y1,Float:x2,Float:y2,Float:percent_size,&Float:tx,&Float:ty){
  2255. new Float:rz;
  2256. GetRotationFor2Point2D(x1,y1,x2,y2,rz);
  2257. GetPointInFront2D(x1,y1,rz,(GetDistanceBetweenPoints2D(x1,y1,x2,y2)*(percent_size/100.0)),tx,ty);
  2258. }
  2259. Tryg3D::Function:: GetPointFor2Point3D(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2,Float:percent_size,&Float:tx,&Float:ty,&Float:tz){
  2260. new Float:rx,Float:rz;
  2261. GetRotationFor2Point3D(x1,y1,z1,x2,y2,z2,rx,rz);
  2262. GetPointInFront3D(x1,y1,z1,rx,rz,(GetDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2)*(percent_size/100.0)),tx,ty,tz);
  2263. }
  2264. Tryg3D::Function:: GetPointFor2Point2DEx(Float:x1,Float:y1,Float:x2,Float:y2,Float:distance,&Float:tx,&Float:ty){
  2265. new Float:rz;
  2266. GetRotationFor2Point2D(x1,y1,x2,y2,rz);
  2267. GetPointInFront2D(x1,y1,rz,distance,tx,ty);
  2268. }
  2269. Tryg3D::Function:: GetPointFor2Point3DEx(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2,Float:distance,&Float:tx,&Float:ty,&Float:tz){
  2270. new Float:rx,Float:rz;
  2271. GetRotationFor2Point3D(x1,y1,z1,x2,y2,z2,rx,rz);
  2272. GetPointInFront3D(x1,y1,z1,rx,rz,distance,tx,ty,tz);
  2273. }
  2274. //DistanceFromPointToLine by Crayder
  2275. Tryg3D::Function:: Float:GetDistanceFromPointToLine(Float:px,Float:py,Float:pz,Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,&Float:iX=0.0,&Float:iY=0.0,&Float:iZ=0.0){
  2276. new Float:dist = GetDistanceBetweenPoints3D(eX,eY,eZ,sX,sY,sZ);
  2277. if(dist <= 0.0) return -1.0;
  2278. new Float:T3D:U = (((px - sX) * (eX - sX)) + ((py - sY) * (eY - sY)) + ((pz - sZ) * (eZ - sZ))) / (dist*dist);
  2279. if(T3D:U < 0.0 || T3D:U > 1.0) return -1.0;
  2280. iX = sX + T3D:U * (eX - sX);
  2281. iY = sY + T3D:U * (eY - sY);
  2282. iZ = sZ + T3D:U * (eZ - sZ);
  2283. return GetDistanceBetweenPoints3D(iX,iY,iZ,px,py,pz);
  2284. }
  2285. Tryg3D::Function:: IsPointBetween2Points2D(Float:px,Float:py,Float:xA,Float:yA,Float:xB,Float:yB){
  2286. return (GetDistanceBetweenPoints2D(xA,yA,xB,yB) == (GetDistanceBetweenPoints2D(xA,yA,px,py) + GetDistanceBetweenPoints2D(xB,yB,px,py)));
  2287. }
  2288. Tryg3D::Function:: IsPointBetween2Points3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB){
  2289. return (GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB) == (GetDistanceBetweenPoints3D(xA,yA,zA,px,py,pz) + GetDistanceBetweenPoints3D(xB,yB,zB,px,py,pz)));
  2290. }
  2291. //Abyss Morgan Algorithm (False Ellipse Test 2D)
  2292. Tryg3D::Function:: IsPointNearly2Points2D(Float:px,Float:py,Float:xA,Float:yA,Float:xB,Float:yB,Float:maxdist){
  2293. new Float:dAB = GetDistanceBetweenPoints2D(xA,yA,xB,yB);
  2294. return (dAB <= (GetDistanceBetweenPoints2D(xA,yA,px,py) + GetDistanceBetweenPoints2D(xB,yB,px,py)) <= (dAB+maxdist));
  2295. }
  2296. //Abyss Morgan Algorithm (False Ellipse Test 3D)
  2297. Tryg3D::Function:: IsPointNearly2Points3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:maxdist){
  2298. new Float:dAB = GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB);
  2299. return (dAB <= (GetDistanceBetweenPoints3D(xA,yA,zA,px,py,pz) + GetDistanceBetweenPoints3D(xB,yB,zB,px,py,pz)) <= (dAB+maxdist));
  2300. }
  2301. //IsPointInCylinder by Crayder
  2302. Tryg3D::Function:: IsPointInCylinder3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius){
  2303. new Float:cylinder_length = GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB);
  2304. if(cylinder_length <= 0.0) return 0;
  2305. new Float:iX, Float:iY, Float:iZ,
  2306. Float:distance = GetDistanceFromPointToLine(px,py,pz,xA,yA,zA,xB,yB,zB,iX,iY,iZ),
  2307. Float:tmp_radius = (GetDistanceBetweenPoints3D(iX,iY,iZ,xA,yA,zA) / cylinder_length * radius) + (GetDistanceBetweenPoints3D(iX,iY,iZ,xB,yB,zB) / cylinder_length * radius);
  2308. return (distance != -1.0 && distance <= tmp_radius);
  2309. }
  2310. //x,y,z - cube center point, rx,ry,rz - cube rotations
  2311. Tryg3D::Function:: IsPointInCube3D(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z){
  2312. if(size_x <= 0.0 || size_y <= 0.0 || size_z <= 0.0) return 0;
  2313. new Float:offset_x,Float:offset_y,Float:offset_z;
  2314. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  2315. ShiftPositionToOffset(x,y,z,rx,ry,rz,offset_x,offset_y,offset_z,px,py,pz);
  2316. return IsPointInCube(offset_x,offset_y,offset_z,-size_x,-size_y,-size_z,size_x,size_y,size_z);
  2317. }
  2318. //IsPointInCone by Crayder
  2319. Tryg3D::Function:: IsPointInCone3D(Float:px,Float:py,Float:pz,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius){
  2320. new Float:cylinder_length = GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB);
  2321. if(cylinder_length <= 0.0) return 0;
  2322. new Float:iX, Float:iY, Float:iZ,
  2323. Float:distance = GetDistanceFromPointToLine(px,py,pz,xA,yA,zA,xB,yB,zB,iX,iY,iZ),
  2324. Float:radius = (GetDistanceBetweenPoints3D(iX,iY,iZ,xA,yA,zA) / cylinder_length * pointB_radius) + (GetDistanceBetweenPoints3D(iX,iY,iZ,xB,yB,zB) / cylinder_length * pointA_radius);
  2325. return (distance != -1.0 && distance <= radius);
  2326. }
  2327. //Abyss Morgan Algorithm Circular Sector
  2328. Tryg3D::Function:: IsPointInCircularSector(Float:px,Float:py,Float:x,Float:y,Float:rz,Float:radius,Float:view_angle){
  2329. if(GetDistanceBetweenPoints2D(px,py,x,y) > radius) return 0;
  2330. new Float:trz;
  2331. view_angle /= 2.0;
  2332. GetRotationFor2Point2D(x,y,px,py,trz);
  2333. return (IsRotationTest(trz,rz-view_angle,rz+view_angle));
  2334. }
  2335. //Abyss Morgan Algorithm Spherical Sector
  2336. Tryg3D::Function:: IsPointInSphericalSector(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz){
  2337. if(GetDistanceBetweenPoints3D(px,py,pz,x,y,z) > radius) return 0;
  2338. new Float:trx,Float:trz;
  2339. vrx /= 2.0;
  2340. vrz /= 2.0;
  2341. if(!GetRotationFor2Point3D(x,y,z,px,py,pz,trx,trz)) return 0;
  2342. return (IsRotationTest(trx,rx-vrx,rx+vrx) && IsRotationTest(trz,rz-vrz,rz+vrz));
  2343. }
  2344. //Abyss Morgan Algorithm Spherical Sector
  2345. Tryg3D::Function:: IsPointInSphericalSectorEx(Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz,bool:testLOS=true,bool:veh_col=false){
  2346. if(GetDistanceBetweenPoints3D(px,py,pz,x,y,z) > radius) return 0;
  2347. #if defined Tryg3D_ColAndreas
  2348. if(testLOS){
  2349. new Float:T3D:x,Float:T3D:y,Float:T3D:z;
  2350. if(ColAndreas::RayCastLine(x,y,z,px,py,pz,T3D:x,T3D:y,T3D:z)) return 0;
  2351. }
  2352. #else
  2353. #pragma unused testLOS
  2354. #endif
  2355. #if defined Tryg3D_VehicleCollision
  2356. if(veh_col && Tryg3D::VehicleCollisionSystem){
  2357. new Float:T3D:x,Float:T3D:y,Float:T3D:z;
  2358. if(MovePointColWithVehicle(x,y,z,px,py,pz,T3D:x,T3D:y,T3D:z) != INVALID_VEHICLE_ID) return 0;
  2359. }
  2360. #else
  2361. #pragma unused veh_col
  2362. #endif
  2363. vrx /= 2.0;
  2364. vrz /= 2.0;
  2365. new Float:trx,Float:trz;
  2366. if(!GetRotationFor2Point3D(x,y,z,px,py,pz,trx,trz)) return 0;
  2367. return (IsRotationTest(trx,rx-vrx,rx+vrx) && IsRotationTest(trz,rz-vrz,rz+vrz));
  2368. }
  2369. Tryg3D::Function:: IsPointInEllipse(Float:px,Float:py,Float:cx,Float:cy,Float:size_x,Float:size_y){
  2370. new Float:rz;
  2371. GetRotationFor2Point2D(cx,cy,px,py,rz);
  2372. return (GetDistanceBetweenPoints2D(px,py,cx,cy) <= GetEllipseRadius(size_x,size_y,rz));
  2373. }
  2374. Tryg3D::Function:: IsPointInEllipticalCylinder2D(Float:px,Float:py,Float:pz,Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y){
  2375. if(!((pz >= minz) && (pz <= maxz))) return 0;
  2376. new Float:rz;
  2377. GetRotationFor2Point2D(cx,cy,px,py,rz);
  2378. return (GetDistanceBetweenPoints2D(px,py,cx,cy) <= GetEllipseRadius(size_x,size_y,rz));
  2379. }
  2380. //Polygon Test by RyDeR SRC:http://forum.sa-mp.com/showpost.php?p=1154971&postcount=1871 (Updated)
  2381. Tryg3D::Function:: IsPointInPolygon(Float:x,Float:y,Float:points[],maxpoints = sizeof(points)){
  2382. new polygon_Sides = ((maxpoints - 2) / 2);
  2383. if((maxpoints - 2) & 0b1 || polygon_Sides < 3) return 0;
  2384. new Float:polygon_Data[2][MAX_POLYGON_POINTS], cross_Total;
  2385. for(new i = 0, j; i < maxpoints; i += 2, j++){
  2386. polygon_Data[0][j] = points[i];
  2387. polygon_Data[1][j] = points[i+1];
  2388. }
  2389. for(new i, j = polygon_Sides - 1; i < polygon_Sides; j = i, i++){
  2390. if(polygon_Data[1][i] < y && polygon_Data[1][j] >= y || polygon_Data[1][j] < y && polygon_Data[1][i] >= y){
  2391. if(polygon_Data[0][i] + (y - polygon_Data[1][i]) / (polygon_Data[1][j] - polygon_Data[1][i]) * (polygon_Data[0][j] - polygon_Data[0][i]) < x){
  2392. cross_Total++;
  2393. }
  2394. }
  2395. }
  2396. return (cross_Total & 0x1);
  2397. }
  2398. //GetRandomPointInCircle by Crayder
  2399. Tryg3D::Function:: GetRandomPointInCircle(Float:x,Float:y,Float:radius,&Float:tx,&Float:ty){
  2400. new Float:T3D:alfa = float(random(1000000)+1)/1000000.0,
  2401. Float:T3D:beta = float(random(1000000)+1)/1000000.0;
  2402. if(T3D:beta < T3D:alfa) Tryg3D::SwapInt(T3D:alfa,T3D:beta);
  2403. tx = x + (T3D:beta * radius * floatcos(2.0 * FLOAT_PI * T3D:alfa / T3D:beta));
  2404. ty = y + (T3D:beta * radius * floatsin(2.0 * FLOAT_PI * T3D:alfa / T3D:beta));
  2405. }
  2406. //GetRandomPointInCylinder2D by Crayder
  2407. Tryg3D::Function:: GetRandomPointInCylinder2D(Float:x,Float:y,Float:minz,Float:maxz,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  2408. GetRandomPointInCircle(x,y,radius,tx,ty);
  2409. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)))+minz;
  2410. }
  2411. //GetRandomPointInCylinder3D by Abyss Morgan
  2412. Tryg3D::Function:: GetRandomPointInCylinder3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  2413. new Float:px,Float:py,Float:pz,Float:trx,Float:trz;
  2414. GetRotationFor2Point3D(xA,yA,zA,xB,yB,zB,trx,trz);
  2415. GetPointInFront3D(xA,yA,zA,trx,trz,Tryg3D::RandomFloat(0.0,GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB)),px,py,pz);
  2416. GetPointInFront3DEx(px,py,pz,Tryg3D::RandomFloat(0.0,360.0),trx,CompRotationFloat(trz+90.0),Tryg3D::RandomFloat(0.0,radius),tx,ty,tz);
  2417. }
  2418. Tryg3D::Function:: GetRandomPointInSphere(Float:x,Float:y,Float:z,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  2419. GetPointInFront3D(x,y,z,Tryg3D::RandomFloat(0.0,360.0),Tryg3D::RandomFloat(0.0,360.0),Tryg3D::RandomFloat(0.0,radius),tx,ty,tz);
  2420. }
  2421. Tryg3D::Function:: GetRandomPointInRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy,&Float:tx,&Float:ty){
  2422. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2423. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2424. }
  2425. Tryg3D::Function:: GetRandomPointInCube(Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz,&Float:tx,&Float:ty,&Float:tz){
  2426. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2427. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2428. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2429. }
  2430. Tryg3D::Function:: GetRandomPointInCube3D(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z,&Float:tx,&Float:ty,&Float:tz){
  2431. if(size_x <= 0 || size_y <= 0 || size_z <= 0.0) return 0;
  2432. new Float:offset_x,Float:offset_y,Float:offset_z;
  2433. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  2434. GetRandomPointInCube(-size_x,-size_y,-size_z,size_x,size_y,size_z,offset_x,offset_y,offset_z);
  2435. ShiftOffsetToPosition(x,y,z,rx,ry,rz,offset_x,offset_y,offset_z,tx,ty,tz);
  2436. return 1;
  2437. }
  2438. //GetRandomPointInCone3D by Abyss Morgan
  2439. Tryg3D::Function:: GetRandomPointInCone3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius,&Float:tx,&Float:ty,&Float:tz){
  2440. new Float:px,Float:py,Float:pz,Float:trx,Float:trz,
  2441. Float:dist = GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB),
  2442. Float:rand_dist = Tryg3D::RandomFloat(0.0,dist),
  2443. Float:radius = rand_dist*((pointB_radius-pointA_radius)*(1.0/dist))+pointA_radius;
  2444. GetRotationFor2Point3D(xA,yA,zA,xB,yB,zB,trx,trz);
  2445. GetPointInFront3D(xA,yA,zA,trx,trz,rand_dist,px,py,pz);
  2446. GetPointInFront3DEx(px,py,pz,Tryg3D::RandomFloat(0.0,360.0),trx,CompRotationFloat(trz+90.0),Tryg3D::RandomFloat(0.0,radius),tx,ty,tz);
  2447. }
  2448. Tryg3D::Function:: GetRandomPointInCircularSector(Float:x,Float:y,Float:rz,Float:radius,Float:view_angle,&Float:tx,&Float:ty){
  2449. view_angle /= 2.0;
  2450. new Float:rand_rz = CompRotationFloat(Tryg3D::RandomFloat(rz-view_angle+360.0,rz+view_angle+360.0,6)),
  2451. Float:rand_rad = Tryg3D::RandomFloat(0.0,radius,6);
  2452. if(rand_rad > radius) rand_rad = radius;
  2453. rand_rz = NMTV(rand_rz,(rz+view_angle));
  2454. rand_rz = NLTV(rand_rz,(rz-view_angle));
  2455. GetPointInFront2D(x,y,rand_rz,rand_rad,tx,ty);
  2456. }
  2457. //Beta Algorithm by Abyss Morgan
  2458. Tryg3D::Function:: GetRandomPointInSphericalSector(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz,&Float:tx,&Float:ty,&Float:tz){
  2459. new Float:rand_rx = CompRotationFloat(Tryg3D::RandomFloat(rx-vrx+360.0,rx+vrx+360.0,6)),
  2460. Float:rand_rz = CompRotationFloat(Tryg3D::RandomFloat(rz-vrz+360.0,rz+vrz+360.0,6)),
  2461. Float:rand_rad = Tryg3D::RandomFloat(0.0,radius,6);
  2462. vrx /= 2.0;
  2463. vrz /= 2.0;
  2464. if(rand_rad > radius) rand_rad = radius;
  2465. if(rand_rx > rx+vrx) rand_rx = rx+vrx;
  2466. if(rand_rx < rx-vrx) rand_rx = rx-vrx;
  2467. if(rand_rz > rz+vrz) rand_rz = rz+vrz;
  2468. if(rand_rz < rz-vrz) rand_rz = rz-vrz;
  2469. GetPointInFront3D(x,y,z,rand_rx,rand_rz,rand_rad,tx,ty,tz);
  2470. }
  2471. Tryg3D::Function:: GetRandomPointInEllipse(Float:cx,Float:cy,Float:size_x,Float:size_y,&Float:tx,&Float:ty){
  2472. new Float:omega = Tryg3D::RandomFloat(0.0,360.0,6);
  2473. GetPointInFront2D(cx,cy,omega,Tryg3D::RandomFloat(0.0,GetEllipseRadius(size_x,size_y,omega),6),tx,ty);
  2474. }
  2475. Tryg3D::Function:: GetRandomPointInEllipticalCyl2D(Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y,&Float:tx,&Float:ty,&Float:tz){
  2476. new Float:omega = Tryg3D::RandomFloat(0.0,360.0,6);
  2477. GetPointInFront2D(cx,cy,omega,Tryg3D::RandomFloat(0.0,GetEllipseRadius(size_x,size_y,omega),6),tx,ty);
  2478. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2479. }
  2480. //Abyss Morgan Algorithm Polygon
  2481. Tryg3D::Function:: GetRandomPointInPolygon(Float:points[],&Float:tx,&Float:ty,maxpoints = sizeof(points)){
  2482. new Float:minx, Float:miny, Float:maxx, Float:maxy, recheck = 1;
  2483. minx = maxx = points[0];
  2484. miny = maxy = points[1];
  2485. for(new i = 2; i < maxpoints; i += 2){
  2486. if(points[i] < minx) minx = points[i];
  2487. if(points[i] > maxx) maxx = points[i];
  2488. if(points[i+1] < miny) miny = points[i+1];
  2489. if(points[i+1] > maxy) maxy = points[i+1];
  2490. }
  2491. GetRandomPointInRectangle(minx,miny,maxx,maxy,tx,ty);
  2492. while(!IsPointInPolygon(tx,ty,points,maxpoints)){
  2493. GetRandomPointInRectangle(minx,miny,maxx,maxy,tx,ty);
  2494. recheck++;
  2495. }
  2496. return recheck;
  2497. }
  2498. Tryg3D::Function:: Float:GetRandomPointOnClock(Float:x,Float:y,Float:radius,&Float:tx,&Float:ty,&Float:trz,Float:rz = INVALID_ROTATION){
  2499. if(rz == INVALID_ROTATION) rz = Tryg3D::RandomFloat(0.0,360.0);
  2500. GetPointInFront2D(x,y,rz,radius,tx,ty);
  2501. return CompRotationFloat(rz-180.0,trz);
  2502. }
  2503. Tryg3D::Function:: GetRandomPointOnCylinder2D(Float:x,Float:y,Float:minz,Float:maxz,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  2504. GetRandomPointOnCircle(x,y,radius,tx,ty);
  2505. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)))+minz;
  2506. }
  2507. //GetRandomPointOnCylinder3D by Abyss Morgan
  2508. Tryg3D::Function:: GetRandomPointOnCylinder3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  2509. new Float:px,Float:py,Float:pz,Float:trx,Float:trz;
  2510. GetRotationFor2Point3D(xA,yA,zA,xB,yB,zB,trx,trz);
  2511. GetPointInFront3D(xA,yA,zA,trx,trz,Tryg3D::RandomFloat(0.0,GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB)),px,py,pz);
  2512. GetPointInFront3DEx(px,py,pz,Tryg3D::RandomFloat(0.0,360.0),trx,CompRotationFloat(trz+90.0),radius,tx,ty,tz);
  2513. }
  2514. //GetRandomPointOnSphere by Neil Lamoureux
  2515. Tryg3D::Function:: GetRandomPointOnSphere(Float:x,Float:y,Float:z,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  2516. new Float:T3D:alfa = float(random(1000000)+1)/1000000.0,
  2517. Float:T3D:beta = float(random(1000000)+1)/1000000.0,
  2518. Float:T3D:theta = 2 * FLOAT_PI * T3D:alfa,
  2519. Float:T3D:phi = acos(2 * T3D:beta - 1);
  2520. tx = x + (radius * floatsin(T3D:phi,degrees) * floatcos(T3D:theta,degrees));
  2521. ty = y + (radius * floatsin(T3D:phi,degrees) * floatsin(T3D:theta,degrees));
  2522. tz = z + (radius * floatcos(T3D:phi,degrees));
  2523. }
  2524. Tryg3D::Function:: GetRandomPointOnRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy,&Float:tx,&Float:ty){
  2525. switch(random(4)){
  2526. case 0: {
  2527. tx = minx;
  2528. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2529. }
  2530. case 1: {
  2531. tx = maxx;
  2532. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2533. }
  2534. case 2: {
  2535. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2536. ty = miny;
  2537. }
  2538. case 3: {
  2539. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2540. ty = maxy;
  2541. }
  2542. }
  2543. }
  2544. Tryg3D::Function:: GetRandomPointOnCube(Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz,&Float:tx,&Float:ty,&Float:tz){
  2545. switch(random(12)){
  2546. case 0: {
  2547. tx = minx;
  2548. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2549. tz = minz;
  2550. }
  2551. case 1: {
  2552. tx = maxx;
  2553. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2554. tz = minz;
  2555. }
  2556. case 2: {
  2557. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2558. ty = miny;
  2559. tz = minz;
  2560. }
  2561. case 3: {
  2562. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2563. ty = maxy;
  2564. tz = minz;
  2565. }
  2566. case 4: {
  2567. tx = minx;
  2568. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2569. tz = maxz;
  2570. }
  2571. case 5: {
  2572. tx = maxx;
  2573. ty = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(miny-maxy,2)),6)+miny;
  2574. tz = maxz;
  2575. }
  2576. case 6: {
  2577. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2578. ty = miny;
  2579. tz = maxz;
  2580. }
  2581. case 7: {
  2582. tx = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minx-maxx,2)),6)+minx;
  2583. ty = maxy;
  2584. tz = maxz;
  2585. }
  2586. case 8: {
  2587. tx = minx;
  2588. ty = miny;
  2589. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2590. }
  2591. case 9: {
  2592. tx = maxx;
  2593. ty = miny;
  2594. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2595. }
  2596. case 10: {
  2597. tx = minx;
  2598. ty = maxy;
  2599. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2600. }
  2601. case 11: {
  2602. tx = maxx;
  2603. ty = maxy;
  2604. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2605. }
  2606. }
  2607. }
  2608. Tryg3D::Function:: GetRandomPointOnCube3D(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z,&Float:tx,&Float:ty,&Float:tz){
  2609. if(size_x <= 0 || size_y <= 0 || size_z <= 0.0) return 0;
  2610. new Float:offset_x,Float:offset_y,Float:offset_z;
  2611. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  2612. GetRandomPointOnCube(-size_x,-size_y,-size_z,size_x,size_y,size_z,offset_x,offset_y,offset_z);
  2613. ShiftOffsetToPosition(x,y,z,rx,ry,rz,offset_x,offset_y,offset_z,tx,ty,tz);
  2614. return 1;
  2615. }
  2616. //GetRandomPointOnCone3D by Abyss Morgan
  2617. Tryg3D::Function:: GetRandomPointOnCone3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius,&Float:tx,&Float:ty,&Float:tz){
  2618. new Float:px,Float:py,Float:pz,Float:trx,Float:trz,
  2619. Float:dist = GetDistanceBetweenPoints3D(xA,yA,zA,xB,yB,zB),
  2620. Float:rand_dist = Tryg3D::RandomFloat(0.0,dist),
  2621. Float:radius = rand_dist*((pointB_radius-pointA_radius)*(1.0/dist))+pointA_radius;
  2622. GetRotationFor2Point3D(xA,yA,zA,xB,yB,zB,trx,trz);
  2623. GetPointInFront3D(xA,yA,zA,trx,trz,rand_dist,px,py,pz);
  2624. GetPointInFront3DEx(px,py,pz,Tryg3D::RandomFloat(0.0,360.0),trx,CompRotationFloat(trz+90.0),radius,tx,ty,tz);
  2625. }
  2626. Tryg3D::Function:: GetRandomPointOnCircularSector(Float:x,Float:y,Float:rz,Float:radius,Float:view_angle,&Float:tx,&Float:ty){
  2627. view_angle /= 2.0;
  2628. new Float:rand_rz = CompRotationFloat(Tryg3D::RandomFloat(rz-view_angle+360.0,rz+view_angle+360.0,6));
  2629. rand_rz = NMTV(rand_rz,(rz+view_angle));
  2630. rand_rz = NLTV(rand_rz,(rz-view_angle));
  2631. GetPointInFront2D(x,y,rand_rz,radius,tx,ty);
  2632. }
  2633. //Beta Algorithm by Abyss Morgan
  2634. Tryg3D::Function:: GetRandomPointOnSphericalSector(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz,&Float:tx,&Float:ty,&Float:tz){
  2635. vrx /= 2.0;
  2636. vrz /= 2.0;
  2637. new Float:rand_rx = CompRotationFloat(Tryg3D::RandomFloat(rx-vrx+360.0,rx+vrx+360.0,6)),
  2638. Float:rand_rz = CompRotationFloat(Tryg3D::RandomFloat(rz-vrz+360.0,rz+vrz+360.0,6));
  2639. if(rand_rx > rx+vrx) rand_rx = rx+vrx;
  2640. if(rand_rx < rx-vrx) rand_rx = rx-vrx;
  2641. if(rand_rz > rz+vrz) rand_rz = rz+vrz;
  2642. if(rand_rz < rz-vrz) rand_rz = rz-vrz;
  2643. GetPointInFront3D(x,y,z,rand_rx,rand_rz,radius,tx,ty,tz);
  2644. }
  2645. Tryg3D::Function:: GetRandomPointOnEllipse(Float:cx,Float:cy,Float:size_x,Float:size_y,&Float:tx,&Float:ty){
  2646. new Float:omega = Tryg3D::RandomFloat(0.0,360.0,6);
  2647. GetPointInFront2D(cx,cy,omega,GetEllipseRadius(size_x,size_y,omega),tx,ty);
  2648. }
  2649. Tryg3D::Function:: GetRandomPointOnEllipticalCyl2D(Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y,&Float:tx,&Float:ty,&Float:tz){
  2650. new Float:omega = Tryg3D::RandomFloat(0.0,360.0,6);
  2651. GetPointInFront2D(cx,cy,omega,GetEllipseRadius(size_x,size_y,omega),tx,ty);
  2652. tz = Tryg3D::RandomFloat(0.0,floatsqroot(floatpower(minz-maxz,2)),6)+minz;
  2653. }
  2654. Tryg3D::Function:: IsPlayerFakeSpectating(playerid,bool:force_disable=true){
  2655. if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING && IsPlayerAdmin(playerid)) return 0;
  2656. if(GetPlayerCameraMode(playerid) != 4) return 0;
  2657. new Float:px,Float:py,Float:pz,
  2658. Float:cx,Float:cy,Float:cz;
  2659. GetPlayerPos(playerid,px,py,pz);
  2660. GetPlayerCameraPos(playerid,cx,cy,cz);
  2661. if(VectorSize(px-cx,py-cy,pz-cz) < 20.0) return 0;
  2662. if(force_disable) SetCameraBehindPlayer(playerid);
  2663. return 1;
  2664. }
  2665. Tryg3D::Function:: GenerateGangZone(Float:x,Float:y,Float:radius,&Float:minx,&Float:miny,&Float:maxx,&Float:maxy){
  2666. minx = x - radius;
  2667. miny = y - radius;
  2668. maxx = x + radius;
  2669. maxy = y + radius;
  2670. }
  2671. Tryg3D::Function:: Float:GetCameraTargetDistance(Float:CamX,Float:CamY,Float:CamZ,Float:ObjX,Float:ObjY,Float:ObjZ,Float:FrX,Float:FrY,Float:FrZ){
  2672. new Float:T3D:dist = GetDistanceBetweenPoints3D(CamX,CamY,CamZ,ObjX,ObjY,ObjZ);
  2673. return GetDistanceBetweenPoints3D(ObjX,ObjY,ObjZ,(FrX * T3D:dist + CamX),(FrY * T3D:dist + CamY),(FrZ * T3D:dist + CamZ));
  2674. }
  2675. Tryg3D::Function:: IsPlayerAimingAt(playerid,Float:x,Float:y,Float:z,Float:radius){
  2676. new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
  2677. GetPlayerCameraPos(playerid,cx,cy,cz);
  2678. GetPlayerCameraFrontVector(playerid,fx,fy,fz);
  2679. return (radius >= GetCameraTargetDistance(cx,cy,cz,x,y,z,fx,fy,fz));
  2680. }
  2681. Tryg3D::Function:: IPL_CreateObject(modelid,Float:x,Float:y,Float:z,Float:qx,Float:qy,Float:qz,Float:qw,Float:drawdistance=0.0){
  2682. new Float:rx,Float:ry,Float:rz;
  2683. Tryg3D::QuatToEuler(rx,ry,rz,qw,qx,qy,qz);
  2684. return CreateObject(modelid,x,y,z,rx,ry,rz,drawdistance);
  2685. }
  2686. /************************************************************************************************************************************
  2687. * *
  2688. * Universal Functions *
  2689. * *
  2690. ************************************************************************************************************************************/
  2691. Tryg3D::Function:: GetInvalidElementID(Item3D_Type:item_type){
  2692. switch(item_type){
  2693. case item_player: return INVALID_PLAYER_ID;
  2694. case item_npc: return INVALID_PLAYER_ID;
  2695. #if defined Tryg3D_Actor
  2696. case item_actor: return INVALID_ACTOR_ID;
  2697. #endif
  2698. case item_object: return INVALID_OBJECT_ID;
  2699. case item_vehicle: return INVALID_VEHICLE_ID;
  2700. #if defined Tryg3D_Streamer
  2701. case item_dynamic_object: return INVALID_STREAMER_ID;
  2702. case item_dynamic_pickup: return INVALID_STREAMER_ID;
  2703. case item_dynamic_cp: return INVALID_STREAMER_ID;
  2704. case item_dynamic_racecp: return INVALID_STREAMER_ID;
  2705. case item_dynamic_mapicon: return INVALID_STREAMER_ID;
  2706. case item_dynamic_3dtext: return INVALID_STREAMER_ID;
  2707. case item_dynamic_actor: return INVALID_STREAMER_ID;
  2708. #endif
  2709. #if defined Tryg3D_VehicleStreamer
  2710. case item_dynamic_vehicle: return INVALID_STREAMER_ID;
  2711. #endif
  2712. #if defined Tryg3D_FCNPC
  2713. case item_fcnpc: return INVALID_PLAYER_ID;
  2714. #endif
  2715. }
  2716. return cellmax;
  2717. }
  2718. Tryg3D::Function:: GetElementPos(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,&Float:x,&Float:y,&Float:z){
  2719. switch(element_type){
  2720. case item_player: {
  2721. GetPlayerPos(_:elementid,x,y,z);
  2722. }
  2723. case item_npc: {
  2724. #if defined Tryg3D_FCNPC
  2725. if(FCNPC::IsValid(_:elementid)){
  2726. FCNPC::GetPosition(_:elementid,x,y,z);
  2727. } else {
  2728. GetPlayerPos(_:elementid,x,y,z);
  2729. }
  2730. #else
  2731. GetPlayerPos(_:elementid,x,y,z);
  2732. #endif
  2733. }
  2734. #if defined Tryg3D_Actor
  2735. case item_actor: {
  2736. GetActorPos(_:elementid,x,y,z);
  2737. }
  2738. #endif
  2739. case item_object: {
  2740. GetObjectPos(_:elementid,x,y,z);
  2741. }
  2742. case item_vehicle: {
  2743. GetVehiclePos(_:elementid,x,y,z);
  2744. }
  2745. #if defined Tryg3D_Streamer
  2746. case item_dynamic_object: {
  2747. GetDynamicObjectPos(STREAMER_TAG_OBJECT (_:elementid),x,y,z);
  2748. }
  2749. case item_dynamic_pickup: {
  2750. Streamer::GetFloatData(STREAMER_TYPE_PICKUP,_:elementid,E_STREAMER_X,x);
  2751. Streamer::GetFloatData(STREAMER_TYPE_PICKUP,_:elementid,E_STREAMER_Y,y);
  2752. Streamer::GetFloatData(STREAMER_TYPE_PICKUP,_:elementid,E_STREAMER_Z,z);
  2753. }
  2754. case item_dynamic_cp: {
  2755. Streamer::GetFloatData(STREAMER_TYPE_CP,_:elementid,E_STREAMER_X,x);
  2756. Streamer::GetFloatData(STREAMER_TYPE_CP,_:elementid,E_STREAMER_Y,y);
  2757. Streamer::GetFloatData(STREAMER_TYPE_CP,_:elementid,E_STREAMER_Z,z);
  2758. }
  2759. case item_dynamic_racecp: {
  2760. Streamer::GetFloatData(STREAMER_TYPE_RACE_CP,_:elementid,E_STREAMER_X,x);
  2761. Streamer::GetFloatData(STREAMER_TYPE_RACE_CP,_:elementid,E_STREAMER_Y,y);
  2762. Streamer::GetFloatData(STREAMER_TYPE_RACE_CP,_:elementid,E_STREAMER_Z,z);
  2763. }
  2764. case item_dynamic_mapicon: {
  2765. Streamer::GetFloatData(STREAMER_TYPE_MAP_ICON,_:elementid,E_STREAMER_X,x);
  2766. Streamer::GetFloatData(STREAMER_TYPE_MAP_ICON,_:elementid,E_STREAMER_Y,y);
  2767. Streamer::GetFloatData(STREAMER_TYPE_MAP_ICON,_:elementid,E_STREAMER_Z,z);
  2768. }
  2769. case item_dynamic_3dtext: {
  2770. Streamer::GetFloatData(STREAMER_TYPE_3D_TEXT_LABEL,_:elementid,E_STREAMER_X,x);
  2771. Streamer::GetFloatData(STREAMER_TYPE_3D_TEXT_LABEL,_:elementid,E_STREAMER_Y,y);
  2772. Streamer::GetFloatData(STREAMER_TYPE_3D_TEXT_LABEL,_:elementid,E_STREAMER_Z,z);
  2773. }
  2774. case item_dynamic_actor: {
  2775. GetDynamicActorPos(STREAMER_TAG_ACTOR (_:elementid),x,y,z);
  2776. }
  2777. #endif
  2778. #if defined Tryg3D_VehicleStreamer
  2779. case item_dynamic_vehicle: {
  2780. GetDynamicVehiclePos(STREAMER_TAG_VEHICLE (_:elementid),x,y,z);
  2781. }
  2782. #endif
  2783. #if defined Tryg3D_FCNPC
  2784. case item_fcnpc: {
  2785. FCNPC::GetPosition(_:elementid,x,y,z);
  2786. }
  2787. #endif
  2788. default: return 0;
  2789. }
  2790. return 1;
  2791. }
  2792. Tryg3D::Function:: GetElementVirtualWorld(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type){
  2793. switch(element_type){
  2794. case item_player: {
  2795. return GetPlayerVirtualWorld(_:elementid);
  2796. }
  2797. case item_npc: {
  2798. #if defined Tryg3D_FCNPC
  2799. if(FCNPC::IsValid(_:elementid)){
  2800. return FCNPC::GetVirtualWorld(_:elementid);
  2801. } else {
  2802. return GetPlayerVirtualWorld(_:elementid);
  2803. }
  2804. #else
  2805. return GetPlayerVirtualWorld(_:elementid);
  2806. #endif
  2807. }
  2808. #if defined Tryg3D_Actor
  2809. case item_actor: {
  2810. return GetActorVirtualWorld(_:elementid);
  2811. }
  2812. #endif
  2813. case item_vehicle: {
  2814. return GetVehicleVirtualWorld(_:elementid);
  2815. }
  2816. #if defined Tryg3D_Streamer
  2817. case item_dynamic_object: {
  2818. return Streamer::GetIntData(STREAMER_TYPE_OBJECT,_:elementid,E_STREAMER_WORLD_ID);
  2819. }
  2820. case item_dynamic_pickup: {
  2821. return Streamer::GetIntData(STREAMER_TYPE_PICKUP,_:elementid,E_STREAMER_WORLD_ID);
  2822. }
  2823. case item_dynamic_cp: {
  2824. return Streamer::GetIntData(STREAMER_TYPE_CP,_:elementid,E_STREAMER_WORLD_ID);
  2825. }
  2826. case item_dynamic_racecp: {
  2827. return Streamer::GetIntData(STREAMER_TYPE_RACE_CP,_:elementid,E_STREAMER_WORLD_ID);
  2828. }
  2829. case item_dynamic_mapicon: {
  2830. return Streamer::GetIntData(STREAMER_TYPE_MAP_ICON,_:elementid,E_STREAMER_WORLD_ID);
  2831. }
  2832. case item_dynamic_3dtext: {
  2833. return Streamer::GetIntData(STREAMER_TYPE_3D_TEXT_LABEL,_:elementid,E_STREAMER_WORLD_ID);
  2834. }
  2835. case item_dynamic_actor: {
  2836. return GetDynamicActorVirtualWorld(STREAMER_TAG_ACTOR (_:elementid));
  2837. }
  2838. #endif
  2839. #if defined Tryg3D_VehicleStreamer
  2840. case item_dynamic_vehicle: {
  2841. return GetDynamicVehicleVirtualWorld(STREAMER_TAG_VEHICLE (_:elementid));
  2842. }
  2843. #endif
  2844. #if defined Tryg3D_FCNPC
  2845. case item_fcnpc: {
  2846. return FCNPC::GetVirtualWorld(_:elementid);
  2847. }
  2848. #endif
  2849. }
  2850. return INVALID_VIRTUAL_WORLD;
  2851. }
  2852. Tryg3D::Function:: GetElementRotationQuat(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,&Float:qw,&Float:qx,&Float:qy,&Float:qz){
  2853. new Float:rx,Float:ry,Float:rz;
  2854. qw = qx = qy = qz = 0.0;
  2855. switch(element_type){
  2856. #if defined Tryg3D_YSF
  2857. case item_player: {
  2858. GetPlayerRotationQuat(_:elementid,qw,qx,qy,qz);
  2859. }
  2860. #endif
  2861. case item_object: {
  2862. GetObjectRot(_:elementid,rx,ry,rz);
  2863. Tryg3D::EulerToQuat(rx,ry,rz,qw,qx,qy,qz);
  2864. qw *= (-1);
  2865. }
  2866. case item_vehicle: {
  2867. GetVehicleRotationQuat(_:elementid,qw,qx,qy,qz);
  2868. }
  2869. #if defined Tryg3D_Streamer
  2870. case item_dynamic_object: {
  2871. GetDynamicObjectRot(STREAMER_TAG_OBJECT (_:elementid),rx,ry,rz);
  2872. Tryg3D::EulerToQuat(rx,ry,rz,qw,qx,qy,qz);
  2873. qw *= (-1);
  2874. }
  2875. #endif
  2876. #if defined Tryg3D_VehicleStreamer
  2877. case item_dynamic_vehicle: {
  2878. GetDynamicVehicleRotationQuat(STREAMER_TAG_VEHICLE (_:elementid),qw,qx,qy,qz);
  2879. }
  2880. #endif
  2881. #if defined Tryg3D_FCNPC
  2882. case item_fcnpc: {
  2883. FCNPC::GetQuaternion(_:elementid,qw,qx,qy,qz);
  2884. }
  2885. #endif
  2886. default: return 0;
  2887. }
  2888. return 1;
  2889. }
  2890. Tryg3D::Function:: GetElementUpVector(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,&Float:vx,&Float:vy,&Float:vz){
  2891. new Float:qw,Float:qx,Float:qy,Float:qz;
  2892. if(!GetElementRotationQuat(elementid,element_type,qw,qx,qy,qz)) return 0;
  2893. switch(element_type){
  2894. case item_object: {
  2895. GetQuatUpVector(qw,qx,qy,qz,vx,vy,vz);
  2896. }
  2897. case item_vehicle, item_dynamic_vehicle: {
  2898. GetQuatUpVector(qw,-qx,-qy,-qz,vx,vy,vz);
  2899. }
  2900. #if defined Tryg3D_Streamer
  2901. case item_dynamic_object: {
  2902. GetQuatUpVector(qw,qx,qy,qz,vx,vy,vz);
  2903. }
  2904. #endif
  2905. default: return 0;
  2906. }
  2907. return 1;
  2908. }
  2909. Tryg3D::Function:: GetElementUpPos(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:radius,&Float:x,&Float:y,&Float:z,bool:reverse=false){
  2910. new Float:vx,Float:vy,Float:vz,Float:rx,Float:rz;
  2911. if(!GetElementUpVector(elementid,element_type,vx,vy,vz)) return 0;
  2912. ShiftVectorToRotation(vx,vy,vz,rx,rz);
  2913. if(!GetElementPos(elementid,element_type,vx,vy,vz)) return 0;
  2914. if(!reverse){
  2915. GetPointInFront3D(vx,vy,vz,rx,rz,radius,x,y,z);
  2916. } else {
  2917. GetPointInFront3D(vx,vy,vz,CompRotationFloat(rx-180.0),rz,radius,x,y,z);
  2918. }
  2919. return 1;
  2920. }
  2921. Tryg3D::Function:: IsElementOnPlayerScreen(playerid,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type=item_player,element_orientation:orientation=o_front,Float:rx=INVALID_ROTATION,Float:rz=INVALID_ROTATION,Float:vrx=VERTICAL_CAMERA_RADIUS,Float:vrz=HORIZONTAL_CAMERA_RADIUS,bool:testLOS=true,bool:testVW=true,bool:veh_col=false){
  2922. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:prx,Float:prz,worldid;
  2923. GetPlayerCameraPos(playerid,x,y,z);
  2924. GetPlayerCameraRotation(playerid,prx,prz);
  2925. switch(orientation){
  2926. case o_left: prx = CompRotationFloat(prx+90.0);
  2927. case o_right: prx = CompRotationFloat(prx-90.0);
  2928. case o_back: prx = CompRotationFloat(prx+180.0);
  2929. }
  2930. worldid = GetPlayerVirtualWorld(playerid);
  2931. if(rx != INVALID_ROTATION) prx = rx;
  2932. if(rz != INVALID_ROTATION) prz = rz;
  2933. if(!GetElementPos(targetid,target_type,tx,ty,tz)) return 0;
  2934. if(testVW){
  2935. new T3D:vw = GetElementVirtualWorld(targetid,target_type);
  2936. if(T3D:vw != worldid && T3D:vw != -1) return 0;
  2937. }
  2938. return IsPointInSphericalSectorEx(tx,ty,tz,x,y,z,prx,prz,Tryg3D::StreamDistance,vrx,vrz,testLOS,veh_col);
  2939. }
  2940. Tryg3D::Function:: IsElementOnFakeScreen(Float:x,Float:y,Float:z,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type,Float:rx,Float:rz,Float:vrx=VERTICAL_CAMERA_RADIUS,Float:vrz=HORIZONTAL_CAMERA_RADIUS,bool:testLOS=true,bool:veh_col=false){
  2941. new Float:tx,Float:ty,Float:tz;
  2942. if(!GetElementPos(targetid,target_type,tx,ty,tz)) return 0;
  2943. return IsPointInSphericalSectorEx(tx,ty,tz,x,y,z,rx,rz,Tryg3D::StreamDistance,vrx,vrz,testLOS,veh_col);
  2944. }
  2945. Tryg3D::Function:: Float:GetElementsDistance(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type){
  2946. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz;
  2947. if(!GetElementPos(elementid,element_type,x,y,z)) return -1.0;
  2948. if(!GetElementPos(targetid,target_type,tx,ty,tz)) return -1.0;
  2949. return GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz);
  2950. }
  2951. Tryg3D::Function:: Float:GetElementDistanceFromPoint(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z){
  2952. new Float:tx,Float:ty,Float:tz;
  2953. if(!GetElementPos(elementid,element_type,tx,ty,tz)) return -1.0;
  2954. return GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz);
  2955. }
  2956. Tryg3D::Function:: IsElementInCircle(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:radius){
  2957. new Float:px,Float:py,Float:pz;
  2958. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2959. return IsPointInCircle(px,py,x,y,radius);
  2960. }
  2961. Tryg3D::Function:: IsElementInCylinder3D(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius){
  2962. new Float:px,Float:py,Float:pz;
  2963. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2964. return IsPointInCylinder3D(px,py,pz,xA,yA,zA,xB,yB,zB,radius);
  2965. }
  2966. Tryg3D::Function:: IsElementInCylinder2D(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:minz,Float:maxz,Float:radius){
  2967. new Float:px,Float:py,Float:pz;
  2968. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2969. return IsPointInCylinder2D(px,py,pz,x,y,minz,maxz,radius);
  2970. }
  2971. Tryg3D::Function:: IsElementInSphere(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z,Float:radius){
  2972. new Float:px,Float:py,Float:pz;
  2973. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2974. return IsPointInSphere(px,py,pz,x,y,z,radius);
  2975. }
  2976. Tryg3D::Function:: IsElementInRectangle(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:minx,Float:miny,Float:maxx,Float:maxy){
  2977. new Float:px,Float:py,Float:pz;
  2978. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2979. return IsPointInRectangle(px,py,minx,miny,maxx,maxy);
  2980. }
  2981. Tryg3D::Function:: IsElementInCube(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz){
  2982. new Float:px,Float:py,Float:pz;
  2983. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2984. return IsPointInCube(px,py,pz,minx,miny,minz,maxx,maxy,maxz);
  2985. }
  2986. Tryg3D::Function:: IsElementInPolygon(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:points[],maxpoints = sizeof(points)){
  2987. new Float:px,Float:py,Float:pz;
  2988. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2989. return IsPointInPolygon(px,py,points,maxpoints);
  2990. }
  2991. Tryg3D::Function:: IsElementInCircularSector(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:rz,Float:radius,Float:view_angle){
  2992. new Float:px,Float:py,Float:pz;
  2993. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2994. return IsPointInCircularSector(px,py,x,y,rz,radius,view_angle);
  2995. }
  2996. Tryg3D::Function:: IsElementInSphericalSector(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz){
  2997. new Float:px,Float:py,Float:pz;
  2998. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  2999. return IsPointInSphericalSector(px,py,pz,x,y,z,rx,rz,radius,vrx,vrz);
  3000. }
  3001. Tryg3D::Function:: IsElementInCone(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius){
  3002. new Float:px,Float:py,Float:pz;
  3003. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3004. return IsPointInCone3D(px,py,pz,xA,yA,zA,xB,yB,zB,pointA_radius,pointB_radius);
  3005. }
  3006. Tryg3D::Function:: IsElementInCube3D(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z){
  3007. new Float:px,Float:py,Float:pz;
  3008. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3009. return IsPointInCube3D(px,py,pz,x,y,z,rx,ry,rz,size_x,size_y,size_z);
  3010. }
  3011. Tryg3D::Function:: IsElementInEllipse(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:cx,Float:cy,Float:size_x,Float:size_y){
  3012. new Float:px,Float:py,Float:pz;
  3013. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3014. return IsPointInEllipse(px,py,cx,cy,size_x,size_y);
  3015. }
  3016. Tryg3D::Function:: IsElementInEllipticalCylinder2D(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y){
  3017. new Float:px,Float:py,Float:pz;
  3018. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3019. return IsPointInEllipticalCylinder2D(px,py,pz,cx,cy,minz,maxz,size_x,size_y);
  3020. }
  3021. Tryg3D::Function:: GetElementToPointVector(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:tx,Float:ty,Float:tz,&Float:vx,&Float:vy,&Float:vz){
  3022. new Float:px,Float:py,Float:pz,Float:rx,Float:rz;
  3023. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3024. if(GetRotationFor2Point3D(px,py,pz,tx,ty,tz,rx,rz)){
  3025. ShiftRotationToVector(rx,rz,vx,vy,vz);
  3026. return 1;
  3027. } else {
  3028. vx = vy = vz = 0.0;
  3029. return 0;
  3030. }
  3031. }
  3032. Tryg3D::Function:: GetElementRotatedVector(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:tx,Float:ty,Float:tz,&Float:vx,&Float:vy,&Float:vz,bool:return_vector=true,Float:rx=0.0,Float:ry=0.0,Float:rz=0.0){
  3033. new Float:px,Float:py,Float:pz;
  3034. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3035. if(return_vector){
  3036. ShiftLineRotationVector(px,py,pz,tx,ty,tz,rx,ry,rz,vx,vy,vz);
  3037. } else {
  3038. ShiftLineRotation(px,py,pz,tx,ty,tz,rx,ry,rz,vx,vy,vz);
  3039. }
  3040. return 1;
  3041. }
  3042. Tryg3D::Function:: GetElementOrientationPos(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,element_orientation:orientation,Float:distance,&Float:tx,&Float:ty,&Float:tz){
  3043. new Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz;
  3044. if(!GetElementPos(elementid,element_type,x,y,z)) return 0;
  3045. switch(element_type){
  3046. case item_player: {
  3047. GetPlayerFacingAngle(_:elementid,rz);
  3048. }
  3049. case item_npc: {
  3050. #if defined Tryg3D_FCNPC
  3051. if(FCNPC::IsValid(_:elementid)){
  3052. rz = FCNPC::GetAngle(_:elementid);
  3053. } else {
  3054. GetPlayerFacingAngle(_:elementid,rz);
  3055. }
  3056. #else
  3057. GetPlayerFacingAngle(_:elementid,rz);
  3058. #endif
  3059. }
  3060. #if defined Tryg3D_Actor
  3061. case item_actor: {
  3062. GetActorFacingAngle(_:elementid,rz);
  3063. }
  3064. #endif
  3065. case item_object: {
  3066. GetObjectRot(_:elementid,rx,ry,rz);
  3067. }
  3068. case item_vehicle: {
  3069. Tryg3D::GetVehicleRotation(_:elementid,rx,ry,rz);
  3070. }
  3071. #if defined Tryg3D_Streamer
  3072. case item_dynamic_object: {
  3073. GetDynamicObjectRot(STREAMER_TAG_OBJECT (_:elementid),rx,ry,rz);
  3074. }
  3075. case item_dynamic_actor: {
  3076. GetDynamicActorFacingAngle(STREAMER_TAG_ACTOR (_:elementid),rz);
  3077. }
  3078. #endif
  3079. #if defined Tryg3D_VehicleStreamer
  3080. case item_dynamic_vehicle: {
  3081. GetDynamicVehicleRotation(STREAMER_TAG_VEHICLE (_:elementid),rx,ry,rz);
  3082. }
  3083. #endif
  3084. #if defined Tryg3D_FCNPC
  3085. case item_fcnpc: {
  3086. rz = FCNPC::GetAngle(_:elementid);
  3087. }
  3088. #endif
  3089. default: return 0;
  3090. }
  3091. switch(element_type){
  3092. case item_player, item_npc, item_actor, item_dynamic_actor, item_fcnpc: {
  3093. switch(orientation){
  3094. case o_left: GetPointInFront3D(x,y,z,0.0,CompRotationFloat(rz+90.0),distance,tx,ty,tz);
  3095. case o_right: GetPointInFront3D(x,y,z,0.0,CompRotationFloat(rz-90.0),distance,tx,ty,tz);
  3096. case o_up: tx = x, ty = y, tz = z + distance;
  3097. case o_down: tx = x, ty = y, tz = z - distance;
  3098. case o_front: GetPointInFront3D(x,y,z,0.0,rz,distance,tx,ty,tz);
  3099. case o_back: GetPointInFront3D(x,y,z,0.0,CompRotationFloat(rz+180.0),distance,tx,ty,tz);
  3100. }
  3101. }
  3102. case item_vehicle, item_object, item_dynamic_object, item_dynamic_vehicle: {
  3103. switch(orientation){
  3104. case o_left: GetPointInFront3D(x,y,z,ry,CompRotationFloat(rz+90.0),distance,tx,ty,tz);
  3105. case o_right: GetPointInFront3D(x,y,z,CompRotationFloat(ry+180.0),CompRotationFloat(rz+90.0),distance,tx,ty,tz);
  3106. case o_up: GetElementUpPos(elementid,element_type,distance,tx,ty,tz);
  3107. case o_down: GetElementUpPos(elementid,element_type,distance,tx,ty,tz,true);
  3108. case o_front: GetPointInFront3D(x,y,z,rx,rz,distance,tx,ty,tz);
  3109. case o_back: GetPointInFront3D(x,y,z,CompRotationFloat(rx+180.0),rz,distance,tx,ty,tz);
  3110. }
  3111. }
  3112. }
  3113. return 1;
  3114. }
  3115. #if defined Tryg3D_VehicleCollision
  3116. /************************************************************************************************************************************
  3117. * *
  3118. * Vehicle Collision Functions *
  3119. * *
  3120. ************************************************************************************************************************************/
  3121. #define IsVehicleCollisionEnabled() Tryg3D::VehicleCollisionSystem
  3122. Tryg3D::Public:: Tryg3D::SyncVehicleCollision(vehicleid){
  3123. if(!Tryg3D::VehicleCollisionSystem) return 0;
  3124. new Float:T3D:sx,Float:T3D:sy,Float:T3D:sz;
  3125. GetVehicleModelInfo(GetVehicleModel(vehicleid),VEHICLE_MODEL_INFO_SIZE,T3D:sx,T3D:sy,T3D:sz);
  3126. T3D:sx /= 2.0;
  3127. T3D:sy /= 2.0;
  3128. T3D:sz /= 2.0;
  3129. Streamer::SetFloatData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_MIN_X,-T3D:sx);
  3130. Streamer::SetFloatData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_MIN_Y,-T3D:sy);
  3131. Streamer::SetFloatData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_MIN_Z,-T3D:sz);
  3132. Streamer::SetFloatData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_MAX_X,T3D:sx);
  3133. Streamer::SetFloatData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_MAX_Y,T3D:sy);
  3134. Streamer::SetFloatData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_MAX_Z,T3D:sz);
  3135. AttachDynamicAreaToVehicle(Tryg3D::VehicleCollisionZone[vehicleid],vehicleid);
  3136. return 1;
  3137. }
  3138. Tryg3D::Public:: Tryg3D::InitVehicleCollision(){
  3139. if(Tryg3D::VehicleCollisionSystem) return 0;
  3140. for(new vehicleid = 1; vehicleid < MAX_VEHICLES; vehicleid++){
  3141. Tryg3D::VehicleCollisionZone[vehicleid] = CreateDynamicCube(-1.0,-1.0,-6000.0,1.0,1.0,-5000.0);
  3142. Streamer::SetIntData(STREAMER_TYPE_AREA,Tryg3D::VehicleCollisionZone[vehicleid],E_STREAMER_EXTRA_ID,(vehicleid+VCOLLISION_EXTRA_ID_OFFSET));
  3143. if(IsValidVehicle(vehicleid)){
  3144. Tryg3D::SyncVehicleCollision(vehicleid);
  3145. }
  3146. }
  3147. Tryg3D::VehicleCollisionSystem = true;
  3148. print("[ADM] Info: Vehicle Collision successfully init.");
  3149. return 1;
  3150. }
  3151. Tryg3D::Public:: Tryg3D::ExitVehicleCollision(){
  3152. if(!Tryg3D::VehicleCollisionSystem) return 0;
  3153. for(new vehicleid = 1; vehicleid < MAX_VEHICLES; vehicleid++){
  3154. if(IsValidDynamicArea(Tryg3D::VehicleCollisionZone[vehicleid])) DestroyDynamicArea(Tryg3D::VehicleCollisionZone[vehicleid]);
  3155. Tryg3D::VehicleCollisionZone[vehicleid] = STREAMER_TAG_AREA INVALID_STREAMER_ID;
  3156. }
  3157. Tryg3D::VehicleCollisionSystem = false;
  3158. print("[ADM] Info: Vehicle Collision successfully exit.");
  3159. return 1;
  3160. }
  3161. Tryg3D::Public:: MovePointColWithVehicle(Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ,&Float:x,&Float:y,&Float:z){
  3162. x = y = z = 0.0;
  3163. ColAndreas::RayCastLine(StartX,StartY,StartZ,EndX,EndY,EndZ,x,y,z); //first find wall collision
  3164. if(x == 0.0) x = EndX;
  3165. if(y == 0.0) y = EndY;
  3166. if(z == 0.0) z = EndZ;
  3167. if(Tryg3D::VehicleCollisionSystem){
  3168. new Float:vx, Float:vy, Float:vz, Tryg3D::AreaCount;
  3169. Tryg3D::AreaCount = GetNumberDynamicAreasForLine(StartX,StartY,StartZ,x,y,z);
  3170. if(Tryg3D::AreaCount){
  3171. new STREAMER_TAG_AREA Tryg3D::Area[128], T3D:vehicleid, Float:T3D:sx, Float:T3D:sy, Float:T3D:sz, Float:T3D:last_dist = 20000.0, Float:T3D:dist, T3D:near_vehicleid = INVALID_VEHICLE_ID;
  3172. GetDynamicAreasForLine(StartX,StartY,StartZ,x,y,z,Tryg3D::Area,sizeof(Tryg3D::Area));
  3173. for(new k = 0; k < Tryg3D::AreaCount; k++){
  3174. T3D:vehicleid = Streamer::GetIntData(STREAMER_TYPE_AREA,Tryg3D::Area[k],E_STREAMER_EXTRA_ID) - VCOLLISION_EXTRA_ID_OFFSET;
  3175. if(T3D:vehicleid >= 1 && T3D:vehicleid < MAX_VEHICLES && IsValidVehicle(T3D:vehicleid)){
  3176. if(Tryg3D::Area[k] == Tryg3D::VehicleCollisionZone[T3D:vehicleid]){
  3177. GetVehiclePos(T3D:vehicleid,vx,vy,vz);
  3178. if((T3D:dist = GetDistanceBetweenPoints3D(StartX,StartY,StartZ,vx,vy,vz)) < T3D:last_dist){
  3179. T3D:last_dist = T3D:dist;
  3180. T3D:near_vehicleid = T3D:vehicleid;
  3181. }
  3182. }
  3183. }
  3184. }
  3185. if(T3D:near_vehicleid != INVALID_VEHICLE_ID){
  3186. GetVehiclePos(T3D:near_vehicleid,vx,vy,vz);
  3187. GetVehicleModelInfo(GetVehicleModel(T3D:near_vehicleid),VEHICLE_MODEL_INFO_SIZE,T3D:sx,T3D:sy,T3D:sz);
  3188. GetPointFor2Point3DEx(StartX,StartY,StartZ,vx,vy,vz,GetDistanceBetweenPoints3D(StartX,StartY,StartZ,vx,vy,vz)-VectorSize((T3D:sx/2.0),(T3D:sy/2.0),(T3D:sz/2.0)),x,y,z);
  3189. return T3D:near_vehicleid;
  3190. }
  3191. }
  3192. }
  3193. return INVALID_VEHICLE_ID;
  3194. }
  3195. Tryg3D::Function:: MovePointColWithVehicleCut(Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ,&Float:x,&Float:y,&Float:z,Float:cut_size=0.0){
  3196. new Float:px,Float:py,Float:pz,vehicleid;
  3197. vehicleid = MovePointColWithVehicle(StartX,StartY,StartZ,EndX,EndY,EndZ,px,py,pz);
  3198. GetPointFor2Point3DEx(StartX,StartY,StartZ,px,py,pz,(GetDistanceBetweenPoints3D(StartX,StartY,StartZ,px,py,pz)-cut_size),x,y,z);
  3199. return vehicleid;
  3200. }
  3201. Tryg3D::Function:: IsBetweenElementToPointIsVeh(Float:x,Float:y,Float:z,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type){
  3202. new Float:xB,Float:yB,Float:zB,Float:T3D:x,Float:T3D:y,Float:T3D:z;
  3203. if(!GetElementPos(targetid,target_type,xB,yB,zB)) return 0;
  3204. return (ColAndreas::RayCastLine(xB,yB,zB,x,y,z,T3D:x,T3D:y,T3D:z) || (MovePointColWithVehicle(x,y,z,xB,yB,zB,T3D:x,T3D:y,T3D:z) != INVALID_VEHICLE_ID));
  3205. }
  3206. Tryg3D::Function:: IsBetweenElementsIsVeh(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type){
  3207. new Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:T3D:x,Float:T3D:y,Float:T3D:z;
  3208. if(!GetElementPos(elementid,element_type,xA,yA,zA)) return 0;
  3209. if(!GetElementPos(targetid,target_type,xB,yB,zB)) return 0;
  3210. return (ColAndreas::RayCastLine(xA,yA,zA,xB,yB,zB,T3D:x,T3D:y,T3D:z) || (MovePointColWithVehicle(xA,yA,zA,xB,yB,zB,T3D:x,T3D:y,T3D:z) != INVALID_VEHICLE_ID));
  3211. }
  3212. #endif
  3213. #if defined Tryg3D_Anims
  3214. /************************************************************************************************************************************
  3215. * *
  3216. * Animation Functions *
  3217. * *
  3218. ************************************************************************************************************************************/
  3219. Tryg3D::Function:: IsPlayerSkydiving(playerid){
  3220. new T3D:index = GetPlayerAnimationIndex(playerid);
  3221. return (T3D:index >= 958 && T3D:index <= 962);
  3222. }
  3223. Tryg3D::Function:: IsPlayerUsingParachute(playerid){
  3224. new T3D:index = GetPlayerAnimationIndex(playerid);
  3225. return (T3D:index >= 963 && T3D:index <= 979);
  3226. }
  3227. Tryg3D::Function:: IsPlayerAiming(playerid){
  3228. switch(GetPlayerAnimationIndex(playerid)){
  3229. case 1160..1163,1167,1365,1643,1453,220: return 1;
  3230. }
  3231. return 0;
  3232. }
  3233. Tryg3D::Function:: IsPlayerStay(playerid){
  3234. new T3D:index = GetPlayerAnimationIndex(playerid);
  3235. return (T3D:index == 1189 || T3D:index == 1133);
  3236. }
  3237. Tryg3D::Function:: IsPlayerRunning(playerid){
  3238. new T3D:index = GetPlayerAnimationIndex(playerid);
  3239. return (T3D:index == 1231 || T3D:index == 1266 || T3D:index == 1196);
  3240. }
  3241. Tryg3D::Function:: IsPlayerSwim(playerid){
  3242. new T3D:index = GetPlayerAnimationIndex(playerid);
  3243. return (T3D:index == 1538 || T3D:index == 1539 || T3D:index == 1541 || T3D:index == 1544);
  3244. }
  3245. Tryg3D::Function:: IsPlayerJump(playerid){
  3246. new T3D:index = GetPlayerAnimationIndex(playerid);
  3247. return (T3D:index == 1195 || T3D:index == 1198);
  3248. }
  3249. Tryg3D::Function:: IsPlayerParaFall(playerid){
  3250. new T3D:index = GetPlayerAnimationIndex(playerid);
  3251. return (T3D:index == 958 || T3D:index == 959 || T3D:index == 961 || T3D:index == 962 || T3D:index == 1134);
  3252. }
  3253. Tryg3D::Function:: IsPlayerParaGlide(playerid){
  3254. new T3D:index = GetPlayerAnimationIndex(playerid);
  3255. return (T3D:index == 963 || T3D:index == 965 || T3D:index == 971 || T3D:index == 976 || T3D:index == 978);
  3256. }
  3257. Tryg3D::Function:: IsPlayerFall(playerid){
  3258. return (GetPlayerAnimationIndex(playerid) == 1130);
  3259. }
  3260. #endif
  3261. /************************************************************************************************************************************
  3262. * *
  3263. * Extended Functions *
  3264. * *
  3265. ************************************************************************************************************************************/
  3266. //flag_a
  3267. #define Tryg3D_GetActiveCount() GetSVarInt("ADM:3DTryg:ACTIVE")
  3268. #define Tryg3D_GetErrorCount() GetSVarInt("ADM:3DTryg:Error")
  3269. #define Tryg3D_ResetErrorCount() SetSVarInt("ADM:3DTryg:Error",0)
  3270. #define Update3DTrygErrorCount() SetSVarInt("ADM:3DTryg:Error",Tryg3D::GetErrorCount()+1)
  3271. #define Tryg3D_SetStreamDistance(%0) Tryg3D::StreamDistance = (%0)
  3272. #define Tryg3D_GetStreamDistance() Tryg3D::StreamDistance
  3273. Tryg3D::Function:: Tryg3D::IsModuleLoaded(Tryg3D::Module:moduleid){
  3274. switch(moduleid){
  3275. case TRYG3D_MODULEID_MAPANDREAS: return Tryg3D_Module_MapAndreas;
  3276. case TRYG3D_MODULEID_COLANDREAS: return Tryg3D_Module_ColAndreas;
  3277. case TRYG3D_MODULEID_YSF: return Tryg3D_Module_YSF;
  3278. case TRYG3D_MODULEID_STREAMER: return Tryg3D_Module_Streamer;
  3279. case TRYG3D_MODULEID_FOXFOREACH: return Tryg3D_Module_FoxForeach;
  3280. case TRYG3D_MODULEID_YSIFOREACH: return Tryg3D_Module_YSIForeach;
  3281. case TRYG3D_MODULEID_FCNPC: return Tryg3D_Module_FCNPC;
  3282. case TRYG3D_MODULEID_STREAM3D: return Tryg3D_Module_Stream3D;
  3283. case TRYG3D_MODULEID_ACTOR: return Tryg3D_Module_Actor;
  3284. case TRYG3D_MODULEID_ATM: return Tryg3D_Module_ATM;
  3285. case TRYG3D_MODULEID_ANIMS: return Tryg3D_Module_Anims;
  3286. case TRYG3D_MODULEID_VEHSTREAMER: return Tryg3D_Module_VehicleStreamer;
  3287. case TRYG3D_MODULEID_VEHICLECOL: return Tryg3D_Module_VehicleCollision;
  3288. }
  3289. return 0;
  3290. }
  3291. Tryg3D::Function:: Tryg3D::GetModuleName(Tryg3D::Module:moduleid,module_name[],maxdest=sizeof(module_name)){
  3292. switch(moduleid){
  3293. case TRYG3D_MODULEID_MAPANDREAS: format(module_name,maxdest,"MapAndreas");
  3294. case TRYG3D_MODULEID_COLANDREAS: format(module_name,maxdest,"ColAndreas");
  3295. case TRYG3D_MODULEID_YSF: format(module_name,maxdest,"YSF");
  3296. case TRYG3D_MODULEID_STREAMER: format(module_name,maxdest,"Streamer");
  3297. case TRYG3D_MODULEID_FOXFOREACH: format(module_name,maxdest,"FoxForeach");
  3298. case TRYG3D_MODULEID_YSIFOREACH: format(module_name,maxdest,"YSIForeach");
  3299. case TRYG3D_MODULEID_FCNPC: format(module_name,maxdest,"FCNPC");
  3300. case TRYG3D_MODULEID_STREAM3D: format(module_name,maxdest,"Stream3D");
  3301. case TRYG3D_MODULEID_ACTOR: format(module_name,maxdest,"Actor");
  3302. case TRYG3D_MODULEID_ATM: format(module_name,maxdest,"ATM");
  3303. case TRYG3D_MODULEID_ANIMS: format(module_name,maxdest,"Anims");
  3304. case TRYG3D_MODULEID_VEHSTREAMER: format(module_name,maxdest,"VehicleStreamer");
  3305. case TRYG3D_MODULEID_VEHICLECOL: format(module_name,maxdest,"VehicleCollision");
  3306. }
  3307. }
  3308. Tryg3D::Function:: Tryg3D::GetModules(&modules_count=0){
  3309. modules_count = 0;
  3310. new T3D:string[256], T3D:module_name[20];
  3311. format(T3D:string,sizeof(T3D:string),"3D");
  3312. for(new i = 0; i < _:(Tryg3D::Module); i++){
  3313. if(Tryg3D::IsModuleLoaded(Tryg3D::Module:i)){
  3314. Tryg3D::GetModuleName(Tryg3D::Module:i,T3D:module_name);
  3315. format(T3D:string,sizeof(T3D:string),"%s:%s",T3D:string,T3D:module_name);
  3316. modules_count++;
  3317. }
  3318. }
  3319. return T3D:string;
  3320. }
  3321. #if defined Tryg3D_ATM
  3322. /************************************************************************************************************************************
  3323. * *
  3324. * ATM Module Functions *
  3325. * Code anti-collision: YES *
  3326. * *
  3327. ************************************************************************************************************************************/
  3328. #if !defined randomex
  3329. #define randomex(%0,%1) (random((%1)-(%0)+1)+(%0))
  3330. #endif
  3331. #define Tryg3D_KeyPressed(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  3332. #define Tryg3D_KeyReleased(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  3333. #define Tryg3D_KeyHolding(%0) ((newkeys & (%0)) == (%0))
  3334. //%d:%02d:%02d:%02d
  3335. #define Tryg3D_SecToTimeDay(%0) ((%0) / 86400),(((%0) % 86400) / 3600),((((%0) % 86400) % 3600) / 60),((((%0) % 86400) % 3600) % 60)
  3336. #define Tryg3D_MSToTimeDay(%0) Tryg3D_SecToTimeDay((%0)/1000)
  3337. //%02d:%02d:%02d
  3338. #define Tryg3D_SecToTime(%0) ((%0) / 3600),(((%0) % 3600) / 60),(((%0) % 3600) % 60)
  3339. #define Tryg3D_MSToTime(%0) Tryg3D_SecToTime((%0)/1000)
  3340. //%02d:%02d
  3341. #define Tryg3D_SecToTimeMini(%0) ((%0) / 60),((%0) % 60)
  3342. #define Tryg3D_MSToTimeMini(%0) Tryg3D_SecToTimeMini((%0)/1000)
  3343. #define v3Dfunction%0(%1) forward %0(%1); public %0(%1)
  3344. Tryg3D::Function:: Tryg3D::GetSAMIncludeVersion(value,name[],maxdest = sizeof(name)){
  3345. format(name,maxdest,"%d.%d.%d",(value / 10000),((value % 10000) / 100),((value % 10000) % 100));
  3346. }
  3347. Tryg3D::Function:: Tryg3D::DisableADMLogging(bool:disable){
  3348. if(disable){
  3349. SetSVarInt("ADM:Logging:Disable",1);
  3350. } else {
  3351. SetSVarInt("ADM:Logging:Disable",0);
  3352. }
  3353. }
  3354. #endif
  3355. #if defined Tryg3D_Actor
  3356. /************************************************************************************************************************************
  3357. * *
  3358. * Actor Functions *
  3359. * *
  3360. ************************************************************************************************************************************/
  3361. #define GetActorDistanceFromPoint(%0,%1,%2,%3) GetElementDistanceFromPoint((%0),item_actor,(%1),(%2),(%3))
  3362. #define GetPlayerActorDistance(%1,%2) GetElementsDistance((%1),item_player,(%1),item_actor)
  3363. #define IsActorInRangeOfPoint(%0,%1,%2,%3,%4) (GetElementDistanceFromPoint((%0),item_actor,(%2),(%3),(%4)) <= (%1))
  3364. Tryg3D::Function:: CountActors(){
  3365. new T3D:count = 0;
  3366. for(new i = 0, j = GetActorPoolSize(); i <= j; i++){
  3367. if(IsValidActor(i)){
  3368. T3D:count++;
  3369. }
  3370. }
  3371. return T3D:count;
  3372. }
  3373. Tryg3D::Function:: CountVisibleActors(playerid){
  3374. new T3D:count = 0;
  3375. for(new i = 0, j = GetActorPoolSize(); i <= j; i++){
  3376. if(IsValidActor(i) && IsActorStreamedIn(i,playerid)){
  3377. T3D:count++;
  3378. }
  3379. }
  3380. return T3D:count;
  3381. }
  3382. #endif
  3383. #if defined Tryg3D_Stream3D
  3384. /************************************************************************************************************************************
  3385. * *
  3386. * Stream3D Functions *
  3387. * *
  3388. ************************************************************************************************************************************/
  3389. #define StreamCreate(%0) Stream:%0[Stream3D]
  3390. #define GetStreamType(%0) (%0[T3D:type])
  3391. Tryg3D::Function:: IsValidStream(Stream:StreamData[Stream3D]){
  3392. return (StreamData[T3D:type] != s_invalid);
  3393. }
  3394. Tryg3D::Function:: Stream:StreamCircle(Float:x,Float:y,Float:radius){
  3395. new StreamCreate(StreamData);
  3396. StreamData[T3D:type] = s_circle;
  3397. StreamData[T3D:X] = x;
  3398. StreamData[T3D:Y] = y;
  3399. StreamData[T3D:R] = radius;
  3400. return StreamData;
  3401. }
  3402. Tryg3D::Function:: Stream:StreamCylinder3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:radius){
  3403. new StreamCreate(StreamData);
  3404. StreamData[T3D:type] = s_cylinder3d;
  3405. StreamData[T3D:minX] = xA;
  3406. StreamData[T3D:minY] = yA;
  3407. StreamData[T3D:minZ] = zA;
  3408. StreamData[T3D:maxX] = xB;
  3409. StreamData[T3D:maxY] = yB;
  3410. StreamData[T3D:maxZ] = zB;
  3411. StreamData[T3D:R] = radius;
  3412. return StreamData;
  3413. }
  3414. Tryg3D::Function:: Stream:StreamCone3D(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:pointA_radius,Float:pointB_radius){
  3415. new StreamCreate(StreamData);
  3416. StreamData[T3D:type] = s_cone;
  3417. StreamData[T3D:minX] = xA;
  3418. StreamData[T3D:minY] = yA;
  3419. StreamData[T3D:minZ] = zA;
  3420. StreamData[T3D:maxX] = xB;
  3421. StreamData[T3D:maxY] = yB;
  3422. StreamData[T3D:maxZ] = zB;
  3423. StreamData[T3D:X] = pointA_radius;
  3424. StreamData[T3D:Y] = pointB_radius;
  3425. return StreamData;
  3426. }
  3427. Tryg3D::Function:: Stream:StreamCube3D(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:size_x,Float:size_y,Float:size_z){
  3428. new StreamCreate(StreamData);
  3429. StreamData[T3D:type] = s_cube3d;
  3430. StreamData[T3D:X] = x;
  3431. StreamData[T3D:Y] = y;
  3432. StreamData[T3D:Z] = z;
  3433. StreamData[T3D:minX] = rx;
  3434. StreamData[T3D:minY] = ry;
  3435. StreamData[T3D:minZ] = rz;
  3436. StreamData[T3D:maxX] = size_x;
  3437. StreamData[T3D:maxY] = size_y;
  3438. StreamData[T3D:maxZ] = size_z;
  3439. return StreamData;
  3440. }
  3441. Tryg3D::Function:: Stream:StreamCylinder2D(Float:x,Float:y,Float:minz,Float:maxz,Float:radius){
  3442. new StreamCreate(StreamData);
  3443. StreamData[T3D:type] = s_cylinder2d;
  3444. StreamData[T3D:X] = x;
  3445. StreamData[T3D:Y] = y;
  3446. StreamData[T3D:minZ] = minz;
  3447. StreamData[T3D:maxZ] = maxz;
  3448. StreamData[T3D:R] = radius;
  3449. return StreamData;
  3450. }
  3451. Tryg3D::Function:: Stream:StreamSphere(Float:x,Float:y,Float:z,Float:radius){
  3452. new StreamCreate(StreamData);
  3453. StreamData[T3D:type] = s_sphere;
  3454. StreamData[T3D:X] = x;
  3455. StreamData[T3D:Y] = y;
  3456. StreamData[T3D:Z] = z;
  3457. StreamData[T3D:R] = radius;
  3458. return StreamData;
  3459. }
  3460. Tryg3D::Function:: Stream:StreamRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy){
  3461. new StreamCreate(StreamData);
  3462. StreamData[T3D:type] = s_rectangle;
  3463. StreamData[T3D:minX] = minx;
  3464. StreamData[T3D:minY] = miny;
  3465. StreamData[T3D:maxX] = maxx;
  3466. StreamData[T3D:maxY] = maxy;
  3467. return StreamData;
  3468. }
  3469. Tryg3D::Function:: Stream:StreamCube(Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz){
  3470. new StreamCreate(StreamData);
  3471. StreamData[T3D:type] = s_cube2d;
  3472. StreamData[T3D:minX] = minx;
  3473. StreamData[T3D:minY] = miny;
  3474. StreamData[T3D:minZ] = minz;
  3475. StreamData[T3D:maxX] = maxx;
  3476. StreamData[T3D:maxY] = maxy;
  3477. StreamData[T3D:maxZ] = maxz;
  3478. return StreamData;
  3479. }
  3480. Tryg3D::Function:: Stream:StreamCircularSector(Float:x,Float:y,Float:rz,Float:radius,Float:view_angle){
  3481. new StreamCreate(StreamData);
  3482. StreamData[T3D:type] = s_circularsector;
  3483. StreamData[T3D:X] = x;
  3484. StreamData[T3D:Y] = y;
  3485. StreamData[T3D:minZ] = rz;
  3486. StreamData[T3D:R] = radius;
  3487. StreamData[T3D:maxZ] = view_angle;
  3488. return StreamData;
  3489. }
  3490. Tryg3D::Function:: Stream:StreamSphericalSector(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,Float:vrx,Float:vrz){
  3491. new StreamCreate(StreamData);
  3492. StreamData[T3D:type] = s_sphericalsector;
  3493. StreamData[T3D:X] = x;
  3494. StreamData[T3D:Y] = y;
  3495. StreamData[T3D:Z] = z;
  3496. StreamData[T3D:minX] = rx;
  3497. StreamData[T3D:minZ] = rz;
  3498. StreamData[T3D:R] = radius;
  3499. StreamData[T3D:maxX] = vrx;
  3500. StreamData[T3D:maxZ] = vrz;
  3501. return StreamData;
  3502. }
  3503. Tryg3D::Function:: Stream:StreamEllipse(Float:cx,Float:cy,Float:size_x,Float:size_y){
  3504. new StreamCreate(StreamData);
  3505. StreamData[T3D:type] = s_ellipse;
  3506. StreamData[T3D:X] = cx;
  3507. StreamData[T3D:Y] = cy;
  3508. StreamData[T3D:minX] = size_x;
  3509. StreamData[T3D:minY] = size_y;
  3510. return StreamData;
  3511. }
  3512. Tryg3D::Function:: Stream:StreamEllipticalCylinder2D(Float:cx,Float:cy,Float:minz,Float:maxz,Float:size_x,Float:size_y){
  3513. new StreamCreate(StreamData);
  3514. StreamData[T3D:type] = s_ellipticalcyl2d;
  3515. StreamData[T3D:X] = cx;
  3516. StreamData[T3D:Y] = cy;
  3517. StreamData[T3D:minZ] = minz;
  3518. StreamData[T3D:maxZ] = maxz;
  3519. StreamData[T3D:minX] = size_x;
  3520. StreamData[T3D:minY] = size_y;
  3521. return StreamData;
  3522. }
  3523. Tryg3D::Function:: IsPointInStream(Float:x,Float:y,Float:z,Stream:StreamData[Stream3D]){
  3524. switch(StreamData[T3D:type]){
  3525. case s_circle: return IsPointInCircle(x,y,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:R]);
  3526. case s_cylinder3d: return IsPointInCylinder3D(x,y,z,StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],StreamData[T3D:R]);
  3527. case s_cylinder2d: return IsPointInCylinder2D(x,y,z,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:maxZ],StreamData[T3D:R]);
  3528. case s_sphere: return IsPointInSphere(x,y,z,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:R]);
  3529. case s_rectangle: return IsPointInRectangle(x,y,StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:maxX],StreamData[T3D:maxY]);
  3530. case s_cube2d: return IsPointInCube(x,y,z,StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ]);
  3531. case s_circularsector: return IsPointInCircularSector(x,y,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:R],StreamData[T3D:maxZ]);
  3532. case s_sphericalsector: return IsPointInSphericalSector(x,y,z,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:minX],StreamData[T3D:minZ],StreamData[T3D:R],StreamData[T3D:maxX],StreamData[T3D:maxZ]);
  3533. case s_cone: return IsPointInCone3D(x,y,z,StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],StreamData[T3D:X],StreamData[T3D:Y]);
  3534. case s_cube3d: return IsPointInCube3D(x,y,z,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ]);
  3535. case s_ellipse: return IsPointInEllipse(x,y,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minX],StreamData[T3D:minY]);
  3536. case s_ellipticalcyl2d: return IsPointInEllipticalCylinder2D(x,y,z,StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:maxZ],StreamData[T3D:minX],StreamData[T3D:minY]);
  3537. }
  3538. return 0;
  3539. }
  3540. Tryg3D::Function:: GetRandomPointInStream(Stream:StreamData[Stream3D],&Float:x,&Float:y,&Float:z){
  3541. switch(StreamData[T3D:type]){
  3542. case s_circle: {
  3543. GetRandomPointInCircle(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:R],x,y);
  3544. z = FLOAT_INFINITY;
  3545. return 1;
  3546. }
  3547. case s_cylinder3d: {
  3548. GetRandomPointInCylinder3D(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],StreamData[T3D:R],x,y,z);
  3549. return 1;
  3550. }
  3551. case s_cylinder2d: {
  3552. GetRandomPointInCylinder2D(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:maxZ],StreamData[T3D:R],x,y,z);
  3553. return 1;
  3554. }
  3555. case s_sphere: {
  3556. GetRandomPointInSphere(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:R],x,y,z);
  3557. return 1;
  3558. }
  3559. case s_rectangle: {
  3560. GetRandomPointInRectangle(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:maxX],StreamData[T3D:maxY],x,y);
  3561. z = FLOAT_INFINITY;
  3562. return 1;
  3563. }
  3564. case s_cube2d: {
  3565. GetRandomPointInCube(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],x,y,z);
  3566. return 1;
  3567. }
  3568. case s_circularsector: {
  3569. GetRandomPointInCircularSector(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:R],StreamData[T3D:maxZ],x,y);
  3570. z = FLOAT_INFINITY;
  3571. return 1;
  3572. }
  3573. case s_sphericalsector: {
  3574. GetRandomPointInSphericalSector(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:minX],StreamData[T3D:minZ],StreamData[T3D:R],StreamData[T3D:maxX],StreamData[T3D:maxZ],x,y,z);
  3575. return 1;
  3576. }
  3577. case s_cone: {
  3578. GetRandomPointInCone3D(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],StreamData[T3D:X],StreamData[T3D:Y],x,y,z);
  3579. return 1;
  3580. }
  3581. case s_cube3d: {
  3582. GetRandomPointInCube3D(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],x,y,z);
  3583. return 1;
  3584. }
  3585. case s_ellipse: {
  3586. GetRandomPointInEllipse(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minX],StreamData[T3D:minY],x,y);
  3587. z = FLOAT_INFINITY;
  3588. return 1;
  3589. }
  3590. case s_ellipticalcyl2d: {
  3591. GetRandomPointInEllipticalCyl2D(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:maxZ],StreamData[T3D:minX],StreamData[T3D:minY],x,y,z);
  3592. return 1;
  3593. }
  3594. }
  3595. return 0;
  3596. }
  3597. Tryg3D::Function:: GetRandomPointOnStream(Stream:StreamData[Stream3D],&Float:x,&Float:y,&Float:z){
  3598. switch(StreamData[T3D:type]){
  3599. case s_circle: {
  3600. GetRandomPointOnCircle(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:R],x,y);
  3601. z = FLOAT_INFINITY;
  3602. return 1;
  3603. }
  3604. case s_cylinder3d: {
  3605. GetRandomPointOnCylinder3D(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],StreamData[T3D:R],x,y,z);
  3606. return 1;
  3607. }
  3608. case s_cylinder2d: {
  3609. GetRandomPointOnCylinder2D(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:maxZ],StreamData[T3D:R],x,y,z);
  3610. return 1;
  3611. }
  3612. case s_sphere: {
  3613. GetRandomPointOnSphere(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:R],x,y,z);
  3614. return 1;
  3615. }
  3616. case s_rectangle: {
  3617. GetRandomPointOnRectangle(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:maxX],StreamData[T3D:maxY],x,y);
  3618. z = FLOAT_INFINITY;
  3619. return 1;
  3620. }
  3621. case s_cube2d: {
  3622. GetRandomPointOnCube(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],x,y,z);
  3623. return 1;
  3624. }
  3625. case s_circularsector: {
  3626. GetRandomPointOnCircularSector(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:R],StreamData[T3D:maxZ],x,y);
  3627. z = FLOAT_INFINITY;
  3628. return 1;
  3629. }
  3630. case s_sphericalsector: {
  3631. GetRandomPointOnSphericalSector(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:minX],StreamData[T3D:minZ],StreamData[T3D:R],StreamData[T3D:maxX],StreamData[T3D:maxZ],x,y,z);
  3632. return 1;
  3633. }
  3634. case s_cone: {
  3635. GetRandomPointOnCone3D(StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],StreamData[T3D:X],StreamData[T3D:Y],x,y,z);
  3636. return 1;
  3637. }
  3638. case s_cube3d: {
  3639. GetRandomPointOnCube3D(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:Z],StreamData[T3D:minX],StreamData[T3D:minY],StreamData[T3D:minZ],StreamData[T3D:maxX],StreamData[T3D:maxY],StreamData[T3D:maxZ],x,y,z);
  3640. return 1;
  3641. }
  3642. case s_ellipse: {
  3643. GetRandomPointOnEllipse(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minX],StreamData[T3D:minY],x,y);
  3644. z = FLOAT_INFINITY;
  3645. return 1;
  3646. }
  3647. case s_ellipticalcyl2d: {
  3648. GetRandomPointOnEllipticalCyl2D(StreamData[T3D:X],StreamData[T3D:Y],StreamData[T3D:minZ],StreamData[T3D:maxZ],StreamData[T3D:minX],StreamData[T3D:minY],x,y,z);
  3649. return 1;
  3650. }
  3651. }
  3652. return 0;
  3653. }
  3654. Tryg3D::Function:: IsElementInStream(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Stream:StreamData[Stream3D]){
  3655. new Float:px,Float:py,Float:pz;
  3656. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  3657. return IsPointInStream(px,py,pz,StreamData);
  3658. }
  3659. Tryg3D::Function:: IsVehicleFullyInStream(vehicleid,Stream:StreamData[Stream3D]){
  3660. new Float:size_x,Float:size_y,Float:size_z,
  3661. Float:x,Float:y,Float:z,
  3662. Float:minx,Float:miny,Float:minz,
  3663. Float:maxx,Float:maxy,Float:maxz;
  3664. GetVehicleModelInfo(GetVehicleModel(vehicleid),VEHICLE_MODEL_INFO_SIZE,size_x,size_y,size_z);
  3665. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  3666. GetVehiclePos(vehicleid,x,y,z);
  3667. minx = x - size_x;
  3668. miny = y - size_y;
  3669. minz = z - size_z;
  3670. maxx = x + size_x;
  3671. maxy = y + size_y;
  3672. maxz = z + size_z;
  3673. if(!IsPointInStream(minx,miny,minz,StreamData)) return 0;
  3674. if(!IsPointInStream(minx,miny,maxz,StreamData)) return 0;
  3675. if(!IsPointInStream(minx,maxy,minz,StreamData)) return 0;
  3676. if(!IsPointInStream(minx,maxy,maxz,StreamData)) return 0;
  3677. if(!IsPointInStream(maxx,miny,minz,StreamData)) return 0;
  3678. if(!IsPointInStream(maxx,miny,maxz,StreamData)) return 0;
  3679. if(!IsPointInStream(maxx,maxy,minz,StreamData)) return 0;
  3680. if(!IsPointInStream(maxx,maxy,maxz,StreamData)) return 0;
  3681. return 1;
  3682. }
  3683. Tryg3D::Function:: GetElementsInStream(Stream:StreamData[Stream3D],Item3D_Type:element_type,element_list[],max_element=sizeof(element_list)){
  3684. new T3D:cnt = 0, T3D:upp = -1;
  3685. switch(element_type){
  3686. case item_player: {
  3687. Tryg3D::Foreach(i){
  3688. if(T3D:upp >= max_element) break;
  3689. if(!IsPlayerNPC(i)){
  3690. if(IsElementInStream(i,element_type,StreamData)){
  3691. element_list[T3D:upp++] = i;
  3692. T3D:cnt++;
  3693. }
  3694. }
  3695. }
  3696. }
  3697. case item_npc: {
  3698. Tryg3D::Foreach(i){
  3699. if(T3D:upp >= max_element) break;
  3700. if(IsPlayerNPC(i)){
  3701. if(IsElementInStream(i,element_type,StreamData)){
  3702. element_list[T3D:upp++] = i;
  3703. T3D:cnt++;
  3704. }
  3705. }
  3706. }
  3707. }
  3708. #if defined Tryg3D_Actor
  3709. case item_actor: {
  3710. for(new i = 0, j = GetActorPoolSize(); i <= j; i++){
  3711. if(T3D:upp >= max_element) break;
  3712. if(IsValidActor(i) && IsElementInStream(i,element_type,StreamData)){
  3713. element_list[T3D:upp++] = i;
  3714. T3D:cnt++;
  3715. }
  3716. }
  3717. }
  3718. #endif
  3719. case item_object: {
  3720. for(new i = 0; i < MAX_OBJECTS; i++){
  3721. if(T3D:upp >= max_element) break;
  3722. if(IsValidObject(i) && IsElementInStream(i,element_type,StreamData)){
  3723. element_list[T3D:upp++] = i;
  3724. T3D:cnt++;
  3725. }
  3726. }
  3727. }
  3728. case item_vehicle: {
  3729. for(new i = 0, j = GetVehiclePoolSize(); i <= j; i++){
  3730. if(T3D:upp >= max_element) break;
  3731. if(IsValidVehicle(i) && IsElementInStream(i,element_type,StreamData)){
  3732. element_list[T3D:upp++] = i;
  3733. T3D:cnt++;
  3734. }
  3735. }
  3736. }
  3737. #if defined Tryg3D_Streamer
  3738. case item_dynamic_object: {
  3739. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_OBJECT); i <= j; i++){
  3740. if(IsValidDynamicObject(STREAMER_TAG_OBJECT i)){
  3741. if(T3D:upp >= max_element) break;
  3742. if(IsElementInStream(i,element_type,StreamData)){
  3743. element_list[T3D:upp++] = i;
  3744. T3D:cnt++;
  3745. }
  3746. }
  3747. }
  3748. }
  3749. case item_dynamic_pickup: {
  3750. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_PICKUP); i <= j; i++){
  3751. if(IsValidDynamicPickup(STREAMER_TAG_PICKUP i)){
  3752. if(T3D:upp >= max_element) break;
  3753. if(IsElementInStream(i,element_type,StreamData)){
  3754. element_list[T3D:upp++] = i;
  3755. T3D:cnt++;
  3756. }
  3757. }
  3758. }
  3759. }
  3760. case item_dynamic_cp: {
  3761. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_CP); i <= j; i++){
  3762. if(IsValidDynamicCP(STREAMER_TAG_CP i)){
  3763. if(T3D:upp >= max_element) break;
  3764. if(IsElementInStream(i,element_type,StreamData)){
  3765. element_list[T3D:upp++] = i;
  3766. T3D:cnt++;
  3767. }
  3768. }
  3769. }
  3770. }
  3771. case item_dynamic_racecp: {
  3772. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_RACE_CP); i <= j; i++){
  3773. if(IsValidDynamicRaceCP(STREAMER_TAG_RACE_CP i)){
  3774. if(T3D:upp >= max_element) break;
  3775. if(IsElementInStream(i,element_type,StreamData)){
  3776. element_list[T3D:upp++] = i;
  3777. T3D:cnt++;
  3778. }
  3779. }
  3780. }
  3781. }
  3782. case item_dynamic_mapicon: {
  3783. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_MAP_ICON); i <= j; i++){
  3784. if(IsValidDynamicMapIcon(STREAMER_TAG_MAP_ICON i)){
  3785. if(T3D:upp >= max_element) break;
  3786. if(IsElementInStream(i,element_type,StreamData)){
  3787. element_list[T3D:upp++] = i;
  3788. T3D:cnt++;
  3789. }
  3790. }
  3791. }
  3792. }
  3793. case item_dynamic_3dtext: {
  3794. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_3D_TEXT_LABEL); i <= j; i++){
  3795. if(IsValidDynamic3DTextLabel(STREAMER_TAG_3D_TEXT_LABEL i)){
  3796. if(T3D:upp >= max_element) break;
  3797. if(IsElementInStream(i,element_type,StreamData)){
  3798. element_list[T3D:upp++] = i;
  3799. T3D:cnt++;
  3800. }
  3801. }
  3802. }
  3803. }
  3804. case item_dynamic_actor: {
  3805. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_ACTOR); i <= j; i++){
  3806. if(IsValidDynamicActor(STREAMER_TAG_ACTOR i)){
  3807. if(T3D:upp >= max_element) break;
  3808. if(IsElementInStream(i,element_type,StreamData)){
  3809. element_list[T3D:upp++] = i;
  3810. T3D:cnt++;
  3811. }
  3812. }
  3813. }
  3814. }
  3815. #endif
  3816. #if defined Tryg3D_VehicleStreamer
  3817. case item_dynamic_vehicle: {
  3818. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_VEHICLE); i <= j; i++){
  3819. if(IsValidDynamicVehicle(STREAMER_TAG_VEHICLE i)){
  3820. if(T3D:upp >= max_element) break;
  3821. if(IsElementInStream(i,element_type,StreamData)){
  3822. element_list[T3D:upp++] = i;
  3823. T3D:cnt++;
  3824. }
  3825. }
  3826. }
  3827. }
  3828. #endif
  3829. #if defined Tryg3D_FCNPC
  3830. case item_fcnpc: {
  3831. Tryg3D::Foreach(i){
  3832. if(T3D:upp >= max_element) break;
  3833. if(IsPlayerNPC(i) && FCNPC::IsValid(i)){
  3834. if(IsElementInStream(i,element_type,StreamData)){
  3835. element_list[T3D:upp++] = i;
  3836. T3D:cnt++;
  3837. }
  3838. }
  3839. }
  3840. }
  3841. #endif
  3842. }
  3843. return T3D:cnt;
  3844. }
  3845. #if defined Tryg3D_Streamer
  3846. Tryg3D::Function:: Stream:ConvertAreaToStream(STREAMER_TAG_AREA areaid){
  3847. new StreamCreate(StreamData);
  3848. if(!IsValidDynamicArea(STREAMER_TAG_AREA areaid)) return StreamData;
  3849. switch(Streamer::GetIntData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_TYPE)){
  3850. case STREAMER_AREA_TYPE_CIRCLE: {
  3851. StreamData[T3D:type] = s_circle;
  3852. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_X,StreamData[T3D:X]);
  3853. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Y,StreamData[T3D:Y]);
  3854. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_SIZE,StreamData[T3D:R]);
  3855. }
  3856. case STREAMER_AREA_TYPE_CYLINDER: {
  3857. StreamData[T3D:type] = s_cylinder2d;
  3858. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_X,StreamData[T3D:X]);
  3859. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Y,StreamData[T3D:Y]);
  3860. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Z,StreamData[T3D:minZ]);
  3861. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Z,StreamData[T3D:maxZ]);
  3862. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_SIZE,StreamData[T3D:R]);
  3863. }
  3864. case STREAMER_AREA_TYPE_SPHERE: {
  3865. StreamData[T3D:type] = s_sphere;
  3866. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_X,StreamData[T3D:X]);
  3867. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Y,StreamData[T3D:Y]);
  3868. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Z,StreamData[T3D:Z]);
  3869. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_SIZE,StreamData[T3D:R]);
  3870. }
  3871. case STREAMER_AREA_TYPE_RECTANGLE: {
  3872. StreamData[T3D:type] = s_rectangle;
  3873. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_X,StreamData[T3D:minX]);
  3874. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Y,StreamData[T3D:minY]);
  3875. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_X,StreamData[T3D:maxX]);
  3876. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Y,StreamData[T3D:maxY]);
  3877. }
  3878. case STREAMER_AREA_TYPE_CUBOID: {
  3879. StreamData[T3D:type] = s_cube2d;
  3880. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_X,StreamData[T3D:minX]);
  3881. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Y,StreamData[T3D:minY]);
  3882. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Z,StreamData[T3D:minZ]);
  3883. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_X,StreamData[T3D:maxX]);
  3884. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Y,StreamData[T3D:maxY]);
  3885. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Z,StreamData[T3D:maxZ]);
  3886. }
  3887. }
  3888. return StreamData;
  3889. }
  3890. #endif
  3891. #endif
  3892. #if defined Tryg3D_Streamer
  3893. /************************************************************************************************************************************
  3894. * *
  3895. * Streamer Functions *
  3896. * *
  3897. ************************************************************************************************************************************/
  3898. #define IsDynamicObjectInRangeOfPoint(%0,%1,%2,%3,%4) (GetElementDistanceFromPoint((%0),item_dynamic_object,(%2),(%3),(%4)) <= (%1))
  3899. #define IsDynamicActorInRangeOfPoint(%0,%1,%2,%3,%4) (GetElementDistanceFromPoint((%0),item_dynamic_actor,(%2),(%3),(%4)) <= (%1))
  3900. Tryg3D::Function:: SetPlayerAbsolutePosition(playerid,Float:x,Float:y,Float:z,Float:angle,worldid = -1,interiorid = -1,compensatedtime = -1,freezeplayer = 1){
  3901. Streamer::UpdateEx(playerid,x,y,z,worldid,interiorid,-1,compensatedtime,freezeplayer);
  3902. if(worldid != -1) SetPlayerVirtualWorld(playerid,worldid);
  3903. if(interiorid != -1) SetPlayerInterior(playerid,interiorid);
  3904. SetPlayerPos(playerid,x,y,z);
  3905. SetPlayerFacingAngle(playerid,angle);
  3906. SetCameraBehindPlayer(playerid);
  3907. }
  3908. Tryg3D::Function:: SetPlayerAbsolutePositionVeh(playerid,Float:x,Float:y,Float:z,Float:angle,worldid = -1,interiorid = -1,compensatedtime = -1,freezeplayer = 1){
  3909. new T3D:vehicleid = GetPlayerVehicleID(playerid), seatid;
  3910. if(T3D:vehicleid == 0){
  3911. SetPlayerAbsolutePosition(playerid,x,y,z,angle,worldid,interiorid,compensatedtime,freezeplayer);
  3912. } else {
  3913. SetPlayerAbsolutePosition(playerid,x,y,z,angle,worldid,interiorid,compensatedtime,freezeplayer);
  3914. if(worldid != -1) SetVehicleVirtualWorld(T3D:vehicleid,worldid);
  3915. if(interiorid != -1) LinkVehicleToInterior(T3D:vehicleid,interiorid);
  3916. SetVehiclePos(T3D:vehicleid,x,y,z);
  3917. SetVehicleZAngle(T3D:vehicleid,angle);
  3918. PutPlayerInVehicle(playerid,T3D:vehicleid,0);
  3919. if(worldid != -1 || interiorid != -1){
  3920. Tryg3D::Foreach(i){
  3921. if(GetPlayerVehicleID(i) == T3D:vehicleid && (seatid = GetPlayerVehicleSeat(i)) != 0){
  3922. if(worldid != -1) SetPlayerVirtualWorld(i,worldid);
  3923. if(interiorid != -1) SetPlayerInterior(i,interiorid);
  3924. PutPlayerInVehicle(i,T3D:vehicleid,seatid);
  3925. }
  3926. }
  3927. }
  3928. }
  3929. }
  3930. Tryg3D::Function:: IsVehicleFullyInDynamicArea(vehicleid,STREAMER_TAG_AREA areaid){
  3931. new Float:size_x,Float:size_y,Float:size_z,
  3932. Float:x,Float:y,Float:z,
  3933. Float:minx,Float:miny,Float:minz,
  3934. Float:maxx,Float:maxy,Float:maxz;
  3935. GetVehicleModelInfo(GetVehicleModel(vehicleid),VEHICLE_MODEL_INFO_SIZE,size_x,size_y,size_z);
  3936. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  3937. GetVehiclePos(vehicleid,x,y,z);
  3938. minx = x - size_x;
  3939. miny = y - size_y;
  3940. minz = z - size_z;
  3941. maxx = x + size_x;
  3942. maxy = y + size_y;
  3943. maxz = z + size_z;
  3944. if(!IsPointInDynamicArea(areaid,minx,miny,minz)) return 0;
  3945. if(!IsPointInDynamicArea(areaid,minx,miny,maxz)) return 0;
  3946. if(!IsPointInDynamicArea(areaid,minx,maxy,minz)) return 0;
  3947. if(!IsPointInDynamicArea(areaid,minx,maxy,maxz)) return 0;
  3948. if(!IsPointInDynamicArea(areaid,maxx,miny,minz)) return 0;
  3949. if(!IsPointInDynamicArea(areaid,maxx,miny,maxz)) return 0;
  3950. if(!IsPointInDynamicArea(areaid,maxx,maxy,minz)) return 0;
  3951. if(!IsPointInDynamicArea(areaid,maxx,maxy,maxz)) return 0;
  3952. return 1;
  3953. }
  3954. Tryg3D::Function:: GetRandomPointInDynamicArea(STREAMER_TAG_AREA areaid,&Float:tx,&Float:ty,&Float:tz){
  3955. switch(Streamer::GetIntData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_TYPE)){
  3956. case STREAMER_AREA_TYPE_CIRCLE: {
  3957. new Float:x,Float:y,Float:size;
  3958. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_X,x);
  3959. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Y,y);
  3960. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_SIZE,size);
  3961. GetRandomPointInCircle(x,y,size,tx,ty);
  3962. tz = FLOAT_INFINITY;
  3963. return 1;
  3964. }
  3965. case STREAMER_AREA_TYPE_CYLINDER: {
  3966. new Float:x,Float:y,Float:size,Float:minz,Float:maxz;
  3967. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_X,x);
  3968. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Y,y);
  3969. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Z,minz);
  3970. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Z,maxz);
  3971. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_SIZE,size);
  3972. GetRandomPointInCylinder2D(x,y,minz,maxz,size,tx,ty,tz);
  3973. return 1;
  3974. }
  3975. case STREAMER_AREA_TYPE_SPHERE: {
  3976. new Float:x,Float:y,Float:z,Float:size;
  3977. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_X,x);
  3978. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Y,y);
  3979. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_Z,z);
  3980. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_SIZE,size);
  3981. GetRandomPointInSphere(x,y,z,size,tx,ty,tz);
  3982. return 1;
  3983. }
  3984. case STREAMER_AREA_TYPE_RECTANGLE: {
  3985. new Float:minx,Float:miny,Float:maxx,Float:maxy;
  3986. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_X,minx);
  3987. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Y,miny);
  3988. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_X,maxx);
  3989. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Y,maxy);
  3990. GetRandomPointInRectangle(minx,miny,maxx,maxy,tx,ty);
  3991. tz = FLOAT_INFINITY;
  3992. return 1;
  3993. }
  3994. case STREAMER_AREA_TYPE_CUBOID: {
  3995. new Float:minx,Float:miny,Float:minz,Float:maxx,Float:maxy,Float:maxz;
  3996. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_X,minx);
  3997. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Y,miny);
  3998. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MIN_Z,minz);
  3999. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_X,maxx);
  4000. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Y,maxy);
  4001. Streamer::GetFloatData(STREAMER_TYPE_AREA,_:areaid,E_STREAMER_MAX_Z,maxz);
  4002. GetRandomPointInCube(minx,miny,minz,maxx,maxy,maxz,tx,ty,tz);
  4003. return 1;
  4004. }
  4005. }
  4006. return 0;
  4007. }
  4008. Tryg3D::Function:: STREAMER_TAG_OBJECT IPL_CreateDynamicObject(modelid,Float:x,Float:y,Float:z,Float:qx,Float:qy,Float:qz,Float:qw,worldid=-1,interiorid=-1,playerid=-1,Float:streamdistance=STREAMER_OBJECT_SD,Float:drawdistance=STREAMER_OBJECT_DD,STREAMER_TAG_AREA areaid=STREAMER_TAG_AREA -1,priority=0){
  4009. new Float:rx,Float:ry,Float:rz;
  4010. Tryg3D::QuatToEuler(rx,ry,rz,qw,qx,qy,qz);
  4011. return CreateDynamicObject(modelid,x,y,z,rx,ry,rz,worldid,interiorid,playerid,streamdistance,drawdistance,areaid,priority);
  4012. }
  4013. Tryg3D::Function:: IsElementInDynamicArea(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,STREAMER_TAG_AREA areaid){
  4014. new Float:px,Float:py,Float:pz;
  4015. if(!GetElementPos(elementid,element_type,px,py,pz)) return 0;
  4016. return IsPointInDynamicArea(areaid,px,py,pz);
  4017. }
  4018. Tryg3D::Function:: GetElementsInDynamicArea(STREAMER_TAG_AREA areaid,Item3D_Type:element_type,element_list[],max_element=sizeof(element_list)){
  4019. new T3D:cnt = 0, T3D:upp = -1;
  4020. switch(element_type){
  4021. case item_player: {
  4022. Tryg3D::Foreach(i){
  4023. if(T3D:upp >= max_element) break;
  4024. if(!IsPlayerNPC(i)){
  4025. if(IsElementInDynamicArea(i,element_type,areaid)){
  4026. element_list[T3D:upp++] = i;
  4027. T3D:cnt++;
  4028. }
  4029. }
  4030. }
  4031. }
  4032. case item_npc: {
  4033. Tryg3D::Foreach(i){
  4034. if(T3D:upp >= max_element) break;
  4035. if(IsPlayerNPC(i)){
  4036. if(IsElementInDynamicArea(i,element_type,areaid)){
  4037. element_list[T3D:upp++] = i;
  4038. T3D:cnt++;
  4039. }
  4040. }
  4041. }
  4042. }
  4043. #if defined Tryg3D_Actor
  4044. case item_actor: {
  4045. for(new i = 0, j = GetActorPoolSize(); i <= j; i++){
  4046. if(T3D:upp >= max_element) break;
  4047. if(IsValidActor(i) && IsElementInDynamicArea(i,element_type,areaid)){
  4048. element_list[T3D:upp++] = i;
  4049. T3D:cnt++;
  4050. }
  4051. }
  4052. }
  4053. #endif
  4054. case item_object: {
  4055. for(new i = 0; i < MAX_OBJECTS; i++){
  4056. if(T3D:upp >= max_element) break;
  4057. if(IsValidObject(i) && IsElementInDynamicArea(i,element_type,areaid)){
  4058. element_list[T3D:upp++] = i;
  4059. T3D:cnt++;
  4060. }
  4061. }
  4062. }
  4063. case item_vehicle: {
  4064. for(new i = 0, j = GetVehiclePoolSize(); i <= j; i++){
  4065. if(T3D:upp >= max_element) break;
  4066. if(IsValidVehicle(i) && IsElementInDynamicArea(i,element_type,areaid)){
  4067. element_list[T3D:upp++] = i;
  4068. T3D:cnt++;
  4069. }
  4070. }
  4071. }
  4072. #if defined Tryg3D_Streamer
  4073. case item_dynamic_object: {
  4074. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_OBJECT); i <= j; i++){
  4075. if(IsValidDynamicObject(STREAMER_TAG_OBJECT i)){
  4076. if(T3D:upp >= max_element) break;
  4077. if(IsElementInDynamicArea(i,element_type,areaid)){
  4078. element_list[T3D:upp++] = i;
  4079. T3D:cnt++;
  4080. }
  4081. }
  4082. }
  4083. }
  4084. case item_dynamic_pickup: {
  4085. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_PICKUP); i <= j; i++){
  4086. if(IsValidDynamicPickup(STREAMER_TAG_PICKUP i)){
  4087. if(T3D:upp >= max_element) break;
  4088. if(IsElementInDynamicArea(i,element_type,areaid)){
  4089. element_list[T3D:upp++] = i;
  4090. T3D:cnt++;
  4091. }
  4092. }
  4093. }
  4094. }
  4095. case item_dynamic_cp: {
  4096. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_CP); i <= j; i++){
  4097. if(IsValidDynamicCP(STREAMER_TAG_CP i)){
  4098. if(T3D:upp >= max_element) break;
  4099. if(IsElementInDynamicArea(i,element_type,areaid)){
  4100. element_list[T3D:upp++] = i;
  4101. T3D:cnt++;
  4102. }
  4103. }
  4104. }
  4105. }
  4106. case item_dynamic_racecp: {
  4107. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_RACE_CP); i <= j; i++){
  4108. if(IsValidDynamicRaceCP(STREAMER_TAG_RACE_CP i)){
  4109. if(T3D:upp >= max_element) break;
  4110. if(IsElementInDynamicArea(i,element_type,areaid)){
  4111. element_list[T3D:upp++] = i;
  4112. T3D:cnt++;
  4113. }
  4114. }
  4115. }
  4116. }
  4117. case item_dynamic_mapicon: {
  4118. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_MAP_ICON); i <= j; i++){
  4119. if(IsValidDynamicMapIcon(STREAMER_TAG_MAP_ICON i)){
  4120. if(T3D:upp >= max_element) break;
  4121. if(IsElementInDynamicArea(i,element_type,areaid)){
  4122. element_list[T3D:upp++] = i;
  4123. T3D:cnt++;
  4124. }
  4125. }
  4126. }
  4127. }
  4128. case item_dynamic_3dtext: {
  4129. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_3D_TEXT_LABEL); i <= j; i++){
  4130. if(IsValidDynamic3DTextLabel(STREAMER_TAG_3D_TEXT_LABEL i)){
  4131. if(T3D:upp >= max_element) break;
  4132. if(IsElementInDynamicArea(i,element_type,areaid)){
  4133. element_list[T3D:upp++] = i;
  4134. T3D:cnt++;
  4135. }
  4136. }
  4137. }
  4138. }
  4139. case item_dynamic_actor: {
  4140. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_ACTOR); i <= j; i++){
  4141. if(IsValidDynamicActor(STREAMER_TAG_ACTOR i)){
  4142. if(T3D:upp >= max_element) break;
  4143. if(IsElementInDynamicArea(i,element_type,areaid)){
  4144. element_list[T3D:upp++] = i;
  4145. T3D:cnt++;
  4146. }
  4147. }
  4148. }
  4149. }
  4150. #endif
  4151. #if defined Tryg3D_VehicleStreamer
  4152. case item_dynamic_vehicle: {
  4153. for(new i = 1, j = Streamer::GetUpperBound(STREAMER_TYPE_VEHICLE); i <= j; i++){
  4154. if(IsValidDynamicVehicle(STREAMER_TAG_VEHICLE i)){
  4155. if(T3D:upp >= max_element) break;
  4156. if(IsElementInDynamicArea(i,element_type,areaid)){
  4157. element_list[T3D:upp++] = i;
  4158. T3D:cnt++;
  4159. }
  4160. }
  4161. }
  4162. }
  4163. #endif
  4164. #if defined Tryg3D_FCNPC
  4165. case item_fcnpc: {
  4166. Tryg3D::Foreach(i){
  4167. if(T3D:upp >= max_element) break;
  4168. if(IsPlayerNPC(i) && FCNPC::IsValid(i)){
  4169. if(IsElementInDynamicArea(i,element_type,areaid)){
  4170. element_list[T3D:upp++] = i;
  4171. T3D:cnt++;
  4172. }
  4173. }
  4174. }
  4175. }
  4176. #endif
  4177. }
  4178. return T3D:cnt;
  4179. }
  4180. #endif
  4181. #if defined Tryg3D_ColAndreas
  4182. /************************************************************************************************************************************
  4183. * *
  4184. * ColAndreas Functions *
  4185. * *
  4186. ************************************************************************************************************************************/
  4187. #define IsCollisionFlag(%0,%1) ((%0) & (%1))
  4188. #define IsPointInUnderwater(%1,%2,%3) (IsPointInWater((%1),(%2),(%3)) && ((%3) < -1.0))
  4189. #define GetPlayerCollisionFlags(%0) GetElementCollisionFlags((%0),item_player)
  4190. #define GetVehicleCollisionFlags(%0) GetElementCollisionFlags((%0),item_vehicle)
  4191. #define GetPointInFrontOnGround(%0,%1,%2,%3,%4,%5,%6,%7,%8) GetPointInFront3DCol((%0),(%1),(%2),(%3),(%4),(%8),(%5),(%6),(%7))
  4192. Tryg3D::Function:: MovePointCol(Float:StartX,Float:StartY,Float:StartZ,Float:EndX,Float:EndY,Float:EndZ,&Float:x,&Float:y,&Float:z){
  4193. x = y = z = 0.0;
  4194. ColAndreas::RayCastLine(StartX,StartY,StartZ,EndX,EndY,EndZ,x,y,z);
  4195. if(x == 0.0) x = EndX;
  4196. if(y == 0.0) y = EndY;
  4197. if(z == 0.0) z = EndZ;
  4198. }
  4199. Tryg3D::Function:: MovePointColCutLine(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,&Float:x,&Float:y,&Float:z,Float:cut_size=0.0){
  4200. new Float:radius, Float:rx, Float:rz;
  4201. x = y = z = 0.0;
  4202. ColAndreas::RayCastLine(sX,sY,sZ,eX,eY,eZ,x,y,z);
  4203. if(x == 0.0) x = eX;
  4204. if(y == 0.0) y = eY;
  4205. if(z == 0.0) z = eZ;
  4206. if((radius = GetDistanceBetweenPoints3D(sX,sY,sZ,x,y,z)) <= 0.0) return 0;
  4207. CompRotationFloat(-(acos((z-sZ)/radius)-90.0),rx);
  4208. CompRotationFloat((atan2(y-sY,x-sX)-90.0),rz);
  4209. if(radius-cut_size > 0.0) radius -= cut_size;
  4210. GetPointInFront3D(sX,sY,sZ,rx,rz,radius,x,y,z);
  4211. return 1;
  4212. }
  4213. Tryg3D::Function:: MovePointColCutLineEx(Float:sX,Float:sY,Float:sZ,Float:eX,Float:eY,Float:eZ,&Float:x,&Float:y,&Float:z,Float:cut_size=0.0){
  4214. new Float:radius, Float:rx, Float:rz;
  4215. x = y = z = 0.0;
  4216. ColAndreas::RayCastLine(sX,sY,sZ,eX,eY,eZ,x,y,z);
  4217. if(x == 0.0) x = eX;
  4218. if(y == 0.0) y = eY;
  4219. if(z == 0.0) z = eZ;
  4220. if((radius = GetDistanceBetweenPoints3D(sX,sY,sZ,x,y,z)) <= 0.0) return 0;
  4221. CompRotationFloat(-(acos((z-sZ)/radius)-90.0),rx);
  4222. CompRotationFloat((atan2(y-sY,x-sX)-90.0),rz);
  4223. if((radius-cut_size > cut_size) && (radius-cut_size > 0.0)){
  4224. radius -= cut_size;
  4225. } else {
  4226. radius = FLOAT_DEFECT;
  4227. }
  4228. GetPointInFront3D(sX,sY,sZ,rx,rz,radius,x,y,z);
  4229. return 1;
  4230. }
  4231. //GetPointInFront3D (ColAndreas)
  4232. Tryg3D::Function:: GetPointInFront3DCol(Float:x,Float:y,Float:z,Float:rx,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  4233. tx = x - (radius * floatcos(rx,degrees) * floatsin(rz,degrees));
  4234. ty = y + (radius * floatcos(rx,degrees) * floatcos(rz,degrees));
  4235. tz = z + (radius * floatsin(rx,degrees));
  4236. MovePointCol(x,y,z,tx,ty,tz,tx,ty,tz);
  4237. }
  4238. Tryg3D::Function:: GetPointInFront3DColEx(Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,Float:radius,&Float:tx,&Float:ty,&Float:tz){
  4239. new Float:vx,Float:vy,Float:vz,Float:trx,Float:trz;
  4240. Tryg3D::EulerRotate(rx,ry,rz,0.0,1.0,0.0,vx,vy,vz,T3D:euler_zyx);
  4241. GetRotationFor2Point3D(0.0,0.0,0.0,vx,vy,vz,trx,trz);
  4242. GetPointInFront3DCol(x,y,z,trx,trz,radius,tx,ty,tz);
  4243. }
  4244. //GetPointInFrontOfPlayer (ColAndreas)
  4245. Tryg3D::Function:: Float:GetPointInFrontOfPlayerCol(playerid,&Float:tx,&Float:ty,Float:radius){
  4246. new Float:rz,Float:z;
  4247. GetPlayerPos(playerid,tx,ty,z);
  4248. if(IsPlayerInAnyVehicle(playerid)){
  4249. GetVehicleZAngle(GetPlayerVehicleID(playerid),rz);
  4250. } else {
  4251. GetPlayerFacingAngle(playerid,rz);
  4252. }
  4253. GetPointInFront3DCol(tx,ty,z,0.0,rz,radius,tx,ty,z);
  4254. return rz;
  4255. }
  4256. //GetPointInFrontOfCamera2D (ColAndreas)
  4257. Tryg3D::Function:: Float:GetPointInFrontOfCamera2DCol(playerid,&Float:tx,&Float:ty,Float:radius){
  4258. new Float:x,Float:y,Float:z,Float:rz;
  4259. GetPlayerCameraPos(playerid,x,y,z);
  4260. GetPlayerCameraZAngle(playerid,rz);
  4261. GetPointInFront3DCol(x,y,z,0.0,rz,radius,tx,ty,z);
  4262. return rz;
  4263. }
  4264. //GetPointInFrontOfCamera3D (ColAndreas)
  4265. Tryg3D::Function:: GetPointInFrontOfCamera3DCol(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0){
  4266. new Float:x,Float:y,Float:z;
  4267. GetPlayerCameraPos(playerid,x,y,z);
  4268. GetPlayerCameraRotation(playerid,rx,rz);
  4269. GetPointInFront3DCol(x,y,z,rx,rz,radius,tx,ty,tz);
  4270. }
  4271. //GetPointInFrontOfVehicle2D (ColAndreas)
  4272. Tryg3D::Function:: Float:GetPointInFrontOfVehicle2DCol(vehicleid,&Float:tx,&Float:ty,Float:radius){
  4273. new Float:rz,Float:x,Float:y,Float:z;
  4274. GetVehiclePos(vehicleid,x,y,z);
  4275. GetVehicleZAngle(vehicleid,rz);
  4276. GetPointInFront3DCol(x,y,z,0.0,rz,radius,tx,ty,z);
  4277. return rz;
  4278. }
  4279. //GetPointInFrontOfVehicle3D (ColAndreas)
  4280. Tryg3D::Function:: GetPointInFrontOfVehicle3DCol(vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0){
  4281. new Float:ry,Float:x,Float:y,Float:z;
  4282. GetVehiclePos(vehicleid,x,y,z);
  4283. Tryg3D::GetVehicleRotation(vehicleid,rx,ry,rz);
  4284. GetPointInFront3DCol(x,y,z,rx,rz,radius,tx,ty,tz);
  4285. }
  4286. Tryg3D::Function:: Float:UndergroundFindZ(Float:x,Float:y,&Float:z=0.0){
  4287. z = 0.0;
  4288. ColAndreas::RayCastLine(x,y,-0.002,x,y,-100.0,x,y,z);
  4289. return z;
  4290. }
  4291. Tryg3D::Function:: Float:InteriorFindZ(Float:px,Float:py,Float:pz=1000.0,Float:size=2.0,&Float:z=0.0){
  4292. z = 0.0;
  4293. ColAndreas::RayCastLine(px,py,pz+size,px,py,pz-100.0,px,py,z);
  4294. return z;
  4295. }
  4296. Tryg3D::Function:: IsPointInWater(Float:x,Float:y,Float:z=0.0){
  4297. if(z > 0.0) return 0;
  4298. new Float:tmpzA, Float:tmpzB;
  4299. Tryg3D::MapAndreasFindZ(x,y,tmpzA);
  4300. UndergroundFindZ(x,y,tmpzB);
  4301. return ((z >= tmpzB) && (tmpzB < 0.0) && (tmpzA > -0.001 && tmpzA < 0.001));
  4302. }
  4303. Tryg3D::Function:: IsPointInUnderground(Float:x,Float:y,Float:z){
  4304. new Float:tmpzA;
  4305. Tryg3D::MapAndreasFindZ(x,y,tmpzA);
  4306. return (z < tmpzA && !IsPointInWater(x,y,z));
  4307. }
  4308. Tryg3D::Function:: IsPointInAir(Float:x,Float:y,Float:z,bool:interior=false,Float:max_distance=2.2){
  4309. new Float:tmpzA;
  4310. if(interior){
  4311. InteriorFindZ(x,y,z,2.0,tmpzA);
  4312. } else {
  4313. Tryg3D::MapAndreasFindZ(x,y,tmpzA);
  4314. }
  4315. return (z >= tmpzA+max_distance);
  4316. }
  4317. Tryg3D::Function:: IsPointInGround(Float:x,Float:y,Float:z,bool:interior=false,Float:max_distance=2.2){
  4318. if(z <= 0.0) return 0;
  4319. new Float:tmpzA;
  4320. if(interior){
  4321. InteriorFindZ(x,y,z,2.0,tmpzA);
  4322. } else {
  4323. Tryg3D::MapAndreasFindZ(x,y,tmpzA);
  4324. }
  4325. return (z <= tmpzA+max_distance);
  4326. }
  4327. Tryg3D::Function:: GetPointCollisionFlags(Float:x,Float:y,Float:z,interiorid=0){
  4328. new bool:isinterior = false, flag_value;
  4329. if(interiorid != 0){
  4330. flag_value |= POSITION_FLAG_INTERIOR;
  4331. isinterior = true;
  4332. } else {
  4333. flag_value |= POSITION_FLAG_WORLD;
  4334. }
  4335. if(IsPointInUnderwater(x,y,z)){
  4336. flag_value |= POSITION_FLAG_WATER;
  4337. flag_value |= POSITION_FLAG_UNDERWATER;
  4338. } else if(IsPointInWater(x,y,z)){
  4339. flag_value |= POSITION_FLAG_WATER;
  4340. } else if(IsPointInAir(x,y,z,isinterior,2.2)){
  4341. flag_value |= POSITION_FLAG_AIR;
  4342. } else if(IsPointInUnderground(x,y,z)){
  4343. flag_value |= POSITION_FLAG_UNDERGROUND;
  4344. } else {
  4345. flag_value |= POSITION_FLAG_GROUND;
  4346. }
  4347. return flag_value;
  4348. }
  4349. Tryg3D::Function:: IsBetweenPlayersIsWall(playerid,targetid){
  4350. new Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:T3D:tmp;
  4351. GetPlayerPos(playerid,xA,yA,zA);
  4352. GetPlayerPos(targetid,xB,yB,zB);
  4353. return ColAndreas::RayCastLine(xA,yA,zA,xB,yB,zB,T3D:tmp,T3D:tmp,T3D:tmp);
  4354. }
  4355. Tryg3D::Function:: IsBetweenPlayerToPointIsWall(playerid,Float:x,Float:y,Float:z){
  4356. new Float:xA,Float:yA,Float:zA,Float:T3D:tmp;
  4357. GetPlayerPos(playerid,xA,yA,zA);
  4358. return ColAndreas::RayCastLine(xA,yA,zA,x,y,z,T3D:tmp,T3D:tmp,T3D:tmp);
  4359. }
  4360. Tryg3D::Function:: GetPointInWallForPoint(Float:x,Float:y,Float:z,Float:radius,&Float:tx,&Float:ty,&Float:tz,Float:sector=90.0){
  4361. if(sector <= 0.0 || sector > 360.0) return 0;
  4362. new Float:px,Float:py,Float:pz,Float:tmp_dist,Float:near_dist = 20000.0,sec_cnt = floatround(360.0/sector);
  4363. if(sec_cnt > 360) sec_cnt = 360;
  4364. for(new i = 0; i < sec_cnt; i++){
  4365. GetPointInFront3DCol(x,y,z,0.0,CompRotationFloat(sector*i),radius,px,py,pz);
  4366. tmp_dist = GetDistanceBetweenPoints3D(x,y,z,px,py,pz);
  4367. if(tmp_dist < near_dist){
  4368. near_dist = tmp_dist;
  4369. tx = px;
  4370. ty = py;
  4371. tz = pz;
  4372. }
  4373. }
  4374. return 1;
  4375. }
  4376. Tryg3D::Function:: IsPlayerInRangeOfElement(playerid,Float:range,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type=item_player,bool:testLOS=true,bool:veh_col=false){
  4377. return IsElementInRangeOfElement(playerid,item_player,range,targetid,target_type,testLOS,veh_col);
  4378. }
  4379. Tryg3D::Function:: IsElementInRangeOfPoint(Float:x,Float:y,Float:z,Float:range,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type=item_player,bool:testLOS=true,bool:veh_col=false){
  4380. new Float:tx,Float:ty,Float:tz;
  4381. if(!GetElementPos(targetid,target_type,tx,ty,tz)) return 0;
  4382. if(testLOS){
  4383. new Float:T3D:x,Float:T3D:y,Float:T3D:z;
  4384. if(ColAndreas::RayCastLine(x,y,z,tx,ty,tz,T3D:x,T3D:y,T3D:z)) return 0;
  4385. }
  4386. #if defined Tryg3D_VehicleCollision
  4387. if(veh_col && Tryg3D::VehicleCollisionSystem){
  4388. new Float:T3D:x,Float:T3D:y,Float:T3D:z;
  4389. if(MovePointColWithVehicle(x,y,z,tx,ty,tz,T3D:x,T3D:y,T3D:z) != INVALID_VEHICLE_ID) return 0;
  4390. }
  4391. #else
  4392. #pragma unused veh_col
  4393. #endif
  4394. return (GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz) <= range);
  4395. }
  4396. Tryg3D::Function:: IsElementInRangeOfElement(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:range,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type=item_player,bool:testLOS=true,bool:veh_col=false){
  4397. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz;
  4398. if(!GetElementPos(elementid,element_type,x,y,z)) return 0;
  4399. if(!GetElementPos(targetid,target_type,tx,ty,tz)) return 0;
  4400. if(testLOS){
  4401. new Float:T3D:x,Float:T3D:y,Float:T3D:z;
  4402. if(ColAndreas::RayCastLine(tx,ty,tz,x,y,z,T3D:x,T3D:y,T3D:z)) return 0;
  4403. }
  4404. #if defined Tryg3D_VehicleCollision
  4405. if(veh_col && Tryg3D::VehicleCollisionSystem){
  4406. new Float:T3D:x,Float:T3D:y,Float:T3D:z;
  4407. if(MovePointColWithVehicle(tx,ty,tz,x,y,z,T3D:x,T3D:y,T3D:z) != INVALID_VEHICLE_ID) return 0;
  4408. }
  4409. #else
  4410. #pragma unused veh_col
  4411. #endif
  4412. return (GetDistanceBetweenPoints3D(x,y,z,tx,ty,tz) <= range);
  4413. }
  4414. Tryg3D::Function:: IsBetweenElementsIsWall(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type){
  4415. new Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB,Float:T3D:tmp;
  4416. if(!GetElementPos(elementid,element_type,xA,yA,zA)) return false;
  4417. if(!GetElementPos(targetid,target_type,xB,yB,zB)) return false;
  4418. return ColAndreas::RayCastLine(xA,yA,zA,xB,yB,zB,T3D:tmp,T3D:tmp,T3D:tmp);
  4419. }
  4420. Tryg3D::Function:: IsBetweenElementToPointIsWall(Float:x,Float:y,Float:z,TRYG3D_ELEMENT_TAG targetid,Item3D_Type:target_type){
  4421. new Float:xB,Float:yB,Float:zB,Float:T3D:tmp;
  4422. if(!GetElementPos(targetid,target_type,xB,yB,zB)) return false;
  4423. return ColAndreas::RayCastLine(xB,yB,zB,x,y,z,T3D:tmp,T3D:tmp,T3D:tmp);
  4424. }
  4425. Tryg3D::Function:: GetElementCollisionFlags(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type){
  4426. new Float:x,Float:y,Float:z;
  4427. if(!GetElementPos(elementid,element_type,x,y,z)) return 0;
  4428. return GetPointCollisionFlags(x,y,z);
  4429. }
  4430. Tryg3D::Function:: GetElementOrientationPosCol(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,element_orientation:orientation,Float:distance,&Float:tx,&Float:ty,&Float:tz){
  4431. new Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz;
  4432. if(!GetElementPos(elementid,element_type,x,y,z)) return 0;
  4433. switch(element_type){
  4434. case item_player: {
  4435. GetPlayerFacingAngle(_:elementid,rz);
  4436. }
  4437. case item_npc: {
  4438. #if defined Tryg3D_FCNPC
  4439. if(FCNPC::IsValid(_:elementid)){
  4440. rz = FCNPC::GetAngle(_:elementid);
  4441. } else {
  4442. GetPlayerFacingAngle(_:elementid,rz);
  4443. }
  4444. #else
  4445. GetPlayerFacingAngle(_:elementid,rz);
  4446. #endif
  4447. }
  4448. #if defined Tryg3D_Actor
  4449. case item_actor: {
  4450. GetActorFacingAngle(_:elementid,rz);
  4451. }
  4452. #endif
  4453. case item_object: {
  4454. GetObjectRot(_:elementid,rx,ry,rz);
  4455. }
  4456. case item_vehicle: {
  4457. Tryg3D::GetVehicleRotation(_:elementid,rx,ry,rz);
  4458. }
  4459. #if defined Tryg3D_Streamer
  4460. case item_dynamic_object: {
  4461. GetDynamicObjectRot(STREAMER_TAG_OBJECT (_:elementid),rx,ry,rz);
  4462. }
  4463. case item_dynamic_actor: {
  4464. GetDynamicActorFacingAngle(STREAMER_TAG_ACTOR (_:elementid),rz);
  4465. }
  4466. #endif
  4467. #if defined Tryg3D_VehicleStreamer
  4468. case item_dynamic_vehicle: {
  4469. GetDynamicVehicleRotation(STREAMER_TAG_VEHICLE (_:elementid),rx,ry,rz);
  4470. }
  4471. #endif
  4472. #if defined Tryg3D_FCNPC
  4473. case item_fcnpc: {
  4474. rz = FCNPC::GetAngle(_:elementid);
  4475. }
  4476. #endif
  4477. default: return 0;
  4478. }
  4479. switch(element_type){
  4480. case item_player, item_npc, item_actor, item_dynamic_actor, item_fcnpc: {
  4481. switch(orientation){
  4482. case o_left: GetPointInFront3DCol(x,y,z,0.0,CompRotationFloat(rz+90.0),distance,tx,ty,tz);
  4483. case o_right: GetPointInFront3DCol(x,y,z,0.0,CompRotationFloat(rz-90.0),distance,tx,ty,tz);
  4484. case o_up: GetPointInFront3DCol(x,y,z,90.0,0.0,distance,tx,ty,tz);
  4485. case o_down: GetPointInFront3DCol(x,y,z,270.0,0.0,distance,tx,ty,tz);
  4486. case o_front: GetPointInFront3DCol(x,y,z,0.0,rz,distance,tx,ty,tz);
  4487. case o_back: GetPointInFront3DCol(x,y,z,0.0,CompRotationFloat(rz+180.0),distance,tx,ty,tz);
  4488. }
  4489. }
  4490. case item_vehicle, item_object, item_dynamic_object, item_dynamic_vehicle: {
  4491. switch(orientation){
  4492. case o_left: GetPointInFront3DCol(x,y,z,ry,CompRotationFloat(rz+90.0),distance,tx,ty,tz);
  4493. case o_right: GetPointInFront3DCol(x,y,z,CompRotationFloat(ry+180.0),CompRotationFloat(rz+90.0),distance,tx,ty,tz);
  4494. case o_up: {
  4495. GetElementUpPos(elementid,element_type,distance,tx,ty,tz);
  4496. MovePointCol(x,y,z,tx,ty,tz,tx,ty,tz);
  4497. }
  4498. case o_down: {
  4499. GetElementUpPos(elementid,element_type,distance,tx,ty,tz,true);
  4500. MovePointCol(x,y,z,tx,ty,tz,tx,ty,tz);
  4501. }
  4502. case o_front: GetPointInFront3DCol(x,y,z,rx,rz,distance,tx,ty,tz);
  4503. case o_back: GetPointInFront3DCol(x,y,z,CompRotationFloat(rx+180.0),rz,distance,tx,ty,tz);
  4504. }
  4505. }
  4506. }
  4507. return 1;
  4508. }
  4509. Tryg3D::Function:: GetWallRotation(Float:sx,Float:sy,Float:sz,Float:ex,Float:ey,Float:ez,&Float:rx,&Float:rz,&Float:px=0.0,&Float:py=0.0,&Float:pz=0.0,Float:size=1.0,Float:cut_size=0.0){
  4510. new Float:line_rx, Float:line_rz, Float:T3D:tmp;
  4511. if(!GetRotationFor2Point3D(sx,sy,sz,ex,ey,ez,line_rx,line_rz)) return 0;
  4512. new VecStart[4][Vectors3D], VecEnd[4][Vectors3D], VecProduct[4][Vectors3D];
  4513. //Start: Right -> Left
  4514. GetPointInFront3D(sx,sy,sz,line_rx,CompRotationFloat(line_rz-90.0),size,VecStart[0][T3D:X],VecStart[0][T3D:Y],VecStart[0][T3D:Z]);
  4515. GetPointInFront3D(sx,sy,sz,line_rx,CompRotationFloat(line_rz+90.0),size,VecStart[1][T3D:X],VecStart[1][T3D:Y],VecStart[1][T3D:Z]);
  4516. //Start: Down -> Up
  4517. GetPointInFront3D(sx,sy,sz,CompRotationFloat(line_rx-90.0),line_rz,size,VecStart[2][T3D:X],VecStart[2][T3D:Y],VecStart[2][T3D:Z]);
  4518. GetPointInFront3D(sx,sy,sz,CompRotationFloat(line_rx+90.0),line_rz,size,VecStart[3][T3D:X],VecStart[3][T3D:Y],VecStart[3][T3D:Z]);
  4519. //End: Right -> Left
  4520. GetPointInFront3D(ex,ey,ez,line_rx,CompRotationFloat(line_rz-90.0),size,VecEnd[0][T3D:X],VecEnd[0][T3D:Y],VecEnd[0][T3D:Z]);
  4521. GetPointInFront3D(ex,ey,ez,line_rx,CompRotationFloat(line_rz+90.0),size,VecEnd[1][T3D:X],VecEnd[1][T3D:Y],VecEnd[1][T3D:Z]);
  4522. //End: Down -> Up
  4523. GetPointInFront3D(ex,ey,ez,CompRotationFloat(line_rx-90.0),line_rz,size,VecEnd[2][T3D:X],VecEnd[2][T3D:Y],VecEnd[2][T3D:Z]);
  4524. GetPointInFront3D(ex,ey,ez,CompRotationFloat(line_rx+90.0),line_rz,size,VecEnd[3][T3D:X],VecEnd[3][T3D:Y],VecEnd[3][T3D:Z]);
  4525. for(new i = 0; i < 4; i++){
  4526. GetPointFor2Point3DEx(VecStart[1][T3D:X],VecStart[1][T3D:Y],VecStart[1][T3D:Z],VecEnd[i][T3D:X],VecEnd[i][T3D:Y],VecEnd[i][T3D:Z],20000.0,VecEnd[i][T3D:X],VecEnd[i][T3D:Y],VecEnd[i][T3D:Z]);
  4527. MovePointCol(VecStart[i][T3D:X],VecStart[i][T3D:Y],VecStart[i][T3D:Z],VecEnd[i][T3D:X],VecEnd[i][T3D:Y],VecEnd[i][T3D:Z],VecProduct[i][T3D:X],VecProduct[i][T3D:Y],VecProduct[i][T3D:Z]);
  4528. }
  4529. MovePointColCutLine(sx,sy,sz,ex,ey,ez,px,py,pz,cut_size);
  4530. if(!GetRotationFor2Point3D(VecProduct[0][T3D:X],VecProduct[0][T3D:Y],VecProduct[0][T3D:Z],VecProduct[1][T3D:X],VecProduct[1][T3D:Y],VecProduct[1][T3D:Z],T3D:tmp,rz)) return 0;
  4531. if(!GetRotationFor2Point3D(VecProduct[2][T3D:X],VecProduct[2][T3D:Y],VecProduct[2][T3D:Z],VecProduct[3][T3D:X],VecProduct[3][T3D:Y],VecProduct[3][T3D:Z],rx,T3D:tmp)) return 0;
  4532. return 1;
  4533. }
  4534. #endif
  4535. #if ((defined Tryg3D_MapAndreas) && (!defined Tryg3D_ColAndreas))
  4536. /************************************************************************************************************************************
  4537. * *
  4538. * MapAndreas Functions *
  4539. * *
  4540. ************************************************************************************************************************************/
  4541. Tryg3D::Function:: GetPointInFrontOnGround(Float:x,Float:y,Float:z,Float:rx,Float:rz,&Float:tx,&Float:ty,&Float:tz,Float:max_distance){
  4542. new Float:tmpz;
  4543. Tryg3D::MapAndreasFindZ(x,y,tmpz);
  4544. new Float:radius = GetDistanceBetweenPoints3D(x,y,z,x,y,tmpz),
  4545. Float:cos = floatcos(rx+90.0,degrees),
  4546. Float:dist;
  4547. if(cos == 0.0){
  4548. dist = radius;
  4549. } else {
  4550. dist = floatabs(radius/cos);
  4551. }
  4552. if((dist > max_distance) || (rx >= 0.0 && rx <= 180.0)){
  4553. dist = max_distance;
  4554. }
  4555. GetPointInFront3D(x,y,z,rx,rz,dist,tx,ty,tz);
  4556. if(!((dist > max_distance) || (rx >= 0.0 && rx <= 180.0))){
  4557. Tryg3D::MapAndreasFindZ(tx,ty,tz);
  4558. }
  4559. }
  4560. Tryg3D::Function:: IsPointInWater(Float:x,Float:y,Float:z=0.0){
  4561. if(z > 0.0) return 0;
  4562. new Float:tmpz;
  4563. Tryg3D::MapAndreasFindZ(x,y,tmpz);
  4564. return (tmpz == 0.0);
  4565. }
  4566. #endif
  4567. #if (defined Tryg3D_MapAndreas || defined Tryg3D_ColAndreas)
  4568. /************************************************************************************************************************************
  4569. * *
  4570. * MapAndreas/ColAndreas Functions *
  4571. * *
  4572. ************************************************************************************************************************************/
  4573. Tryg3D::Function:: GetGroundRotation(Float:x,Float:y,Float:size,&Float:rx,&Float:ry){
  4574. new Float:tpx1,Float:tpy1,Float:tpz1,
  4575. Float:tpx2,Float:tpy2,Float:tpz2,
  4576. Float:T3D:tmp;
  4577. GetPointInFront2D(x,y,0.0,size,tpx1,tpy1);
  4578. GetPointInFront2D(x,y,180.0,size,tpx2,tpy2);
  4579. Tryg3D::MapAndreasFindZ(tpx1,tpy1,tpz1);
  4580. Tryg3D::MapAndreasFindZ(tpx2,tpy2,tpz2);
  4581. GetRotationFor2Point3D(tpx1,tpy1,tpz1,tpx2,tpy2,tpz2,rx,T3D:tmp);
  4582. GetPointInFront2D(x,y,90.0,size,tpx1,tpy1);
  4583. GetPointInFront2D(x,y,270.0,size,tpx2,tpy2);
  4584. Tryg3D::MapAndreasFindZ(tpx1,tpy1,tpz1);
  4585. Tryg3D::MapAndreasFindZ(tpx2,tpy2,tpz2);
  4586. GetRotationFor2Point3D(tpx1,tpy1,tpz1,tpx2,tpy2,tpz2,ry,T3D:tmp);
  4587. }
  4588. Tryg3D::Function:: IsPointInWaterOrientOfElement(TRYG3D_ELEMENT_TAG elementid,Item3D_Type:element_type,Float:radius,element_orientation:orientation=o_front){
  4589. new Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z;
  4590. if(!GetElementPos(elementid,element_type,px,py,pz)) return false;
  4591. if(!GetElementOrientationPos(elementid,element_type,orientation,radius,x,y,z)) return false;
  4592. return IsPointInWater(x,y,0.0);
  4593. }
  4594. Tryg3D::Deprecated:: IsPointInWaterFrontOfPlayer(playerid,Float:radius){
  4595. new Float:x, Float:y, Float:z;
  4596. GetPlayerPos(playerid,x,y,z);
  4597. GetPointInFrontOfPlayer(playerid,x,y,radius);
  4598. return IsPointInWater(x,y,0.0);
  4599. }
  4600. #endif
  4601. #if defined Tryg3D_YSF
  4602. /************************************************************************************************************************************
  4603. * *
  4604. * YSF Functions *
  4605. * *
  4606. ************************************************************************************************************************************/
  4607. #define GetPlayerHydraReactorRX(%0) CompRotationFloat((GetPlayerHydraReactorAngle(%0)/55.5555555))
  4608. #define IsPlayerHydraReactorBoost(%0) (GetPlayerHydraReactorAngle(%0) == 0)
  4609. Tryg3D::Function:: CountTextDraw(){
  4610. new T3D:count = 0;
  4611. for(new i = 0; i < MAX_TEXT_DRAWS; i++){
  4612. if(IsValidTextDraw(Text:i)) T3D:count++;
  4613. }
  4614. return T3D:count;
  4615. }
  4616. Tryg3D::Function:: CountVisibleTextDraw(playerid){
  4617. new T3D:count = 0;
  4618. for(new i = 0; i < MAX_TEXT_DRAWS; i++){
  4619. if(IsValidTextDraw(Text:i) && IsTextDrawVisibleForPlayer(playerid,Text:i)) T3D:count++;
  4620. }
  4621. return T3D:count;
  4622. }
  4623. Tryg3D::Function:: CountPlayerTextDraw(playerid){
  4624. new T3D:count = 0;
  4625. for(new i = 0; i < MAX_PLAYER_TEXT_DRAWS; i++){
  4626. if(IsValidPlayerTextDraw(playerid,PlayerText:i)) T3D:count++;
  4627. }
  4628. return T3D:count;
  4629. }
  4630. Tryg3D::Function:: CountVisiblePlayerTextDraw(playerid){
  4631. new T3D:count = 0;
  4632. for(new i = 0; i < MAX_PLAYER_TEXT_DRAWS; i++){
  4633. if(IsValidPlayerTextDraw(playerid,PlayerText:i) && IsPlayerTextDrawVisible(playerid,PlayerText:i)) T3D:count++;
  4634. }
  4635. return T3D:count;
  4636. }
  4637. Tryg3D::Function:: CountGangZone(){
  4638. new T3D:count = 0;
  4639. for(new i = 0; i < MAX_GANG_ZONES; i++){
  4640. if(IsValidGangZone(i)) T3D:count++;
  4641. }
  4642. return T3D:count;
  4643. }
  4644. Tryg3D::Function:: CountVisibleGangZone(playerid){
  4645. new T3D:count = 0;
  4646. for(new i = 0; i < MAX_GANG_ZONES; i++){
  4647. if(IsValidGangZone(i) && IsGangZoneVisibleForPlayer(playerid,i)) T3D:count++;
  4648. }
  4649. return T3D:count;
  4650. }
  4651. Tryg3D::Function:: CountPlayerGangZone(playerid){
  4652. new T3D:count = 0;
  4653. for(new i = 0; i < MAX_GANG_ZONES; i++){
  4654. if(IsValidPlayerGangZone(playerid,i)) T3D:count++;
  4655. }
  4656. return T3D:count;
  4657. }
  4658. Tryg3D::Function:: CountVisiblePlayerGangZone(playerid){
  4659. new T3D:count = 0;
  4660. for(new i = 0; i < MAX_GANG_ZONES; i++){
  4661. if(IsValidPlayerGangZone(playerid,i) && IsPlayerGangZoneVisible(playerid,i)) T3D:count++;
  4662. }
  4663. return T3D:count;
  4664. }
  4665. Tryg3D::Function:: IsVehicleOnSpawn(vehicleid,Float:check_radius=1.0){
  4666. new Float:x,Float:y,Float:z,Float:rz,color1,color2;
  4667. GetVehicleSpawnInfo(vehicleid,x,y,z,rz,color1,color2);
  4668. return IsVehicleInRangeOfPoint(vehicleid,check_radius,x,y,z);
  4669. }
  4670. Tryg3D::Function:: IsPlayerOnSpawn(playerid,Float:check_radius=1.0){
  4671. new teamid,modelid,Float:spawn_x,Float:spawn_y,Float:spawn_z,Float:z_angle,weapon1,weapon1_ammo,weapon2,weapon2_ammo,weapon3,weapon3_ammo;
  4672. GetSpawnInfo(playerid,teamid,modelid,spawn_x,spawn_y,spawn_z,z_angle,weapon1,weapon1_ammo,weapon2,weapon2_ammo,weapon3,weapon3_ammo);
  4673. return IsPlayerInRangeOfPoint(playerid,check_radius,spawn_x,spawn_y,spawn_z);
  4674. }
  4675. Tryg3D::Function:: GetPlayerRotation(playerid,&Float:rx,&Float:ry,&Float:rz){
  4676. new Float:qw,Float:qx,Float:qy,Float:qz;
  4677. GetPlayerRotationQuat(playerid,qw,qx,qy,qz);
  4678. Tryg3D::QuatToEuler(rx,ry,rz,qw,qx,qy,qz);
  4679. }
  4680. Tryg3D::Function:: GetRandomPointInGangZone(zoneid,&Float:tx,&Float:ty){
  4681. new Float:minx,Float:miny,Float:maxx,Float:maxy;
  4682. GangZoneGetPos(zoneid,minx,miny,maxx,maxy);
  4683. GetRandomPointInRectangle(minx,miny,maxx,maxy,tx,ty);
  4684. }
  4685. Tryg3D::Function:: GetRandomPointInPlayerGangZone(playerid,zoneid,&Float:tx,&Float:ty){
  4686. new Float:minx,Float:miny,Float:maxx,Float:maxy;
  4687. PlayerGangZoneGetPos(playerid,zoneid,minx,miny,maxx,maxy);
  4688. GetRandomPointInRectangle(minx,miny,maxx,maxy,tx,ty);
  4689. }
  4690. #endif
  4691. #if defined Tryg3D_FCNPC
  4692. /************************************************************************************************************************************
  4693. * *
  4694. * FCNPC Functions *
  4695. * *
  4696. ************************************************************************************************************************************/
  4697. #define FCNPC_InRangeOfPoint(%0,%1,%2,%3,%4) (GetElementDistanceFromPoint((%0),item_fcnpc,(%2),(%3),(%4)) <= (%1))
  4698. #define IsNPCInRangeOfPoint FCNPC_InRangeOfPoint
  4699. #define GetNPCTargetAngle FCNPC_GetTargetAngle
  4700. #define SetNPCTargetAngle FCNPC_SetTargetAngle
  4701. #define GetNPCSpeed FCNPC_GetSpeed
  4702. #define GetPointInFrontOfNPC FCNPC_GetPointInFront
  4703. #define GetPointInFrontOfNPCCol FCNPC_GetPointInFrontCol
  4704. #define SetNPCAbsolutePosition FCNPC_SetAbsolutePosition
  4705. Tryg3D::Function:: Float:FCNPC::GetPointInFront(npcid,&Float:tx,&Float:ty,Float:radius){
  4706. new Float:rz;
  4707. FCNPC::GetPosition(npcid,tx,ty,rz);
  4708. if(IsPlayerInAnyVehicle(npcid)){
  4709. GetVehicleZAngle(FCNPC::GetVehicleID(npcid),rz);
  4710. } else {
  4711. rz = FCNPC::GetAngle(npcid);
  4712. }
  4713. GetPointInFront2D(tx,ty,rz,radius,tx,ty);
  4714. return rz;
  4715. }
  4716. Tryg3D::Function:: Float:FCNPC::GetSpeed(npcid){
  4717. new Float:x,Float:y,Float:z;
  4718. FCNPC::GetVelocity(npcid,x,y,z);
  4719. return floatmul(VectorSize(x,y,z),PLAYER_SPEED_MULTIPLIER);
  4720. }
  4721. Tryg3D::Function:: Float:FCNPC::GetTargetAngle(npcid,Float:x,Float:y,&Float:rz=0.0){
  4722. new Float:mx,Float:my;
  4723. FCNPC::GetPosition(npcid,mx,my,rz);
  4724. GetRotationFor2Point2D(mx,my,x,y,rz);
  4725. return rz;
  4726. }
  4727. Tryg3D::Function:: Float:FCNPC::SetTargetAngle(npcid,Float:x,Float:y,&Float:rz=0.0){
  4728. new Float:mx,Float:my;
  4729. FCNPC::GetPosition(npcid,mx,my,rz);
  4730. GetRotationFor2Point2D(mx,my,x,y,rz);
  4731. FCNPC::SetAngle(npcid,rz);
  4732. return rz;
  4733. }
  4734. Tryg3D::Function:: FCNPC::SetVehicleRotation(npcid,Float:rx,Float:ry,Float:rz){
  4735. new Float:qw,Float:qx,Float:qy,Float:qz;
  4736. Tryg3D::EulerToQuat(rx,ry,rz,qw,qx,qy,qz);
  4737. FCNPC::SetQuaternion(npcid,qw,qx,qy,qz);
  4738. }
  4739. Tryg3D::Function:: FCNPC::SetVehicleTargetRotation(npcid,Float:tx,Float:ty,Float:tz,Float:ry=0.0){
  4740. new Float:x,Float:y,Float:z,Float:rx,Float:rz;
  4741. GetVehiclePos(FCNPC::GetVehicleID(npcid),x,y,z);
  4742. if(GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz)){
  4743. new Float:qw,Float:qx,Float:qy,Float:qz;
  4744. Tryg3D::EulerToQuat(rx,ry,rz,qw,qx,qy,qz);
  4745. FCNPC::SetQuaternion(npcid,qw,qx,qy,qz);
  4746. return 1;
  4747. }
  4748. return 0;
  4749. }
  4750. Tryg3D::Function:: FCNPC::GoToAir(npcid,Float:x,Float:y,Float:z,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,Float:dist_offset = 0.0,stopdelay = 250){
  4751. FCNPC::SetVehicleTargetRotation(npcid,x,y,z);
  4752. FCNPC::GoTo(npcid,x,y,z,type,speed,false,0.0,false,dist_offset,stopdelay);
  4753. }
  4754. #if defined Tryg3D_ColAndreas
  4755. Tryg3D::Function:: Float:FCNPC::GetPointInFrontCol(npcid,&Float:tx,&Float:ty,Float:radius){
  4756. new Float:rz,Float:z;
  4757. FCNPC::GetPosition(npcid,tx,ty,z);
  4758. if(IsPlayerInAnyVehicle(npcid)){
  4759. GetVehicleZAngle(FCNPC::GetVehicleID(npcid),rz);
  4760. } else {
  4761. rz = FCNPC::GetAngle(npcid);
  4762. }
  4763. GetPointInFront3DCol(tx,ty,z,0.0,rz,radius,tx,ty,z);
  4764. return rz;
  4765. }
  4766. Tryg3D::Function:: FCNPC::GoToCol(npcid,Float:x,Float:y,Float:z,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas = false,Float:cut_size = 0.0,bool:setangle = true,Float:dist_offset = 0.0,stopdelay = 250){
  4767. new Float:px,Float:py,Float:pz,Float:tx,Float:ty,Float:tz;
  4768. FCNPC::GetPosition(npcid,px,py,pz);
  4769. if(MovePointColCutLineEx(px,py,pz,x,y,z,tx,ty,tz,cut_size)){
  4770. FCNPC::GoTo(npcid,tx,ty,tz,type,speed,UseMapAndreas,0.0,setangle,dist_offset,stopdelay);
  4771. }
  4772. }
  4773. Tryg3D::Function:: FCNPC::GoToPlayerCol(npcid,playerid,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas = false,Float:cut_size = 0.0,bool:setangle = true,Float:dist_offset = 0.0,stopdelay = 250){
  4774. new Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz;
  4775. GetPlayerPos(playerid,x,y,z);
  4776. FCNPC::GetPosition(npcid,px,py,pz);
  4777. if(MovePointColCutLineEx(px,py,pz,x,y,z,tx,ty,tz,cut_size)){
  4778. FCNPC::GoTo(npcid,tx,ty,tz,type,speed,UseMapAndreas,0.0,setangle,dist_offset,stopdelay);
  4779. }
  4780. }
  4781. Tryg3D::Function:: FCNPC::GoToPlayerOnGroundCol(npcid,playerid,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas = false,Float:cut_size = 1.0,Float:climbing = 2.0,bool:setangle = true,Float:dist_offset = 0.0,stopdelay = 250){
  4782. new Float:px,Float:py,Float:pz,Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz;
  4783. GetPlayerPos(playerid,x,y,z);
  4784. FCNPC::GetPosition(npcid,px,py,pz);
  4785. if(GetDistanceBetweenPoints1D(pz,z) > climbing) z = pz;
  4786. if(MovePointColCutLineEx(px,py,pz,x,y,z,tx,ty,tz,cut_size)){
  4787. FCNPC::GoTo(npcid,tx,ty,tz,type,speed,UseMapAndreas,0.0,setangle,dist_offset,stopdelay);
  4788. }
  4789. }
  4790. Tryg3D::Function:: FCNPC::GoToAirCol(npcid,Float:x,Float:y,Float:z,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,Float:cut_size = 0.0,Float:dist_offset = 0.0,stopdelay = 250){
  4791. new Float:px,Float:py,Float:pz,Float:tx,Float:ty,Float:tz;
  4792. GetVehiclePos(FCNPC::GetVehicleID(npcid),px,py,pz);
  4793. if(MovePointColCutLineEx(px,py,pz,x,y,z,tx,ty,tz,cut_size)){
  4794. FCNPC::SetVehicleTargetRotation(npcid,tx,ty,tz);
  4795. FCNPC::GoTo(npcid,tx,ty,tz,type,speed,false,0.0,false,dist_offset,stopdelay);
  4796. }
  4797. }
  4798. Tryg3D::Function:: FCNPC::SetFloorPos(npcid){
  4799. new Float:x,Float:y,Float:z,Float:T3D:tmp,Float:target_z;
  4800. FCNPC::GetPosition(npcid,x,y,z);
  4801. MovePointCol(x,y,z+1.0,x,y,-100.0,T3D:tmp,T3D:tmp,target_z);
  4802. FCNPC::SetPosition(npcid,x,y,target_z+1.0);
  4803. return 1;
  4804. }
  4805. #if defined Tryg3D_Streamer
  4806. Tryg3D::Function:: FCNPC::RandomMoveInDynamicArea(npcid,STREAMER_TAG_AREA areaid,Float:climbing = 2.0,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas = false,bool:setangle = true,Float:dist_offset = 0.0,stopdelay = 250){
  4807. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:T3D:tmp;
  4808. FCNPC::GetPosition(npcid,x,y,z);
  4809. for(;;){
  4810. GetRandomPointInDynamicArea(areaid,tx,ty,tz);
  4811. if(ColAndreas::RayCastLine(x,y,z,tx,ty,z,T3D:tmp,T3D:tmp,T3D:tmp)) continue;
  4812. ColAndreas::FindZ_For2DCoord(tx,ty,tz);
  4813. if(GetDistanceBetweenPoints1D(tz,z) > climbing) continue;
  4814. break;
  4815. }
  4816. return FCNPC::GoTo(npcid,tx,ty,tz+1.0,type,speed,UseMapAndreas,0.0,setangle,dist_offset,stopdelay);
  4817. }
  4818. #endif
  4819. #if defined Tryg3D_Stream3D
  4820. Tryg3D::Function:: FCNPC::RandomMoveInStream(npcid,Stream:StreamData[Stream3D],Float:climbing = 2.0,type = FCNPC_MOVE_TYPE_AUTO,Float:speed = FCNPC_MOVE_SPEED_AUTO,bool:UseMapAndreas = false,bool:setangle = true,Float:dist_offset = 0.0,stopdelay = 250){
  4821. new Float:x,Float:y,Float:z,Float:tx,Float:ty,Float:tz,Float:T3D:tmp;
  4822. FCNPC::GetPosition(npcid,x,y,z);
  4823. for(;;){
  4824. GetRandomPointInStream(StreamData,tx,ty,tz);
  4825. if(ColAndreas::RayCastLine(x,y,z,tx,ty,z,T3D:tmp,T3D:tmp,T3D:tmp)) continue;
  4826. ColAndreas::FindZ_For2DCoord(tx,ty,tz);
  4827. if(GetDistanceBetweenPoints1D(tz,z) > climbing) continue;
  4828. break;
  4829. }
  4830. return FCNPC::GoTo(npcid,tx,ty,tz+1.0,type,speed,UseMapAndreas,0.0,setangle,dist_offset,stopdelay);
  4831. }
  4832. #endif
  4833. #endif
  4834. #if defined Tryg3D_Streamer
  4835. Tryg3D::Function:: FCNPC::SetAbsolutePosition(npcid,Float:x,Float:y,Float:z,Float:angle,worldid = -1,interiorid = -1,compensatedtime = -1,freezeplayer = 1){
  4836. Streamer::UpdateEx(npcid,x,y,z,worldid,interiorid,-1,compensatedtime,freezeplayer);
  4837. if(worldid != -1) FCNPC::SetVirtualWorld(npcid,worldid);
  4838. if(interiorid != -1) FCNPC::SetInterior(npcid,interiorid);
  4839. FCNPC::SetPosition(npcid,x,y,z);
  4840. FCNPC::SetAngle(npcid,angle);
  4841. }
  4842. #endif
  4843. #endif
  4844. #if defined Tryg3D_VehicleStreamer
  4845. /************************************************************************************************************************************
  4846. * *
  4847. * VehicleStreamer Functions *
  4848. * *
  4849. ************************************************************************************************************************************/
  4850. #define GetDynamicVehicleFlags(%0) GetVehicleFlagsByModel(GetDynamicVehicleModel(%0))
  4851. #define IsDynVehInRangeOfPoint(%0,%1,%2,%3,%4) (GetDynamicVehDistanceFromPoint((%0),(%2),(%3),(%4)) <= (%1))
  4852. //GetVehicleRotation Created by IllidanS4
  4853. Tryg3D::Function:: GetDynamicVehicleRotation(STREAMER_TAG_VEHICLE vehicleid,&Float:rx,&Float:ry,&Float:rz){
  4854. new Float:qw,Float:qx,Float:qy,Float:qz;
  4855. GetDynamicVehicleRotationQuat(vehicleid,qw,qx,qy,qz);
  4856. Tryg3D::QuatToEuler(rx,ry,rz,qw,qx,qy,qz);
  4857. }
  4858. Tryg3D::Function:: Float:GetPointInFrontOfDynVeh2D(STREAMER_TAG_VEHICLE vehicleid,&Float:tx,&Float:ty,Float:radius){
  4859. new Float:rx,Float:ry,Float:rz,Float:x,Float:y;
  4860. GetDynamicVehiclePos(vehicleid,x,y,rz);
  4861. GetDynamicVehicleRotation(vehicleid,rx,ry,rz);
  4862. GetPointInFront2D(x,y,rz,radius,tx,ty);
  4863. return rz;
  4864. }
  4865. Tryg3D::Function:: GetPointInFrontOfDynVeh3D(STREAMER_TAG_VEHICLE vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0){
  4866. new Float:ry,Float:x,Float:y,Float:z;
  4867. GetDynamicVehiclePos(vehicleid,x,y,z);
  4868. GetDynamicVehicleRotation(vehicleid,rx,ry,rz);
  4869. GetPointInFront3D(x,y,z,rx,rz,radius,tx,ty,tz);
  4870. }
  4871. Tryg3D::Function:: Float:GetDynamicVehicleSpeed(STREAMER_TAG_VEHICLE vehicleid){
  4872. new Float:x,Float:y,Float:z;
  4873. GetDynamicVehicleVelocity(vehicleid,x,y,z);
  4874. return floatmul(VectorSize(x,y,z),VEHICLE_SPEED_MULTIPLIER);
  4875. }
  4876. #if defined Tryg3D_ColAndreas
  4877. //GetPointInFrontOfVehicle2D (ColAndreas)
  4878. Tryg3D::Function:: Float:GetPointInFrontOfDynVeh2DCol(STREAMER_TAG_VEHICLE vehicleid,&Float:tx,&Float:ty,Float:radius){
  4879. new Float:rx,Float:ry,Float:rz,Float:x,Float:y,Float:z;
  4880. GetDynamicVehiclePos(vehicleid,x,y,z);
  4881. GetDynamicVehicleRotation(vehicleid,rx,ry,rz);
  4882. GetPointInFront3DCol(x,y,z,0.0,rz,radius,tx,ty,z);
  4883. return rz;
  4884. }
  4885. //GetPointInFrontOfVehicle3D (ColAndreas)
  4886. Tryg3D::Function:: GetPointInFrontOfDynVeh3DCol(STREAMER_TAG_VEHICLE vehicleid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0){
  4887. new Float:ry,Float:x,Float:y,Float:z;
  4888. GetDynamicVehiclePos(vehicleid,x,y,z);
  4889. GetDynamicVehicleRotation(vehicleid,rx,ry,rz);
  4890. GetPointInFront3DCol(x,y,z,rx,rz,radius,tx,ty,tz);
  4891. }
  4892. #endif
  4893. #if defined Tryg3D_YSF
  4894. Tryg3D::Function:: IsDynamicVehicleOnSpawn(STREAMER_TAG_VEHICLE vehicleid,Float:check_radius=1.0){
  4895. new Float:x,Float:y,Float:z,Float:rz,color1,color2,siren;
  4896. GetDynamicVehicleSpawnInfo(vehicleid,x,y,z,rz,color1,color2,siren);
  4897. return IsDynVehInRangeOfPoint(vehicleid,check_radius,x,y,z);
  4898. }
  4899. #endif
  4900. #if defined Tryg3D_Streamer
  4901. Tryg3D::Function:: IsDynVehFullyInDynamicArea(STREAMER_TAG_VEHICLE vehicleid,STREAMER_TAG_AREA areaid){
  4902. new Float:size_x,Float:size_y,Float:size_z,
  4903. Float:x,Float:y,Float:z,
  4904. Float:minx,Float:miny,Float:minz,
  4905. Float:maxx,Float:maxy,Float:maxz;
  4906. GetVehicleModelInfo(GetDynamicVehicleModel(vehicleid),VEHICLE_MODEL_INFO_SIZE,size_x,size_y,size_z);
  4907. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  4908. GetDynamicVehiclePos(vehicleid,x,y,z);
  4909. minx = x - size_x;
  4910. miny = y - size_y;
  4911. minz = z - size_z;
  4912. maxx = x + size_x;
  4913. maxy = y + size_y;
  4914. maxz = z + size_z;
  4915. if(!IsPointInDynamicArea(areaid,minx,miny,minz)) return 0;
  4916. if(!IsPointInDynamicArea(areaid,minx,miny,maxz)) return 0;
  4917. if(!IsPointInDynamicArea(areaid,minx,maxy,minz)) return 0;
  4918. if(!IsPointInDynamicArea(areaid,minx,maxy,maxz)) return 0;
  4919. if(!IsPointInDynamicArea(areaid,maxx,miny,minz)) return 0;
  4920. if(!IsPointInDynamicArea(areaid,maxx,miny,maxz)) return 0;
  4921. if(!IsPointInDynamicArea(areaid,maxx,maxy,minz)) return 0;
  4922. if(!IsPointInDynamicArea(areaid,maxx,maxy,maxz)) return 0;
  4923. return 1;
  4924. }
  4925. #endif
  4926. #if defined Tryg3D_Stream3D
  4927. Tryg3D::Function:: IsDynamicVehicleFullyInStream(STREAMER_TAG_VEHICLE vehicleid,Stream:StreamData[Stream3D]){
  4928. new Float:size_x,Float:size_y,Float:size_z,
  4929. Float:x,Float:y,Float:z,
  4930. Float:minx,Float:miny,Float:minz,
  4931. Float:maxx,Float:maxy,Float:maxz;
  4932. GetVehicleModelInfo(GetDynamicVehicleModel(vehicleid),VEHICLE_MODEL_INFO_SIZE,size_x,size_y,size_z);
  4933. size_x /= 2.0, size_y /= 2.0, size_z /= 2.0;
  4934. GetDynamicVehiclePos(vehicleid,x,y,z);
  4935. minx = x - size_x;
  4936. miny = y - size_y;
  4937. minz = z - size_z;
  4938. maxx = x + size_x;
  4939. maxy = y + size_y;
  4940. maxz = z + size_z;
  4941. if(!IsPointInStream(minx,miny,minz,StreamData)) return 0;
  4942. if(!IsPointInStream(minx,miny,maxz,StreamData)) return 0;
  4943. if(!IsPointInStream(minx,maxy,minz,StreamData)) return 0;
  4944. if(!IsPointInStream(minx,maxy,maxz,StreamData)) return 0;
  4945. if(!IsPointInStream(maxx,miny,minz,StreamData)) return 0;
  4946. if(!IsPointInStream(maxx,miny,maxz,StreamData)) return 0;
  4947. if(!IsPointInStream(maxx,maxy,minz,StreamData)) return 0;
  4948. if(!IsPointInStream(maxx,maxy,maxz,StreamData)) return 0;
  4949. return 1;
  4950. }
  4951. #endif
  4952. #endif
  4953. /************************************************************************************************************************************
  4954. * *
  4955. * Functions extra names *
  4956. * *
  4957. ************************************************************************************************************************************/
  4958. #define GetDistanceBetweenPoints GetDistanceBetweenPoints3D
  4959. #define GetPlayersDistance GetDistanceBetweenPlayers
  4960. #define GetVehiclesDistance GetDistanceBetweenVehicles
  4961. #define GetObjectsDistance GetDistanceBetweenObjects
  4962. /************************************************************************************************************************************
  4963. * *
  4964. * FilterScript/GameMode Init Hook *
  4965. * *
  4966. ************************************************************************************************************************************/
  4967. new bool:CRC_Tryg3DInit = true,
  4968. bool:CRC_Tryg3DExit = true,
  4969. T3D:FSAT = 0;
  4970. #define Tryg3D_GetActiveTime() (GetTickCount()-T3D:FSAT)
  4971. #define Tryg3D_GetVersion(%0) ((%0) / 10000),(((%0) % 10000) / 100),(((%0) % 10000) % 100)
  4972. #if defined Tryg3D_ColAndreas
  4973. forward OnColAndreasRemoveBuilding();
  4974. Tryg3D::Function:: Tryg3D::IsColAndreasInit(){
  4975. new Float:mapunit;
  4976. ColAndreas::FindZ_For2DCoord(0.0,0.0,mapunit);
  4977. return !(mapunit <= 0.0);
  4978. }
  4979. Tryg3D::Function:: Tryg3D::SafeColAndreasInit(){
  4980. //check ColAndreas Init
  4981. new bool:ColAndreasLastStat = false;
  4982. if(!Tryg3D::IsColAndreasInit()){
  4983. CallRemoteFunction("OnColAndreasRemoveBuilding","");
  4984. ColAndreas::Init();
  4985. ColAndreasLastStat = true;
  4986. }
  4987. if(!Tryg3D::IsColAndreasInit()){
  4988. if(GetSVarInt("ADM:Logging:Disable") == 0){
  4989. print("[ADM] Error: ColAndreas failed to initiated.");
  4990. print("[ADM] Error: Cannot load /scriptfiles/colandreas/ColAndreas.cadb (http://8.ct8.pl/d/ColAndreas%20Data%20Base)");
  4991. Update3DTrygErrorCount();
  4992. }
  4993. } else {
  4994. if(ColAndreasLastStat){
  4995. if(GetSVarInt("ADM:Logging:Disable") == 0){
  4996. print("[ADM] Info: ColAndreas successfully init.");
  4997. }
  4998. }
  4999. }
  5000. }
  5001. #endif
  5002. #if defined Tryg3D_MapAndreas
  5003. Tryg3D::Function:: Tryg3D::IsMapAndreasInit(){
  5004. new Float:mapunit;
  5005. MapAndreas_FindZ_For2DCoord(0.0,0.0,mapunit);
  5006. return !(mapunit <= 0.0);
  5007. }
  5008. //MapAndreas 1.2.1
  5009. Tryg3D::Function:: Tryg3D::SafeMapAndreasInit(mode = MAP_ANDREAS_MODE_FULL, name[]="", len=sizeof(name)){
  5010. //check MapAndreas Init
  5011. new bool:MapAndreasLastStat = false;
  5012. if(!Tryg3D::IsMapAndreasInit()){
  5013. MapAndreas_Init(mode,name,len);
  5014. MapAndreasLastStat = true;
  5015. }
  5016. if(!Tryg3D::IsMapAndreasInit()){
  5017. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5018. print("[ADM] Error: MapAndreas failed to initiated.");
  5019. print("[ADM] Error: Cannot load /scriptfiles/SAfull.hmap (http://8.ct8.pl/d/MapAndreas%201.2.1)");
  5020. Update3DTrygErrorCount();
  5021. }
  5022. } else {
  5023. if(MapAndreasLastStat){
  5024. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5025. print("[ADM] Info: MapAndreas successfully init.");
  5026. }
  5027. }
  5028. }
  5029. }
  5030. #endif
  5031. Tryg3D::Public:: Tryg3D::OnRequestResponse(index, response_code, data[]){
  5032. if(response_code == 200){
  5033. if(isnull(data)) return 0;
  5034. new T3D:version[16], T3D:ver, T3D:file_ver = Tryg3D::Version;
  5035. strmid(T3D:version,data,0,strlen(data));
  5036. T3D:ver = strval(T3D:version);
  5037. if(T3D:ver > T3D:file_ver){
  5038. print(" ");
  5039. printf("[ADM] Info: Please update your 3DTryg include to v%d.%d.%d from here:",Tryg3D::GetVersion(T3D:ver));
  5040. print("http://8.ct8.pl/d/3DTryg.inc");
  5041. print(" ");
  5042. }
  5043. }
  5044. return 1;
  5045. }
  5046. Tryg3D::Function:: Tryg3D::Init(){
  5047. T3D:FSAT = GetTickCount();
  5048. SetSVarInt("ADM:3DTryg:ACTIVE",Tryg3D::GetActiveCount()+1);
  5049. //Welcome to 3DTryg
  5050. new T3D:ver_name[16];
  5051. format(T3D:ver_name,sizeof(T3D:ver_name),"%d.%d.%d",Tryg3D::GetVersion(Tryg3D::Version));
  5052. if(GetSVarInt("ADM:3DTryg:INIT") == 0){
  5053. SetSVarInt("ADM:3DTryg:INIT",1);
  5054. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5055. printf("[ADM] Info: Load 3DTryg v%s for SA:MP %s by Abyss Morgan",T3D:ver_name,Tryg3D_SAMP_Version);
  5056. }
  5057. }
  5058. //Init Map Precision
  5059. #if !defined DISABLE_3D_TRYG_INIT
  5060. #if defined Tryg3D_ColAndreas
  5061. Tryg3D::SafeColAndreasInit();
  5062. #endif
  5063. #if defined Tryg3D_MapAndreas
  5064. Tryg3D::SafeMapAndreasInit(MAP_ANDREAS_MODE_FULL);
  5065. #endif
  5066. #endif
  5067. #if ((defined Tryg3D_MapAndreas) && (defined Tryg3D_FCNPC))
  5068. new T3D:MapAddress = MapAndreas_GetAddress();
  5069. if(T3D:MapAddress != 0){
  5070. FCNPC::InitMapAndreas(T3D:MapAddress);
  5071. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5072. print("[ADM] Info: MapAndreas successfully attached to FCNPC.");
  5073. }
  5074. } else {
  5075. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5076. print("[ADM] Error: MapAndreas failed attach to FCNPC (MapAndreas not inited).");
  5077. Update3DTrygErrorCount();
  5078. }
  5079. }
  5080. #endif
  5081. #if defined Tryg3D_FCNPC
  5082. if(!fexist("FCNPC/nodes")){
  5083. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5084. print("[ADM] Error: Plugin data not found /scriptfiles/FCNPC/nodes/*.dat (http://8.ct8.pl/d/FCNPC%20Nodes).");
  5085. Update3DTrygErrorCount();
  5086. }
  5087. }
  5088. #endif
  5089. if(GetSVarInt("ADM:3DTryg:VERCHECK") == 0){
  5090. SetSVarInt("ADM:3DTryg:VERCHECK",1);
  5091. SetSVarInt("ADM:3DTryg:VERSION",Tryg3D::Version);
  5092. new T3D:send_data[50];
  5093. format(T3D:send_data,sizeof(T3D:send_data),"8.ct8.pl/tryg3d/check.php?version=%d",Tryg3D::Version);
  5094. HTTP(0,HTTP_GET,T3D:send_data,"","Tryg3D_OnRequestResponse");
  5095. }
  5096. for(new i = 400; i <= 611; i++){
  5097. SetVehicleFlagsByModel(i,GetVehicleDefaultFlagsByModel(i));
  5098. }
  5099. }
  5100. Tryg3D::Function:: Tryg3D::Exit(){
  5101. SetSVarInt("ADM:3DTryg:ACTIVE",Tryg3D::GetActiveCount()-1);
  5102. //Goodbye 3DTryg
  5103. new T3D:ver_name[16];
  5104. format(T3D:ver_name,sizeof(T3D:ver_name),"%d.%d.%d",(Tryg3D::Version / 10000),((Tryg3D::Version % 10000) / 100),((Tryg3D::Version % 10000) % 100));
  5105. if(Tryg3D::GetActiveCount() == 0){
  5106. SetSVarInt("ADM:3DTryg:INIT",0);
  5107. if(GetSVarInt("ADM:Logging:Disable") == 0){
  5108. printf("[ADM] Info: Unload 3DTryg v%s for SA:MP %s by Abyss Morgan",T3D:ver_name,Tryg3D_SAMP_Version);
  5109. }
  5110. }
  5111. }
  5112. //Hook: OnFilterScriptInit
  5113. public OnFilterScriptInit(){
  5114. if(CRC_Tryg3DInit){
  5115. CRC_Tryg3DInit = false;
  5116. Tryg3D::Init();
  5117. }
  5118. #if defined Tryg3D_OnFilterScriptInit
  5119. Tryg3D_OnFilterScriptInit();
  5120. #endif
  5121. return 1;
  5122. }
  5123. #if defined _ALS_OnFilterScriptInit
  5124. #undef OnFilterScriptInit
  5125. #else
  5126. #define _ALS_OnFilterScriptInit
  5127. #endif
  5128. #define OnFilterScriptInit Tryg3D_OnFilterScriptInit
  5129. #if defined Tryg3D_OnFilterScriptInit
  5130. forward Tryg3D_OnFilterScriptInit();
  5131. #endif
  5132. //Hook: OnGameModeInit
  5133. public OnGameModeInit(){
  5134. if(CRC_Tryg3DInit){
  5135. CRC_Tryg3DInit = false;
  5136. Tryg3D::Init();
  5137. }
  5138. #if defined Tryg3D_OnGameModeInit
  5139. Tryg3D_OnGameModeInit();
  5140. #endif
  5141. return 1;
  5142. }
  5143. #if defined _ALS_OnGameModeInit
  5144. #undef OnGameModeInit
  5145. #else
  5146. #define _ALS_OnGameModeInit
  5147. #endif
  5148. #define OnGameModeInit Tryg3D_OnGameModeInit
  5149. #if defined Tryg3D_OnGameModeInit
  5150. forward Tryg3D_OnGameModeInit();
  5151. #endif
  5152. //Hook: OnFilterScriptExit
  5153. public OnFilterScriptExit(){
  5154. if(CRC_Tryg3DExit){
  5155. CRC_Tryg3DExit = false;
  5156. Tryg3D::Exit();
  5157. }
  5158. #if defined Tryg3D_OnFilterScriptExit
  5159. Tryg3D_OnFilterScriptExit();
  5160. #endif
  5161. return 1;
  5162. }
  5163. #if defined _ALS_OnFilterScriptExit
  5164. #undef OnFilterScriptExit
  5165. #else
  5166. #define _ALS_OnFilterScriptExit
  5167. #endif
  5168. #define OnFilterScriptExit Tryg3D_OnFilterScriptExit
  5169. #if defined Tryg3D_OnFilterScriptExit
  5170. forward Tryg3D_OnFilterScriptExit();
  5171. #endif
  5172. //Hook: OnGameModeExit
  5173. public OnGameModeExit(){
  5174. if(CRC_Tryg3DExit){
  5175. CRC_Tryg3DExit = false;
  5176. Tryg3D::Exit();
  5177. }
  5178. #if defined Tryg3D_OnGameModeExit
  5179. Tryg3D_OnGameModeExit();
  5180. #endif
  5181. return 1;
  5182. }
  5183. #if defined _ALS_OnGameModeExit
  5184. #undef OnGameModeExit
  5185. #else
  5186. #define _ALS_OnGameModeExit
  5187. #endif
  5188. #define OnGameModeExit Tryg3D_OnGameModeExit
  5189. #if defined Tryg3D_OnGameModeExit
  5190. forward Tryg3D_OnGameModeExit();
  5191. #endif
  5192. /************************************************************************************************************************************
  5193. * *
  5194. * Additional operations *
  5195. * *
  5196. ************************************************************************************************************************************/
  5197. #pragma unused Tryg3D_WeaponDamage
  5198. #pragma unused Tryg3D_StreamDistance
  5199. #pragma unused Tryg3D_DeatchTick
  5200. #pragma unused v3DFSAT
  5201. #undef Update3DTrygErrorCount
  5202. //EOF