3DTryg.inc 261 KB

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