1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379 |
- class PlayerBase extends ManBase
- {
- const int SIMPLIFIED_SHOCK_CAP = 63;
- const int SHAKE_LEVEL_MAX = 7;
- private int m_LifeSpanState;
- private int m_LastShavedSeconds;
- private int m_BloodType;
- private bool m_HasBloodTypeVisible;
- private bool m_LiquidTendencyDrain; //client-side only - Obsolete
- private bool m_FlagRaisingTendency;
- private int m_HasBloodyHandsVisible;
- protected bool m_HasHeatBuffer;
- protected int m_HeatBufferStage;
- protected float m_HeatBufferDynamicMax;
- protected bool m_IsInColdArea;
- protected bool m_PlayerLoaded;
- protected bool m_PlayerDisconnectProcessed;
- protected bool m_ProcessUIWarning;
- protected int m_LocalRefreshAnimStateIdx;
- protected int m_RefreshAnimStateIdx;
- private int m_StoreLoadVersion;
- const int ACT_STORE_SAVE_VERSION = 4;
- protected int m_LifespanLevelLocal; //control variable for change calls
- protected int m_AnimCommandStarting; //signals the command that is about to start the next frame (e.g. Swim, Fall...)
- EUndergroundPresence m_UndergroundPresence;
-
- private PluginPlayerStatus m_ModulePlayerStatus;
- PluginConfigEmotesProfile m_ConfigEmotesProfile;
- private PluginLifespan m_ModuleLifespan;
- protected PluginPresenceNotifier m_PresenceNotifier;
-
- protected ref UndergroundHandlerClient m_UndergroundHandler;
- protected ref UndergroundBunkerHandlerClient m_UndergroundBunkerHandler;
- ref PlayerStats m_PlayerStats;
- PluginRecipesManager m_ModuleRecipesManager;
- ref BleedingSourcesManagerServer m_BleedingManagerServer;
- ref BleedingSourcesManagerRemote m_BleedingManagerRemote;
- ref ModifiersManager m_ModifiersManager;
- ref NotifiersManager m_NotifiersManager;
- ref protected ActionManagerBase m_ActionManager;
- ref PlayerAgentPool m_AgentPool;
- int m_Agents;
- ref Environment m_Environment;
- ref EmoteManager m_EmoteManager;
- ref SymptomManager m_SymptomManager;
- ref VirtualHud m_VirtualHud;
- ref StaminaHandler m_StaminaHandler;
- ref InjuryAnimationHandler m_InjuryHandler;
- ref ShockHandler m_ShockHandler; //New shock handler
- ref SoftSkillsManager m_SoftSkillsManager;
- ref StanceIndicator m_StanceIndicator;
- ref TransferValues m_TrasferValues;
- ref DebugMonitorValues m_DebugMonitorValues;
- const int OVERLOAD_LIMIT = 30000;
- float m_CargoLoad;
- float m_VisibilityCoef;
- float m_OriginalSlidePoseAngle;
- int m_SoundEvent;
- int m_SoundEventParam;
- int m_FliesIndex;
- bool m_SoundEventSent;
- ref Param2<float,float> m_UAProgressParam;
- ref Param2<int,int> m_UAParam;
- ref Param3<float,float,bool> m_StaminaParam;
- ref Param1<string> m_UAParamMessage;
- ref Param1<float> m_UnconParam;
- ref Param1<float> m_DeathDarkeningParam;
- ref DamageDealtEffect m_DamageDealtEffect;
- ref EffectRadial m_EffectRadial;
- ref FlashbangEffect m_FlashbangEffect;
- ref ShockDealtEffect m_ShockDealtEffect;
- ref EffectParticle m_FliesEff;
- ref TInputActionMap m_InputActionMap; // Backwards compatibility
- ref TInputActionMap m_InputActionMapControled;
- ref TInputActionMap m_InputActionMapAsTarget;
- bool m_ActionsInitialize;
- //ref CraftingMeta m_CraftingMeta;
- ref HiddenSelectionsData m_EmptyGloves;
- ref WeaponManager m_WeaponManager;
- ref CraftingManager m_CraftingManager;
- ref ArrowManagerPlayer m_ArrowManager;
- ref InventoryActionHandler m_InventoryActionHandler;
- ref protected QuickBarBase m_QuickBarBase;
- ref PlayerSoundManagerServer m_PlayerSoundManagerServer;
- ref PlayerSoundManagerClient m_PlayerSoundManagerClient;
- ref HeatComfortAnimHandler m_HCAnimHandler;
- ref EffectSound m_SoundFliesEffect;
- bool m_QuickBarHold;
- bool m_QuickBarFT = false;
- Hud m_Hud;
- protected int m_RecipePick;
- protected bool m_IsHoldingBreath;
- protected bool m_IsInWater;
- float m_LastPostFrameTickTime;
- //AbstractWave m_SaySoundWave;
- ref Timer m_DeathCheckTimer;
- bool m_CorpseProcessing;
- int m_CorpseState;
- protected int m_CorpseStateLocal;
- protected bool m_IsHeadingRestricted;
- protected ref HeadingRestrictData m_HeadingRestrictData;
-
- int m_PersistentFlags;
- int m_StaminaState;
- float m_UnconsciousTime;
- int m_ShockSimplified;
- float m_CurrentShock; //Used to synchronize shock between server and client
- bool m_IsRestrained;
- bool m_IsRestrainedLocal;
- bool m_IsRestrainStarted;
- bool m_IsRestrainStartedLocal;
- bool m_IsRestrainPrelocked;
- bool m_ImmunityBoosted;
- bool m_AreHandsLocked; //Currently only used to block quickbar usage after canceling placement
- float m_UnconsciousVignetteTarget = 2;
- float m_CameraSwayModifier = 0.2;
- float m_LastShockHitTime;
- DayZPlayerCameraBase m_CurrentCamera;
- int m_BleedingBits;
- vector m_DirectionToCursor;
- vector m_DefaultHitPosition;
- int m_DiseaseCount;
- int m_HealingsCount;
- protected bool m_AllowQuickRestrain;
- protected bool m_AllowQuickFishing;
- protected int m_Shakes;
- protected int m_ShakesForced;
- int m_BreathVapour;
- int m_HealthLevel;
- int m_MixedSoundStates;
- int m_QuickBarBonus = 0;
- bool m_IsVehicleSeatDriver;
- float m_UnconsciousEndTime = 0;
- int m_BleedingSourceCount;
- Head_Default m_CharactersHead;
- EPulseType m_PulseType;
- PlayerBase m_CheckPulseLastTarget;
- int m_ForceInjuryAnimMask;
- bool m_HideHairAnimated;
- string m_DecayedTexture;
- protected ref array<EntityAI> m_ItemsToDelete;
- int m_BrokenLegState = eBrokenLegs.NO_BROKEN_LEGS; //Describe the current leg state, can go bellow 0, cannot be used directly to obtain broken legs state, use GetBrokenLegs() instead
- int m_LocalBrokenState = eBrokenLegs.NO_BROKEN_LEGS;
- bool m_BrokenLegsJunctureReceived;
- ref EffectSound m_BrokenLegSound;
- const string SOUND_BREAK_LEG = "broken_leg_SoundSet";
- bool m_CanPlayBrokenLegSound; //Used to check if sound has already been played
- static bool DEBUG_INVENTORY_ACCESS = false;
- static ref array<string> m_BleedingSourcesLow; //Stores all LOWER body part bleeding sources
- static ref array<string> m_BleedingSourcesUp; //Stores all UPPER body part bleeding sources EXCLUDING HEAD
- float m_UnconRefillModifier = 1;
- ref protected RandomGeneratorSyncManager m_RGSManager;
-
- // CONTAMINATED AREA RELATED
- bool m_ContaminatedAreaEffectEnabled;
- const string CONTAMINATED_AREA_AMBIENT = "ContaminatedArea_SoundSet";//obsolete, use EffectTrigger::GetAmbientSoundsetName() instead
- EffectSound m_AmbientContamination;
- protected int m_ContaminatedAreaCount;
- protected int m_EffectAreaCount;
- protected bool m_InsideEffectArea;
- protected bool m_InsideEffectAreaPrev;
- protected EffectTrigger m_CurrentEffectTrigger;
-
- // effect areas
- protected EEffectAreaType m_InEffectAreaType; // flags for identifying which area the player is in, synchronized by EffectTriggers
- protected ref map<EEffectAreaType, int> m_EffectAreaOverlap = new map<EEffectAreaType, int>(); // type -> how many of such areas is player currently in
- protected ref map<EEffectAreaType, float> m_EffectAreaTimeToTick = new map<EEffectAreaType, float>(); // type -> how long has player spent in an area since last effect tick
- static ref array<Man> m_ServerPlayers = new array<Man>;
- protected bool m_CanDisplayHitEffectPPE;
-
- protected string m_CachedPlayerName;//cached from player identity
- protected string m_CachedPlayerID;//cached from player identity
-
- #ifdef DIAG_DEVELOPER
- int m_IsInsideTrigger;
- bool m_CanBeTargetedDebug; //server-side only
- ref array<EntityAI> m_PresetItems = new array<EntityAI>;
- bool m_PresetSpawned;
- ref CameraToolsMenuClient m_CameraToolsMenuClient;
- protected PluginTargetTemperature m_TargetTemperatureDiag;
- #endif
-
- #ifdef DEVELOPER
- Transport m_GetInVehicleTransportDebug;
- #endif
-
- #ifdef DIAG_DEVELOPER
- ref Bot m_Bot;
- #endif
-
- //Temp QuickBar load
- ref array<ref Param2<EntityAI,int> > m_aQuickBarLoad;
-
- //hologram
- ref Hologram m_HologramServer;
- ref Hologram m_HologramLocal;
- vector m_LocalProjectionPosition = "0 0 0 ";
- vector m_LocalProjectionOrientation = "0 0 0 ";
- //Sheduler
- float m_LastTick = -1;
- int m_AddModifier = -1;
- //crafting start
- int m_RecipeID = -1;
- EntityAI m_Item1;
- EntityAI m_Item2;
- bool m_IsCraftingReady;
- float m_RecipeAnimLength;
- vector m_CraftingInitialPos;
- ref array<int> m_Recipes;
- //crafting end
- ref SoundParams m_SaySoundParams;
- ref SoundObjectBuilder m_SaySoundBuilder;
- ref SoundObject m_SaySoundObject;
- string m_SaySoundLastSetName;
- //input control
- bool m_ActionQBControl;
-
- //Action data for base building actions
- ref ConstructionActionData m_ConstructionActionData;
- //Action data for fireplace (indoor)
- vector m_LastFirePoint;
- float m_LastFirePointRot;
- int m_LastFirePointIndex;
-
- bool ItemToInventory;
- bool m_IsFighting = false;
- bool m_IsDrowning;//Set only via the setter SetDrowning
- // debug monitor
- int m_DebugMonitorEnabled;
-
- //map
- ActionUnfoldMapCB m_hac;
- bool m_MapOpen;
- bool m_MapCloseRequestProcessed; //DEPRECATED
- protected bool m_MapClosingSyncSent;
- protected float m_LastMapScale = -1.0;
- protected vector m_LastMapPos;
- protected ref MapNavigationBehaviour m_MapNavigationBehaviour;
-
- //inventory soft locking
- protected bool m_InventorySoftLocked; //obsolete, count should be checked instead. Left in here for legacy's sake.
- protected int m_InventorySoftLockCount = 0;
- static ref TStringArray m_QBarItems;
-
- //Analytics
- string m_DatabaseID;
- ref Timer m_AnalyticsTimer;
-
- //! melee stats
- protected bool m_MeleeDebug;
- //protected bool m_CheckMeleeItem;
- protected ItemBase m_CheckMeleeItem;
-
- //! user actions & symptoms
- protected string m_UALastMessage;
- protected ref Timer m_UALastMessageTimer;
- protected int m_PerformedAnimActionID = -1; // animated action being performed, -1 if none
- protected int m_ActivePrimarySymptomID = 0; // active primary symptom, 0 if none, symptom has to be overriden to allow sync
-
- bool m_WorkingNVGHeadset; //Deprecated
- bool m_LoweredNVGHeadset;
- protected ref array<int> m_ActiveNVTypes;
- //bool m_PreviousNVGState;
- int m_SyncedModifiers;
- int m_SyncedModifiersPrev;
- PluginAdminLog m_AdminLog;
- ref PlayerStomach m_PlayerStomach;
-
- protected static Particle m_ContaminatedAroundPlayer;
- protected static Particle m_ContaminatedAroundPlayerTiny;
-
- protected PlayerStat<float> m_StatWater;
- protected PlayerStat<float> m_StatToxicity;
- protected PlayerStat<float> m_StatEnergy;
- protected PlayerStat<float> m_StatHeatComfort;
- protected PlayerStat<float> m_StatTremor;
- protected PlayerStat<int> m_StatWet
- protected PlayerStat<int> m_StatBloodType
- protected PlayerStat<float> m_StatDiet
- protected PlayerStat<float> m_StatStamina
- protected PlayerStat<float> m_StatSpecialty
- protected PlayerStat<float> m_StatHeatBuffer
-
- //!effect widgets
- protected GameplayEffectWidgets_base m_EffectWidgets;
- protected ref array<int> m_ProcessAddEffectWidgets;
- protected ref array<int> m_ProcessRemoveEffectWidgets;
-
- //postprocess processing
- protected ref array<int> m_ProcessAddGlassesEffects;
- protected ref array<int> m_ProcessRemoveGlassesEffects;
-
- protected EMedicalDrugsType m_MedicalDrugsActive;
- //! invokers
- protected ref ScriptInvoker m_OnUnconsciousStart;
- protected ref ScriptInvoker m_OnUnconsciousStop;
-
- void PlayerBase()
- {
- Init();
- }
-
- void Init()
- {
- SetEventMask(EntityEvent.INIT|EntityEvent.POSTFRAME|EntityEvent.FRAME);
- m_StoreLoadVersion = 0;
- m_IsCraftingReady = false;
- m_Recipes = new array<int>;
- m_LastShavedSeconds = 0;
- m_BloodType = 0;
- m_HasBloodTypeVisible = false;
- m_LifeSpanState = 0;
- m_LifespanLevelLocal = -1;
- m_CorpseState = 0;
- m_CorpseStateLocal = 0;
- m_HasBloodyHandsVisible = 0;
- m_PlayerLoaded = false;
- m_PlayerSelected = false;
- m_ProcessUIWarning = false;
- m_FlagRaisingTendency = true;
- m_LiquidTendencyDrain = false;
- m_UAParamMessage = new Param1<string>("");
- m_UnconParam = new Param1<float>(0);
- m_DeathDarkeningParam = new Param1<float>(0);
- m_UAParam = new Param2<int,int>(0,0);
- m_UAProgressParam = new Param2<float,float>(0,0);
- m_QuickBarBase = new QuickBarBase(this);
- m_QuickBarBonus = Math.Max(ConfigGetInt("quickBarBonus"), 0);
- m_CargoLoad = 0;
- m_VisibilityCoef = 1.0;
- m_Hud = GetGame().GetMission().GetHud();
- m_RecipePick = 0;
- m_ActionQBControl = false;
- m_QuickBarHold = false;
- m_HideHairAnimated = true;
- m_WorkingNVGHeadset = false;
- m_LoweredNVGHeadset = false;
- m_AreHandsLocked = false;
- m_ItemsToDelete = new array<EntityAI>;
- m_AnimCommandStarting = HumanMoveCommandID.None;
- m_EmptyGloves = new HiddenSelectionsData(ConfigGetString("emptyGloves"));
- m_CanDisplayHitEffectPPE = true;
- m_HeadingRestrictData = new HeadingRestrictData();
-
- #ifdef DIAG_DEVELOPER
- m_CanBeTargetedDebug = true;
- //RegisterNetSyncVariableBool("m_CanBeTargetedDebug");
- #endif
-
- m_AnalyticsTimer = new Timer(CALL_CATEGORY_SYSTEM);
- m_StaminaHandler = new StaminaHandler(this);//current stamina calculation
- m_InjuryHandler = new InjuryAnimationHandler(this);
- m_ShockHandler = new ShockHandler(this); //New shock handler
- m_HCAnimHandler = new HeatComfortAnimHandler(this);
- m_PlayerStats = new PlayerStats(this);//player stats
- m_ArrowManager = new ArrowManagerPlayer(this);
-
- if (GetGame().IsServer())
- {
- m_PlayerStomach = new PlayerStomach(this);
- m_NotifiersManager = new NotifiersManager(this); // player notifiers
- m_AgentPool = new PlayerAgentPool(this); // agent pool manager
- m_BleedingManagerServer = new BleedingSourcesManagerServer(this);
- m_Environment = new Environment(this);//environment effects on player
- m_ModifiersManager = new ModifiersManager(this); // player modifiers
- m_PlayerSoundManagerServer = new PlayerSoundManagerServer(this);
- m_VirtualHud = new VirtualHud(this);
-
- m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
- }
-
- m_SymptomManager = new SymptomManager(this); // state manager
- m_ModuleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
-
- m_TrasferValues = new TransferValues(this);
- m_EmoteManager = new EmoteManager(this);
- m_SoftSkillsManager = new SoftSkillsManager(this);//Soft Skills calculation
-
- m_WeaponManager = new WeaponManager(this);
- m_DebugMonitorValues = new DebugMonitorValues(this);
- m_RGSManager = new RandomGeneratorSyncManager(this);
-
- if (!GetGame().IsDedicatedServer())
- {
- m_MeleeDebug = false;
- m_UALastMessage = "";
- m_UALastMessageTimer = new Timer;
- m_InventoryActionHandler = new InventoryActionHandler(this);
- m_BleedingManagerRemote = new BleedingSourcesManagerRemote(this);
- m_PlayerSoundManagerClient = new PlayerSoundManagerClient(this);
- m_StanceIndicator = new StanceIndicator(this);
- m_ActionsInitialize = false;
- ClientData.AddPlayerBase(this);
- m_ProcessAddEffectWidgets = new array<int>;
- m_ProcessRemoveEffectWidgets = new array<int>;
- m_ActiveNVTypes = new array<int>;
- m_ProcessAddGlassesEffects = new array<int>;
- m_ProcessRemoveGlassesEffects = new array<int>;
- }
- m_ActionManager = NULL;
-
- m_ConfigEmotesProfile = PluginConfigEmotesProfile.Cast(GetPlugin(PluginConfigEmotesProfile));
-
- if (GetDayZGame().IsDebug())
- {
- PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed = PluginConfigDebugProfileFixed.Cast(GetPlugin(PluginConfigDebugProfileFixed));
- PluginConfigDebugProfile m_ConfigDebugProfile = PluginConfigDebugProfile.Cast(GetPlugin(PluginConfigDebugProfile));
- PluginDeveloper m_Developer = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
-
- PlayerBase player = this;
-
- if (m_ConfigDebugProfile)
- {
- string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
- if (player && default_preset != "")
- {
- TStringArray preset_array = new TStringArray;
- m_ConfigDebugProfileFixed.GetPresetItems(default_preset, preset_array);
-
- bool is_preset_fixed = true;
- if (preset_array.Count() == 0)
- {
- m_ConfigDebugProfile.GetPresetItems(default_preset, preset_array);
- is_preset_fixed = false;
- }
-
- if (preset_array.Count() > 0)
- {
- m_Developer.ClearInventory(player);
-
- for (int i = 0; i < preset_array.Count(); i++)
- {
- float health = -1;
- int quantity = -1;
- if (is_preset_fixed)
- {
- health = m_ConfigDebugProfileFixed.GetItemHealth(default_preset, i);
- quantity = m_ConfigDebugProfileFixed.GetItemQuantity(default_preset, i);
- }
- else
- {
- health = m_ConfigDebugProfile.GetItemHealth(default_preset, i);
- quantity = m_ConfigDebugProfile.GetItemQuantity(default_preset, i);
- }
- m_Developer.SpawnEntityInPlayerInventory(player, preset_array.Get(i), health, quantity);
- }
- }
- }
- }
- }
-
- m_MedicalDrugsActive = EMedicalDrugsType.NONE;
-
- m_MapNavigationBehaviour = new MapNavigationBehaviour(this);
-
- m_ModulePlayerStatus = PluginPlayerStatus.Cast(GetPlugin(PluginPlayerStatus));
- m_ModuleLifespan = PluginLifespan.Cast(GetPlugin(PluginLifespan));
-
- m_BleedingSourcesLow = new array<string>;
- m_BleedingSourcesLow.Insert("RightToeBase");
- m_BleedingSourcesLow.Insert("RightFoot");
- m_BleedingSourcesLow.Insert("LeftToeBase");
- m_BleedingSourcesLow.Insert("LeftFoot");
- m_BleedingSourcesLow.Insert("RightUpLegRoll");
- m_BleedingSourcesLow.Insert("RightUpLeg");
- m_BleedingSourcesLow.Insert("RightLegRoll");
- m_BleedingSourcesLow.Insert("RightLeg");
- m_BleedingSourcesLow.Insert("LeftUpLegRoll");
- m_BleedingSourcesLow.Insert("LeftUpLeg");
- m_BleedingSourcesLow.Insert("LeftLegRoll");
- m_BleedingSourcesLow.Insert("LeftLeg");
-
- m_BleedingSourcesUp = new array<string>;
- m_BleedingSourcesUp.Insert("RightForeArmRoll");
- m_BleedingSourcesUp.Insert("LeftForeArmRoll");
- m_BleedingSourcesUp.Insert("RightForeArm");
- m_BleedingSourcesUp.Insert("RightArmRoll");
- m_BleedingSourcesUp.Insert("RightArm");
- m_BleedingSourcesUp.Insert("RightShoulder");
- m_BleedingSourcesUp.Insert("LeftForeArm");
- m_BleedingSourcesUp.Insert("LeftArmRoll");
- m_BleedingSourcesUp.Insert("LeftArm");
- m_BleedingSourcesUp.Insert("LeftShoulder");
- m_BleedingSourcesUp.Insert("Spine3");
- m_BleedingSourcesUp.Insert("Spine2");
- m_BleedingSourcesUp.Insert("Spine1");
- m_BleedingSourcesUp.Insert("Spine");
- m_BleedingSourcesUp.Insert("Pelvis");
- m_BleedingSourcesUp.Insert("Neck");
-
- RegisterNetSyncVariableInt("m_PersistentFlags", 0, 1<<(EnumTools.GetEnumSize(PersistentFlag) + 1));
- RegisterNetSyncVariableInt("m_LifeSpanState", LifeSpanState.BEARD_NONE, LifeSpanState.COUNT);
- RegisterNetSyncVariableInt("m_BloodType", 0, 128);
- RegisterNetSyncVariableInt("m_ShockSimplified",0, SIMPLIFIED_SHOCK_CAP);
- RegisterNetSyncVariableInt("m_SoundEvent",0, EPlayerSoundEventID.ENUM_COUNT - 1);
- RegisterNetSyncVariableInt("m_SoundEventParam", 0, ((EPlayerSoundEventParam.ENUM_COUNT - 1) * 2) - 1);
- RegisterNetSyncVariableInt("m_StaminaState",0, eStaminaState.COUNT - 1);
- RegisterNetSyncVariableInt("m_BleedingBits");
- RegisterNetSyncVariableInt("m_Shakes", 0, SHAKE_LEVEL_MAX);
- RegisterNetSyncVariableInt("m_BreathVapour", 0, BREATH_VAPOUR_LEVEL_MAX);
- RegisterNetSyncVariableInt("m_HealthLevel", eInjuryHandlerLevels.PRISTINE, eInjuryHandlerLevels.RUINED);
- RegisterNetSyncVariableInt("m_MixedSoundStates", 0, eMixedSoundStates.COUNT - 1);
- RegisterNetSyncVariableInt("m_CorpseState",-PlayerConstants.CORPSE_STATE_DECAYED,PlayerConstants.CORPSE_STATE_DECAYED);//do note the negative min, negative sign denotes a special meaning
- RegisterNetSyncVariableInt("m_RefreshAnimStateIdx",0,3);
- RegisterNetSyncVariableInt("m_BrokenLegState", -eBrokenLegs.BROKEN_LEGS_SPLINT, eBrokenLegs.BROKEN_LEGS_SPLINT);
- RegisterNetSyncVariableInt("m_SyncedModifiers", 0, ((eModifierSyncIDs.LAST_INDEX - 1) * 2) - 1);
- RegisterNetSyncVariableInt("m_HasBloodyHandsVisible", 0, eBloodyHandsTypes.LAST_INDEX - 1);
- RegisterNetSyncVariableInt("m_ActionSoundCategoryHash");
- RegisterNetSyncVariableInt("m_PerformedAnimActionID", -1, 2048); // generous upper limit for modding reasons
- RegisterNetSyncVariableInt("m_ActivePrimarySymptomID", 0, SymptomIDs.LAST_INDEX);
- RegisterNetSyncVariableInt("m_HeatBufferStage", 0, HeatBufferMdfr.NUMBER_OF_STAGES - 1);
- RegisterNetSyncVariableFloat("m_HeatBufferDynamicMax", 0.0, 1.0, 2);
-
- RegisterNetSyncVariableBool("m_IsUnconscious");
- RegisterNetSyncVariableBool("m_IsRestrained");
- RegisterNetSyncVariableBool("m_IsInWater");
- RegisterNetSyncVariableBool("m_InsideEffectArea");
-
- RegisterNetSyncVariableBool("m_HasBloodTypeVisible");
- RegisterNetSyncVariableBool("m_IsRestrainStarted");
- RegisterNetSyncVariableBool("m_IsRestrainPrelocked");
- RegisterNetSyncVariableBool("m_HasHeatBuffer");
- RegisterNetSyncVariableBool("m_IsInColdArea");
-
- RegisterNetSyncVariableFloat("m_CurrentShock"); //Register shock synchronized variable
-
- m_OriginalSlidePoseAngle = GetSlidePoseAngle();
-
- //! sets default hit position and cache it here (mainly for impact particles)
- m_DefaultHitPosition = SetDefaultHitPosition(GetDayZPlayerType().GetDefaultHitPositionComponent());
-
- m_DecayedTexture = ConfigGetString("decayedTexture");
- m_FliesIndex = -1;
- GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(this.OnPlayerLoaded);
- }
-
- ScriptInvoker GetOnUnconsciousStart()
- {
- if (!m_OnUnconsciousStart)
- m_OnUnconsciousStart = new ScriptInvoker();
- return m_OnUnconsciousStart;
- }
-
- ScriptInvoker GetOnUnconsciousStop()
- {
- if (!m_OnUnconsciousStop)
- m_OnUnconsciousStop = new ScriptInvoker();
- return m_OnUnconsciousStop;
- }
- void AddMedicalDrugsInUse(EMedicalDrugsType drugType)
- {
- if ((m_MedicalDrugsActive & drugType) != drugType)
- m_MedicalDrugsActive = m_MedicalDrugsActive | drugType;
- }
-
- void RemoveMedicalDrugsInUse(EMedicalDrugsType drugType)
- {
- if ((m_MedicalDrugsActive & drugType) == drugType)
- m_MedicalDrugsActive &= ~drugType;
- }
-
- bool IsChelationActive()
- {
- return (m_MedicalDrugsActive & EMedicalDrugsType.CHELATION) == EMedicalDrugsType.CHELATION;
- }
-
- bool IsAntibioticsActive()
- {
- return (m_MedicalDrugsActive & EMedicalDrugsType.ANTIBIOTICS) == EMedicalDrugsType.ANTIBIOTICS;
- }
-
- void SetSoundCategoryHash(int hash)
- {
- m_ActionSoundCategoryHash = hash;
- SetSynchDirty();
- }
-
- void SetPerformedActionID(int id)
- {
- m_PerformedAnimActionID = id;
- SetSynchDirty();
- }
-
- int GetPerformedActionID()
- {
- return m_PerformedAnimActionID;
- }
-
- void SetActivePrimarySymptomID(SymptomIDs id)
- {
- m_ActivePrimarySymptomID = id;
- SetSynchDirty();
- }
-
- SymptomIDs GetActivePrimarySymptomID()
- {
- return m_ActivePrimarySymptomID;
- }
-
- void RequestTriggerEffect(EffectTrigger trigger, int ppeIdx = -1, int aroundId = ParticleList.CONTAMINATED_AREA_GAS_AROUND, int tinyId = ParticleList.CONTAMINATED_AREA_GAS_TINY, string soundset = "", bool partDynaUpdate = false, int newBirthRate = 0, bool forceUpdate = false)
- {
- //do note multiple triggers can be calling this method within a single frame depending on the contaminated area setup and dynamic gameplay events(such as gas grenades being deployed)
-
- if (!m_InsideEffectArea)
- return;
- bool allow = false;
- if (!m_CurrentEffectTrigger)
- {
- allow = true;
- }
- else if (trigger == m_CurrentEffectTrigger && forceUpdate)
- {
- allow = true;
- //Print("ON Enabling effect FORCED " + trigger);
- }
- else if (trigger.GetEffectsPriority() > m_CurrentEffectTrigger.GetEffectsPriority())
- {
- RemoveCurrentEffectTrigger();
- allow = true;
- }
- if (allow)
- {
- /*
- Print("--------------------------------------------------");
- Print("ON Enabling effect " + trigger);
- Print("------------> soundset " + soundset);
- Print("--------------------------------------------------");
- */
- m_CurrentEffectTrigger = trigger;
- SetContaminatedEffectEx( true, ppeIdx, aroundId, tinyId, soundset,partDynaUpdate, newBirthRate );
- }
- }
-
-
- void RemoveCurrentEffectTrigger()
- {
- if (m_CurrentEffectTrigger)
- {
- /*
- Print("--------------------------------------------------");
- Print("OFF Disabling effect");
- Print("--------------------------------------------------");
- */
- SetContaminatedEffectEx( false, m_CurrentEffectTrigger.m_PPERequester );
- m_CurrentEffectTrigger = null;
- }
- }
-
- void IncreaseContaminatedAreaCount()
- {
- if (m_ContaminatedAreaCount == 0)
- OnContaminatedAreaEnterServer();
- m_ContaminatedAreaCount++;
- }
-
- void DecreaseContaminatedAreaCount()
- {
- m_ContaminatedAreaCount--;
- if (m_ContaminatedAreaCount <= 0)
- {
- m_ContaminatedAreaCount = 0;
- OnContaminatedAreaExitServer();
- }
- }
- void IncreaseEffectAreaCount()
- {
- if (m_EffectAreaCount == 0)
- {
- m_InsideEffectArea = true;
- SetSynchDirty();
- OnPlayerIsNowInsideEffectAreaBeginServer();
- }
- m_EffectAreaCount++;
- }
-
- void DecreaseEffectAreaCount()
- {
- m_EffectAreaCount--;
- if (m_EffectAreaCount <= 0)
- {
- m_EffectAreaCount = 0;
- m_InsideEffectArea = false;
- SetSynchDirty();
- OnPlayerIsNowInsideEffectAreaEndServer();
- }
- }
-
- void SetInEffectAreaTypeFlag(EEffectAreaType flag)
- {
- int areaCount = m_EffectAreaOverlap.Get(flag);
-
- if (areaCount > 0)
- m_EffectAreaOverlap.Set(flag, m_EffectAreaOverlap.Get(flag) + 1);
- else
- m_EffectAreaOverlap.Set(flag, 1);
-
- m_InEffectAreaType |= flag;
- }
-
- void UnsetInEffectAreaTypeFlag(EEffectAreaType flag)
- {
- int areaCount = m_EffectAreaOverlap.Get(flag);
-
- if (areaCount > 1)
- m_EffectAreaOverlap.Set(flag, m_EffectAreaOverlap.Get(flag) - 1);
- else
- {
- m_EffectAreaOverlap.Set(flag, 0);
- m_InEffectAreaType &= ~flag;
- }
- }
-
- bool IsInEffectArea(EEffectAreaType area)
- {
- if (m_InEffectAreaType & area)
- return true;
-
- return false;
- }
-
- // Server side update when player is present in any effect area
- protected void OnUpdateEffectAreaServer(float timeSlice)
- {
- float timeSpent;
-
- if (IsInEffectArea(EEffectAreaType.HOT_SPRING))
- {
- float waterLevel = GetCurrentWaterLevel();
- if (waterLevel > 0.5)
- {
- timeSpent = m_EffectAreaTimeToTick.Get(EEffectAreaType.HOT_SPRING);
- timeSpent += timeSlice;
- if (timeSpent > HotSpringTrigger.HEAT_DAMAGE_TICK_TIME)
- {
- m_EffectAreaTimeToTick.Set(EEffectAreaType.HOT_SPRING, 0);
- HotSpringTrigger.ApplyEffects(this);
- }
- else
- m_EffectAreaTimeToTick.Set(EEffectAreaType.HOT_SPRING, timeSpent);
- }
- }
-
- if (IsInEffectArea(EEffectAreaType.VOLCANIC))
- {
- timeSpent = m_EffectAreaTimeToTick.Get(EEffectAreaType.VOLCANIC);
- timeSpent += timeSlice;
- if (timeSpent > VolcanicTrigger.HEAT_DAMAGE_TICK_TIME)
- {
- m_EffectAreaTimeToTick.Set(EEffectAreaType.VOLCANIC, 0);
- VolcanicTrigger.ApplyEffects(this);
- }
- else
- m_EffectAreaTimeToTick.Set(EEffectAreaType.VOLCANIC, timeSpent);
- }
- }
-
- protected void OnContaminatedAreaEnterServer()
- {
- GetModifiersManager().ActivateModifier( eModifiers.MDF_AREAEXPOSURE );
- //Print("Contaminated ENTERED <------------------------------------------------------------- FINAL");
- }
-
- protected void OnContaminatedAreaExitServer()
- {
- GetModifiersManager().DeactivateModifier( eModifiers.MDF_AREAEXPOSURE );
- //Print("Contaminated LEFT <------------------------------------------------------------- FINAL");
- }
-
- protected void OnPlayerIsNowInsideEffectAreaBeginServer()
- {
- //Print("ANY EFFECT AREA ENTERED <------------------------------------------------------------- FINAL");
- }
-
- protected void OnPlayerIsNowInsideEffectAreaEndServer()
- {
- //Print("ANY EFFECT AREA LEFT <------------------------------------------------------------- FINAL");
- }
-
- protected void OnPlayerIsNowInsideEffectAreaBeginClient()
- {
- //Print("ANY EFFECT AREA ENTERED CLIENT <------------------------------------------------------------- FINAL");
- }
-
- protected void OnPlayerIsNowInsideEffectAreaEndClient()
- {
- RemoveCurrentEffectTrigger();
- //Print("ANY EFFECT AREA LEFT CLIENT <------------------------------------------------------------- FINAL");
- }
-
- //! Returns item that's on this player's attachment slot. Parameter slot_type should be a string from config parameter 'itemInfo[]' like "Legs", "Headgear" and so on.
- ItemBase GetItemOnSlot(string slot_type)
- {
- int slot_id = InventorySlots.GetSlotIdFromString(slot_type);
- EntityAI item_EAI = this.GetInventory().FindAttachment(slot_id);
- ItemBase item_IB = ItemBase.Cast(item_EAI);
-
- if (item_EAI && !item_IB)
- {
- string str = "Warning! GetItemOnSlot() >> found item on slot " + slot_type + " can't be cast to ItemBase! Found item is " + item_EAI.GetType() + " and the player is " + GetType() + "!";
- Error(str);
- return null;
- }
-
- return item_IB;
- }
-
- //! Returns item on player's head. For an example, a headtorch.
- ItemBase GetItemOnHead()
- {
- return GetItemOnSlot("Headgear");
- }
-
- override int GetQuickBarBonus()
- {
- return m_QuickBarBonus;
- }
-
- //--------------------------------------------------------------------------
- // Inventory overrides
- //--------------------------------------------------------------------------
- override bool CanDropEntity (notnull EntityAI item)
- {
- if (GetInventory().HasInventoryReservation(item, null))
- {
- return false;
- }
-
- if (IsRestrained())
- {
- if (GetHumanInventory().GetEntityInHands() == item)
- return false;
- }
-
- return true;
- }
- //--------------------------------------------------------------------------
- // PLAYER DAMAGE EVENT HANDLING
- //--------------------------------------------------------------------------
-
- int GetBreathVapourLevel()
- {
- return m_BreathVapour;
- }
-
- // adds state to and syncs sound states variable which is used to generate sound client-side
- void UnsetMixedSoundState(eMixedSoundStates state)
- {
- int bit_mask_remove = ~state;
-
- eMixedSoundStates new_states = m_MixedSoundStates & bit_mask_remove;
- if (new_states != m_MixedSoundStates)
- {
- m_MixedSoundStates = new_states;
- SetSynchDirty();
- }
- }
-
- // adds state to and syncs sound states variable which is used to generate sound client-side
- void SetMixedSoundState(eMixedSoundStates state)
- {
- eMixedSoundStates new_states = m_MixedSoundStates | state;
-
- if (new_states != m_MixedSoundStates)
- {
- m_MixedSoundStates = new_states;
- SetSynchDirty();
- }
- }
-
- override bool IsPlayer()
- {
- return true;
- }
-
- bool IsBleeding()
- {
- return (m_BleedingBits != 0);
- }
-
- void SetBleedingBits(int bits)
- {
- if (m_BleedingBits != bits)
- {
- if (m_BleedingBits == 0)
- {
- OnBleedingBegin();
- }
- else if (bits == 0)
- {
- OnBleedingEnd();
- }
- }
- m_BleedingBits = bits;
- SetSynchDirty();
- }
-
- int GetBleedingBits()
- {
- return m_BleedingBits;
- }
-
- void IncreaseDiseaseCount()
- {
- m_DiseaseCount++;
- }
-
- void DecreaseDiseaseCount()
- {
- m_DiseaseCount--;
- }
-
- void IncreaseHealingsCount()
- {
- m_HealingsCount++;
- }
-
- void DecreaseHealingsCount()
- {
- m_HealingsCount--;
- }
-
-
- bool HasHealings()
- {
- return m_HealingsCount;//0 for no healings, 1+ for healings, gets truncated to 1
- }
-
- bool HasDisease()
- {
- return m_DiseaseCount;//0 for no disease, 1+ for disease, gets truncated to 1
- }
-
-
- EPulseType GetPulseType()
- {
- return m_PulseType;
- }
-
- void SetPulseType(EPulseType pulse_type)
- {
- m_PulseType = pulse_type;
- }
-
- void QueueAddEffectWidget(array<int> effects)
- {
- m_ProcessAddEffectWidgets.InsertArray(effects);
- }
-
- void QueueRemoveEffectWidget(array<int> effects)
- {
- m_ProcessRemoveEffectWidgets.InsertArray(effects);
- }
-
- void QueueAddGlassesEffect(int id)
- {
- m_ProcessAddGlassesEffects.Insert(id);
- }
-
- void QueueRemoveGlassesEffect(int id)
- {
- m_ProcessRemoveGlassesEffects.Insert(id);
- }
-
- DamageDealtEffect GetDamageDealtEffect()
- {
- return m_DamageDealtEffect;
- }
-
- override void SpawnDamageDealtEffect()
- {
- if (m_DamageDealtEffect)
- {
- delete m_DamageDealtEffect;
- }
-
- if (m_CanDisplayHitEffectPPE)
- {
- m_DamageDealtEffect = new DamageDealtEffect();
- }
- }
-
- void SpawnDamageDealtEffect2(Param param1 = null, Param param2 = null)
- {
- if (m_EffectRadial)
- {
- delete m_EffectRadial;
- }
-
- m_EffectRadial = new EffectRadial(param1,param2);
- }
-
- FlashbangEffect GetFlashbangEffect()
- {
- return m_FlashbangEffect;
- }
-
- void SpawnFlashbangEffect(PlayerBase player, bool visual)
- {
- if (m_FlashbangEffect)
- {
- m_FlashbangEffect.Stop();
- delete m_FlashbangEffect;
- }
-
- m_FlashbangEffect = new FlashbangEffect(player, visual);
- }
-
- ShockDealtEffect GetShockEffect()
- {
- return m_ShockDealtEffect;
- }
-
- void SpawnShockEffect(float intensity_max)
- {
- if (m_ShockDealtEffect)
- {
- delete m_ShockDealtEffect;
- }
-
- m_ShockDealtEffect = new ShockDealtEffect(intensity_max);
- }
-
- override void EEKilled(Object killer)
- {
- //Print(Object.GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " event EEKilled, player has died at STS=" + GetSimulationTimeStamp());
-
- if (m_AdminLog)
- {
- m_AdminLog.PlayerKilled(this, killer);
- }
-
- if (GetBleedingManagerServer())
- delete GetBleedingManagerServer();
- // kill character in database
- if (GetHive())
- {
- GetHive().CharacterKill(this);
- }
-
- // disable voice communication
- GetGame().EnableVoN(this, false);
- if (!GetGame().IsDedicatedServer())
- ClientData.RemovePlayerBase(this);
- GetSymptomManager().OnPlayerKilled();
-
- if (GetEconomyProfile() && !m_CorpseProcessing && m_CorpseState == 0 && GetGame().GetMission().InsertCorpse(this))
- {
- m_CorpseProcessing = true;
- //Print("EEKilled - processing corpse");
- }
-
- if (GetGame().IsMultiplayer() && GetGame().IsServer())
- {
- if (GetGame().GetMission())
- {
- GetGame().GetMission().SyncRespawnModeInfo(GetIdentity());
- }
- }
-
- super.EEKilled(killer);
- }
- override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
- {
- super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
-
- if (m_AdminLog)
- {
- m_AdminLog.PlayerHitBy(damageResult, damageType, this, source, component, dmgZone, ammo);
- }
-
- if (damageResult != null && damageResult.GetDamage(dmgZone, "Shock") > 0)
- {
- m_LastShockHitTime = GetGame().GetTime();
-
- if (!IsUnconscious())
- {
- if (GetGame().ConfigIsExisting("cfgAmmo " + ammo + " unconRefillModifier"))
- {
- m_UnconRefillModifier = GetGame().ConfigGetInt("cfgAmmo " + ammo + " unconRefillModifier");
- }
- else
- {
- m_UnconRefillModifier = 1;
- }
- }
- }
-
- //! DT_EXPLOSION & FlashGrenade
- if (damageType == DT_EXPLOSION && ammo == "FlashGrenade_Ammo")
- {
- GetStaminaHandler().DepleteStamina(EStaminaModifiers.OVERALL_DRAIN);
- }
-
- //new bleeding computation
- //---------------------------------------
- if (damageResult != null && GetBleedingManagerServer())
- {
- float dmg = damageResult.GetDamage(dmgZone, "Blood");
- GetBleedingManagerServer().ProcessHit(dmg, source, component, dmgZone, ammo, modelPos);
- }
- //---------------------------------------
-
- #ifdef DIAG_DEVELOPER
- if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
- Print("EEHitBy() | " + GetDisplayName() + " hit by " + source.GetDisplayName() + " to " + dmgZone);
-
- PluginRemotePlayerDebugServer plugin_remote_server = PluginRemotePlayerDebugServer.Cast(GetPlugin(PluginRemotePlayerDebugServer));
- if (plugin_remote_server)
- {
- plugin_remote_server.OnDamageEvent(this, damageResult);
- }
- #endif
-
- if (GetGame().IsDebugMonitor())
- m_DebugMonitorValues.SetLastDamage(source.GetDisplayName());
-
- if (m_ActionManager)
- m_ActionManager.Interrupt();
-
- int transferShockToDamageCoef = g_Game.ConfigGetInt(string.Format("%1 %2 DamageApplied transferShockToDamage", CFG_AMMO, ammo));
- if (transferShockToDamageCoef == 1)
- {
- //Print("PlayerBase | EEHitBy | nonlethal hit");
- AddHealth("", "Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone, "Shock"), damageType));
- if (dmgZone != "Head")
- AddHealth(dmgZone, "Health", -damageResult.GetDamage(dmgZone, "Shock")); //Also deal damage to zone health, no dmg reduction
- }
-
- if (GetGame().IsServer())
- {
- if (GetHealth("RightLeg", "Health") <= 1 || GetHealth("LeftLeg", "Health") <= 1 || GetHealth("RightFoot", "Health") <= 1 || GetHealth("LeftFoot", "Health") <= 1)
- {
- if (GetModifiersManager().IsModifierActive(eModifiers.MDF_BROKEN_LEGS))//effectively resets the modifier
- {
- GetModifiersManager().DeactivateModifier(eModifiers.MDF_BROKEN_LEGS);
- }
- GetModifiersManager().ActivateModifier(eModifiers.MDF_BROKEN_LEGS);
- }
-
- if (ammo == "Bullet_CupidsBolt" && IsAlive())
- {
- DamageSystem.ResetAllZones(this);
- m_ModifiersManager.ResetAll();
- m_ModifiersManager.ActivateModifier(eModifiers.MDF_IMMUNITYBOOST);
-
- // bleeding sources
- if (m_BleedingManagerServer)
- m_BleedingManagerServer.RemoveAllSources();
-
- // Stats
- if (GetPlayerStats())
- {
- int bloodType = GetStatBloodType().Get();
- float energyValue = GetStatEnergy().Get();
- float waterValue = GetStatWater().Get();
- float heatBuffer = GetStatHeatBuffer().Get();
- float heatComfort = GetStatHeatComfort().Get();
- GetPlayerStats().ResetAllStats();
- GetStatBloodType().Set(bloodType);
- GetStatWater().Set(waterValue);
- GetStatEnergy().Set(energyValue);
- GetStatHeatBuffer().Set(heatBuffer);
- GetStatHeatComfort().Set(heatComfort);
- }
-
- // Agents
- if (m_AgentPool)
- m_AgentPool.RemoveAllAgents();
-
- if (m_StaminaHandler)
- m_StaminaHandler.SetStamina(GameConstants.STAMINA_MAX);
-
- // uncon
- if (IsUnconscious())
- DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, false);
- }
- }
-
- m_ShockHandler.CheckValue(true);
-
- //analytics
- GetGame().GetAnalyticsServer().OnEntityHit(source, this);
- }
-
- override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
- {
- super.EEHitByRemote(damageType, source, component, dmgZone, ammo, modelPos);
- if (m_MeleeFightLogic.IsInBlock())
- {
- EffectSound sound = SEffectManager.PlaySoundOnObject("BlockingAttack_SoundSet", this);
- sound.SetAutodestroy(true);
- }
- }
-
- override void EEDelete(EntityAI parent)
- {
- SEffectManager.DestroyEffect(m_FliesEff);
- StopSoundSet(m_SoundFliesEffect);
- if (GetArrowManager())
- GetArrowManager().ClearArrows();
- }
- override protected float ConvertNonlethalDamage(float damage, DamageType damageType)
- {
- if (damageType == DamageType.FIRE_ARM)
- return damage * GameConstants.NL_DAMAGE_FIREARM_CONVERSION_PLAYERS;
-
- return super.ConvertNonlethalDamage(damage, damageType);
- }
-
- /** Call only on client or single player PlayerBase
- * (as GetGame().GetPlayer())
- */
- override void OnReceivedHit(ImpactEffectsData hitData)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- float shakeStrength = Math.InverseLerp(0, 500, hitData.m_InSpeed.Length());
- GetCurrentCamera().SpawnCameraShake(shakeStrength);
- OnPlayerRecievedHit();
- }
-
- if (hitData.m_AmmoType == "Bullet_CupidsBolt")
- Ammo_CupidsBolt.PlayOnHitParticle(hitData.m_Position);
- }
- // DEPRECATED by method OnReceivedHit
- override void OnPlayerRecievedHit()
- {
- #ifndef NO_GUI
- if (m_MeleeFightLogic.IsInBlock())
- {
- EffectSound sound = SEffectManager.PlaySoundOnObject("BlockingAttack_SoundSet", this);
- sound.SetAutodestroy(true);
- return;
- }
- SpawnDamageDealtEffect();
- CachedObjectsParams.PARAM2_FLOAT_FLOAT.param1 = 32;
- CachedObjectsParams.PARAM2_FLOAT_FLOAT.param2 = 0.3;
- SpawnDamageDealtEffect2(CachedObjectsParams.PARAM2_FLOAT_FLOAT);
-
- CloseMapEx(true);
- #endif
- }
-
- void OnPlayerReceiveFlashbangHitStart(bool visual)
- {
- SpawnFlashbangEffect(this, visual);
- }
- void OnPlayerReceiveFlashbangHitEnd() {}
- //--------------------------------------------------------------------------
- //! Melee helpers
- //--------------------------------------------------------------------------
- //! select & return hit component for attacking AI
- override string GetHitComponentForAI()
- {
- return GetDayZPlayerType().GetHitComponentForAI();
- }
- //! returns default hit component (fallback)
- override string GetDefaultHitComponent()
- {
- return GetDayZPlayerType().GetDefaultHitComponent();
- }
-
- override vector GetDefaultHitPosition()
- {
- return m_DefaultHitPosition;
- }
-
- //! returns list of suitable finisher hit components (defined on base entity/entity type)
- override array<string> GetSuitableFinisherHitComponents()
- {
- return GetDayZPlayerType().GetSuitableFinisherHitComponents();
- }
-
- protected vector SetDefaultHitPosition(string pSelection)
- {
- return GetSelectionPositionMS(pSelection);
- }
- //--------------------------------------------------------------------------
- //!DEPRECATED!
- void AddPossibleCoverFaceForShave()
- {
- m_FaceCoveredForShaveLayers++;
- }
- //!DEPRECATED!
- void RemovePossibleCoverFaceForShave()
- {
- m_FaceCoveredForShaveLayers--;
- }
- //--------------------------------------------------------------------------
- override void EEItemAttached(EntityAI item, string slot_name)
- {
- super.EEItemAttached(item, slot_name);
- ItemBase itemIB = ItemBase.Cast(item);
- SwitchItemSelectionTexture(item, slot_name);
- Param1<PlayerBase> p = new Param1<PlayerBase>(this);
- item.SwitchItemSelectionTextureEx(EItemManipulationContext.ATTACHING, p);
- m_QuickBarBase.updateSlotsCount();
- CalculateVisibilityForAI();
- UpdateShoulderProxyVisibility(item, slot_name);
-
- HideHairSelections(itemIB,true);
-
- GetGame().GetAnalyticsClient().OnItemAttachedAtPlayer(item, slot_name);
- Clothing clothing = Clothing.Cast(item);
- if (clothing)
- {
- if (!GetGame().IsDedicatedServer())
- {
- if (clothing.GetEffectWidgetTypes())
- {
- QueueAddEffectWidget(clothing.GetEffectWidgetTypes());
- }
-
- if (clothing.GetGlassesEffectID() > -1)
- {
- QueueAddGlassesEffect(clothing.GetGlassesEffectID());
- }
-
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 200, false);//sometimes it takes a while to load in
- UpdateCorpseStateVisual();//....but if possible, we don't want a delay
- }
- else if (GetGame().IsServer())
- {
- if (clothing.IsGasMask())
- {
- GetModifiersManager().ActivateModifier(eModifiers.MDF_MASK);
- }
- }
-
- clothing.UpdateNVGStatus(this,true);
- }
-
- AdjustBandana(item,slot_name);
- AdjustShemag(item,slot_name);
- }
-
- override void EEItemDetached(EntityAI item, string slot_name)
- {
- super.EEItemDetached(item, slot_name);
- ItemBase item_base = ItemBase.Cast(item);
- SwitchItemSelectionTexture(item, slot_name);
- item.SwitchItemSelectionTextureEx(EItemManipulationContext.DETACHING);
- m_QuickBarBase.updateSlotsCount();
- CalculateVisibilityForAI();
-
- HideHairSelections(item_base,false);
-
- Clothing clothing = Clothing.Cast(item);
-
- if (clothing)
- {
- if (!GetGame().IsDedicatedServer())
- {
- if (clothing.GetEffectWidgetTypes())
- {
- QueueRemoveEffectWidget(clothing.GetEffectWidgetTypes());
- }
-
- if (clothing.GetGlassesEffectID() > -1)
- {
- QueueRemoveGlassesEffect(clothing.GetGlassesEffectID());
- }
- }
-
- if (GetGame().IsServer())
- {
- if (clothing.IsGasMask())
- {
- GetModifiersManager().DeactivateModifier(eModifiers.MDF_MASK);
- }
- }
-
- clothing.UpdateNVGStatus(this);
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 200, false);//sometimes it takes a while to load in
- UpdateCorpseStateVisual();//....but if possible, we don't want a delay
- }
- }
- void UpdateShoulderProxyVisibility(EntityAI item, string slot_name)
- {
- string slot = slot_name;
- bool boo;
- boo = item.IsWeapon();
-
- if (slot == "Melee")
- {
- SetSimpleHiddenSelectionState(SIMPLE_SELECTION_MELEE_RIFLE,boo);
- SetSimpleHiddenSelectionState(SIMPLE_SELECTION_MELEE_MELEE,!boo);
- }
- else if (slot == "Shoulder")
- {
- SetSimpleHiddenSelectionState(SIMPLE_SELECTION_SHOULDER_RIFLE,boo);
- SetSimpleHiddenSelectionState(SIMPLE_SELECTION_SHOULDER_MELEE,!boo);
- }
- }
-
- override void SwitchItemSelectionTexture(EntityAI item, string slot_name)
- {
- super.SwitchItemSelectionTexture(item,slot_name);
-
- //shirt + armband
- EntityAI armband = FindAttachmentBySlotName("Armband");
- if (slot_name == "Body" && armband)
- {
- Param1<PlayerBase> p = new Param1<PlayerBase>(this);
- armband.SwitchItemSelectionTextureEx(EItemManipulationContext.UPDATE,p);
- }
- }
-
- void RemoveAllItems()
- {
- array<EntityAI> itemsArray = new array<EntityAI>;
- ItemBase item;
- GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER, itemsArray);
-
- for (int i = 0; i < itemsArray.Count(); i++)
- {
- Class.CastTo(item, itemsArray.Get(i));
- if (item && !item.IsInherited(SurvivorBase)) GetInventory().LocalDestroyEntity(item);
- }
- }
-
- bool GetHitPPEEnabled()
- {
- return m_CanDisplayHitEffectPPE;
- }
-
- void SetHitPPEEnabled(bool enabled)
- {
- m_CanDisplayHitEffectPPE = enabled;
- }
-
- bool IsMale()
- {
- if (ConfigGetBool("woman") != 1)
- {
- return true;
- }
- return false;
- }
-
- int GetVoiceType()
- {
- int voice_type = ConfigGetInt("voiceType");
-
- if (voice_type == 0)
- {
- voice_type = 1;
- }
-
- return voice_type;
- }
-
- PlayerSoundManagerServer GetPlayerSoundManagerServer()
- {
- return m_PlayerSoundManagerServer;
- }
-
-
- UndergroundHandlerClient GetUndergroundHandler()
- {
- if (!m_UndergroundHandler && IsAlive())
- {
- m_UndergroundHandler = new UndergroundHandlerClient(this);
- }
-
- return m_UndergroundHandler;
- }
-
- UndergroundBunkerHandlerClient GetUndergroundBunkerHandler()
- {
- if (!m_UndergroundBunkerHandler && IsAlive())
- {
- m_UndergroundBunkerHandler = new UndergroundBunkerHandlerClient(this);
- }
-
- return m_UndergroundBunkerHandler;
- }
-
- void KillUndergroundHandler()
- {
- m_UndergroundHandler = null;
- m_UndergroundBunkerHandler = null;
- }
- // --------------------------------------------------
- // User Actions
- //---------------------------------------------------
- void SetActions(out TInputActionMap InputActionMap)
- {
- AddAction(ActionOpenDoors, InputActionMap);
- AddAction(ActionCloseDoors, InputActionMap);
- AddAction(ActionLockedDoors, InputActionMap);
- AddAction(ActionEnterLadder, InputActionMap);
- AddAction(ActionExitLadder, InputActionMap);
-
- //-----------CheckIfCanMOveToTarget----------
- AddAction(ActionStartEngine, InputActionMap);
- AddAction(ActionStartEngineBoat, InputActionMap);
- AddAction(ActionStopEngine, InputActionMap);
- AddAction(ActionStopEngineBoat, InputActionMap);
- AddAction(ActionSwitchSeats, InputActionMap);
- AddAction(ActionOpenCarDoors,InputActionMap);
- AddAction(ActionCloseCarDoors,InputActionMap);
- AddAction(ActionUncoverHeadSelf, InputActionMap);
- AddAction(ActionDrinkPondContinuous, InputActionMap);
- AddAction(ActionEatSnowContinuous, InputActionMap);
-
- AddAction(ActionIgniteFireplaceByAir, InputActionMap);
- AddAction(ActionMineBushByHand, InputActionMap);
-
- AddAction(ActionUngagSelf, InputActionMap);
- AddAction(ActionWashHandsWater, InputActionMap);
- AddAction(ActionWashHandsSnow, InputActionMap);
- AddAction(ActionGetOutTransport, InputActionMap);
-
- AddAction(ActionUnrestrainTargetHands, InputActionMap);
- AddAction(ActionTakeArrow, InputActionMap);
- AddAction(ActionTakeArrowToHands, InputActionMap);
- AddAction(ActionOperatePanelPowerStation, InputActionMap);
- }
-
- void SetActions() // Backwards compatibility, not recommended to use
- {
- }
-
- void SetActionsRemoteTarget(out TInputActionMap InputActionMap)
- {
- AddAction(ActionCPR, InputActionMap);
- AddAction(ActionUncoverHeadTarget, InputActionMap);
- AddAction(ActionUngagTarget, InputActionMap);
- AddAction(ActionPullBodyFromTransport, InputActionMap);
- AddAction(ActionCheckPulseTarget, InputActionMap);
- }
-
- void SetActionsRemoteTarget() // Backwards compatibility, not recommended to use
- {
- }
-
- void InitializeActions()
- {
- // Backwards compatibility
- if (IsControlledPlayer())
- {
- m_InputActionMap = new TInputActionMap;
- SetActions();
- }
- else
- {
- m_InputActionMap = new TInputActionMap;
- SetActionsRemoteTarget();
- }
- //////////////////////////
-
- m_InputActionMapControled = new TInputActionMap;
- SetActions(m_InputActionMapControled);
- m_InputActionMapAsTarget = new TInputActionMap;
- SetActionsRemoteTarget(m_InputActionMapAsTarget);
- }
-
- override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
- {
- if (!m_ActionsInitialize)
- {
- m_ActionsInitialize = true;
- InitializeActions();
- }
- // Backwards compatibility
- array<ActionBase_Basic> bcActions = m_InputActionMap.Get(action_input_type);
- if (!bcActions)
- {
- if (IsControlledPlayer())
- actions = m_InputActionMapControled.Get(action_input_type);
- else
- actions = m_InputActionMapAsTarget.Get(action_input_type);
- }
- else
- {
- if (!actions)
- actions = new array<ActionBase_Basic>();
-
- if (IsControlledPlayer())
- actions.InsertAll(m_InputActionMapControled.Get(action_input_type));
- else
- actions.InsertAll(m_InputActionMapAsTarget.Get(action_input_type));
-
- actions.InsertAll(bcActions);
- }
- }
-
- void AddAction(typename actionName, out TInputActionMap InputActionMap)
- {
- ActionBase action = GetActionManager().GetAction(actionName);
- typename ai = action.GetInputType();
- if (!ai)
- {
- m_ActionsInitialize = false;
- return;
- }
-
- ref array<ActionBase_Basic> action_array = InputActionMap.Get(ai);
-
- if (!action_array)
- {
- action_array = new array<ActionBase_Basic>;
- InputActionMap.Insert(ai, action_array);
- }
- action_array.Insert(action);
- }
-
- void AddAction(typename actionName) // Backwards compatibility, not recommended to use
- {
- AddAction(actionName, m_InputActionMap);
- }
-
- void RemoveAction(typename actionName, out TInputActionMap InputActionMap)
- {
- ActionBase action = GetActionManager().GetAction(actionName);
- typename ai = action.GetInputType();
- ref array<ActionBase_Basic> action_array = InputActionMap.Get(ai);
-
- if (action_array)
- {
- for (int i = 0; i < action_array.Count(); i++)
- {
- if (action == action_array.Get(i))
- {
- action_array.Remove(i);
- }
- }
- action_array = new array<ActionBase_Basic>;
- InputActionMap.Insert(ai, action_array);
- }
- action_array.Insert(action);
- }
-
- void RemoveAction(typename actionName) // Backwards compatibility, not recommended to use
- {
- RemoveAction(actionName, m_InputActionMap);
- }
-
- int GetCurrentRecipe()
- {
- return m_RecipePick;
- }
-
- void SetNextRecipe()
- {
- m_RecipePick++;
- }
-
- void SetFirstRecipe()
- {
- m_RecipePick = 0;
- }
-
- //---------------------------------------------------
-
-
- ActionManagerBase GetActionManager()
- {
- return m_ActionManager;
- }
-
- EmoteManager GetEmoteManager()
- {
- return m_EmoteManager;
- }
-
- RandomGeneratorSyncManager GetRandomGeneratorSyncManager()
- {
- return m_RGSManager;
- }
-
- //!called every command handler tick when player is on ladder
- override void OnLadder(float delta_time, HumanMovementState pState)
- {
- ProcessHandDamage(delta_time, pState);
- }
-
- void ProcessHandDamage(float delta_time, HumanMovementState pState)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
- {
- if (pState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SLIDE)
- {
- //Print("sliding down");
- EntityAI gloves = GetInventory().FindAttachment(InventorySlots.GLOVES);
-
- if (gloves && gloves.GetHealthLevel() < 4)
- {
- gloves.AddHealth("","", PlayerConstants.GLOVES_DAMAGE_SLIDING_LADDER_PER_SEC * delta_time);
- return;
- }
-
- if (Math.RandomFloat01() < PlayerConstants.CHANCE_TO_BLEED_SLIDING_LADDER_PER_SEC * delta_time)
- {
- if (Math.RandomFloat01() < 0.5)
- {
- if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll"))
- {
- SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
- }
- }
- else
- {
- if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightForeArmRoll"))
- {
- SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
- }
- }
- }
-
- }
- }
- }
-
- override void ProcessFeetDamageServer(int pUserInt)
- {
- //InventorySlots.HEADGEAR
- EntityAI shoes = GetInventory().FindAttachment(InventorySlots.FEET);
-
- string surface; int liquid;
- GetGame().SurfaceUnderObject(this, surface, liquid);
- float modifier_surface = Surface.GetParamFloat(surface, "footDamage");
-
- if (shoes && shoes.GetHealthLevel() < 4)
- {
- shoes.AddHealth("", "", -1 * modifier_surface * PlayerConstants.SHOES_MOVEMENT_DAMAGE_PER_STEP * (float)PlayerConstants.CHECK_EVERY_N_STEP);
- return;
- }
- float rnd = Math.RandomFloat01();
- float modifier_movement = GetFeetDamageMoveModifier();
- float chance = modifier_movement * modifier_surface * PlayerConstants.BAREFOOT_MOVEMENT_BLEED_MODIFIER * (float)PlayerConstants.CHECK_EVERY_N_STEP;
- if (rnd < chance)
- {
- if (pUserInt % 2 == 0)
- {
- if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightFoot"))
- SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
-
- }
- else
- {
- if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftFoot"))
- SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
- }
- }
- }
-
- float GetFeetDamageMoveModifier()
- {
- float modifier;
- switch(m_MovementState.m_iMovement)
- {
- case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
- modifier = 1;
- break
- case DayZPlayerConstants.MOVEMENTIDX_RUN:
- modifier = 0.5;
- break
- case DayZPlayerConstants.MOVEMENTIDX_WALK:
- modifier = 0;
- break
- }
- return modifier;
- }
-
- void SetStamina(int value, int range)
- {
- if (m_ModulePlayerStatus)
- m_ModulePlayerStatus.SetStamina(value, range);
- }
-
- #ifdef DIAG_DEVELOPER
- void SetStaminaDisabled(bool value)
- {
- if (m_StaminaHandler)
- m_StaminaHandler.SetStaminaDisabled(value);
- }
- #endif
-
- void SetQuickRestrain(bool enable)
- {
- m_AllowQuickRestrain = enable;
- }
-
- void SetQuickFishing(bool enable)
- {
- m_AllowQuickFishing = enable;
- }
-
- bool IsQuickRestrain()
- {
- return m_AllowQuickRestrain;
- }
-
- bool IsQuickFishing()
- {
- return m_AllowQuickFishing;
- }
-
- PlayerStats GetPlayerStats()
- {
- return m_PlayerStats;
- }
- CraftingManager GetCraftingManager()
- {
- return m_CraftingManager;
- }
-
- StaminaHandler GetStaminaHandler()
- {
- return m_StaminaHandler;
- }
-
- override WeaponManager GetWeaponManager()
- {
- return m_WeaponManager;
- }
-
- override ArrowManagerBase GetArrowManager()
- {
- return m_ArrowManager;
- }
-
- bool CanBeRestrained()
- {
- if (IsInVehicle() || IsRaised() || IsSwimming() || IsClimbing() || IsClimbingLadder() || IsRestrained() || !GetWeaponManager() || GetWeaponManager().IsRunning() || !GetActionManager() || GetActionManager().GetRunningAction() != null || IsMapOpen())
- {
- return false;
- }
- if (GetThrowing() && GetThrowing().IsThrowingModeEnabled())
- {
- return false;
- }
- return true;
- }
-
- void SetRestrainStarted(bool restrain_started)
- {
- m_IsRestrainStarted = restrain_started;
- SetSynchDirty();
- }
-
- bool IsRestrainStarted()
- {
- return m_IsRestrainStarted;
- }
-
- void SetRestrainPrelocked(bool restrain_prelock)
- {
- m_IsRestrainPrelocked = restrain_prelock;
- SetSynchDirty();
- }
-
- bool IsRestrainPrelocked()
- {
- return m_IsRestrainPrelocked;
- }
-
- void SetRestrained(bool is_restrained)
- {
- m_IsRestrained = is_restrained;
- SetSynchDirty();
- }
-
- override bool IsRestrained()
- {
- return m_IsRestrained;
- }
-
- void OnRestrainStartedChangeClient()
- {
- if (m_IsRestrainStarted && IsControlledPlayer())
- {
- if (GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
- GetGame().GetUIManager().FindMenu(MENU_RADIAL_QUICKBAR).Close();
- if (GetGame().GetUIManager().IsMenuOpen(MENU_INVENTORY))
- GetGame().GetMission().HideInventory();
- }
- }
-
- void OnRestrainChangeClient()
- {
- if (m_IsRestrained && IsControlledPlayer())
- {
- if (GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
- GetGame().GetUIManager().FindMenu(MENU_RADIAL_QUICKBAR).Close();
- if (GetGame().GetUIManager().IsMenuOpen(MENU_INVENTORY))
- GetGame().GetMission().HideInventory();
- }
- }
-
- override bool IsInventoryVisible()
- {
- return true;
- }
-
- bool CanManipulateInventory()
- {
- if (IsControlledPlayer())
- {
- return !IsRestrained() && !IsRestrainPrelocked() && !IsRestrainStarted();
- }
- return true;
- }
-
- override bool CanReleaseAttachment (EntityAI attachment)
- {
- return super.CanReleaseAttachment(attachment);
- }
-
- override bool CanReleaseCargo (EntityAI cargo)
- {
- return super.CanReleaseCargo(cargo);
- }
-
- override bool CanReceiveItemIntoCargo(EntityAI item)
- {
- return super.CanReceiveItemIntoCargo(item);
- }
-
- override bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
- {
- return super.CanSwapItemInCargo(child_entity, new_entity);
- }
-
- override bool CanReceiveItemIntoHands(EntityAI item_to_hands)
- {
- if (IsInVehicle())
- return false;
-
- if (!CanPickupHeavyItem(item_to_hands))
- return false;
-
- return super.CanReceiveItemIntoHands(item_to_hands);
- }
-
- override bool CanSaveItemInHands(EntityAI item_in_hands)
- {
- return super.CanSaveItemInHands(item_in_hands);
- }
-
- override bool CanReleaseFromHands(EntityAI handheld)
- {
- return super.CanReleaseFromHands(handheld);
- }
-
- int GetCraftingRecipeID()
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- return GetCraftingManager().GetRecipeID();
- }
- else
- {
- return m_RecipeID;
- }
- }
-
- void SetCraftingRecipeID(int recipeID)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- GetCraftingManager().SetRecipeID(recipeID);
- }
- else
- {
- m_RecipeID = recipeID;
- }
- }
-
- // --------------------------------------------------
- // Action data for base building actions
- //---------------------------------------------------
- ConstructionActionData GetConstructionActionData()
- {
- return m_ConstructionActionData;
- }
-
- void ResetConstructionActionData()
- {
- if (m_ConstructionActionData)
- {
- m_ConstructionActionData.ResetActionIndexes();
- }
- }
-
- // --------------------------------------------------
- // Action data for fireplace (indoor)
- //---------------------------------------------------
- vector GetLastFirePoint()
- {
- return m_LastFirePoint;
- }
- float GetLastFirePointRot()
- {
- return m_LastFirePointRot;
- }
- int GetLastFirePointIndex()
- {
- return m_LastFirePointIndex;
- }
- void SetLastFirePoint(vector last_fire_point)
- {
- m_LastFirePoint = last_fire_point;
- }
- void SetLastFirePointRot(float last_fire_point_rot)
- {
- m_LastFirePointRot = last_fire_point_rot;
- }
- void SetLastFirePointIndex(int last_fire_point_index)
- {
- m_LastFirePointIndex = last_fire_point_index;
- }
- // --------------------------------------------------
- // QuickBar
- //---------------------------------------------------
-
- void RemoveQuickBarEntityShortcut(EntityAI entity)
- {
- int index = m_QuickBarBase.FindEntityIndex(entity);
- if (index != -1)
- m_QuickBarBase.SetEntityShortcut(entity,-1);
- }
- //---------------------------------------------------
- void SetEnableQuickBarEntityShortcut(EntityAI entity, bool value)
- {
- int index = m_QuickBarBase.FindEntityIndex(entity);
- if (index != -1)
- m_QuickBarBase.SetShotcutEnable(index,value);
- }
- //---------------------------------------------------
- int FindQuickBarEntityIndex(EntityAI entity)
- {
- int index;
- index = m_QuickBarBase.FindEntityIndex(entity);
- if (m_QuickBarBase.GetEntity(index) == NULL)
- return -1;
- return index;
- }
- //---------------------------------------------------
-
- int GetQuickBarSize()
- {
- return m_QuickBarBase.GetSize();
- }
- //---------------------------------------------------
- EntityAI GetQuickBarEntity(int index)
- {
- return m_QuickBarBase.GetEntity(index);
- }
- //---------------------------------------------------
- void UpdateQuickBarEntityVisibility(EntityAI entity)
- {
- int i = FindQuickBarEntityIndex(entity);
- if (i >= 0)
- m_QuickBarBase.UpdateShotcutVisibility(i);
- }
- //---------------------------------------------------
- void SetQuickBarEntityShortcut(EntityAI entity, int index, bool force = false)
- {
- m_QuickBarBase.SetEntityShortcut(entity, index, force);
- }
- //---------------------------------------------------
- void OnQuickbarSetEntityRequest(ParamsReadContext ctx)
- {
- m_QuickBarBase.OnSetEntityRequest(ctx);
- }
- //---------------------------------------------------
- // Applies splint on all limbs.
- void ApplySplint()
- {
- float add_health_coef = 0.33;
- // The idea is to slightly increase health of broken limb so the player is still limping. Using more splints will help but each time less. 100% recovery can be achieved only through long term healing.
- if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
- {
- AddHealth("LeftLeg", "Health", (GetMaxHealth("LeftLeg", "Health") - GetHealth("LeftLeg", "Health") ) * add_health_coef );
- AddHealth("RightLeg", "Health", (GetMaxHealth("RightLeg", "Health") - GetHealth("RightLeg", "Health")) * add_health_coef );
- AddHealth("RightFoot", "Health", (GetMaxHealth("RightFoot", "Health") - GetHealth("RightFoot", "Health")) * add_health_coef );
- AddHealth("LeftFoot", "Health", (GetMaxHealth("LeftFoot", "Health") - GetHealth("LeftFoot", "Health")) * add_health_coef );
- }
- }
-
- void ProcessDrowning(float dT)
- {
- GetStaminaHandler().DepleteStamina(EStaminaModifiers.DROWN,dT);
-
- #ifndef SERVER
- //PP EFFECTS
- PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
- req.SetStamina01(GetStaminaHandler().GetStaminaNormalized());
- #endif
- }
-
- void SpawnDrowningBubbles()
- {
- if (!GetDrowningWaterLevelCheck())
- return;
- float bubbleFrequency = Math.Lerp(PlayerConstants.DROWNING_BUBBLE_FREQUENCY_MIN, PlayerConstants.DROWNING_BUBBLE_FREQUENCY_MAX, GetStaminaHandler().GetSyncedStaminaNormalized());
- int boneIdx = GetBoneIndexByName("Head");
-
- if (boneIdx != -1)
- {
- Particle p = ParticleManager.GetInstance().PlayInWorld(ParticleList.DROWNING_BUBBLES, "-0.03 0.15 0");
- if (p)
- AddChild(p, boneIdx);
- GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnDrowningBubbles, bubbleFrequency);
- }
- }
-
- void ProcessHoldBreath(float dT)
- {
- if (IsTryingHoldBreath() && CanStartConsumingStamina(EStaminaConsumers.HOLD_BREATH))
- {
- if (!m_IsHoldingBreath)
- {
- OnHoldBreathStart();
- m_IsHoldingBreath = true;
- }
- }
- else if (!IsTryingHoldBreath() || !CanConsumeStamina(EStaminaConsumers.HOLD_BREATH))
- {
- if (m_IsHoldingBreath) OnHoldBreathEnd();
- m_IsHoldingBreath = false;
- }
- }
-
- void OnHoldBreathStart()
- {
- //SendSoundEvent(SoundSetMap.GetSoundSetID("holdBreath_male_Char_SoundSet"));
- RequestSoundEventEx(EPlayerSoundEventID.HOLD_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
- }
-
- void OnHoldBreathExhausted()
- {
- RequestSoundEventEx(EPlayerSoundEventID.EXHAUSTED_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
- }
-
- void OnHoldBreathEnd()
- {
- //SendSoundEvent(SoundSetMap.GetSoundSetID("releaseBreath_male_Char_SoundSet"));
- RequestSoundEventEx(EPlayerSoundEventID.RELEASE_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
- }
-
- override bool IsHoldingBreath()
- {
- return m_IsHoldingBreath;
- }
-
- override bool IsRefresherSignalingViable()
- {
- return false;
- }
-
- override bool IsSelfAdjustingTemperature()
- {
- return IsAlive();
- }
-
- eMixedSoundStates GetMixedSoundStates()
- {
- return m_MixedSoundStates;
- }
-
- AbstractWave SaySoundSet(string name)
- {
- if (m_SaySoundLastSetName != name)
- {
- m_SaySoundParams = new SoundParams(name);
- m_SaySoundBuilder = new SoundObjectBuilder(m_SaySoundParams);
- m_SaySoundLastSetName = name;
- }
-
- m_SaySoundObject = m_SaySoundBuilder.BuildSoundObject();
- m_SaySoundObject.SetPosition(GetPosition());
- return GetGame().GetSoundScene().Play3D(m_SaySoundObject, m_SaySoundBuilder);
- }
- EntityAI FindCargoByBaseType(string searched_item)
- {
- EntityAI attachment;
- string item_name;
- int attcount = this.GetInventory().AttachmentCount();
-
- for (int att = 0; att < attcount; att++)
- {
- attachment = GetInventory().GetAttachmentFromIndex(att);
- if (attachment.IsItemBase())
- {
- item_name = attachment.GetType();
- if (GetGame().IsKindOf(item_name, searched_item))
- {
- return attachment;
- }
- }
- }
- return NULL;
- }
- void InitEditor()
- {
- if (GetGame().IsDebug())
- {
- if (!GetGame().IsMultiplayer() && GetGame().GetPlayer() && GetGame().GetPlayer().GetID() == this.GetID())
- {
- PluginSceneManager scene_editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
- scene_editor.InitLoad();
- }
- }
- }
-
- //---------------------------------------------------------------------------------------------------------------------------
- void OnPlayerLoaded()
- {
- InitEditor();
-
- //! initialize EnvironmentExposure data; waits for PlayerStats load
- if (m_Environment)
- m_Environment.Init();
-
- if (GetGame().IsMultiplayer() || GetGame().IsServer())
- {
- if (m_ModuleLifespan)
- {
- m_ModuleLifespan.SynchLifespanVisual(this, m_LifeSpanState, m_HasBloodyHandsVisible, m_HasBloodTypeVisible, m_BloodType);
- }
- }
-
- if (IsControlledPlayer())//true only on client for the controlled character
- {
- if (!m_VirtualHud)
- m_VirtualHud = new VirtualHud(this);
- if (m_Hud)
- {
- m_Hud.UpdateBloodName();
- PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Stop();
- PPERequesterBank.GetRequester(PPERequester_ShockHitReaction).Stop();
- PPERequesterBank.GetRequester(PPERequester_UnconEffects).Stop();
- GetGame().GetUIManager().CloseAll();
- GetGame().GetMission().SetPlayerRespawning(false);
- GetGame().GetMission().OnPlayerRespawned(this);
-
- m_Hud.ShowHudUI(true);
- m_Hud.ShowQuickbarUI(true);
- m_Hud.UpdateQuickbarGlobalVisibility();
- m_Hud.InitHeatBufferUI(this);
- }
- m_EffectWidgets = GetGame().GetMission().GetEffectWidgets();
- }
- if (!GetGame().IsDedicatedServer())
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 2000, false);//sometimes it takes a while to load in
- m_PlayerSoundEventHandler = new PlayerSoundEventHandler(this);
- m_ReplaceSoundEventHandler = new ReplaceSoundEventHandler(this);
- }
- int slotId = InventorySlots.GetSlotIdFromString("Head");
- m_CharactersHead = Head_Default.Cast(GetInventory().FindPlaceholderForSlot(slotId));
- CheckHairClippingOnCharacterLoad();
- UpdateHairSelectionVisibility();
- PreloadDecayTexture();
-
- Weapon_Base wpn = Weapon_Base.Cast(GetItemInHands());
- if (wpn)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE)
- {
- wpn.DelayedValidateAndRepair();
- }
- else
- {
- wpn.ValidateAndRepair();
- }
- }
- m_PlayerLoaded = true;
- }
-
- void SetPlayerDisconnected(bool state)
- {
- m_PlayerDisconnectProcessed = state;
- }
-
- bool IsPlayerDisconnected()
- {
- return m_PlayerDisconnectProcessed;
- }
- // --------------------------------------------------
- // Advanced placement
- //---------------------------------------------------
-
- //get hologram
- Hologram GetHologramServer()
- {
- return m_HologramServer;
- }
-
- Hologram GetHologramLocal()
- {
- return m_HologramLocal;
- }
-
- void PlacingStartServer(ItemBase item)
- {
- if (item)
- {
- m_HologramServer = new Hologram(this, GetLocalProjectionPosition(), item);
- GetHologramServer().SetProjectionPosition(GetLocalProjectionPosition());
- GetHologramServer().SetProjectionOrientation(GetLocalProjectionOrientation());
- GetHologramServer().GetProjectionEntity().OnPlacementStarted(this);
- GetHologramServer().CheckPowerSource();
- GetHologramServer().RefreshVisual();
- }
- }
-
- void PlacingStartLocal(ItemBase item)
- {
- if (GetGame().IsMultiplayer() && GetGame().IsServer())
- return;
-
- if (item)
- {
- m_HologramLocal = new Hologram(this, GetLocalProjectionPosition(), item);
- GetHologramLocal().GetProjectionEntity().OnPlacementStarted(this);
- }
- }
-
- void PlacingCancelServer()
- {
- EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
-
- if (IsPlacingServer())
- {
- GetHologramServer().CheckPowerSource();
- GetHologramServer().GetParentEntity().OnPlacementCancelled(this);
-
- delete m_HologramServer;
- return;
- }
- else if (entityInHands && entityInHands.HasEnergyManager())
- {
- if (entityInHands.GetCompEM().IsPlugged())
- entityInHands.OnPlacementCancelled(this);
- }
- }
-
- //Called when item placement is canceled, will prevent quickbar usage until the item the player was placing is back in hands
- void LockHandsUntilItemHeld()
- {
- m_AreHandsLocked = true;
- }
-
- void PlacingCancelLocal()
- {
- EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
- if (entityInHands && entityInHands.HasEnergyManager())
- {
- if (entityInHands.GetCompEM().IsPlugged())
- entityInHands.OnPlacementCancelled(this);
- }
- delete m_HologramLocal;
- }
-
- void PlacingCompleteServer()
- {
- SetLocalProjectionPosition(vector.Zero);
- delete m_HologramServer;
- }
-
- void PlacingCompleteLocal()
- {
- SetLocalProjectionPosition(vector.Zero);
- delete m_HologramLocal;
- }
-
- bool IsPlacingServer()
- {
- if (m_HologramServer)
- return true;
- return false;
- }
-
- bool IsPlacingLocal()
- {
- if (m_HologramLocal)
- return true;
-
- return false;
- }
-
- void SetDrowning(bool enable)
- {
- if (enable != m_IsDrowning)
- {
- if (enable)
- OnDrowningStart();
- else
- OnDrowningEnd();
- }
- m_IsDrowning = enable;
- }
-
- void OnDrowningStart()
- {
- #ifndef SERVER
- if (IsControlledPlayer())
- {
- PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
- req.Start();
- }
- //Particles
- SpawnDrowningBubbles();
- #endif
- }
-
- void OnDrowningEnd()
- {
- #ifndef SERVER
- if (IsControlledPlayer())
- {
- PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
- req.Stop();
- }
- GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(SpawnDrowningBubbles);
- #endif
- }
-
- bool TogglePlacingServer(int userDataType, ParamsReadContext ctx)
- {
- if (userDataType == INPUT_UDT_ADVANCED_PLACEMENT)
- {
- PlacingCancelServer();
- return true;
- }
-
- return false;
- }
-
- void RequestResetADSSync()
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && GetGame().IsMultiplayer())
- {
- if (ScriptInputUserData.CanStoreInputUserData())
- {
- ScriptInputUserData ctx = new ScriptInputUserData;
- ctx.Write(INPUT_UDT_RESET_ADS);
- ctx.Send();
- }
- }
- else if (!GetGame().IsMultiplayer())
- {
- m_ResetADS = true;
- }
- }
-
- //! server only
- bool ResetADSPlayerSync(int userDataType, ParamsReadContext ctx)
- {
- if (userDataType == INPUT_UDT_RESET_ADS)
- {
- ScriptJunctureData pCtx = new ScriptJunctureData;
- SendSyncJuncture(DayZPlayerSyncJunctures.SJ_ADS_RESET,pCtx);
- return true;
- }
-
- return false;
- }
-
- override bool CanPlaceItem(EntityAI item)
- {
- if (m_UndergroundPresence > EUndergroundPresence.NONE)
- {
- TStringSet disallowedUndergroundTypes = CfgGameplayHandler.GetDisallowedTypesInUnderground();
- foreach (string t: disallowedUndergroundTypes)
- {
- if (item.IsKindOf(t))
- return false;
- }
- }
- return true;
- }
-
- void SetUnderground(EUndergroundPresence presence)
- {
- m_UndergroundPresence = presence;
- }
-
- void TogglePlacingLocal(ItemBase item = null)
- {
- if (IsPlacingLocal())
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && GetGame().IsMultiplayer())
- {
- if (ScriptInputUserData.CanStoreInputUserData())
- {
- ScriptInputUserData ctx = new ScriptInputUserData;
- ctx.Write(INPUT_UDT_ADVANCED_PLACEMENT);
- ctx.Send();
- }
- }
- PlacingCancelLocal();
- }
- else if (!item)
- {
- PlacingStartLocal(GetItemInHands());
- }
- else
- {
- PlacingStartLocal(item);
- }
- }
- void SetLocalProjectionPosition(vector local_position)
- {
- m_LocalProjectionPosition = local_position;
- }
-
- void SetLocalProjectionOrientation(vector local_orientation)
- {
- m_LocalProjectionOrientation = local_orientation;
- }
-
- vector GetLocalProjectionPosition()
- {
- return m_LocalProjectionPosition;
- }
-
- vector GetLocalProjectionOrientation()
- {
- return m_LocalProjectionOrientation;
- }
-
- void SetInColdArea(bool state)
- {
- if (m_IsInColdArea != state)
- {
- m_IsInColdArea = state;
- SetSynchDirty();
- }
- }
-
- bool GetInColdArea()
- {
- return m_IsInColdArea;
- }
-
- // ------------------------------------------------------------------------
- //! water contact (driven by Environment)
- void SetInWater(bool pState)
- {
- m_IsInWater = pState;
- SetSynchDirty();
- }
- bool IsInWater()
- {
- return m_IsInWater;
- }
- // -------------------------------------------------------------------------
- void ~PlayerBase()
- {
- if (GetGame() && (!GetGame().IsDedicatedServer()))
- {
- ClientData.RemovePlayerBase(this);
- SetContaminatedEffectEx(false);
- }
-
- SEffectManager.DestroyEffect(m_FliesEff);
- StopSoundSet(m_SoundFliesEffect);
- }
- void OnCameraChanged(DayZPlayerCameraBase new_camera)
- {
- m_CameraSwayModifier = new_camera.GetWeaponSwayModifier();
- m_CurrentCamera = new_camera;
- }
-
- DayZPlayerCamera GetCurrentPlayerCamera()
- {
- return m_CurrentCamera;
- }
-
- bool IsCurrentCameraAimedAtGround()
- {
- if (!m_CurrentCamera)
- return false;
-
- return m_CurrentCamera.GetCurrentPitch() < PlayerConstants.CAMERA_THRESHOLD_PITCH;
- }
-
- BleedingSourcesManagerServer GetBleedingManagerServer()
- {
- return m_BleedingManagerServer;
- }
-
- BleedingSourcesManagerRemote GetBleedingManagerRemote()
- {
- return m_BleedingManagerRemote;
- }
- SymptomManager GetSymptomManager()
- {
- return m_SymptomManager;
- }
- VirtualHud GetVirtualHud()
- {
- if (!m_VirtualHud)
- {
- m_VirtualHud = new VirtualHud(this);
- }
- return m_VirtualHud;
- }
- TransferValues GetTransferValues()
- {
- return m_TrasferValues;
- }
- DebugMonitorValues GetDebugMonitorValues()
- {
- return m_DebugMonitorValues;
- }
-
- //--------------------------------------------------------------------------
- void OnScheduledTick(float deltaTime)
- {
- if (!IsPlayerSelected() || !IsAlive())
- return;
- if (m_ModifiersManager)
- m_ModifiersManager.OnScheduledTick(deltaTime);
- if (m_NotifiersManager)
- m_NotifiersManager.OnScheduledTick();
- if (m_TrasferValues)
- m_TrasferValues.OnScheduledTick(deltaTime);
- if (m_VirtualHud)
- m_VirtualHud.OnScheduledTick();
- if (GetBleedingManagerServer())
- GetBleedingManagerServer().OnTick(deltaTime);
- if (m_Environment)
- m_Environment.Update(deltaTime);
- // Check if electric device needs to be unplugged
- ItemBase heldItem = GetItemInHands();
- if (heldItem && heldItem.HasEnergyManager() && heldItem.GetCompEM().IsPlugged())
- {
- // Now we know we are working with an electric device which is plugged into a power source.
- EntityAI placed_entity = heldItem;
-
- // Unplug the device when the player is too far from the power source.
- placed_entity.GetCompEM().UpdatePlugState();
- }
- }
-
- void OnCommandHandlerTick(float delta_time, int pCurrentCommandID)
- {
- if (!IsAlive())
- {
- if (!m_DeathSyncSent && m_KillerData)
- {
- SyncEvents.SendEntityKilled(this, m_KillerData.m_Killer, m_KillerData.m_MurderWeapon, m_KillerData.m_KillerHiTheBrain);
- m_DeathSyncSent = true;
- }
- return;
- }
- if (m_DebugMonitorValues)
- m_DebugMonitorValues.OnScheduledTick(delta_time);
- if (GetSymptomManager())
- GetSymptomManager().OnTick(delta_time, pCurrentCommandID, m_MovementState);//needs to stay in command handler tick as it's playing animations
- //if (GetBleedingManagerServer()) GetBleedingManagerServer().OnTick(delta_time);
-
- DayZPlayerInstanceType instType = GetInstanceType();
- if (instType == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- if (m_PlayerSoundEventHandler)
- m_PlayerSoundEventHandler.OnTick(delta_time);
-
- if (m_ProcessRemoveEffectWidgets && m_ProcessRemoveEffectWidgets.Count() > 0)
- {
- m_EffectWidgets.RemoveActiveEffects(m_ProcessRemoveEffectWidgets);
- }
-
- if (m_ProcessAddEffectWidgets && m_ProcessAddEffectWidgets.Count() > 0)
- {
- m_EffectWidgets.AddActiveEffects(m_ProcessAddEffectWidgets);
- }
-
- HandleGlassesEffect();
-
- if (m_ContaminatedAreaEffectEnabled)
- ContaminatedParticleAdjustment();
-
- #ifdef DIAG_DEVELOPER
- if (m_WeaponDebug)
- {
- m_WeaponDebug.OnCommandHandlerUpdate();
- }
- #endif
-
- m_ProcessAddEffectWidgets.Clear(); //clears array for remotes as well
- m_ProcessRemoveEffectWidgets.Clear(); //clears array for remotes as well
- }
-
- m_AnimCommandStarting = HumanMoveCommandID.None;
- if (CfgGameplayHandler.GetAllowStaminaAffectInertia())
- UpdateMovementInertia();
- }
-
- //! Update movement inertia based on stamina available
- void UpdateMovementInertia()
- {
- HumanCommandMove hcm = GetCommand_Move();
- if (hcm)
- {
- float staminaPercentage = GetStaminaHandler().GetSyncedStaminaNormalized();
- hcm.SetTurnSpanSprintModifier(2 - staminaPercentage);
- hcm.SetRunSprintFilterModifier((2 - staminaPercentage) * 0.5);
- hcm.SetDirectionSprintFilterModifier(2 - staminaPercentage);
- }
- }
-
- bool m_ShowDbgUI = true;
- int m_DbgListSelection = 0;
- float m_DbgSliderValue = 0.0;
- ref array<string> m_DbgOptions = {"jedna", "dva", "tri"};
-
- NotifiersManager GetNotifiersManager()
- {
- return m_NotifiersManager;
- }
- //--------------------------------------------------------------------------
- void OnTick()
- {
- float deltaT = (GetGame().GetTime() - m_LastTick) * 0.001;
- if (m_LastTick < 0)
- deltaT = 0; //first tick protection
- m_LastTick = GetGame().GetTime();
-
- OnScheduledTick(deltaT);
- }
- // -------------------------------------------------------------------------
- override void EEItemIntoHands(EntityAI item)
- {
- super.EEItemIntoHands(item);
- if (item)
- {
- MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(item, {Bolt_Base});
- Weapon_Base w;
- if (Class.CastTo(w, item))
- {
- w.ResetWeaponAnimState();
-
- HumanCommandMove cm = GetCommand_Move();
- if (cm)
- {
- cm.SetMeleeBlock(false);
- GetMeleeFightLogic().SetBlock(false);
- }
- }
- //! fixes situation where raise is canceling some manipulation with heavy item(ex. TakeItemToHands), forces normal stance
- if (item.IsHeavyBehaviour() && IsRaised())
- {
- HumanCommandMove cm2 = GetCommand_Move();
- if (cm2)
- {
- cm2.ForceStance(DayZPlayerConstants.STANCEIDX_ERECT);
- }
- }
-
- OnItemInHandsChanged();
- }
- }
-
- override void EEItemOutOfHands(EntityAI item)
- {
- super.EEItemOutOfHands(item);
- if (IsPlacingLocal())
- {
- GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(TogglePlacingLocal);
- }
-
- OnItemInHandsChanged();
- }
-
- PlayerStomach GetStomach()
- {
- return m_PlayerStomach;
- }
-
- override void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
- {
- EvaluateDamageHit(pCurrentCommandID);
- // lower implement
- super.CommandHandler(pDt,pCurrentCommandID,pCurrentCommandFinished);
- vector playerPosition = PhysicsGetPositionWS();
- HumanInputController hic = GetInputController();
-
- CheckZeroSoundEvent();
- CheckSendSoundEvent();
-
- ProcessADDModifier();
- if (m_BrokenLegsJunctureReceived)//was there a change in broken legs state ?
- {
- m_BrokenLegsJunctureReceived = false;
- bool initial = m_BrokenLegState < 0;//negative values indicate initial activation
- if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
- {
- DropHeavyItem();
- if (initial)
- {
- BrokenLegForceProne();
- hic.ResetADS();
- GetUApi().GetInputByID(UATempRaiseWeapon).Supress();
- ExitSights();
- }
- }
- }
-
- GetDayZPlayerInventory().HandleInventory(pDt);
-
- if (IsFireWeaponRaised() || m_IsHoldingBreath)
- {
- ProcessHoldBreath(pDt);
- }
- ActionManagerBase mngr = GetActionManager();
-
- if (m_AreHandsLocked && GetHumanInventory().GetEntityInHands())
- {
- m_AreHandsLocked = false;
- }
-
- // freelook camera memory for weapon raycast
- if (hic.CameraIsFreeLook() && m_DirectionToCursor == vector.Zero)
- {
- m_DirectionToCursor = GetGame().GetCurrentCameraDirection();
- }
- else if (!hic.CameraIsFreeLook() && m_DirectionToCursor != vector.Zero)
- {
- m_DirectionToCursor = vector.Zero;
- }
-
- if (m_WeaponManager)
- {
- m_WeaponManager.Update(pDt);
- }
- if (m_EmoteManager && IsPlayerSelected())
- {
- m_EmoteManager.Update(pDt);
- }
- if (m_RGSManager)
- {
- m_RGSManager.Update();
- }
- if (m_StanceIndicator)
- {
- m_StanceIndicator.Update();
- }
- if (m_StaminaHandler)
- {
- m_StaminaHandler.Update(pDt, pCurrentCommandID);
- }
- if (m_InjuryHandler)
- {
- m_InjuryHandler.Update(pDt);
- }
- if (m_HCAnimHandler)
- {
- m_HCAnimHandler.Update(pDt, m_MovementState);
- }
- if (m_ShockHandler)
- {
- m_ShockHandler.Update(pDt);
- }
-
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
- {
- GetPlayerSoundManagerServer().Update();
- ShockRefill(pDt);
- FreezeCheck();
- }
-
- GetHumanInventory().Update(pDt);
- if (m_IsDrowning)
- {
- ProcessDrowning(pDt);
- }
- UpdateDelete();
-
- HandleDamageHit(pCurrentCommandID);
-
- if (mngr && hic)
- {
- mngr.Update(pCurrentCommandID);
- HumanCommandUnconscious hcu = GetCommand_Unconscious();
- HumanCommandVehicle hcv = GetCommand_Vehicle();
- if (!m_UnconsciousDebug)
- {
- //! When the player should be and is unconscious
- if (m_ShouldBeUnconscious && m_IsUnconscious)
- {
- if (hcu)
- {
- //! Player can start floating while unconscious
- m_Swimming.m_bWasSwimming |= hcu.IsInWater();
- }
- if (m_Swimming.m_bWasSwimming)
- {
- m_LastCommandBeforeUnconscious = DayZPlayerConstants.COMMANDID_SWIM;
- }
- OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
- }
- //! When the player will be unconscious, or is being blocked from being unconscious
- else if (m_ShouldBeUnconscious)
- {
- //! If the player is getting in/out or switching seats, delay unconsciousness until after animation has finished
- bool isTransitioning = hcv && (hcv.IsGettingIn() || hcv.IsGettingOut() || hcv.IsSwitchSeat());
- if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
- {
- OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
- m_IsUnconscious = true;
- OnUnconsciousStart();
- }
- //! Death gate - prevent unlikely occurence of death -> unconsciousness transition
- //! Fall gate - prevent unconciousness animation from playing while falling, doesn't look good
- //! Transition gate - prevent unconciousness while previous command is transitioning
- else if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH && pCurrentCommandID != DayZPlayerConstants.COMMANDID_FALL && !isTransitioning)
- {
- m_LastCommandBeforeUnconscious = pCurrentCommandID;
- if (hcv)
- {
- m_TransportCache = hcv.GetTransport();
- }
- else
- {
- m_TransportCache = null;
- }
-
- //! TODO: rework vehicle command Knockout back to force player prone after they have exited the vehicle
- m_JumpClimb.CheckAndFinishJump();
- StartCommand_Unconscious(0);
- SetFallYDiff(playerPosition[1]);
- }
- }
- //! When the player is waking up
- else if (m_IsUnconscious)
- {
- //! Make sure the player is actually unconscious
- if (hcu && pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
- {
- OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
- //! protection for a player being broken when attempting to wake them up too early into unconsciousness
- if (m_UnconsciousTime > 2)
- {
- int wakeUpStance = DayZPlayerConstants.STANCEIDX_PRONE;
- //! Don't set the stance if we are swimming or in a vehicle, stance change animation could play
- if (m_Swimming.m_bWasSwimming || m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE)
- wakeUpStance = -1;
- hcu.WakeUp(wakeUpStance);
- m_IsUnconscious = false;
- OnUnconsciousStop(pCurrentCommandID);
- }
- }
- else
- {
- //! Maybe instead error out or notify of possible desync?
- if (IsAlive())
- {
- m_IsUnconscious = false;
- OnUnconsciousStop(pCurrentCommandID);
- }
- }
- }
- }
-
- // quickbar use
- int quickBarSlot = hic.IsQuickBarSlot();
- if (quickBarSlot && IsAlive())
- {
- if (hic.IsQuickBarSingleUse())
- {
- OnQuickBarSingleUse(quickBarSlot);
- //Print("PlayerBase.c IsQuickBarSingleUse - slot: " + quickBarSlot.ToString());
- }
- if (hic.IsQuickBarContinuousUseStart() && ((!GetGame().IsDedicatedServer()) && !GetGame().GetUIManager().GetMenu()))
- {
- OnQuickBarContinuousUseStart(quickBarSlot);
- //Print("PlayerBase.c IsQuickBarContinuousUseStart - slot: " + quickBarSlot.ToString());
- }
- if (hic.IsQuickBarContinuousUseEnd() && ((!GetGame().IsDedicatedServer())))
- {
- OnQuickBarContinuousUseEnd(quickBarSlot);
- //Print("PlayerBase.c IsQuickBarContinuousUseEnd - slot: " + quickBarSlot.ToString());
- }
- }
-
- /*if ((pCurrentCommandID == DayZPlayerConstants.COMMANDID_ACTION || pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE || pCurrentCommandID == DayZPlayerConstants.COMMANDID_LADDER || pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM))
- {
- mngr.Update(); // checks for suitable action and sets it
- }*/
- }
- if (m_StaminaHandler && hic)
- {
- //! SPRINT: enable/disable - based on stamina; disable also when raised
- if (!CanConsumeStamina(EStaminaConsumers.SPRINT) || !CanSprint())
- {
- hic.LimitsDisableSprint(true);
- }
- else
- {
- hic.LimitsDisableSprint(false);
- }
- }
- //map closing - feel free to move to different "update" if it does not belong here
- if (IsMapOpen())
- {
- if (!GetGame().IsDedicatedServer())
- {
- if (!CfgGameplayHandler.GetUse3DMap() && !GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
- {
- CloseMapEx(false);
- }
- else if (CfgGameplayHandler.GetUse3DMap())
- {
- if (IsMapCallbackCancelInput())
- {
- CloseMapEx(true);
- }
- else if (IsMapCallbackEndInput())
- {
- CloseMapEx(false);
- }
- }
- }
- }
-
-
- #ifdef DIAG_DEVELOPER
- if (m_Bot)
- m_Bot.OnUpdate(pDt);
- #endif
-
- if (m_CheckMeleeItem && (!GetGame().IsDedicatedServer()))
- {
- CheckMeleeItemDamage(m_CheckMeleeItem);
- SetCheckMeleeItem();
- }
-
- #ifdef DEVELOPER
- TryGetInVehicleDebug();
- #endif
-
- OnCommandHandlerTick(pDt, pCurrentCommandID);
- }
-
- #ifdef DEVELOPER
- void SetGetInVehicleDebug(EntityAI ent)
- {
- m_GetInVehicleTransportDebug = Transport.Cast(ent);
- }
-
- void TryGetInVehicleDebug()
- {
- if (m_GetInVehicleTransportDebug)
- {
- HumanCommandVehicle vehCommand = StartCommand_Vehicle(m_GetInVehicleTransportDebug, 0, 0);
- if (vehCommand)
- {
- vehCommand.SetVehicleType(m_GetInVehicleTransportDebug.GetAnimInstance());
- }
- m_GetInVehicleTransportDebug = null;
- }
- }
- #endif
-
- //MAP handling
- //! DEPRECATED; terminates map animation callback and re-enables controls
- void CloseMap()
- {
- CloseMapEx(false);
- }
-
- void CloseMapEx(bool cancelled)
- {
- if (m_hac && !GetMapClosingSyncSent())
- {
- if (ScriptInputUserData.CanStoreInputUserData())
- {
- if (GetGame().IsMultiplayer() && GetGame().IsClient())
- {
- ActionManagerClient mngr_client;
- CastTo(mngr_client, GetActionManager());
-
- if (cancelled)
- {
- mngr_client.RequestInterruptAction();
- }
- else
- {
- mngr_client.RequestEndAction();
- }
-
- GetGame().GetMission().RemoveActiveInputExcludes({"map"});
- GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
- }
- else if (!GetGame().IsMultiplayer())
- {
- int command_ID = DayZPlayerConstants.CMD_ACTIONINT_END;
- if (cancelled)
- {
- command_ID = DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT;
- }
- m_hac.InternalCommand(command_ID);
- }
- SetMapClosingSyncSet(true);
- }
- }
-
- if (!GetGame().IsDedicatedServer())
- {
- if (GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
- {
- GetGame().GetUIManager().FindMenu(MENU_MAP).Close();
- if (m_Hud)
- {
- m_Hud.ShowHudPlayer(true);
- m_Hud.ShowQuickbarPlayer(true);
- }
-
- GetGame().GetMission().RemoveActiveInputExcludes({"map"});
- GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
- }
- }
- }
-
- void SetMapOpen(bool state)
- {
- m_MapOpen = state;
- }
-
- bool IsMapOpen()
- {
- return m_MapOpen;
- }
-
- void SetMapClosingSyncSet(bool state)
- {
- m_MapClosingSyncSent = state;
- }
-
- bool GetMapClosingSyncSent()
- {
- return m_MapClosingSyncSent;
- }
-
- bool IsMapCallbackCancelInput()
- {
- if (IsRaised() || (GetUApi().GetInputByID(UAUIMenu).LocalPress() || GetUApi().GetInputByID(UAGear).LocalPress()))
- {
- return true;
- }
-
- return false;
- }
-
- bool IsMapCallbackEndInput()
- {
- if (GetUApi().GetInputByID(UADefaultAction).LocalPress())
- {
- return true;
- }
-
- return false;
- }
-
- MapNavigationBehaviour GetMapNavigationBehaviour()
- {
- return m_MapNavigationBehaviour;
- }
-
- void MapNavigationItemInPossession(EntityAI item)
- {
- if (GetMapNavigationBehaviour())
- {
- GetMapNavigationBehaviour().OnItemInPlayerPossession(item);
- }
- }
-
- void MapNavigationItemNotInPossession(EntityAI item)
- {
- if (GetMapNavigationBehaviour())
- {
- GetMapNavigationBehaviour().OnItemNotInPlayerPossession(item);
- }
- }
-
- void SetCheckMeleeItem(ItemBase item = null)
- {
- m_CheckMeleeItem = item;
- }
-
- void SetShakesForced(int value)
- {
- m_ShakesForced = value;
- }
-
- void FreezeCheck()
- {
- int level;
- if (m_ShakesForced > 0)
- {
- level = m_ShakesForced;
- }
- else
- {
- float heat_comfort = GetStatHeatComfort().Get();
- if (heat_comfort <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING)
- {
- float value = Math.InverseLerp(PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING, PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_CRITICAL,heat_comfort);
- level = Math.Lerp(1,7,value);
- level = Math.Clamp(value,1,7);
- /*
- value = Math.Clamp(value,0,1);
- level = Math.Round(value * SHAKE_LEVEL_MAX);//translate from normalized value to levels
- */
- }
- }
- if (level != m_Shakes)
- {
- m_Shakes = level;
- SetSynchDirty();
- }
- }
- override bool IsLanded(int pCurrentCommandID)
- {
- if (super.IsLanded(pCurrentCommandID))
- {
- return true;
- }
- //! Handle fall damage for unconscious
- if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
- {
- bool wasFalling = m_IsUnconsciousFalling;
- m_IsUnconsciousFalling = PhysicsIsFalling(false);
- return wasFalling && !m_IsUnconsciousFalling;
- }
- //! No fall damage for players currently being damaged, animation is temporary
- return false;
- }
- override bool OnLand(int pCurrentCommandID, FallDamageData fallDamageData)
- {
- if (super.OnLand(pCurrentCommandID, fallDamageData))
- {
- return true;
- }
- //! Nothing happens for unconscious
- //! Nothing happens for being damaged
- return false;
- }
- override bool IsAlreadyInFallingCommand(int pCurrentCommandID)
- {
- if (super.IsAlreadyInFallingCommand(pCurrentCommandID))
- {
- return true;
- }
- //! Don't switch to falling command if unconscious
- //! Don't switch to falling command if being damaged
- return pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE;
- }
-
- void OnUnconsciousStart()
- {
- CloseInventoryMenu();
-
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- SetInventorySoftLock(true);
- if (m_LastCommandBeforeUnconscious != DayZPlayerConstants.COMMANDID_VEHICLE)
- {
- EntityAI entity_in_hands = GetHumanInventory().GetEntityInHands();
- if (entity_in_hands && CanDropEntity(entity_in_hands) && !IsRestrained() && !IsSurrendered())
- {
- DropItem(ItemBase.Cast(entity_in_hands));
- }
- }
- GetGame().GetSoundScene().SetSoundVolume(0,2);
- m_EffectWidgets.AddSuspendRequest(EffectWidgetSuspends.UNCON);
- }
-
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || (!GetGame().IsMultiplayer() && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT))
- {
- SetSynchDirty();
-
- if (m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE)
- {
- if (m_TransportCache)
- m_TransportCache.MarkCrewMemberUnconscious(m_TransportCache.CrewMemberIndex(this));
- }
-
- // disable voice communication
- GetGame().EnableVoN(this, false);
-
- if (m_AdminLog)
- {
- m_AdminLog.UnconStart(this);
- }
-
- // When we fall uncon we force out of block
- if (GetMeleeFightLogic())
- {
- GetMeleeFightLogic().SetBlock(false);
- }
- }
-
- SetMasterAttenuation("UnconsciousAttenuation");
-
- if (m_OnUnconsciousStart)
- m_OnUnconsciousStart.Invoke(this);
- }
-
- void OnUnconsciousStop(int pCurrentCommandID)
- {
- m_UnconRefillModifier =1;
- SetSynchDirty();
- m_UnconsciousTime = 0;
- m_UnconsciousVignetteTarget = 2;
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH)
- {
- GetGame().GetSoundScene().SetSoundVolume(g_Game.m_volume_sound,1);
- PPERequesterBank.GetRequester(PPERequester_UnconEffects).Stop();
- GetGame().GetMission().GetHud().ShowHudUI(true);
- GetGame().GetMission().GetHud().ShowQuickbarUI(true);
- if (GetGame().GetUIManager().IsDialogVisible())
- {
- GetGame().GetUIManager().CloseDialog();
- }
- if (GetGame().GetUIManager().IsMenuOpen(MENU_RESPAWN_DIALOGUE))
- {
- GetGame().GetUIManager().FindMenu(MENU_RESPAWN_DIALOGUE).Close();
- }
- }
- SetInventorySoftLock(false);
- m_EffectWidgets.RemoveSuspendRequest(EffectWidgetSuspends.UNCON);
- }
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
- {
- // enable voice communication
- if (IsAlive())
- GetGame().EnableVoN(this, true);
-
- if (m_AdminLog)
- {
- m_AdminLog.UnconStop(this);
- }
- }
-
- SetMasterAttenuation("");
-
- if (m_OnUnconsciousStop)
- m_OnUnconsciousStop.Invoke(this);
- }
- void OnUnconsciousUpdate(float pDt, int last_command)
- {
- m_UnconsciousTime += pDt;
- if (GetGame().IsServer())
- {
- int shock_simplified = SimplifyShock();
-
- if (m_ShockSimplified != shock_simplified)
- {
- m_ShockSimplified = shock_simplified;
- SetSynchDirty();
- }
- if (m_UnconsciousTime > PlayerConstants.UNCONSCIOUS_IN_WATER_TIME_LIMIT_TO_DEATH && last_command == DayZPlayerConstants.COMMANDID_SWIM)
- {
- SetHealth("","",-100);
- }
- }
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- GetGame().GetMission().GetHud().ShowHudUI(false);
- GetGame().GetMission().GetHud().ShowQuickbarUI(false);
- if (GetPulseType() == EPulseType.REGULAR)
- {
- float shock_simple_normalized = GetSimplifiedShockNormalized();
-
- float sin = Math.Sin(m_UnconsciousTime * 0.3);
- float sin_normalized = (sin + 1) / 2;
- if (sin_normalized < 0.05)
- {
- m_UnconsciousVignetteTarget = (1 - shock_simple_normalized / 3) * 2/*vignette max*/;
- }
- float vignette = Math.Lerp(2,m_UnconsciousVignetteTarget, sin_normalized);
- m_UnconParam.param1 = vignette;
- PPERequesterBank.GetRequester(PPERequester_UnconEffects).Start(m_UnconParam);
- }
- }
- }
-
- int SimplifyShock()
- {
- int shock = Math.Lerp(0, SIMPLIFIED_SHOCK_CAP, GetHealth("","Shock") / GetMaxHealth("","Shock"));
- shock = Math.Clamp(shock, 0, SIMPLIFIED_SHOCK_CAP);
- return shock;
- }
-
- float GetSimplifiedShockNormalized()
- {
- return (m_ShockSimplified / SIMPLIFIED_SHOCK_CAP);
- }
-
- override bool IsUnconscious()
- {
- return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || m_IsUnconscious;
- }
-
- override bool IsUnconsciousStateOnly()
- {
- return m_IsUnconscious;
- }
-
- override bool CanBeTargetedByAI(EntityAI ai)
- {
- #ifdef DIAG_DEVELOPER
- if (!m_CanBeTargetedDebug)
- {
- return false;
- }
- #endif
-
- return super.CanBeTargetedByAI(ai) && !IsUnconscious() && !IsInVehicle();
- }
-
- void GiveShock(float shock)
- {
- AddHealth("","Shock",shock);
- }
-
-
- void OnRestrainStart()
- {
- CloseInventoryMenu();
- GetGame().GetMission().RemoveActiveInputExcludes({"inventory"},true);
- GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
- }
-
- //! functionality moved to ShockMdfr::OnTick
- void ShockRefill(float pDt);
-
- //BrokenLegs
- // -----------------------
- eBrokenLegs GetBrokenLegs()
- {
- return Math.AbsInt(m_BrokenLegState);//negative value denotes first time activation
- }
-
- //Server side
- void SetBrokenLegs(int stateId)
- {
- m_BrokenLegState = stateId;
-
- DayZPlayerSyncJunctures.SendBrokenLegsEx(this, stateId);
- eBrokenLegs state = GetBrokenLegs();//m_BrokenLegState can go bellow 0, cannot be used directly
-
- if (state == eBrokenLegs.NO_BROKEN_LEGS)
- {
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
- }
- else if (state == eBrokenLegs.BROKEN_LEGS)
- {
- SetLegHealth();
- }
- else if (state == eBrokenLegs.BROKEN_LEGS_SPLINT)
- {
- // handle splint here
- }
- SetSynchDirty();
- }
- //Update of state
- void UpdateBrokenLegs(int stateId)
- {
- eBrokenLegs state = GetBrokenLegs();
- //Raise broken legs flag and force to prone
- if (state != eBrokenLegs.NO_BROKEN_LEGS)
- {
- if (state == eBrokenLegs.BROKEN_LEGS_SPLINT)
- {
- if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE)
- {
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask | eInjuryOverrides.BROKEN_LEGS_SPLINT;
- }
- m_InjuryHandler.CheckValue(false);
- }
- else if (state == eBrokenLegs.BROKEN_LEGS)
- {
- if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE)
- {
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask | eInjuryOverrides.BROKEN_LEGS;
- }
-
- BrokenLegWalkShock();
- m_InjuryHandler.CheckValue(false);
- }
- }
- else if (state == eBrokenLegs.NO_BROKEN_LEGS)
- {
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
- }
-
- }
-
- void BreakLegSound()
- {
- PlaySoundSet(m_BrokenLegSound, SOUND_BREAK_LEG, 0.1, 0.1);
- }
- void BrokenLegForceProne(bool forceOverride = false)
- {
- if (!IsInWater() && !IsSwimming() && !IsClimbingLadder() && !IsInVehicle() && !IsClimbing() && DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_PRONE))
- {
- if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE && m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
- {
- EntityAI attachment;
- Class.CastTo(attachment, GetItemOnSlot("Splint_Right"));
- if (attachment && attachment.GetType() == "Splint_Applied")
- {
- attachment.Delete();
- }
-
- m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_INITIAL_SHOCK);
- m_ShockHandler.CheckValue(true);
-
-
- if (m_ShockHandler.GetCurrentShock() >= 25) //Prevent conflict with unconsciousness by not forcing prone when going uncon (25 shock or less left)
- {
-
- //calcels user action
- HumanCommandActionCallback cmd = GetCommand_Action();
- if (cmd)
- {
- cmd.Cancel();
- }
-
- StopHandEvent();
- //Get command move and verify not null
- HumanCommandMove hcm = StartCommand_Move();//not sure why this is here
- hcm = GetCommand_Move();
- if (hcm)
- {
- hcm.ForceStance(DayZPlayerConstants.STANCEIDX_PRONE);
- }
- }
- }
- }
- m_JumpClimb.CheckAndFinishJump();
- }
-
- //Used to inflict shock when player is walking (only inflicted on Update timer)
- void BrokenLegWalkShock()
- {
- //No need to pursue here if player is prone as the following logic is not applied
- if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE && m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
- {
- float avgLegHealth = GetHealth("RightLeg","") + GetHealth("LeftLeg","") + GetHealth("RightFoot","") + GetHealth("LeftFoot","");
- avgLegHealth *= 0.25; //divide by 4 to make the average leg health;
-
- if (IsSwimming())
- {
- //swimming other than forward is not detectable in script other than through velocity check
- vector v;
- PhysicsGetVelocity(v);
-
- if (v.LengthSq() > 0)
- {
- m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_SHOCK_SWIM);
- }
- }
- else if (m_MovementState.m_iMovement != 0)
- {
- if (IsClimbingLadder())
- {
- MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK);
- }
- else if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
- {
- if (m_MovementState.m_iMovement > 1)//only jog and faster
- {
- MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK);
- }
- }
- else if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
- {
- //any speed other than idle
- MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK * PlayerConstants.BROKEN_CROUCH_MODIFIER, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK * PlayerConstants.BROKEN_CROUCH_MODIFIER, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK * PlayerConstants.BROKEN_CROUCH_MODIFIER);
- }
- }
- else
- {
- //Here apply shock if player is standing or crouched and STANDING STILL
- m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_STAND_SHOCK);
- }
-
- m_ShockHandler.CheckValue(true);
- }
- }
-
- //Always use the same thresholds but allow passing of different shock values
- void MovingShock(float legHealth, float highShock, float midShock, float lowShock)
- {
- if (legHealth <= PlayerConstants.BROKEN_LEGS_LOW_HEALTH_THRESHOLD)
- {
- //Inflict "high shock"
- m_ShockHandler.SetShock(highShock);
- }
- else if (legHealth >= PlayerConstants.BROKEN_LEGS_HIGH_HEALTH_THRESHOLD)
- {
- //Inflict "low shock"
- m_ShockHandler.SetShock(lowShock);
- }
- else
- {
- //If neither high nore low, inflict "mid shock"
- m_ShockHandler.SetShock(midShock);
- }
- }
-
- void DealShock(float dmg)
- {
- Param1<float> damage = new Param1<float>(0);
- damage.param1 = dmg;
- GetGame().RPCSingleParam(this, ERPCs.RPC_SHOCK, damage, true, GetIdentity());
- }
-
- //Prevent player from picking up heavy items when legs are broken
- override bool CanPickupHeavyItem(notnull EntityAI item)
- {
- if (item.IsHeavyBehaviour() && (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS || GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS_SPLINT))
- return false;
- return super.CanPickupHeavyItem(item);
- }
-
- //Set all leg zones' health to 0 in order to limit emergent behaviour and prevent confusion as to how broken legs really work
- void SetLegHealth()
- {
- SetHealth("RightLeg", "", 0);
- SetHealth("RightFoot", "", 0);
- SetHealth("LeftLeg", "", 0);
- SetHealth("LeftFoot", "", 0);
- }
-
- void DropHeavyItem()
- {
- ItemBase itemInHands = GetItemInHands();
- if (itemInHands && itemInHands.IsHeavyBehaviour())
- DropItem(itemInHands);
- }
-
- bool IsWearingSplint()
- {
- EntityAI attachment;
- Class.CastTo(attachment, GetItemOnSlot("Splint_Right"));
- if (attachment && attachment.GetType() == "Splint_Applied")
- {
- return true;
- }
- return false;
- }
-
- // -----------------------
-
-
- override void OnCommandSwimStart()
- {
- ItemBase itemInHands = GetItemInHands();
- if (itemInHands)
- {
- if (itemInHands.IsHeavyBehaviour())
- {
- TryHideItemInHands(false);
- DropHeavyItem();
- }
- else
- {
- TryHideItemInHands(true);
- }
- itemInHands.OnItemInHandsPlayerSwimStart(this);
- }
- m_AnimCommandStarting = HumanMoveCommandID.CommandSwim;
-
- if (GetInventory())
- GetInventory().LockInventory(LOCK_FROM_SCRIPT);
-
- CloseInventoryMenu();
- GetDayZGame().GetBacklit().OnSwimmingStart();
-
- AbortWeaponEvent();
- GetWeaponManager().DelayedRefreshAnimationState(10);
- RequestHandAnimationStateRefresh();
-
- GetGame().GetMission().AddActiveInputExcludes({"swimming"});
- }
-
- override void OnCommandSwimFinish()
- {
- TryHideItemInHands(false, true);
-
- if (GetInventory())
- GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
-
- GetDayZGame().GetBacklit().OnSwimmingStop();
-
- GetWeaponManager().RefreshAnimationState();
-
- GetGame().GetMission().RemoveActiveInputExcludes({"swimming"});
- }
-
- override void OnCommandLadderStart()
- {
- m_AnimCommandStarting = HumanMoveCommandID.CommandLadder;
- TryHideItemInHands(true);
-
- if (GetInventory())
- GetInventory().LockInventory(LOCK_FROM_SCRIPT);
-
- CloseInventoryMenu();
-
- GetGame().GetMission().AddActiveInputExcludes({"ladderclimbing"});
- }
-
- override void OnCommandLadderFinish()
- {
- TryHideItemInHands(false, true);
-
- if (GetInventory())
- GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
-
- GetGame().GetMission().RemoveActiveInputExcludes({"ladderclimbing"});
- }
-
- override void OnCommandFallStart()
- {
- m_AnimCommandStarting = HumanMoveCommandID.CommandFall;
-
- if (GetInventory())
- GetInventory().LockInventory(LOCK_FROM_SCRIPT);
-
- CloseInventoryMenu();
-
- AbortWeaponEvent();
- GetWeaponManager().DelayedRefreshAnimationState(10);
- RequestHandAnimationStateRefresh();
- }
-
- override void OnCommandFallFinish()
- {
- if (GetInventory())
- GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
-
- GetWeaponManager().RefreshAnimationState();
- }
-
- override void OnCommandClimbStart()
- {
- m_AnimCommandStarting = HumanMoveCommandID.CommandClimb;
-
- if (GetInventory())
- GetInventory().LockInventory(LOCK_FROM_SCRIPT);
-
- CloseInventoryMenu();
-
- AbortWeaponEvent();
- GetWeaponManager().DelayedRefreshAnimationState(10);
- RequestHandAnimationStateRefresh();
- }
-
- override void OnCommandClimbFinish()
- {
- if (GetInventory())
- GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
-
- GetWeaponManager().RefreshAnimationState();
- }
-
- override void OnCommandVehicleStart()
- {
- m_AnimCommandStarting = HumanMoveCommandID.CommandVehicle;
-
- if (GetInventory())
- GetInventory().LockInventory(LOCK_FROM_SCRIPT);
-
- CloseInventoryMenu();
-
- ItemBase itemInHand = GetItemInHands();
- EntityAI itemOnHead = FindAttachmentBySlotName("Headgear");
- if (itemInHand && itemInHand.GetCompEM())
- itemInHand.GetCompEM().SwitchOff();
- TryHideItemInHands(true);
- if (itemOnHead && itemOnHead.GetCompEM())
- itemOnHead.GetCompEM().SwitchOff();
-
- GetGame().GetMission().AddActiveInputExcludes({"vehicledriving"});
- }
-
- override void OnCommandVehicleFinish()
- {
- if (GetInventory())
- GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
-
- TryHideItemInHands(false, true);
-
- GetGame().GetMission().RemoveActiveInputExcludes({"vehicledriving"});
- }
-
- override void OnCommandMelee2Start()
- {
- m_AnimCommandStarting = HumanMoveCommandID.CommandMelee2;
- m_IsFighting = true;
-
- AbortWeaponEvent();
- GetWeaponManager().DelayedRefreshAnimationState(10);
- RequestHandAnimationStateRefresh();
- }
-
- override void OnCommandMelee2Finish()
- {
- RunFightBlendTimer();
-
- GetWeaponManager().RefreshAnimationState();
-
- }
-
- override void OnCommandDeathStart()
- {
- m_AnimCommandStarting = HumanMoveCommandID.CommandDeath;
- AbortWeaponEvent();
- GetWeaponManager().DelayedRefreshAnimationState(10);
- RequestHandAnimationStateRefresh();
-
- super.OnCommandDeathStart();
- }
-
- override void OnJumpStart()
- {
- m_ActionManager.OnJumpStart();
-
- AbortWeaponEvent();
- GetWeaponManager().DelayedRefreshAnimationState(10);
- RequestHandAnimationStateRefresh();
- CloseMapEx(true);
- }
-
- override void OnJumpEnd(int pLandType = 0)
- {
- if (m_PresenceNotifier)
- {
- switch (pLandType)
- {
- case HumanCommandFall.LANDTYPE_NONE:
- case HumanCommandFall.LANDTYPE_LIGHT:
- m_PresenceNotifier.ProcessEvent(EPresenceNotifierNoiseEventType.LAND_LIGHT);
- break;
- case HumanCommandFall.LANDTYPE_MEDIUM:
- case HumanCommandFall.LANDTYPE_HEAVY:
- m_PresenceNotifier.ProcessEvent(EPresenceNotifierNoiseEventType.LAND_HEAVY);
- break;
- }
- }
-
- GetWeaponManager().RefreshAnimationState();
- }
-
- bool IsStance(int stance, int stanceMask)
- {
- return ((1 << stance) & stanceMask) != 0;
- }
-
- override void OnStanceChange(int previousStance, int newStance)
- {
- int prone = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE;
- int notProne = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_RAISEDERECT | DayZPlayerConstants.STANCEMASK_RAISEDCROUCH;
- if (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_PRONE) && IsStance(newStance, DayZPlayerConstants.STANCEMASK_ERECT))
- m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_FROM_PRONE;
-
- if (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_PRONE) && IsStance(previousStance, DayZPlayerConstants.STANCEMASK_CROUCH) || (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_CROUCH) && IsStance(newStance, DayZPlayerConstants.STANCEMASK_ERECT)))
- m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_FROM_CROUCH;
-
- if ((IsStance(previousStance, prone) && IsStance(newStance, notProne)) || (IsStance(previousStance, notProne) && IsStance(newStance, prone)))
- {
- AbortWeaponEvent();
- GetWeaponManager().RefreshAnimationState();
- }
- }
-
- override bool CanChangeStance(int previousStance, int newStance)
- {
- // Check if the player is playing a throwing animation
- if (GetThrowing().IsThrowingAnimationPlaying())
- {
- return false;
- }
-
- // don't allow base stance change, only raised hands change
- if (IsRolling())
- {
- if (Math.AbsInt(previousStance - newStance) == 3)
- return true;
-
- return false;
- }
-
- // Check if the player is going to crouch or raised crouch
- if (newStance == DayZPlayerConstants.STANCEIDX_CROUCH || newStance == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
- {
- return GetCurrentWaterLevel() <= GetDayZPlayerType().CommandSwimSettingsW().m_fToErectLevel;
- }
-
- // Check if the player is going to prone
- if (newStance == DayZPlayerConstants.STANCEIDX_PRONE || newStance == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
- {
- return GetCurrentWaterLevel() <= GetDayZPlayerType().CommandSwimSettingsW().m_fToCrouchLevel;
- }
-
- // The player can change stance if none of the conditions above are met
- return true;
- }
-
- override void OnCommandMoveStart()
- {
- if (GetGame().IsServer())
- {
- //In case player changes stance through a different command, we refresh the anim overrides
- int prone = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE;
- if (!IsPlayerInStance(prone))
- {
- m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
- ForceUpdateInjuredState();
- }
- }
- }
-
- override bool CanRoll()
- {
- if (!CanConsumeStamina(EStaminaConsumers.ROLL))
- return false;
-
- if (IsInFBEmoteState() || m_EmoteManager.m_MenuEmote)
- {
- return false;
- }
-
- return IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE) && GetCommand_Move() && !GetCommand_Move().IsOnBack();
- }
-
- override void OnRollStart(bool isToTheRight)
- {
- DepleteStamina(EStaminaModifiers.ROLL);
-
- if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
- m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_ROLL_SHOCK);
- }
-
- override void OnRollFinish()
- {
- }
-
- void OnJumpOutVehicleFinish(float carSpeed)
- {
- string surfaceType;
- int liquidType;
- GetGame().SurfaceUnderObject(this, surfaceType, liquidType);
- }
-
- void OnVehicleSwitchSeat(int seatIndex)
- {
- }
-
- override void OnVehicleSeatDriverEnter()
- {
- m_IsVehicleSeatDriver = true;
- if (m_Hud)
- m_Hud.ShowVehicleInfo();
-
- #ifdef FEATURE_NETWORK_RECONCILIATION
- PlayerIdentity identity = GetIdentity();
- if (identity)
- {
- Pawn pawn = Pawn.Cast(GetParent());
- //! Hand off control to the vehicle - null is valid
- identity.Possess(pawn);
- }
- #endif
- }
-
- override void OnVehicleSeatDriverLeft()
- {
- #ifdef FEATURE_NETWORK_RECONCILIATION
- PlayerIdentity identity = GetIdentity();
- //! Don't possess the player if we are in the vehicle and unconscious, we are still the driver!
- if (identity && !m_ShouldBeUnconscious)
- {
- //! And now we want to resume control of the player
- identity.Possess(this);
- }
- #endif
-
- m_IsVehicleSeatDriver = false;
- if (m_Hud)
- m_Hud.HideVehicleInfo();
- }
-
- override void OnThrowingModeChange(bool change_to_enabled)
- {
- if (change_to_enabled)
- {
- PlacingCancelLocal();
- PlacingCancelServer();
- }
- }
-
- override void EOnFrame(IEntity other, float timeSlice)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- #ifndef NO_GUI
- m_Hud.Update(timeSlice);
-
- if (IsControlledPlayer() && m_EffectWidgets && m_EffectWidgets.IsAnyEffectRunning())
- {
- m_EffectWidgets.Update(timeSlice);
- }
- #endif
- if (m_UndergroundHandler)
- m_UndergroundHandler.Tick(timeSlice);
-
- if (m_UndergroundBunkerHandler)
- m_UndergroundBunkerHandler.Tick(timeSlice);
- }
-
- if (m_InEffectAreaType != 0 && GetGame().IsServer())
- OnUpdateEffectAreaServer(timeSlice);
- }
-
- override void EOnPostFrame(IEntity other, int extra)
- {
- float delta_time = (GetGame().GetTime() - m_LastPostFrameTickTime) / 1000;
- m_LastPostFrameTickTime = GetGame().GetTime();
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- if (GetDamageDealtEffect())
- {
- if (IsAlive())
- GetDamageDealtEffect().Update(delta_time);
- else
- delete GetDamageDealtEffect();
- }
-
- if (m_EffectRadial)
- {
- if (IsAlive())
- {
- m_EffectRadial.Update(delta_time);
- }
- else
- m_EffectRadial = null;
- }
-
-
- if (GetFlashbangEffect())
- {
- if (IsAlive())
- {
- GetFlashbangEffect().Update(delta_time);
- }
- else
- {
- GetFlashbangEffect().Stop();
- delete GetFlashbangEffect();
- }
- }
-
- if (GetShockEffect())
- {
- if (IsAlive())
- GetShockEffect().Update(delta_time);
- else
- delete GetShockEffect();
- }
- m_InventoryActionHandler.OnUpdate();
- }
-
- #ifdef DIAG_DEVELOPER
- DiagOnPostFrame(other, extra);
- #endif
- }
-
- #ifdef DIAG_DEVELOPER
- protected void DiagOnPostFrame(IEntity other, int extra)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- if (m_WeaponDebug)
- {
- m_WeaponDebug.OnPostFrameUpdate();
- }
- if (GetBleedingManagerRemote())
- {
- GetBleedingManagerRemote().OnUpdate();
- }
-
- if (m_MeleeCombat)
- {
- if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
- {
- m_MeleeDebug = true;
- m_MeleeCombat.Debug(GetItemInHands(), m_MeleeCombat.GetHitType());
- }
- else if (!DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG) && m_MeleeDebug)
- {
- m_MeleeDebug = false;
- m_MeleeCombat.Debug(GetItemInHands(), m_MeleeCombat.GetHitType());
- }
- }
-
- if (DiagMenu.GetBool(DiagMenuIDs.SOUNDS_ITEM_IMPACT_SOUNDS))
- InventoryItem.DrawImpacts();
-
- if (GetPluginManager())
- {
- PluginDrawCheckerboard drawCheckerboard = PluginDrawCheckerboard.Cast(GetPluginManager().GetPluginByType(PluginDrawCheckerboard));
- if (drawCheckerboard && !drawCheckerboard.IsActive())
- {
- drawCheckerboard.ShowWidgets(DiagMenu.GetBool(DiagMenuIDs.MISC_DRAW_CHECKERBOARD));
- }
- }
-
- if (m_PresenceNotifier)
- {
- m_PresenceNotifier.EnableDebug(DiagMenu.GetBool(DiagMenuIDs.MISC_PRESENCE_NOTIFIER_DBG));
- }
-
- if (m_TargetTemperatureDiag)
- {
- m_TargetTemperatureDiag.ShowDebug(DiagMenu.GetBool(DiagMenuIDs.MISC_TARGET_TEMPERATURE));
- }
-
- if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_PLAYER_DEBUG))
- {
- vector minmax[2];
- GetCollisionBox(minmax);
-
- int color = COLOR_RED_A;
- if (m_IsInsideTrigger)
- color = COLOR_GREEN_A;
-
- Shape dbgShape = Debug.DrawBoxEx(minmax[0], minmax[1], color, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE|ShapeFlags.ONCE);
-
- vector mat[4];
- GetTransform(mat);
- dbgShape.CreateMatrix(mat);
- dbgShape.SetMatrix(mat);
- }
- }
-
- if (m_Environment && m_Environment.m_Debug)
- {
- #ifdef SERVER
- EnvDebugData envDebugData = m_Environment.GetEnvDebugData();
- GetGame().RPCSingleParam(this, ERPCs.DIAG_MISC_ENVIRONMENT_DEBUG_DATA, envDebugData, false, GetIdentity());
- #else
- m_Environment.ShowEnvDebugPlayerInfo(DiagMenu.GetBool(DiagMenuIDs.MISC_ENVIRONMENT_DEBUG));
- #endif
- }
-
- if (m_FallDamage && m_FallDamage.m_Debug)
- {
- #ifdef SERVER
- FallDamageDebugData fallDamageDebugData = m_FallDamage.GetFallDamageDebugData();
- GetGame().RPCSingleParam(this, ERPCs.DIAG_MISC_FALLDAMAGE_DEBUG_DATA, fallDamageDebugData, false, GetIdentity());
- #else
- m_FallDamage.ShowFallDamageDebugInfo(DiagMenu.GetBool(DiagMenuIDs.MISC_FALLDAMAGE_DEBUG));
- #endif
- }
- }
-
- override void OnEnterTrigger(ScriptedEntity trigger)
- {
- super.OnEnterTrigger(trigger);
- ++m_IsInsideTrigger;
- }
-
- override void OnLeaveTrigger(ScriptedEntity trigger)
- {
- super.OnLeaveTrigger(trigger);
- --m_IsInsideTrigger;
- }
- #endif
- void StaminaHUDNotifier(bool show)
- {
- if (m_Hud)
- m_Hud.SetStaminaBarVisibility(show);
- }
-
- override void DepleteStamina(EStaminaModifiers modifier, float dT = -1)
- {
- if (GetStaminaHandler())
- GetStaminaHandler().DepleteStamina(modifier,dT);
- }
- override bool CanConsumeStamina(EStaminaConsumers consumer)
- {
- if (!GetStaminaHandler()) return false;
-
- bool val = (GetStaminaHandler().HasEnoughStaminaFor(consumer) /*&& !IsOverloaded()*/ && !IsRestrained() && !IsInFBEmoteState());
-
- if (!val)
- StaminaHUDNotifier(false);
- return val;
- }
-
- override bool CanStartConsumingStamina(EStaminaConsumers consumer)
- {
- if (!GetStaminaHandler()) return false;
-
- bool val = (GetStaminaHandler().HasEnoughStaminaToStart(consumer) && !IsRestrained() && !IsInFBEmoteState());
-
- if (!val)
- StaminaHUDNotifier(false);
- return val;
- }
-
- override bool CanClimb(int climbType, SHumanCommandClimbResult climbRes)
- {
- if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
- return false;
-
- if (climbType == 1 && !CanConsumeStamina(EStaminaConsumers.VAULT))
- return false;
-
- //! vault from water allowed
- if (IsSwimming())
- return true;
-
- if (climbType == 2 && (!CanConsumeStamina(EStaminaConsumers.CLIMB) || GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS))
- return false;
- if (climbType > 0 && m_InjuryHandler && m_InjuryHandler.GetInjuryAnimValue() >= InjuryAnimValues.LVL3)
- return false;
- return super.CanClimb(climbType,climbRes);
- }
- override bool CanJump()
- {
- if (GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS)
- {
- return false;
- }
-
- if (!CanConsumeStamina(EStaminaConsumers.JUMP))
- return false;
- //! disables jump when player is significantly injured
- if (m_InjuryHandler && m_InjuryHandler.GetInjuryAnimValue() >= InjuryAnimValues.LVL3)
- return false;
-
- if (IsInFBEmoteState() || m_EmoteManager.m_MenuEmote)
- {
- return false;
- }
- return super.CanJump();
- }
-
- bool IsJumpInProgress()
- {
- return m_JumpClimb.m_bIsJumpInProgress;
- }
-
- bool IsTargetInActiveRefresherRange(EntityAI target)
- {
- array<vector> temp = new array<vector>;
- temp = GetGame().GetMission().GetActiveRefresherLocations();
- int count = temp.Count();
- if (count > 0)
- {
- vector pos = target.GetPosition();
- for (int i = 0; i < count; i++)
- {
- if (vector.Distance(pos,temp.Get(i)) < GameConstants.REFRESHER_RADIUS)
- return true;
- }
-
- return false;
- }
- else
- {
- return false;
- }
- }
-
- void RequestHandAnimationStateRefresh()
- {
- if ((GetGame().IsMultiplayer() && GetGame().IsServer()))
- {
- m_RefreshAnimStateIdx++;
- if (m_RefreshAnimStateIdx > 3)
- m_RefreshAnimStateIdx = 0;
- SetSynchDirty();
- }
- }
-
- void RefreshHandAnimationState(int delay = 0)
- {
- if (delay == 0)
- {
- GetItemAccessor().OnItemInHandsChanged(true);
- GetItemAccessor().ResetWeaponInHands();
- }
- else
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(RefreshHandAnimationState,delay,false,0);
- }
- }
-
- // -------------------------------------------------------------------------
- // USER ACTIONS
- // -------------------------------------------------------------------------
- bool IsFacingTarget(Object target)
- {
- vector pdir = GetDirection();
- vector ptv = target.GetPosition() - GetPosition();
- pdir.Normalize();
- ptv.Normalize();
- if (Math.AbsFloat(pdir[0]-ptv[0]) < 0.5 && Math.AbsFloat(pdir[2]-ptv[2]) < 0.5)
- {
- return true;
- }
- return false;
- }
- //---------------------------------------------------------
- void OnQuickBarSingleUse(int slotClicked)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
- return;
-
- if (m_AreHandsLocked)
- return; //Player is in the short window of time after interrupting placement of an item and before getting it back in hands
- if (GetInventory().IsInventoryLocked() || IsEmotePlaying())
- return;
-
- if (GetThrowing().IsThrowingModeEnabled() || GetThrowing().IsThrowingAnimationPlaying())
- return;
-
- if (IsRaised() || GetCommand_Melee() || IsSwimming() || IsClimbingLadder() || IsClimbing() || IsRestrained() || IsRestrainPrelocked())
- return;
-
- if (GetDayZPlayerInventory().IsProcessing() || IsItemsToDelete())
- return;
-
- if (GetActionManager().GetRunningAction() != null)
- return;
-
- if (GetWeaponManager() && GetWeaponManager().IsRunning())
- return;
-
- if (!ScriptInputUserData.CanStoreInputUserData())
- return;
-
- //TODO MW change locking method
- //if (GetDayZPlayerInventory().HasLockedHands())
- // return;
-
- EntityAI quickBarEntity = GetQuickBarEntity(slotClicked - 1);//GetEntityInQuickBar(slotClicked - 1);
-
- if (!quickBarEntity)
- return;
-
- Magazine mag;
- Weapon_Base wpn;
-
- if (Class.CastTo(mag, quickBarEntity) && Class.CastTo(wpn, mag.GetHierarchyParent()))
- return;
- EntityAI inHandEntity = GetHumanInventory().GetEntityInHands();
-
- if (!GetDayZPlayerInventory().IsIdle())
- return; // player is already performing some animation
- InventoryLocation handInventoryLocation = new InventoryLocation;
- handInventoryLocation.SetHands(this,quickBarEntity);
- if (this.GetInventory().HasInventoryReservation(quickBarEntity, handInventoryLocation))
- return;
-
- if (inHandEntity == quickBarEntity)
- {
- if (GetHumanInventory().CanRemoveEntityInHands())
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Stash - PredictiveMoveItemFromHandsToInventory HND=" + Object.GetDebugName(inHandEntity));
- PredictiveMoveItemFromHandsToInventory();
- }
- }
- else
- {
- InventoryLocation invLocQBItem = new InventoryLocation;
- quickBarEntity.GetInventory().GetCurrentInventoryLocation(invLocQBItem);
- if (GetInventory().HasInventoryReservation(quickBarEntity,invLocQBItem))
- return;
-
- if (inHandEntity)
- {
- InventoryLocation Reserved_Item_il = new InventoryLocation;
-
- InventoryLocation inHandEntityFSwapDst = new InventoryLocation;
- inHandEntity.GetInventory().GetCurrentInventoryLocation(inHandEntityFSwapDst);
- int index = GetHumanInventory().FindUserReservedLocationIndex(inHandEntity);
- if (index >= 0)
- GetHumanInventory().GetUserReservedLocation(index, Reserved_Item_il);
-
- if (Reserved_Item_il)
- inHandEntityFSwapDst.CopyLocationFrom(Reserved_Item_il, true);
-
- if (index < 0 && GameInventory.CanSwapEntitiesEx(quickBarEntity, inHandEntity))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] PredictiveSwapEntities QB=" + Object.GetDebugName(quickBarEntity) + " HND=" + Object.GetDebugName(inHandEntity));
- PredictiveSwapEntities(quickBarEntity, inHandEntity);
- }
- else if (GameInventory.CanForceSwapEntitiesEx(quickBarEntity, handInventoryLocation, inHandEntity, inHandEntityFSwapDst))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Swap - PredictiveForceSwapEntities HND=" + Object.GetDebugName(inHandEntity) + " QB=" + Object.GetDebugName(quickBarEntity) + " fswap_dst=" + InventoryLocation.DumpToStringNullSafe(inHandEntityFSwapDst));
- PredictiveForceSwapEntities(quickBarEntity, inHandEntity, inHandEntityFSwapDst);
- }
- }
- else
- {
- if (GetInventory().HasInventoryReservation(quickBarEntity,handInventoryLocation))
- return;
-
- if (GetInventory().CanAddEntityIntoHands(quickBarEntity))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Stash - PredictiveTakeEntityToHands QB=" + Object.GetDebugName(quickBarEntity));
- PredictiveTakeEntityToHands(quickBarEntity);
- }
- }
- }
- }
- //---------------------------------------------------------
- void OnQuickBarContinuousUseStart(int slotClicked)
- {
- if (GetInventory().IsInventoryLocked())
- return;
-
- if (IsSwimming() || IsClimbingLadder() || GetCommand_Melee() || IsClimbing() || IsRestrained() || IsRestrainPrelocked())
- return;
-
- ItemBase quickBarItem = ItemBase.Cast(GetQuickBarEntity(slotClicked - 1));
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- ItemBase itemInHands = ItemBase.Cast(GetHumanInventory().GetEntityInHands());
- if (itemInHands != quickBarItem)
- {
- ActionManagerClient amc = ActionManagerClient.Cast(GetActionManager());
- if (amc.CanPerformActionFromQuickbar(itemInHands, quickBarItem))
- {
- amc.PerformActionFromQuickbar(itemInHands, quickBarItem);
- }
- else
- {
- if (IsRaised() || GetCommand_Melee())
- return;
- amc.ForceTarget(quickBarItem);
- m_QuickBarFT = true;
- }
- }
- }
- m_QuickBarHold = true;
- }
- //---------------------------------------------------------
- void OnQuickBarContinuousUseEnd(int slotClicked)
- {
- if (m_QuickBarHold)
- {
- if ( GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- ActionManagerClient am = ActionManagerClient.Cast(GetActionManager());
-
- if (m_ActionQBControl)
- {
- ActionBase action = am.GetRunningAction();
- if (action)
- {
- if (!action.GetInput().IsActive())
- {
- am.EndActionInput();
- }
-
- }
- }
-
- if (m_QuickBarFT)
- {
- am.ClearForceTarget();
- m_QuickBarFT = false;
- }
- }
- }
- m_QuickBarHold = false;
- }
- void SetActionEndInput(ActionBase action)
- {
- m_ActionQBControl = !action.GetInput().IsActive();
- }
-
- bool IsQBControl()
- {
- return m_ActionQBControl;
- }
- void ResetActionEndInput()
- {
- m_ActionQBControl = false;
- }
-
- //---------------------------------------------------------
- // RADIAL QUICKBAR AND RELOAD ACTIONS
- //---------------------------------------------------------
- //the same functionality as normal quick bar slot key press
- void RadialQuickBarSingleUse(int slotClicked)
- {
- OnQuickBarSingleUse(slotClicked);
- }
-
- //removed the need for holding down quick bar slot key
- void RadialQuickBarCombine(int slotClicked)
- {
- EntityAI quickBarEntity = GetQuickBarEntity(slotClicked - 1);
- EntityAI entity_in_hands = GetHumanInventory().GetEntityInHands();
-
- ReloadWeapon(entity_in_hands, quickBarEntity);
- }
- //removed the need for holding down quick bar slot key
- void QuickReloadWeapon(EntityAI weapon)
- {
- EntityAI magazine = GetMagazineToReload(weapon);
- ReloadWeapon(weapon, magazine);
- }
-
- //Reload weapon with given magazine
- void ReloadWeapon(EntityAI weapon, EntityAI magazine)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- ActionManagerClient mngr_client;
- CastTo(mngr_client, GetActionManager());
-
- if (mngr_client && FirearmActionLoadMultiBulletRadial.Cast(mngr_client.GetRunningAction()))
- {
- mngr_client.Interrupt();
- }
- else if (GetHumanInventory().GetEntityInHands()!= magazine)
- {
- Weapon_Base wpn;
- Magazine mag;
- Class.CastTo(wpn, weapon);
- Class.CastTo(mag, magazine);
- if (GetWeaponManager().CanUnjam(wpn))
- {
- GetWeaponManager().Unjam();
- }
- else if (GetWeaponManager().CanAttachMagazine(wpn, mag))
- {
- GetWeaponManager().AttachMagazine(mag);
- }
- else if (GetWeaponManager().CanSwapMagazine(wpn, mag))
- {
- GetWeaponManager().SwapMagazine(mag);
- }
- else if (GetWeaponManager().CanLoadBullet(wpn, mag))
- {
- //GetWeaponManager().LoadMultiBullet(mag);
- ActionTarget atrg = new ActionTarget(mag, this, -1, vector.Zero, -1.0);
- if (mngr_client && !mngr_client.GetRunningAction() && mngr_client.GetAction(FirearmActionLoadMultiBulletRadial).Can(this, atrg, wpn))
- mngr_client.PerformActionStart(mngr_client.GetAction(FirearmActionLoadMultiBulletRadial), atrg, wpn);
- }
- }
- }
- }
- //returns compatible magazine from player inventory with highest ammo count
- EntityAI GetMagazineToReload(EntityAI weapon)
- {
- Weapon_Base weapon_base = Weapon_Base.Cast(weapon);
- WeaponManager weapon_manager = GetWeaponManager();
- EntityAI magazine_to_reload;
-
- EntityAI ammo_magazine; //magazine
- int last_ammo_magazine_count;
- int ammo_magazine_count;
-
- EntityAI ammo_pile; //ammo pile
- int last_ammo_pile_count;
- int ammo_pile_count;
-
- //Get all magazines in (player) inventory
- for (int att_i = 0; att_i < GetInventory().AttachmentCount(); ++att_i)
- {
- EntityAI attachment = GetInventory().GetAttachmentFromIndex(att_i);
- ref CargoBase attachment_cargo = attachment.GetInventory().GetCargo();
-
- if (attachment_cargo)
- {
- for (int cgo_i = 0; cgo_i < attachment_cargo.GetItemCount(); ++cgo_i)
- {
- EntityAI cargo_item = attachment_cargo.GetItem(cgo_i);
-
- //check for proper magazine
- if (cargo_item.IsMagazine())
- {
- Magazine magazine = Magazine.Cast(cargo_item);
- ammo_pile_count = magazine.GetAmmoCount();
-
- //magazines (get magazine with max ammo count)
- if (weapon_manager.CanAttachMagazine(weapon_base, magazine) || weapon_manager.CanSwapMagazine(weapon_base, magazine))
- {
- if (ammo_pile_count > 0)
- {
- if (last_ammo_magazine_count == 0)
- {
- ammo_magazine = magazine;
- last_ammo_magazine_count = ammo_pile_count;
- }
- else
- {
- if (last_ammo_magazine_count < ammo_pile_count)
- {
- ammo_magazine = magazine;
- last_ammo_magazine_count = ammo_pile_count;
- }
- }
- }
- }
- //bullets (get ammo pile with min ammo count)
- else if (weapon_manager.CanLoadBullet(weapon_base, magazine))
- {
- if (ammo_pile_count > 0)
- {
- if (last_ammo_pile_count == 0)
- {
- ammo_pile = magazine;
- last_ammo_pile_count = ammo_pile_count;
- }
- else
- {
- if (last_ammo_pile_count > ammo_pile_count)
- {
- ammo_pile = magazine;
- last_ammo_pile_count = ammo_pile_count;
- }
- }
- }
- }
- }
- }
- }
- }
- //prioritize magazine
- if (ammo_magazine)
- {
- return ammo_magazine;
- }
-
- return ammo_pile;
- }
- //---------------------------------------------------------
-
-
- //---------------------------------------------------------
- void OnSpawnedFromConsole()
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
- {
- GetGame().GetMission().AddDummyPlayerToScheduler(this);
- OnSelectPlayer();
- }
- #ifdef DIAG_DEVELOPER
- if (!m_Bot)
- {
- m_Bot = new Bot(this);
- m_Bot.Start();
- }
- #endif
- }
-
- //---------------------------------------------------------
- //Obsolete
- bool GetLiquidTendencyDrain()
- {
- return m_LiquidTendencyDrain;
- }
- //---------------------------------------------------------
- //Obsolete
- void SetLiquidTendencyDrain(bool state)
- {
- m_LiquidTendencyDrain = state;
- }
-
- //---------------------------------------------------------
- //! DEPRECATED
- bool GetFlagTendencyRaise()
- {
- return m_FlagRaisingTendency;
- }
- //---------------------------------------------------------
- //! DEPRECATED
- void SetFlagTendencyRaise(bool state)
- {
- m_FlagRaisingTendency = state;
- }
-
- override SoundOnVehicle PlaySound(string sound_name, float range, bool create_local = false)
- {
- return BetaSound.SaySound(this, sound_name, range, false);
- }
-
- float GetPlayerLoad()
- {
- return GetWeightEx();
- }
-
- bool IsOverloaded()
- {
- return GetWeightEx() >= OVERLOAD_LIMIT;
- }
- void SetPlayerLoad(float load)//Deprecated
- {
- m_CargoLoad = load;
- //Print("m_CargoLoad: " + m_CargoLoad);
- //Log(ToString(this) + "'s load weight is " + ftoa(m_CargoLoad) + " g.", LogTemplates.TEMPLATE_PLAYER_WEIGHT);
- }
- //Deprecated, will be overrid by other method calls (in order to ensure stamina calculation is properly set)
- void AddPlayerLoad(float addedload)//Deprecated
- {
- float newload = GetPlayerLoad() + addedload;
- SetPlayerLoad(newload);
-
- // Do not need -> Log is in SetPlayerLoad
- //PrintString(ToString(this) + "'s load weight is " + ToString(m_CargoLoad) + " g.");
- }
- bool IsItemInInventory(EntityAI entity)
- {
- return GetInventory().HasEntityInInventory(entity);
- }
- override bool NeedInventoryJunctureFromServer(notnull EntityAI item, EntityAI currParent, EntityAI newParent)
- {
- if (GetGame().IsMultiplayer())
- {
- DayZPlayerInstanceType t = GetInstanceType();
- switch (t)
- {
- case DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER:
- return false;
- case DayZPlayerInstanceType.INSTANCETYPE_CLIENT:
- case DayZPlayerInstanceType.INSTANCETYPE_SERVER:
- case DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER:
- case DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE:
- case DayZPlayerInstanceType.INSTANCETYPE_REMOTE:
- return true; // Might help mitigate "megabugged" (desync)
-
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " NeedInventoryJunctureFromServer item=" + Object.GetDebugName(item) + " currPar=" + currParent + " newPar=" + newParent);
-
- bool i_owned = GetHumanInventory().HasEntityInInventory(item);
-
- bool cp_owned = false;
- if (currParent)
- cp_owned = GetHumanInventory().HasEntityInInventory(currParent);
-
- bool np_owned = false;
- if (newParent)
- np_owned = GetHumanInventory().HasEntityInInventory(newParent);
- bool all_owned = i_owned && cp_owned && (np_owned || (newParent == null));
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " NeedInventoryJunctureFromServer=" + !all_owned + " i_pwn=" + i_owned + " cp_pwn=" + cp_owned + " np_pwn=" + np_owned);
-
- return !all_owned;
- default:
- Error("[syncinv] unsupported instance type t=" + t);
- break;
- }
- }
- return false;
- }
-
-
- override protected float GetWeightSpecialized(bool forceRecalc = false)
- {
- float totalWeight = super.GetWeightSpecialized(forceRecalc);
-
- ItemBase itemHands = GetItemInHands();
- if (itemHands) // adds weight of item carried in hands
- {
- totalWeight += itemHands.GetWeightEx(forceRecalc);
- }
- #ifdef DEVELOPER
- if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
- {
- float itemInHandsWeight = totalWeight - super.GetWeightSpecialized(forceRecalc);
- WeightDebugData dta = WeightDebug.GetWeightDebug(this);
- dta.SetCalcDetails("TMan: " + (super.GetWeightSpecialized(forceRecalc)+ itemInHandsWeight) +"(contents weight[includes item in hands])");
- }
- #endif
- return totalWeight;
- }
-
- void CalculateVisibilityForAI()
- {
- const int VISIBILITY_SLOTS_COUNT = 10;
- int attcount = GetInventory().AttachmentCount();
- float sumVisibility = 0;
- float countVisibility = 0;
- float visibilityMean = 0;
- if (attcount > 0)
- {
- for (int att = 0; att < attcount; att++)
- {
- EntityAI attachment = GetInventory().GetAttachmentFromIndex(att);
- if (attachment.IsClothing())
- {
- ClothingBase clothing;
- Class.CastTo(clothing, attachment);
- sumVisibility += clothing.GetItemVisibility();
- countVisibility++;
- }
- }
- visibilityMean = (sumVisibility + (VISIBILITY_SLOTS_COUNT - countVisibility)) / VISIBILITY_SLOTS_COUNT;
- SetVisibilityCoef(visibilityMean);
- }
- else
- {
- visibilityMean = 1;
- SetVisibilityCoef(visibilityMean);
- }
- }
-
- void SetVisibilityCoef(float pVisibility)
- {
- m_VisibilityCoef = pVisibility;
- }
-
- float GetVisibilityCoef()
- {
- return m_VisibilityCoef;
- }
-
- int GetShakeLevel()
- {
- return m_Shakes;
- }
-
-
- EStatLevels GetStatLevelHealth()
- {
- float health = GetHealth("","");
- return GetStatLevel(health, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH);
- }
-
- EStatLevels GetStatLevelToxicity()
- {
- float toxicity = GetStatToxicity().Get();
- return GetStatLevel(toxicity, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH);
- }
-
- EStatLevels GetStatLevelBlood()
- {
- float blood = GetHealth("","Blood");
- return GetStatLevel(blood, PlayerConstants.SL_BLOOD_CRITICAL, PlayerConstants.SL_BLOOD_LOW, PlayerConstants.SL_BLOOD_NORMAL, PlayerConstants.SL_BLOOD_HIGH);
- }
-
- EStatLevels GetStatLevelEnergy()
- {
- float energy = GetStatEnergy().Get();
- return GetStatLevel(energy, PlayerConstants.SL_ENERGY_CRITICAL, PlayerConstants.SL_ENERGY_LOW, PlayerConstants.SL_ENERGY_NORMAL, PlayerConstants.SL_ENERGY_HIGH);
- }
-
- EStatLevels GetStatLevelWater()
- {
- float water = GetStatWater().Get();
- return GetStatLevel(water, PlayerConstants.SL_WATER_CRITICAL, PlayerConstants.SL_WATER_LOW, PlayerConstants.SL_WATER_NORMAL, PlayerConstants.SL_WATER_HIGH);
- }
-
- EStatLevels GetImmunityLevel()
- {
- float immunity = GetImmunity();
- if (m_ImmunityBoosted)
- return EStatLevels.GREAT;
- return GetStatLevel(immunity, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_CRITICAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_LOW, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_NORMAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_HIGH);
- }
-
- //-------------------------------------
- float GetBordersImmunity()
- {
- float immunity = GetImmunity();
- float immmunity_max = 1;
- return GetStatLevelBorders(immunity, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_CRITICAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_LOW, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_NORMAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_HIGH, immmunity_max);
- }
-
-
- float GetStatBordersHealth()
- {
- float health = GetHealth("","");
- float health_max = GetMaxHealth("","");
- return GetStatLevelBorders(health, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH, health_max);
- }
-
- float GetStatBordersToxicity()
- {
- float toxicity = GetStatToxicity().Get();
- float toxicity_max = GetStatToxicity().GetMax();
- return GetStatLevelBorders(toxicity, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH, toxicity_max);
- }
-
- float GetStatBordersBlood()
- {
- float blood = GetHealth("","Blood");
- float blood_max = GetMaxHealth("","Blood");
- return GetStatLevelBorders(blood, PlayerConstants.SL_BLOOD_CRITICAL, PlayerConstants.SL_BLOOD_LOW, PlayerConstants.SL_BLOOD_NORMAL, PlayerConstants.SL_BLOOD_HIGH, blood_max);
- }
-
- float GetStatBordersEnergy()
- {
- float energy = GetStatEnergy().Get();
- float energy_max = GetStatEnergy().GetMax();
- return GetStatLevelBorders(energy, PlayerConstants.SL_ENERGY_CRITICAL, PlayerConstants.SL_ENERGY_LOW, PlayerConstants.SL_ENERGY_NORMAL, PlayerConstants.SL_ENERGY_HIGH, energy_max);
- }
-
- float GetStatBordersWater()
- {
- float water = GetStatWater().Get();
- float water_max = GetStatWater().GetMax();
- return GetStatLevelBorders(water, PlayerConstants.SL_WATER_CRITICAL, PlayerConstants.SL_WATER_LOW, PlayerConstants.SL_WATER_NORMAL, PlayerConstants.SL_WATER_HIGH, water_max);
- }
-
- //------------------------------------
-
- float GetStatLevelBorders(float stat_value, float critical, float low, float normal, float high, float max)
- {
- if (stat_value <= critical)
- {
- return Math.InverseLerp(0, critical, stat_value);
- }
- if (stat_value <= low)
- {
- return Math.InverseLerp(critical, low, stat_value);
- }
- if (stat_value <= normal)
- {
- return Math.InverseLerp(low, normal, stat_value);
- }
- if (stat_value <= high)
- {
- return Math.InverseLerp(normal, high, stat_value);
- }
- return Math.InverseLerp(high, max, stat_value);
- }
-
- EStatLevels GetStatLevel(float stat_value, float critical, float low, float normal, float high)
- {
- if (stat_value <= critical)
- {
- return EStatLevels.CRITICAL;
- }
- if (stat_value <= low)
- {
- return EStatLevels.LOW;
- }
- if (stat_value <= normal)
- {
- return EStatLevels.MEDIUM;
- }
- if (stat_value <= high)
- {
- return EStatLevels.HIGH;
- }
- return EStatLevels.GREAT;
- }
-
- void SetImmunityBoosted(bool boosted)
- {
- m_ImmunityBoosted = boosted;
- }
-
-
-
- //!returns player's immunity strength between 0..1
- float GetImmunity()
- {
- float immunity;
- if (GetPlayerStats())
- {
- float max_health = GetMaxHealth("GlobalHealth", "Health") + 0.01;//addition to prevent divisioin by zero in case of some messup
- float max_blood = GetMaxHealth("GlobalHealth", "Blood") + 0.01;//addition to prevent divisioin by zero in case of some messup
- float energy_normalized = GetStatEnergy().Get() / PlayerConstants.SL_ENERGY_MAX;
- float water_normalized = GetStatWater().Get() / PlayerConstants.SL_WATER_MAX;
- float health_normalized = GetHealth("GlobalHealth", "Health") / max_health;
- float blood_normalized = GetHealth("GlobalHealth", "Blood") / max_blood;
- immunity = energy_normalized + water_normalized + health_normalized + blood_normalized;
- immunity = immunity / 4;//avg
- immunity = Math.Clamp(immunity,0,1);
- }
- return immunity;
- }
-
- bool IsSprinting()
- {
- return m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENT_SPRINT);
- }
- bool CanSprint()
- {
- ItemBase item = GetItemInHands();
- if (IsRaised() || (item && item.IsHeavyBehaviour()))
- return false;
-
- if (item && GetThrowing() && GetThrowing().IsThrowingModeEnabled())
- return false;
-
- if (GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS)
- return false;
-
- return true;
- }
-
- bool IsInProne()
- {
- return m_MovementState.IsInProne();
- }
-
- bool IsInRasedProne()
- {
- return m_MovementState.IsInRaisedProne();
- }
-
- bool IsLeaning()
- {
- return m_MovementState.IsLeaning();
- }
-
- bool IsRolling()
- {
- return GetCommand_Move() && GetCommand_Move().IsInRoll());
- }
-
- bool IsClimbing()
- {
- return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB;
- }
-
- bool IsFalling()
- {
- return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_FALL;
- }
- override bool IsFighting()
- {
- return m_IsFighting;
- }
-
- bool IsEmotePlaying()
- {
- return m_EmoteManager && m_EmoteManager.IsEmotePlaying();
- }
-
- override bool IsIgnoredByConstruction()
- {
- return IsRuined();
- }
-
- /*!
- Returns whether the specified movement command(s) are starting the next frame.
- Use caution when using this for anything player animation-related, some commands may require the movement state to be truly active (wait until next update)
- */
- bool AnimCommandCheck(HumanMoveCommandID mask)
- {
- return m_AnimCommandStarting & mask;
- }
-
- void RunFightBlendTimer()
- {
- if (!m_FightEndBlendTimer)
- m_FightEndBlendTimer = new Timer();
- if (!m_FightEndBlendTimer.IsRunning())
- {
- m_FightEndBlendTimer.Run(PlayerConstants.MELEE2_MOVEMENT_BLEND_DELAY,this,"EndFighting");
- }
- }
-
- void EndFighting()
- {
- m_IsFighting = false;
- }
-
- bool CheckMeleeItemDamage(ItemBase item)
- {
- //on-hit drop of melee weapons
- //bayonets & buttstocks
- if (item && item.GetHierarchyParent() && item.GetHierarchyParent().IsWeapon() && item.IsRuined()/*&& item.FindAttachmentBySlotName()*/)
- {
- PlayAttachmentDropSound();
- return DropItem(item);
- }
- //handheld items themselves
- if (item && item == GetItemInHands() && item.IsRuined())
- {
- return PredictiveDropEntity(item);
- }
- return false;
- }
-
- void PlayAttachmentDropSound()
- {
- //TODO
- }
-
- // -------------------------------------------------------------------------
- override void RPC(int rpc_type, array<ref Param> params, bool guaranteed, PlayerIdentity recipient = NULL)
- {
- super.RPC(rpc_type, params, guaranteed, recipient);
- }
- // -------------------------------------------------------------------------
- override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
- {
- super.OnRPC(sender, rpc_type, ctx);
-
- switch (rpc_type)
- {
- #ifndef SERVER
-
- case ERPCs.RPC_PLAYER_STAT:
- if (GetPlayerStats())
- GetPlayerStats().OnRPC(ctx);
- break;
-
- case ERPCs.RPC_SYNC_DISPLAY_STATUS:
- if (GetVirtualHud())
- {
- GetVirtualHud().OnRPC(ctx);
- }
- break;
-
- case ERPCs.RPC_PLAYER_SYMPTOM_ON:
- if (GetSymptomManager())
- {
- GetSymptomManager().OnRPC(ERPCs.RPC_PLAYER_SYMPTOM_ON, ctx);
- }
- break;
-
- case ERPCs.RPC_PLAYER_SYMPTOM_OFF:
- if (GetSymptomManager())
- {
- GetSymptomManager().OnRPC(ERPCs.RPC_PLAYER_SYMPTOM_OFF, ctx);
- }
- break;
-
- case ERPCs.RPC_DAMAGE_VALUE_SYNC:
- if (m_TrasferValues)
- m_TrasferValues.OnRPC(ctx);
- break;
-
- case ERPCs.RPC_USER_ACTION_MESSAGE:
- if (!GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- break;
- }
- if (ctx.Read(m_UAParamMessage))
- {
- string actiontext = m_UAParamMessage.param1;
- MessageAction(actiontext);
- }
- break;
-
- case ERPCs.RPC_SOFT_SKILLS_SPECIALTY_SYNC:
- ref Param1<float> p_synch = new Param1<float>(0);
- ctx.Read(p_synch);
- float specialty_level = p_synch.param1;
- GetSoftSkillsManager().SetSpecialtyLevel(specialty_level);
- break;
- case ERPCs.RPC_SOFT_SKILLS_STATS_SYNC:
- ref Param5<float, float, float, float, bool> p_debug_synch = new Param5<float, float ,float, float, bool>(0, 0, 0, 0, false);
- ctx.Read(p_debug_synch);
- float general_bonus_before = p_debug_synch.param1;
- float general_bonus_after = p_debug_synch.param2;
- float last_UA_value = p_debug_synch.param3;
- float cooldown_value = p_debug_synch.param4;
- float cooldown_active = p_debug_synch.param5;
- GetSoftSkillsManager().SetGeneralBonusBefore(general_bonus_before);
- GetSoftSkillsManager().SetGeneralBonusAfter(general_bonus_after);
- GetSoftSkillsManager().SetLastUAValue(last_UA_value);
- GetSoftSkillsManager().SetCoolDownValue(cooldown_value);
- GetSoftSkillsManager().SetCoolDown(cooldown_active);
- break;
-
- case ERPCs.RPC_WARNING_ITEMDROP:
- {
- if (GetGame().IsClient() && GetGame().GetUIManager() && !GetGame().GetUIManager().FindMenu(MENU_WARNING_ITEMDROP))
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_WARNING_ITEMDROP,null);
- GetGame().GetMission().AddActiveInputExcludes({"menu"});
- }
- break;
- }
-
- case ERPCs.RPC_WARNING_TELEPORT:
- {
- if (GetGame().IsClient() && GetGame().GetUIManager() && !GetGame().GetUIManager().FindMenu(MENU_WARNING_TELEPORT))
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_WARNING_TELEPORT,null);
- GetGame().GetMission().AddActiveInputExcludes({"menu"});
- }
- break;
- }
- case ERPCs.RPC_INIT_SET_QUICKBAR:
- ref Param1<int> count = new Param1<int>(0);
- if (ctx.Read(count));
- {
- for (int i = 0; i < count.param1 ; i++)
- {
- m_QuickBarBase.OnSetEntityRPC(ctx);
- }
- }
- break;
-
- case ERPCs.RPC_SYNC_THERMOMETER:
- {
- float value;
- if (ctx.Read(value))
- m_Hud.SetTemperature(value.ToString() + "#degrees_celsius");
- break;
- }
-
-
- case ERPCs.RPC_CHECK_PULSE:
- ctx.Read(CachedObjectsParams.PARAM1_INT);
- EPulseType pulse;
- if ((CachedObjectsParams.PARAM1_INT.param1 & ActionCheckPulse.TARGET_IRREGULAR_PULSE_BIT) == 0)
- {
- pulse = EPulseType.REGULAR;
- }
- else
- {
- pulse = EPulseType.IRREGULAR;
- }
-
- int blood_level = ~ActionCheckPulse.TARGET_IRREGULAR_PULSE_BIT & CachedObjectsParams.PARAM1_INT.param1;
- if (m_CheckPulseLastTarget)
- {
- m_CheckPulseLastTarget.SetLastUAMessage(ActionCheckPulse.GetPulseMessage(pulse, blood_level));
- }
- break;
-
- //! uses contants outside of ERPCs !!!!
- //woodcutting
- case PlantType.TREE_HARD:
- SoundHardTreeFallingPlay();
- break;
-
- case PlantType.TREE_SOFT:
- SoundSoftTreeFallingPlay();
- break;
-
- case PlantType.BUSH_HARD:
- SoundHardBushFallingPlay();
- break;
-
- case PlantType.BUSH_SOFT:
- SoundSoftBushFallingPlay();
- break;
-
- case ERPCs.RPC_DEBUG_MONITOR_FLT:
- if (m_DebugMonitorValues)
- {
- m_DebugMonitorValues.OnRPCFloat(ctx);
- }
- break;
-
- case ERPCs.RPC_DEBUG_MONITOR_STR:
- if (m_DebugMonitorValues)
- {
- m_DebugMonitorValues.OnRPCString(ctx);
- }
- break;
- #endif
-
- /*
- case ERPCs.RPC_CRAFTING_INVENTORY_INSTANT:
- ref Param3<int, ItemBase, ItemBase> craftParam = new Param3<int, ItemBase, ItemBase>(-1, NULL, NULL);
- if (ctx.Read(craftParam))
- {
- m_ModuleRecipesManager.PerformRecipeServer(craftParam.param1, craftParam.param2, craftParam.param3, this);
- }
- break;
- */
-
-
- #ifdef DIAG_DEVELOPER
- case ERPCs.DEV_RPC_AGENT_RESET:
- {
- bool val;
- if (ctx.Read(val))
- m_AgentPool.RemoveAllAgents();
- break;
- }
-
- case ERPCs.DEV_PLAYER_DEBUG_REQUEST:
- {
- PluginRemotePlayerDebugServer plugin_remote_server = PluginRemotePlayerDebugServer.Cast(GetPlugin(PluginRemotePlayerDebugServer));
- plugin_remote_server.OnRPC(ctx, this);
- break;
- }
-
- case ERPCs.DEV_PLAYER_DEBUG_DATA:
- {
- PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(GetPlugin(PluginRemotePlayerDebugClient));
- PluginDeveloper plugin_dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
- if (plugin_dev.m_ScriptConsole)
- plugin_dev.m_ScriptConsole.OnRPCEx(rpc_type, ctx);
- else
- plugin_remote_client.OnRPC(ctx);
- break;
- }
-
- case ERPCs.DEV_AGENT_GROW:
- {
- m_AgentPool.RemoteGrowRequestDebug(ctx);
- break;
- }
- case ERPCs.RPC_ITEM_DIAG_CLOSE:
- {
- PluginItemDiagnostic mid = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
- mid.StopWatchRequest(this);
- break;
- }
-
- //! Universal Temperature Sources debug
- case ERPCs.DEV_REQUEST_UTS_DEBUG:
- {
- PluginUniversalTemperatureSourceServer plugin_uts_server = PluginUniversalTemperatureSourceServer.Cast(GetPlugin(PluginUniversalTemperatureSourceServer));
- plugin_uts_server.OnRPC(ctx, this);
- break;
- }
-
- case ERPCs.DEV_UTS_DEBUG_DATA:
- {
- PluginUniversalTemperatureSourceClient plugin_uts_client = PluginUniversalTemperatureSourceClient.Cast(GetPlugin(PluginUniversalTemperatureSourceClient));
- plugin_uts_client.OnRPC(ctx);
- break;
- }
- //! ---
- #endif
-
- #ifdef DEVELOPER
- case ERPCs.DEV_RPC_SERVER_SCRIPT:
- {
- //PluginItemDiagnostic plugin = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
- //SetDebugDeveloper_item(plugin.GetWatchedItem(this));//!! needs to be inside DEVELOPER ifdef
-
- if (ctx.Read(CachedObjectsParams.PARAM1_STRING))
- {
- _player = this;
- string code = CachedObjectsParams.PARAM1_STRING.param1;
- bool success = GetGame().ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
- CachedObjectsParams.PARAM1_BOOL.param1 = success;
- RPCSingleParam(ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT, CachedObjectsParams.PARAM1_BOOL,true, GetIdentity());
- }
- break;
- }
-
- case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
- {
- PluginDeveloper dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
- if (dev.m_ScriptConsole)
- dev.m_ScriptConsole.OnRPCEx(rpc_type, ctx);
- break;
- }
-
- case ERPCs.DEV_SET_DEV_ITEM:
- {
- Param1<EntityAI> ent = new Param1<EntityAI>(null);
- if (ctx.Read(ent) && ent.param1)
- {
- PluginItemDiagnostic mid2 = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
- mid2.RegisterDebugItem(ent.param1, this);
- }
- //SetDebugDeveloper_item(this);
- break;
- }
- case ERPCs.RPC_ITEM_DIAG:
- {
- Param1<EntityAI> p1 = new Param1<EntityAI>(null);
- if (ctx.Read(p1))
- {
- PluginItemDiagnostic plgn = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
- plgn.OnRPC(p1.param1, ctx);
- }
- break;
- }
- #endif
- }
-
- #ifdef DIAG_DEVELOPER
- PluginDeveloper module_rc = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
- if (module_rc)
- module_rc.OnRPC(this, rpc_type, ctx);
-
- PluginDeveloperSync module_rcs = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
- if (module_rcs)
- module_rcs.OnRPC(this, rpc_type, ctx);
-
- #ifdef SERVER
- PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenuServer));
- #else
- PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenuClient));
- #endif
-
- if (plugin_diag_menu)
- plugin_diag_menu.OnRPC(this, rpc_type, ctx);
- #endif
- }
-
- override void OnGameplayDataHandlerSync()
- {
- super.OnGameplayDataHandlerSync();
-
- UpdateLighting();
- GetGame().GetMission().SetRespawnModeClient(CfgGameplayHandler.GetDisableRespawnDialog());
- SetHitPPEEnabled(CfgGameplayHandler.GetHitIndicationPPEEnabled());
- }
-
- void UpdateLighting()
- {
- Mission mission = GetGame().GetMission();
- if (mission)
- {
- WorldLighting wLighting = mission.GetWorldLighting();
- if (wLighting)
- wLighting.SetGlobalLighting(CfgGameplayHandler.GetLightingConfig());
- }
- }
-
- void SetContaminatedEffectEx(bool enable, int ppeIdx = -1, int aroundId = ParticleList.CONTAMINATED_AREA_GAS_AROUND, int tinyId = ParticleList.CONTAMINATED_AREA_GAS_TINY, string soundset = "", bool partDynaUpdate = false, int newBirthRate = 0)
- {
- if (enable) // enable
- {
- // We assume that if this is set to true the PPE is already active
- if (m_ContaminatedAreaEffectEnabled == enable)
- return;
-
- if (aroundId !=0)
- {
- if (!m_ContaminatedAroundPlayer)
- {
- m_ContaminatedAroundPlayer = ParticleManager.GetInstance().PlayInWorld(aroundId, GetPosition());
- }
- // First entry in an area with dynamic tweaks to particles
- if (partDynaUpdate)
- {
- m_ContaminatedAroundPlayer.SetParameter(0, EmitorParam.BIRTH_RATE, newBirthRate);
- }
- }
-
- if (!m_ContaminatedAroundPlayerTiny && tinyId !=0)
- {
- m_ContaminatedAroundPlayerTiny = ParticleManager.GetInstance().PlayInWorld(tinyId, GetPosition());
- }
-
- if (ppeIdx != -1)
- {
- PPERequesterBase ppeRequester;
- if (Class.CastTo(ppeRequester, PPERequesterBank.GetRequester(ppeIdx)))
- ppeRequester.Start();
- }
-
- // We start playing the ambient sound
- if (!m_AmbientContamination && soundset != "")
- PlaySoundSetLoop(m_AmbientContamination, soundset, 0.1, 0.1);
-
- }
- else // disable
- {
- if (m_ContaminatedAroundPlayer)
- {
- m_ContaminatedAroundPlayer.Stop();
- m_ContaminatedAroundPlayer = null;
- }
-
- if (m_ContaminatedAroundPlayerTiny)
- {
- m_ContaminatedAroundPlayerTiny.Stop();
- m_ContaminatedAroundPlayerTiny = null;
- }
- if (ppeIdx != -1)
- PPERequesterBank.GetRequester(ppeIdx).Stop(new Param1<bool>(true)); //fade out
-
- // We stop the ambient sound
- if (m_AmbientContamination)
- StopSoundSet(m_AmbientContamination);
-
- // We make sure to reset the state
- }
- m_ContaminatedAreaEffectEnabled = enable;
- }
-
- void SetContaminatedEffect(bool enable, int ppeIdx = -1, int aroundId = ParticleList.CONTAMINATED_AREA_GAS_AROUND, int tinyId = ParticleList.CONTAMINATED_AREA_GAS_TINY, bool partDynaUpdate = false, int newBirthRate = 0)
- {
- SetContaminatedEffectEx(enable, ppeIdx, aroundId, tinyId, "", partDynaUpdate, newBirthRate);
- }
-
- // -------------------------------------------------------------------------
- void UpdateCorpseState()
- {
- UpdateCorpseStateVisual();
- if (m_CorpseState > 0 && !GetIsFrozen())
- SetDecayEffects(Math.AbsInt(m_CorpseState));
- else
- SetDecayEffects();//no params means remove the effects
- m_CorpseStateLocal = m_CorpseState;
- }
- // -------------------------------------------------------------------------
- override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
- {
- super.EEHealthLevelChanged(oldLevel, newLevel, zone);
- if (!GetGame().IsDedicatedServer())
- {
- if (newLevel == GameConstants.STATE_RUINED)
- {
- ClearLastUAMessage();
- }
- if (m_CorpseState != 0)
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseState, 0, false);
- }
- }
- }
-
-
- // -------------------------------------------------------------------------
- override void OnVariablesSynchronized()
- {
- super.OnVariablesSynchronized();
- if (m_ModuleLifespan)
- {
- m_ModuleLifespan.SynchLifespanVisual(this, m_LifeSpanState, m_HasBloodyHandsVisible, m_HasBloodTypeVisible, m_BloodType);
-
- if (m_LifespanLevelLocal != m_LifeSpanState) //client solution, lifespan level changed
- {
- m_LifespanLevelLocal = m_LifeSpanState;
- UpdateHairSelectionVisibility();
- }
- }
-
- CheckSoundEvent();
- if (GetBleedingManagerRemote() && IsPlayerLoaded())
- {
- GetBleedingManagerRemote().OnVariablesSynchronized(GetBleedingBits());
- }
-
- if (m_CorpseStateLocal != m_CorpseState && (IsPlayerLoaded() || IsControlledPlayer()))
- {
- UpdateCorpseState();
- }
-
- if (m_RefreshAnimStateIdx != m_LocalRefreshAnimStateIdx)
- {
- RefreshHandAnimationState(396); //mean animation blend time
- m_LocalRefreshAnimStateIdx = m_RefreshAnimStateIdx;
- }
- if (m_InsideEffectArea != m_InsideEffectAreaPrev)
- {
- if (m_InsideEffectArea)
- {
- OnPlayerIsNowInsideEffectAreaBeginClient();
- }
- else
- {
- OnPlayerIsNowInsideEffectAreaEndClient();
- }
- m_InsideEffectAreaPrev = m_InsideEffectArea;
- }
-
- //-------MODIFIERS START--------
- if (m_SyncedModifiers != m_SyncedModifiersPrev)
- {
- int diff = (m_SyncedModifiers & ~m_SyncedModifiersPrev) | (~m_SyncedModifiers & m_SyncedModifiersPrev);//XOR gets us a mask for modifiers that changed by either deactivating, or activating
- if (eModifierSyncIDs.MODIFIER_SYNC_DROWNING & diff)//has this modifier's status as active/inactive changed ?
- {
- if (eModifierSyncIDs.MODIFIER_SYNC_DROWNING & m_SyncedModifiers)//is this modifier currently active ? if so, it means it's been just activated
- {
- SetDrowning(true);
- }
- else
- {
- SetDrowning(false);
- }
-
- }
-
- m_SyncedModifiersPrev = m_SyncedModifiers;
- }
- //-------MODIFIERS END--------
-
- HandleBrokenLegsSync();
-
- //! Remotely Activated Item Behaviour refresh on item is in hands
- ItemBase itemHands = GetItemInHands();
- if (itemHands)
- {
- RemotelyActivatedItemBehaviour raib = itemHands.GetRemotelyActivatedItemBehaviour();
- if (raib)
- raib.OnVariableSynchronized();
- }
-
- //restrain events
- if (m_IsRestrainedLocal != m_IsRestrained)
- {
- m_IsRestrainedLocal = m_IsRestrained;
- OnRestrainChangeClient();
- }
-
- if (m_IsRestrainStartedLocal != m_IsRestrainStarted)
- {
- m_IsRestrainStartedLocal = m_IsRestrainStarted;
- OnRestrainStartedChangeClient();
- }
- }
-
- //! Checks whether modifier (which has syncing enabled) is currently active, works on both Client and Server
- bool IsSyncedModifierActive(eModifierSyncIDs modifier)
- {
- return (m_SyncedModifiers & m_SyncedModifiersPrev);
- }
-
- void HandleBrokenLegsSync()
- {
- if (m_BrokenLegState != m_LocalBrokenState)
- {
- m_LocalBrokenState = m_BrokenLegState;
- if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
- {
- if (m_BrokenLegState < 0)
- BreakLegSound();
- }
- }
- }
- void FixAllInventoryItems()
- {
- array<EntityAI> items = new array<EntityAI>();
- GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, items);
- foreach (EntityAI item : items)
- {
- item.SetHealthMax("", "");
- item.SetWet(item.GetWetInit());
- item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
- item.SetFrozen(false);
- }
- }
-
- void OnInventoryMenuOpen();
- void OnInventoryMenuClose();
-
- //--------------------------------------------------------------------------
- void OnSelectPlayer()
- {
- //Print("PlayerBase | OnSelectPlayer()");
- m_PlayerSelected = true;
-
- m_QuickBarBase.updateSlotsCount();
-
- m_WeaponManager.SortMagazineAfterLoad();
-
- PlayerIdentity identity = GetIdentity();
-
- #ifdef FEATURE_NETWORK_RECONCILIATION
- if (identity)
- {
- //! TODO(kumarjac): vhc: Check if it causes further issues with SelectPlayer while a player is leaving freecam
- identity.Possess(this);
- }
- #endif
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
- {
- if (identity)
- {
- m_CachedPlayerID = identity.GetId();
- m_CachedPlayerName = identity.GetName();
- }
-
- //! add callbacks for ai target system
- SetAITargetCallbacks(new AITargetCallbacksPlayer(this));
- array<ref Param> params = new array<ref Param>;
- if (m_aQuickBarLoad)
- {
- int count = m_aQuickBarLoad.Count();
- Param1<int> paramCount = new Param1<int>(count);
- params.Insert(paramCount);
- for (int i = 0; i < count; i++)
- {
- m_QuickBarBase.OnSetEntityNoSync(m_aQuickBarLoad.Get(i).param1,m_aQuickBarLoad.Get(i).param2);
- params.Insert(m_aQuickBarLoad.Get(i));
- }
-
- if (count > 0 && GetGame().IsMultiplayer())
- {
- GetGame().RPC(this, ERPCs.RPC_INIT_SET_QUICKBAR, params, true, identity);
- }
- m_aQuickBarLoad = NULL;
- }
-
- GetSoftSkillsManager().InitSpecialty(GetStatSpecialty().Get());
- GetModifiersManager().SetModifiers(true);
-
- SetSynchDirty();
-
- if (GetGame().IsMultiplayer())
- {
- //Drop item warning
- if (m_ProcessUIWarning)
- {
- GetGame().RPCSingleParam(this, ERPCs.RPC_WARNING_ITEMDROP, null, true, identity);
- m_ProcessUIWarning = false;
- }
-
- GetGame().GetMission().SyncRespawnModeInfo(identity);
- }
- }
-
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
- {
- m_ActionManager = new ActionManagerServer(this);
- m_ConstructionActionData = new ConstructionActionData();
-
- CheckForGag();
- }
- else if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- m_ActionManager = new ActionManagerClient(this);
- m_CraftingManager = new CraftingManager(this,m_ModuleRecipesManager);
- m_ConstructionActionData = new ConstructionActionData();
-
- }
- else if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER)
- {
- m_ActionManager = new ActionManagerServer(this);
- }
-
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- if (GetGame().GetMission())
- {
- GetGame().GetMission().ResetGUI();
- // force update player
- GetDayZGame().GetBacklit().UpdatePlayer(true);
- }
-
- m_DeathCheckTimer = new Timer();
- m_DeathCheckTimer.Run(0.1, this, "CheckDeath", null, true);
- PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
- CheckForBurlap();
-
- int characterCount = GetGame().GetMenuData().GetCharactersCount() - 1;
- int idx = GetGame().GetMenuData().GetLastPlayedCharacter();
- if (idx == GameConstants.DEFAULT_CHARACTER_MENU_ID || idx > characterCount)
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetNewCharName);
- }
- GetGame().GetMission().EnableAllInputs(true);
-
- m_PresenceNotifier = PluginPresenceNotifier.Cast(GetPlugin(PluginPresenceNotifier));
- m_PresenceNotifier.Init(this);
- #ifdef DIAG_DEVELOPER
- m_TargetTemperatureDiag = PluginTargetTemperature.Cast(GetPlugin(PluginTargetTemperature));
- m_TargetTemperatureDiag.Init(this);
- #endif
- OnGameplayDataHandlerSync();//only here for legacy reasons
- }
-
- #ifdef BOT
- m_Bot = new Bot(this);
- m_Bot.Start(true, new MyBotTrigger(this));
- #endif
- }
-
- override void SimulateDeath(bool state)
- {
- super.SimulateDeath(state);
- m_UndergroundHandler = null;
- m_UndergroundBunkerHandler = null;
- if (m_EffectWidgets)
- {
- m_EffectWidgets.StopAllEffects();
- m_EffectWidgets.ClearSuspendRequests();
- }
- }
-
- void SetNewCharName()
- {
- g_Game.GetMenuData().SaveCharacter(false, true);
- g_Game.GetMenuData().SetCharacterName(g_Game.GetMenuData().GetLastPlayedCharacter(), g_Game.GetMenuDefaultCharacterData(false).GetCharacterName());
- g_Game.GetMenuData().SaveCharactersLocal();
- }
- void CheckForBurlap()
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- BurlapSackCover attachment;
- Class.CastTo(attachment, GetInventory().FindAttachment(InventorySlots.HEADGEAR));
-
- PPERequester_BurlapSackEffects req;
- if (Class.CastTo(req,PPERequesterBank.GetRequester(PPERequesterBank.REQ_BURLAPSACK)))
- {
- if (attachment)
- {
- req.Start();
- }
- else if (req.IsRequesterRunning())
- {
- PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
- }
- }
- }
- }
-
- void CheckForGag()
- {
- #ifdef SERVER
- Clothing item;
- Class.CastTo(item, GetInventory().FindAttachment(InventorySlots.MASK));
- if (!item)
- {
- Class.CastTo(item, GetInventory().FindAttachment(InventorySlots.HEADGEAR));
- }
-
- if (item && item.IsObstructingVoice())
- {
- item.MutePlayer(this,true);
- }
- else //should probably check for relevant types before removing mumbling and obstruction specifically..
- {
- GetGame().SetVoiceEffect(this, VoiceEffectMumbling, false);
- GetGame().SetVoiceEffect(this, VoiceEffectObstruction, false);
- }
- #endif
- }
-
- void UpdateMaskBreathWidget(notnull MaskBase mask, bool is_start = false)
- {
- if (is_start)
- m_EffectWidgets.ResetMaskUpdateCount();
- float resistance = 0;
- if (mask.HasIntegratedFilter() || mask.IsExternalFilterAttached())
- resistance = 1 - mask.GetFilterQuantity01();
-
- m_EffectWidgets.OnVoiceEvent(resistance);
- m_EffectWidgets.IncreaseMaskUpdateCount();
-
- }
-
-
- // -------------------------------------------------------------------------
- void OnVoiceEvent(PlayerSoundEventBase voice_event)
- {
- if (m_EffectWidgets)
- {
- MaskBase mask = MaskBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
- if (mask)
- {
- UpdateMaskBreathWidget(mask, true);
- //m_EffectWidgets.SetBreathIntensityStamina(GetStaminaHandler().GetStaminaCap(),GetStaminaHandler().GetStamina());
- }
- }
- }
-
- // -------------------------------------------------------------------------
- //! called every cmd handler tick during a playback of PlayerSoundEvent, m_ProcessPlaybackEvent needs to be enabled on the PlayerSoundEvent
- void OnVoiceEventPlayback(PlayerSoundEventBase voice_event, AbstractWave callback, float playback_time)
- {
- if (m_EffectWidgets)
- {
- MaskBase mask = MaskBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
- if (mask)
- {
- if (m_EffectWidgets.m_MaskWidgetUpdateCount < 2 && callback.GetLength() > 2 && playback_time > 0.5 )
- UpdateMaskBreathWidget(mask);
- }
- }
- }
-
- // -------------------------------------------------------------------------
- override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
- {
- if (super.OnInputUserDataProcess(userDataType, ctx))
- return true;
-
- if (m_QuickBarBase.OnInputUserDataProcess(userDataType, ctx))
- return true;
-
- if (m_WeaponManager.OnInputUserDataProcess(userDataType, ctx))
- return true;
- if (HandleRemoteItemManipulation(userDataType, ctx))
- return true;
-
- if (userDataType == INPUT_UDT_INVENTORY && GetHumanInventory().OnInputUserDataProcess(ctx))
- return true;
-
- if (TogglePlacingServer(userDataType, ctx))
- return true;
-
- if (ResetADSPlayerSync(userDataType, ctx))
- return true;
-
- string uid;
- bool mute;
- if (userDataType == INPUT_UDT_USER_MUTE_XBOX)
- {
- if (ctx.Read(uid) && ctx.Read(mute))
- {
- GetGame().MutePlayer(uid, GetIdentity().GetPlainId(), mute);
- // commented because plainID should not be present in logs
- //Print("Player: " + GetIdentity().GetId() + " set mute for " + uid + " to " + mute);
- }
- }
-
- if (m_EmoteManager && userDataType == INPUT_UDT_GESTURE)
- return m_EmoteManager.OnInputUserDataProcess(userDataType, ctx);
-
- if (userDataType == INPUT_UDT_WEAPON_LIFT_EVENT)
- return ReadLiftWeaponRequest(userDataType, ctx);
-
- if (m_ActionManager)
- return m_ActionManager.OnInputUserDataProcess(userDataType, ctx);
- return false;
- }
-
- float GetHealthRegenSpeed()
- {
- float blood = GetHealth("GlobalHealth", "Blood");
- float blood_scale_normalized = Math.InverseLerp(PlayerConstants.BLOOD_THRESHOLD_FATAL, GetMaxHealth("", "Blood"), blood);
- blood_scale_normalized = Math.Clamp(blood_scale_normalized,0,1);
- return Math.Lerp(PlayerConstants.HEALTH_REGEN_MIN, PlayerConstants.HEALTH_REGEN_MAX, blood_scale_normalized);
- }
- bool HandleRemoteItemManipulation(int userDataType, ParamsReadContext ctx)
- {
- if (userDataType == INPUT_UDT_ITEM_MANIPULATION)
- {
- int type = -1;
- ItemBase item1 = null;
- ItemBase item2 = null;
- bool use_stack_max = false;
- int slot_id = -1;
- if (!ctx.Read(type))
- return false;
-
- if (type == 4)
- {
- if (!ctx.Read(item1))
- return false;
- InventoryLocation dst = new InventoryLocation;
- if (dst.ReadFromContext(ctx))
- {
- //Print(InventoryLocation.DumpToStringNullSafe(dst));
- bool dummy;
- if (ctx.Read(dummy))
- item1.SplitItemToInventoryLocation(dst);
- else
- item1.SplitIntoStackMaxToInventoryLocation(dst);
- return true;
- }
- return false;
- }
-
- if (!ctx.Read(item1))
- return false;
- if (!ctx.Read(item2))
- return false;
- if (!ctx.Read(use_stack_max))
- return false;
- if (!ctx.Read(slot_id))
- return false;
-
- if (type == -1 && item1 && item2)//combine
- {
- item1.CombineItems(item2, use_stack_max);
- }
- else if (type == 1 && item1)
- {
- if (use_stack_max)
- item1.SplitIntoStackMax(item2, slot_id, this);
- else
- item1.SplitItem(this);
- }
- else if (type == 2 && item1)
- {
- int row, col;
- if (!ctx.Read(row))
- return false;
- if (!ctx.Read(col))
- return false;
- item1.SplitIntoStackMaxCargo(item2, slot_id, row, col);
- }
- else if (type == 3 && item1)
- {
- item1.SplitIntoStackMaxHands(this);
- }
- return true;
- }
- return false;
- }
-
- // -------------------------------------------------------------------------
- ItemBase GetItemInHands()
- {
- if (GetHumanInventory())
- {
- return ItemBase.Cast(GetHumanInventory().GetEntityInHands());
- }
- return null;
-
- }
- //--------------------------------------------------------------------------
- override EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
- {
- bool is_AI = GetGame().IsKindOf(object_name, "DZ_LightAI");
- if (is_AI)
- {
- return SpawnAI(object_name, pos);
- }
- else
- {
- InventoryLocation inv_loc = new InventoryLocation;
- vector mtx[4];
- Math3D.MatrixIdentity4(mtx);
- mtx[3] = pos;
- inv_loc.SetGround(null, mtx);
-
- int flags = ECE_PLACE_ON_SURFACE;
- #ifdef DEVELOPER
- if (g_Game.IsKindOf(object_name, "Boat"))
- flags = ECE_KEEPHEIGHT;
- #endif
- return EntityAI.Cast(GetGame().CreateObjectEx(object_name, inv_loc.GetPos(), flags));
- }
- }
- return null;
- }
- EntityAI SpawnEntityOnGroundOnCursorDir(string object_name, float distance)
- {
- vector position = GetPosition() + (GetDirection() * distance);
- return SpawnEntityOnGroundPos(object_name, position);
- }
- EntityAI SpawnAI(string object_name, vector pos)
- {
- bool is_ai = GetGame().IsKindOf(object_name, "DZ_LightAI");
- if (is_ai)
- {
- return EntityAI.Cast(GetGame().CreateObjectEx(object_name, pos, ECE_PLACE_ON_SURFACE|ECE_INITAI|ECE_EQUIP_ATTACHMENTS));
- }
- return NULL;
- }
-
- //--------------------------------------------------------------------------
- bool DropItem(ItemBase item)
- {
- bool can_be_dropped = CanDropEntity(item);
- if (can_be_dropped)
- {
- can_be_dropped = PredictiveDropEntity(item);
- }
- vector pos_spawn = GetPosition() + GetDirection();
- pos_spawn[0] = pos_spawn[0] + Math.RandomFloat(-0.2, 0.2);
- pos_spawn[2] = pos_spawn[2] + Math.RandomFloat(-0.2, 0.2);
- item.SetPosition(pos_spawn);
- item.PlaceOnSurface();
- return can_be_dropped;
- }
- // -------------------------------------------------------------------------
- /**
- /brief Creates \p ItemBase in players inventory. If player dont have enough slots for new item, item will be created on the ground under player.
- \param item_name \p string Class name of ItemBase in configs
- \returns \p ItemBase Created item
- @code
- ItemBase item = g_Game.GetPlayer().CreateInInventory("Consumable_GardenLime", "cargo_weapon");
- @endcode
- */
-
-
- EntityAI CreateInInventory(string item_name, string cargo_type = "", bool full_quantity = false)
- {
- InventoryLocation inv_loc = new InventoryLocation;
- if (GetInventory().FindFirstFreeLocationForNewEntity(item_name, FindInventoryLocationType.ANY, inv_loc))
- {
- return SpawnItemOnLocation(item_name, inv_loc, full_quantity);
- }
- return NULL;
- }
-
- ItemBase CreateCopyOfItemInInventory (ItemBase src)
- {
- InventoryLocation loc = new InventoryLocation;
- string t = src.GetType();
- if (GetInventory().FindFirstFreeLocationForNewEntity(t, FindInventoryLocationType.CARGO, loc))
- {
- bool locked = GetGame().HasInventoryJunctureDestination(this, loc);
- if (locked)
- {
- Print("Warning: Split: CreateCopyOfItemInInventory - Cannot create entity at locked inventory at loc=" + InventoryLocation.DumpToStringNullSafe(loc));
- return null;
- }
- ItemBase dst = ItemBase.Cast(GetInventory().LocationCreateLocalEntity(loc, t, ECE_IN_INVENTORY, RF_DEFAULT));
- if (dst)
- {
- MiscGameplayFunctions.TransferItemProperties(src, dst);
- GetGame().RemoteObjectTreeCreate(dst);
-
- Print("CreateCopyOfItemInInventory - created " + dst.GetName() + " at loc=" + InventoryLocation.DumpToStringNullSafe(loc));
- }
- return dst;
- }
- return NULL;
- }
-
- ItemBase CreateCopyOfItemInInventoryOrGround(ItemBase src)
- {
- return CreateCopyOfItemInInventoryOrGroundEx(src, false);
- }
-
- ItemBase CreateCopyOfItemInInventoryOrGroundEx(ItemBase src, bool markItemAsSplitResult = false)
- {
- ItemBase dst = CreateCopyOfItemInInventory(src);
- if (!dst)
- {
- dst = ItemBase.Cast(SpawnEntityOnGroundPos(src.GetType(), this.GetPosition()));
- dst.PlaceOnSurface();
- dst.SetResultOfSplit(markItemAsSplitResult);
- MiscGameplayFunctions.TransferItemProperties(src, dst);
- }
-
- return dst;
- }
- // -------------------------------------------------------------------------
- /**
- colorStatusChannel
- colorAction
- colorFriendly
- colorImportant
- */
- void Message(string text, string style)
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
- {
- GetGame().ChatMP(this, text, style);
- }
- else
- {
- GetGame().Chat(text, style);
- }
- }
- // -------------------------------------------------------------------------
- void MessageStatus(string text)
- {
- Message(text, "colorStatusChannel");
- }
- // -------------------------------------------------------------------------
- void MessageAction(string text)
- {
- Message(text, "colorAction");
- }
- // -------------------------------------------------------------------------
- void MessageFriendly(string text)
- {
- Message(text, "colorFriendly");
- }
- // -------------------------------------------------------------------------
- void MessageImportant(string text)
- {
- Message(text, "colorImportant");
- }
- void CloseInventoryMenu()
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- #ifndef NO_GUI
- UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
- if (menu && (menu.GetID() == MENU_INVENTORY || menu.GetID() == MENU_INSPECT))
- {
- GetGame().GetUIManager().CloseAll();
- GetGame().GetMission().RemoveActiveInputExcludes({"inventory"},false);
- GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
- }
- #endif
- }
- }
-
- // -------------------------------------------------------------------------
- /**
- /brief Delete all items in inventory
- \returns \p void
- @code
- PlayerBase player = GetGame().GetPlayer();
- player.ClearInventory();
- @endcode
- */
- override void ClearInventory()
- {
- if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
- {
- GameInventory inv = PlayerBase.Cast(this).GetInventory();
- array<EntityAI> items = new array<EntityAI>;
- inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
- for (int i = 0; i < items.Count(); i++)
- {
- ItemBase item = ItemBase.Cast(items.Get(i));
- if (item)
- {
- GetGame().ObjectDelete(item);
- }
- }
- ItemBase item_in_hands = ItemBase.Cast(GetHumanInventory().GetEntityInHands());
- if (item_in_hands)
- {
- LocalDestroyEntityInHands();
- }
- }
- }
-
- //! Drops all clothes/wearables this character is carrying on themselves.
- void DropAllItems()
- {
- array<EntityAI> itemsArray = new array<EntityAI>;
- ItemBase item;
- GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, itemsArray);
- int count = itemsArray.Count();
-
- for (int i = 0; i < itemsArray.Count(); i++)
- {
- Class.CastTo(item, itemsArray.Get(i));
-
- if (item && !item.IsInherited(SurvivorBase))
- {
- ServerDropEntity(item);
- }
- }
- }
- string GetPlayerClass()
- {
- string type;
- GetGame().ObjectGetType(this, type);
- return type;
- }
- // --------------------------------------------------
- // Lifespan
- //---------------------------------------------------
-
- void ShavePlayer()
- {
- SetLastShavedSeconds(StatGet(AnalyticsManagerServer.STAT_PLAYTIME));
- m_ModuleLifespan.UpdateLifespan(this, true);
- }
- bool CanShave()
- {
- if (!HasCoveredFaceForShave() && GetLifeSpanState())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
- override void OnParticleEvent(string pEventType, string pUserString, int pUserInt)
- {
- super.OnParticleEvent(pEventType ,pUserString, pUserInt);
-
- if (!GetGame().IsDedicatedServer())
- {
- if (pUserInt == 123456) // 123456 is ID for vomiting effect. The current implementation is WIP.
- {
- PlayerBase player = PlayerBase.Cast(this);
- int boneIdx = player.GetBoneIndexByName("Head");
-
- if (boneIdx != -1)
- {
- EffectParticle eff;
-
- if (m_SyncedModifiers & eModifierSyncIDs.MODIFIER_SYNC_CONTAMINATION2)
- {
- eff = new EffVomitBlood();
- }
- else
- {
- eff = new EffVomit();
- }
-
- eff.SetDecalOwner(player);
- eff.SetAutodestroy(true);
- SEffectManager.PlayInWorld(eff, vector.Zero);
- Particle p = eff.GetParticle();
- player.AddChild(p, boneIdx);
- }
- }
- }
- }
-
-
- bool CanSpawnBreathVaporEffect()
- {
- if (!ToDelete() && IsAlive() && !IsSwimming() && !m_IsDrowning)
- {
- return true;
- }
- return false;
- }
-
- void ProcessADDModifier()
- {
- if (m_AddModifier != -1)
- {
- HumanCommandAdditives ad = GetCommandModifier_Additives();
- if (ad)
- ad.StartModifier(m_AddModifier);
-
- m_AddModifier = -1;
- }
- }
-
- void SpawnBreathVaporEffect()
- {
- //Print("SpawnBreathVaporEffect:"+GetGame().GetTime());
- int boneIdx = GetBoneIndexByName("Head");
- if (boneIdx != -1)
- {
- Particle p;
- switch (m_BreathVapour)
- {
- case 1:
- p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_LIGHT, "-0.03 0.15 0");
- break;
- case 2:
- p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_MEDIUM, "-0.03 0.15 0");
- break;
- case 3:
- p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_HEAVY, "-0.03 0.15 0");
- break;
- default:
- break;
- }
-
- if (p)
- AddChild(p, boneIdx);
- }
- }
-
- // returns 'true' if the player is submerged under water deep enough so that we consider him/her to be eligible for drowning, do note some other conditions may apply for actual drowning to be turned on
- bool GetDrowningWaterLevelCheck()
- {
- int index = GetBoneIndexByName("head");
- vector pos = GetBonePositionWS(index);
- float depth = g_Game.GetWaterDepth(pos);
-
- if (IsSwimming())
- {
- return depth > PlayerConstants.DROWNING_SWIMMING_THRESHOLD;
- }
- else if (IsUnconscious())
- {
- return depth > PlayerConstants.DROWNING_UNCONSCIOUS_THRESHOLD;
- }
- return depth > PlayerConstants.DROWNING_DEFAULT_THRESHOLD;
- }
- void SetLifeSpanStateVisible(int show_state)
- {
- bool state_changed;
- if (show_state != m_LifeSpanState)
- state_changed = true;
- m_LifeSpanState = show_state;
- SetSynchDirty();
-
- if (state_changed) //server only, client solution in OnVariablesSynchronized()
- {
- //SendLifespanSyncEvent(m_LifeSpanState);
-
- UpdateHairSelectionVisibility();
- }
- }
-
- int GetLifeSpanState()
- {
- return m_LifeSpanState;
- }
-
- int GetLastShavedSeconds()
- {
- return m_LastShavedSeconds;
- }
- void SetLastShavedSeconds(int last_shaved_seconds)
- {
- m_LastShavedSeconds = last_shaved_seconds;
- }
-
- bool HasCoveredFaceForShave()
- {
- return IsExclusionFlagPresent(GetFaceCoverageShaveValues());
- }
-
- //! returns a set of face covering values
- static set<int> GetFaceCoverageShaveValues()
- {
- set<int> ret = new set<int>;
- ret.Insert(EAttExclusions.SHAVING_MASK_ATT_0);
- ret.Insert(EAttExclusions.SHAVING_HEADGEAR_ATT_0);
- //ret.Insert(EAttExclusions.SHAVING_EYEWEAR_ATT_0);
-
- return ret;
- }
-
- eBloodyHandsTypes HasBloodyHandsEx()
- {
- return m_HasBloodyHandsVisible;
- }
-
- bool HasBloodyHands()
- {
- return m_HasBloodyHandsVisible;
- }
- void SetBloodyHands(bool show)
- {
- SetBloodyHandsBase(show);
- }
-
- void SetBloodyHandsEx(eBloodyHandsTypes type)
- {
- SetBloodyHandsBase(type);
- }
-
- private void SetBloodyHandsBase(int type)
- {
- m_HasBloodyHandsVisible = type;
- SetSynchDirty();
-
- #ifdef DIAG_DEVELOPER
- #ifndef SERVER
- if (IsControlledPlayer())
- {
- bool enable = type;
- DiagMenu.SetValue(DiagMenuIDs.LIFESPAN_BLOODY_HANDS, enable);
- }
- #endif
- #endif
- }
-
- void SetBloodyHandsPenalty()
- {
- InsertAgent(eAgents.SALMONELLA, 1);
- }
-
- bool HasBloodTypeVisible()
- {
- return m_HasBloodTypeVisible;
- }
-
- void SetBloodTypeVisible(bool show)
- {
- m_HasBloodTypeVisible = show;
- SetSynchDirty();
- }
-
- int GetBloodType()
- {
- return m_BloodType;
- }
-
- void SetBloodType(int blood_type)
- {
- m_BloodType = blood_type;
- SetSynchDirty();
- }
- // --------------------------------------------------
- // Soft Skills
- //---------------------------------------------------
-
- SoftSkillsManager GetSoftSkillsManager()
- {
- return m_SoftSkillsManager;
- }
-
- void CheckDeath()
- {
- if (IsPlayerSelected() && !IsAlive())
- {
- SimulateDeath(true);
- m_DeathCheckTimer.Stop();
- }
- }
-
- // -------------------------------------------------------------------------
-
- // --------------------------------------------------
- // AI Presence
- //---------------------------------------------------
-
- //! Return actual noise presence of player
- int GetNoisePresenceInAI()
- {
- if (m_PresenceNotifier)
- {
- return m_PresenceNotifier.GetNoisePresence();
- }
- return 0;
- }
- // is a bit on in the persistent flags
- bool IsPersistentFlag(PersistentFlag bit)
- {
- return (m_PersistentFlags & bit);
- }
- // turn on/off a bit in the persistent flag
- void SetPersistentFlag(PersistentFlag bit, bool enable)
- {
- if (enable)//turn on bit
- m_PersistentFlags = (m_PersistentFlags | bit);
- else//turn off bit
- m_PersistentFlags = ((~bit) & m_PersistentFlags);
-
- }
-
- // -------------------------------------------------------------------------
- int GetStoreLoadVersion()
- {
- return m_StoreLoadVersion;
- }
- override void OnStoreSave(ParamsWriteContext ctx)
- {
- //Print("OnStoreSave");
- if (GetGame().SaveVersion() < 102)
- {
- ctx.Write(ACT_STORE_SAVE_VERSION);//to be removed after we push 102+
- }
- super.OnStoreSave(ctx);
- GetHumanInventory().OnStoreSave(ctx); // FSM of hands
- OnStoreSaveLifespan(ctx);
- if (GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer())
- {
- GetPlayerStats().SaveStats(ctx);// save stats
- m_ModifiersManager.OnStoreSave(ctx);// save modifiers
- m_AgentPool.OnStoreSave(ctx);//save agents
- GetSymptomManager().OnStoreSave(ctx);//save states
- if (GetBleedingManagerServer())
- {
- GetBleedingManagerServer().OnStoreSave(ctx);//save bleeding sources
- }
- m_PlayerStomach.OnStoreSave(ctx);
- ctx.Write(GetBrokenLegs());
- //ctx.Write(m_LocalBrokenState);
- SaveAreaPersistenceFlag(ctx);
- HumanCommandLadder ladder = GetCommand_Ladder();
- if (ladder)
- {
- ctx.Write(true);
- ctx.Write(ladder.GetLogoutPosition());
- }
- else
- {
- ctx.Write(false);
- }
-
- ArrowManagerPlayer arrowManager = ArrowManagerPlayer.Cast(GetArrowManager());
- arrowManager.Save(ctx);
- }
- }
-
- void SaveAreaPersistenceFlag(ParamsWriteContext ctx)
- {
- if (GetModifiersManager())
- SetPersistentFlag(PersistentFlag.AREA_PRESENCE, GetModifiersManager().IsModifierActive(eModifiers.MDF_AREAEXPOSURE));//set the flag for player's presence in contaminated area
- ctx.Write(m_PersistentFlags);
- }
-
-
- override bool OnStoreLoad(ParamsReadContext ctx, int version)
- {
- //Print("---- PlayerBase OnStoreLoad START ----, version: "+version);
- m_aQuickBarLoad = new array<ref Param2<EntityAI,int>>;
-
- // todo :: this should be after base call !!!!
- if (version < 102)//write removed in v. 102
- {
- if (!ctx.Read(m_StoreLoadVersion))
- return false;
- }
- if (!super.OnStoreLoad(ctx, version))
- return false;
- // FSM of hands
- if (!GetHumanInventory().OnStoreLoad(ctx, version))
- return false;
- if (!OnStoreLoadLifespan(ctx, version))
- return false;
- if (GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer())
- {
- if (!GetPlayerStats().LoadStats(ctx, version)) // load stats
- {
- Print("---- failed to load PlayerStats ----");
- return false;
- }
-
- if (version < m_ModifiersManager.GetStorageVersion())//load modifiers !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
- {
- Print("---- failed to load ModifiersManager, unsupported version ----");
- return false;
- }
- else
- {
- if (!m_ModifiersManager.OnStoreLoad(ctx, version))
- {
- Print("---- failed to load ModifiersManager, read fail ----");
- return false;
- }
- }
-
- if (version < m_AgentPool.GetStorageVersion())//load agents !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
- {
- Print("---- failed to load AgentPool, unsupported version ----");
- return false;
- }
- else
- {
- if (!m_AgentPool.OnStoreLoad(ctx, version))
- {
- Print("---- failed to load AgentPool, read fail ----");
- return false;
- }
- }
-
-
- if (version < GetSymptomManager().GetStorageVersion())//load symptoms !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
- {
- Print("---- failed to load SymptomManager, unsupported version ----");
- return false;
- }
- else
- {
- if (!GetSymptomManager().OnStoreLoad(ctx, version))
- {
- Print("---- failed to load SymptomManager, read fail ----");
- return false;
- }
- }
-
- if (version < GetBleedingManagerServer().GetStorageVersion())//load bleeding manager !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
- {
- Print("---- failed to load BleedingManagerServer, unsupported version ----");
- return false;
- }
- else
- {
- if (!GetBleedingManagerServer().OnStoreLoad(ctx, version))
- {
- Print("---- failed to load BleedingManagerServer, read fail ----");
- return false;
- }
- }
-
- if (version < m_PlayerStomach.GetStorageVersion())//load PlayerStomach !! WILL CANCEL REST OF STREAM IF UNSUPPORTED VERSION !!
- {
- Print("---- failed to load PlayerStomach, unsupported version ----");
- return false;
- }
- else
- {
- if (!m_PlayerStomach.OnStoreLoad(ctx, version))
- {
- Print("---- failed to load PlayerStomach, read fail ----");
- return false;
- }
- }
-
- //Check for broken leg value
- if (version >= 116)
- {
- if (!ctx.Read(m_BrokenLegState))
- {
- return false;
- }
- if (version <= 126)// WHILE >= 116
- {
- if (!ctx.Read(m_LocalBrokenState))
- {
- return false;
- }
- }
- }
- //Load persistent flags value
- if (version >= 125 && (!ctx.Read(m_PersistentFlags)))
- {
- Print("---- failed to load Persistent Flags, read fail ----");
- return false;
- }
- if (version >= 131)
- {
- bool onLadder;
- if (!ctx.Read(onLadder))
- {
- return false;
- }
- if (onLadder)
- {
- vector position;
- if (!ctx.Read(position))
- {
- return false;
- }
- Hive hive = GetHive();
- if (!hive || !hive.CharacterIsLoginPositionChanged(this))
- {
- SetPosition(position);
- }
- }
- }
-
- if (version >= 134)
- {
- ArrowManagerPlayer arrowManager = ArrowManagerPlayer.Cast(GetArrowManager());
- arrowManager.Load(ctx);
- }
- }
-
- Print("---- PlayerBase OnStoreLoad SUCCESS ----");
- return true;
- }
- override void AfterStoreLoad()
- {
- GetHumanInventory().OnAfterStoreLoad();
- if (m_EmoteManager)
- m_EmoteManager.AfterStoreLoad();
-
- if (GetPlayerStats())
- GetPlayerStats().OnAfterStoreLoad();
-
- PlayerRestrictedAreaInstance pra;
- vector currentPos = GetPosition();
- if (g_Game.GetGameState() != DayZGameState.MAIN_MENU && CfgPlayerRestrictedAreaHandler.IsInitialized() && CfgPlayerRestrictedAreaHandler.IsPointInPlayerRestrictedArea(currentPos,pra))
- {
- //vector safePos = pra.GetClosestSafePos3D(currentPos);
- vector safePos = pra.GetRandomSafePos3D(currentPos);
- if (MiscGameplayFunctions.TeleportPlayerToSafeLocation3D(this,safePos) && m_AdminLog)
- m_AdminLog.PlayerTeleportedLog(this,currentPos,safePos,"Spawning in Player Restricted Area: " + pra.areaName);
- }
- }
- void OnStoreSaveLifespan(ParamsWriteContext ctx)
- {
- ctx.Write(m_LifeSpanState);
- ctx.Write(m_LastShavedSeconds);
- ctx.Write(m_HasBloodyHandsVisible);
- ctx.Write(m_HasBloodTypeVisible);
- ctx.Write(m_BloodType);
- }
- bool OnStoreLoadLifespan(ParamsReadContext ctx, int version)
- {
- int lifespan_state = 0;
- if (!ctx.Read(lifespan_state))
- return false;
- m_LifeSpanState = lifespan_state;
-
- int last_shaved = 0;
- if (!ctx.Read(last_shaved))
- return false;
- m_LastShavedSeconds = last_shaved;
-
- if (version < 122)
- {
- bool bloody_hands_old;
- if (!ctx.Read(bloody_hands_old))
- return false;
- m_HasBloodyHandsVisible = bloody_hands_old;
- }
- else
- {
- int bloody_hands = 0;
- if (!ctx.Read(bloody_hands))
- return false;
- m_HasBloodyHandsVisible = bloody_hands;
- }
-
-
- bool blood_visible = false;
- if (!ctx.Read(blood_visible))
- return false;
- m_HasBloodTypeVisible = blood_visible;
-
- int blood_type = 0;
- if (!ctx.Read(blood_type))
- return false;
- m_BloodType = blood_type;
- return true;
- }
-
- vector m_PlayerOldPos;
- void UpdatePlayerMeasures()
- {
- int hour, minute, second;
- GetHourMinuteSecond(hour, minute, second);
- float distance;
- distance = StatGet(AnalyticsManagerServer.STAT_DISTANCE);
- if (m_AnalyticsTimer)
- {
- StatsEventMeasuresData data = new StatsEventMeasuresData();
- data.m_CharacterId = g_Game.GetDatabaseID();
- data.m_TimeInterval = m_AnalyticsTimer.GetRemaining();
- data.m_DaytimeHour = hour;
- data.m_PositionStart = m_PlayerOldPos;
- data.m_PositionEnd = GetPosition();
- data.m_DistanceOnFoot = distance;
- Analytics.PlayerMeasures(data);
- }
- m_PlayerOldPos = GetPosition();
- }
- void OnConnect()
- {
- Debug.Log("Player connected:"+this.ToString(),"Connect");
- // analytics
- GetGame().GetAnalyticsServer().OnPlayerConnect(this);
-
- m_PlayerOldPos = GetPosition();
- if (m_AnalyticsTimer)
- m_AnalyticsTimer.Run(60, this, "UpdatePlayerMeasures", null, true);
-
- //construction action data
- ResetConstructionActionData();
- }
-
- void OnReconnect()
- {
- Debug.Log("Player reconnected:"+this.ToString(),"Reconnect");
-
- //construction action data
-
- ResetConstructionActionData();
- }
-
- void OnDisconnect()
- {
- Debug.Log("Player disconnected:"+this.ToString(),"Connect");
-
- // analytics
- // force update of the stats
- // if player disconnect too soon, UpdatePlayersStats() is not called
- GetGame().GetAnalyticsServer().OnPlayerDisconnect(this);
-
- StatsEventDisconnectedData data = new StatsEventDisconnectedData();
- data.m_CharacterId = g_Game.GetDatabaseID();
- data.m_Reason = "Disconnected";
- Analytics.PlayerDisconnected(data);
-
- if (m_AnalyticsTimer)
- m_AnalyticsTimer.Stop();
- UpdatePlayerMeasures();
-
- SetPlayerDisconnected(true);
- }
- void SetModifiers(bool enable)
- {
- GetModifiersManager().SetModifiers(enable);
- }
- bool Consume(ItemBase source, float amount, EConsumeType consume_type)
- {
- PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
- int agents;
- int pollution = GetGame().GetMission().GetWorldData().GetPollution();
- float temperature = 0;
-
- if (consume_type == EConsumeType.ENVIRO_POND || consume_type == EConsumeType.ENVIRO_WELL)
- {
- if (consume_type == EConsumeType.ENVIRO_POND)
- {
- if (pollution & EPollution.HEAVYMETAL)
- {
- agents = agents | eAgents.HEAVYMETAL;
- }
- agents = agents | eAgents.CHOLERA;
- //plugin.TransmitAgents(NULL, this, AGT_WATER_POND, amount);
- }
- temperature = GetGame().GetMission().GetWorldData().GetLiquidTypeEnviroTemperature(consume_type);
- m_PlayerStomach.AddToStomach(Liquid.GetLiquidClassname(LIQUID_WATER), amount, 0 , agents, temperature);
-
-
- return true;
- }
- if (consume_type == EConsumeType.ENVIRO_SNOW)
- {
- if (pollution & EPollution.HEAVYMETAL)
- {
- agents = agents | eAgents.HEAVYMETAL;
- }
- temperature = GetGame().GetMission().GetWorldData().GetLiquidTypeEnviroTemperature(consume_type);
- m_PlayerStomach.AddToStomach(Liquid.GetLiquidClassname(LIQUID_WATER), amount, 0 , agents, temperature);
- }
-
- Edible_Base edible_item = Edible_Base.Cast(source);
- if (!edible_item || edible_item.GetIsFrozen())
- {
- return false;
- }
-
- agents = edible_item.FilterAgents(edible_item.GetAgents());
- temperature = edible_item.GetTemperature();
-
- if (consume_type == EConsumeType.ITEM_SINGLE_TIME || consume_type == EConsumeType.ITEM_CONTINUOUS)
- {
- if (consume_type == EConsumeType.ITEM_SINGLE_TIME)
- {
- plugin.TransmitAgents(edible_item, this, AGT_UACTION_CONSUME, amount);
- }
- /*
- else
- {
- plugin.TransmitAgents(edible_item, this, AGT_UACTION_TO_PLAYER, amount);
- }
- */
- if (edible_item.IsLiquidContainer())
- {
- int liquid_type = edible_item.GetLiquidType();
- string liquidClassName = Liquid.GetLiquidClassname(liquid_type);
- if (liquidClassName.Length() == 0)
- Error("Error! Trying to add unknown liquid to stomach with item=" + Object.GetDebugName(edible_item) + " consume_type=" + consume_type + " liquid_type=" + liquid_type);
- m_PlayerStomach.AddToStomach(liquidClassName, amount, 0, agents, temperature);
- }
- else
- {
- int food_stage_type;
- if (edible_item.GetFoodStage())
- {
- food_stage_type = edible_item.GetFoodStage().GetFoodStageType();
- }
- m_PlayerStomach.AddToStomach(source.GetType(), amount, food_stage_type, agents, temperature);
- }
- edible_item.Consume(amount, this);
- return true;
- }
- /*
- if (consume_type == EConsumeType.ITEM_CONTINUOUS)
- {
- if (edible_item)
- {
- plugin.TransmitAgents(edible_item, this, AGT_UACTION_TO_PLAYER, amount);
- edible_item.Consume(amount, this);
- //ProcessNutritions(edible_item.GetNutritionalProfile(),amount);
- m_PlayerStomach.AddToStomach(source.GetType(), amount, edible_item.GetNutritionalProfile());
- return true;
- }
- }
- */
- return false;
- }
-
- void ShowUnconsciousScreen(bool show)
- {
- #ifndef NO_GUI
- if (show)
- {
- GetGame().GetUIManager().ScreenFadeIn(0, "You are Unconscious", FadeColors.BLACK, FadeColors.WHITE);
- PrintString("Fade in");
- }
- else
- {
- GetGame().GetUIManager().ScreenFadeOut(0);
- PrintString("Fade out");
- }
- #endif
- }
-
- override void RequestSoundEventEx(EPlayerSoundEventID id, bool from_server_and_client = false, int param = 0)
- {
- if (from_server_and_client && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- PlaySoundEventEx(id, false, false, param);
- return;
- }
- SendSoundEventEx(id, param);
- }
-
- override void RequestSoundEvent(EPlayerSoundEventID id, bool from_server_and_client = false)
- {
- RequestSoundEventEx(id, from_server_and_client);
- }
- override protected void SendSoundEvent(EPlayerSoundEventID id)
- {
- SendSoundEventEx(id);
- }
-
- override protected void SendSoundEventEx(EPlayerSoundEventID id, int param = 0)
- {
- if (!GetGame().IsServer())
- {
- return;
- }
- m_SoundEvent = id;
- m_SoundEventParam = param;
- SetSynchDirty();
-
- if (!GetGame().IsMultiplayer())
- {
- CheckSoundEvent();
- }
-
- //PrintString(GetGame().GetTime().ToString() + " Set SoundEvent, id:" + id.ToString());
- }
-
- void CheckZeroSoundEvent()
- {
- if (m_SoundEvent != 0 && m_SoundEventSent)
- {
- m_SoundEvent = 0;
- m_SoundEventParam = 0;
- m_SoundEventSent = false;
- SetSynchDirty();
- }
- }
-
- void CheckSendSoundEvent()
- {
- if (m_SoundEvent!= 0 && !m_SoundEventSent)
- {
- m_SoundEventSent = true;
- }
- }
-
- override bool PlaySoundEventType(ESoundEventType soundType, int soundEventID, int param = 0)
- {
- if (m_ReplaceSoundEventHandler)
- return m_ReplaceSoundEventHandler.PlayReplaceSound(soundEventID, soundType, param);
-
- return false;
- }
-
- override bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false)
- {
- return PlaySoundEventEx(id, from_anim_system, is_from_server);
- }
-
- override bool PlaySoundEventEx(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false, int param = 0)
- {
- if (!m_PlayerSoundEventHandler)
- return false;
- return m_PlayerSoundEventHandler.PlayRequestEx(id, is_from_server, param);
- }
-
- PlayerSoundEventHandler GetPlayerSoundEventHandler()
- {
- return m_PlayerSoundEventHandler;
- }
-
- void OnBleedingBegin();
- void OnBleedingEnd();
-
- void OnBleedingSourceAdded()
- {
- m_BleedingSourceCount++;
- if (IsControlledPlayer())
- {
- if (!GetGame().IsDedicatedServer())
- {
- DisplayElementBadge dis_elm = DisplayElementBadge.Cast(GetVirtualHud().GetElement(eDisplayElements.DELM_BADGE_BLEEDING));
- if (dis_elm)
- {
- dis_elm.SetValue(GetBleedingSourceCount());
- }
-
-
- //Print("----------bleeding_SoundSet----------");
- SEffectManager.PlaySoundOnObject("bleeding_SoundSet", this);
- }
- }
- }
-
- void OnBleedingSourceRemoved()
- {
- m_BleedingSourceCount--;
- if (GetGame().IsServer())
- {
- ArrowManagerBase arrowManager = GetArrowManager();
- if (GetBleedingSourceCount() > 0)
- {
- arrowManager.DropFirstArrow();
- }
- else
- {
- arrowManager.DropAllArrows();
- }
- }
-
- if (IsControlledPlayer())
- {
- if (!GetGame().IsDedicatedServer())
- {
- //Print("GetBleedingSourceCount() "+GetBleedingSourceCount());
- DisplayElementBadge dis_elm = DisplayElementBadge.Cast(GetVirtualHud().GetElement(eDisplayElements.DELM_BADGE_BLEEDING));
- if (dis_elm)
- {
- dis_elm.SetValue(GetBleedingSourceCount());
- }
- }
- }
- }
-
-
- void OnBleedingSourceRemovedEx(ItemBase item)
- {
- OnBleedingSourceRemoved();
- }
-
- int GetBleedingSourceCount()
- {
- return m_BleedingSourceCount;
- }
- // for debug purposes, should reset some systems like Modifiers, Stats, Damage etc.....
- void ResetPlayer(bool set_max)
- {
- #ifdef DIAG_DEVELOPER
- if (GetGame().IsServer() || !GetGame().IsMultiplayer())
- {
- GetStomach().ClearContents();
- DamageSystem.ResetAllZones(this);
- GetModifiersManager().ResetAll();
-
- // bleeding sources
- if (m_BleedingManagerServer)
- m_BleedingManagerServer.RemoveAllSources();
-
- // Stats
- if (GetPlayerStats())
- {
- int bloodType = GetStatBloodType().Get();
- GetPlayerStats().ResetAllStats();
- GetStatBloodType().Set(bloodType);
- }
- // Agents
- if (m_AgentPool)
- m_AgentPool.RemoveAllAgents();
-
- if (m_StaminaHandler)
- m_StaminaHandler.SetStamina(GameConstants.STAMINA_MAX);
-
- // uncon
- if (IsUnconscious())
- DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, false);
-
- // set max
- if (set_max)
- {
- GetStatWater().Set(GetStatWater().GetMax());
- GetStatEnergy().Set(GetStatEnergy().GetMax());
- }
-
- // fix up inventory
- FixAllInventoryItems();
-
- //remove bloody hands
- PluginLifespan moduleLifespan = PluginLifespan.Cast(GetPlugin(PluginLifespan));
- moduleLifespan.UpdateBloodyHandsVisibilityEx(this, eBloodyHandsTypes.CLEAN);
-
- if (GetArrowManager())
- GetArrowManager().ClearArrows();
- }
- // client + single + server
- HumanCommandVehicle vehCmd = GetCommand_Vehicle();
- if (vehCmd)
- {
- Transport transport = vehCmd.GetTransport();
- if (transport)
- transport.FixEntity();
- }
- #endif
- }
-
- void CheckSoundEvent()
- {
- if (m_SoundEvent != 0)
- {
- PlaySoundEventEx(m_SoundEvent, false, true,m_SoundEventParam);
- m_SoundEvent = 0;
- m_SoundEventParam = 0;
- }
-
- // cancelling marked interrupted sounds
- if (m_PerformedAnimActionID == -1)
- {
- if (m_PerformedActionSounds.Count() == 0)
- return;
-
- foreach (AbstractWave sound : m_PerformedActionSounds)
- {
- if (sound)
- sound.Stop();
- }
-
- m_PerformedActionSounds.Clear();
- }
- }
-
- void TestSend()
- {
- if (GetGame().IsClient()) return;
- RequestSoundEvent(1234);
- //Math.RandomInt(1,4096)
- }
-
- void SetStaminaState(eStaminaState state)
- {
- if (state != m_StaminaState)
- {
- m_StaminaState = state;
- //PrintString("m_StaminaState:"+m_StaminaState.ToString());
- SetSynchDirty();
- }
- }
-
- int GetStaminaState()
- {
- return m_StaminaState;
- }
-
- void UpdateQuickBarExtraSlots()
- {
- m_QuickBarBase.updateSlotsCount();
- }
- bool Save()
- {
- // saved player must be alive and not captive
- if (GetPlayerState() == EPlayerStates.ALIVE && !IsRestrained())
- {
- GetHive().CharacterSave(this);
- Debug.Log("Player "+this.ToString()+ " saved as alive");
-
- return true;
- }
- return false;
- }
- // agent transfer
- //! chance between [0..1] , distance in meters
- void SpreadAgentsEx(float distance = 3,float chance = 0.25)
- {
- if (Math.RandomFloat01() > chance)
- return;
-
- GetGame().GetPlayers(m_ServerPlayers);
- float dist_check = distance * distance;//make it sq
- PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
-
- foreach (Man target: m_ServerPlayers)
- {
- if (vector.DistanceSq(GetWorldPosition(), target.GetWorldPosition()) < dist_check && target != this)
- {
- plugin.TransmitAgents(this, target, AGT_AIRBOURNE_BIOLOGICAL, 1);
- }
- }
- }
-
- void SpreadAgents()//legacy method
- {
- SpreadAgentsEx(3,1);
- }
- //--------------------------------------------------------------------------------------------
- override int GetAgents()
- {
- return m_AgentPool.GetAgents();
- }
- //--------------------------------------------------------------------------------------------
- override void RemoveAgent(int agent_id) //removes a single agent type from the player agent pool
- {
- m_AgentPool.RemoveAgent(agent_id);
- }
- //--------------------------------------------------------------------------------------------
- override void RemoveAllAgents()
- {
- m_AgentPool.RemoveAllAgents();
- }
- //--------------------------------------------------------------------------------------------
- override void InsertAgent(int agent, float count = 1) //adds a single agent type to the player agent pool
- {
- m_AgentPool.AddAgent(agent,count);
- }
- //--------------------------------------------------------------------------------------------
- int GetSingleAgentCount(int agent_id)
- {
- return m_AgentPool.GetSingleAgentCount(agent_id);
- }
- //--------------------------------------------------------------------------------------------
- float GetSingleAgentCountNormalized(int agent_id)
- {
- int max_count = PluginTransmissionAgents.GetAgentMaxCount(agent_id);
- return m_AgentPool.GetSingleAgentCount(agent_id) / max_count;
- }
- float GetTotalAgentCount()
- {
- return m_AgentPool.GetTotalAgentCount();
- }
- void PrintAgents()
- {
- m_AgentPool.PrintAgents();
- }
- void ImmuneSystemTick(float value, float deltaT)
- {
- m_AgentPool.ImmuneSystemTick(value, deltaT);
- }
-
- void AntibioticsAttack(float value)
- {
- m_AgentPool.DrugsAttack(EMedicalDrugsType.ANTIBIOTICS, value);
- }
-
- void SetTemporaryResistanceToAgent(int agent, float time)
- {
- m_AgentPool.SetTemporaryResistance(agent, time);
- }
- //Get aim (player crosshair) position
- vector GetAimPosition()
- {
- float min_distance = 0.5; //min distance, default = 5m
-
- vector from = GetGame().GetCurrentCameraPosition();
- vector to = from + (GetGame().GetCurrentCameraDirection() * min_distance);
- vector contactPos;
- vector contactDir;
- int contactComponent;
-
- DayZPhysics.RaycastRV(from, to, contactPos, contactDir, contactComponent, NULL, NULL, NULL, false, true);
-
- return contactPos;
- }
-
- bool CanEatAndDrink()
- {
- ItemBase mask = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
- return (!mask || (mask && mask.AllowFoodConsumption()));
- }
-
- //get modifier manager
- ModifiersManager GetModifiersManager()
- {
- return m_ModifiersManager;
- }
- PlayerStat<float> GetStatWater()
- {
- if (!m_StatWater && GetPlayerStats())
- {
- m_StatWater = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.WATER));
- }
- return m_StatWater;
- }
-
- PlayerStat<float> GetStatToxicity()
- {
- if (!m_StatToxicity && GetPlayerStats())
- {
- m_StatToxicity = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.TOXICITY));
- }
- return m_StatToxicity;
- }
- PlayerStat<float> GetStatEnergy()
- {
- if (!m_StatEnergy && GetPlayerStats())
- {
- m_StatEnergy = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.ENERGY));
- }
- return m_StatEnergy;
- }
-
- PlayerStat<float> GetStatHeatComfort()
- {
- if (!m_StatHeatComfort && GetPlayerStats())
- {
- m_StatHeatComfort = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.HEATCOMFORT));
- }
- return m_StatHeatComfort;
- }
-
- PlayerStat<float> GetStatTremor()
- {
- if (!m_StatTremor && GetPlayerStats())
- {
- m_StatTremor = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.TREMOR));
- }
- return m_StatTremor;
- }
-
- PlayerStat<int> GetStatWet()
- {
- if (!m_StatWet && GetPlayerStats())
- {
- m_StatWet = PlayerStat<int>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.WET));
- }
- return m_StatWet;
- }
-
- PlayerStat<float> GetStatDiet()
- {
- if (!m_StatDiet && GetPlayerStats())
- {
- m_StatDiet = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.DIET));
- }
- return m_StatDiet;
- }
-
- PlayerStat<float> GetStatStamina()
- {
- if (!m_StatStamina && GetPlayerStats())
- {
- m_StatStamina = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.STAMINA));
- }
- return m_StatStamina;
- }
-
- PlayerStat<float> GetStatSpecialty()
- {
- if (!m_StatSpecialty && GetPlayerStats())
- {
- m_StatSpecialty = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.SPECIALTY));
- }
- return m_StatSpecialty;
- }
-
- PlayerStat<int> GetStatBloodType()
- {
- if (!m_StatBloodType && GetPlayerStats())
- {
- m_StatBloodType = PlayerStat<int>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.BLOODTYPE));
- }
- return m_StatBloodType;
- }
-
- PlayerStat<float> GetStatHeatBuffer()
- {
- if (!m_StatHeatBuffer && GetPlayerStats())
- {
- m_StatHeatBuffer = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.HEATBUFFER));
- }
- return m_StatHeatBuffer;
- }
-
- void SetHeatBufferDynamicMax(float value)
- {
- m_HeatBufferDynamicMax = value;
- SetSynchDirty();
- }
-
- float GetHeatBufferDynamicMax()
- {
- return m_HeatBufferDynamicMax;
- }
-
- void ToggleHeatBufferVisibility(bool show)
- {
- m_HasHeatBuffer = show;
- SetSynchDirty();
- }
-
- void ToggleHeatBufferVisibility(int heatbufferStage)
- {
- m_HeatBufferStage = heatbufferStage;
- SetSynchDirty();
- }
-
- //! UA Last Message
- string GetLastUAMessage()
- {
- return m_UALastMessage;
- }
- void SetLastUAMessage(string pMsg)
- {
- m_UALastMessage = pMsg;
- if (m_UALastMessageTimer.IsRunning())
- {
- m_UALastMessageTimer.Stop();
- }
-
- m_UALastMessageTimer.Run(PlayerConstants.LAST_UA_MSG_LIFETIME, this, "ClearLastUAMessage", null);
- }
- protected void ClearLastUAMessage()
- {
- if (m_UALastMessageTimer.IsRunning())
- {
- m_UALastMessageTimer.Stop();
- }
-
- m_UALastMessage = "";
- }
- //! -------------------------------------------------------------------------
- //! Injured stat
-
- //! update injured state immediately
- void ForceUpdateInjuredState()
- {
- m_InjuryHandler.CheckValue(true);
- }
-
- override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
- {
- #ifdef DIAG_DEVELOPER
- if (m_Bot && action_id > EActions.PLAYER_BOT_INTERNAL_START && action_id < EActions.PLAYER_BOT_END)
- {
- m_Bot.StartAction(action_id);
- return true;
- }
- #endif
-
- return super.OnAction(action_id, player, ctx);
- }
-
- // -------------------------------------------------------------------------
- override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
- {
- int i;
-
- PluginTransmissionAgents pluginTransmissionAgents = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
-
- if (pluginTransmissionAgents)
- {
- map<int, string> agentList = pluginTransmissionAgents.GetSimpleAgentList();
-
- if (agentList)
- {
- foreach (int tid, string tname : agentList)
- {
- string injectName = "Inject " + tname;
- string removeName = "Remove " + tname;
-
- outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_AGENTS_RANGE_INJECT_START + tid, injectName, Colors.WHITE));
- outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_AGENTS_RANGE_REMOVE_START + tid, removeName, Colors.WHITE));
- }
- }
- }
-
- #ifdef DIAG_DEVELOPER
- if (m_Bot || GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE)
- {
- outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
-
- typename e = EActions;
-
- int cnt = e.GetVariableCount();
- int val;
-
- for (i = 0; i < cnt; i++)
- {
- if (!e.GetVariableValue(null, i, val))
- continue;
-
- if (val <= EActions.PLAYER_BOT_INTERNAL_START)
- continue;
-
- if (val == EActions.PLAYER_BOT_START)
- {
- outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
- continue;
- }
-
- if (val >= EActions.PLAYER_BOT_END)
- break;
-
- string name = e.GetVariableName(i);
-
- outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, val, name, FadeColors.LIGHT_GREY));
- }
- }
- #endif
- }
- //-------------------------------------------------------------
- //!
- //! SyncJunctures
- //!
- override void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
- {
- super.OnSyncJuncture(pJunctureID, pCtx);
-
- switch(pJunctureID)
- {
- case DayZPlayerSyncJunctures.SJ_INJURY:
- eInjuryHandlerLevels level;
- bool enable;
- DayZPlayerSyncJunctures.ReadInjuryParams(pCtx, enable, level);
- m_InjuryHandler.SetInjuryCommandParams(enable, level);
- break;
- case DayZPlayerSyncJunctures.SJ_PLAYER_STATES:
- GetSymptomManager().SetAnimation(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_QUICKBAR_SET_SHORTCUT:
- OnQuickbarSetEntityRequest(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_INVENTORY:
- GetInventory().OnInventoryJunctureFromServer(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_INVENTORY_REPAIR:
- GetInventory().OnInventoryJunctureRepairFromServer(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE:
- GetInventory().OnInventoryJunctureFailureFromServer(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_ACTION_INTERRUPT:
- case DayZPlayerSyncJunctures.SJ_ACTION_ACK_ACCEPT:
- case DayZPlayerSyncJunctures.SJ_ACTION_ACK_REJECT:
- m_ActionManager.OnSyncJuncture(pJunctureID,pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_WEAPON_ACTION_ACK_ACCEPT:
- case DayZPlayerSyncJunctures.SJ_WEAPON_ACTION_ACK_REJECT:
- case DayZPlayerSyncJunctures.SJ_WEAPON_SET_JAMMING_CHANCE:
- m_WeaponManager.OnSyncJuncture(pJunctureID,pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_UNCONSCIOUSNESS:
- DayZPlayerSyncJunctures.ReadPlayerUnconsciousnessParams(pCtx, m_ShouldBeUnconscious);
- break;
- case DayZPlayerSyncJunctures.SJ_PLAYER_ADD_MODIFIER:
- GetSymptomManager().SetAnimation(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_KURU_REQUEST:
- float amount;
- if (DayZPlayerSyncJunctures.ReadKuruRequest(pCtx, amount))
- {
- if (GetAimingModel() && IsFireWeaponRaised())
- {
- GetAimingModel().RequestKuruShake(amount);
- }
- }
- break;
- case DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST :
- m_EmoteManager.OnSyncJuncture(pJunctureID, pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_WEAPON_LIFT: // Obsolete
- SetLiftWeapon(pJunctureID, pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_ADS_RESET:
- m_ResetADS = true;
- break;
- case DayZPlayerSyncJunctures.SJ_DELETE_ITEM:
- SetToDelete(pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_BROKEN_LEGS:
- m_BrokenLegsJunctureReceived = true;
- DayZPlayerSyncJunctures.ReadBrokenLegsParamsEx(pCtx, m_BrokenLegState);
- break;
- case DayZPlayerSyncJunctures.SJ_SHOCK :
- DayZPlayerSyncJunctures.ReadShockParams(pCtx, m_CurrentShock);
- break;
- case DayZPlayerSyncJunctures.SJ_STAMINA:
- m_StaminaHandler.OnSyncJuncture(pJunctureID, pCtx);
- break;
- case DayZPlayerSyncJunctures.SJ_STAMINA_MISC:
- m_StaminaHandler.OnSyncJuncture(pJunctureID, pCtx);
- break;
- #ifdef DEVELOPER
- case DayZPlayerSyncJunctures.SJ_DEBUG_GET_IN_VEHICLE:
- EntityAI vehicle;
- DayZPlayerSyncJunctures.ReadGetInVehicleParams(pCtx, vehicle);
- SetGetInVehicleDebug(vehicle);
- break;
- #endif
- }
- }
-
- bool IsItemsToDelete()
- {
- return m_ItemsToDelete.Count() > 0;
- }
-
- void SetToDelete(ParamsReadContext pCtx)
- {
- EntityAI item;
- pCtx.Read(item);
- AddItemToDelete(item);
- }
-
- override void AddItemToDelete(EntityAI item)
- {
- if (item)
- {
- item.SetPrepareToDelete();
- m_ItemsToDelete.Insert(item);
- }
- }
-
- bool CanDeleteItems()
- {
- return !(GetThrowing().IsThrowingAnimationPlaying() || GetDayZPlayerInventory().IsProcessing() || (GetActionManager() && GetActionManager().GetRunningAction()));
- }
-
- override void JunctureDeleteItem(EntityAI item)
- {
- DayZPlayerSyncJunctures.SendDeleteItem(this, item);
- }
-
- void UpdateDelete()
- {
- int count = m_ItemsToDelete.Count();
- if (count > 0)
- {
- if (CanDeleteItems())
- {
- EntityAI itemToDelete;
-
- if (GetGame().IsClient() && GetGame().IsMultiplayer())
- {
- InventoryLocation il = new InventoryLocation();
- for (int i = count - 1; i >= 0 ; i--)
- {
- itemToDelete = m_ItemsToDelete.Get(i);
- if (itemToDelete != null)
- {
- itemToDelete.GetInventory().GetCurrentInventoryLocation(il);
- }
-
- if (itemToDelete == null || (GetItemInHands() == null && il.GetType() == InventoryLocationType.UNKNOWN))
- {
- m_ItemsToDelete.Remove(i);
- }
- }
- }
- else
- {
- for (int j = count - 1; j >= 0 ; j--)
- {
- itemToDelete = m_ItemsToDelete.Get(j);
- if (itemToDelete == null)
- {
- m_ItemsToDelete.Remove(j);
- }
- else
- {
- itemToDelete.Delete();
- m_ItemsToDelete.Remove(j);
- }
- }
- }
- }
- }
- }
-
- override bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
- {
- if (GetActionManager()) // disable character turning while performing actions
- {
- ActionContinuousBase action = ActionContinuousBase.Cast(GetActionManager().GetRunningAction());
- if (action && action.IsFullBody(this) && action.IsCameraLockOnPerform())
- {
- if (!m_IsHeadingRestricted)
- {
- m_IsHeadingRestricted = true;
- m_HeadingRestrictData.InitData(pModel.m_fHeadingAngle, action.GetCameraLRAngle());
- }
-
- return DayZPlayerImplementHeading.RestrictHeading(pDt, pModel, m_fLastHeadingDiff, m_HeadingRestrictData);
- }
- else
- m_IsHeadingRestricted = false;
- }
- //! during fullbody gestures - disables character turning
- if (GetEmoteManager().IsControllsLocked())
- {
- HumanItemAccessor hia = GetItemAccessor();
- HumanItemBehaviorCfg hibcfg = hia.GetItemInHandsBehaviourCfg();
- if (hibcfg && hibcfg.m_StanceRotation[m_MovementState.m_iStanceIdx] == DayZPlayerConstants.ROTATION_DISABLE)
- {
- return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
- }
- else
- {
- m_fLastHeadingDiff = 0;
- return DayZPlayerImplementHeading.ClampHeading(pDt, pModel, m_fLastHeadingDiff);
- }
- }
-
- return super.HeadingModel(pDt, pModel);
- }
-
- override bool IsInventorySoftLocked()
- {
- return m_InventorySoftLockCount > 0;
- }
-
- //! 'soft lock' meaning inventory screen cannot be displayed, but mechanically, inventory operations are still possible
- override void SetInventorySoftLock(bool status)
- {
- if (status)
- m_InventorySoftLockCount++;
- else
- m_InventorySoftLockCount--;
-
- if (m_InventorySoftLockCount < 0)
- m_InventorySoftLockCount = 0;
-
- m_InventorySoftLocked = IsInventorySoftLocked();
- }
-
- void SetLoadedQuickBarItemBind(EntityAI entity, int index)
- {
- if (m_aQuickBarLoad)
- m_aQuickBarLoad.Insert(new Param2<EntityAI, int>(entity,index));
- }
-
- override bool IsLiftWeapon()
- {
- return m_LiftWeapon_player;
- }
-
- //Server
- bool ReadLiftWeaponRequest(int userDataType, ParamsReadContext ctx)
- {
- bool state;
- ctx.Read(state);
-
-
- SetLiftWeapon(state);
-
- return true;
- }
-
- void SetLiftWeapon(int pJunctureID, ParamsReadContext ctx) // Obsolete
- {
- bool state;
- ctx.Read(state);
-
- SetLiftWeapon(state);
-
- //Print("SetLiftWeapon | STS: " + GetSimulationTimeStamp());
- }
-
- void SetLiftWeapon(bool state)
- {
- m_ProcessLiftWeaponState = state;
- m_ProcessLiftWeapon = true;
- }
-
- //! Client-side only
- void SendLiftWeaponSync(bool state)
- {
- HumanCommandWeapons hcw;
-
- // Apply state immediately
- m_LiftWeapon_player = state;
-
- hcw = GetCommandModifier_Weapons();
- if (hcw)
- hcw.LiftWeapon(state);
-
- GetWeaponManager().OnLiftWeapon();
-
- // Notify server to apply same state
- if (GetGame().IsMultiplayer() && GetGame().IsClient())
- {
- ScriptInputUserData ctx = new ScriptInputUserData;
- if (!ctx.CanStoreInputUserData())
- {
- // ctx not available??
- return;
- }
-
- ctx.Write(INPUT_UDT_WEAPON_LIFT_EVENT);
- ctx.Write(state);
- ctx.Send();
- }
- }
-
- override void CheckLiftWeapon()
- {
- // lift weapon check
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- Weapon_Base weap;
- if (Weapon_Base.CastTo(weap, GetItemInHands()))
- {
- bool limited = weap.LiftWeaponCheck(this);
- if (limited && !m_LiftWeapon_player)
- SendLiftWeaponSync(true);
- else if (!limited && m_LiftWeapon_player)
- SendLiftWeaponSync(false);
- }
- else if (m_LiftWeapon_player)
- {
- SendLiftWeaponSync(false);
- }
- }
- }
-
- override void ProcessLiftWeapon()
- {
- if (m_ProcessLiftWeapon)
- {
- HumanCommandWeapons hcw = GetCommandModifier_Weapons();
- if (hcw)
- hcw.LiftWeapon(m_ProcessLiftWeaponState);
-
- GetWeaponManager().OnLiftWeapon();
- m_LiftWeapon_player = m_ProcessLiftWeaponState;
- m_ProcessLiftWeapon = false;
-
- //Debug.Log("SimulationStamp_server: " + this.GetSimulationTimeStamp());
- }
- }
-
- //! state 'true' == hide
- override void HideClothing(ItemOptics optic, bool state)
- {
- super.HideClothing(optic, state);
- array<int> clothingArray = new array<int>;
- Clothing clothes;
-
- if (state && DayZPlayerCameraOptics.Cast(m_CurrentCamera))
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- clothingArray.Insert(InventorySlots.BACK);
- clothingArray.Insert(InventorySlots.SHOULDER);
- clothingArray.Insert(InventorySlots.MELEE);
- if (optic && optic.GetCurrentStepFOV() < GameConstants.DZPLAYER_CAMERA_FOV_IRONSIGHTS)
- {
- clothingArray.Insert(InventorySlots.BODY);
- clothingArray.Insert(InventorySlots.VEST);
- }
-
- SetInvisibleRecursive(true,this,clothingArray);
- }
- }
- //showing should be instant (called directly, not via CallLater)
- else
- {
- if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- {
- clothingArray = {InventorySlots.BACK,InventorySlots.BODY,InventorySlots.VEST,InventorySlots.SHOULDER,InventorySlots.MELEE};
-
- SetInvisibleRecursive(false,this,clothingArray);
- }
- }
- }
-
- void RequestUnconsciousness(bool enable)
- {
- DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, enable);
- }
-
- override void SetDeathDarknessLevel(float duration, float tick_time)
- {
- super.SetDeathDarknessLevel(duration, tick_time);
-
- if (IsControlledPlayer())
- {
- float actual_tick = tick_time;
- if (GetDamageDealtEffect())
- m_DamageDealtEffect = null;
-
- if (GetFlashbangEffect())
- m_FlashbangEffect = null;
-
- float progress;
- if (duration > 0)
- progress = 1 - ((duration - m_DeathDarkeningCurrentTime) / duration);
-
- m_DeathDarkeningCurrentTime += actual_tick;
-
- if (!IsAlive() && IsPlayerSelected())
- {
- m_DeathDarkeningParam.param1 = progress;
- PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Start(m_DeathDarkeningParam);
- }
-
- if (m_DeathDarkeningCurrentTime >= duration)
- {
- StopDeathDarkeningEffect();
- }
- }
- else
- {
- StopDeathDarkeningEffect();
- }
- }
-
- override bool IsInFBEmoteState()
- {
- if (!IsEmotePlaying())
- return false;
- if ((m_EmoteManager.m_Callback && m_EmoteManager.m_Callback.m_IsFullbody) || m_EmoteManager.m_IsSurrendered)
- {
- return true;
- }
- return false;
- }
-
- //! ends surrender, originally intended for surrender->restrained transitioning
- void EndSurrenderRequest(SurrenderData data = null)
- {
- if (m_EmoteManager)
- m_EmoteManager.EndSurrenderRequest(data);
- }
-
- bool IsSurrendered()
- {
- if (m_EmoteManager)
- return m_EmoteManager.m_IsSurrendered;
-
- return false;
- }
-
- bool IsPlayerLoaded()
- {
- return m_PlayerLoaded;
- }
-
- //disconnected, caused problems. Awaiting refactor
- override void CheckAnimationOverrides()
- {
- //FB gesture slideposeangle override
- if (IsInFBEmoteState() && IsControlledPlayer() && IsPlayerSelected())
- {
- OverrideSlidePoseAngle(Math.PI2);
- }
- else if (!IsInFBEmoteState() && IsControlledPlayer() && IsPlayerSelected())
- {
- OverrideSlidePoseAngle(m_OriginalSlidePoseAngle);
- }
-
- //+add more, if needed
- }
-
- /*void OnSurrenderEnd()
- {
- }*/
-
- bool CanRedirectToWeaponManager (notnull EntityAI item, out bool isActionPossible)
- {
- isActionPossible = false;
- Magazine mag = Magazine.Cast(item);
- Weapon_Base wpn = Weapon_Base.Cast(item.GetHierarchyParent());
- if (mag && wpn)
- {
- if (GetWeaponManager().CanDetachMagazine(wpn, mag))
- {
- //Print("[inv] PlayerBase.CanRedirectToWeaponManager OK, can detach mag=" + mag + " from wpn=" + wpn);
- isActionPossible = true;
- }
- else
- {
- //Print("[inv] PlayerBase.CanRedirectToWeaponManager cannot detach mag=" + mag + " from wpn=" + wpn);
- }
- return true;
- }
- return false;
- }
-
- // Inventory actions with redirection to weapon manager
- override bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
- {
- bool can_detach;
- if (CanRedirectToWeaponManager(item,can_detach))
- {
- InventoryLocation il = new InventoryLocation();
- if (can_detach && target.GetInventory().FindFreeLocationFor(item, flags, il))
- {
- return GetWeaponManager().DetachMagazine(il);
- }
- return false;
- }
- return super.PredictiveTakeEntityToTargetInventory(target, flags, item);
- }
- override bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
- {
- bool can_detach;
- if (CanRedirectToWeaponManager(item,can_detach))
- {
- InventoryLocation il = new InventoryLocation();
- if (can_detach && GetInventory().FindFreeLocationFor(item, flags, il))
- {
- return GetWeaponManager().DetachMagazine(il);
- }
- return false;
- }
- return super.PredictiveTakeEntityToInventory(flags, item);
- }
-
- override bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
- {
- Weapon_Base parentWpn = Weapon_Base.Cast(target);
- Magazine mag = Magazine.Cast(item);
- if (parentWpn && mag)
- {
- if (GetWeaponManager().CanAttachMagazine(parentWpn, mag))
- return GetWeaponManager().AttachMagazine(mag);
- return false;
- }
- return super.PredictiveTakeEntityToTargetAttachment(target, item);
- }
-
- override bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
- {
- Weapon_Base parentWpn = Weapon_Base.Cast(target);
- Magazine mag = Magazine.Cast(item);
- if (parentWpn && mag)
- {
- if (target.CanReceiveAttachment(item,slot) && GetWeaponManager().CanAttachMagazine(parentWpn, mag))
- return GetWeaponManager().AttachMagazine(mag);
- return false;
- }
- return super.PredictiveTakeEntityToTargetAttachmentEx(target, item,slot);
- }
-
- override bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
- {
- bool can_detach;
- if (CanRedirectToWeaponManager(item,can_detach))
- {
- InventoryLocation il = new InventoryLocation();
- if (can_detach && target.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, il))
- {
- return GetWeaponManager().DetachMagazine(il);
- }
- return false;
- }
- return super.PredictiveTakeEntityToTargetCargo(target,item);
- }
-
- override bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
- {
- bool can_detach;
- if (CanRedirectToWeaponManager(item, can_detach))
- {
- if (can_detach)
- {
- InventoryLocation dst = new InventoryLocation;
- dst.SetCargoAuto(cargo, item, row, col, item.GetInventory().GetFlipCargo());
- return GetWeaponManager().DetachMagazine(dst);
- }
- return false;
- }
- return super.PredictiveTakeEntityToTargetCargoEx (cargo, item, row, col);
- }
-
- override bool PredictiveDropEntity (notnull EntityAI item)
- {
- bool can_detach;
- if (CanRedirectToWeaponManager(item,can_detach))
- {
- if (can_detach)
- {
- vector m4[4];
- Math3D.MatrixIdentity4(m4);
-
- //! We don't care if a valid transform couldn't be found, we just want to preferably use it instead of placing on the player
- GameInventory.PrepareDropEntityPos(this, item, m4, false, GameConstants.INVENTORY_ENTITY_DROP_OVERLAP_DEPTH);
- InventoryLocation il = new InventoryLocation;
- il.SetGround(item, m4);
- return GetWeaponManager().DetachMagazine(il);
- }
- return false;
- }
- return super.PredictiveDropEntity(item);
- }
-
- override bool PredictiveSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
- {
- ForceStandUpForHeavyItemsSwap(item1, item2);
- //Print("PlayerBase | PredictiveSwapEntities");
- Magazine swapmag1 = Magazine.Cast(item1);
- Magazine swapmag2 = Magazine.Cast(item2);
- if (swapmag1 && swapmag2)
- {
- Weapon_Base parentWpn;
- if (Class.CastTo(parentWpn, swapmag1.GetHierarchyParent()))
- {
- if (GetWeaponManager().CanSwapMagazine(parentWpn, swapmag2))
- {
- Print("[inv] PlayerBase.PredictiveSwapEntities: swapping mag1=" + swapmag1 + " to parent wpn=" + parentWpn + " of mag1=" + swapmag1);
- return GetWeaponManager().SwapMagazine(swapmag2);
- }
- else
- {
- Print("[inv] PlayerBase.PredictiveSwapEntities: can not swap magazines");
- return false;
- }
- }
- if (Class.CastTo(parentWpn, swapmag2.GetHierarchyParent()))
- {
- if (GetWeaponManager().CanSwapMagazine(parentWpn, swapmag1))
- {
- Print("[inv] PlayerBase.PredictiveSwapEntities: swapping mag1=" + swapmag1 + " to parent wpn=" + parentWpn + " of mag2=" + swapmag2);
- return GetWeaponManager().SwapMagazine(swapmag1);
- }
- else
- {
- Print("[inv] PlayerBase.PredictiveSwapEntities: can not swap magazines");
- return false;
- }
- }
- }
-
- EntityAI item_hands;
- EntityAI item_ground;
- if (IsSwapBetweenHandsAndGroundLargeItem(item1,item2,item_hands,item_ground) && !m_ActionManager.GetRunningAction())
- {
- ActionManagerClient mngr_client;
- CastTo(mngr_client,m_ActionManager);
-
- ActionTarget atrg = new ActionTarget(item_ground,null,-1,vector.Zero,-1.0);
- if (mngr_client.GetAction(ActionSwapItemToHands).Can(this,atrg,ItemBase.Cast(item_hands)))
- {
- mngr_client.PerformActionStart(mngr_client.GetAction(ActionSwapItemToHands),atrg,ItemBase.Cast(item_hands));
- return true;
- }
- return super.PredictiveSwapEntities(item1, item2);
- }
- else
- return super.PredictiveSwapEntities(item1, item2);
- }
-
- override bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
- {
- ForceStandUpForHeavyItemsSwap(item1, item2);
- InventoryLocation il = new InventoryLocation;
- if (item1.IsHeavyBehaviour() && item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND && !m_ActionManager.GetRunningAction())
- {
- //Print("override bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)");
- ActionManagerClient mngr_client;
- CastTo(mngr_client,m_ActionManager);
-
- ActionTarget atrg = new ActionTarget(item1,null,-1,vector.Zero,-1.0);
- if (mngr_client.GetAction(ActionSwapItemToHands).Can(this,atrg,ItemBase.Cast(item2)))
- {
- mngr_client.PerformActionStart(mngr_client.GetAction(ActionSwapItemToHands),atrg,ItemBase.Cast(item2));
- }
- return true;
- }
- else
- return super.PredictiveForceSwapEntities(item1, item2, item2_dst);
- }
-
- override void PredictiveTakeEntityToHands(EntityAI item)
- {
- if (item.IsHeavyBehaviour() && !m_ActionManager.GetRunningAction() && !item.GetHierarchyParent())
- {
- ActionManagerClient mngr_client;
- if (CastTo(mngr_client,m_ActionManager))
- {
- ActionTarget atrg = new ActionTarget(item,null,-1,vector.Zero,-1.0);
-
- if (mngr_client.GetAction(ActionTakeItemToHands).Can(this,atrg,null))
- {
- mngr_client.PerformActionStart(mngr_client.GetAction(ActionTakeItemToHands),atrg,null);
- }
- /*).Can(this,
- mngr_client.ActionStart(mngr_client.GetAction(ActionTakeItemToHands),mngr_client.FindActionTarget(),null);
- return;*/
- }
- }
- else
- super.PredictiveTakeEntityToHands(item);
- }
- override bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
- {
- EntityAI item = src.GetItem();
- if (item)
- {
- bool can_detach;
-
- if (CanRedirectToWeaponManager(item,can_detach))
- {
- if (can_detach)
- {
- return GetWeaponManager().DetachMagazine(dst);
- }
- return false;
- }
- return super.PredictiveTakeToDst(src,dst);
- }
- return false;
- }
-
- bool IsSwapBetweenHandsAndGroundLargeItem(notnull EntityAI item1, notnull EntityAI item2, out EntityAI item_hands, out EntityAI item_ground)
- {
- InventoryLocation il = new InventoryLocation;
- if (item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.HANDS)
- item_hands = item1;
- if (item2.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.HANDS)
- item_hands = item2;
- if (item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND)
- item_ground = item1;
- if (item2.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND)
- item_ground = item2;
-
- return item_hands && item_ground && item_ground.IsHeavyBehaviour();
- }
-
- //! Dynamic hair hiding
- void SetHairLevelToHide(int level, bool state, bool was_debug = false)
- {
- if (was_debug && GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
- return;
-
- if (!m_CharactersHead)
- {
- ErrorEx("No valid head detected on character!");
- return;
- }
-
- if (level == -1) //hide/show ALL
- {
- m_HideHairAnimated = !m_HideHairAnimated;
- for (int i = 0; i < m_CharactersHead.m_HeadHairSelectionArray.Count(); ++i)
- {
- //m_CharactersHead.SetSimpleHiddenSelectionState(i,m_HideHairAnimated);
- SelectionTranslation stt = SelectionTranslation.Cast(m_CharactersHead.m_HeadHairHidingStateMap.Get(i));
- stt.SetSelectionState(m_HideHairAnimated);
- m_CharactersHead.m_HeadHairHidingStateMap.Set(i, stt);
- #ifdef DIAG_DEVELOPER
- #ifndef SERVER
- PluginDiagMenuClient diagmenu = PluginDiagMenuClient.Cast(GetPlugin(PluginDiagMenuClient));
- diagmenu.m_HairHidingStateMap.Set(i, m_HideHairAnimated);
- #endif
- #endif
- }
- }
- else //hide/show selected level only
- {
- bool switchState;
- if (was_debug)
- {
- #ifdef DIAG_DEVELOPER
- #ifndef SERVER
- PluginDiagMenuClient diagmenuu = PluginDiagMenuClient.Cast(GetPlugin(PluginDiagMenuClient));
- switchState = !diagmenuu.m_HairHidingStateMap.Get(level);
- diagmenuu.m_HairHidingStateMap.Set(level, switchState);
- #endif
- #endif
- }
- else
- {
- switchState = !state;
- }
- //m_CharactersHead.SetSimpleHiddenSelectionState(level,switchState);
- stt = SelectionTranslation.Cast(m_CharactersHead.m_HeadHairHidingStateMap.Get(level));
- stt.SetSelectionState(switchState);
- m_CharactersHead.m_HeadHairHidingStateMap.Set(level, stt); //nescessary?
- }
- }
-
- void HideHairSelections(ItemBase item, bool state)
- {
- if (!item || !item.GetHeadHidingSelection() || !m_CharactersHead)
- return;
-
- int slot_id; //item currently attached (or detaching from) here
- string slot_name; //item currently attached (or detaching from) here
- string str
- int idx = 0;
- int i;
- int count;
- item.GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
-
- if (item.HidesSelectionBySlot())
- {
- count = item.GetInventory().GetSlotIdCount();
- for (i = 0; i < count; i++)
- {
- if (item.GetInventory().GetSlotId(i) == slot_id)
- {
- str = item.GetHeadHidingSelection().Get(i);
- idx = m_CharactersHead.m_HeadHairSelectionArray.Find(str);
- if (idx != -1)
- SetHairLevelToHide(idx,state);
- #ifdef DEVELOPER
- else
- Debug.Log("No valid selection '" + str + "' found on head of " + GetType() + ". Verify the p3d, model config, and the 'HAIR_HIDING_SELECTIONS' macro in basicDefines.");
- #endif
- }
- }
- }
- else
- {
- count = item.GetHeadHidingSelection().Count();
- for (i = 0; i < count; i++)
- {
- str = item.GetHeadHidingSelection().Get(i);
- idx = m_CharactersHead.m_HeadHairSelectionArray.Find(str);
- if (idx != -1)
- SetHairLevelToHide(idx,state);
- #ifdef DEVELOPER
- else
- Debug.Log("No valid selection '" + str + "' found on head of " + GetType() + ". Verify the p3d, model config, and the 'HAIR_HIDING_SELECTIONS' macro in basicDefines.");
- #endif
- }
- }
- UpdateHairSelectionVisibility();
- }
-
- void UpdateHairSelectionVisibility(bool was_debug = false)
- {
- if (!m_CharactersHead)
- return;
- bool shown;
- bool exception_hidden = false;
- int i;
- int count = m_CharactersHead.m_HeadHairHidingStateMap.Count();
- SelectionTranslation stt;
-
- //hide/show beard
- if (IsMale() && m_CharactersHead.GetBeardIndex() > -1 && !was_debug)
- {
- SetHairLevelToHide(m_CharactersHead.GetBeardIndex(),GetLifeSpanState() != LifeSpanState.BEARD_EXTRA);
- }
-
- //show all first
- for (i = 0; i < count; i++)
- {
- m_CharactersHead.SetSimpleHiddenSelectionState(i,true);
- }
- //then carve it up
- for (i = 0; i < count; i++)
- {
- stt = m_CharactersHead.m_HeadHairHidingStateMap.Get(i);
- shown = stt.GetSelectionState();
- if (!shown)
- {
- if (/*IsMale() && */!m_CharactersHead.IsHandlingException())
- {
- m_CharactersHead.SetSimpleHiddenSelectionState(i,shown);
- UpdateTranslatedSelections(stt);
- //Print("hidden idx: " + i);
- }
- else
- {
- exception_hidden = true;
- }
- }
- }
-
- //exceptions handled differently; hides hair
- if (exception_hidden)
- {
- m_CharactersHead.SetSimpleHiddenSelectionState(m_CharactersHead.GetHairIndex(),false);
- if (IsMale())
- m_CharactersHead.SetSimpleHiddenSelectionState(m_CharactersHead.GetBeardIndex(),false);
- }
- }
-
- void UpdateTranslatedSelections(SelectionTranslation stt)
- {
- int index;
- array<int> translatedSelectinosArray = stt.GetTranslatedSelections();
- for (int i = 0; i < translatedSelectinosArray.Count(); i++)
- {
- index = translatedSelectinosArray.Get(i);
- //if (index > -1)
- m_CharactersHead.SetSimpleHiddenSelectionState(index,false); //safe this way, only hiding/carving from shown parts
- }
- }
-
- //! helper method for re-checking hairhiding on character load
- void CheckHairClippingOnCharacterLoad()
- {
- ItemBase headgear = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.HEADGEAR));
- ItemBase mask = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
-
- HideHairSelections(headgear,true);
- HideHairSelections(mask,true);
- }
-
- bool IsNVGWorking()
- {
- return m_ActiveNVTypes && m_ActiveNVTypes.Count() > 0;
- }
-
- bool IsNVGLowered()
- {
- return m_LoweredNVGHeadset;
- }
-
- int GetNVType()
- {
- if (!m_ActiveNVTypes || m_ActiveNVTypes.Count() == 0)
- {
- return NVTypes.NONE;
- }
- else
- {
- return m_ActiveNVTypes[m_ActiveNVTypes.Count() - 1];
- }
- }
-
- array<int> GetNVTypesArray()
- {
- return m_ActiveNVTypes;
- }
-
- //!Deprecated
- void SetNVGWorking(bool state)
- {
- //Deprecated, below is for legacy's sake
- AddActiveNV(NVTypes.NV_GOGGLES);
- }
-
- void SetNVGLowered(bool state)
- {
- m_LoweredNVGHeadset = state;
- }
-
- void AddActiveNV(int type)
- {
- if (!m_ActiveNVTypes || (GetGame().IsMultiplayer() && GetGame().IsServer()))
- {
- #ifdef DEVELOPER
- Error("AddActiveNV | illegal server-side call!");
- #endif
-
- return;
- }
-
- if (m_ActiveNVTypes.Find(type) == -1)
- m_ActiveNVTypes.Insert(type);
- }
-
- void RemoveActiveNV(int type)
- {
- if (!m_ActiveNVTypes || (GetGame().IsMultiplayer() && GetGame().IsServer()))
- {
- #ifdef DEVELOPER
- Error("RemoveActiveNV | illegal server-side call!");
- #endif
-
- return;
- }
-
- if (m_ActiveNVTypes.Find(type) != -1)
- m_ActiveNVTypes.RemoveItem(type);
- }
-
- void ResetActiveNV()
- {
- m_ActiveNVTypes.Clear();
- }
-
- #ifdef DEVELOPER
- override string GetDebugText()
- {
- string text = super.GetDebugText();
- /*
- text += "GetMovementTimeToStrafeJog:" + CfgGameplayHandler.GetMovementTimeToStrafeJog() + "\n";
- text += "GetMovementTimeToStrafeSprint:" + CfgGameplayHandler.GetMovementTimeToStrafeSprint()+ "\n";
-
- SHumanCommandMoveSettings moveSettings = GetDayZPlayerType().CommandMoveSettingsW();
- if (moveSettings)
- {
- text += "hmcs.m_fDirFilterTimeout:" + moveSettings.m_fDirFilterTimeout + "\n";
- text += "hmcs.m_fDirFilterSprintTimeout:" + moveSettings.m_fDirFilterSprintTimeout+ "\n";
- }*/
-
- return text;
- }
-
-
- void DEBUGRotateNVG()
- {
- NVGoggles nvg;
-
- if (FindAttachmentBySlotName("Eyewear"))
- {
- nvg = NVGoggles.Cast(FindAttachmentBySlotName("Eyewear").FindAttachmentBySlotName("NVG"));
- }
- else if (FindAttachmentBySlotName("Headgear"))
- {
- nvg = NVGoggles.Cast(FindAttachmentBySlotName("Headgear").FindAttachmentBySlotName("NVG"));
- }
-
- if (nvg)
- {
- nvg.RotateGoggles(nvg.m_IsLowered);
- }
- }
- #endif
-
- void AdjustBandana(EntityAI item, string slot_name)
- {
- if (Bandana_ColorBase.Cast(item))
- {
- if (slot_name == "Headgear")
- {
- item.SetSimpleHiddenSelectionState(0,1);
- item.SetSimpleHiddenSelectionState(1,0);
- }
- else if (slot_name == "Mask")
- {
- item.SetSimpleHiddenSelectionState(0,0);
- item.SetSimpleHiddenSelectionState(1,1);
- }
- }
- }
-
- void AdjustShemag(EntityAI item, string slot_name)
- {
- if (Shemag_ColorBase.Cast(item))
- {
- if (slot_name == "Headgear")
- {
- item.SetSimpleHiddenSelectionState(0,1);
- item.SetSimpleHiddenSelectionState(1,0);
- }
- else if (slot_name == "Mask")
- {
- item.SetSimpleHiddenSelectionState(0,0);
- item.SetSimpleHiddenSelectionState(1,1);
- }
- }
- }
-
- //client-side
- void UpdateCorpseStateVisual()
- {
- //Print("---Prettying up corpses... | " + GetGame().GetTime() + " | " + this + " | " + GetType() + "---");
- //Print("m_DecayedTexture = " + m_DecayedTexture);
- int state = Math.AbsInt(m_CorpseState);//negative sign denotes a special meaning(state was forced to a live player), but we are only intetested in the positive value here
- if (state == PlayerConstants.CORPSE_STATE_DECAYED)
- {
- EntityAI bodypart;
- ItemBase item;
-
- string path;
- int idx;
- int slot_id;
- array<string> bodyparts = {"Gloves","Body","Legs","Feet"};
-
- for (int i = 0; i < bodyparts.Count(); i++)
- {
- slot_id = InventorySlots.GetSlotIdFromString(bodyparts.Get(i));
- bodypart = GetInventory().FindPlaceholderForSlot(slot_id);
- item = ItemBase.Cast(GetInventory().FindAttachment(slot_id));
-
- if (bodypart)
- {
- path = "cfgVehicles " + bodypart.GetType();
- idx = bodypart.GetHiddenSelectionIndex("personality");
- if (idx > -1)
- {
- bodypart.SetObjectTexture(idx,m_DecayedTexture);
- }
- }
- if (item)
- {
- path = "cfgVehicles " + item.GetType();
- idx = item.GetHiddenSelectionIndex("personality");
- if (idx > -1)
- {
- item.SetObjectTexture(idx,m_DecayedTexture);
- }
- }
- }
-
- SetFaceTexture(m_DecayedTexture);
- }
- }
-
- void SetDecayEffects(int effect = -1)
- {
- int boneIdx = GetBoneIndexByName("Spine2");
- Particle p;
-
- switch (effect)
- {
- case PlayerConstants.CORPSE_STATE_MEDIUM :
- //play medium sound/flies particle
- if (!m_FliesEff)
- m_FliesEff = new EffSwarmingFlies();
-
- if (m_FliesEff && !SEffectManager.IsEffectExist(m_FliesIndex))
- {
- m_FliesEff.SetDecalOwner(this);
- m_FliesIndex = SEffectManager.PlayOnObject(m_FliesEff, this, "0 0.25 0");
- p = m_FliesEff.GetParticle();
- AddChild(p, boneIdx);
- if (!m_SoundFliesEffect)
- {
- PlaySoundSetLoop(m_SoundFliesEffect, "Flies_SoundSet", 1.0, 1.0);
- }
- }
- break;
- case PlayerConstants.CORPSE_STATE_DECAYED :
- //play serious sound/flies particle
- if (!m_FliesEff)
- m_FliesEff = new EffSwarmingFlies();
-
- if (m_FliesEff && !SEffectManager.IsEffectExist(m_FliesIndex))
- {
- m_FliesEff.SetDecalOwner(this);
- m_FliesIndex = SEffectManager.PlayOnObject(m_FliesEff, this, "0 0.25 0");
- p = m_FliesEff.GetParticle();
- AddChild(p, boneIdx);
- if (!m_SoundFliesEffect)
- {
- PlaySoundSetLoop(m_SoundFliesEffect, "Flies_SoundSet", 1.0, 1.0);
- }
- }
- break;
- //remove
- default:
- SEffectManager.DestroyEffect(m_FliesEff);
- StopSoundSet(m_SoundFliesEffect);
- break;
- }
- }
-
- void PreloadDecayTexture()
- {
- int idx = GetHiddenSelectionIndex("decay_preload");
- if (idx > -1)
- SetObjectTexture(idx, m_DecayedTexture);
- }
-
- void SetLastMapInfo(float scale, vector pos)
- {
- m_LastMapScale = scale;
- m_LastMapPos = pos;
- }
-
- bool GetLastMapInfo(out float scale, out vector pos)
- {
- scale = m_LastMapScale;
- pos = m_LastMapPos;
-
- return m_LastMapScale != -1.0;
- }
-
- override bool PhysicalPredictiveDropItem(EntityAI entity, bool heavy_item_only = true)
- {
- vector dir;
- ItemBase item = ItemBase.Cast(entity);
-
- //! from hands
- if (GetItemInHands() == item)
- {
- return PredictiveDropEntity(item);
- }
- else
- {
- ActionManagerClient actionManager = ActionManagerClient.Cast(m_ActionManager);
- if (actionManager)
- {
- ActionTarget actionTarget = new ActionTarget(null, null, -1, vector.Zero, -1);
- if (actionManager.GetAction(ActionDropItemSimple).Can(this, actionTarget, item))
- {
- actionManager.PerformActionStart(actionManager.GetAction(ActionDropItemSimple), actionTarget, item);
- return true;
- }
- }
- else
- return true;
- }
-
- return false;
- }
-
- override void SetProcessUIWarning(bool state)
- {
- m_ProcessUIWarning = state;
- }
-
- void dmgDebugPrint(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
- {
- /*Print("ProjectileDebugging | Damage Health: " + damageResult.GetDamage(dmgZone,"Health") + " | Component: " + component + " | Zone: " + dmgZone + "| Timestamp: " + GetSimulationTimeStamp());
- Print("ProjectileDebugging | speedCoef: " + speedCoef);
- Print("ProjectileDebugging | GetWorldTime(): " + GetWorldTime());
- Print("-----------------------------------------------");*/
- }
-
- //Use this method to process additionnal dmg to legs specifically (must use the dmg system to fire relevant events)
- //Legzone is a dummy to inflict damage once and NOT transfer damage to other zones. All leg zones will drop to 0 anyway
- void DamageAllLegs(float inputDmg)
- {
- array<string> legZones = new array<string>;
- legZones.Insert("LeftLeg");
- legZones.Insert("RightLeg");
- legZones.Insert("RightFoot");
- legZones.Insert("LeftFoot");
-
- foreach (string legZone : legZones)
- DecreaseHealth(legZone, "", inputDmg);
- }
-
- //! tries to hide item in player's hands, some exceptions for various movement states
- void TryHideItemInHands(bool hide, bool force = false)
- {
- if (!hide && ((!IsSwimming() && !IsClimbingLadder() && !IsInVehicle() && !AnimCommandCheck(HumanMoveCommandID.CommandSwim | HumanMoveCommandID.CommandLadder | HumanMoveCommandID.CommandVehicle)) || force))
- {
- GetItemAccessor().HideItemInHands(false);
- }
- else
- {
- GetItemAccessor().HideItemInHands(true);
- }
- }
-
- //!
- bool CheckAndExecuteStackSplit(FindInventoryLocationType flags, notnull EntityAI item, notnull EntityAI target)
- {
- float stackable = item.GetTargetQuantityMax();
- if (!(stackable == 0 || stackable >= item.GetQuantity()))
- {
- InventoryLocation il = new InventoryLocation;
- if (target && target.GetInventory().FindFreeLocationFor(item, flags, il))
- {
- ItemBase itemB;
- if (CastTo(itemB, item))
- {
- itemB.SplitIntoStackMaxToInventoryLocationClient(il);
- return true;
- }
- }
- }
- return false;
- }
-
- bool CheckAndExecuteStackSplitToInventoryLocation(InventoryLocation il, notnull EntityAI item)
- {
- float stackable = item.GetTargetQuantityMax();
- if (!(stackable == 0 || stackable >= item.GetQuantity()))
- {
- ItemBase itemB;
- if (CastTo(itemB, item))
- {
- itemB.SplitIntoStackMaxToInventoryLocationClient(il);
- return true;
- }
- }
- return false;
- }
-
- override protected bool TakeEntityToInventoryImpl(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
- {
- if (CheckAndExecuteStackSplit(flags, item, this))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Inv(SPLIT) item=" + GetDebugName(item));
- return true;
- }
-
- return super.TakeEntityToInventoryImpl(mode, flags, item);
- }
-
- override protected bool TakeEntityToCargoImpl(InventoryMode mode, notnull EntityAI item)
- {
- if (CheckAndExecuteStackSplit(FindInventoryLocationType.CARGO, item, this))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Cgo(SPLIT) item=" +GetDebugName(item));
- return true;
- }
-
- return super.TakeEntityToCargoImpl(mode, item);
- }
-
- override protected bool TakeEntityAsAttachmentImpl(InventoryMode mode, notnull EntityAI item)
- {
- if (CheckAndExecuteStackSplit(FindInventoryLocationType.ATTACHMENT, item, this))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Att(SPLIT) item=" + GetDebugName(item));
- return true;
- }
-
- return super.TakeEntityAsAttachmentImpl(mode, item);
- }
-
- override void TakeEntityToHandsImpl(InventoryMode mode, EntityAI item)
- {
- if (CheckAndExecuteStackSplit(FindInventoryLocationType.HANDS, item, this))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Hands(SPLIT) item=" + GetDebugName(item));
- return;
- }
-
- super.TakeEntityToHandsImpl(mode, item);
- }
-
- override protected bool TakeEntityToTargetInventoryImpl(InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
- {
- if (CheckAndExecuteStackSplit(flags, item, target))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetInv(SPLIT) item=" + GetDebugName(item));
- return true;
- }
-
- return super.TakeEntityToTargetInventoryImpl(mode, target, flags, item);
- }
-
- override protected bool TakeEntityToTargetCargoImpl(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
- {
- if (CheckAndExecuteStackSplit(FindInventoryLocationType.CARGO, item, target))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetCgo(SPLIT) item=" + GetDebugName(item));
- return true;
- }
-
- return super.TakeEntityToTargetCargoImpl(mode, target, item);
- }
-
- override protected bool TakeEntityToTargetAttachmentImpl(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
- {
- if (CheckAndExecuteStackSplit(FindInventoryLocationType.ATTACHMENT, item, target))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetAtt(SPLIT) item=" + GetDebugName(item));
- return true;
- }
-
- return super.TakeEntityToTargetAttachmentImpl(mode, target, item);
- }
-
- override protected bool TakeToDstImpl(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
- {
- if (CheckAndExecuteStackSplitToInventoryLocation(dst, dst.GetItem()))
- {
- if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Dst(SPLIT) item=" + GetDebugName(dst.GetItem()));
- return true;
- }
-
- return super.TakeToDstImpl(mode, src, dst);
- }
-
- override vector GetCenter()
- {
- return GetBonePositionWS(GetBoneIndexByName("spine3"));
- }
-
-
- // contaminated areas - temp stuff
- void ContaminatedParticleAdjustment()
- {
- if (GetCommand_Move() && m_ContaminatedAroundPlayer && m_ContaminatedAroundPlayerTiny)
- {
- float playerSpeed = GetCommand_Move().GetCurrentMovementSpeed();
- //Print(playerSpeed);
-
- // 1 - prone, crouch
- // 2 - jog
- // 3 - sprint
- float particleLifetime = 5.25;
- float particleSpeed = 0.25;
- if (playerSpeed >= 1)
- {
- particleLifetime = 3.5;
- particleSpeed = 3.25;
- }
- if (playerSpeed >= 2)
- {
- particleLifetime = 2.5;
- particleSpeed = 5.25;
- }
- if (playerSpeed >= 3)
- {
- particleLifetime = 1.5;
- particleSpeed = 8.25;
- }
- m_ContaminatedAroundPlayer.SetParameter(0, EmitorParam.LIFETIME, particleLifetime);
- m_ContaminatedAroundPlayer.SetParameter(1, EmitorParam.LIFETIME, particleLifetime);
- m_ContaminatedAroundPlayer.SetParameter(2, EmitorParam.LIFETIME, particleLifetime);
- m_ContaminatedAroundPlayer.SetParameter(3, EmitorParam.LIFETIME, particleLifetime);
-
- m_ContaminatedAroundPlayerTiny.SetParameter(0, EmitorParam.VELOCITY, particleSpeed);
- vector transform[4];
- GetTransform(transform);
- m_ContaminatedAroundPlayer.SetTransform(transform);
- m_ContaminatedAroundPlayerTiny.SetTransform(transform);
- }
- }
-
- void HandleGlassesEffect()
- {
- if (!IsControlledPlayer())
- return;
- int i;
-
- if (m_ProcessRemoveGlassesEffects)
- {
- for (i = 0; i < m_ProcessRemoveGlassesEffects.Count(); i++)
- {
- PPERequesterBank.GetRequester(m_ProcessRemoveGlassesEffects[i]).Stop();
- }
- m_ProcessRemoveGlassesEffects.Clear();
- }
-
- if (m_ProcessAddGlassesEffects)
- {
- for (i = 0; i < m_ProcessAddGlassesEffects.Count(); i++)
- {
- PPERequesterBank.GetRequester(m_ProcessAddGlassesEffects[i]).Start();
- }
- m_ProcessAddGlassesEffects.Clear();
- }
- }
-
- override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
- {
- CachedObjectsArrays.ARRAY_STRING.Clear();
- GetActionComponentNameList(componentIndex, CachedObjectsArrays.ARRAY_STRING, LOD.NAME_FIRE);
-
- int pivot = componentIndex;
- int newPivot = -1;
- string compName;
- for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count() && newPivot == -1; i++)
- {
- compName = CachedObjectsArrays.ARRAY_STRING.Get(i);
- newPivot = GetBoneIndexByName(compName);
-
- }
-
- if (newPivot != -1)
- {
- pivot = newPivot;
-
- }
-
- vector parentTransMat[4];
- vector arrowTransMat[4];
-
- arrow.GetTransform(arrowTransMat);
-
- if (pivot == -1)
- {
- GetTransformWS(parentTransMat);
- }
- else
- {
- vector rotMatrix[3];
- Math3D.YawPitchRollMatrix(closeBoneRotWS * Math.RAD2DEG,rotMatrix);
-
- parentTransMat[0] = rotMatrix[0];
- parentTransMat[1] = rotMatrix[1];
- parentTransMat[2] = rotMatrix[2];
- parentTransMat[3] = closeBonePosWS;
- }
-
- Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
- Math3D.MatrixOrthogonalize4(arrowTransMat);
- arrow.SetTransform(arrowTransMat);
-
- AddChild(arrow, pivot);
-
- #ifdef SERVER
- // creating bleeding source
- BleedingSourcesManagerServer bleedingManager = GetBleedingManagerServer();
- if (bleedingManager)
- {
- if (!bleedingManager.AttemptAddBleedingSourceBySelection(compName))
- bleedingManager.AttemptAddBleedingSourceBySelection("Pelvis");//fallback, if we can't attach bleeding source to the fallback location because there already is another one, it's fine, we are just trying make sure there is at least one
- }
- #endif
- }
-
- override bool IsManagingArrows()
- {
- return true;
- }
-
- string GetCachedName()
- {
- return m_CachedPlayerName;
- }
-
- string GetCachedID()
- {
- return m_CachedPlayerID;
- }
-
- override void OnFreezeStateChangeClient()
- {
- super.OnFreezeStateChangeClient();
-
- UpdateCorpseState();
- }
- bool HasHeatBuffer()
- {
- return m_HasHeatBuffer;
- }
-
- int GetHeatBufferStage()
- {
- return m_HeatBufferStage;
- }
-
- //! ----------
- //! DEPRECATED
- //! ----------
-
- static ref array<Object> SPREAD_AGENTS_OBJECTS = new array<Object>;
- static ref array<CargoBase> SPREAD_AGENTS_PROXY_CARGOS = new array<CargoBase>;
-
- private int m_FaceCoveredForShaveLayers = 0;
- int m_AntibioticsActive;
- void SwitchItemTypeAttach(EntityAI item, string slot)
- {
- if (!GetGame().IsServer())
- return;
- }
-
- void SwitchItemTypeDetach(EntityAI item, string slot);
- void AddToEnvironmentTemperature(float pTemperature);
- void IncreaseAntibioticsCount()
- {
- AddMedicalDrugsInUse(EMedicalDrugsType.ANTIBIOTICS);
- }
- void DecreaseAntibioticsCount()
- {
- RemoveMedicalDrugsInUse(EMedicalDrugsType.ANTIBIOTICS);
- }
- bool HasStaminaRemaining()
- {
- if (!GetStaminaHandler())
- return false;
-
- return GetStaminaHandler().GetStamina() > 0;
- }
- }
- #ifdef DEVELOPER
- PlayerBase _player;
- #endif
|