playerbase.c 251 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401
  1. class PlayerBase extends ManBase
  2. {
  3. const int SIMPLIFIED_SHOCK_CAP = 63;
  4. const int SHAKE_LEVEL_MAX = 7;
  5. private int m_LifeSpanState;
  6. private int m_LastShavedSeconds;
  7. private int m_BloodType;
  8. private bool m_HasBloodTypeVisible;
  9. private bool m_LiquidTendencyDrain; //client-side only - Obsolete
  10. private bool m_FlagRaisingTendency;
  11. private int m_HasBloodyHandsVisible;
  12. protected bool m_HasHeatBuffer;
  13. protected int m_HeatBufferStage;
  14. protected float m_HeatBufferDynamicMax;
  15. protected bool m_IsInColdArea;
  16. protected bool m_PlayerLoaded;
  17. protected bool m_PlayerDisconnectProcessed;
  18. protected bool m_ProcessUIWarning;
  19. protected int m_LocalRefreshAnimStateIdx;
  20. protected int m_RefreshAnimStateIdx;
  21. private int m_StoreLoadVersion;
  22. const int ACT_STORE_SAVE_VERSION = 4;
  23. protected int m_LifespanLevelLocal; //control variable for change calls
  24. protected int m_AnimCommandStarting; //signals the command that is about to start the next frame (e.g. Swim, Fall...)
  25. EUndergroundPresence m_UndergroundPresence;
  26. private PluginPlayerStatus m_ModulePlayerStatus;
  27. PluginConfigEmotesProfile m_ConfigEmotesProfile;
  28. private PluginLifespan m_ModuleLifespan;
  29. protected PluginPresenceNotifier m_PresenceNotifier;
  30. protected ref UndergroundHandlerClient m_UndergroundHandler;
  31. protected ref UndergroundBunkerHandlerClient m_UndergroundBunkerHandler;
  32. ref PlayerStats m_PlayerStats;
  33. PluginRecipesManager m_ModuleRecipesManager;
  34. ref BleedingSourcesManagerServer m_BleedingManagerServer;
  35. ref BleedingSourcesManagerRemote m_BleedingManagerRemote;
  36. ref ModifiersManager m_ModifiersManager;
  37. ref NotifiersManager m_NotifiersManager;
  38. ref protected ActionManagerBase m_ActionManager;
  39. ref PlayerAgentPool m_AgentPool;
  40. int m_Agents;
  41. ref Environment m_Environment;
  42. ref EmoteManager m_EmoteManager;
  43. ref SymptomManager m_SymptomManager;
  44. ref VirtualHud m_VirtualHud;
  45. ref StaminaHandler m_StaminaHandler;
  46. ref InjuryAnimationHandler m_InjuryHandler;
  47. ref ShockHandler m_ShockHandler; //New shock handler
  48. ref SoftSkillsManager m_SoftSkillsManager;
  49. ref StanceIndicator m_StanceIndicator;
  50. ref TransferValues m_TrasferValues;
  51. ref DebugMonitorValues m_DebugMonitorValues;
  52. const int OVERLOAD_LIMIT = 30000;
  53. float m_CargoLoad;
  54. float m_VisibilityCoef;
  55. float m_OriginalSlidePoseAngle;
  56. int m_SoundEvent;
  57. int m_SoundEventParam;
  58. int m_FliesIndex;
  59. bool m_SoundEventSent;
  60. ref Param2<float,float> m_UAProgressParam;
  61. ref Param2<int,int> m_UAParam;
  62. ref Param3<float,float,bool> m_StaminaParam;
  63. ref Param1<string> m_UAParamMessage;
  64. ref Param1<float> m_UnconParam;
  65. ref Param1<float> m_DeathDarkeningParam;
  66. ref DamageDealtEffect m_DamageDealtEffect;
  67. ref EffectRadial m_EffectRadial;
  68. ref FlashbangEffect m_FlashbangEffect;
  69. ref ShockDealtEffect m_ShockDealtEffect;
  70. ref EffectParticle m_FliesEff;
  71. ref TInputActionMap m_InputActionMap; // Backwards compatibility
  72. ref TInputActionMap m_InputActionMapControled;
  73. ref TInputActionMap m_InputActionMapAsTarget;
  74. bool m_ActionsInitialize;
  75. //ref CraftingMeta m_CraftingMeta;
  76. ref HiddenSelectionsData m_EmptyGloves;
  77. ref WeaponManager m_WeaponManager;
  78. ref CraftingManager m_CraftingManager;
  79. ref ArrowManagerPlayer m_ArrowManager;
  80. ref InventoryActionHandler m_InventoryActionHandler;
  81. ref protected QuickBarBase m_QuickBarBase;
  82. ref PlayerSoundManagerServer m_PlayerSoundManagerServer;
  83. ref PlayerSoundManagerClient m_PlayerSoundManagerClient;
  84. ref HeatComfortAnimHandler m_HCAnimHandler;
  85. ref EffectSound m_SoundFliesEffect;
  86. bool m_QuickBarHold;
  87. bool m_QuickBarFT = false;
  88. Hud m_Hud;
  89. protected int m_RecipePick;
  90. protected bool m_IsHoldingBreath;
  91. protected bool m_IsInWater;
  92. float m_LastPostFrameTickTime;
  93. //AbstractWave m_SaySoundWave;
  94. ref Timer m_DeathCheckTimer;
  95. bool m_CorpseProcessing;
  96. int m_CorpseState;
  97. protected int m_CorpseStateLocal;
  98. protected bool m_IsHeadingRestricted;
  99. protected ref HeadingRestrictData m_HeadingRestrictData;
  100. int m_PersistentFlags;
  101. int m_StaminaState;
  102. float m_UnconsciousTime;
  103. int m_ShockSimplified;
  104. float m_CurrentShock; //Used to synchronize shock between server and client
  105. bool m_IsRestrained;
  106. bool m_IsRestrainedLocal;
  107. bool m_IsRestrainStarted;
  108. bool m_IsRestrainStartedLocal;
  109. bool m_IsRestrainPrelocked;
  110. bool m_ImmunityBoosted;
  111. bool m_AreHandsLocked; //Currently only used to block quickbar usage after canceling placement
  112. float m_UnconsciousVignetteTarget = 2;
  113. float m_CameraSwayModifier = 0.2;
  114. float m_LastShockHitTime;
  115. DayZPlayerCameraBase m_CurrentCamera;
  116. int m_BleedingBits;
  117. vector m_DirectionToCursor;
  118. vector m_DefaultHitPosition;
  119. int m_DiseaseCount;
  120. int m_HealingsCount;
  121. protected bool m_AllowQuickRestrain;
  122. protected bool m_AllowQuickFishing;
  123. protected int m_Shakes;
  124. protected int m_ShakesForced;
  125. int m_BreathVapour;
  126. int m_HealthLevel;
  127. int m_MixedSoundStates;
  128. int m_QuickBarBonus = 0;
  129. bool m_IsVehicleSeatDriver;
  130. float m_UnconsciousEndTime = 0;
  131. int m_BleedingSourceCount;
  132. Head_Default m_CharactersHead;
  133. EPulseType m_PulseType;
  134. PlayerBase m_CheckPulseLastTarget;
  135. int m_ForceInjuryAnimMask;
  136. bool m_HideHairAnimated;
  137. string m_DecayedTexture;
  138. protected ref array<EntityAI> m_ItemsToDelete;
  139. 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
  140. int m_LocalBrokenState = eBrokenLegs.NO_BROKEN_LEGS;
  141. bool m_BrokenLegsJunctureReceived;
  142. ref EffectSound m_BrokenLegSound;
  143. const string SOUND_BREAK_LEG = "broken_leg_SoundSet";
  144. bool m_CanPlayBrokenLegSound; //Used to check if sound has already been played
  145. static bool DEBUG_INVENTORY_ACCESS = false;
  146. static ref array<string> m_BleedingSourcesLow; //Stores all LOWER body part bleeding sources
  147. static ref array<string> m_BleedingSourcesUp; //Stores all UPPER body part bleeding sources EXCLUDING HEAD
  148. float m_UnconRefillModifier = 1;
  149. ref protected RandomGeneratorSyncManager m_RGSManager;
  150. // CONTAMINATED AREA RELATED
  151. bool m_ContaminatedAreaEffectEnabled;
  152. const string CONTAMINATED_AREA_AMBIENT = "ContaminatedArea_SoundSet";//obsolete, use EffectTrigger::GetAmbientSoundsetName() instead
  153. EffectSound m_AmbientContamination;
  154. protected int m_ContaminatedAreaCount;
  155. protected int m_EffectAreaCount;
  156. protected bool m_InsideEffectArea;
  157. protected bool m_InsideEffectAreaPrev;
  158. protected EffectTrigger m_CurrentEffectTrigger;
  159. // effect areas
  160. protected EEffectAreaType m_InEffectAreaType; // flags for identifying which area the player is in, synchronized by EffectTriggers
  161. protected ref map<EEffectAreaType, int> m_EffectAreaOverlap = new map<EEffectAreaType, int>(); // type -> how many of such areas is player currently in
  162. protected ref map<EEffectAreaType, float> m_EffectAreaTimeToTick = new map<EEffectAreaType, float>(); // type -> how long has player spent in an area since last effect tick
  163. static ref array<Man> m_ServerPlayers = new array<Man>;
  164. protected bool m_CanDisplayHitEffectPPE;
  165. protected string m_CachedPlayerName;//cached from player identity
  166. protected string m_CachedPlayerID;//cached from player identity
  167. #ifdef DIAG_DEVELOPER
  168. int m_IsInsideTrigger;
  169. bool m_CanBeTargetedDebug; //server-side only
  170. ref array<EntityAI> m_PresetItems = new array<EntityAI>;
  171. bool m_PresetSpawned;
  172. ref CameraToolsMenuClient m_CameraToolsMenuClient;
  173. protected PluginTargetTemperature m_TargetTemperatureDiag;
  174. #endif
  175. #ifdef DEVELOPER
  176. Transport m_GetInVehicleTransportDebug;
  177. #endif
  178. #ifdef DIAG_DEVELOPER
  179. ref Bot m_Bot;
  180. #endif
  181. //Temp QuickBar load
  182. ref array<ref Param2<EntityAI,int> > m_aQuickBarLoad;
  183. //hologram
  184. ref Hologram m_HologramServer;
  185. ref Hologram m_HologramLocal;
  186. vector m_LocalProjectionPosition = "0 0 0 ";
  187. vector m_LocalProjectionOrientation = "0 0 0 ";
  188. //Sheduler
  189. float m_LastTick = -1;
  190. int m_AddModifier = -1;
  191. //crafting start
  192. int m_RecipeID = -1;
  193. EntityAI m_Item1;
  194. EntityAI m_Item2;
  195. bool m_IsCraftingReady;
  196. float m_RecipeAnimLength;
  197. vector m_CraftingInitialPos;
  198. ref array<int> m_Recipes;
  199. //crafting end
  200. ref SoundParams m_SaySoundParams;
  201. ref SoundObjectBuilder m_SaySoundBuilder;
  202. ref SoundObject m_SaySoundObject;
  203. string m_SaySoundLastSetName;
  204. //input control
  205. bool m_ActionQBControl;
  206. //Action data for base building actions
  207. ref ConstructionActionData m_ConstructionActionData;
  208. //Action data for fireplace (indoor)
  209. vector m_LastFirePoint;
  210. float m_LastFirePointRot;
  211. int m_LastFirePointIndex;
  212. bool ItemToInventory;
  213. bool m_IsFighting = false;
  214. bool m_IsDrowning;//Set only via the setter SetDrowning
  215. // debug monitor
  216. int m_DebugMonitorEnabled;
  217. //map
  218. ActionUnfoldMapCB m_hac;
  219. bool m_MapOpen;
  220. bool m_MapCloseRequestProcessed; //DEPRECATED
  221. protected bool m_MapClosingSyncSent;
  222. protected float m_LastMapScale = -1.0;
  223. protected vector m_LastMapPos;
  224. protected ref MapNavigationBehaviour m_MapNavigationBehaviour;
  225. //inventory soft locking
  226. protected bool m_InventorySoftLocked; //obsolete, count should be checked instead. Left in here for legacy's sake.
  227. protected int m_InventorySoftLockCount = 0;
  228. static ref TStringArray m_QBarItems;
  229. //Analytics
  230. string m_DatabaseID;
  231. ref Timer m_AnalyticsTimer;
  232. //! melee stats
  233. protected bool m_MeleeDebug;
  234. //protected bool m_CheckMeleeItem;
  235. protected ItemBase m_CheckMeleeItem;
  236. //! user actions & symptoms
  237. protected string m_UALastMessage;
  238. protected ref Timer m_UALastMessageTimer;
  239. protected int m_PerformedAnimActionID = -1; // animated action being performed, -1 if none
  240. protected int m_ActivePrimarySymptomID = 0; // active primary symptom, 0 if none, symptom has to be overriden to allow sync
  241. bool m_WorkingNVGHeadset; //Deprecated
  242. bool m_LoweredNVGHeadset;
  243. protected ref array<int> m_ActiveNVTypes;
  244. //bool m_PreviousNVGState;
  245. int m_SyncedModifiers;
  246. int m_SyncedModifiersPrev;
  247. PluginAdminLog m_AdminLog;
  248. ref PlayerStomach m_PlayerStomach;
  249. protected static Particle m_ContaminatedAroundPlayer;
  250. protected static Particle m_ContaminatedAroundPlayerTiny;
  251. protected PlayerStat<float> m_StatWater;
  252. protected PlayerStat<float> m_StatToxicity;
  253. protected PlayerStat<float> m_StatEnergy;
  254. protected PlayerStat<float> m_StatHeatComfort;
  255. protected PlayerStat<float> m_StatTremor;
  256. protected PlayerStat<int> m_StatWet
  257. protected PlayerStat<int> m_StatBloodType
  258. protected PlayerStat<float> m_StatDiet
  259. protected PlayerStat<float> m_StatStamina
  260. protected PlayerStat<float> m_StatSpecialty
  261. protected PlayerStat<float> m_StatHeatBuffer
  262. //!effect widgets
  263. protected GameplayEffectWidgets_base m_EffectWidgets;
  264. protected ref array<int> m_ProcessAddEffectWidgets;
  265. protected ref array<int> m_ProcessRemoveEffectWidgets;
  266. //postprocess processing
  267. protected ref array<int> m_ProcessAddGlassesEffects;
  268. protected ref array<int> m_ProcessRemoveGlassesEffects;
  269. protected EMedicalDrugsType m_MedicalDrugsActive;
  270. //! invokers
  271. protected ref ScriptInvoker m_OnUnconsciousStart;
  272. protected ref ScriptInvoker m_OnUnconsciousStop;
  273. private ref map<eAgents, float> m_BloodyHandsPenaltyChancePerAgent;
  274. void PlayerBase()
  275. {
  276. Init();
  277. }
  278. void Init()
  279. {
  280. SetEventMask(EntityEvent.INIT|EntityEvent.POSTFRAME|EntityEvent.FRAME);
  281. m_StoreLoadVersion = 0;
  282. m_IsCraftingReady = false;
  283. m_Recipes = new array<int>;
  284. m_LastShavedSeconds = 0;
  285. m_BloodType = 0;
  286. m_HasBloodTypeVisible = false;
  287. m_LifeSpanState = 0;
  288. m_LifespanLevelLocal = -1;
  289. m_CorpseState = 0;
  290. m_CorpseStateLocal = 0;
  291. m_HasBloodyHandsVisible = 0;
  292. m_PlayerLoaded = false;
  293. m_PlayerSelected = false;
  294. m_ProcessUIWarning = false;
  295. m_FlagRaisingTendency = true;
  296. m_LiquidTendencyDrain = false;
  297. m_UAParamMessage = new Param1<string>("");
  298. m_UnconParam = new Param1<float>(0);
  299. m_DeathDarkeningParam = new Param1<float>(0);
  300. m_UAParam = new Param2<int,int>(0,0);
  301. m_UAProgressParam = new Param2<float,float>(0,0);
  302. m_QuickBarBase = new QuickBarBase(this);
  303. m_QuickBarBonus = Math.Max(ConfigGetInt("quickBarBonus"), 0);
  304. m_CargoLoad = 0;
  305. m_VisibilityCoef = 1.0;
  306. m_Hud = GetGame().GetMission().GetHud();
  307. m_RecipePick = 0;
  308. m_ActionQBControl = false;
  309. m_QuickBarHold = false;
  310. m_HideHairAnimated = true;
  311. m_WorkingNVGHeadset = false;
  312. m_LoweredNVGHeadset = false;
  313. m_AreHandsLocked = false;
  314. m_ItemsToDelete = new array<EntityAI>;
  315. m_AnimCommandStarting = HumanMoveCommandID.None;
  316. m_EmptyGloves = new HiddenSelectionsData(ConfigGetString("emptyGloves"));
  317. m_CanDisplayHitEffectPPE = true;
  318. m_HeadingRestrictData = new HeadingRestrictData();
  319. #ifdef DIAG_DEVELOPER
  320. m_CanBeTargetedDebug = true;
  321. //RegisterNetSyncVariableBool("m_CanBeTargetedDebug");
  322. #endif
  323. m_AnalyticsTimer = new Timer(CALL_CATEGORY_SYSTEM);
  324. m_StaminaHandler = new StaminaHandler(this);//current stamina calculation
  325. m_InjuryHandler = new InjuryAnimationHandler(this);
  326. m_ShockHandler = new ShockHandler(this); //New shock handler
  327. m_HCAnimHandler = new HeatComfortAnimHandler(this);
  328. m_PlayerStats = new PlayerStats(this);//player stats
  329. m_ArrowManager = new ArrowManagerPlayer(this);
  330. if (GetGame().IsServer())
  331. {
  332. m_PlayerStomach = new PlayerStomach(this);
  333. m_NotifiersManager = new NotifiersManager(this); // player notifiers
  334. m_AgentPool = new PlayerAgentPool(this); // agent pool manager
  335. m_BleedingManagerServer = new BleedingSourcesManagerServer(this);
  336. m_Environment = new Environment(this);//environment effects on player
  337. m_ModifiersManager = new ModifiersManager(this); // player modifiers
  338. m_PlayerSoundManagerServer = new PlayerSoundManagerServer(this);
  339. m_VirtualHud = new VirtualHud(this);
  340. m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
  341. }
  342. m_SymptomManager = new SymptomManager(this); // state manager
  343. m_ModuleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
  344. m_TrasferValues = new TransferValues(this);
  345. m_EmoteManager = new EmoteManager(this);
  346. m_SoftSkillsManager = new SoftSkillsManager(this);//Soft Skills calculation
  347. m_WeaponManager = new WeaponManager(this);
  348. m_DebugMonitorValues = new DebugMonitorValues(this);
  349. m_RGSManager = new RandomGeneratorSyncManager(this);
  350. if (!GetGame().IsDedicatedServer())
  351. {
  352. m_MeleeDebug = false;
  353. m_UALastMessage = "";
  354. m_UALastMessageTimer = new Timer;
  355. m_InventoryActionHandler = new InventoryActionHandler(this);
  356. m_BleedingManagerRemote = new BleedingSourcesManagerRemote(this);
  357. m_PlayerSoundManagerClient = new PlayerSoundManagerClient(this);
  358. m_StanceIndicator = new StanceIndicator(this);
  359. m_ActionsInitialize = false;
  360. ClientData.AddPlayerBase(this);
  361. m_ProcessAddEffectWidgets = new array<int>;
  362. m_ProcessRemoveEffectWidgets = new array<int>;
  363. m_ActiveNVTypes = new array<int>;
  364. m_ProcessAddGlassesEffects = new array<int>;
  365. m_ProcessRemoveGlassesEffects = new array<int>;
  366. }
  367. m_ActionManager = NULL;
  368. m_ConfigEmotesProfile = PluginConfigEmotesProfile.Cast(GetPlugin(PluginConfigEmotesProfile));
  369. if (GetDayZGame().IsDebug())
  370. {
  371. PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed = PluginConfigDebugProfileFixed.Cast(GetPlugin(PluginConfigDebugProfileFixed));
  372. PluginConfigDebugProfile m_ConfigDebugProfile = PluginConfigDebugProfile.Cast(GetPlugin(PluginConfigDebugProfile));
  373. PluginDeveloper m_Developer = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
  374. PlayerBase player = this;
  375. if (m_ConfigDebugProfile)
  376. {
  377. string default_preset = m_ConfigDebugProfile.GetDefaultPreset();
  378. if (player && default_preset != "")
  379. {
  380. TStringArray preset_array = new TStringArray;
  381. m_ConfigDebugProfileFixed.GetPresetItems(default_preset, preset_array);
  382. bool is_preset_fixed = true;
  383. if (preset_array.Count() == 0)
  384. {
  385. m_ConfigDebugProfile.GetPresetItems(default_preset, preset_array);
  386. is_preset_fixed = false;
  387. }
  388. if (preset_array.Count() > 0)
  389. {
  390. m_Developer.ClearInventory(player);
  391. for (int i = 0; i < preset_array.Count(); i++)
  392. {
  393. float health = -1;
  394. int quantity = -1;
  395. if (is_preset_fixed)
  396. {
  397. health = m_ConfigDebugProfileFixed.GetItemHealth(default_preset, i);
  398. quantity = m_ConfigDebugProfileFixed.GetItemQuantity(default_preset, i);
  399. }
  400. else
  401. {
  402. health = m_ConfigDebugProfile.GetItemHealth(default_preset, i);
  403. quantity = m_ConfigDebugProfile.GetItemQuantity(default_preset, i);
  404. }
  405. m_Developer.SpawnEntityInPlayerInventory(player, preset_array.Get(i), health, quantity);
  406. }
  407. }
  408. }
  409. }
  410. }
  411. m_MedicalDrugsActive = EMedicalDrugsType.NONE;
  412. m_MapNavigationBehaviour = new MapNavigationBehaviour(this);
  413. m_ModulePlayerStatus = PluginPlayerStatus.Cast(GetPlugin(PluginPlayerStatus));
  414. m_ModuleLifespan = PluginLifespan.Cast(GetPlugin(PluginLifespan));
  415. m_BleedingSourcesLow = new array<string>;
  416. m_BleedingSourcesLow.Insert("RightToeBase");
  417. m_BleedingSourcesLow.Insert("RightFoot");
  418. m_BleedingSourcesLow.Insert("LeftToeBase");
  419. m_BleedingSourcesLow.Insert("LeftFoot");
  420. m_BleedingSourcesLow.Insert("RightUpLegRoll");
  421. m_BleedingSourcesLow.Insert("RightUpLeg");
  422. m_BleedingSourcesLow.Insert("RightLegRoll");
  423. m_BleedingSourcesLow.Insert("RightLeg");
  424. m_BleedingSourcesLow.Insert("LeftUpLegRoll");
  425. m_BleedingSourcesLow.Insert("LeftUpLeg");
  426. m_BleedingSourcesLow.Insert("LeftLegRoll");
  427. m_BleedingSourcesLow.Insert("LeftLeg");
  428. m_BleedingSourcesUp = new array<string>;
  429. m_BleedingSourcesUp.Insert("RightForeArmRoll");
  430. m_BleedingSourcesUp.Insert("LeftForeArmRoll");
  431. m_BleedingSourcesUp.Insert("RightForeArm");
  432. m_BleedingSourcesUp.Insert("RightArmRoll");
  433. m_BleedingSourcesUp.Insert("RightArm");
  434. m_BleedingSourcesUp.Insert("RightShoulder");
  435. m_BleedingSourcesUp.Insert("LeftForeArm");
  436. m_BleedingSourcesUp.Insert("LeftArmRoll");
  437. m_BleedingSourcesUp.Insert("LeftArm");
  438. m_BleedingSourcesUp.Insert("LeftShoulder");
  439. m_BleedingSourcesUp.Insert("Spine3");
  440. m_BleedingSourcesUp.Insert("Spine2");
  441. m_BleedingSourcesUp.Insert("Spine1");
  442. m_BleedingSourcesUp.Insert("Spine");
  443. m_BleedingSourcesUp.Insert("Pelvis");
  444. m_BleedingSourcesUp.Insert("Neck");
  445. RegisterNetSyncVariableInt("m_PersistentFlags", 0, 1<<(EnumTools.GetEnumSize(PersistentFlag) + 1));
  446. RegisterNetSyncVariableInt("m_LifeSpanState", LifeSpanState.BEARD_NONE, LifeSpanState.COUNT);
  447. RegisterNetSyncVariableInt("m_BloodType", 0, 128);
  448. RegisterNetSyncVariableInt("m_ShockSimplified",0, SIMPLIFIED_SHOCK_CAP);
  449. RegisterNetSyncVariableInt("m_SoundEvent",0, EPlayerSoundEventID.ENUM_COUNT - 1);
  450. RegisterNetSyncVariableInt("m_SoundEventParam", 0, ((EPlayerSoundEventParam.ENUM_COUNT - 1) * 2) - 1);
  451. RegisterNetSyncVariableInt("m_StaminaState",0, eStaminaState.COUNT - 1);
  452. RegisterNetSyncVariableInt("m_BleedingBits");
  453. RegisterNetSyncVariableInt("m_Shakes", 0, SHAKE_LEVEL_MAX);
  454. RegisterNetSyncVariableInt("m_BreathVapour", 0, BREATH_VAPOUR_LEVEL_MAX);
  455. RegisterNetSyncVariableInt("m_HealthLevel", eInjuryHandlerLevels.PRISTINE, eInjuryHandlerLevels.RUINED);
  456. RegisterNetSyncVariableInt("m_MixedSoundStates", 0, eMixedSoundStates.COUNT - 1);
  457. RegisterNetSyncVariableInt("m_CorpseState",-PlayerConstants.CORPSE_STATE_DECAYED,PlayerConstants.CORPSE_STATE_DECAYED);//do note the negative min, negative sign denotes a special meaning
  458. RegisterNetSyncVariableInt("m_RefreshAnimStateIdx",0,3);
  459. RegisterNetSyncVariableInt("m_BrokenLegState", -eBrokenLegs.BROKEN_LEGS_SPLINT, eBrokenLegs.BROKEN_LEGS_SPLINT);
  460. RegisterNetSyncVariableInt("m_SyncedModifiers", 0, ((eModifierSyncIDs.LAST_INDEX - 1) * 2) - 1);
  461. RegisterNetSyncVariableInt("m_HasBloodyHandsVisible", 0, eBloodyHandsTypes.LAST_INDEX - 1);
  462. RegisterNetSyncVariableInt("m_ActionSoundCategoryHash");
  463. RegisterNetSyncVariableInt("m_PerformedAnimActionID", -1, 2048); // generous upper limit for modding reasons
  464. RegisterNetSyncVariableInt("m_ActivePrimarySymptomID", 0, SymptomIDs.LAST_INDEX);
  465. RegisterNetSyncVariableInt("m_HeatBufferStage", 0, HeatBufferMdfr.NUMBER_OF_STAGES - 1);
  466. RegisterNetSyncVariableFloat("m_HeatBufferDynamicMax", 0.0, 1.0, 2);
  467. RegisterNetSyncVariableBool("m_IsUnconscious");
  468. RegisterNetSyncVariableBool("m_IsRestrained");
  469. RegisterNetSyncVariableBool("m_IsInWater");
  470. RegisterNetSyncVariableBool("m_InsideEffectArea");
  471. RegisterNetSyncVariableBool("m_HasBloodTypeVisible");
  472. RegisterNetSyncVariableBool("m_IsRestrainStarted");
  473. RegisterNetSyncVariableBool("m_IsRestrainPrelocked");
  474. RegisterNetSyncVariableBool("m_HasHeatBuffer");
  475. RegisterNetSyncVariableBool("m_IsInColdArea");
  476. RegisterNetSyncVariableFloat("m_CurrentShock"); //Register shock synchronized variable
  477. m_OriginalSlidePoseAngle = GetSlidePoseAngle();
  478. //! sets default hit position and cache it here (mainly for impact particles)
  479. m_DefaultHitPosition = SetDefaultHitPosition(GetDayZPlayerType().GetDefaultHitPositionComponent());
  480. m_DecayedTexture = ConfigGetString("decayedTexture");
  481. m_FliesIndex = -1;
  482. m_BloodyHandsPenaltyChancePerAgent = new map<eAgents, float>();
  483. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(this.OnPlayerLoaded);
  484. }
  485. ScriptInvoker GetOnUnconsciousStart()
  486. {
  487. if (!m_OnUnconsciousStart)
  488. m_OnUnconsciousStart = new ScriptInvoker();
  489. return m_OnUnconsciousStart;
  490. }
  491. ScriptInvoker GetOnUnconsciousStop()
  492. {
  493. if (!m_OnUnconsciousStop)
  494. m_OnUnconsciousStop = new ScriptInvoker();
  495. return m_OnUnconsciousStop;
  496. }
  497. void AddMedicalDrugsInUse(EMedicalDrugsType drugType)
  498. {
  499. if ((m_MedicalDrugsActive & drugType) != drugType)
  500. m_MedicalDrugsActive = m_MedicalDrugsActive | drugType;
  501. }
  502. void RemoveMedicalDrugsInUse(EMedicalDrugsType drugType)
  503. {
  504. if ((m_MedicalDrugsActive & drugType) == drugType)
  505. m_MedicalDrugsActive &= ~drugType;
  506. }
  507. bool IsChelationActive()
  508. {
  509. return (m_MedicalDrugsActive & EMedicalDrugsType.CHELATION) == EMedicalDrugsType.CHELATION;
  510. }
  511. bool IsAntibioticsActive()
  512. {
  513. return (m_MedicalDrugsActive & EMedicalDrugsType.ANTIBIOTICS) == EMedicalDrugsType.ANTIBIOTICS;
  514. }
  515. void SetSoundCategoryHash(int hash)
  516. {
  517. m_ActionSoundCategoryHash = hash;
  518. SetSynchDirty();
  519. }
  520. void SetPerformedActionID(int id)
  521. {
  522. m_PerformedAnimActionID = id;
  523. SetSynchDirty();
  524. }
  525. int GetPerformedActionID()
  526. {
  527. return m_PerformedAnimActionID;
  528. }
  529. void SetActivePrimarySymptomID(SymptomIDs id)
  530. {
  531. m_ActivePrimarySymptomID = id;
  532. SetSynchDirty();
  533. }
  534. SymptomIDs GetActivePrimarySymptomID()
  535. {
  536. return m_ActivePrimarySymptomID;
  537. }
  538. 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)
  539. {
  540. //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)
  541. if (!m_InsideEffectArea)
  542. return;
  543. bool allow = false;
  544. if (!m_CurrentEffectTrigger)
  545. {
  546. allow = true;
  547. }
  548. else if (trigger == m_CurrentEffectTrigger && forceUpdate)
  549. {
  550. allow = true;
  551. //Print("ON Enabling effect FORCED " + trigger);
  552. }
  553. else if (trigger.GetEffectsPriority() > m_CurrentEffectTrigger.GetEffectsPriority())
  554. {
  555. RemoveCurrentEffectTrigger();
  556. allow = true;
  557. }
  558. if (allow)
  559. {
  560. /*
  561. Print("--------------------------------------------------");
  562. Print("ON Enabling effect " + trigger);
  563. Print("------------> soundset " + soundset);
  564. Print("--------------------------------------------------");
  565. */
  566. m_CurrentEffectTrigger = trigger;
  567. SetContaminatedEffectEx( true, ppeIdx, aroundId, tinyId, soundset,partDynaUpdate, newBirthRate );
  568. }
  569. }
  570. void RemoveCurrentEffectTrigger()
  571. {
  572. if (m_CurrentEffectTrigger)
  573. {
  574. /*
  575. Print("--------------------------------------------------");
  576. Print("OFF Disabling effect");
  577. Print("--------------------------------------------------");
  578. */
  579. SetContaminatedEffectEx( false, m_CurrentEffectTrigger.m_PPERequester );
  580. m_CurrentEffectTrigger = null;
  581. }
  582. }
  583. void IncreaseContaminatedAreaCount()
  584. {
  585. if (m_ContaminatedAreaCount == 0)
  586. OnContaminatedAreaEnterServer();
  587. m_ContaminatedAreaCount++;
  588. }
  589. void DecreaseContaminatedAreaCount()
  590. {
  591. m_ContaminatedAreaCount--;
  592. if (m_ContaminatedAreaCount <= 0)
  593. {
  594. m_ContaminatedAreaCount = 0;
  595. OnContaminatedAreaExitServer();
  596. }
  597. }
  598. void IncreaseEffectAreaCount()
  599. {
  600. if (m_EffectAreaCount == 0)
  601. {
  602. m_InsideEffectArea = true;
  603. SetSynchDirty();
  604. OnPlayerIsNowInsideEffectAreaBeginServer();
  605. }
  606. m_EffectAreaCount++;
  607. }
  608. void DecreaseEffectAreaCount()
  609. {
  610. m_EffectAreaCount--;
  611. if (m_EffectAreaCount <= 0)
  612. {
  613. m_EffectAreaCount = 0;
  614. m_InsideEffectArea = false;
  615. SetSynchDirty();
  616. OnPlayerIsNowInsideEffectAreaEndServer();
  617. }
  618. }
  619. void SetInEffectAreaTypeFlag(EEffectAreaType flag)
  620. {
  621. int areaCount = m_EffectAreaOverlap.Get(flag);
  622. if (areaCount > 0)
  623. m_EffectAreaOverlap.Set(flag, m_EffectAreaOverlap.Get(flag) + 1);
  624. else
  625. m_EffectAreaOverlap.Set(flag, 1);
  626. m_InEffectAreaType |= flag;
  627. }
  628. void UnsetInEffectAreaTypeFlag(EEffectAreaType flag)
  629. {
  630. int areaCount = m_EffectAreaOverlap.Get(flag);
  631. if (areaCount > 1)
  632. m_EffectAreaOverlap.Set(flag, m_EffectAreaOverlap.Get(flag) - 1);
  633. else
  634. {
  635. m_EffectAreaOverlap.Set(flag, 0);
  636. m_InEffectAreaType &= ~flag;
  637. }
  638. }
  639. bool IsInEffectArea(EEffectAreaType area)
  640. {
  641. if (m_InEffectAreaType & area)
  642. return true;
  643. return false;
  644. }
  645. // Server side update when player is present in any effect area
  646. protected void OnUpdateEffectAreaServer(float timeSlice)
  647. {
  648. float timeSpent;
  649. if (IsInEffectArea(EEffectAreaType.HOT_SPRING))
  650. {
  651. float waterLevel = GetCurrentWaterLevel();
  652. if (waterLevel > 0.5)
  653. {
  654. timeSpent = m_EffectAreaTimeToTick.Get(EEffectAreaType.HOT_SPRING);
  655. timeSpent += timeSlice;
  656. if (timeSpent > HotSpringTrigger.HEAT_DAMAGE_TICK_TIME)
  657. {
  658. m_EffectAreaTimeToTick.Set(EEffectAreaType.HOT_SPRING, 0);
  659. HotSpringTrigger.ApplyEffects(this);
  660. }
  661. else
  662. m_EffectAreaTimeToTick.Set(EEffectAreaType.HOT_SPRING, timeSpent);
  663. }
  664. }
  665. if (IsInEffectArea(EEffectAreaType.VOLCANIC))
  666. {
  667. timeSpent = m_EffectAreaTimeToTick.Get(EEffectAreaType.VOLCANIC);
  668. timeSpent += timeSlice;
  669. if (timeSpent > VolcanicTrigger.HEAT_DAMAGE_TICK_TIME)
  670. {
  671. m_EffectAreaTimeToTick.Set(EEffectAreaType.VOLCANIC, 0);
  672. VolcanicTrigger.ApplyEffects(this);
  673. }
  674. else
  675. m_EffectAreaTimeToTick.Set(EEffectAreaType.VOLCANIC, timeSpent);
  676. }
  677. }
  678. protected void OnContaminatedAreaEnterServer()
  679. {
  680. GetModifiersManager().ActivateModifier( eModifiers.MDF_AREAEXPOSURE );
  681. //Print("Contaminated ENTERED <------------------------------------------------------------- FINAL");
  682. }
  683. protected void OnContaminatedAreaExitServer()
  684. {
  685. GetModifiersManager().DeactivateModifier( eModifiers.MDF_AREAEXPOSURE );
  686. //Print("Contaminated LEFT <------------------------------------------------------------- FINAL");
  687. }
  688. protected void OnPlayerIsNowInsideEffectAreaBeginServer()
  689. {
  690. //Print("ANY EFFECT AREA ENTERED <------------------------------------------------------------- FINAL");
  691. }
  692. protected void OnPlayerIsNowInsideEffectAreaEndServer()
  693. {
  694. //Print("ANY EFFECT AREA LEFT <------------------------------------------------------------- FINAL");
  695. }
  696. protected void OnPlayerIsNowInsideEffectAreaBeginClient()
  697. {
  698. //Print("ANY EFFECT AREA ENTERED CLIENT <------------------------------------------------------------- FINAL");
  699. }
  700. protected void OnPlayerIsNowInsideEffectAreaEndClient()
  701. {
  702. RemoveCurrentEffectTrigger();
  703. //Print("ANY EFFECT AREA LEFT CLIENT <------------------------------------------------------------- FINAL");
  704. }
  705. //! 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.
  706. ItemBase GetItemOnSlot(string slot_type)
  707. {
  708. int slot_id = InventorySlots.GetSlotIdFromString(slot_type);
  709. EntityAI item_EAI = this.GetInventory().FindAttachment(slot_id);
  710. ItemBase item_IB = ItemBase.Cast(item_EAI);
  711. if (item_EAI && !item_IB)
  712. {
  713. 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() + "!";
  714. Error(str);
  715. return null;
  716. }
  717. return item_IB;
  718. }
  719. //! Returns item on player's head. For an example, a headtorch.
  720. ItemBase GetItemOnHead()
  721. {
  722. return GetItemOnSlot("Headgear");
  723. }
  724. override int GetQuickBarBonus()
  725. {
  726. return m_QuickBarBonus;
  727. }
  728. //--------------------------------------------------------------------------
  729. // Inventory overrides
  730. //--------------------------------------------------------------------------
  731. override bool CanDropEntity (notnull EntityAI item)
  732. {
  733. if (GetInventory().HasInventoryReservation(item, null))
  734. {
  735. return false;
  736. }
  737. if (IsRestrained())
  738. {
  739. if (GetHumanInventory().GetEntityInHands() == item)
  740. return false;
  741. }
  742. return true;
  743. }
  744. //--------------------------------------------------------------------------
  745. // PLAYER DAMAGE EVENT HANDLING
  746. //--------------------------------------------------------------------------
  747. int GetBreathVapourLevel()
  748. {
  749. return m_BreathVapour;
  750. }
  751. // adds state to and syncs sound states variable which is used to generate sound client-side
  752. void UnsetMixedSoundState(eMixedSoundStates state)
  753. {
  754. int bit_mask_remove = ~state;
  755. eMixedSoundStates new_states = m_MixedSoundStates & bit_mask_remove;
  756. if (new_states != m_MixedSoundStates)
  757. {
  758. m_MixedSoundStates = new_states;
  759. SetSynchDirty();
  760. }
  761. }
  762. // adds state to and syncs sound states variable which is used to generate sound client-side
  763. void SetMixedSoundState(eMixedSoundStates state)
  764. {
  765. eMixedSoundStates new_states = m_MixedSoundStates | state;
  766. if (new_states != m_MixedSoundStates)
  767. {
  768. m_MixedSoundStates = new_states;
  769. SetSynchDirty();
  770. }
  771. }
  772. override bool IsPlayer()
  773. {
  774. return true;
  775. }
  776. bool IsBleeding()
  777. {
  778. return (m_BleedingBits != 0);
  779. }
  780. void SetBleedingBits(int bits)
  781. {
  782. if (m_BleedingBits != bits)
  783. {
  784. if (m_BleedingBits == 0)
  785. {
  786. OnBleedingBegin();
  787. }
  788. else if (bits == 0)
  789. {
  790. OnBleedingEnd();
  791. }
  792. }
  793. m_BleedingBits = bits;
  794. SetSynchDirty();
  795. }
  796. int GetBleedingBits()
  797. {
  798. return m_BleedingBits;
  799. }
  800. void IncreaseDiseaseCount()
  801. {
  802. m_DiseaseCount++;
  803. }
  804. void DecreaseDiseaseCount()
  805. {
  806. m_DiseaseCount--;
  807. }
  808. void IncreaseHealingsCount()
  809. {
  810. m_HealingsCount++;
  811. }
  812. void DecreaseHealingsCount()
  813. {
  814. m_HealingsCount--;
  815. }
  816. bool HasHealings()
  817. {
  818. return m_HealingsCount;//0 for no healings, 1+ for healings, gets truncated to 1
  819. }
  820. bool HasDisease()
  821. {
  822. return m_DiseaseCount;//0 for no disease, 1+ for disease, gets truncated to 1
  823. }
  824. EPulseType GetPulseType()
  825. {
  826. return m_PulseType;
  827. }
  828. void SetPulseType(EPulseType pulse_type)
  829. {
  830. m_PulseType = pulse_type;
  831. }
  832. void QueueAddEffectWidget(array<int> effects)
  833. {
  834. m_ProcessAddEffectWidgets.InsertArray(effects);
  835. }
  836. void QueueRemoveEffectWidget(array<int> effects)
  837. {
  838. m_ProcessRemoveEffectWidgets.InsertArray(effects);
  839. }
  840. void QueueAddGlassesEffect(int id)
  841. {
  842. m_ProcessAddGlassesEffects.Insert(id);
  843. }
  844. void QueueRemoveGlassesEffect(int id)
  845. {
  846. m_ProcessRemoveGlassesEffects.Insert(id);
  847. }
  848. DamageDealtEffect GetDamageDealtEffect()
  849. {
  850. return m_DamageDealtEffect;
  851. }
  852. override void SpawnDamageDealtEffect()
  853. {
  854. if (m_DamageDealtEffect)
  855. {
  856. delete m_DamageDealtEffect;
  857. }
  858. if (m_CanDisplayHitEffectPPE)
  859. {
  860. m_DamageDealtEffect = new DamageDealtEffect();
  861. }
  862. }
  863. void SpawnDamageDealtEffect2(Param param1 = null, Param param2 = null)
  864. {
  865. if (m_EffectRadial)
  866. {
  867. delete m_EffectRadial;
  868. }
  869. m_EffectRadial = new EffectRadial(param1,param2);
  870. }
  871. FlashbangEffect GetFlashbangEffect()
  872. {
  873. return m_FlashbangEffect;
  874. }
  875. void SpawnFlashbangEffect(PlayerBase player, bool visual)
  876. {
  877. if (m_FlashbangEffect)
  878. {
  879. m_FlashbangEffect.Stop();
  880. delete m_FlashbangEffect;
  881. }
  882. m_FlashbangEffect = new FlashbangEffect(player, visual);
  883. }
  884. ShockDealtEffect GetShockEffect()
  885. {
  886. return m_ShockDealtEffect;
  887. }
  888. void SpawnShockEffect(float intensity_max)
  889. {
  890. if (m_ShockDealtEffect)
  891. {
  892. delete m_ShockDealtEffect;
  893. }
  894. m_ShockDealtEffect = new ShockDealtEffect(intensity_max);
  895. }
  896. override void EEKilled(Object killer)
  897. {
  898. //Print(Object.GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " event EEKilled, player has died at STS=" + GetSimulationTimeStamp());
  899. if (m_AdminLog)
  900. {
  901. m_AdminLog.PlayerKilled(this, killer);
  902. }
  903. if (GetBleedingManagerServer())
  904. delete GetBleedingManagerServer();
  905. // kill character in database
  906. if (GetHive())
  907. {
  908. GetHive().CharacterKill(this);
  909. }
  910. // disable voice communication
  911. GetGame().EnableVoN(this, false);
  912. if (!GetGame().IsDedicatedServer())
  913. ClientData.RemovePlayerBase(this);
  914. GetSymptomManager().OnPlayerKilled();
  915. if (GetEconomyProfile() && !m_CorpseProcessing && m_CorpseState == 0 && GetGame().GetMission().InsertCorpse(this))
  916. {
  917. m_CorpseProcessing = true;
  918. //Print("EEKilled - processing corpse");
  919. }
  920. if (GetGame().IsMultiplayer() && GetGame().IsServer())
  921. {
  922. if (GetGame().GetMission())
  923. {
  924. GetGame().GetMission().SyncRespawnModeInfo(GetIdentity());
  925. }
  926. }
  927. super.EEKilled(killer);
  928. }
  929. override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
  930. {
  931. super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
  932. if (m_AdminLog)
  933. {
  934. m_AdminLog.PlayerHitBy(damageResult, damageType, this, source, component, dmgZone, ammo);
  935. }
  936. if (damageResult != null && damageResult.GetDamage(dmgZone, "Shock") > 0)
  937. {
  938. m_LastShockHitTime = GetGame().GetTime();
  939. if (!IsUnconscious())
  940. {
  941. if (GetGame().ConfigIsExisting("cfgAmmo " + ammo + " unconRefillModifier"))
  942. {
  943. m_UnconRefillModifier = GetGame().ConfigGetInt("cfgAmmo " + ammo + " unconRefillModifier");
  944. }
  945. else
  946. {
  947. m_UnconRefillModifier = 1;
  948. }
  949. }
  950. }
  951. //! DamageType.EXPLOSION & FlashGrenade
  952. if (damageType == DamageType.EXPLOSION && ammo == "FlashGrenade_Ammo")
  953. {
  954. GetStaminaHandler().DepleteStamina(EStaminaModifiers.OVERALL_DRAIN);
  955. }
  956. //new bleeding computation
  957. //---------------------------------------
  958. if (damageResult != null && GetBleedingManagerServer())
  959. {
  960. float dmg = damageResult.GetDamage(dmgZone, "Blood");
  961. GetBleedingManagerServer().ProcessHit(dmg, source, component, dmgZone, ammo, modelPos);
  962. }
  963. //---------------------------------------
  964. #ifdef DIAG_DEVELOPER
  965. if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
  966. Print("EEHitBy() | " + GetDisplayName() + " hit by " + source.GetDisplayName() + " to " + dmgZone);
  967. PluginRemotePlayerDebugServer plugin_remote_server = PluginRemotePlayerDebugServer.Cast(GetPlugin(PluginRemotePlayerDebugServer));
  968. if (plugin_remote_server)
  969. {
  970. plugin_remote_server.OnDamageEvent(this, damageResult);
  971. }
  972. #endif
  973. if (GetGame().IsDebugMonitor())
  974. m_DebugMonitorValues.SetLastDamage(source.GetDisplayName());
  975. if (m_ActionManager)
  976. m_ActionManager.Interrupt();
  977. int transferShockToDamageCoef = g_Game.ConfigGetInt(string.Format("%1 %2 DamageApplied transferShockToDamage", CFG_AMMO, ammo));
  978. if (transferShockToDamageCoef == 1)
  979. {
  980. //Print("PlayerBase | EEHitBy | nonlethal hit");
  981. AddHealth("", "Health", -ConvertNonlethalDamage(damageResult.GetDamage(dmgZone, "Shock"), damageType));
  982. if (dmgZone != "Head")
  983. AddHealth(dmgZone, "Health", -damageResult.GetDamage(dmgZone, "Shock")); //Also deal damage to zone health, no dmg reduction
  984. }
  985. if (GetGame().IsServer())
  986. {
  987. if (GetHealth("RightLeg", "Health") <= 1 || GetHealth("LeftLeg", "Health") <= 1 || GetHealth("RightFoot", "Health") <= 1 || GetHealth("LeftFoot", "Health") <= 1)
  988. {
  989. if (GetModifiersManager().IsModifierActive(eModifiers.MDF_BROKEN_LEGS))//effectively resets the modifier
  990. {
  991. GetModifiersManager().DeactivateModifier(eModifiers.MDF_BROKEN_LEGS);
  992. }
  993. GetModifiersManager().ActivateModifier(eModifiers.MDF_BROKEN_LEGS);
  994. }
  995. if (ammo == "Bullet_CupidsBolt" && IsAlive())
  996. {
  997. DamageSystem.ResetAllZones(this);
  998. m_ModifiersManager.ResetAll();
  999. m_ModifiersManager.ActivateModifier(eModifiers.MDF_IMMUNITYBOOST);
  1000. // bleeding sources
  1001. if (m_BleedingManagerServer)
  1002. m_BleedingManagerServer.RemoveAllSources();
  1003. // Stats
  1004. if (GetPlayerStats())
  1005. {
  1006. int bloodType = GetStatBloodType().Get();
  1007. float energyValue = GetStatEnergy().Get();
  1008. float waterValue = GetStatWater().Get();
  1009. float heatBuffer = GetStatHeatBuffer().Get();
  1010. float heatComfort = GetStatHeatComfort().Get();
  1011. GetPlayerStats().ResetAllStats();
  1012. GetStatBloodType().Set(bloodType);
  1013. GetStatWater().Set(waterValue);
  1014. GetStatEnergy().Set(energyValue);
  1015. GetStatHeatBuffer().Set(heatBuffer);
  1016. GetStatHeatComfort().Set(heatComfort);
  1017. }
  1018. // Agents
  1019. if (m_AgentPool)
  1020. m_AgentPool.RemoveAllAgents();
  1021. if (m_StaminaHandler)
  1022. m_StaminaHandler.SetStamina(GameConstants.STAMINA_MAX);
  1023. // uncon
  1024. if (IsUnconscious())
  1025. DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, false);
  1026. }
  1027. }
  1028. m_ShockHandler.CheckValue(true);
  1029. //analytics
  1030. GetGame().GetAnalyticsServer().OnEntityHit(source, this);
  1031. }
  1032. override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
  1033. {
  1034. super.EEHitByRemote(damageType, source, component, dmgZone, ammo, modelPos);
  1035. if (m_MeleeFightLogic.IsInBlock())
  1036. {
  1037. EffectSound sound = SEffectManager.PlaySoundOnObject("BlockingAttack_SoundSet", this);
  1038. sound.SetAutodestroy(true);
  1039. }
  1040. }
  1041. override void EEDelete(EntityAI parent)
  1042. {
  1043. SEffectManager.DestroyEffect(m_FliesEff);
  1044. StopSoundSet(m_SoundFliesEffect);
  1045. if (GetArrowManager())
  1046. GetArrowManager().ClearArrows();
  1047. }
  1048. override protected float ConvertNonlethalDamage(float damage, DamageType damageType)
  1049. {
  1050. if (damageType == DamageType.FIRE_ARM)
  1051. return damage * GameConstants.NL_DAMAGE_FIREARM_CONVERSION_PLAYERS;
  1052. return super.ConvertNonlethalDamage(damage, damageType);
  1053. }
  1054. /** Call only on client or single player PlayerBase
  1055. * (as GetGame().GetPlayer())
  1056. */
  1057. override void OnReceivedHit(ImpactEffectsData hitData)
  1058. {
  1059. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  1060. {
  1061. float shakeStrength = Math.InverseLerp(0, 500, hitData.m_InSpeed.Length());
  1062. GetCurrentCamera().SpawnCameraShake(shakeStrength);
  1063. OnPlayerRecievedHit();
  1064. }
  1065. if (hitData.m_AmmoType == "Bullet_CupidsBolt")
  1066. Ammo_CupidsBolt.PlayOnHitParticle(hitData.m_Position);
  1067. }
  1068. // DEPRECATED by method OnReceivedHit
  1069. override void OnPlayerRecievedHit()
  1070. {
  1071. #ifndef NO_GUI
  1072. if (m_MeleeFightLogic.IsInBlock())
  1073. {
  1074. EffectSound sound = SEffectManager.PlaySoundOnObject("BlockingAttack_SoundSet", this);
  1075. sound.SetAutodestroy(true);
  1076. return;
  1077. }
  1078. SpawnDamageDealtEffect();
  1079. CachedObjectsParams.PARAM2_FLOAT_FLOAT.param1 = 32;
  1080. CachedObjectsParams.PARAM2_FLOAT_FLOAT.param2 = 0.3;
  1081. SpawnDamageDealtEffect2(CachedObjectsParams.PARAM2_FLOAT_FLOAT);
  1082. CloseMapEx(true);
  1083. #endif
  1084. }
  1085. void OnPlayerReceiveFlashbangHitStart(bool visual)
  1086. {
  1087. SpawnFlashbangEffect(this, visual);
  1088. }
  1089. void OnPlayerReceiveFlashbangHitEnd() {}
  1090. //--------------------------------------------------------------------------
  1091. //! Melee helpers
  1092. //--------------------------------------------------------------------------
  1093. //! select & return hit component for attacking AI
  1094. override string GetHitComponentForAI()
  1095. {
  1096. return GetDayZPlayerType().GetHitComponentForAI();
  1097. }
  1098. //! returns default hit component (fallback)
  1099. override string GetDefaultHitComponent()
  1100. {
  1101. return GetDayZPlayerType().GetDefaultHitComponent();
  1102. }
  1103. override vector GetDefaultHitPosition()
  1104. {
  1105. return m_DefaultHitPosition;
  1106. }
  1107. //! returns list of suitable finisher hit components (defined on base entity/entity type)
  1108. override array<string> GetSuitableFinisherHitComponents()
  1109. {
  1110. return GetDayZPlayerType().GetSuitableFinisherHitComponents();
  1111. }
  1112. protected vector SetDefaultHitPosition(string pSelection)
  1113. {
  1114. return GetSelectionPositionMS(pSelection);
  1115. }
  1116. //--------------------------------------------------------------------------
  1117. //!DEPRECATED!
  1118. void AddPossibleCoverFaceForShave()
  1119. {
  1120. m_FaceCoveredForShaveLayers++;
  1121. }
  1122. //!DEPRECATED!
  1123. void RemovePossibleCoverFaceForShave()
  1124. {
  1125. m_FaceCoveredForShaveLayers--;
  1126. }
  1127. //--------------------------------------------------------------------------
  1128. override void EEItemAttached(EntityAI item, string slot_name)
  1129. {
  1130. super.EEItemAttached(item, slot_name);
  1131. ItemBase itemIB = ItemBase.Cast(item);
  1132. SwitchItemSelectionTexture(item, slot_name);
  1133. Param1<PlayerBase> p = new Param1<PlayerBase>(this);
  1134. item.SwitchItemSelectionTextureEx(EItemManipulationContext.ATTACHING, p);
  1135. m_QuickBarBase.updateSlotsCount();
  1136. CalculateVisibilityForAI();
  1137. UpdateShoulderProxyVisibility(item, slot_name);
  1138. HideHairSelections(itemIB,true);
  1139. GetGame().GetAnalyticsClient().OnItemAttachedAtPlayer(item, slot_name);
  1140. Clothing clothing = Clothing.Cast(item);
  1141. if (clothing)
  1142. {
  1143. if (!GetGame().IsDedicatedServer())
  1144. {
  1145. if (clothing.GetEffectWidgetTypes())
  1146. {
  1147. QueueAddEffectWidget(clothing.GetEffectWidgetTypes());
  1148. }
  1149. if (clothing.GetGlassesEffectID() > -1)
  1150. {
  1151. QueueAddGlassesEffect(clothing.GetGlassesEffectID());
  1152. }
  1153. GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 200, false);//sometimes it takes a while to load in
  1154. UpdateCorpseStateVisual();//....but if possible, we don't want a delay
  1155. }
  1156. else if (GetGame().IsServer())
  1157. {
  1158. if (clothing.IsGasMask())
  1159. {
  1160. GetModifiersManager().ActivateModifier(eModifiers.MDF_MASK);
  1161. }
  1162. }
  1163. clothing.UpdateNVGStatus(this,true);
  1164. }
  1165. AdjustBandana(item,slot_name);
  1166. AdjustShemag(item,slot_name);
  1167. }
  1168. override void EEItemDetached(EntityAI item, string slot_name)
  1169. {
  1170. super.EEItemDetached(item, slot_name);
  1171. ItemBase item_base = ItemBase.Cast(item);
  1172. SwitchItemSelectionTexture(item, slot_name);
  1173. item.SwitchItemSelectionTextureEx(EItemManipulationContext.DETACHING);
  1174. m_QuickBarBase.updateSlotsCount();
  1175. CalculateVisibilityForAI();
  1176. HideHairSelections(item_base,false);
  1177. Clothing clothing = Clothing.Cast(item);
  1178. if (clothing)
  1179. {
  1180. if (!GetGame().IsDedicatedServer())
  1181. {
  1182. if (clothing.GetEffectWidgetTypes())
  1183. {
  1184. QueueRemoveEffectWidget(clothing.GetEffectWidgetTypes());
  1185. }
  1186. if (clothing.GetGlassesEffectID() > -1)
  1187. {
  1188. QueueRemoveGlassesEffect(clothing.GetGlassesEffectID());
  1189. }
  1190. }
  1191. if (GetGame().IsServer())
  1192. {
  1193. if (clothing.IsGasMask())
  1194. {
  1195. GetModifiersManager().DeactivateModifier(eModifiers.MDF_MASK);
  1196. }
  1197. }
  1198. clothing.UpdateNVGStatus(this);
  1199. GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 200, false);//sometimes it takes a while to load in
  1200. UpdateCorpseStateVisual();//....but if possible, we don't want a delay
  1201. }
  1202. }
  1203. void UpdateShoulderProxyVisibility(EntityAI item, string slot_name)
  1204. {
  1205. string slot = slot_name;
  1206. bool boo;
  1207. boo = item.IsWeapon();
  1208. if (slot == "Melee")
  1209. {
  1210. SetSimpleHiddenSelectionState(SIMPLE_SELECTION_MELEE_RIFLE,boo);
  1211. SetSimpleHiddenSelectionState(SIMPLE_SELECTION_MELEE_MELEE,!boo);
  1212. }
  1213. else if (slot == "Shoulder")
  1214. {
  1215. SetSimpleHiddenSelectionState(SIMPLE_SELECTION_SHOULDER_RIFLE,boo);
  1216. SetSimpleHiddenSelectionState(SIMPLE_SELECTION_SHOULDER_MELEE,!boo);
  1217. }
  1218. }
  1219. override void SwitchItemSelectionTexture(EntityAI item, string slot_name)
  1220. {
  1221. super.SwitchItemSelectionTexture(item,slot_name);
  1222. //shirt + armband
  1223. EntityAI armband = FindAttachmentBySlotName("Armband");
  1224. if (slot_name == "Body" && armband)
  1225. {
  1226. Param1<PlayerBase> p = new Param1<PlayerBase>(this);
  1227. armband.SwitchItemSelectionTextureEx(EItemManipulationContext.UPDATE,p);
  1228. }
  1229. }
  1230. void RemoveAllItems()
  1231. {
  1232. array<EntityAI> itemsArray = new array<EntityAI>;
  1233. ItemBase item;
  1234. GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER, itemsArray);
  1235. for (int i = 0; i < itemsArray.Count(); i++)
  1236. {
  1237. Class.CastTo(item, itemsArray.Get(i));
  1238. if (item && !item.IsInherited(SurvivorBase)) GetInventory().LocalDestroyEntity(item);
  1239. }
  1240. }
  1241. bool GetHitPPEEnabled()
  1242. {
  1243. return m_CanDisplayHitEffectPPE;
  1244. }
  1245. void SetHitPPEEnabled(bool enabled)
  1246. {
  1247. m_CanDisplayHitEffectPPE = enabled;
  1248. }
  1249. bool IsMale()
  1250. {
  1251. if (ConfigGetBool("woman") != 1)
  1252. {
  1253. return true;
  1254. }
  1255. return false;
  1256. }
  1257. int GetVoiceType()
  1258. {
  1259. int voice_type = ConfigGetInt("voiceType");
  1260. if (voice_type == 0)
  1261. {
  1262. voice_type = 1;
  1263. }
  1264. return voice_type;
  1265. }
  1266. PlayerSoundManagerServer GetPlayerSoundManagerServer()
  1267. {
  1268. return m_PlayerSoundManagerServer;
  1269. }
  1270. UndergroundHandlerClient GetUndergroundHandler()
  1271. {
  1272. if (!m_UndergroundHandler && IsAlive())
  1273. {
  1274. m_UndergroundHandler = new UndergroundHandlerClient(this);
  1275. }
  1276. return m_UndergroundHandler;
  1277. }
  1278. UndergroundBunkerHandlerClient GetUndergroundBunkerHandler()
  1279. {
  1280. if (!m_UndergroundBunkerHandler && IsAlive())
  1281. {
  1282. m_UndergroundBunkerHandler = new UndergroundBunkerHandlerClient(this);
  1283. }
  1284. return m_UndergroundBunkerHandler;
  1285. }
  1286. void KillUndergroundHandler()
  1287. {
  1288. m_UndergroundHandler = null;
  1289. m_UndergroundBunkerHandler = null;
  1290. }
  1291. // --------------------------------------------------
  1292. // User Actions
  1293. //---------------------------------------------------
  1294. void SetActions(out TInputActionMap InputActionMap)
  1295. {
  1296. AddAction(ActionOpenDoors, InputActionMap);
  1297. AddAction(ActionCloseDoors, InputActionMap);
  1298. AddAction(ActionLockedDoors, InputActionMap);
  1299. AddAction(ActionEnterLadder, InputActionMap);
  1300. AddAction(ActionExitLadder, InputActionMap);
  1301. //-----------CheckIfCanMOveToTarget----------
  1302. AddAction(ActionStartEngine, InputActionMap);
  1303. AddAction(ActionStartEngineBoat, InputActionMap);
  1304. AddAction(ActionStopEngine, InputActionMap);
  1305. AddAction(ActionStopEngineBoat, InputActionMap);
  1306. AddAction(ActionSwitchSeats, InputActionMap);
  1307. AddAction(ActionOpenCarDoors,InputActionMap);
  1308. AddAction(ActionCloseCarDoors,InputActionMap);
  1309. AddAction(ActionUncoverHeadSelf, InputActionMap);
  1310. AddAction(ActionDrinkPondContinuous, InputActionMap);
  1311. AddAction(ActionEatSnowContinuous, InputActionMap);
  1312. AddAction(ActionIgniteFireplaceByAir, InputActionMap);
  1313. AddAction(ActionMineBushByHand, InputActionMap);
  1314. AddAction(ActionUngagSelf, InputActionMap);
  1315. AddAction(ActionWashHandsWater, InputActionMap);
  1316. AddAction(ActionWashHandsSnow, InputActionMap);
  1317. AddAction(ActionGetOutTransport, InputActionMap);
  1318. AddAction(ActionUnrestrainTargetHands, InputActionMap);
  1319. AddAction(ActionTakeArrow, InputActionMap);
  1320. AddAction(ActionTakeArrowToHands, InputActionMap);
  1321. AddAction(ActionOperatePanelPowerStation, InputActionMap);
  1322. }
  1323. void SetActions() // Backwards compatibility, not recommended to use
  1324. {
  1325. }
  1326. void SetActionsRemoteTarget(out TInputActionMap InputActionMap)
  1327. {
  1328. AddAction(ActionCPR, InputActionMap);
  1329. AddAction(ActionUncoverHeadTarget, InputActionMap);
  1330. AddAction(ActionUngagTarget, InputActionMap);
  1331. AddAction(ActionPullBodyFromTransport, InputActionMap);
  1332. AddAction(ActionCheckPulseTarget, InputActionMap);
  1333. }
  1334. void SetActionsRemoteTarget() // Backwards compatibility, not recommended to use
  1335. {
  1336. }
  1337. void InitializeActions()
  1338. {
  1339. // Backwards compatibility
  1340. if (IsControlledPlayer())
  1341. {
  1342. m_InputActionMap = new TInputActionMap;
  1343. SetActions();
  1344. }
  1345. else
  1346. {
  1347. m_InputActionMap = new TInputActionMap;
  1348. SetActionsRemoteTarget();
  1349. }
  1350. //////////////////////////
  1351. m_InputActionMapControled = new TInputActionMap;
  1352. SetActions(m_InputActionMapControled);
  1353. m_InputActionMapAsTarget = new TInputActionMap;
  1354. SetActionsRemoteTarget(m_InputActionMapAsTarget);
  1355. }
  1356. override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
  1357. {
  1358. if (!m_ActionsInitialize)
  1359. {
  1360. m_ActionsInitialize = true;
  1361. InitializeActions();
  1362. }
  1363. // Backwards compatibility
  1364. array<ActionBase_Basic> bcActions = m_InputActionMap.Get(action_input_type);
  1365. if (!bcActions)
  1366. {
  1367. if (IsControlledPlayer())
  1368. actions = m_InputActionMapControled.Get(action_input_type);
  1369. else
  1370. actions = m_InputActionMapAsTarget.Get(action_input_type);
  1371. }
  1372. else
  1373. {
  1374. if (!actions)
  1375. actions = new array<ActionBase_Basic>();
  1376. if (IsControlledPlayer())
  1377. actions.InsertAll(m_InputActionMapControled.Get(action_input_type));
  1378. else
  1379. actions.InsertAll(m_InputActionMapAsTarget.Get(action_input_type));
  1380. actions.InsertAll(bcActions);
  1381. }
  1382. }
  1383. void AddAction(typename actionName, out TInputActionMap InputActionMap)
  1384. {
  1385. ActionBase action = GetActionManager().GetAction(actionName);
  1386. typename ai = action.GetInputType();
  1387. if (!ai)
  1388. {
  1389. m_ActionsInitialize = false;
  1390. return;
  1391. }
  1392. ref array<ActionBase_Basic> action_array = InputActionMap.Get(ai);
  1393. if (!action_array)
  1394. {
  1395. action_array = new array<ActionBase_Basic>;
  1396. InputActionMap.Insert(ai, action_array);
  1397. }
  1398. action_array.Insert(action);
  1399. }
  1400. void AddAction(typename actionName) // Backwards compatibility, not recommended to use
  1401. {
  1402. AddAction(actionName, m_InputActionMap);
  1403. }
  1404. void RemoveAction(typename actionName, out TInputActionMap InputActionMap)
  1405. {
  1406. ActionBase action = GetActionManager().GetAction(actionName);
  1407. typename ai = action.GetInputType();
  1408. ref array<ActionBase_Basic> action_array = InputActionMap.Get(ai);
  1409. if (action_array)
  1410. {
  1411. for (int i = 0; i < action_array.Count(); i++)
  1412. {
  1413. if (action == action_array.Get(i))
  1414. {
  1415. action_array.Remove(i);
  1416. }
  1417. }
  1418. action_array = new array<ActionBase_Basic>;
  1419. InputActionMap.Insert(ai, action_array);
  1420. }
  1421. action_array.Insert(action);
  1422. }
  1423. void RemoveAction(typename actionName) // Backwards compatibility, not recommended to use
  1424. {
  1425. RemoveAction(actionName, m_InputActionMap);
  1426. }
  1427. int GetCurrentRecipe()
  1428. {
  1429. return m_RecipePick;
  1430. }
  1431. void SetNextRecipe()
  1432. {
  1433. m_RecipePick++;
  1434. }
  1435. void SetFirstRecipe()
  1436. {
  1437. m_RecipePick = 0;
  1438. }
  1439. //---------------------------------------------------
  1440. ActionManagerBase GetActionManager()
  1441. {
  1442. return m_ActionManager;
  1443. }
  1444. EmoteManager GetEmoteManager()
  1445. {
  1446. return m_EmoteManager;
  1447. }
  1448. RandomGeneratorSyncManager GetRandomGeneratorSyncManager()
  1449. {
  1450. return m_RGSManager;
  1451. }
  1452. //!called every command handler tick when player is on ladder
  1453. override void OnLadder(float delta_time, HumanMovementState pState)
  1454. {
  1455. ProcessHandDamage(delta_time, pState);
  1456. }
  1457. void ProcessHandDamage(float delta_time, HumanMovementState pState)
  1458. {
  1459. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
  1460. {
  1461. if (pState.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SLIDE)
  1462. {
  1463. //Print("sliding down");
  1464. EntityAI gloves = GetInventory().FindAttachment(InventorySlots.GLOVES);
  1465. if (gloves && gloves.GetHealthLevel() < 4)
  1466. {
  1467. gloves.AddHealth("","", PlayerConstants.GLOVES_DAMAGE_SLIDING_LADDER_PER_SEC * delta_time);
  1468. return;
  1469. }
  1470. if (Math.RandomFloat01() < PlayerConstants.CHANCE_TO_BLEED_SLIDING_LADDER_PER_SEC * delta_time)
  1471. {
  1472. if (Math.RandomFloat01() < 0.5)
  1473. {
  1474. if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftForeArmRoll"))
  1475. {
  1476. SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
  1477. }
  1478. }
  1479. else
  1480. {
  1481. if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightForeArmRoll"))
  1482. {
  1483. SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
  1484. }
  1485. }
  1486. }
  1487. }
  1488. }
  1489. }
  1490. override void ProcessFeetDamageServer(int pUserInt)
  1491. {
  1492. //InventorySlots.HEADGEAR
  1493. EntityAI shoes = GetInventory().FindAttachment(InventorySlots.FEET);
  1494. string surface; int liquid;
  1495. GetGame().SurfaceUnderObject(this, surface, liquid);
  1496. float modifier_surface = Surface.GetParamFloat(surface, "footDamage");
  1497. if (shoes && shoes.GetHealthLevel() < 4)
  1498. {
  1499. shoes.AddHealth("", "", -1 * modifier_surface * PlayerConstants.SHOES_MOVEMENT_DAMAGE_PER_STEP * (float)PlayerConstants.CHECK_EVERY_N_STEP);
  1500. return;
  1501. }
  1502. float rnd = Math.RandomFloat01();
  1503. float modifier_movement = GetFeetDamageMoveModifier();
  1504. float chance = modifier_movement * modifier_surface * PlayerConstants.BAREFOOT_MOVEMENT_BLEED_MODIFIER * (float)PlayerConstants.CHECK_EVERY_N_STEP;
  1505. if (rnd < chance)
  1506. {
  1507. if (pUserInt % 2 == 0)
  1508. {
  1509. if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("RightFoot"))
  1510. SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
  1511. }
  1512. else
  1513. {
  1514. if (GetBleedingManagerServer().AttemptAddBleedingSourceBySelection("LeftFoot"))
  1515. SendSoundEvent(EPlayerSoundEventID.INJURED_LIGHT);
  1516. }
  1517. }
  1518. }
  1519. float GetFeetDamageMoveModifier()
  1520. {
  1521. float modifier;
  1522. switch(m_MovementState.m_iMovement)
  1523. {
  1524. case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
  1525. modifier = 1;
  1526. break
  1527. case DayZPlayerConstants.MOVEMENTIDX_RUN:
  1528. modifier = 0.5;
  1529. break
  1530. case DayZPlayerConstants.MOVEMENTIDX_WALK:
  1531. modifier = 0;
  1532. break
  1533. }
  1534. return modifier;
  1535. }
  1536. void SetStamina(int value, int range)
  1537. {
  1538. if (m_ModulePlayerStatus)
  1539. m_ModulePlayerStatus.SetStamina(value, range);
  1540. }
  1541. #ifdef DIAG_DEVELOPER
  1542. void SetStaminaDisabled(bool value)
  1543. {
  1544. if (m_StaminaHandler)
  1545. m_StaminaHandler.SetStaminaDisabled(value);
  1546. }
  1547. #endif
  1548. void SetQuickRestrain(bool enable)
  1549. {
  1550. m_AllowQuickRestrain = enable;
  1551. }
  1552. void SetQuickFishing(bool enable)
  1553. {
  1554. m_AllowQuickFishing = enable;
  1555. }
  1556. bool IsQuickRestrain()
  1557. {
  1558. return m_AllowQuickRestrain;
  1559. }
  1560. bool IsQuickFishing()
  1561. {
  1562. return m_AllowQuickFishing;
  1563. }
  1564. PlayerStats GetPlayerStats()
  1565. {
  1566. return m_PlayerStats;
  1567. }
  1568. CraftingManager GetCraftingManager()
  1569. {
  1570. return m_CraftingManager;
  1571. }
  1572. StaminaHandler GetStaminaHandler()
  1573. {
  1574. return m_StaminaHandler;
  1575. }
  1576. override WeaponManager GetWeaponManager()
  1577. {
  1578. return m_WeaponManager;
  1579. }
  1580. override ArrowManagerBase GetArrowManager()
  1581. {
  1582. return m_ArrowManager;
  1583. }
  1584. bool CanBeRestrained()
  1585. {
  1586. if (IsInVehicle() || IsRaised() || IsSwimming() || IsClimbing() || IsClimbingLadder() || IsRestrained() || !GetWeaponManager() || GetWeaponManager().IsRunning() || !GetActionManager() || GetActionManager().GetRunningAction() != null || IsMapOpen())
  1587. {
  1588. return false;
  1589. }
  1590. if (GetThrowing() && GetThrowing().IsThrowingModeEnabled())
  1591. {
  1592. return false;
  1593. }
  1594. return true;
  1595. }
  1596. void SetRestrainStarted(bool restrain_started)
  1597. {
  1598. m_IsRestrainStarted = restrain_started;
  1599. SetSynchDirty();
  1600. }
  1601. bool IsRestrainStarted()
  1602. {
  1603. return m_IsRestrainStarted;
  1604. }
  1605. void SetRestrainPrelocked(bool restrain_prelock)
  1606. {
  1607. m_IsRestrainPrelocked = restrain_prelock;
  1608. SetSynchDirty();
  1609. }
  1610. bool IsRestrainPrelocked()
  1611. {
  1612. return m_IsRestrainPrelocked;
  1613. }
  1614. void SetRestrained(bool is_restrained)
  1615. {
  1616. m_IsRestrained = is_restrained;
  1617. SetSynchDirty();
  1618. }
  1619. override bool IsRestrained()
  1620. {
  1621. return m_IsRestrained;
  1622. }
  1623. void OnRestrainStartedChangeClient()
  1624. {
  1625. if (m_IsRestrainStarted && IsControlledPlayer())
  1626. {
  1627. if (GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
  1628. GetGame().GetUIManager().FindMenu(MENU_RADIAL_QUICKBAR).Close();
  1629. if (GetGame().GetUIManager().IsMenuOpen(MENU_INVENTORY))
  1630. GetGame().GetMission().HideInventory();
  1631. }
  1632. }
  1633. void OnRestrainChangeClient()
  1634. {
  1635. if (m_IsRestrained && IsControlledPlayer())
  1636. {
  1637. if (GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
  1638. GetGame().GetUIManager().FindMenu(MENU_RADIAL_QUICKBAR).Close();
  1639. if (GetGame().GetUIManager().IsMenuOpen(MENU_INVENTORY))
  1640. GetGame().GetMission().HideInventory();
  1641. }
  1642. }
  1643. override bool IsInventoryVisible()
  1644. {
  1645. return true;
  1646. }
  1647. bool CanManipulateInventory()
  1648. {
  1649. if (IsControlledPlayer())
  1650. {
  1651. return !IsRestrained() && !IsRestrainPrelocked() && !IsRestrainStarted();
  1652. }
  1653. return true;
  1654. }
  1655. override bool CanReleaseAttachment (EntityAI attachment)
  1656. {
  1657. return super.CanReleaseAttachment(attachment);
  1658. }
  1659. override bool CanReleaseCargo (EntityAI cargo)
  1660. {
  1661. return super.CanReleaseCargo(cargo);
  1662. }
  1663. override bool CanReceiveItemIntoCargo(EntityAI item)
  1664. {
  1665. return super.CanReceiveItemIntoCargo(item);
  1666. }
  1667. override bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
  1668. {
  1669. return super.CanSwapItemInCargo(child_entity, new_entity);
  1670. }
  1671. override bool CanReceiveItemIntoHands(EntityAI item_to_hands)
  1672. {
  1673. if (IsInVehicle())
  1674. return false;
  1675. if (!CanPickupHeavyItem(item_to_hands))
  1676. return false;
  1677. return super.CanReceiveItemIntoHands(item_to_hands);
  1678. }
  1679. override bool CanSaveItemInHands(EntityAI item_in_hands)
  1680. {
  1681. return super.CanSaveItemInHands(item_in_hands);
  1682. }
  1683. override bool CanReleaseFromHands(EntityAI handheld)
  1684. {
  1685. return super.CanReleaseFromHands(handheld);
  1686. }
  1687. int GetCraftingRecipeID()
  1688. {
  1689. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  1690. {
  1691. return GetCraftingManager().GetRecipeID();
  1692. }
  1693. else
  1694. {
  1695. return m_RecipeID;
  1696. }
  1697. }
  1698. void SetCraftingRecipeID(int recipeID)
  1699. {
  1700. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  1701. {
  1702. GetCraftingManager().SetRecipeID(recipeID);
  1703. }
  1704. else
  1705. {
  1706. m_RecipeID = recipeID;
  1707. }
  1708. }
  1709. // --------------------------------------------------
  1710. // Action data for base building actions
  1711. //---------------------------------------------------
  1712. ConstructionActionData GetConstructionActionData()
  1713. {
  1714. return m_ConstructionActionData;
  1715. }
  1716. void ResetConstructionActionData()
  1717. {
  1718. if (m_ConstructionActionData)
  1719. {
  1720. m_ConstructionActionData.ResetActionIndexes();
  1721. }
  1722. }
  1723. // --------------------------------------------------
  1724. // Action data for fireplace (indoor)
  1725. //---------------------------------------------------
  1726. vector GetLastFirePoint()
  1727. {
  1728. return m_LastFirePoint;
  1729. }
  1730. float GetLastFirePointRot()
  1731. {
  1732. return m_LastFirePointRot;
  1733. }
  1734. int GetLastFirePointIndex()
  1735. {
  1736. return m_LastFirePointIndex;
  1737. }
  1738. void SetLastFirePoint(vector last_fire_point)
  1739. {
  1740. m_LastFirePoint = last_fire_point;
  1741. }
  1742. void SetLastFirePointRot(float last_fire_point_rot)
  1743. {
  1744. m_LastFirePointRot = last_fire_point_rot;
  1745. }
  1746. void SetLastFirePointIndex(int last_fire_point_index)
  1747. {
  1748. m_LastFirePointIndex = last_fire_point_index;
  1749. }
  1750. // --------------------------------------------------
  1751. // QuickBar
  1752. //---------------------------------------------------
  1753. void RemoveQuickBarEntityShortcut(EntityAI entity)
  1754. {
  1755. int index = m_QuickBarBase.FindEntityIndex(entity);
  1756. if (index != -1)
  1757. m_QuickBarBase.SetEntityShortcut(entity,-1);
  1758. }
  1759. //---------------------------------------------------
  1760. void SetEnableQuickBarEntityShortcut(EntityAI entity, bool value)
  1761. {
  1762. int index = m_QuickBarBase.FindEntityIndex(entity);
  1763. if (index != -1)
  1764. m_QuickBarBase.SetShotcutEnable(index,value);
  1765. }
  1766. //---------------------------------------------------
  1767. int FindQuickBarEntityIndex(EntityAI entity)
  1768. {
  1769. int index;
  1770. index = m_QuickBarBase.FindEntityIndex(entity);
  1771. if (m_QuickBarBase.GetEntity(index) == NULL)
  1772. return -1;
  1773. return index;
  1774. }
  1775. //---------------------------------------------------
  1776. int GetQuickBarSize()
  1777. {
  1778. return m_QuickBarBase.GetSize();
  1779. }
  1780. //---------------------------------------------------
  1781. EntityAI GetQuickBarEntity(int index)
  1782. {
  1783. return m_QuickBarBase.GetEntity(index);
  1784. }
  1785. //---------------------------------------------------
  1786. void UpdateQuickBarEntityVisibility(EntityAI entity)
  1787. {
  1788. int i = FindQuickBarEntityIndex(entity);
  1789. if (i >= 0)
  1790. m_QuickBarBase.UpdateShotcutVisibility(i);
  1791. }
  1792. //---------------------------------------------------
  1793. void SetQuickBarEntityShortcut(EntityAI entity, int index, bool force = false)
  1794. {
  1795. m_QuickBarBase.SetEntityShortcut(entity, index, force);
  1796. }
  1797. //---------------------------------------------------
  1798. void OnQuickbarSetEntityRequest(ParamsReadContext ctx)
  1799. {
  1800. m_QuickBarBase.OnSetEntityRequest(ctx);
  1801. }
  1802. //---------------------------------------------------
  1803. // Applies splint on all limbs.
  1804. void ApplySplint()
  1805. {
  1806. float add_health_coef = 0.33;
  1807. // 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.
  1808. if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  1809. {
  1810. AddHealth("LeftLeg", "Health", (GetMaxHealth("LeftLeg", "Health") - GetHealth("LeftLeg", "Health") ) * add_health_coef );
  1811. AddHealth("RightLeg", "Health", (GetMaxHealth("RightLeg", "Health") - GetHealth("RightLeg", "Health")) * add_health_coef );
  1812. AddHealth("RightFoot", "Health", (GetMaxHealth("RightFoot", "Health") - GetHealth("RightFoot", "Health")) * add_health_coef );
  1813. AddHealth("LeftFoot", "Health", (GetMaxHealth("LeftFoot", "Health") - GetHealth("LeftFoot", "Health")) * add_health_coef );
  1814. }
  1815. }
  1816. void ProcessDrowning(float dT)
  1817. {
  1818. GetStaminaHandler().DepleteStamina(EStaminaModifiers.DROWN,dT);
  1819. #ifndef SERVER
  1820. //PP EFFECTS
  1821. PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
  1822. req.SetStamina01(GetStaminaHandler().GetStaminaNormalized());
  1823. #endif
  1824. }
  1825. void SpawnDrowningBubbles()
  1826. {
  1827. if (!GetDrowningWaterLevelCheck())
  1828. return;
  1829. float bubbleFrequency = Math.Lerp(PlayerConstants.DROWNING_BUBBLE_FREQUENCY_MIN, PlayerConstants.DROWNING_BUBBLE_FREQUENCY_MAX, GetStaminaHandler().GetSyncedStaminaNormalized());
  1830. int boneIdx = GetBoneIndexByName("Head");
  1831. if (boneIdx != -1)
  1832. {
  1833. Particle p = ParticleManager.GetInstance().PlayInWorld(ParticleList.DROWNING_BUBBLES, "-0.03 0.15 0");
  1834. if (p)
  1835. AddChild(p, boneIdx);
  1836. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SpawnDrowningBubbles, bubbleFrequency);
  1837. }
  1838. }
  1839. void ProcessHoldBreath(float dT)
  1840. {
  1841. if (IsTryingHoldBreath() && CanStartConsumingStamina(EStaminaConsumers.HOLD_BREATH))
  1842. {
  1843. if (!m_IsHoldingBreath)
  1844. {
  1845. OnHoldBreathStart();
  1846. m_IsHoldingBreath = true;
  1847. }
  1848. }
  1849. else if (!IsTryingHoldBreath() || !CanConsumeStamina(EStaminaConsumers.HOLD_BREATH))
  1850. {
  1851. if (m_IsHoldingBreath) OnHoldBreathEnd();
  1852. m_IsHoldingBreath = false;
  1853. }
  1854. }
  1855. void OnHoldBreathStart()
  1856. {
  1857. //SendSoundEvent(SoundSetMap.GetSoundSetID("holdBreath_male_Char_SoundSet"));
  1858. RequestSoundEventEx(EPlayerSoundEventID.HOLD_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
  1859. }
  1860. void OnHoldBreathExhausted()
  1861. {
  1862. RequestSoundEventEx(EPlayerSoundEventID.EXHAUSTED_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
  1863. }
  1864. void OnHoldBreathEnd()
  1865. {
  1866. //SendSoundEvent(SoundSetMap.GetSoundSetID("releaseBreath_male_Char_SoundSet"));
  1867. RequestSoundEventEx(EPlayerSoundEventID.RELEASE_BREATH, true, EPlayerSoundEventParam.SKIP_CONTROLLED_PLAYER);
  1868. }
  1869. override bool IsHoldingBreath()
  1870. {
  1871. return m_IsHoldingBreath;
  1872. }
  1873. override bool IsRefresherSignalingViable()
  1874. {
  1875. return false;
  1876. }
  1877. override bool IsSelfAdjustingTemperature()
  1878. {
  1879. return IsAlive();
  1880. }
  1881. eMixedSoundStates GetMixedSoundStates()
  1882. {
  1883. return m_MixedSoundStates;
  1884. }
  1885. AbstractWave SaySoundSet(string name)
  1886. {
  1887. if (m_SaySoundLastSetName != name)
  1888. {
  1889. m_SaySoundParams = new SoundParams(name);
  1890. m_SaySoundBuilder = new SoundObjectBuilder(m_SaySoundParams);
  1891. m_SaySoundLastSetName = name;
  1892. }
  1893. m_SaySoundObject = m_SaySoundBuilder.BuildSoundObject();
  1894. m_SaySoundObject.SetPosition(GetPosition());
  1895. return GetGame().GetSoundScene().Play3D(m_SaySoundObject, m_SaySoundBuilder);
  1896. }
  1897. EntityAI FindCargoByBaseType(string searched_item)
  1898. {
  1899. EntityAI attachment;
  1900. string item_name;
  1901. int attcount = this.GetInventory().AttachmentCount();
  1902. for (int att = 0; att < attcount; att++)
  1903. {
  1904. attachment = GetInventory().GetAttachmentFromIndex(att);
  1905. if (attachment.IsItemBase())
  1906. {
  1907. item_name = attachment.GetType();
  1908. if (GetGame().IsKindOf(item_name, searched_item))
  1909. {
  1910. return attachment;
  1911. }
  1912. }
  1913. }
  1914. return NULL;
  1915. }
  1916. void InitEditor()
  1917. {
  1918. if (GetGame().IsDebug())
  1919. {
  1920. if (!GetGame().IsMultiplayer() && GetGame().GetPlayer() && GetGame().GetPlayer().GetID() == this.GetID())
  1921. {
  1922. PluginSceneManager scene_editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
  1923. scene_editor.InitLoad();
  1924. }
  1925. }
  1926. }
  1927. //---------------------------------------------------------------------------------------------------------------------------
  1928. void OnPlayerLoaded()
  1929. {
  1930. InitEditor();
  1931. //! initialize EnvironmentExposure data; waits for PlayerStats load
  1932. if (m_Environment)
  1933. m_Environment.Init();
  1934. if (GetGame().IsMultiplayer() || GetGame().IsServer())
  1935. {
  1936. if (m_ModuleLifespan)
  1937. {
  1938. m_ModuleLifespan.SynchLifespanVisual(this, m_LifeSpanState, m_HasBloodyHandsVisible, m_HasBloodTypeVisible, m_BloodType);
  1939. }
  1940. }
  1941. if (IsControlledPlayer())//true only on client for the controlled character
  1942. {
  1943. if (!m_VirtualHud)
  1944. m_VirtualHud = new VirtualHud(this);
  1945. if (m_Hud)
  1946. {
  1947. m_Hud.UpdateBloodName();
  1948. PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.GAMEPLAY_EFFECTS);
  1949. GetGame().GetUIManager().CloseAll();
  1950. GetGame().GetMission().SetPlayerRespawning(false);
  1951. GetGame().GetMission().OnPlayerRespawned(this);
  1952. m_Hud.ShowQuickbarUI(true);
  1953. m_Hud.UpdateQuickbarGlobalVisibility();
  1954. m_Hud.InitHeatBufferUI(this);
  1955. m_Hud.OnPlayerLoaded();
  1956. }
  1957. m_EffectWidgets = GetGame().GetMission().GetEffectWidgets();
  1958. }
  1959. if (!GetGame().IsDedicatedServer())
  1960. {
  1961. GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseStateVisual, 2000, false);//sometimes it takes a while to load in
  1962. m_PlayerSoundEventHandler = new PlayerSoundEventHandler(this);
  1963. m_ReplaceSoundEventHandler = new ReplaceSoundEventHandler(this);
  1964. }
  1965. int slotId = InventorySlots.GetSlotIdFromString("Head");
  1966. m_CharactersHead = Head_Default.Cast(GetInventory().FindPlaceholderForSlot(slotId));
  1967. CheckHairClippingOnCharacterLoad();
  1968. UpdateHairSelectionVisibility();
  1969. PreloadDecayTexture();
  1970. Weapon_Base wpn = Weapon_Base.Cast(GetItemInHands());
  1971. if (wpn)
  1972. {
  1973. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE)
  1974. {
  1975. wpn.DelayedValidateAndRepair();
  1976. }
  1977. else
  1978. {
  1979. wpn.ValidateAndRepair();
  1980. }
  1981. }
  1982. m_PlayerLoaded = true;
  1983. }
  1984. void SetPlayerDisconnected(bool state)
  1985. {
  1986. m_PlayerDisconnectProcessed = state;
  1987. }
  1988. bool IsPlayerDisconnected()
  1989. {
  1990. return m_PlayerDisconnectProcessed;
  1991. }
  1992. // --------------------------------------------------
  1993. // Advanced placement
  1994. //---------------------------------------------------
  1995. //get hologram
  1996. Hologram GetHologramServer()
  1997. {
  1998. return m_HologramServer;
  1999. }
  2000. Hologram GetHologramLocal()
  2001. {
  2002. return m_HologramLocal;
  2003. }
  2004. void PlacingStartServer(ItemBase item)
  2005. {
  2006. if (item)
  2007. {
  2008. m_HologramServer = new Hologram(this, GetLocalProjectionPosition(), item);
  2009. GetHologramServer().SetProjectionPosition(GetLocalProjectionPosition());
  2010. GetHologramServer().SetProjectionOrientation(GetLocalProjectionOrientation());
  2011. GetHologramServer().GetProjectionEntity().OnPlacementStarted(this);
  2012. GetHologramServer().CheckPowerSource();
  2013. GetHologramServer().RefreshVisual();
  2014. }
  2015. }
  2016. void PlacingStartLocal(ItemBase item)
  2017. {
  2018. if (GetGame().IsMultiplayer() && GetGame().IsServer())
  2019. return;
  2020. if (item)
  2021. {
  2022. m_HologramLocal = new Hologram(this, GetLocalProjectionPosition(), item);
  2023. GetHologramLocal().GetProjectionEntity().OnPlacementStarted(this);
  2024. }
  2025. }
  2026. void PlacingCancelServer()
  2027. {
  2028. EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
  2029. if (IsPlacingServer())
  2030. {
  2031. GetHologramServer().CheckPowerSource();
  2032. GetHologramServer().GetParentEntity().OnPlacementCancelled(this);
  2033. delete m_HologramServer;
  2034. return;
  2035. }
  2036. else if (entityInHands && entityInHands.HasEnergyManager())
  2037. {
  2038. if (entityInHands.GetCompEM().IsPlugged())
  2039. entityInHands.OnPlacementCancelled(this);
  2040. }
  2041. }
  2042. //Called when item placement is canceled, will prevent quickbar usage until the item the player was placing is back in hands
  2043. void LockHandsUntilItemHeld()
  2044. {
  2045. m_AreHandsLocked = true;
  2046. }
  2047. void PlacingCancelLocal()
  2048. {
  2049. EntityAI entityInHands = GetHumanInventory().GetEntityInHands();
  2050. if (entityInHands && entityInHands.HasEnergyManager())
  2051. {
  2052. if (entityInHands.GetCompEM().IsPlugged())
  2053. entityInHands.OnPlacementCancelled(this);
  2054. }
  2055. delete m_HologramLocal;
  2056. }
  2057. void PlacingCompleteServer()
  2058. {
  2059. SetLocalProjectionPosition(vector.Zero);
  2060. delete m_HologramServer;
  2061. }
  2062. void PlacingCompleteLocal()
  2063. {
  2064. SetLocalProjectionPosition(vector.Zero);
  2065. delete m_HologramLocal;
  2066. }
  2067. bool IsPlacingServer()
  2068. {
  2069. if (m_HologramServer)
  2070. return true;
  2071. return false;
  2072. }
  2073. bool IsPlacingLocal()
  2074. {
  2075. if (m_HologramLocal)
  2076. return true;
  2077. return false;
  2078. }
  2079. void SetDrowning(bool enable)
  2080. {
  2081. if (enable != m_IsDrowning)
  2082. {
  2083. if (enable)
  2084. OnDrowningStart();
  2085. else
  2086. OnDrowningEnd();
  2087. }
  2088. m_IsDrowning = enable;
  2089. }
  2090. void OnDrowningStart()
  2091. {
  2092. #ifndef SERVER
  2093. if (IsControlledPlayer())
  2094. {
  2095. PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
  2096. req.Start();
  2097. }
  2098. //Particles
  2099. SpawnDrowningBubbles();
  2100. #endif
  2101. }
  2102. void OnDrowningEnd()
  2103. {
  2104. #ifndef SERVER
  2105. if (IsControlledPlayer())
  2106. {
  2107. PPERequester_Drowning req = PPERequester_Drowning.Cast(PPERequesterBank.GetRequester(PPERequesterBank.REQ_DROWNING));
  2108. req.Stop();
  2109. }
  2110. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(SpawnDrowningBubbles);
  2111. #endif
  2112. }
  2113. bool TogglePlacingServer(int userDataType, ParamsReadContext ctx)
  2114. {
  2115. if (userDataType == INPUT_UDT_ADVANCED_PLACEMENT)
  2116. {
  2117. PlacingCancelServer();
  2118. return true;
  2119. }
  2120. return false;
  2121. }
  2122. void RequestResetADSSync()
  2123. {
  2124. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && GetGame().IsMultiplayer())
  2125. {
  2126. m_ProcessResetADS = true;
  2127. ProcessADSSyncResetRequest();
  2128. }
  2129. else if (!GetGame().IsMultiplayer())
  2130. {
  2131. m_ResetADS = true;
  2132. }
  2133. }
  2134. void ProcessADSSyncResetRequest()
  2135. {
  2136. if (ScriptInputUserData.CanStoreInputUserData())
  2137. {
  2138. ScriptInputUserData ctx = new ScriptInputUserData;
  2139. ctx.Write(INPUT_UDT_RESET_ADS);
  2140. ctx.Send();
  2141. m_ProcessResetADS = false;
  2142. }
  2143. }
  2144. //! server only
  2145. bool ResetADSPlayerSync(int userDataType, ParamsReadContext ctx)
  2146. {
  2147. if (userDataType == INPUT_UDT_RESET_ADS)
  2148. {
  2149. ScriptJunctureData pCtx = new ScriptJunctureData;
  2150. SendSyncJuncture(DayZPlayerSyncJunctures.SJ_ADS_RESET,pCtx);
  2151. return true;
  2152. }
  2153. return false;
  2154. }
  2155. override bool CanPlaceItem(EntityAI item)
  2156. {
  2157. if (m_UndergroundPresence > EUndergroundPresence.NONE)
  2158. {
  2159. TStringSet disallowedUndergroundTypes = CfgGameplayHandler.GetDisallowedTypesInUnderground();
  2160. foreach (string t: disallowedUndergroundTypes)
  2161. {
  2162. if (item.IsKindOf(t))
  2163. return false;
  2164. }
  2165. }
  2166. return true;
  2167. }
  2168. void SetUnderground(EUndergroundPresence presence)
  2169. {
  2170. m_UndergroundPresence = presence;
  2171. }
  2172. void TogglePlacingLocal(ItemBase item = null)
  2173. {
  2174. if (IsPlacingLocal())
  2175. {
  2176. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && GetGame().IsMultiplayer())
  2177. {
  2178. if (ScriptInputUserData.CanStoreInputUserData())
  2179. {
  2180. ScriptInputUserData ctx = new ScriptInputUserData;
  2181. ctx.Write(INPUT_UDT_ADVANCED_PLACEMENT);
  2182. ctx.Send();
  2183. PlacingCancelLocal();
  2184. }
  2185. }
  2186. }
  2187. else if (!item)
  2188. {
  2189. PlacingStartLocal(GetItemInHands());
  2190. }
  2191. else
  2192. {
  2193. PlacingStartLocal(item);
  2194. }
  2195. }
  2196. void SetLocalProjectionPosition(vector local_position)
  2197. {
  2198. m_LocalProjectionPosition = local_position;
  2199. }
  2200. void SetLocalProjectionOrientation(vector local_orientation)
  2201. {
  2202. m_LocalProjectionOrientation = local_orientation;
  2203. }
  2204. vector GetLocalProjectionPosition()
  2205. {
  2206. return m_LocalProjectionPosition;
  2207. }
  2208. vector GetLocalProjectionOrientation()
  2209. {
  2210. return m_LocalProjectionOrientation;
  2211. }
  2212. void SetInColdArea(bool state)
  2213. {
  2214. if (m_IsInColdArea != state)
  2215. {
  2216. m_IsInColdArea = state;
  2217. SetSynchDirty();
  2218. }
  2219. }
  2220. bool GetInColdArea()
  2221. {
  2222. return m_IsInColdArea;
  2223. }
  2224. // ------------------------------------------------------------------------
  2225. //! water contact (driven by Environment)
  2226. void SetInWater(bool pState)
  2227. {
  2228. m_IsInWater = pState;
  2229. SetSynchDirty();
  2230. }
  2231. bool IsInWater()
  2232. {
  2233. return m_IsInWater;
  2234. }
  2235. // -------------------------------------------------------------------------
  2236. void ~PlayerBase()
  2237. {
  2238. if (GetGame() && (!GetGame().IsDedicatedServer()))
  2239. {
  2240. ClientData.RemovePlayerBase(this);
  2241. SetContaminatedEffectEx(false);
  2242. }
  2243. SEffectManager.DestroyEffect(m_FliesEff);
  2244. StopSoundSet(m_SoundFliesEffect);
  2245. }
  2246. void OnCameraChanged(DayZPlayerCameraBase new_camera)
  2247. {
  2248. m_CameraSwayModifier = new_camera.GetWeaponSwayModifier();
  2249. m_CurrentCamera = new_camera;
  2250. }
  2251. DayZPlayerCamera GetCurrentPlayerCamera()
  2252. {
  2253. return m_CurrentCamera;
  2254. }
  2255. bool IsCurrentCameraAimedAtGround()
  2256. {
  2257. if (!m_CurrentCamera)
  2258. return false;
  2259. return m_CurrentCamera.GetCurrentPitch() < PlayerConstants.CAMERA_THRESHOLD_PITCH;
  2260. }
  2261. BleedingSourcesManagerServer GetBleedingManagerServer()
  2262. {
  2263. return m_BleedingManagerServer;
  2264. }
  2265. BleedingSourcesManagerRemote GetBleedingManagerRemote()
  2266. {
  2267. return m_BleedingManagerRemote;
  2268. }
  2269. SymptomManager GetSymptomManager()
  2270. {
  2271. return m_SymptomManager;
  2272. }
  2273. VirtualHud GetVirtualHud()
  2274. {
  2275. if (!m_VirtualHud)
  2276. {
  2277. m_VirtualHud = new VirtualHud(this);
  2278. }
  2279. return m_VirtualHud;
  2280. }
  2281. TransferValues GetTransferValues()
  2282. {
  2283. return m_TrasferValues;
  2284. }
  2285. DebugMonitorValues GetDebugMonitorValues()
  2286. {
  2287. return m_DebugMonitorValues;
  2288. }
  2289. //--------------------------------------------------------------------------
  2290. void OnScheduledTick(float deltaTime)
  2291. {
  2292. if (!IsPlayerSelected() || !IsAlive())
  2293. return;
  2294. if (m_ModifiersManager)
  2295. m_ModifiersManager.OnScheduledTick(deltaTime);
  2296. if (m_NotifiersManager)
  2297. m_NotifiersManager.OnScheduledTick();
  2298. if (m_TrasferValues)
  2299. m_TrasferValues.OnScheduledTick(deltaTime);
  2300. if (m_VirtualHud)
  2301. m_VirtualHud.OnScheduledTick();
  2302. if (GetBleedingManagerServer())
  2303. GetBleedingManagerServer().OnTick(deltaTime);
  2304. if (m_Environment)
  2305. m_Environment.Update(deltaTime);
  2306. // Check if electric device needs to be unplugged
  2307. ItemBase heldItem = GetItemInHands();
  2308. if (heldItem && heldItem.HasEnergyManager() && heldItem.GetCompEM().IsPlugged())
  2309. {
  2310. // Now we know we are working with an electric device which is plugged into a power source.
  2311. EntityAI placed_entity = heldItem;
  2312. // Unplug the device when the player is too far from the power source.
  2313. placed_entity.GetCompEM().UpdatePlugState();
  2314. }
  2315. }
  2316. void OnCommandHandlerTick(float delta_time, int pCurrentCommandID)
  2317. {
  2318. if (!IsAlive())
  2319. {
  2320. if (!m_DeathSyncSent && m_KillerData)
  2321. {
  2322. SyncEvents.SendEntityKilled(this, m_KillerData.m_Killer, m_KillerData.m_MurderWeapon, m_KillerData.m_KillerHiTheBrain);
  2323. m_DeathSyncSent = true;
  2324. }
  2325. return;
  2326. }
  2327. if (m_DebugMonitorValues)
  2328. m_DebugMonitorValues.OnScheduledTick(delta_time);
  2329. if (GetSymptomManager())
  2330. GetSymptomManager().OnTick(delta_time, pCurrentCommandID, m_MovementState);//needs to stay in command handler tick as it's playing animations
  2331. //if (GetBleedingManagerServer()) GetBleedingManagerServer().OnTick(delta_time);
  2332. DayZPlayerInstanceType instType = GetInstanceType();
  2333. if (instType == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  2334. {
  2335. if (m_PlayerSoundEventHandler)
  2336. m_PlayerSoundEventHandler.OnTick(delta_time);
  2337. if (m_ProcessRemoveEffectWidgets && m_ProcessRemoveEffectWidgets.Count() > 0)
  2338. {
  2339. m_EffectWidgets.RemoveActiveEffects(m_ProcessRemoveEffectWidgets);
  2340. }
  2341. if (m_ProcessAddEffectWidgets && m_ProcessAddEffectWidgets.Count() > 0)
  2342. {
  2343. m_EffectWidgets.AddActiveEffects(m_ProcessAddEffectWidgets);
  2344. }
  2345. HandleGlassesEffect();
  2346. if (m_ContaminatedAreaEffectEnabled)
  2347. ContaminatedParticleAdjustment();
  2348. #ifdef DIAG_DEVELOPER
  2349. if (m_WeaponDebug)
  2350. {
  2351. m_WeaponDebug.OnCommandHandlerUpdate();
  2352. }
  2353. #endif
  2354. m_ProcessAddEffectWidgets.Clear(); //clears array for remotes as well
  2355. m_ProcessRemoveEffectWidgets.Clear(); //clears array for remotes as well
  2356. }
  2357. m_AnimCommandStarting = HumanMoveCommandID.None;
  2358. if (CfgGameplayHandler.GetAllowStaminaAffectInertia())
  2359. UpdateMovementInertia();
  2360. if (m_ProcessResetADS)
  2361. ProcessADSSyncResetRequest();
  2362. }
  2363. //! Update movement inertia based on stamina available
  2364. void UpdateMovementInertia()
  2365. {
  2366. HumanCommandMove hcm = GetCommand_Move();
  2367. if (hcm)
  2368. {
  2369. float staminaPercentage = GetStaminaHandler().GetSyncedStaminaNormalized();
  2370. hcm.SetTurnSpanSprintModifier(2 - staminaPercentage);
  2371. hcm.SetRunSprintFilterModifier((2 - staminaPercentage) * 0.5);
  2372. hcm.SetDirectionSprintFilterModifier(2 - staminaPercentage);
  2373. }
  2374. }
  2375. bool m_ShowDbgUI = true;
  2376. int m_DbgListSelection = 0;
  2377. float m_DbgSliderValue = 0.0;
  2378. ref array<string> m_DbgOptions = {"jedna", "dva", "tri"};
  2379. NotifiersManager GetNotifiersManager()
  2380. {
  2381. return m_NotifiersManager;
  2382. }
  2383. //--------------------------------------------------------------------------
  2384. void OnTick()
  2385. {
  2386. float deltaT = (GetGame().GetTime() - m_LastTick) * 0.001;
  2387. if (m_LastTick < 0)
  2388. deltaT = 0; //first tick protection
  2389. m_LastTick = GetGame().GetTime();
  2390. OnScheduledTick(deltaT);
  2391. }
  2392. // -------------------------------------------------------------------------
  2393. override void EEItemIntoHands(EntityAI item)
  2394. {
  2395. super.EEItemIntoHands(item);
  2396. if (item)
  2397. {
  2398. MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(item, {Bolt_Base});
  2399. Weapon_Base w;
  2400. if (Class.CastTo(w, item))
  2401. {
  2402. w.ResetWeaponAnimState();
  2403. HumanCommandMove cm = GetCommand_Move();
  2404. if (cm)
  2405. {
  2406. cm.SetMeleeBlock(false);
  2407. GetMeleeFightLogic().SetBlock(false);
  2408. }
  2409. }
  2410. //! fixes situation where raise is canceling some manipulation with heavy item(ex. TakeItemToHands), forces normal stance
  2411. if (item.IsHeavyBehaviour() && IsRaised())
  2412. {
  2413. HumanCommandMove cm2 = GetCommand_Move();
  2414. if (cm2)
  2415. {
  2416. cm2.ForceStance(DayZPlayerConstants.STANCEIDX_ERECT);
  2417. }
  2418. }
  2419. OnItemInHandsChanged();
  2420. }
  2421. }
  2422. override void EEItemOutOfHands(EntityAI item)
  2423. {
  2424. super.EEItemOutOfHands(item);
  2425. if (IsPlacingLocal())
  2426. {
  2427. GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(TogglePlacingLocal);
  2428. }
  2429. OnItemInHandsChanged();
  2430. }
  2431. PlayerStomach GetStomach()
  2432. {
  2433. return m_PlayerStomach;
  2434. }
  2435. override void CommandHandler(float pDt, int pCurrentCommandID, bool pCurrentCommandFinished)
  2436. {
  2437. EvaluateDamageHit(pCurrentCommandID);
  2438. // lower implement
  2439. super.CommandHandler(pDt,pCurrentCommandID,pCurrentCommandFinished);
  2440. vector playerPosition = PhysicsGetPositionWS();
  2441. HumanInputController hic = GetInputController();
  2442. CheckZeroSoundEvent();
  2443. CheckSendSoundEvent();
  2444. ProcessADDModifier();
  2445. if (m_BrokenLegsJunctureReceived)//was there a change in broken legs state ?
  2446. {
  2447. m_BrokenLegsJunctureReceived = false;
  2448. bool initial = m_BrokenLegState < 0;//negative values indicate initial activation
  2449. if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  2450. {
  2451. DropHeavyItem();
  2452. if (initial)
  2453. {
  2454. BrokenLegForceProne();
  2455. hic.ResetADS();
  2456. GetUApi().GetInputByID(UATempRaiseWeapon).Supress();
  2457. ExitSights();
  2458. }
  2459. }
  2460. }
  2461. GetDayZPlayerInventory().HandleInventory(pDt);
  2462. if (IsFireWeaponRaised() || m_IsHoldingBreath)
  2463. {
  2464. ProcessHoldBreath(pDt);
  2465. }
  2466. ActionManagerBase mngr = GetActionManager();
  2467. if (m_AreHandsLocked && GetHumanInventory().GetEntityInHands())
  2468. {
  2469. m_AreHandsLocked = false;
  2470. }
  2471. // freelook camera memory for weapon raycast
  2472. if (hic.CameraIsFreeLook() && m_DirectionToCursor == vector.Zero)
  2473. {
  2474. m_DirectionToCursor = GetGame().GetCurrentCameraDirection();
  2475. }
  2476. else if (!hic.CameraIsFreeLook() && m_DirectionToCursor != vector.Zero)
  2477. {
  2478. m_DirectionToCursor = vector.Zero;
  2479. }
  2480. if (m_WeaponManager)
  2481. {
  2482. m_WeaponManager.Update(pDt);
  2483. }
  2484. if (m_EmoteManager && IsPlayerSelected())
  2485. {
  2486. m_EmoteManager.Update(pDt);
  2487. }
  2488. if (m_RGSManager)
  2489. {
  2490. m_RGSManager.Update();
  2491. }
  2492. if (m_StanceIndicator)
  2493. {
  2494. m_StanceIndicator.Update();
  2495. }
  2496. if (m_StaminaHandler)
  2497. {
  2498. m_StaminaHandler.Update(pDt, pCurrentCommandID);
  2499. }
  2500. if (m_InjuryHandler)
  2501. {
  2502. m_InjuryHandler.Update(pDt);
  2503. }
  2504. if (m_HCAnimHandler)
  2505. {
  2506. m_HCAnimHandler.Update(pDt, m_MovementState);
  2507. }
  2508. if (m_ShockHandler)
  2509. {
  2510. m_ShockHandler.Update(pDt);
  2511. }
  2512. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
  2513. {
  2514. GetPlayerSoundManagerServer().Update();
  2515. ShockRefill(pDt);
  2516. FreezeCheck();
  2517. }
  2518. GetHumanInventory().Update(pDt);
  2519. if (m_IsDrowning)
  2520. {
  2521. ProcessDrowning(pDt);
  2522. }
  2523. UpdateDelete();
  2524. HandleDamageHit(pCurrentCommandID);
  2525. if (mngr && hic)
  2526. {
  2527. mngr.Update(pCurrentCommandID);
  2528. HumanCommandUnconscious hcu = GetCommand_Unconscious();
  2529. HumanCommandVehicle hcv = GetCommand_Vehicle();
  2530. if (!m_UnconsciousDebug)
  2531. {
  2532. //! When the player should be and is unconscious
  2533. if (m_ShouldBeUnconscious && m_IsUnconscious)
  2534. {
  2535. if (hcu)
  2536. {
  2537. //! Player can start floating while unconscious
  2538. m_Swimming.m_bWasSwimming |= hcu.IsInWater();
  2539. }
  2540. if (m_Swimming.m_bWasSwimming)
  2541. {
  2542. m_LastCommandBeforeUnconscious = DayZPlayerConstants.COMMANDID_SWIM;
  2543. }
  2544. OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
  2545. }
  2546. //! When the player will be unconscious, or is being blocked from being unconscious
  2547. else if (m_ShouldBeUnconscious)
  2548. {
  2549. //! If the player is getting in/out or switching seats, delay unconsciousness until after animation has finished
  2550. bool isTransitioning = hcv && (hcv.IsGettingIn() || hcv.IsGettingOut() || hcv.IsSwitchSeat());
  2551. if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
  2552. {
  2553. OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
  2554. m_IsUnconscious = true;
  2555. OnUnconsciousStart();
  2556. }
  2557. //! Death gate - prevent unlikely occurence of death -> unconsciousness transition
  2558. //! Fall gate - prevent unconciousness animation from playing while falling, doesn't look good
  2559. //! Transition gate - prevent unconciousness while previous command is transitioning
  2560. else if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH && pCurrentCommandID != DayZPlayerConstants.COMMANDID_FALL && !isTransitioning)
  2561. {
  2562. m_LastCommandBeforeUnconscious = pCurrentCommandID;
  2563. if (hcv)
  2564. {
  2565. m_TransportCache = hcv.GetTransport();
  2566. }
  2567. else
  2568. {
  2569. m_TransportCache = null;
  2570. }
  2571. //! TODO: rework vehicle command Knockout back to force player prone after they have exited the vehicle
  2572. m_JumpClimb.CheckAndFinishJump();
  2573. StartCommand_Unconscious(0);
  2574. SetFallYDiff(playerPosition[1]);
  2575. }
  2576. }
  2577. //! When the player is waking up
  2578. else if (m_IsUnconscious)
  2579. {
  2580. //! Make sure the player is actually unconscious
  2581. if (hcu && pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
  2582. {
  2583. OnUnconsciousUpdate(pDt, m_LastCommandBeforeUnconscious);
  2584. //! protection for a player being broken when attempting to wake them up too early into unconsciousness
  2585. if (m_UnconsciousTime > 2)
  2586. {
  2587. int wakeUpStance = DayZPlayerConstants.STANCEIDX_PRONE;
  2588. //! Don't set the stance if we are swimming or in a vehicle, stance change animation could play
  2589. if (m_Swimming.m_bWasSwimming || m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE)
  2590. wakeUpStance = -1;
  2591. hcu.WakeUp(wakeUpStance);
  2592. m_IsUnconscious = false;
  2593. OnUnconsciousStop(pCurrentCommandID);
  2594. }
  2595. }
  2596. else
  2597. {
  2598. //! Maybe instead error out or notify of possible desync?
  2599. if (IsAlive())
  2600. {
  2601. m_IsUnconscious = false;
  2602. OnUnconsciousStop(pCurrentCommandID);
  2603. }
  2604. }
  2605. }
  2606. }
  2607. // quickbar use
  2608. int quickBarSlot = hic.IsQuickBarSlot();
  2609. if (quickBarSlot && IsAlive())
  2610. {
  2611. if (hic.IsQuickBarSingleUse())
  2612. {
  2613. OnQuickBarSingleUse(quickBarSlot);
  2614. //Print("PlayerBase.c IsQuickBarSingleUse - slot: " + quickBarSlot.ToString());
  2615. }
  2616. if (hic.IsQuickBarContinuousUseStart() && ((!GetGame().IsDedicatedServer()) && !GetGame().GetUIManager().GetMenu()))
  2617. {
  2618. OnQuickBarContinuousUseStart(quickBarSlot);
  2619. //Print("PlayerBase.c IsQuickBarContinuousUseStart - slot: " + quickBarSlot.ToString());
  2620. }
  2621. if (hic.IsQuickBarContinuousUseEnd() && ((!GetGame().IsDedicatedServer())))
  2622. {
  2623. OnQuickBarContinuousUseEnd(quickBarSlot);
  2624. //Print("PlayerBase.c IsQuickBarContinuousUseEnd - slot: " + quickBarSlot.ToString());
  2625. }
  2626. }
  2627. /*if ((pCurrentCommandID == DayZPlayerConstants.COMMANDID_ACTION || pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE || pCurrentCommandID == DayZPlayerConstants.COMMANDID_LADDER || pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM))
  2628. {
  2629. mngr.Update(); // checks for suitable action and sets it
  2630. }*/
  2631. }
  2632. if (m_StaminaHandler && hic)
  2633. {
  2634. HumanCommandMove hcm = GetCommand_Move();
  2635. bool isSwimmingOrClimbing = GetCommand_Swim() || GetCommand_Climb() || GetCommand_Ladder();
  2636. bool isStaminaLimitAppliable = hcm || isSwimmingOrClimbing;
  2637. if (isStaminaLimitAppliable)
  2638. {
  2639. bool isRunning = hcm && hcm.GetCurrentMovementSpeed() > 1.0;
  2640. //! only run and higher for movement
  2641. if (isRunning || isSwimmingOrClimbing)
  2642. {
  2643. //! SPRINT: enable/disable - based on stamina; disable also when raised
  2644. if (CanConsumeStamina(EStaminaConsumers.SPRINT) && CanSprint())
  2645. {
  2646. hic.LimitsDisableSprint(false);
  2647. }
  2648. else
  2649. {
  2650. hic.LimitsDisableSprint(true);
  2651. }
  2652. }
  2653. else
  2654. {
  2655. hic.LimitsDisableSprint(!CanSprint());
  2656. }
  2657. }
  2658. }
  2659. //map closing - feel free to move to different "update" if it does not belong here
  2660. if (IsMapOpen())
  2661. {
  2662. if (!GetGame().IsDedicatedServer())
  2663. {
  2664. if (!CfgGameplayHandler.GetUse3DMap() && !GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
  2665. {
  2666. CloseMapEx(false);
  2667. }
  2668. else if (CfgGameplayHandler.GetUse3DMap())
  2669. {
  2670. if (IsMapCallbackCancelInput())
  2671. {
  2672. CloseMapEx(true);
  2673. }
  2674. else if (IsMapCallbackEndInput())
  2675. {
  2676. CloseMapEx(false);
  2677. }
  2678. }
  2679. }
  2680. }
  2681. #ifdef DIAG_DEVELOPER
  2682. if (m_Bot)
  2683. m_Bot.OnUpdate(pDt);
  2684. #endif
  2685. if (m_CheckMeleeItem && (!GetGame().IsDedicatedServer()))
  2686. {
  2687. CheckMeleeItemDamage(m_CheckMeleeItem);
  2688. SetCheckMeleeItem();
  2689. }
  2690. #ifdef DEVELOPER
  2691. TryGetInVehicleDebug();
  2692. #endif
  2693. OnCommandHandlerTick(pDt, pCurrentCommandID);
  2694. }
  2695. #ifdef DEVELOPER
  2696. void SetGetInVehicleDebug(EntityAI ent)
  2697. {
  2698. m_GetInVehicleTransportDebug = Transport.Cast(ent);
  2699. }
  2700. void TryGetInVehicleDebug()
  2701. {
  2702. if (m_GetInVehicleTransportDebug)
  2703. {
  2704. HumanCommandVehicle vehCommand = StartCommand_Vehicle(m_GetInVehicleTransportDebug, 0, 0);
  2705. if (vehCommand)
  2706. {
  2707. vehCommand.SetVehicleType(m_GetInVehicleTransportDebug.GetAnimInstance());
  2708. }
  2709. m_GetInVehicleTransportDebug = null;
  2710. }
  2711. }
  2712. #endif
  2713. //MAP handling
  2714. //! DEPRECATED; terminates map animation callback and re-enables controls
  2715. void CloseMap()
  2716. {
  2717. CloseMapEx(false);
  2718. }
  2719. void CloseMapEx(bool cancelled)
  2720. {
  2721. if (m_hac && !GetMapClosingSyncSent())
  2722. {
  2723. if (ScriptInputUserData.CanStoreInputUserData())
  2724. {
  2725. if (GetGame().IsMultiplayer() && GetGame().IsClient())
  2726. {
  2727. ActionManagerClient mngr_client;
  2728. CastTo(mngr_client, GetActionManager());
  2729. if (cancelled)
  2730. {
  2731. mngr_client.RequestInterruptAction();
  2732. }
  2733. else
  2734. {
  2735. mngr_client.RequestEndAction();
  2736. }
  2737. GetGame().GetMission().RemoveActiveInputExcludes({"map"});
  2738. GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
  2739. }
  2740. else if (!GetGame().IsMultiplayer())
  2741. {
  2742. int command_ID = DayZPlayerConstants.CMD_ACTIONINT_END;
  2743. if (cancelled)
  2744. {
  2745. command_ID = DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT;
  2746. }
  2747. m_hac.InternalCommand(command_ID);
  2748. }
  2749. SetMapClosingSyncSet(true);
  2750. }
  2751. }
  2752. if (!GetGame().IsDedicatedServer())
  2753. {
  2754. if (GetGame().GetUIManager().IsMenuOpen(MENU_MAP))
  2755. {
  2756. GetGame().GetUIManager().FindMenu(MENU_MAP).Close();
  2757. if (m_Hud)
  2758. {
  2759. m_Hud.ShowQuickbarPlayer(true);
  2760. }
  2761. GetGame().GetMission().RemoveActiveInputExcludes({"map"});
  2762. GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.MAP);
  2763. }
  2764. }
  2765. }
  2766. void SetMapOpen(bool state)
  2767. {
  2768. m_MapOpen = state;
  2769. }
  2770. bool IsMapOpen()
  2771. {
  2772. return m_MapOpen;
  2773. }
  2774. void SetMapClosingSyncSet(bool state)
  2775. {
  2776. m_MapClosingSyncSent = state;
  2777. }
  2778. bool GetMapClosingSyncSent()
  2779. {
  2780. return m_MapClosingSyncSent;
  2781. }
  2782. bool IsMapCallbackCancelInput()
  2783. {
  2784. if (IsRaised())
  2785. {
  2786. return true;
  2787. }
  2788. return false;
  2789. }
  2790. bool IsMapCallbackEndInput()
  2791. {
  2792. if (GetUApi().GetInputByID(UADefaultAction).LocalPress() || GetUApi().GetInputByID(UAUIMenu).LocalPress() || GetUApi().GetInputByID(UAGear).LocalPress())
  2793. {
  2794. return true;
  2795. }
  2796. return false;
  2797. }
  2798. MapNavigationBehaviour GetMapNavigationBehaviour()
  2799. {
  2800. return m_MapNavigationBehaviour;
  2801. }
  2802. void MapNavigationItemInPossession(EntityAI item)
  2803. {
  2804. if (GetMapNavigationBehaviour())
  2805. {
  2806. GetMapNavigationBehaviour().OnItemInPlayerPossession(item);
  2807. }
  2808. }
  2809. void MapNavigationItemNotInPossession(EntityAI item)
  2810. {
  2811. if (GetMapNavigationBehaviour())
  2812. {
  2813. GetMapNavigationBehaviour().OnItemNotInPlayerPossession(item);
  2814. }
  2815. }
  2816. void SetCheckMeleeItem(ItemBase item = null)
  2817. {
  2818. m_CheckMeleeItem = item;
  2819. }
  2820. void SetShakesForced(int value)
  2821. {
  2822. m_ShakesForced = value;
  2823. }
  2824. void FreezeCheck()
  2825. {
  2826. int level;
  2827. if (m_ShakesForced > 0)
  2828. {
  2829. level = m_ShakesForced;
  2830. }
  2831. else
  2832. {
  2833. float heat_comfort = GetStatHeatComfort().Get();
  2834. if (heat_comfort <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING)
  2835. {
  2836. float value = Math.InverseLerp(PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING, PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_CRITICAL,heat_comfort);
  2837. level = Math.Lerp(1,7,value);
  2838. level = Math.Clamp(value,1,7);
  2839. /*
  2840. value = Math.Clamp(value,0,1);
  2841. level = Math.Round(value * SHAKE_LEVEL_MAX);//translate from normalized value to levels
  2842. */
  2843. }
  2844. }
  2845. if (level != m_Shakes)
  2846. {
  2847. m_Shakes = level;
  2848. SetSynchDirty();
  2849. }
  2850. }
  2851. override bool IsLanded(int pCurrentCommandID)
  2852. {
  2853. if (super.IsLanded(pCurrentCommandID))
  2854. {
  2855. return true;
  2856. }
  2857. //! Handle fall damage for unconscious
  2858. if (pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS)
  2859. {
  2860. bool wasFalling = m_IsUnconsciousFalling;
  2861. m_IsUnconsciousFalling = PhysicsIsFalling(false);
  2862. return wasFalling && !m_IsUnconsciousFalling;
  2863. }
  2864. //! No fall damage for players currently being damaged, animation is temporary
  2865. return false;
  2866. }
  2867. override bool OnLand(int pCurrentCommandID, FallDamageData fallDamageData)
  2868. {
  2869. if (super.OnLand(pCurrentCommandID, fallDamageData))
  2870. {
  2871. return true;
  2872. }
  2873. //! Nothing happens for unconscious
  2874. //! Nothing happens for being damaged
  2875. return false;
  2876. }
  2877. override bool IsAlreadyInFallingCommand(int pCurrentCommandID)
  2878. {
  2879. if (super.IsAlreadyInFallingCommand(pCurrentCommandID))
  2880. {
  2881. return true;
  2882. }
  2883. //! Don't switch to falling command if unconscious
  2884. //! Don't switch to falling command if being damaged
  2885. return pCurrentCommandID == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || pCurrentCommandID == DayZPlayerConstants.COMMANDID_DAMAGE;
  2886. }
  2887. void OnUnconsciousStart()
  2888. {
  2889. CloseInventoryMenu();
  2890. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  2891. {
  2892. GetGame().GetMission().GetHud().ShowHudUI(false);
  2893. SetInventorySoftLock(true);
  2894. if (m_LastCommandBeforeUnconscious != DayZPlayerConstants.COMMANDID_VEHICLE)
  2895. {
  2896. EntityAI entity_in_hands = GetHumanInventory().GetEntityInHands();
  2897. if (entity_in_hands && CanDropEntity(entity_in_hands) && !IsRestrained() && !IsSurrendered())
  2898. {
  2899. DropItem(ItemBase.Cast(entity_in_hands));
  2900. }
  2901. }
  2902. GetGame().GetSoundScene().SetSoundVolume(0,2);
  2903. m_EffectWidgets.AddSuspendRequest(EffectWidgetSuspends.UNCON);
  2904. }
  2905. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || (!GetGame().IsMultiplayer() && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT))
  2906. {
  2907. SetSynchDirty();
  2908. if (m_LastCommandBeforeUnconscious == DayZPlayerConstants.COMMANDID_VEHICLE)
  2909. {
  2910. if (m_TransportCache)
  2911. m_TransportCache.MarkCrewMemberUnconscious(m_TransportCache.CrewMemberIndex(this));
  2912. }
  2913. // disable voice communication
  2914. GetGame().EnableVoN(this, false);
  2915. if (m_AdminLog)
  2916. {
  2917. m_AdminLog.UnconStart(this);
  2918. }
  2919. // When we fall uncon we force out of block
  2920. if (GetMeleeFightLogic())
  2921. {
  2922. GetMeleeFightLogic().SetBlock(false);
  2923. }
  2924. }
  2925. SetMasterAttenuation("UnconsciousAttenuation");
  2926. if (m_OnUnconsciousStart)
  2927. m_OnUnconsciousStart.Invoke(this);
  2928. }
  2929. void OnUnconsciousStop(int pCurrentCommandID)
  2930. {
  2931. m_UnconRefillModifier =1;
  2932. SetSynchDirty();
  2933. m_UnconsciousTime = 0;
  2934. m_UnconsciousVignetteTarget = 2;
  2935. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  2936. {
  2937. GetGame().GetMission().GetHud().ShowHudUI(true);
  2938. if (pCurrentCommandID != DayZPlayerConstants.COMMANDID_DEATH)
  2939. {
  2940. GetGame().GetSoundScene().SetSoundVolume(g_Game.m_volume_sound,1);
  2941. PPERequesterBank.GetRequester(PPERequester_UnconEffects).Stop();
  2942. GetGame().GetMission().GetHud().ShowQuickbarUI(true);
  2943. if (GetGame().GetUIManager().IsDialogVisible())
  2944. {
  2945. GetGame().GetUIManager().CloseDialog();
  2946. }
  2947. if (GetGame().GetUIManager().IsMenuOpen(MENU_RESPAWN_DIALOGUE))
  2948. {
  2949. GetGame().GetUIManager().FindMenu(MENU_RESPAWN_DIALOGUE).Close();
  2950. }
  2951. }
  2952. SetInventorySoftLock(false);
  2953. m_EffectWidgets.RemoveSuspendRequest(EffectWidgetSuspends.UNCON);
  2954. }
  2955. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
  2956. {
  2957. // enable voice communication
  2958. if (IsAlive())
  2959. GetGame().EnableVoN(this, true);
  2960. if (m_AdminLog)
  2961. {
  2962. m_AdminLog.UnconStop(this);
  2963. }
  2964. }
  2965. SetMasterAttenuation("");
  2966. if (m_OnUnconsciousStop)
  2967. m_OnUnconsciousStop.Invoke(this);
  2968. }
  2969. void OnUnconsciousUpdate(float pDt, int last_command)
  2970. {
  2971. m_UnconsciousTime += pDt;
  2972. if (GetGame().IsServer())
  2973. {
  2974. int shock_simplified = SimplifyShock();
  2975. if (m_ShockSimplified != shock_simplified)
  2976. {
  2977. m_ShockSimplified = shock_simplified;
  2978. SetSynchDirty();
  2979. }
  2980. if (m_UnconsciousTime > PlayerConstants.UNCONSCIOUS_IN_WATER_TIME_LIMIT_TO_DEATH && last_command == DayZPlayerConstants.COMMANDID_SWIM)
  2981. {
  2982. PluginAdminLog adm = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
  2983. adm.PlayerKilledByDrowningUncon(this);
  2984. SetHealth("","",-100);
  2985. }
  2986. }
  2987. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  2988. {
  2989. GetGame().GetMission().GetHud().ShowQuickbarUI(false);
  2990. if (GetPulseType() == EPulseType.REGULAR)
  2991. {
  2992. float shock_simple_normalized = GetSimplifiedShockNormalized();
  2993. float sin = Math.Sin(m_UnconsciousTime * 0.3);
  2994. float sin_normalized = (sin + 1) / 2;
  2995. if (sin_normalized < 0.05)
  2996. {
  2997. m_UnconsciousVignetteTarget = (1 - shock_simple_normalized / 3) * 2/*vignette max*/;
  2998. }
  2999. float vignette = Math.Lerp(2,m_UnconsciousVignetteTarget, sin_normalized);
  3000. m_UnconParam.param1 = vignette;
  3001. PPERequesterBank.GetRequester(PPERequester_UnconEffects).Start(m_UnconParam);
  3002. }
  3003. }
  3004. }
  3005. int SimplifyShock()
  3006. {
  3007. int shock = Math.Lerp(0, SIMPLIFIED_SHOCK_CAP, GetHealth("","Shock") / GetMaxHealth("","Shock"));
  3008. shock = Math.Clamp(shock, 0, SIMPLIFIED_SHOCK_CAP);
  3009. return shock;
  3010. }
  3011. float GetSimplifiedShockNormalized()
  3012. {
  3013. return (m_ShockSimplified / SIMPLIFIED_SHOCK_CAP);
  3014. }
  3015. override bool IsUnconscious()
  3016. {
  3017. return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_UNCONSCIOUS || m_IsUnconscious;
  3018. }
  3019. override bool IsUnconsciousStateOnly()
  3020. {
  3021. return m_IsUnconscious;
  3022. }
  3023. override bool CanBeTargetedByAI(EntityAI ai)
  3024. {
  3025. #ifdef DIAG_DEVELOPER
  3026. if (!m_CanBeTargetedDebug)
  3027. {
  3028. return false;
  3029. }
  3030. #endif
  3031. return super.CanBeTargetedByAI(ai) && !IsUnconscious() && !IsInVehicle();
  3032. }
  3033. void GiveShock(float shock)
  3034. {
  3035. AddHealth("","Shock",shock);
  3036. }
  3037. void OnRestrainStart()
  3038. {
  3039. CloseInventoryMenu();
  3040. GetGame().GetMission().RemoveActiveInputExcludes({"inventory"},true);
  3041. GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
  3042. }
  3043. //! functionality moved to ShockMdfr::OnTick
  3044. void ShockRefill(float pDt);
  3045. //BrokenLegs
  3046. // -----------------------
  3047. eBrokenLegs GetBrokenLegs()
  3048. {
  3049. return Math.AbsInt(m_BrokenLegState);//negative value denotes first time activation
  3050. }
  3051. //Server side
  3052. void SetBrokenLegs(int stateId)
  3053. {
  3054. m_BrokenLegState = stateId;
  3055. DayZPlayerSyncJunctures.SendBrokenLegsEx(this, stateId);
  3056. eBrokenLegs state = GetBrokenLegs();//m_BrokenLegState can go bellow 0, cannot be used directly
  3057. if (state == eBrokenLegs.NO_BROKEN_LEGS)
  3058. {
  3059. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
  3060. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
  3061. }
  3062. else if (state == eBrokenLegs.BROKEN_LEGS)
  3063. {
  3064. SetLegHealth();
  3065. }
  3066. else if (state == eBrokenLegs.BROKEN_LEGS_SPLINT)
  3067. {
  3068. // handle splint here
  3069. }
  3070. SetSynchDirty();
  3071. }
  3072. //Update of state
  3073. void UpdateBrokenLegs(int stateId)
  3074. {
  3075. eBrokenLegs state = GetBrokenLegs();
  3076. //Raise broken legs flag and force to prone
  3077. if (state != eBrokenLegs.NO_BROKEN_LEGS)
  3078. {
  3079. if (state == eBrokenLegs.BROKEN_LEGS_SPLINT)
  3080. {
  3081. if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE)
  3082. {
  3083. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
  3084. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
  3085. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask | eInjuryOverrides.BROKEN_LEGS_SPLINT;
  3086. }
  3087. m_InjuryHandler.CheckValue(false);
  3088. }
  3089. else if (state == eBrokenLegs.BROKEN_LEGS)
  3090. {
  3091. if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE)
  3092. {
  3093. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
  3094. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
  3095. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask | eInjuryOverrides.BROKEN_LEGS;
  3096. }
  3097. BrokenLegWalkShock();
  3098. m_InjuryHandler.CheckValue(false);
  3099. }
  3100. }
  3101. else if (state == eBrokenLegs.NO_BROKEN_LEGS)
  3102. {
  3103. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS;
  3104. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.BROKEN_LEGS_SPLINT;
  3105. }
  3106. }
  3107. void BreakLegSound()
  3108. {
  3109. PlaySoundSet(m_BrokenLegSound, SOUND_BREAK_LEG, 0.1, 0.1);
  3110. }
  3111. void BrokenLegForceProne(bool forceOverride = false)
  3112. {
  3113. if (!IsInWater() && !IsSwimming() && !IsClimbingLadder() && !IsInVehicle() && !IsClimbing() && DayZPlayerUtils.PlayerCanChangeStance(this, DayZPlayerConstants.STANCEIDX_PRONE))
  3114. {
  3115. if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE && m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
  3116. {
  3117. EntityAI attachment;
  3118. Class.CastTo(attachment, GetItemOnSlot("Splint_Right"));
  3119. if (attachment && attachment.GetType() == "Splint_Applied")
  3120. {
  3121. attachment.Delete();
  3122. }
  3123. m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_INITIAL_SHOCK);
  3124. m_ShockHandler.CheckValue(true);
  3125. if (m_ShockHandler.GetCurrentShock() >= 25) //Prevent conflict with unconsciousness by not forcing prone when going uncon (25 shock or less left)
  3126. {
  3127. //calcels user action
  3128. HumanCommandActionCallback cmd = GetCommand_Action();
  3129. if (cmd)
  3130. {
  3131. cmd.Cancel();
  3132. }
  3133. StopHandEvent();
  3134. //Get command move and verify not null
  3135. HumanCommandMove hcm = StartCommand_Move();//not sure why this is here
  3136. hcm = GetCommand_Move();
  3137. if (hcm)
  3138. {
  3139. hcm.ForceStance(DayZPlayerConstants.STANCEIDX_PRONE);
  3140. }
  3141. }
  3142. }
  3143. }
  3144. m_JumpClimb.CheckAndFinishJump();
  3145. }
  3146. //Used to inflict shock when player is walking (only inflicted on Update timer)
  3147. void BrokenLegWalkShock()
  3148. {
  3149. //No need to pursue here if player is prone as the following logic is not applied
  3150. if (m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_PRONE && m_MovementState.m_iStanceIdx != DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
  3151. {
  3152. float avgLegHealth = GetHealth("RightLeg","") + GetHealth("LeftLeg","") + GetHealth("RightFoot","") + GetHealth("LeftFoot","");
  3153. avgLegHealth *= 0.25; //divide by 4 to make the average leg health;
  3154. if (IsSwimming())
  3155. {
  3156. //swimming other than forward is not detectable in script other than through velocity check
  3157. vector v;
  3158. PhysicsGetVelocity(v);
  3159. if (v.LengthSq() > 0)
  3160. {
  3161. m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_SHOCK_SWIM);
  3162. }
  3163. }
  3164. else if (m_MovementState.m_iMovement != 0)
  3165. {
  3166. if (IsClimbingLadder())
  3167. {
  3168. MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK);
  3169. }
  3170. else if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDERECT)
  3171. {
  3172. if (m_MovementState.m_iMovement > 1)//only jog and faster
  3173. {
  3174. MovingShock(avgLegHealth, PlayerConstants.BROKEN_LEGS_HIGH_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_MID_SHOCK_WALK, PlayerConstants.BROKEN_LEGS_LOW_SHOCK_WALK);
  3175. }
  3176. }
  3177. else if (m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH || m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
  3178. {
  3179. //any speed other than idle
  3180. 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);
  3181. }
  3182. }
  3183. else
  3184. {
  3185. //Here apply shock if player is standing or crouched and STANDING STILL
  3186. m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_STAND_SHOCK);
  3187. }
  3188. m_ShockHandler.CheckValue(true);
  3189. }
  3190. }
  3191. //Always use the same thresholds but allow passing of different shock values
  3192. void MovingShock(float legHealth, float highShock, float midShock, float lowShock)
  3193. {
  3194. if (legHealth <= PlayerConstants.BROKEN_LEGS_LOW_HEALTH_THRESHOLD)
  3195. {
  3196. //Inflict "high shock"
  3197. m_ShockHandler.SetShock(highShock);
  3198. }
  3199. else if (legHealth >= PlayerConstants.BROKEN_LEGS_HIGH_HEALTH_THRESHOLD)
  3200. {
  3201. //Inflict "low shock"
  3202. m_ShockHandler.SetShock(lowShock);
  3203. }
  3204. else
  3205. {
  3206. //If neither high nore low, inflict "mid shock"
  3207. m_ShockHandler.SetShock(midShock);
  3208. }
  3209. }
  3210. void DealShock(float dmg)
  3211. {
  3212. Param1<float> damage = new Param1<float>(0);
  3213. damage.param1 = dmg;
  3214. GetGame().RPCSingleParam(this, ERPCs.RPC_SHOCK, damage, true, GetIdentity());
  3215. }
  3216. //Prevent player from picking up heavy items when legs are broken
  3217. override bool CanPickupHeavyItem(notnull EntityAI item)
  3218. {
  3219. if (item.IsHeavyBehaviour() && (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS || GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS_SPLINT))
  3220. return false;
  3221. return super.CanPickupHeavyItem(item);
  3222. }
  3223. //Set all leg zones' health to 0 in order to limit emergent behaviour and prevent confusion as to how broken legs really work
  3224. void SetLegHealth()
  3225. {
  3226. SetHealth("RightLeg", "", 0);
  3227. SetHealth("RightFoot", "", 0);
  3228. SetHealth("LeftLeg", "", 0);
  3229. SetHealth("LeftFoot", "", 0);
  3230. }
  3231. void DropHeavyItem()
  3232. {
  3233. ItemBase itemInHands = GetItemInHands();
  3234. if (itemInHands && itemInHands.IsHeavyBehaviour())
  3235. DropItem(itemInHands);
  3236. }
  3237. bool IsWearingSplint()
  3238. {
  3239. EntityAI attachment;
  3240. Class.CastTo(attachment, GetItemOnSlot("Splint_Right"));
  3241. if (attachment && attachment.GetType() == "Splint_Applied")
  3242. {
  3243. return true;
  3244. }
  3245. return false;
  3246. }
  3247. // -----------------------
  3248. override void OnCommandSwimStart()
  3249. {
  3250. ItemBase itemInHands = GetItemInHands();
  3251. if (itemInHands)
  3252. {
  3253. if (itemInHands.IsHeavyBehaviour())
  3254. {
  3255. TryHideItemInHands(false);
  3256. DropHeavyItem();
  3257. }
  3258. else
  3259. {
  3260. TryHideItemInHands(true);
  3261. }
  3262. itemInHands.OnItemInHandsPlayerSwimStart(this);
  3263. }
  3264. m_AnimCommandStarting = HumanMoveCommandID.CommandSwim;
  3265. if (GetInventory())
  3266. GetInventory().LockInventory(LOCK_FROM_SCRIPT);
  3267. CloseInventoryMenu();
  3268. GetDayZGame().GetBacklit().OnSwimmingStart();
  3269. AbortWeaponEvent();
  3270. GetWeaponManager().DelayedRefreshAnimationState(10);
  3271. RequestHandAnimationStateRefresh();
  3272. GetGame().GetMission().AddActiveInputExcludes({"swimming"});
  3273. }
  3274. override void OnCommandSwimFinish()
  3275. {
  3276. TryHideItemInHands(false, true);
  3277. if (GetInventory())
  3278. GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
  3279. GetDayZGame().GetBacklit().OnSwimmingStop();
  3280. GetWeaponManager().RefreshAnimationState();
  3281. GetGame().GetMission().RemoveActiveInputExcludes({"swimming"});
  3282. }
  3283. override void OnCommandLadderStart()
  3284. {
  3285. m_AnimCommandStarting = HumanMoveCommandID.CommandLadder;
  3286. TryHideItemInHands(true);
  3287. if (GetInventory())
  3288. GetInventory().LockInventory(LOCK_FROM_SCRIPT);
  3289. CloseInventoryMenu();
  3290. GetGame().GetMission().AddActiveInputExcludes({"ladderclimbing"});
  3291. }
  3292. override void OnCommandLadderFinish()
  3293. {
  3294. TryHideItemInHands(false, true);
  3295. if (GetInventory())
  3296. GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
  3297. GetGame().GetMission().RemoveActiveInputExcludes({"ladderclimbing"});
  3298. }
  3299. override void OnCommandFallStart()
  3300. {
  3301. m_AnimCommandStarting = HumanMoveCommandID.CommandFall;
  3302. if (GetInventory())
  3303. GetInventory().LockInventory(LOCK_FROM_SCRIPT);
  3304. CloseInventoryMenu();
  3305. AbortWeaponEvent();
  3306. GetWeaponManager().DelayedRefreshAnimationState(10);
  3307. RequestHandAnimationStateRefresh();
  3308. }
  3309. override void OnCommandFallFinish()
  3310. {
  3311. if (GetInventory())
  3312. GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
  3313. GetWeaponManager().RefreshAnimationState();
  3314. }
  3315. override void OnCommandClimbStart()
  3316. {
  3317. m_AnimCommandStarting = HumanMoveCommandID.CommandClimb;
  3318. if (GetInventory())
  3319. GetInventory().LockInventory(LOCK_FROM_SCRIPT);
  3320. CloseInventoryMenu();
  3321. AbortWeaponEvent();
  3322. GetWeaponManager().DelayedRefreshAnimationState(10);
  3323. RequestHandAnimationStateRefresh();
  3324. }
  3325. override void OnCommandClimbFinish()
  3326. {
  3327. if (GetInventory())
  3328. GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
  3329. GetWeaponManager().RefreshAnimationState();
  3330. }
  3331. override void OnCommandVehicleStart()
  3332. {
  3333. m_AnimCommandStarting = HumanMoveCommandID.CommandVehicle;
  3334. if (GetInventory())
  3335. GetInventory().LockInventory(LOCK_FROM_SCRIPT);
  3336. CloseInventoryMenu();
  3337. ItemBase itemInHand = GetItemInHands();
  3338. EntityAI itemOnHead = FindAttachmentBySlotName("Headgear");
  3339. if (itemInHand && itemInHand.GetCompEM())
  3340. itemInHand.GetCompEM().SwitchOff();
  3341. TryHideItemInHands(true);
  3342. if (itemOnHead && itemOnHead.GetCompEM())
  3343. itemOnHead.GetCompEM().SwitchOff();
  3344. GetGame().GetMission().AddActiveInputExcludes({"vehicledriving"});
  3345. }
  3346. override void OnCommandVehicleFinish()
  3347. {
  3348. if (GetInventory())
  3349. GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
  3350. TryHideItemInHands(false, true);
  3351. GetGame().GetMission().RemoveActiveInputExcludes({"vehicledriving"});
  3352. }
  3353. override void OnCommandMelee2Start()
  3354. {
  3355. m_AnimCommandStarting = HumanMoveCommandID.CommandMelee2;
  3356. m_IsFighting = true;
  3357. AbortWeaponEvent();
  3358. GetWeaponManager().DelayedRefreshAnimationState(10);
  3359. RequestHandAnimationStateRefresh();
  3360. }
  3361. override void OnCommandMelee2Finish()
  3362. {
  3363. RunFightBlendTimer();
  3364. GetWeaponManager().RefreshAnimationState();
  3365. }
  3366. override void OnCommandDeathStart()
  3367. {
  3368. m_AnimCommandStarting = HumanMoveCommandID.CommandDeath;
  3369. AbortWeaponEvent();
  3370. GetWeaponManager().DelayedRefreshAnimationState(10);
  3371. RequestHandAnimationStateRefresh();
  3372. super.OnCommandDeathStart();
  3373. }
  3374. override void OnJumpStart()
  3375. {
  3376. m_ActionManager.OnJumpStart();
  3377. AbortWeaponEvent();
  3378. GetWeaponManager().DelayedRefreshAnimationState(10);
  3379. RequestHandAnimationStateRefresh();
  3380. CloseMapEx(true);
  3381. }
  3382. override void OnJumpEnd(int pLandType = 0)
  3383. {
  3384. if (m_PresenceNotifier)
  3385. {
  3386. switch (pLandType)
  3387. {
  3388. case HumanCommandFall.LANDTYPE_NONE:
  3389. case HumanCommandFall.LANDTYPE_LIGHT:
  3390. m_PresenceNotifier.ProcessEvent(EPresenceNotifierNoiseEventType.LAND_LIGHT);
  3391. break;
  3392. case HumanCommandFall.LANDTYPE_MEDIUM:
  3393. case HumanCommandFall.LANDTYPE_HEAVY:
  3394. m_PresenceNotifier.ProcessEvent(EPresenceNotifierNoiseEventType.LAND_HEAVY);
  3395. break;
  3396. }
  3397. }
  3398. GetWeaponManager().RefreshAnimationState();
  3399. }
  3400. bool IsStance(int stance, int stanceMask)
  3401. {
  3402. return ((1 << stance) & stanceMask) != 0;
  3403. }
  3404. override void OnStanceChange(int previousStance, int newStance)
  3405. {
  3406. int prone = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE;
  3407. int notProne = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_RAISEDERECT | DayZPlayerConstants.STANCEMASK_RAISEDCROUCH;
  3408. if (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_PRONE) && IsStance(newStance, DayZPlayerConstants.STANCEMASK_ERECT))
  3409. m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_FROM_PRONE;
  3410. if (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_PRONE) && IsStance(previousStance, DayZPlayerConstants.STANCEMASK_CROUCH) || (IsStance(previousStance, DayZPlayerConstants.STANCEMASK_CROUCH) && IsStance(newStance, DayZPlayerConstants.STANCEMASK_ERECT)))
  3411. m_SprintedTimePerStanceMin = PlayerConstants.FULL_SPRINT_DELAY_FROM_CROUCH;
  3412. if ((IsStance(previousStance, prone) && IsStance(newStance, notProne)) || (IsStance(previousStance, notProne) && IsStance(newStance, prone)))
  3413. {
  3414. AbortWeaponEvent();
  3415. GetWeaponManager().RefreshAnimationState();
  3416. }
  3417. }
  3418. override bool CanChangeStance(int previousStance, int newStance)
  3419. {
  3420. // Check if the player is playing a throwing animation
  3421. if (GetThrowing().IsThrowingAnimationPlaying())
  3422. {
  3423. return false;
  3424. }
  3425. // don't allow base stance change, only raised hands change
  3426. if (IsRolling())
  3427. {
  3428. if (Math.AbsInt(previousStance - newStance) == 3)
  3429. return true;
  3430. return false;
  3431. }
  3432. // Check if the player is going to crouch or raised crouch
  3433. if (newStance == DayZPlayerConstants.STANCEIDX_CROUCH || newStance == DayZPlayerConstants.STANCEIDX_RAISEDCROUCH)
  3434. {
  3435. return GetCurrentWaterLevel() <= GetDayZPlayerType().CommandSwimSettingsW().m_fToErectLevel;
  3436. }
  3437. // Check if the player is going to prone
  3438. if (newStance == DayZPlayerConstants.STANCEIDX_PRONE || newStance == DayZPlayerConstants.STANCEIDX_RAISEDPRONE)
  3439. {
  3440. return GetCurrentWaterLevel() <= GetDayZPlayerType().CommandSwimSettingsW().m_fToCrouchLevel;
  3441. }
  3442. // The player can change stance if none of the conditions above are met
  3443. return true;
  3444. }
  3445. override void OnCommandMoveStart()
  3446. {
  3447. if (GetGame().IsServer())
  3448. {
  3449. //In case player changes stance through a different command, we refresh the anim overrides
  3450. int prone = DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE;
  3451. if (!IsPlayerInStance(prone))
  3452. {
  3453. m_InjuryHandler.m_ForceInjuryAnimMask = m_InjuryHandler.m_ForceInjuryAnimMask & ~eInjuryOverrides.PRONE_ANIM_OVERRIDE;
  3454. ForceUpdateInjuredState();
  3455. }
  3456. }
  3457. }
  3458. override bool CanRoll()
  3459. {
  3460. if (!CanConsumeStamina(EStaminaConsumers.ROLL))
  3461. return false;
  3462. if (IsInFBEmoteState() || m_EmoteManager.m_MenuEmote)
  3463. {
  3464. return false;
  3465. }
  3466. return IsPlayerInStance(DayZPlayerConstants.STANCEMASK_PRONE | DayZPlayerConstants.STANCEMASK_RAISEDPRONE) && GetCommand_Move() && !GetCommand_Move().IsOnBack();
  3467. }
  3468. override void OnRollStart(bool isToTheRight)
  3469. {
  3470. DepleteStamina(EStaminaModifiers.ROLL);
  3471. if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  3472. m_ShockHandler.SetShock(PlayerConstants.BROKEN_LEGS_ROLL_SHOCK);
  3473. }
  3474. override void OnRollFinish()
  3475. {
  3476. }
  3477. void OnJumpOutVehicleFinish(float carSpeed)
  3478. {
  3479. string surfaceType;
  3480. int liquidType;
  3481. GetGame().SurfaceUnderObject(this, surfaceType, liquidType);
  3482. }
  3483. void OnVehicleSwitchSeat(int seatIndex)
  3484. {
  3485. }
  3486. override void OnVehicleSeatDriverEnter()
  3487. {
  3488. m_IsVehicleSeatDriver = true;
  3489. if (m_Hud)
  3490. m_Hud.ShowVehicleInfo();
  3491. #ifdef FEATURE_NETWORK_RECONCILIATION
  3492. PlayerIdentity identity = GetIdentity();
  3493. if (identity)
  3494. {
  3495. Pawn pawn = Pawn.Cast(GetParent());
  3496. //! Hand off control to the vehicle - null is valid
  3497. identity.Possess(pawn);
  3498. }
  3499. #endif
  3500. }
  3501. override void OnVehicleSeatDriverLeft()
  3502. {
  3503. #ifdef FEATURE_NETWORK_RECONCILIATION
  3504. PlayerIdentity identity = GetIdentity();
  3505. //! Don't possess the player if we are in the vehicle and unconscious, we are still the driver!
  3506. if (identity && !m_ShouldBeUnconscious)
  3507. {
  3508. //! And now we want to resume control of the player
  3509. identity.Possess(this);
  3510. }
  3511. #endif
  3512. m_IsVehicleSeatDriver = false;
  3513. if (m_Hud)
  3514. m_Hud.HideVehicleInfo();
  3515. }
  3516. override void OnThrowingModeChange(bool change_to_enabled)
  3517. {
  3518. if (change_to_enabled)
  3519. {
  3520. PlacingCancelLocal();
  3521. PlacingCancelServer();
  3522. }
  3523. }
  3524. override void EOnFrame(IEntity other, float timeSlice)
  3525. {
  3526. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  3527. {
  3528. #ifndef NO_GUI
  3529. m_Hud.Update(timeSlice);
  3530. if (IsControlledPlayer() && m_EffectWidgets && m_EffectWidgets.IsAnyEffectRunning())
  3531. {
  3532. m_EffectWidgets.Update(timeSlice);
  3533. }
  3534. #endif
  3535. if (m_UndergroundHandler)
  3536. m_UndergroundHandler.Tick(timeSlice);
  3537. if (m_UndergroundBunkerHandler)
  3538. m_UndergroundBunkerHandler.Tick(timeSlice);
  3539. }
  3540. if (m_InEffectAreaType != 0 && GetGame().IsServer())
  3541. OnUpdateEffectAreaServer(timeSlice);
  3542. }
  3543. override void EOnPostFrame(IEntity other, int extra)
  3544. {
  3545. float delta_time = (GetGame().GetTime() - m_LastPostFrameTickTime) / 1000;
  3546. m_LastPostFrameTickTime = GetGame().GetTime();
  3547. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  3548. {
  3549. if (GetDamageDealtEffect())
  3550. {
  3551. if (IsAlive())
  3552. GetDamageDealtEffect().Update(delta_time);
  3553. else
  3554. delete GetDamageDealtEffect();
  3555. }
  3556. if (m_EffectRadial)
  3557. {
  3558. if (IsAlive())
  3559. {
  3560. m_EffectRadial.Update(delta_time);
  3561. }
  3562. else
  3563. m_EffectRadial = null;
  3564. }
  3565. if (GetFlashbangEffect())
  3566. {
  3567. if (IsAlive())
  3568. {
  3569. GetFlashbangEffect().Update(delta_time);
  3570. }
  3571. else
  3572. {
  3573. GetFlashbangEffect().Stop();
  3574. delete GetFlashbangEffect();
  3575. }
  3576. }
  3577. if (GetShockEffect())
  3578. {
  3579. if (IsAlive())
  3580. GetShockEffect().Update(delta_time);
  3581. else
  3582. delete GetShockEffect();
  3583. }
  3584. m_InventoryActionHandler.OnUpdate();
  3585. }
  3586. #ifdef DIAG_DEVELOPER
  3587. DiagOnPostFrame(other, extra);
  3588. #endif
  3589. }
  3590. #ifdef DIAG_DEVELOPER
  3591. protected void DiagOnPostFrame(IEntity other, int extra)
  3592. {
  3593. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  3594. {
  3595. if (m_WeaponDebug)
  3596. {
  3597. m_WeaponDebug.OnPostFrameUpdate();
  3598. }
  3599. if (GetBleedingManagerRemote())
  3600. {
  3601. GetBleedingManagerRemote().OnUpdate();
  3602. }
  3603. if (m_MeleeCombat)
  3604. {
  3605. if (DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG))
  3606. {
  3607. m_MeleeDebug = true;
  3608. m_MeleeCombat.Debug(GetItemInHands(), m_MeleeCombat.GetHitType());
  3609. }
  3610. else if (!DiagMenu.GetBool(DiagMenuIDs.MELEE_DEBUG) && m_MeleeDebug)
  3611. {
  3612. m_MeleeDebug = false;
  3613. m_MeleeCombat.Debug(GetItemInHands(), m_MeleeCombat.GetHitType());
  3614. }
  3615. }
  3616. if (DiagMenu.GetBool(DiagMenuIDs.SOUNDS_ITEM_IMPACT_SOUNDS))
  3617. InventoryItem.DrawImpacts();
  3618. if (GetPluginManager())
  3619. {
  3620. PluginDrawCheckerboard drawCheckerboard = PluginDrawCheckerboard.Cast(GetPluginManager().GetPluginByType(PluginDrawCheckerboard));
  3621. if (drawCheckerboard && !drawCheckerboard.IsActive())
  3622. {
  3623. drawCheckerboard.ShowWidgets(DiagMenu.GetBool(DiagMenuIDs.MISC_DRAW_CHECKERBOARD));
  3624. }
  3625. }
  3626. if (m_PresenceNotifier)
  3627. {
  3628. m_PresenceNotifier.EnableDebug(DiagMenu.GetBool(DiagMenuIDs.MISC_PRESENCE_NOTIFIER_DBG));
  3629. }
  3630. if (m_TargetTemperatureDiag)
  3631. {
  3632. m_TargetTemperatureDiag.ShowDebug(DiagMenu.GetBool(DiagMenuIDs.MISC_TARGET_TEMPERATURE));
  3633. }
  3634. if (DiagMenu.GetBool(DiagMenuIDs.TRIGGER_PLAYER_DEBUG))
  3635. {
  3636. vector minmax[2];
  3637. GetCollisionBox(minmax);
  3638. int color = COLOR_RED_A;
  3639. if (m_IsInsideTrigger)
  3640. color = COLOR_GREEN_A;
  3641. Shape dbgShape = Debug.DrawBoxEx(minmax[0], minmax[1], color, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE|ShapeFlags.ONCE);
  3642. vector mat[4];
  3643. GetTransform(mat);
  3644. dbgShape.CreateMatrix(mat);
  3645. dbgShape.SetMatrix(mat);
  3646. }
  3647. }
  3648. if (m_Environment && m_Environment.m_Debug)
  3649. {
  3650. #ifdef SERVER
  3651. EnvDebugData envDebugData = m_Environment.GetEnvDebugData();
  3652. GetGame().RPCSingleParam(this, ERPCs.DIAG_MISC_ENVIRONMENT_DEBUG_DATA, envDebugData, false, GetIdentity());
  3653. #else
  3654. m_Environment.ShowEnvDebugPlayerInfo(DiagMenu.GetBool(DiagMenuIDs.MISC_ENVIRONMENT_DEBUG));
  3655. #endif
  3656. }
  3657. if (m_FallDamage && m_FallDamage.m_Debug)
  3658. {
  3659. #ifdef SERVER
  3660. FallDamageDebugData fallDamageDebugData = m_FallDamage.GetFallDamageDebugData();
  3661. GetGame().RPCSingleParam(this, ERPCs.DIAG_MISC_FALLDAMAGE_DEBUG_DATA, fallDamageDebugData, false, GetIdentity());
  3662. #else
  3663. m_FallDamage.ShowFallDamageDebugInfo(DiagMenu.GetBool(DiagMenuIDs.MISC_FALLDAMAGE_DEBUG));
  3664. #endif
  3665. }
  3666. }
  3667. override void OnEnterTrigger(ScriptedEntity trigger)
  3668. {
  3669. super.OnEnterTrigger(trigger);
  3670. ++m_IsInsideTrigger;
  3671. }
  3672. override void OnLeaveTrigger(ScriptedEntity trigger)
  3673. {
  3674. super.OnLeaveTrigger(trigger);
  3675. --m_IsInsideTrigger;
  3676. }
  3677. #endif
  3678. void StaminaHUDNotifier(bool show)
  3679. {
  3680. if (m_Hud)
  3681. m_Hud.SetStaminaBarVisibility(show);
  3682. }
  3683. override void DepleteStamina(EStaminaModifiers modifier, float dT = -1)
  3684. {
  3685. if (GetStaminaHandler())
  3686. GetStaminaHandler().DepleteStamina(modifier,dT);
  3687. }
  3688. override bool CanConsumeStamina(EStaminaConsumers consumer)
  3689. {
  3690. if (!GetStaminaHandler())
  3691. return false;
  3692. bool val = (GetStaminaHandler().HasEnoughStaminaFor(consumer) && !IsRestrained() && !IsInFBEmoteState());
  3693. if (!val)
  3694. StaminaHUDNotifier(false);
  3695. return val;
  3696. }
  3697. override bool CanStartConsumingStamina(EStaminaConsumers consumer)
  3698. {
  3699. if (!GetStaminaHandler())
  3700. return false;
  3701. bool val = (GetStaminaHandler().HasEnoughStaminaToStart(consumer) && !IsRestrained() && !IsInFBEmoteState());
  3702. if (!val)
  3703. StaminaHUDNotifier(false);
  3704. return val;
  3705. }
  3706. override bool CanClimb(int climbType, SHumanCommandClimbResult climbRes)
  3707. {
  3708. if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  3709. return false;
  3710. if (climbType == 1 && !CanConsumeStamina(EStaminaConsumers.VAULT))
  3711. return false;
  3712. //! vault from water allowed
  3713. if (IsSwimming())
  3714. return true;
  3715. if (climbType == 2 && (!CanConsumeStamina(EStaminaConsumers.CLIMB) || GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS))
  3716. return false;
  3717. if (climbType > 0 && m_InjuryHandler && m_InjuryHandler.GetInjuryAnimValue() >= InjuryAnimValues.LVL3)
  3718. return false;
  3719. return super.CanClimb(climbType,climbRes);
  3720. }
  3721. override bool CanJump()
  3722. {
  3723. if (GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS)
  3724. {
  3725. return false;
  3726. }
  3727. if (!CanConsumeStamina(EStaminaConsumers.JUMP))
  3728. return false;
  3729. //! disables jump when player is significantly injured
  3730. if (m_InjuryHandler && m_InjuryHandler.GetInjuryAnimValue() >= InjuryAnimValues.LVL3)
  3731. return false;
  3732. if (IsInFBEmoteState() || m_EmoteManager.m_MenuEmote)
  3733. {
  3734. return false;
  3735. }
  3736. return super.CanJump();
  3737. }
  3738. bool IsJumpInProgress()
  3739. {
  3740. return m_JumpClimb.m_bIsJumpInProgress;
  3741. }
  3742. bool IsTargetInActiveRefresherRange(EntityAI target)
  3743. {
  3744. array<vector> temp = new array<vector>;
  3745. temp = GetGame().GetMission().GetActiveRefresherLocations();
  3746. int count = temp.Count();
  3747. if (count > 0)
  3748. {
  3749. vector pos = target.GetPosition();
  3750. for (int i = 0; i < count; i++)
  3751. {
  3752. if (vector.Distance(pos,temp.Get(i)) < GameConstants.REFRESHER_RADIUS)
  3753. return true;
  3754. }
  3755. return false;
  3756. }
  3757. else
  3758. {
  3759. return false;
  3760. }
  3761. }
  3762. void RequestHandAnimationStateRefresh()
  3763. {
  3764. if ((GetGame().IsMultiplayer() && GetGame().IsServer()))
  3765. {
  3766. m_RefreshAnimStateIdx++;
  3767. if (m_RefreshAnimStateIdx > 3)
  3768. m_RefreshAnimStateIdx = 0;
  3769. SetSynchDirty();
  3770. }
  3771. }
  3772. void RefreshHandAnimationState(int delay = 0)
  3773. {
  3774. if (delay == 0)
  3775. {
  3776. GetItemAccessor().OnItemInHandsChanged(true);
  3777. GetItemAccessor().ResetWeaponInHands();
  3778. }
  3779. else
  3780. {
  3781. GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(RefreshHandAnimationState,delay,false,0);
  3782. }
  3783. }
  3784. // -------------------------------------------------------------------------
  3785. // USER ACTIONS
  3786. // -------------------------------------------------------------------------
  3787. bool IsFacingTarget(Object target)
  3788. {
  3789. vector pdir = GetDirection();
  3790. vector ptv = target.GetPosition() - GetPosition();
  3791. pdir.Normalize();
  3792. ptv.Normalize();
  3793. if (Math.AbsFloat(pdir[0]-ptv[0]) < 0.5 && Math.AbsFloat(pdir[2]-ptv[2]) < 0.5)
  3794. {
  3795. return true;
  3796. }
  3797. return false;
  3798. }
  3799. //---------------------------------------------------------
  3800. void OnQuickBarSingleUse(int slotClicked)
  3801. {
  3802. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
  3803. return;
  3804. if (m_AreHandsLocked)
  3805. return; //Player is in the short window of time after interrupting placement of an item and before getting it back in hands
  3806. if (GetInventory().IsInventoryLocked() || IsEmotePlaying())
  3807. return;
  3808. if (GetThrowing().IsThrowingModeEnabled() || GetThrowing().IsThrowingAnimationPlaying())
  3809. return;
  3810. if (IsRaised() || GetCommand_Melee() || IsSwimming() || IsClimbingLadder() || IsClimbing() || IsRestrained() || IsRestrainPrelocked())
  3811. return;
  3812. if (GetDayZPlayerInventory().IsProcessing() || IsItemsToDelete())
  3813. return;
  3814. if (GetActionManager().GetRunningAction() != null)
  3815. return;
  3816. if (GetWeaponManager() && GetWeaponManager().IsRunning())
  3817. return;
  3818. if (!ScriptInputUserData.CanStoreInputUserData())
  3819. return;
  3820. //TODO MW change locking method
  3821. //if (GetDayZPlayerInventory().HasLockedHands())
  3822. // return;
  3823. EntityAI quickBarEntity = GetQuickBarEntity(slotClicked - 1);//GetEntityInQuickBar(slotClicked - 1);
  3824. if (!quickBarEntity)
  3825. return;
  3826. Magazine mag;
  3827. Weapon_Base wpn;
  3828. if (Class.CastTo(mag, quickBarEntity) && Class.CastTo(wpn, mag.GetHierarchyParent()))
  3829. return;
  3830. EntityAI inHandEntity = GetHumanInventory().GetEntityInHands();
  3831. if (!GetDayZPlayerInventory().IsIdle())
  3832. return; // player is already performing some animation
  3833. InventoryLocation handInventoryLocation = new InventoryLocation;
  3834. handInventoryLocation.SetHands(this,quickBarEntity);
  3835. if (this.GetInventory().HasInventoryReservation(quickBarEntity, handInventoryLocation))
  3836. return;
  3837. if (inHandEntity == quickBarEntity)
  3838. {
  3839. if (GetHumanInventory().CanRemoveEntityInHands())
  3840. {
  3841. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Stash - PredictiveMoveItemFromHandsToInventory HND=" + Object.GetDebugName(inHandEntity));
  3842. PredictiveMoveItemFromHandsToInventory();
  3843. }
  3844. }
  3845. else
  3846. {
  3847. InventoryLocation invLocQBItem = new InventoryLocation;
  3848. quickBarEntity.GetInventory().GetCurrentInventoryLocation(invLocQBItem);
  3849. if (GetInventory().HasInventoryReservation(quickBarEntity,invLocQBItem))
  3850. return;
  3851. if (inHandEntity)
  3852. {
  3853. InventoryLocation Reserved_Item_il = new InventoryLocation;
  3854. InventoryLocation inHandEntityFSwapDst = new InventoryLocation;
  3855. inHandEntity.GetInventory().GetCurrentInventoryLocation(inHandEntityFSwapDst);
  3856. int index = GetHumanInventory().FindUserReservedLocationIndex(inHandEntity);
  3857. if (index >= 0)
  3858. GetHumanInventory().GetUserReservedLocation(index, Reserved_Item_il);
  3859. if (Reserved_Item_il)
  3860. inHandEntityFSwapDst.CopyLocationFrom(Reserved_Item_il, true);
  3861. if (index < 0 && GameInventory.CanSwapEntitiesEx(quickBarEntity, inHandEntity))
  3862. {
  3863. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] PredictiveSwapEntities QB=" + Object.GetDebugName(quickBarEntity) + " HND=" + Object.GetDebugName(inHandEntity));
  3864. PredictiveSwapEntities(quickBarEntity, inHandEntity);
  3865. }
  3866. else if (GameInventory.CanForceSwapEntitiesEx(quickBarEntity, handInventoryLocation, inHandEntity, inHandEntityFSwapDst))
  3867. {
  3868. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Swap - PredictiveForceSwapEntities HND=" + Object.GetDebugName(inHandEntity) + " QB=" + Object.GetDebugName(quickBarEntity) + " fswap_dst=" + InventoryLocation.DumpToStringNullSafe(inHandEntityFSwapDst));
  3869. PredictiveForceSwapEntities(quickBarEntity, inHandEntity, inHandEntityFSwapDst);
  3870. }
  3871. }
  3872. else
  3873. {
  3874. if (GetInventory().HasInventoryReservation(quickBarEntity,handInventoryLocation))
  3875. return;
  3876. if (GetInventory().CanAddEntityIntoHands(quickBarEntity))
  3877. {
  3878. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[QB] Stash - PredictiveTakeEntityToHands QB=" + Object.GetDebugName(quickBarEntity));
  3879. PredictiveTakeEntityToHands(quickBarEntity);
  3880. }
  3881. }
  3882. }
  3883. }
  3884. //---------------------------------------------------------
  3885. void OnQuickBarContinuousUseStart(int slotClicked)
  3886. {
  3887. if (GetInventory().IsInventoryLocked())
  3888. return;
  3889. if (IsSwimming() || IsClimbingLadder() || GetCommand_Melee() || IsClimbing() || IsRestrained() || IsRestrainPrelocked())
  3890. return;
  3891. ItemBase quickBarItem = ItemBase.Cast(GetQuickBarEntity(slotClicked - 1));
  3892. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  3893. {
  3894. ItemBase itemInHands = ItemBase.Cast(GetHumanInventory().GetEntityInHands());
  3895. if (itemInHands != quickBarItem)
  3896. {
  3897. ActionManagerClient amc = ActionManagerClient.Cast(GetActionManager());
  3898. if (amc.CanPerformActionFromQuickbar(itemInHands, quickBarItem))
  3899. {
  3900. amc.PerformActionFromQuickbar(itemInHands, quickBarItem);
  3901. }
  3902. else
  3903. {
  3904. if (IsRaised() || GetCommand_Melee())
  3905. return;
  3906. amc.ForceTarget(quickBarItem);
  3907. m_QuickBarFT = true;
  3908. }
  3909. }
  3910. }
  3911. m_QuickBarHold = true;
  3912. }
  3913. //---------------------------------------------------------
  3914. void OnQuickBarContinuousUseEnd(int slotClicked)
  3915. {
  3916. if (m_QuickBarHold)
  3917. {
  3918. if ( GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  3919. {
  3920. ActionManagerClient am = ActionManagerClient.Cast(GetActionManager());
  3921. if (m_ActionQBControl)
  3922. {
  3923. ActionBase action = am.GetRunningAction();
  3924. if (action)
  3925. {
  3926. if (!action.GetInput().IsActive())
  3927. {
  3928. am.EndActionInput();
  3929. }
  3930. }
  3931. }
  3932. if (m_QuickBarFT)
  3933. {
  3934. am.ClearForceTarget();
  3935. m_QuickBarFT = false;
  3936. }
  3937. }
  3938. }
  3939. m_QuickBarHold = false;
  3940. }
  3941. void SetActionEndInput(ActionBase action)
  3942. {
  3943. m_ActionQBControl = !action.GetInput().IsActive();
  3944. }
  3945. bool IsQBControl()
  3946. {
  3947. return m_ActionQBControl;
  3948. }
  3949. void ResetActionEndInput()
  3950. {
  3951. m_ActionQBControl = false;
  3952. }
  3953. //---------------------------------------------------------
  3954. // RADIAL QUICKBAR AND RELOAD ACTIONS
  3955. //---------------------------------------------------------
  3956. //the same functionality as normal quick bar slot key press
  3957. void RadialQuickBarSingleUse(int slotClicked)
  3958. {
  3959. OnQuickBarSingleUse(slotClicked);
  3960. }
  3961. //removed the need for holding down quick bar slot key
  3962. void RadialQuickBarCombine(int slotClicked)
  3963. {
  3964. EntityAI quickBarEntity = GetQuickBarEntity(slotClicked - 1);
  3965. EntityAI entity_in_hands = GetHumanInventory().GetEntityInHands();
  3966. ReloadWeapon(entity_in_hands, quickBarEntity);
  3967. }
  3968. //removed the need for holding down quick bar slot key
  3969. void QuickReloadWeapon(EntityAI weapon)
  3970. {
  3971. EntityAI magazine = GetMagazineToReload(weapon);
  3972. ReloadWeapon(weapon, magazine);
  3973. }
  3974. //Reload weapon with given magazine
  3975. void ReloadWeapon(EntityAI weapon, EntityAI magazine)
  3976. {
  3977. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  3978. {
  3979. ActionManagerClient mngr_client;
  3980. CastTo(mngr_client, GetActionManager());
  3981. if (mngr_client && FirearmActionLoadMultiBulletRadial.Cast(mngr_client.GetRunningAction()))
  3982. {
  3983. mngr_client.Interrupt();
  3984. }
  3985. else if (GetHumanInventory().GetEntityInHands()!= magazine)
  3986. {
  3987. Weapon_Base wpn;
  3988. Magazine mag;
  3989. Class.CastTo(wpn, weapon);
  3990. Class.CastTo(mag, magazine);
  3991. if (GetWeaponManager().CanUnjam(wpn))
  3992. {
  3993. GetWeaponManager().Unjam();
  3994. }
  3995. else if (GetWeaponManager().CanAttachMagazine(wpn, mag))
  3996. {
  3997. GetWeaponManager().AttachMagazine(mag);
  3998. }
  3999. else if (GetWeaponManager().CanSwapMagazine(wpn, mag))
  4000. {
  4001. GetWeaponManager().SwapMagazine(mag);
  4002. }
  4003. else if (GetWeaponManager().CanLoadBullet(wpn, mag))
  4004. {
  4005. //GetWeaponManager().LoadMultiBullet(mag);
  4006. ActionTarget atrg = new ActionTarget(mag, this, -1, vector.Zero, -1.0);
  4007. if (mngr_client && !mngr_client.GetRunningAction() && mngr_client.GetAction(FirearmActionLoadMultiBulletRadial).Can(this, atrg, wpn))
  4008. mngr_client.PerformActionStart(mngr_client.GetAction(FirearmActionLoadMultiBulletRadial), atrg, wpn);
  4009. }
  4010. }
  4011. }
  4012. }
  4013. //returns compatible magazine from player inventory with highest ammo count
  4014. EntityAI GetMagazineToReload(EntityAI weapon)
  4015. {
  4016. Weapon_Base weapon_base = Weapon_Base.Cast(weapon);
  4017. WeaponManager weapon_manager = GetWeaponManager();
  4018. EntityAI magazine_to_reload;
  4019. EntityAI ammo_magazine; //magazine
  4020. int last_ammo_magazine_count;
  4021. int ammo_magazine_count;
  4022. EntityAI ammo_pile; //ammo pile
  4023. int last_ammo_pile_count;
  4024. int ammo_pile_count;
  4025. //Get all magazines in (player) inventory
  4026. for (int att_i = 0; att_i < GetInventory().AttachmentCount(); ++att_i)
  4027. {
  4028. EntityAI attachment = GetInventory().GetAttachmentFromIndex(att_i);
  4029. ref CargoBase attachment_cargo = attachment.GetInventory().GetCargo();
  4030. if (attachment_cargo)
  4031. {
  4032. for (int cgo_i = 0; cgo_i < attachment_cargo.GetItemCount(); ++cgo_i)
  4033. {
  4034. EntityAI cargo_item = attachment_cargo.GetItem(cgo_i);
  4035. //check for proper magazine
  4036. if (cargo_item.IsMagazine())
  4037. {
  4038. Magazine magazine = Magazine.Cast(cargo_item);
  4039. ammo_pile_count = magazine.GetAmmoCount();
  4040. //magazines (get magazine with max ammo count)
  4041. if (weapon_manager.CanAttachMagazine(weapon_base, magazine) || weapon_manager.CanSwapMagazine(weapon_base, magazine))
  4042. {
  4043. if (ammo_pile_count > 0)
  4044. {
  4045. if (last_ammo_magazine_count == 0)
  4046. {
  4047. ammo_magazine = magazine;
  4048. last_ammo_magazine_count = ammo_pile_count;
  4049. }
  4050. else
  4051. {
  4052. if (last_ammo_magazine_count < ammo_pile_count)
  4053. {
  4054. ammo_magazine = magazine;
  4055. last_ammo_magazine_count = ammo_pile_count;
  4056. }
  4057. }
  4058. }
  4059. }
  4060. //bullets (get ammo pile with min ammo count)
  4061. else if (weapon_manager.CanLoadBullet(weapon_base, magazine))
  4062. {
  4063. if (ammo_pile_count > 0)
  4064. {
  4065. if (last_ammo_pile_count == 0)
  4066. {
  4067. ammo_pile = magazine;
  4068. last_ammo_pile_count = ammo_pile_count;
  4069. }
  4070. else
  4071. {
  4072. if (last_ammo_pile_count > ammo_pile_count)
  4073. {
  4074. ammo_pile = magazine;
  4075. last_ammo_pile_count = ammo_pile_count;
  4076. }
  4077. }
  4078. }
  4079. }
  4080. }
  4081. }
  4082. }
  4083. }
  4084. //prioritize magazine
  4085. if (ammo_magazine)
  4086. {
  4087. return ammo_magazine;
  4088. }
  4089. return ammo_pile;
  4090. }
  4091. //---------------------------------------------------------
  4092. //---------------------------------------------------------
  4093. void OnSpawnedFromConsole()
  4094. {
  4095. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
  4096. {
  4097. GetGame().GetMission().AddDummyPlayerToScheduler(this);
  4098. OnSelectPlayer();
  4099. }
  4100. #ifdef DIAG_DEVELOPER
  4101. if (!m_Bot)
  4102. {
  4103. m_Bot = new Bot(this);
  4104. m_Bot.Start();
  4105. }
  4106. #endif
  4107. }
  4108. //---------------------------------------------------------
  4109. //Obsolete
  4110. bool GetLiquidTendencyDrain()
  4111. {
  4112. return m_LiquidTendencyDrain;
  4113. }
  4114. //---------------------------------------------------------
  4115. //Obsolete
  4116. void SetLiquidTendencyDrain(bool state)
  4117. {
  4118. m_LiquidTendencyDrain = state;
  4119. }
  4120. //---------------------------------------------------------
  4121. //! DEPRECATED
  4122. bool GetFlagTendencyRaise()
  4123. {
  4124. return m_FlagRaisingTendency;
  4125. }
  4126. //---------------------------------------------------------
  4127. //! DEPRECATED
  4128. void SetFlagTendencyRaise(bool state)
  4129. {
  4130. m_FlagRaisingTendency = state;
  4131. }
  4132. override SoundOnVehicle PlaySound(string sound_name, float range, bool create_local = false)
  4133. {
  4134. return BetaSound.SaySound(this, sound_name, range, false);
  4135. }
  4136. float GetPlayerLoad()
  4137. {
  4138. return GetWeightEx();
  4139. }
  4140. bool IsOverloaded()
  4141. {
  4142. return GetWeightEx() >= OVERLOAD_LIMIT;
  4143. }
  4144. void SetPlayerLoad(float load)//Deprecated
  4145. {
  4146. m_CargoLoad = load;
  4147. //Print("m_CargoLoad: " + m_CargoLoad);
  4148. //Log(ToString(this) + "'s load weight is " + ftoa(m_CargoLoad) + " g.", LogTemplates.TEMPLATE_PLAYER_WEIGHT);
  4149. }
  4150. //Deprecated, will be overrid by other method calls (in order to ensure stamina calculation is properly set)
  4151. void AddPlayerLoad(float addedload)//Deprecated
  4152. {
  4153. float newload = GetPlayerLoad() + addedload;
  4154. SetPlayerLoad(newload);
  4155. // Do not need -> Log is in SetPlayerLoad
  4156. //PrintString(ToString(this) + "'s load weight is " + ToString(m_CargoLoad) + " g.");
  4157. }
  4158. bool IsItemInInventory(EntityAI entity)
  4159. {
  4160. return GetInventory().HasEntityInInventory(entity);
  4161. }
  4162. override bool NeedInventoryJunctureFromServer(notnull EntityAI item, EntityAI currParent, EntityAI newParent)
  4163. {
  4164. if (GetGame().IsMultiplayer())
  4165. {
  4166. DayZPlayerInstanceType t = GetInstanceType();
  4167. switch (t)
  4168. {
  4169. case DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER:
  4170. return false;
  4171. case DayZPlayerInstanceType.INSTANCETYPE_CLIENT:
  4172. case DayZPlayerInstanceType.INSTANCETYPE_SERVER:
  4173. case DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER:
  4174. case DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE:
  4175. case DayZPlayerInstanceType.INSTANCETYPE_REMOTE:
  4176. return true; // Might help mitigate "megabugged" (desync)
  4177. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " NeedInventoryJunctureFromServer item=" + Object.GetDebugName(item) + " currPar=" + currParent + " newPar=" + newParent);
  4178. bool i_owned = GetHumanInventory().HasEntityInInventory(item);
  4179. bool cp_owned = false;
  4180. if (currParent)
  4181. cp_owned = GetHumanInventory().HasEntityInInventory(currParent);
  4182. bool np_owned = false;
  4183. if (newParent)
  4184. np_owned = GetHumanInventory().HasEntityInInventory(newParent);
  4185. bool all_owned = i_owned && cp_owned && (np_owned || (newParent == null));
  4186. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " NeedInventoryJunctureFromServer=" + !all_owned + " i_pwn=" + i_owned + " cp_pwn=" + cp_owned + " np_pwn=" + np_owned);
  4187. return !all_owned;
  4188. default:
  4189. Error("[syncinv] unsupported instance type t=" + t);
  4190. break;
  4191. }
  4192. }
  4193. return false;
  4194. }
  4195. override protected float GetWeightSpecialized(bool forceRecalc = false)
  4196. {
  4197. float totalWeight = super.GetWeightSpecialized(forceRecalc);
  4198. ItemBase itemHands = GetItemInHands();
  4199. if (itemHands) // adds weight of item carried in hands
  4200. {
  4201. totalWeight += itemHands.GetWeightEx(forceRecalc);
  4202. }
  4203. #ifdef DEVELOPER
  4204. if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
  4205. {
  4206. float itemInHandsWeight = totalWeight - super.GetWeightSpecialized(forceRecalc);
  4207. WeightDebugData dta = WeightDebug.GetWeightDebug(this);
  4208. dta.SetCalcDetails("TMan: " + (super.GetWeightSpecialized(forceRecalc)+ itemInHandsWeight) +"(contents weight[includes item in hands])");
  4209. }
  4210. #endif
  4211. return totalWeight;
  4212. }
  4213. void CalculateVisibilityForAI()
  4214. {
  4215. const int VISIBILITY_SLOTS_COUNT = 10;
  4216. int attcount = GetInventory().AttachmentCount();
  4217. float sumVisibility = 0;
  4218. float countVisibility = 0;
  4219. float visibilityMean = 0;
  4220. if (attcount > 0)
  4221. {
  4222. for (int att = 0; att < attcount; att++)
  4223. {
  4224. EntityAI attachment = GetInventory().GetAttachmentFromIndex(att);
  4225. if (attachment.IsClothing())
  4226. {
  4227. ClothingBase clothing;
  4228. Class.CastTo(clothing, attachment);
  4229. sumVisibility += clothing.GetItemVisibility();
  4230. countVisibility++;
  4231. }
  4232. }
  4233. visibilityMean = (sumVisibility + (VISIBILITY_SLOTS_COUNT - countVisibility)) / VISIBILITY_SLOTS_COUNT;
  4234. SetVisibilityCoef(visibilityMean);
  4235. }
  4236. else
  4237. {
  4238. visibilityMean = 1;
  4239. SetVisibilityCoef(visibilityMean);
  4240. }
  4241. }
  4242. void SetVisibilityCoef(float pVisibility)
  4243. {
  4244. m_VisibilityCoef = pVisibility;
  4245. }
  4246. float GetVisibilityCoef()
  4247. {
  4248. return m_VisibilityCoef;
  4249. }
  4250. int GetShakeLevel()
  4251. {
  4252. return m_Shakes;
  4253. }
  4254. EStatLevels GetStatLevelHealth()
  4255. {
  4256. float health = GetHealth("","");
  4257. return GetStatLevel(health, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH);
  4258. }
  4259. EStatLevels GetStatLevelToxicity()
  4260. {
  4261. float toxicity = GetStatToxicity().Get();
  4262. return GetStatLevel(toxicity, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH);
  4263. }
  4264. EStatLevels GetStatLevelBlood()
  4265. {
  4266. float blood = GetHealth("","Blood");
  4267. return GetStatLevel(blood, PlayerConstants.SL_BLOOD_CRITICAL, PlayerConstants.SL_BLOOD_LOW, PlayerConstants.SL_BLOOD_NORMAL, PlayerConstants.SL_BLOOD_HIGH);
  4268. }
  4269. EStatLevels GetStatLevelEnergy()
  4270. {
  4271. float energy = GetStatEnergy().Get();
  4272. return GetStatLevel(energy, PlayerConstants.SL_ENERGY_CRITICAL, PlayerConstants.SL_ENERGY_LOW, PlayerConstants.SL_ENERGY_NORMAL, PlayerConstants.SL_ENERGY_HIGH);
  4273. }
  4274. EStatLevels GetStatLevelWater()
  4275. {
  4276. float water = GetStatWater().Get();
  4277. return GetStatLevel(water, PlayerConstants.SL_WATER_CRITICAL, PlayerConstants.SL_WATER_LOW, PlayerConstants.SL_WATER_NORMAL, PlayerConstants.SL_WATER_HIGH);
  4278. }
  4279. EStatLevels GetImmunityLevel()
  4280. {
  4281. float immunity = GetImmunity();
  4282. if (m_ImmunityBoosted)
  4283. return EStatLevels.GREAT;
  4284. return GetStatLevel(immunity, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_CRITICAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_LOW, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_NORMAL, PlayerConstants.IMMUNITY_THRESHOLD_LEVEL_HIGH);
  4285. }
  4286. //-------------------------------------
  4287. float GetBordersImmunity()
  4288. {
  4289. float immunity = GetImmunity();
  4290. float immmunity_max = 1;
  4291. 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);
  4292. }
  4293. float GetStatBordersHealth()
  4294. {
  4295. float health = GetHealth("","");
  4296. float health_max = GetMaxHealth("","");
  4297. return GetStatLevelBorders(health, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH, health_max);
  4298. }
  4299. float GetStatBordersToxicity()
  4300. {
  4301. float toxicity = GetStatToxicity().Get();
  4302. float toxicity_max = GetStatToxicity().GetMax();
  4303. return GetStatLevelBorders(toxicity, PlayerConstants.SL_HEALTH_CRITICAL, PlayerConstants.SL_HEALTH_LOW, PlayerConstants.SL_HEALTH_NORMAL, PlayerConstants.SL_HEALTH_HIGH, toxicity_max);
  4304. }
  4305. float GetStatBordersBlood()
  4306. {
  4307. float blood = GetHealth("","Blood");
  4308. float blood_max = GetMaxHealth("","Blood");
  4309. return GetStatLevelBorders(blood, PlayerConstants.SL_BLOOD_CRITICAL, PlayerConstants.SL_BLOOD_LOW, PlayerConstants.SL_BLOOD_NORMAL, PlayerConstants.SL_BLOOD_HIGH, blood_max);
  4310. }
  4311. float GetStatBordersEnergy()
  4312. {
  4313. float energy = GetStatEnergy().Get();
  4314. float energy_max = GetStatEnergy().GetMax();
  4315. return GetStatLevelBorders(energy, PlayerConstants.SL_ENERGY_CRITICAL, PlayerConstants.SL_ENERGY_LOW, PlayerConstants.SL_ENERGY_NORMAL, PlayerConstants.SL_ENERGY_HIGH, energy_max);
  4316. }
  4317. float GetStatBordersWater()
  4318. {
  4319. float water = GetStatWater().Get();
  4320. float water_max = GetStatWater().GetMax();
  4321. return GetStatLevelBorders(water, PlayerConstants.SL_WATER_CRITICAL, PlayerConstants.SL_WATER_LOW, PlayerConstants.SL_WATER_NORMAL, PlayerConstants.SL_WATER_HIGH, water_max);
  4322. }
  4323. //------------------------------------
  4324. float GetStatLevelBorders(float stat_value, float critical, float low, float normal, float high, float max)
  4325. {
  4326. if (stat_value <= critical)
  4327. {
  4328. return Math.InverseLerp(0, critical, stat_value);
  4329. }
  4330. if (stat_value <= low)
  4331. {
  4332. return Math.InverseLerp(critical, low, stat_value);
  4333. }
  4334. if (stat_value <= normal)
  4335. {
  4336. return Math.InverseLerp(low, normal, stat_value);
  4337. }
  4338. if (stat_value <= high)
  4339. {
  4340. return Math.InverseLerp(normal, high, stat_value);
  4341. }
  4342. return Math.InverseLerp(high, max, stat_value);
  4343. }
  4344. EStatLevels GetStatLevel(float stat_value, float critical, float low, float normal, float high)
  4345. {
  4346. if (stat_value <= critical)
  4347. {
  4348. return EStatLevels.CRITICAL;
  4349. }
  4350. if (stat_value <= low)
  4351. {
  4352. return EStatLevels.LOW;
  4353. }
  4354. if (stat_value <= normal)
  4355. {
  4356. return EStatLevels.MEDIUM;
  4357. }
  4358. if (stat_value <= high)
  4359. {
  4360. return EStatLevels.HIGH;
  4361. }
  4362. return EStatLevels.GREAT;
  4363. }
  4364. void SetImmunityBoosted(bool boosted)
  4365. {
  4366. m_ImmunityBoosted = boosted;
  4367. }
  4368. //!returns player's immunity strength between 0..1
  4369. float GetImmunity()
  4370. {
  4371. float immunity;
  4372. if (GetPlayerStats())
  4373. {
  4374. float max_health = GetMaxHealth("GlobalHealth", "Health") + 0.01;//addition to prevent divisioin by zero in case of some messup
  4375. float max_blood = GetMaxHealth("GlobalHealth", "Blood") + 0.01;//addition to prevent divisioin by zero in case of some messup
  4376. float energy_normalized = GetStatEnergy().Get() / PlayerConstants.SL_ENERGY_MAX;
  4377. float water_normalized = GetStatWater().Get() / PlayerConstants.SL_WATER_MAX;
  4378. float health_normalized = GetHealth("GlobalHealth", "Health") / max_health;
  4379. float blood_normalized = GetHealth("GlobalHealth", "Blood") / max_blood;
  4380. immunity = energy_normalized + water_normalized + health_normalized + blood_normalized;
  4381. immunity = immunity / 4;//avg
  4382. immunity = Math.Clamp(immunity,0,1);
  4383. }
  4384. return immunity;
  4385. }
  4386. bool IsSprinting()
  4387. {
  4388. return m_MovementState.m_iMovement == DayZPlayerConstants.MOVEMENT_SPRINT);
  4389. }
  4390. bool CanSprint()
  4391. {
  4392. ItemBase item = GetItemInHands();
  4393. if (IsRaised() || (item && item.IsHeavyBehaviour()))
  4394. return false;
  4395. if (item && GetThrowing() && GetThrowing().IsThrowingModeEnabled())
  4396. return false;
  4397. if (GetBrokenLegs() != eBrokenLegs.NO_BROKEN_LEGS)
  4398. return false;
  4399. return true;
  4400. }
  4401. bool IsInProne()
  4402. {
  4403. return m_MovementState.IsInProne();
  4404. }
  4405. bool IsInRasedProne()
  4406. {
  4407. return m_MovementState.IsInRaisedProne();
  4408. }
  4409. bool IsLeaning()
  4410. {
  4411. return m_MovementState.IsLeaning();
  4412. }
  4413. bool IsRolling()
  4414. {
  4415. return GetCommand_Move() && GetCommand_Move().IsInRoll());
  4416. }
  4417. bool IsClimbing()
  4418. {
  4419. return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_CLIMB;
  4420. }
  4421. bool IsFalling()
  4422. {
  4423. return m_MovementState.m_CommandTypeId == DayZPlayerConstants.COMMANDID_FALL;
  4424. }
  4425. override bool IsFighting()
  4426. {
  4427. return m_IsFighting;
  4428. }
  4429. bool IsEmotePlaying()
  4430. {
  4431. return m_EmoteManager && m_EmoteManager.IsEmotePlaying();
  4432. }
  4433. override bool IsIgnoredByConstruction()
  4434. {
  4435. return IsRuined();
  4436. }
  4437. /*!
  4438. Returns whether the specified movement command(s) are starting the next frame.
  4439. 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)
  4440. */
  4441. bool AnimCommandCheck(HumanMoveCommandID mask)
  4442. {
  4443. return m_AnimCommandStarting & mask;
  4444. }
  4445. void RunFightBlendTimer()
  4446. {
  4447. if (!m_FightEndBlendTimer)
  4448. m_FightEndBlendTimer = new Timer();
  4449. if (!m_FightEndBlendTimer.IsRunning())
  4450. {
  4451. m_FightEndBlendTimer.Run(PlayerConstants.MELEE2_MOVEMENT_BLEND_DELAY,this,"EndFighting");
  4452. }
  4453. }
  4454. void EndFighting()
  4455. {
  4456. m_IsFighting = false;
  4457. }
  4458. bool CheckMeleeItemDamage(ItemBase item)
  4459. {
  4460. //on-hit drop of melee weapons
  4461. //bayonets & buttstocks
  4462. if (item && item.GetHierarchyParent() && item.GetHierarchyParent().IsWeapon() && item.IsRuined()/*&& item.FindAttachmentBySlotName()*/)
  4463. {
  4464. PlayAttachmentDropSound();
  4465. return DropItem(item);
  4466. }
  4467. //handheld items themselves
  4468. if (item && item == GetItemInHands() && item.IsRuined())
  4469. {
  4470. return PredictiveDropEntity(item);
  4471. }
  4472. return false;
  4473. }
  4474. void PlayAttachmentDropSound()
  4475. {
  4476. //TODO
  4477. }
  4478. // -------------------------------------------------------------------------
  4479. override void RPC(int rpc_type, array<ref Param> params, bool guaranteed, PlayerIdentity recipient = NULL)
  4480. {
  4481. super.RPC(rpc_type, params, guaranteed, recipient);
  4482. }
  4483. // -------------------------------------------------------------------------
  4484. override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
  4485. {
  4486. super.OnRPC(sender, rpc_type, ctx);
  4487. switch (rpc_type)
  4488. {
  4489. #ifndef SERVER
  4490. case ERPCs.RPC_PLAYER_STAT:
  4491. if (GetPlayerStats())
  4492. GetPlayerStats().OnRPC(ctx);
  4493. break;
  4494. case ERPCs.RPC_SYNC_DISPLAY_STATUS:
  4495. if (GetVirtualHud())
  4496. {
  4497. GetVirtualHud().OnRPC(ctx);
  4498. }
  4499. break;
  4500. case ERPCs.RPC_PLAYER_SYMPTOM_ON:
  4501. if (GetSymptomManager())
  4502. {
  4503. GetSymptomManager().OnRPC(ERPCs.RPC_PLAYER_SYMPTOM_ON, ctx);
  4504. }
  4505. break;
  4506. case ERPCs.RPC_PLAYER_SYMPTOM_OFF:
  4507. if (GetSymptomManager())
  4508. {
  4509. GetSymptomManager().OnRPC(ERPCs.RPC_PLAYER_SYMPTOM_OFF, ctx);
  4510. }
  4511. break;
  4512. case ERPCs.RPC_DAMAGE_VALUE_SYNC:
  4513. if (m_TrasferValues)
  4514. m_TrasferValues.OnRPC(ctx);
  4515. break;
  4516. case ERPCs.RPC_USER_ACTION_MESSAGE:
  4517. if (!GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  4518. {
  4519. break;
  4520. }
  4521. if (ctx.Read(m_UAParamMessage))
  4522. {
  4523. string actiontext = m_UAParamMessage.param1;
  4524. MessageAction(actiontext);
  4525. }
  4526. break;
  4527. case ERPCs.RPC_SOFT_SKILLS_SPECIALTY_SYNC:
  4528. ref Param1<float> p_synch = new Param1<float>(0);
  4529. ctx.Read(p_synch);
  4530. float specialty_level = p_synch.param1;
  4531. GetSoftSkillsManager().SetSpecialtyLevel(specialty_level);
  4532. break;
  4533. case ERPCs.RPC_SOFT_SKILLS_STATS_SYNC:
  4534. ref Param5<float, float, float, float, bool> p_debug_synch = new Param5<float, float ,float, float, bool>(0, 0, 0, 0, false);
  4535. ctx.Read(p_debug_synch);
  4536. float general_bonus_before = p_debug_synch.param1;
  4537. float general_bonus_after = p_debug_synch.param2;
  4538. float last_UA_value = p_debug_synch.param3;
  4539. float cooldown_value = p_debug_synch.param4;
  4540. float cooldown_active = p_debug_synch.param5;
  4541. GetSoftSkillsManager().SetGeneralBonusBefore(general_bonus_before);
  4542. GetSoftSkillsManager().SetGeneralBonusAfter(general_bonus_after);
  4543. GetSoftSkillsManager().SetLastUAValue(last_UA_value);
  4544. GetSoftSkillsManager().SetCoolDownValue(cooldown_value);
  4545. GetSoftSkillsManager().SetCoolDown(cooldown_active);
  4546. break;
  4547. case ERPCs.RPC_WARNING_ITEMDROP:
  4548. {
  4549. if (GetGame().IsClient() && GetGame().GetUIManager() && !GetGame().GetUIManager().FindMenu(MENU_WARNING_ITEMDROP))
  4550. {
  4551. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_WARNING_ITEMDROP,null);
  4552. GetGame().GetMission().AddActiveInputExcludes({"menu"});
  4553. }
  4554. break;
  4555. }
  4556. case ERPCs.RPC_WARNING_TELEPORT:
  4557. {
  4558. if (GetGame().IsClient() && GetGame().GetUIManager() && !GetGame().GetUIManager().FindMenu(MENU_WARNING_TELEPORT))
  4559. {
  4560. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_WARNING_TELEPORT,null);
  4561. GetGame().GetMission().AddActiveInputExcludes({"menu"});
  4562. }
  4563. break;
  4564. }
  4565. case ERPCs.RPC_INIT_SET_QUICKBAR:
  4566. ref Param1<int> count = new Param1<int>(0);
  4567. if (ctx.Read(count));
  4568. {
  4569. for (int i = 0; i < count.param1 ; i++)
  4570. {
  4571. m_QuickBarBase.OnSetEntityRPC(ctx);
  4572. }
  4573. }
  4574. break;
  4575. case ERPCs.RPC_SYNC_THERMOMETER:
  4576. {
  4577. float value;
  4578. if (ctx.Read(value))
  4579. m_Hud.SetTemperature(value.ToString() + "#degrees_celsius");
  4580. break;
  4581. }
  4582. case ERPCs.RPC_CHECK_PULSE:
  4583. ctx.Read(CachedObjectsParams.PARAM1_INT);
  4584. EPulseType pulse;
  4585. if ((CachedObjectsParams.PARAM1_INT.param1 & ActionCheckPulse.TARGET_IRREGULAR_PULSE_BIT) == 0)
  4586. {
  4587. pulse = EPulseType.REGULAR;
  4588. }
  4589. else
  4590. {
  4591. pulse = EPulseType.IRREGULAR;
  4592. }
  4593. int blood_level = ~ActionCheckPulse.TARGET_IRREGULAR_PULSE_BIT & CachedObjectsParams.PARAM1_INT.param1;
  4594. if (m_CheckPulseLastTarget)
  4595. {
  4596. m_CheckPulseLastTarget.SetLastUAMessage(ActionCheckPulse.GetPulseMessage(pulse, blood_level));
  4597. }
  4598. break;
  4599. //! uses contants outside of ERPCs !!!!
  4600. //woodcutting
  4601. case PlantType.TREE_HARD:
  4602. SoundHardTreeFallingPlay();
  4603. break;
  4604. case PlantType.TREE_SOFT:
  4605. SoundSoftTreeFallingPlay();
  4606. break;
  4607. case PlantType.BUSH_HARD:
  4608. SoundHardBushFallingPlay();
  4609. break;
  4610. case PlantType.BUSH_SOFT:
  4611. SoundSoftBushFallingPlay();
  4612. break;
  4613. case ERPCs.RPC_DEBUG_MONITOR_FLT:
  4614. if (m_DebugMonitorValues)
  4615. {
  4616. m_DebugMonitorValues.OnRPCFloat(ctx);
  4617. }
  4618. break;
  4619. case ERPCs.RPC_DEBUG_MONITOR_STR:
  4620. if (m_DebugMonitorValues)
  4621. {
  4622. m_DebugMonitorValues.OnRPCString(ctx);
  4623. }
  4624. break;
  4625. #endif
  4626. /*
  4627. case ERPCs.RPC_CRAFTING_INVENTORY_INSTANT:
  4628. ref Param3<int, ItemBase, ItemBase> craftParam = new Param3<int, ItemBase, ItemBase>(-1, NULL, NULL);
  4629. if (ctx.Read(craftParam))
  4630. {
  4631. m_ModuleRecipesManager.PerformRecipeServer(craftParam.param1, craftParam.param2, craftParam.param3, this);
  4632. }
  4633. break;
  4634. */
  4635. #ifdef DIAG_DEVELOPER
  4636. case ERPCs.DEV_RPC_AGENT_RESET:
  4637. {
  4638. bool val;
  4639. if (ctx.Read(val))
  4640. m_AgentPool.RemoveAllAgents();
  4641. break;
  4642. }
  4643. case ERPCs.DEV_PLAYER_DEBUG_REQUEST:
  4644. {
  4645. PluginRemotePlayerDebugServer plugin_remote_server = PluginRemotePlayerDebugServer.Cast(GetPlugin(PluginRemotePlayerDebugServer));
  4646. plugin_remote_server.OnRPC(ctx, this);
  4647. break;
  4648. }
  4649. case ERPCs.DEV_PLAYER_DEBUG_DATA:
  4650. {
  4651. PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(GetPlugin(PluginRemotePlayerDebugClient));
  4652. PluginDeveloper plugin_dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
  4653. if (plugin_dev.m_ScriptConsole)
  4654. plugin_dev.m_ScriptConsole.OnRPCEx(rpc_type, ctx);
  4655. else
  4656. plugin_remote_client.OnRPC(ctx);
  4657. break;
  4658. }
  4659. case ERPCs.DEV_AGENT_GROW:
  4660. {
  4661. m_AgentPool.RemoteGrowRequestDebug(ctx);
  4662. break;
  4663. }
  4664. case ERPCs.RPC_ITEM_DIAG_CLOSE:
  4665. {
  4666. PluginItemDiagnostic mid = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
  4667. mid.StopWatchRequest(this);
  4668. break;
  4669. }
  4670. //! Universal Temperature Sources debug
  4671. case ERPCs.DEV_REQUEST_UTS_DEBUG:
  4672. {
  4673. PluginUniversalTemperatureSourceServer plugin_uts_server = PluginUniversalTemperatureSourceServer.Cast(GetPlugin(PluginUniversalTemperatureSourceServer));
  4674. plugin_uts_server.OnRPC(ctx, this);
  4675. break;
  4676. }
  4677. case ERPCs.DEV_UTS_DEBUG_DATA:
  4678. {
  4679. PluginUniversalTemperatureSourceClient plugin_uts_client = PluginUniversalTemperatureSourceClient.Cast(GetPlugin(PluginUniversalTemperatureSourceClient));
  4680. plugin_uts_client.OnRPC(ctx);
  4681. break;
  4682. }
  4683. //! ---
  4684. #endif
  4685. #ifdef DEVELOPER
  4686. case ERPCs.DEV_RPC_SERVER_SCRIPT:
  4687. {
  4688. //PluginItemDiagnostic plugin = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
  4689. //SetDebugDeveloper_item(plugin.GetWatchedItem(this));//!! needs to be inside DEVELOPER ifdef
  4690. if (ctx.Read(CachedObjectsParams.PARAM1_STRING))
  4691. {
  4692. _player = this;
  4693. string code = CachedObjectsParams.PARAM1_STRING.param1;
  4694. bool success = GetGame().ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
  4695. CachedObjectsParams.PARAM1_BOOL.param1 = success;
  4696. RPCSingleParam(ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT, CachedObjectsParams.PARAM1_BOOL,true, GetIdentity());
  4697. }
  4698. break;
  4699. }
  4700. case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
  4701. {
  4702. PluginDeveloper dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
  4703. if (dev.m_ScriptConsole)
  4704. dev.m_ScriptConsole.OnRPCEx(rpc_type, ctx);
  4705. break;
  4706. }
  4707. case ERPCs.DEV_SET_DEV_ITEM:
  4708. {
  4709. Param1<EntityAI> ent = new Param1<EntityAI>(null);
  4710. if (ctx.Read(ent) && ent.param1)
  4711. {
  4712. PluginItemDiagnostic mid2 = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
  4713. mid2.RegisterDebugItem(ent.param1, this);
  4714. }
  4715. //SetDebugDeveloper_item(this);
  4716. break;
  4717. }
  4718. case ERPCs.RPC_ITEM_DIAG:
  4719. {
  4720. Param1<EntityAI> p1 = new Param1<EntityAI>(null);
  4721. if (ctx.Read(p1))
  4722. {
  4723. PluginItemDiagnostic plgn = PluginItemDiagnostic.Cast(GetPlugin(PluginItemDiagnostic));
  4724. plgn.OnRPC(p1.param1, ctx);
  4725. }
  4726. break;
  4727. }
  4728. #endif
  4729. }
  4730. #ifdef DIAG_DEVELOPER
  4731. PluginDeveloper module_rc = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
  4732. if (module_rc)
  4733. module_rc.OnRPC(this, rpc_type, ctx);
  4734. PluginDeveloperSync module_rcs = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
  4735. if (module_rcs)
  4736. module_rcs.OnRPC(this, rpc_type, ctx);
  4737. #ifdef SERVER
  4738. PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenuServer));
  4739. #else
  4740. PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenuClient));
  4741. #endif
  4742. if (plugin_diag_menu)
  4743. plugin_diag_menu.OnRPC(this, rpc_type, ctx);
  4744. #endif
  4745. }
  4746. override void OnGameplayDataHandlerSync()
  4747. {
  4748. super.OnGameplayDataHandlerSync();
  4749. UpdateLighting();
  4750. GetGame().GetMission().SetRespawnModeClient(CfgGameplayHandler.GetDisableRespawnDialog());
  4751. SetHitPPEEnabled(CfgGameplayHandler.GetHitIndicationPPEEnabled());
  4752. }
  4753. void UpdateLighting()
  4754. {
  4755. Mission mission = GetGame().GetMission();
  4756. if (mission)
  4757. {
  4758. WorldLighting wLighting = mission.GetWorldLighting();
  4759. if (wLighting)
  4760. wLighting.SetGlobalLighting(CfgGameplayHandler.GetLightingConfig());
  4761. }
  4762. }
  4763. 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)
  4764. {
  4765. if (enable) // enable
  4766. {
  4767. // We assume that if this is set to true the PPE is already active
  4768. if (m_ContaminatedAreaEffectEnabled == enable)
  4769. return;
  4770. if (aroundId !=0)
  4771. {
  4772. if (!m_ContaminatedAroundPlayer)
  4773. {
  4774. m_ContaminatedAroundPlayer = ParticleManager.GetInstance().PlayInWorld(aroundId, GetPosition());
  4775. }
  4776. // First entry in an area with dynamic tweaks to particles
  4777. if (partDynaUpdate)
  4778. {
  4779. m_ContaminatedAroundPlayer.SetParameter(0, EmitorParam.BIRTH_RATE, newBirthRate);
  4780. }
  4781. }
  4782. if (!m_ContaminatedAroundPlayerTiny && tinyId !=0)
  4783. {
  4784. m_ContaminatedAroundPlayerTiny = ParticleManager.GetInstance().PlayInWorld(tinyId, GetPosition());
  4785. }
  4786. if (ppeIdx != -1)
  4787. {
  4788. PPERequesterBase ppeRequester;
  4789. if (Class.CastTo(ppeRequester, PPERequesterBank.GetRequester(ppeIdx)))
  4790. ppeRequester.Start();
  4791. }
  4792. // We start playing the ambient sound
  4793. if (!m_AmbientContamination && soundset != "")
  4794. PlaySoundSetLoop(m_AmbientContamination, soundset, 0.1, 0.1);
  4795. }
  4796. else // disable
  4797. {
  4798. if (m_ContaminatedAroundPlayer)
  4799. {
  4800. m_ContaminatedAroundPlayer.Stop();
  4801. m_ContaminatedAroundPlayer = null;
  4802. }
  4803. if (m_ContaminatedAroundPlayerTiny)
  4804. {
  4805. m_ContaminatedAroundPlayerTiny.Stop();
  4806. m_ContaminatedAroundPlayerTiny = null;
  4807. }
  4808. if (ppeIdx != -1)
  4809. PPERequesterBank.GetRequester(ppeIdx).Stop(new Param1<bool>(true)); //fade out
  4810. // We stop the ambient sound
  4811. if (m_AmbientContamination)
  4812. StopSoundSet(m_AmbientContamination);
  4813. // We make sure to reset the state
  4814. }
  4815. m_ContaminatedAreaEffectEnabled = enable;
  4816. }
  4817. 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)
  4818. {
  4819. SetContaminatedEffectEx(enable, ppeIdx, aroundId, tinyId, "", partDynaUpdate, newBirthRate);
  4820. }
  4821. // -------------------------------------------------------------------------
  4822. void UpdateCorpseState()
  4823. {
  4824. UpdateCorpseStateVisual();
  4825. if (m_CorpseState > 0 && !GetIsFrozen())
  4826. SetDecayEffects(Math.AbsInt(m_CorpseState));
  4827. else
  4828. SetDecayEffects();//no params means remove the effects
  4829. m_CorpseStateLocal = m_CorpseState;
  4830. }
  4831. // -------------------------------------------------------------------------
  4832. override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
  4833. {
  4834. super.EEHealthLevelChanged(oldLevel, newLevel, zone);
  4835. if (!GetGame().IsDedicatedServer())
  4836. {
  4837. if (newLevel == GameConstants.STATE_RUINED)
  4838. {
  4839. ClearLastUAMessage();
  4840. }
  4841. if (m_CorpseState != 0)
  4842. {
  4843. GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(UpdateCorpseState, 0, false);
  4844. }
  4845. }
  4846. }
  4847. // -------------------------------------------------------------------------
  4848. override void OnVariablesSynchronized()
  4849. {
  4850. super.OnVariablesSynchronized();
  4851. if (m_ModuleLifespan)
  4852. {
  4853. m_ModuleLifespan.SynchLifespanVisual(this, m_LifeSpanState, m_HasBloodyHandsVisible, m_HasBloodTypeVisible, m_BloodType);
  4854. if (m_LifespanLevelLocal != m_LifeSpanState) //client solution, lifespan level changed
  4855. {
  4856. m_LifespanLevelLocal = m_LifeSpanState;
  4857. UpdateHairSelectionVisibility();
  4858. }
  4859. }
  4860. CheckSoundEvent();
  4861. if (GetBleedingManagerRemote() && IsPlayerLoaded())
  4862. {
  4863. GetBleedingManagerRemote().OnVariablesSynchronized(GetBleedingBits());
  4864. }
  4865. if (m_CorpseStateLocal != m_CorpseState && (IsPlayerLoaded() || IsControlledPlayer()))
  4866. {
  4867. UpdateCorpseState();
  4868. }
  4869. if (m_RefreshAnimStateIdx != m_LocalRefreshAnimStateIdx)
  4870. {
  4871. RefreshHandAnimationState(396); //mean animation blend time
  4872. m_LocalRefreshAnimStateIdx = m_RefreshAnimStateIdx;
  4873. }
  4874. if (m_InsideEffectArea != m_InsideEffectAreaPrev)
  4875. {
  4876. if (m_InsideEffectArea)
  4877. {
  4878. OnPlayerIsNowInsideEffectAreaBeginClient();
  4879. }
  4880. else
  4881. {
  4882. OnPlayerIsNowInsideEffectAreaEndClient();
  4883. }
  4884. m_InsideEffectAreaPrev = m_InsideEffectArea;
  4885. }
  4886. //-------MODIFIERS START--------
  4887. if (m_SyncedModifiers != m_SyncedModifiersPrev)
  4888. {
  4889. int diff = (m_SyncedModifiers & ~m_SyncedModifiersPrev) | (~m_SyncedModifiers & m_SyncedModifiersPrev);//XOR gets us a mask for modifiers that changed by either deactivating, or activating
  4890. if (eModifierSyncIDs.MODIFIER_SYNC_DROWNING & diff)//has this modifier's status as active/inactive changed ?
  4891. {
  4892. if (eModifierSyncIDs.MODIFIER_SYNC_DROWNING & m_SyncedModifiers)//is this modifier currently active ? if so, it means it's been just activated
  4893. {
  4894. SetDrowning(true);
  4895. }
  4896. else
  4897. {
  4898. SetDrowning(false);
  4899. }
  4900. }
  4901. m_SyncedModifiersPrev = m_SyncedModifiers;
  4902. }
  4903. //-------MODIFIERS END--------
  4904. HandleBrokenLegsSync();
  4905. //! Remotely Activated Item Behaviour refresh on item is in hands
  4906. ItemBase itemHands = GetItemInHands();
  4907. if (itemHands)
  4908. {
  4909. RemotelyActivatedItemBehaviour raib = itemHands.GetRemotelyActivatedItemBehaviour();
  4910. if (raib)
  4911. raib.OnVariableSynchronized();
  4912. }
  4913. //restrain events
  4914. if (m_IsRestrainedLocal != m_IsRestrained)
  4915. {
  4916. m_IsRestrainedLocal = m_IsRestrained;
  4917. OnRestrainChangeClient();
  4918. }
  4919. if (m_IsRestrainStartedLocal != m_IsRestrainStarted)
  4920. {
  4921. m_IsRestrainStartedLocal = m_IsRestrainStarted;
  4922. OnRestrainStartedChangeClient();
  4923. }
  4924. }
  4925. //! Checks whether modifier (which has syncing enabled) is currently active, works on both Client and Server
  4926. bool IsSyncedModifierActive(eModifierSyncIDs modifier)
  4927. {
  4928. return (m_SyncedModifiers & m_SyncedModifiersPrev);
  4929. }
  4930. void HandleBrokenLegsSync()
  4931. {
  4932. if (m_BrokenLegState != m_LocalBrokenState)
  4933. {
  4934. m_LocalBrokenState = m_BrokenLegState;
  4935. if (GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  4936. {
  4937. if (m_BrokenLegState < 0)
  4938. BreakLegSound();
  4939. }
  4940. }
  4941. }
  4942. void FixAllInventoryItems()
  4943. {
  4944. array<EntityAI> items = new array<EntityAI>();
  4945. GetInventory().EnumerateInventory(InventoryTraversalType.INORDER, items);
  4946. foreach (EntityAI item : items)
  4947. {
  4948. item.SetHealthMax("", "");
  4949. item.SetWet(item.GetWetInit());
  4950. item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
  4951. item.SetFrozen(false);
  4952. }
  4953. }
  4954. void OnInventoryMenuOpen();
  4955. void OnInventoryMenuClose();
  4956. //--------------------------------------------------------------------------
  4957. void OnSelectPlayer()
  4958. {
  4959. //Print("PlayerBase | OnSelectPlayer()");
  4960. m_PlayerSelected = true;
  4961. m_QuickBarBase.updateSlotsCount();
  4962. m_WeaponManager.SortMagazineAfterLoad();
  4963. PlayerIdentity identity = GetIdentity();
  4964. #ifdef FEATURE_NETWORK_RECONCILIATION
  4965. if (identity)
  4966. {
  4967. //! TODO(kumarjac): vhc: Check if it causes further issues with SelectPlayer while a player is leaving freecam
  4968. identity.Possess(this);
  4969. }
  4970. #endif
  4971. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
  4972. {
  4973. if (identity)
  4974. {
  4975. m_CachedPlayerID = identity.GetId();
  4976. m_CachedPlayerName = identity.GetName();
  4977. }
  4978. //! add callbacks for ai target system
  4979. SetAITargetCallbacks(new AITargetCallbacksPlayer(this));
  4980. array<ref Param> params = new array<ref Param>;
  4981. if (m_aQuickBarLoad)
  4982. {
  4983. int count = m_aQuickBarLoad.Count();
  4984. Param1<int> paramCount = new Param1<int>(count);
  4985. params.Insert(paramCount);
  4986. for (int i = 0; i < count; i++)
  4987. {
  4988. m_QuickBarBase.OnSetEntityNoSync(m_aQuickBarLoad.Get(i).param1,m_aQuickBarLoad.Get(i).param2);
  4989. params.Insert(m_aQuickBarLoad.Get(i));
  4990. }
  4991. if (count > 0 && GetGame().IsMultiplayer())
  4992. {
  4993. GetGame().RPC(this, ERPCs.RPC_INIT_SET_QUICKBAR, params, true, identity);
  4994. }
  4995. m_aQuickBarLoad = NULL;
  4996. }
  4997. GetSoftSkillsManager().InitSpecialty(GetStatSpecialty().Get());
  4998. GetModifiersManager().SetModifiers(true);
  4999. SetSynchDirty();
  5000. if (GetGame().IsMultiplayer())
  5001. {
  5002. //Drop item warning
  5003. if (m_ProcessUIWarning)
  5004. {
  5005. GetGame().RPCSingleParam(this, ERPCs.RPC_WARNING_ITEMDROP, null, true, identity);
  5006. m_ProcessUIWarning = false;
  5007. }
  5008. GetGame().GetMission().SyncRespawnModeInfo(identity);
  5009. }
  5010. }
  5011. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
  5012. {
  5013. m_ActionManager = new ActionManagerServer(this);
  5014. m_ConstructionActionData = new ConstructionActionData();
  5015. CheckForGag();
  5016. }
  5017. else if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  5018. {
  5019. m_ActionManager = new ActionManagerClient(this);
  5020. m_CraftingManager = new CraftingManager(this,m_ModuleRecipesManager);
  5021. m_ConstructionActionData = new ConstructionActionData();
  5022. }
  5023. else if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER)
  5024. {
  5025. m_ActionManager = new ActionManagerServer(this);
  5026. }
  5027. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  5028. {
  5029. if (GetGame().GetMission())
  5030. {
  5031. GetGame().GetMission().ResetGUI();
  5032. // force update player
  5033. GetDayZGame().GetBacklit().UpdatePlayer(true);
  5034. }
  5035. m_DeathCheckTimer = new Timer();
  5036. m_DeathCheckTimer.Run(0.1, this, "CheckDeath", null, true);
  5037. PPEManagerStatic.GetPPEManager().StopAllEffects(PPERequesterCategory.ALL);
  5038. CheckForBurlap();
  5039. int characterCount = GetGame().GetMenuData().GetCharactersCount() - 1;
  5040. int idx = GetGame().GetMenuData().GetLastPlayedCharacter();
  5041. if (idx == GameConstants.DEFAULT_CHARACTER_MENU_ID || idx > characterCount)
  5042. {
  5043. GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(SetNewCharName);
  5044. }
  5045. GetGame().GetMission().EnableAllInputs(true);
  5046. m_PresenceNotifier = PluginPresenceNotifier.Cast(GetPlugin(PluginPresenceNotifier));
  5047. m_PresenceNotifier.Init(this);
  5048. #ifdef DIAG_DEVELOPER
  5049. m_TargetTemperatureDiag = PluginTargetTemperature.Cast(GetPlugin(PluginTargetTemperature));
  5050. m_TargetTemperatureDiag.Init(this);
  5051. #endif
  5052. OnGameplayDataHandlerSync();//only here for legacy reasons
  5053. }
  5054. #ifdef BOT
  5055. m_Bot = new Bot(this);
  5056. m_Bot.Start(true, new MyBotTrigger(this));
  5057. #endif
  5058. }
  5059. override void SimulateDeath(bool state)
  5060. {
  5061. super.SimulateDeath(state);
  5062. m_UndergroundHandler = null;
  5063. m_UndergroundBunkerHandler = null;
  5064. if (m_EffectWidgets)
  5065. {
  5066. m_EffectWidgets.StopAllEffects();
  5067. m_EffectWidgets.ClearSuspendRequests();
  5068. }
  5069. }
  5070. void SetNewCharName()
  5071. {
  5072. g_Game.GetMenuData().SaveCharacter(false, true);
  5073. g_Game.GetMenuData().SetCharacterName(g_Game.GetMenuData().GetLastPlayedCharacter(), g_Game.GetMenuDefaultCharacterData(false).GetCharacterName());
  5074. g_Game.GetMenuData().SaveCharactersLocal();
  5075. }
  5076. void CheckForBurlap()
  5077. {
  5078. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  5079. {
  5080. BurlapSackCover attachment;
  5081. Class.CastTo(attachment, GetInventory().FindAttachment(InventorySlots.HEADGEAR));
  5082. PPERequester_BurlapSackEffects req;
  5083. if (Class.CastTo(req,PPERequesterBank.GetRequester(PPERequesterBank.REQ_BURLAPSACK)))
  5084. {
  5085. if (attachment)
  5086. {
  5087. req.Start();
  5088. }
  5089. else if (req.IsRequesterRunning())
  5090. {
  5091. PPERequesterBank.GetRequester(PPERequester_BurlapSackEffects).Stop();
  5092. }
  5093. }
  5094. }
  5095. }
  5096. void CheckForGag()
  5097. {
  5098. #ifdef SERVER
  5099. Clothing item;
  5100. Class.CastTo(item, GetInventory().FindAttachment(InventorySlots.MASK));
  5101. if (!item)
  5102. {
  5103. Class.CastTo(item, GetInventory().FindAttachment(InventorySlots.HEADGEAR));
  5104. }
  5105. if (item && item.IsObstructingVoice())
  5106. {
  5107. item.MutePlayer(this,true);
  5108. }
  5109. else //should probably check for relevant types before removing mumbling and obstruction specifically..
  5110. {
  5111. GetGame().SetVoiceEffect(this, VoiceEffectMumbling, false);
  5112. GetGame().SetVoiceEffect(this, VoiceEffectObstruction, false);
  5113. }
  5114. #endif
  5115. }
  5116. void UpdateMaskBreathWidget(notnull MaskBase mask, bool is_start = false)
  5117. {
  5118. if (is_start)
  5119. m_EffectWidgets.ResetMaskUpdateCount();
  5120. float resistance = 0;
  5121. if (mask.HasIntegratedFilter() || mask.IsExternalFilterAttached())
  5122. resistance = 1 - mask.GetFilterQuantity01();
  5123. m_EffectWidgets.OnVoiceEvent(resistance);
  5124. m_EffectWidgets.IncreaseMaskUpdateCount();
  5125. }
  5126. // -------------------------------------------------------------------------
  5127. void OnVoiceEvent(PlayerSoundEventBase voice_event)
  5128. {
  5129. if (m_EffectWidgets)
  5130. {
  5131. MaskBase mask = MaskBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
  5132. if (mask)
  5133. {
  5134. UpdateMaskBreathWidget(mask, true);
  5135. //m_EffectWidgets.SetBreathIntensityStamina(GetStaminaHandler().GetStaminaCap(),GetStaminaHandler().GetStamina());
  5136. }
  5137. }
  5138. }
  5139. // -------------------------------------------------------------------------
  5140. //! called every cmd handler tick during a playback of PlayerSoundEvent, m_ProcessPlaybackEvent needs to be enabled on the PlayerSoundEvent
  5141. void OnVoiceEventPlayback(PlayerSoundEventBase voice_event, AbstractWave callback, float playback_time)
  5142. {
  5143. if (m_EffectWidgets)
  5144. {
  5145. MaskBase mask = MaskBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
  5146. if (mask)
  5147. {
  5148. if (m_EffectWidgets.m_MaskWidgetUpdateCount < 2 && callback.GetLength() > 2 && playback_time > 0.5 )
  5149. UpdateMaskBreathWidget(mask);
  5150. }
  5151. }
  5152. }
  5153. // -------------------------------------------------------------------------
  5154. override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
  5155. {
  5156. if (super.OnInputUserDataProcess(userDataType, ctx))
  5157. return true;
  5158. if (m_QuickBarBase.OnInputUserDataProcess(userDataType, ctx))
  5159. return true;
  5160. if (m_WeaponManager.OnInputUserDataProcess(userDataType, ctx))
  5161. return true;
  5162. if (HandleRemoteItemManipulation(userDataType, ctx))
  5163. return true;
  5164. if (userDataType == INPUT_UDT_INVENTORY && GetHumanInventory().OnInputUserDataProcess(ctx))
  5165. return true;
  5166. if (TogglePlacingServer(userDataType, ctx))
  5167. return true;
  5168. if (ResetADSPlayerSync(userDataType, ctx))
  5169. return true;
  5170. string uid;
  5171. bool mute;
  5172. if (userDataType == INPUT_UDT_USER_MUTE_XBOX)
  5173. {
  5174. if (ctx.Read(uid) && ctx.Read(mute))
  5175. {
  5176. GetGame().MutePlayer(uid, GetIdentity().GetPlainId(), mute);
  5177. // commented because plainID should not be present in logs
  5178. //Print("Player: " + GetIdentity().GetId() + " set mute for " + uid + " to " + mute);
  5179. }
  5180. }
  5181. if (m_EmoteManager && userDataType == INPUT_UDT_GESTURE)
  5182. return m_EmoteManager.OnInputUserDataProcess(userDataType, ctx);
  5183. if (userDataType == INPUT_UDT_WEAPON_LIFT_EVENT)
  5184. return ReadLiftWeaponRequest(userDataType, ctx);
  5185. if (m_ActionManager)
  5186. return m_ActionManager.OnInputUserDataProcess(userDataType, ctx);
  5187. return false;
  5188. }
  5189. float GetHealthRegenSpeed()
  5190. {
  5191. float blood = GetHealth("GlobalHealth", "Blood");
  5192. float blood_scale_normalized = Math.InverseLerp(PlayerConstants.BLOOD_THRESHOLD_FATAL, GetMaxHealth("", "Blood"), blood);
  5193. blood_scale_normalized = Math.Clamp(blood_scale_normalized,0,1);
  5194. return Math.Lerp(PlayerConstants.HEALTH_REGEN_MIN, PlayerConstants.HEALTH_REGEN_MAX, blood_scale_normalized);
  5195. }
  5196. bool HandleRemoteItemManipulation(int userDataType, ParamsReadContext ctx)
  5197. {
  5198. if (userDataType == INPUT_UDT_ITEM_MANIPULATION)
  5199. {
  5200. int type = -1;
  5201. ItemBase item1 = null;
  5202. ItemBase item2 = null;
  5203. bool use_stack_max = false;
  5204. int slot_id = -1;
  5205. if (!ctx.Read(type))
  5206. return false;
  5207. if (type == 4)
  5208. {
  5209. if (!ctx.Read(item1))
  5210. return false;
  5211. InventoryLocation dst = new InventoryLocation;
  5212. if (item1 && dst.ReadFromContext(ctx))
  5213. {
  5214. //Print(InventoryLocation.DumpToStringNullSafe(dst));
  5215. bool dummy;
  5216. if (ctx.Read(dummy))
  5217. item1.SplitItemToInventoryLocation(dst);
  5218. else
  5219. item1.SplitIntoStackMaxToInventoryLocation(dst);
  5220. return true;
  5221. }
  5222. return false;
  5223. }
  5224. if (!ctx.Read(item1))
  5225. return false;
  5226. if (!ctx.Read(item2))
  5227. return false;
  5228. if (!ctx.Read(use_stack_max))
  5229. return false;
  5230. if (!ctx.Read(slot_id))
  5231. return false;
  5232. if (type == -1 && item1 && item2)//combine
  5233. {
  5234. item1.CombineItems(item2, use_stack_max);
  5235. }
  5236. else if (type == 1 && item1)
  5237. {
  5238. if (use_stack_max)
  5239. item1.SplitIntoStackMax(item2, slot_id, this);
  5240. else
  5241. item1.SplitItem(this);
  5242. }
  5243. else if (type == 2 && item1)
  5244. {
  5245. int row, col;
  5246. if (!ctx.Read(row))
  5247. return false;
  5248. if (!ctx.Read(col))
  5249. return false;
  5250. item1.SplitIntoStackMaxCargo(item2, slot_id, row, col);
  5251. }
  5252. else if (type == 3 && item1)
  5253. {
  5254. item1.SplitIntoStackMaxHands(this);
  5255. }
  5256. return true;
  5257. }
  5258. return false;
  5259. }
  5260. // -------------------------------------------------------------------------
  5261. ItemBase GetItemInHands()
  5262. {
  5263. HumanInventory humanInventory = GetHumanInventory();
  5264. if (humanInventory)
  5265. return ItemBase.Cast(humanInventory.GetEntityInHands());
  5266. return null;
  5267. }
  5268. //--------------------------------------------------------------------------
  5269. override EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
  5270. {
  5271. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
  5272. {
  5273. bool is_AI = GetGame().IsKindOf(object_name, "DZ_LightAI");
  5274. if (is_AI)
  5275. {
  5276. return SpawnAI(object_name, pos);
  5277. }
  5278. else
  5279. {
  5280. InventoryLocation inv_loc = new InventoryLocation;
  5281. vector mtx[4];
  5282. Math3D.MatrixIdentity4(mtx);
  5283. mtx[3] = pos;
  5284. inv_loc.SetGround(null, mtx);
  5285. int flags = ECE_PLACE_ON_SURFACE;
  5286. #ifdef DEVELOPER
  5287. if (g_Game.IsKindOf(object_name, "Boat"))
  5288. flags = ECE_KEEPHEIGHT;
  5289. #endif
  5290. return EntityAI.Cast(GetGame().CreateObjectEx(object_name, inv_loc.GetPos(), flags));
  5291. }
  5292. }
  5293. return null;
  5294. }
  5295. EntityAI SpawnEntityOnGroundRaycastDispersed(string object_name, float raycastDistance = DEFAULT_SPAWN_DISTANCE, float radius = UAItemsSpreadRadius.DEFAULT)
  5296. {
  5297. vector posRandom = MiscGameplayFunctions.GetRandomizedPositionVerifiedPlayer(this,raycastDistance,radius,this);
  5298. return SpawnEntityOnGroundPos(object_name,posRandom);
  5299. }
  5300. EntityAI SpawnEntityOnGroundOnCursorDir(string object_name, float distance)
  5301. {
  5302. vector position = GetPosition() + (GetDirection() * distance);
  5303. return SpawnEntityOnGroundPos(object_name, position);
  5304. }
  5305. EntityAI SpawnAI(string object_name, vector pos)
  5306. {
  5307. bool is_ai = GetGame().IsKindOf(object_name, "DZ_LightAI");
  5308. if (is_ai)
  5309. {
  5310. return EntityAI.Cast(GetGame().CreateObjectEx(object_name, pos, ECE_PLACE_ON_SURFACE|ECE_INITAI|ECE_EQUIP_ATTACHMENTS));
  5311. }
  5312. return NULL;
  5313. }
  5314. //--------------------------------------------------------------------------
  5315. bool DropItem(ItemBase item)
  5316. {
  5317. bool can_be_dropped = CanDropEntity(item);
  5318. if (can_be_dropped)
  5319. {
  5320. can_be_dropped = PredictiveDropEntity(item);
  5321. }
  5322. vector pos_spawn = GetPosition() + GetDirection();
  5323. pos_spawn[0] = pos_spawn[0] + Math.RandomFloat(-0.2, 0.2);
  5324. pos_spawn[2] = pos_spawn[2] + Math.RandomFloat(-0.2, 0.2);
  5325. item.SetPosition(pos_spawn);
  5326. item.PlaceOnSurface();
  5327. return can_be_dropped;
  5328. }
  5329. // -------------------------------------------------------------------------
  5330. /**
  5331. /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.
  5332. \param item_name \p string Class name of ItemBase in configs
  5333. \returns \p ItemBase Created item
  5334. @code
  5335. ItemBase item = g_Game.GetPlayer().CreateInInventory("Consumable_GardenLime", "cargo_weapon");
  5336. @endcode
  5337. */
  5338. EntityAI CreateInInventory(string item_name, string cargo_type = "", bool full_quantity = false)
  5339. {
  5340. InventoryLocation inv_loc = new InventoryLocation;
  5341. if (GetInventory().FindFirstFreeLocationForNewEntity(item_name, FindInventoryLocationType.ANY, inv_loc))
  5342. {
  5343. return SpawnItemOnLocation(item_name, inv_loc, full_quantity);
  5344. }
  5345. return NULL;
  5346. }
  5347. ItemBase CreateCopyOfItemInInventory (ItemBase src)
  5348. {
  5349. InventoryLocation loc = new InventoryLocation;
  5350. string t = src.GetType();
  5351. if (GetInventory().FindFirstFreeLocationForNewEntity(t, FindInventoryLocationType.CARGO, loc))
  5352. {
  5353. bool locked = GetGame().HasInventoryJunctureDestination(this, loc);
  5354. if (locked)
  5355. {
  5356. Print("Warning: Split: CreateCopyOfItemInInventory - Cannot create entity at locked inventory at loc=" + InventoryLocation.DumpToStringNullSafe(loc));
  5357. return null;
  5358. }
  5359. ItemBase dst = ItemBase.Cast(GetInventory().LocationCreateLocalEntity(loc, t, ECE_IN_INVENTORY, RF_DEFAULT));
  5360. if (dst)
  5361. {
  5362. MiscGameplayFunctions.TransferItemProperties(src, dst);
  5363. GetGame().RemoteObjectTreeCreate(dst);
  5364. Print("CreateCopyOfItemInInventory - created " + dst.GetName() + " at loc=" + InventoryLocation.DumpToStringNullSafe(loc));
  5365. }
  5366. return dst;
  5367. }
  5368. return NULL;
  5369. }
  5370. ItemBase CreateCopyOfItemInInventoryOrGround(ItemBase src)
  5371. {
  5372. return CreateCopyOfItemInInventoryOrGroundEx(src, false);
  5373. }
  5374. ItemBase CreateCopyOfItemInInventoryOrGroundEx(ItemBase src, bool markItemAsSplitResult = false)
  5375. {
  5376. ItemBase dst = CreateCopyOfItemInInventory(src);
  5377. if (!dst)
  5378. {
  5379. dst = ItemBase.Cast(SpawnEntityOnGroundPos(src.GetType(), this.GetPosition()));
  5380. dst.PlaceOnSurface();
  5381. dst.SetResultOfSplit(markItemAsSplitResult);
  5382. MiscGameplayFunctions.TransferItemProperties(src, dst);
  5383. }
  5384. return dst;
  5385. }
  5386. // -------------------------------------------------------------------------
  5387. /**
  5388. colorStatusChannel
  5389. colorAction
  5390. colorFriendly
  5391. colorImportant
  5392. */
  5393. void Message(string text, string style)
  5394. {
  5395. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
  5396. {
  5397. GetGame().ChatMP(this, text, style);
  5398. }
  5399. else
  5400. {
  5401. GetGame().Chat(text, style);
  5402. }
  5403. }
  5404. // -------------------------------------------------------------------------
  5405. void MessageStatus(string text)
  5406. {
  5407. Message(text, "colorStatusChannel");
  5408. }
  5409. // -------------------------------------------------------------------------
  5410. void MessageAction(string text)
  5411. {
  5412. Message(text, "colorAction");
  5413. }
  5414. // -------------------------------------------------------------------------
  5415. void MessageFriendly(string text)
  5416. {
  5417. Message(text, "colorFriendly");
  5418. }
  5419. // -------------------------------------------------------------------------
  5420. void MessageImportant(string text)
  5421. {
  5422. Message(text, "colorImportant");
  5423. }
  5424. void CloseInventoryMenu()
  5425. {
  5426. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  5427. {
  5428. #ifndef NO_GUI
  5429. UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
  5430. if (menu && (menu.GetID() == MENU_INVENTORY || menu.GetID() == MENU_INSPECT))
  5431. {
  5432. GetGame().GetUIManager().CloseAll();
  5433. GetGame().GetMission().RemoveActiveInputExcludes({"inventory"},false);
  5434. GetGame().GetMission().RemoveActiveInputRestriction(EInputRestrictors.INVENTORY);
  5435. }
  5436. #endif
  5437. }
  5438. }
  5439. // -------------------------------------------------------------------------
  5440. /**
  5441. /brief Delete all items in inventory
  5442. \returns \p void
  5443. @code
  5444. PlayerBase player = GetGame().GetPlayer();
  5445. player.ClearInventory();
  5446. @endcode
  5447. */
  5448. override void ClearInventory()
  5449. {
  5450. if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
  5451. {
  5452. GameInventory inv = PlayerBase.Cast(this).GetInventory();
  5453. array<EntityAI> items = new array<EntityAI>;
  5454. inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
  5455. for (int i = 0; i < items.Count(); i++)
  5456. {
  5457. ItemBase item = ItemBase.Cast(items.Get(i));
  5458. if (item)
  5459. {
  5460. GetGame().ObjectDelete(item);
  5461. }
  5462. }
  5463. ItemBase item_in_hands = ItemBase.Cast(GetHumanInventory().GetEntityInHands());
  5464. if (item_in_hands)
  5465. {
  5466. LocalDestroyEntityInHands();
  5467. }
  5468. }
  5469. }
  5470. //! Drops all clothes/wearables this character is carrying on themselves.
  5471. void DropAllItems()
  5472. {
  5473. array<EntityAI> itemsArray = new array<EntityAI>;
  5474. ItemBase item;
  5475. GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, itemsArray);
  5476. int count = itemsArray.Count();
  5477. for (int i = 0; i < itemsArray.Count(); i++)
  5478. {
  5479. Class.CastTo(item, itemsArray.Get(i));
  5480. if (item && !item.IsInherited(SurvivorBase))
  5481. {
  5482. ServerDropEntity(item);
  5483. }
  5484. }
  5485. }
  5486. string GetPlayerClass()
  5487. {
  5488. string type;
  5489. GetGame().ObjectGetType(this, type);
  5490. return type;
  5491. }
  5492. // --------------------------------------------------
  5493. // Lifespan
  5494. //---------------------------------------------------
  5495. void ShavePlayer()
  5496. {
  5497. SetLastShavedSeconds(StatGet(AnalyticsManagerServer.STAT_PLAYTIME));
  5498. m_ModuleLifespan.UpdateLifespan(this, true);
  5499. }
  5500. bool CanShave()
  5501. {
  5502. if (!HasCoveredFaceForShave() && GetLifeSpanState())
  5503. {
  5504. return true;
  5505. }
  5506. else
  5507. {
  5508. return false;
  5509. }
  5510. }
  5511. override void OnParticleEvent(string pEventType, string pUserString, int pUserInt)
  5512. {
  5513. super.OnParticleEvent(pEventType ,pUserString, pUserInt);
  5514. if (!GetGame().IsDedicatedServer())
  5515. {
  5516. if (pUserInt == 123456) // 123456 is ID for vomiting effect. The current implementation is WIP.
  5517. {
  5518. PlayerBase player = PlayerBase.Cast(this);
  5519. int boneIdx = player.GetBoneIndexByName("Head");
  5520. if (boneIdx != -1)
  5521. {
  5522. EffectParticle eff;
  5523. if (m_SyncedModifiers & eModifierSyncIDs.MODIFIER_SYNC_CONTAMINATION2)
  5524. {
  5525. eff = new EffVomitBlood();
  5526. }
  5527. else
  5528. {
  5529. eff = new EffVomit();
  5530. }
  5531. eff.SetDecalOwner(player);
  5532. eff.SetAutodestroy(true);
  5533. SEffectManager.PlayInWorld(eff, vector.Zero);
  5534. Particle p = eff.GetParticle();
  5535. player.AddChild(p, boneIdx);
  5536. }
  5537. }
  5538. }
  5539. }
  5540. bool CanSpawnBreathVaporEffect()
  5541. {
  5542. if (!ToDelete() && IsAlive() && !IsSwimming() && !m_IsDrowning)
  5543. {
  5544. return true;
  5545. }
  5546. return false;
  5547. }
  5548. void ProcessADDModifier()
  5549. {
  5550. if (m_AddModifier != -1)
  5551. {
  5552. HumanCommandAdditives ad = GetCommandModifier_Additives();
  5553. if (ad)
  5554. ad.StartModifier(m_AddModifier);
  5555. m_AddModifier = -1;
  5556. }
  5557. }
  5558. void SpawnBreathVaporEffect()
  5559. {
  5560. //Print("SpawnBreathVaporEffect:"+GetGame().GetTime());
  5561. int boneIdx = GetBoneIndexByName("Head");
  5562. if (boneIdx != -1)
  5563. {
  5564. Particle p;
  5565. switch (m_BreathVapour)
  5566. {
  5567. case 1:
  5568. p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_LIGHT, "-0.03 0.15 0");
  5569. break;
  5570. case 2:
  5571. p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_MEDIUM, "-0.03 0.15 0");
  5572. break;
  5573. case 3:
  5574. p = ParticleManager.GetInstance().PlayInWorld(ParticleList.BREATH_VAPOUR_HEAVY, "-0.03 0.15 0");
  5575. break;
  5576. default:
  5577. break;
  5578. }
  5579. if (p)
  5580. AddChild(p, boneIdx);
  5581. }
  5582. }
  5583. // 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
  5584. bool GetDrowningWaterLevelCheck()
  5585. {
  5586. int index = GetBoneIndexByName("head");
  5587. vector pos = GetBonePositionWS(index);
  5588. float depth = g_Game.GetWaterDepth(pos);
  5589. if (IsSwimming())
  5590. {
  5591. return depth > PlayerConstants.DROWNING_SWIMMING_THRESHOLD;
  5592. }
  5593. else if (IsUnconscious())
  5594. {
  5595. return depth > PlayerConstants.DROWNING_UNCONSCIOUS_THRESHOLD;
  5596. }
  5597. return depth > PlayerConstants.DROWNING_DEFAULT_THRESHOLD;
  5598. }
  5599. void SetLifeSpanStateVisible(int show_state)
  5600. {
  5601. bool state_changed;
  5602. if (show_state != m_LifeSpanState)
  5603. state_changed = true;
  5604. m_LifeSpanState = show_state;
  5605. SetSynchDirty();
  5606. if (state_changed) //server only, client solution in OnVariablesSynchronized()
  5607. {
  5608. //SendLifespanSyncEvent(m_LifeSpanState);
  5609. UpdateHairSelectionVisibility();
  5610. }
  5611. }
  5612. int GetLifeSpanState()
  5613. {
  5614. return m_LifeSpanState;
  5615. }
  5616. int GetLastShavedSeconds()
  5617. {
  5618. return m_LastShavedSeconds;
  5619. }
  5620. void SetLastShavedSeconds(int last_shaved_seconds)
  5621. {
  5622. m_LastShavedSeconds = last_shaved_seconds;
  5623. }
  5624. bool HasCoveredFaceForShave()
  5625. {
  5626. return IsExclusionFlagPresent(GetFaceCoverageShaveValues());
  5627. }
  5628. //! returns a set of face covering values
  5629. static set<int> GetFaceCoverageShaveValues()
  5630. {
  5631. set<int> ret = new set<int>;
  5632. ret.Insert(EAttExclusions.SHAVING_MASK_ATT_0);
  5633. ret.Insert(EAttExclusions.SHAVING_HEADGEAR_ATT_0);
  5634. //ret.Insert(EAttExclusions.SHAVING_EYEWEAR_ATT_0);
  5635. return ret;
  5636. }
  5637. eBloodyHandsTypes HasBloodyHandsEx()
  5638. {
  5639. return m_HasBloodyHandsVisible;
  5640. }
  5641. bool HasBloodyHands()
  5642. {
  5643. return m_HasBloodyHandsVisible;
  5644. }
  5645. void SetBloodyHands(bool show)
  5646. {
  5647. SetBloodyHandsBase(show);
  5648. }
  5649. void SetBloodyHandsEx(eBloodyHandsTypes type)
  5650. {
  5651. SetBloodyHandsBase(type);
  5652. }
  5653. private void SetBloodyHandsBase(int type)
  5654. {
  5655. m_HasBloodyHandsVisible = type;
  5656. SetSynchDirty();
  5657. #ifdef DIAG_DEVELOPER
  5658. #ifndef SERVER
  5659. if (IsControlledPlayer())
  5660. {
  5661. bool enable = type;
  5662. DiagMenu.SetValue(DiagMenuIDs.LIFESPAN_BLOODY_HANDS, enable);
  5663. }
  5664. #endif
  5665. #endif
  5666. }
  5667. int GetBloodyHandsPenaltyAgents()
  5668. {
  5669. if (HasBloodyHands())
  5670. {
  5671. if (GetInventory().FindAttachment(InventorySlots.GLOVES))
  5672. return 0;
  5673. float randomValue = Math.RandomFloat01();
  5674. if (GetBloodyHandsPenaltyChancePerAgent(eAgents.SALMONELLA) >= randomValue)
  5675. return eAgents.SALMONELLA;
  5676. return eAgents.FOOD_POISON;
  5677. }
  5678. return 0;
  5679. }
  5680. float GetBloodyHandsPenaltyChancePerAgent(eAgents type)
  5681. {
  5682. float value = 0.0;
  5683. if (m_BloodyHandsPenaltyChancePerAgent.Find(type, value))
  5684. return value;
  5685. return value;
  5686. }
  5687. //! increments the chances per agents
  5688. void SetBloodyHandsPenaltyChancePerAgent(eAgents type, float amount)
  5689. {
  5690. float storedValue = GetBloodyHandsPenaltyChancePerAgent(type);
  5691. if (amount > storedValue)
  5692. m_BloodyHandsPenaltyChancePerAgent.Set(type, Math.Clamp(amount, 0.0, 1.0));
  5693. }
  5694. void ClearBloodyHandsPenaltyChancePerAgent(eAgents type)
  5695. {
  5696. m_BloodyHandsPenaltyChancePerAgent.Set(type, 0.0);
  5697. }
  5698. bool HasBloodTypeVisible()
  5699. {
  5700. return m_HasBloodTypeVisible;
  5701. }
  5702. void SetBloodTypeVisible(bool show)
  5703. {
  5704. m_HasBloodTypeVisible = show;
  5705. SetSynchDirty();
  5706. }
  5707. int GetBloodType()
  5708. {
  5709. return m_BloodType;
  5710. }
  5711. void SetBloodType(int blood_type)
  5712. {
  5713. m_BloodType = blood_type;
  5714. SetSynchDirty();
  5715. }
  5716. // --------------------------------------------------
  5717. // Soft Skills
  5718. //---------------------------------------------------
  5719. SoftSkillsManager GetSoftSkillsManager()
  5720. {
  5721. return m_SoftSkillsManager;
  5722. }
  5723. void CheckDeath()
  5724. {
  5725. if (IsPlayerSelected() && !IsAlive())
  5726. {
  5727. SimulateDeath(true);
  5728. m_DeathCheckTimer.Stop();
  5729. }
  5730. }
  5731. // -------------------------------------------------------------------------
  5732. // --------------------------------------------------
  5733. // AI Presence
  5734. //---------------------------------------------------
  5735. //! Return actual noise presence of player
  5736. int GetNoisePresenceInAI()
  5737. {
  5738. if (m_PresenceNotifier)
  5739. {
  5740. return m_PresenceNotifier.GetNoisePresence();
  5741. }
  5742. return 0;
  5743. }
  5744. // is a bit on in the persistent flags
  5745. bool IsPersistentFlag(PersistentFlag bit)
  5746. {
  5747. return (m_PersistentFlags & bit);
  5748. }
  5749. // turn on/off a bit in the persistent flag
  5750. void SetPersistentFlag(PersistentFlag bit, bool enable)
  5751. {
  5752. if (enable)//turn on bit
  5753. m_PersistentFlags = (m_PersistentFlags | bit);
  5754. else//turn off bit
  5755. m_PersistentFlags = ((~bit) & m_PersistentFlags);
  5756. }
  5757. // -------------------------------------------------------------------------
  5758. int GetStoreLoadVersion()
  5759. {
  5760. return m_StoreLoadVersion;
  5761. }
  5762. override void OnStoreSave(ParamsWriteContext ctx)
  5763. {
  5764. //Print("OnStoreSave");
  5765. if (GetGame().SaveVersion() < 102)
  5766. {
  5767. ctx.Write(ACT_STORE_SAVE_VERSION);//to be removed after we push 102+
  5768. }
  5769. super.OnStoreSave(ctx);
  5770. GetHumanInventory().OnStoreSave(ctx); // FSM of hands
  5771. OnStoreSaveLifespan(ctx);
  5772. if (GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer())
  5773. {
  5774. GetPlayerStats().SaveStats(ctx);// save stats
  5775. m_ModifiersManager.OnStoreSave(ctx);// save modifiers
  5776. m_AgentPool.OnStoreSave(ctx);//save agents
  5777. GetSymptomManager().OnStoreSave(ctx);//save states
  5778. if (GetBleedingManagerServer())
  5779. {
  5780. GetBleedingManagerServer().OnStoreSave(ctx);//save bleeding sources
  5781. }
  5782. m_PlayerStomach.OnStoreSave(ctx);
  5783. ctx.Write(GetBrokenLegs());
  5784. //ctx.Write(m_LocalBrokenState);
  5785. SaveAreaPersistenceFlag(ctx);
  5786. HumanCommandLadder ladder = GetCommand_Ladder();
  5787. if (ladder)
  5788. {
  5789. ctx.Write(true);
  5790. ctx.Write(ladder.GetLogoutPosition());
  5791. }
  5792. else
  5793. {
  5794. ctx.Write(false);
  5795. }
  5796. ArrowManagerPlayer arrowManager = ArrowManagerPlayer.Cast(GetArrowManager());
  5797. arrowManager.Save(ctx);
  5798. }
  5799. }
  5800. void SaveAreaPersistenceFlag(ParamsWriteContext ctx)
  5801. {
  5802. if (GetModifiersManager())
  5803. SetPersistentFlag(PersistentFlag.AREA_PRESENCE, GetModifiersManager().IsModifierActive(eModifiers.MDF_AREAEXPOSURE));//set the flag for player's presence in contaminated area
  5804. ctx.Write(m_PersistentFlags);
  5805. }
  5806. override bool OnStoreLoad(ParamsReadContext ctx, int version)
  5807. {
  5808. //Print("---- PlayerBase OnStoreLoad START ----, version: "+version);
  5809. m_aQuickBarLoad = new array<ref Param2<EntityAI,int>>;
  5810. // todo :: this should be after base call !!!!
  5811. if (version < 102)//write removed in v. 102
  5812. {
  5813. if (!ctx.Read(m_StoreLoadVersion))
  5814. return false;
  5815. }
  5816. if (!super.OnStoreLoad(ctx, version))
  5817. return false;
  5818. // FSM of hands
  5819. if (!GetHumanInventory().OnStoreLoad(ctx, version))
  5820. return false;
  5821. if (!OnStoreLoadLifespan(ctx, version))
  5822. return false;
  5823. if (GetDayZGame().IsServer() && GetDayZGame().IsMultiplayer())
  5824. {
  5825. if (!GetPlayerStats().LoadStats(ctx, version)) // load stats
  5826. {
  5827. Print("---- failed to load PlayerStats ----");
  5828. return false;
  5829. }
  5830. if (!m_ModifiersManager.OnStoreLoad(ctx, version))
  5831. {
  5832. Print("---- failed to load ModifiersManager, read fail ----");
  5833. return false;
  5834. }
  5835. if (!m_AgentPool.OnStoreLoad(ctx, version))
  5836. {
  5837. Print("---- failed to load AgentPool, read fail ----");
  5838. return false;
  5839. }
  5840. if (!GetSymptomManager().OnStoreLoad(ctx, version))
  5841. {
  5842. Print("---- failed to load SymptomManager, read fail ----");
  5843. return false;
  5844. }
  5845. if (!GetBleedingManagerServer().OnStoreLoad(ctx, version))
  5846. {
  5847. Print("---- failed to load BleedingManagerServer, read fail ----");
  5848. return false;
  5849. }
  5850. if (!m_PlayerStomach.OnStoreLoad(ctx, version))
  5851. {
  5852. Print("---- failed to load PlayerStomach, read fail ----");
  5853. return false;
  5854. }
  5855. //Check for broken leg value
  5856. if (version >= 116)
  5857. {
  5858. if (!ctx.Read(m_BrokenLegState))
  5859. {
  5860. return false;
  5861. }
  5862. if (version <= 126)// WHILE >= 116
  5863. {
  5864. if (!ctx.Read(m_LocalBrokenState))
  5865. {
  5866. return false;
  5867. }
  5868. }
  5869. }
  5870. //Load persistent flags value
  5871. if (version >= 125 && (!ctx.Read(m_PersistentFlags)))
  5872. {
  5873. Print("---- failed to load Persistent Flags, read fail ----");
  5874. return false;
  5875. }
  5876. if (version >= 131)
  5877. {
  5878. bool onLadder;
  5879. if (!ctx.Read(onLadder))
  5880. {
  5881. return false;
  5882. }
  5883. if (onLadder)
  5884. {
  5885. vector position;
  5886. if (!ctx.Read(position))
  5887. {
  5888. return false;
  5889. }
  5890. Hive hive = GetHive();
  5891. if (!hive || !hive.CharacterIsLoginPositionChanged(this))
  5892. {
  5893. SetPosition(position);
  5894. }
  5895. }
  5896. }
  5897. if (version >= 134)
  5898. {
  5899. ArrowManagerPlayer arrowManager = ArrowManagerPlayer.Cast(GetArrowManager());
  5900. arrowManager.Load(ctx);
  5901. }
  5902. }
  5903. Print("---- PlayerBase OnStoreLoad SUCCESS ----");
  5904. return true;
  5905. }
  5906. override void AfterStoreLoad()
  5907. {
  5908. GetHumanInventory().OnAfterStoreLoad();
  5909. if (m_EmoteManager)
  5910. m_EmoteManager.AfterStoreLoad();
  5911. if (GetPlayerStats())
  5912. GetPlayerStats().OnAfterStoreLoad();
  5913. PlayerRestrictedAreaInstance pra;
  5914. vector currentPos = GetPosition();
  5915. if (g_Game.GetGameState() != DayZGameState.MAIN_MENU && CfgPlayerRestrictedAreaHandler.IsInitialized() && CfgPlayerRestrictedAreaHandler.IsPointInPlayerRestrictedArea(currentPos,pra))
  5916. {
  5917. //vector safePos = pra.GetClosestSafePos3D(currentPos);
  5918. vector safePos = pra.GetRandomSafePos3D(currentPos);
  5919. if (MiscGameplayFunctions.TeleportPlayerToSafeLocation3D(this,safePos) && m_AdminLog)
  5920. m_AdminLog.PlayerTeleportedLog(this,currentPos,safePos,"Spawning in Player Restricted Area: " + pra.areaName);
  5921. }
  5922. }
  5923. void OnStoreSaveLifespan(ParamsWriteContext ctx)
  5924. {
  5925. ctx.Write(m_LifeSpanState);
  5926. ctx.Write(m_LastShavedSeconds);
  5927. ctx.Write(m_HasBloodyHandsVisible);
  5928. ctx.Write(m_HasBloodTypeVisible);
  5929. ctx.Write(m_BloodType);
  5930. }
  5931. bool OnStoreLoadLifespan(ParamsReadContext ctx, int version)
  5932. {
  5933. int lifespan_state = 0;
  5934. if (!ctx.Read(lifespan_state))
  5935. return false;
  5936. m_LifeSpanState = lifespan_state;
  5937. int last_shaved = 0;
  5938. if (!ctx.Read(last_shaved))
  5939. return false;
  5940. m_LastShavedSeconds = last_shaved;
  5941. if (version < 122)
  5942. {
  5943. bool bloody_hands_old;
  5944. if (!ctx.Read(bloody_hands_old))
  5945. return false;
  5946. m_HasBloodyHandsVisible = bloody_hands_old;
  5947. }
  5948. else
  5949. {
  5950. int bloody_hands = 0;
  5951. if (!ctx.Read(bloody_hands))
  5952. return false;
  5953. m_HasBloodyHandsVisible = bloody_hands;
  5954. }
  5955. bool blood_visible = false;
  5956. if (!ctx.Read(blood_visible))
  5957. return false;
  5958. m_HasBloodTypeVisible = blood_visible;
  5959. int blood_type = 0;
  5960. if (!ctx.Read(blood_type))
  5961. return false;
  5962. m_BloodType = blood_type;
  5963. return true;
  5964. }
  5965. vector m_PlayerOldPos;
  5966. void UpdatePlayerMeasures()
  5967. {
  5968. int hour, minute, second;
  5969. GetHourMinuteSecond(hour, minute, second);
  5970. float distance;
  5971. distance = StatGet(AnalyticsManagerServer.STAT_DISTANCE);
  5972. if (m_AnalyticsTimer)
  5973. {
  5974. StatsEventMeasuresData data = new StatsEventMeasuresData();
  5975. data.m_CharacterId = g_Game.GetDatabaseID();
  5976. data.m_TimeInterval = m_AnalyticsTimer.GetRemaining();
  5977. data.m_DaytimeHour = hour;
  5978. data.m_PositionStart = m_PlayerOldPos;
  5979. data.m_PositionEnd = GetPosition();
  5980. data.m_DistanceOnFoot = distance;
  5981. Analytics.PlayerMeasures(data);
  5982. }
  5983. m_PlayerOldPos = GetPosition();
  5984. }
  5985. void OnConnect()
  5986. {
  5987. Debug.Log("Player connected:"+this.ToString(),"Connect");
  5988. // analytics
  5989. GetGame().GetAnalyticsServer().OnPlayerConnect(this);
  5990. m_PlayerOldPos = GetPosition();
  5991. if (m_AnalyticsTimer)
  5992. m_AnalyticsTimer.Run(60, this, "UpdatePlayerMeasures", null, true);
  5993. //construction action data
  5994. ResetConstructionActionData();
  5995. }
  5996. void OnReconnect()
  5997. {
  5998. Debug.Log("Player reconnected:"+this.ToString(),"Reconnect");
  5999. //construction action data
  6000. ResetConstructionActionData();
  6001. }
  6002. void OnDisconnect()
  6003. {
  6004. Debug.Log("Player disconnected:"+this.ToString(),"Connect");
  6005. // analytics
  6006. // force update of the stats
  6007. // if player disconnect too soon, UpdatePlayersStats() is not called
  6008. GetGame().GetAnalyticsServer().OnPlayerDisconnect(this);
  6009. StatsEventDisconnectedData data = new StatsEventDisconnectedData();
  6010. data.m_CharacterId = g_Game.GetDatabaseID();
  6011. data.m_Reason = "Disconnected";
  6012. Analytics.PlayerDisconnected(data);
  6013. if (m_AnalyticsTimer)
  6014. m_AnalyticsTimer.Stop();
  6015. UpdatePlayerMeasures();
  6016. SetPlayerDisconnected(true);
  6017. }
  6018. void SetModifiers(bool enable)
  6019. {
  6020. GetModifiersManager().SetModifiers(enable);
  6021. }
  6022. bool Consume(PlayerConsumeData data)
  6023. {
  6024. PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
  6025. int pollution = GetGame().GetMission().GetWorldData().GetPollution();
  6026. float temperature = 0;
  6027. if (data.m_Type == EConsumeType.ENVIRO_POND || data.m_Type == EConsumeType.ENVIRO_WELL || data.m_Type == EConsumeType.ENVIRO_SNOW)
  6028. {
  6029. if (data.m_Type != EConsumeType.ENVIRO_WELL)
  6030. {
  6031. if (pollution & EPollution.HEAVYMETAL)
  6032. data.m_Agents = data.m_Agents | eAgents.HEAVYMETAL;
  6033. if (data.m_Type == EConsumeType.ENVIRO_POND)
  6034. data.m_Agents = data.m_Agents | eAgents.CHOLERA;
  6035. }
  6036. temperature = GetGame().GetMission().GetWorldData().GetLiquidTypeEnviroTemperature(data.m_LiquidType);
  6037. m_PlayerStomach.AddToStomach(Liquid.GetLiquidClassname(LIQUID_WATER), data.m_Amount, 0 , data.m_Agents, temperature);
  6038. return true;
  6039. }
  6040. Edible_Base edibleItem = Edible_Base.Cast(data.m_Source);
  6041. if (!edibleItem || !edibleItem.CanBeConsumed())
  6042. return false;
  6043. if (data.m_Type == EConsumeType.ITEM_SINGLE_TIME || data.m_Type == EConsumeType.ITEM_CONTINUOUS)
  6044. {
  6045. data.m_Agents = edibleItem.FilterAgents(data.m_Agents | edibleItem.GetAgents());
  6046. temperature = edibleItem.GetTemperature();
  6047. if (data.m_Type == EConsumeType.ITEM_SINGLE_TIME)
  6048. plugin.TransmitAgents(edibleItem, this, AGT_UACTION_CONSUME, data.m_Amount);
  6049. if (edibleItem.IsLiquidContainer())
  6050. {
  6051. int liquidType = edibleItem.GetLiquidType();
  6052. string liquidClassName = Liquid.GetLiquidClassname(liquidType);
  6053. if (liquidClassName.Length() == 0)
  6054. Error("Error! Trying to add unknown liquid to stomach with item=" + Object.GetDebugName(edibleItem) + " data.m_Type=" + data.m_Type + " liquid_type=" + liquidType);
  6055. m_PlayerStomach.AddToStomach(liquidClassName, data.m_Amount, 0, data.m_Agents, temperature);
  6056. }
  6057. else
  6058. {
  6059. int foodStageType;
  6060. if (edibleItem.GetFoodStage())
  6061. foodStageType = edibleItem.GetFoodStage().GetFoodStageType();
  6062. m_PlayerStomach.AddToStomach(data.m_Source.GetType(), data.m_Amount, foodStageType, data.m_Agents, temperature);
  6063. }
  6064. edibleItem.Consume(data.m_Amount, this);
  6065. return true;
  6066. }
  6067. return false;
  6068. }
  6069. void ShowUnconsciousScreen(bool show)
  6070. {
  6071. #ifndef NO_GUI
  6072. if (show)
  6073. {
  6074. GetGame().GetUIManager().ScreenFadeIn(0, "You are Unconscious", FadeColors.BLACK, FadeColors.WHITE);
  6075. PrintString("Fade in");
  6076. }
  6077. else
  6078. {
  6079. GetGame().GetUIManager().ScreenFadeOut(0);
  6080. PrintString("Fade out");
  6081. }
  6082. #endif
  6083. }
  6084. override void RequestSoundEventEx(EPlayerSoundEventID id, bool from_server_and_client = false, int param = 0)
  6085. {
  6086. if (from_server_and_client && GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  6087. {
  6088. PlaySoundEventEx(id, false, false, param);
  6089. return;
  6090. }
  6091. SendSoundEventEx(id, param);
  6092. }
  6093. override void RequestSoundEvent(EPlayerSoundEventID id, bool from_server_and_client = false)
  6094. {
  6095. RequestSoundEventEx(id, from_server_and_client);
  6096. }
  6097. override protected void SendSoundEvent(EPlayerSoundEventID id)
  6098. {
  6099. SendSoundEventEx(id);
  6100. }
  6101. override protected void SendSoundEventEx(EPlayerSoundEventID id, int param = 0)
  6102. {
  6103. if (!GetGame().IsServer())
  6104. {
  6105. return;
  6106. }
  6107. m_SoundEvent = id;
  6108. m_SoundEventParam = param;
  6109. SetSynchDirty();
  6110. if (!GetGame().IsMultiplayer())
  6111. {
  6112. CheckSoundEvent();
  6113. }
  6114. //PrintString(GetGame().GetTime().ToString() + " Set SoundEvent, id:" + id.ToString());
  6115. }
  6116. void CheckZeroSoundEvent()
  6117. {
  6118. if (m_SoundEvent != 0 && m_SoundEventSent)
  6119. {
  6120. m_SoundEvent = 0;
  6121. m_SoundEventParam = 0;
  6122. m_SoundEventSent = false;
  6123. SetSynchDirty();
  6124. }
  6125. }
  6126. void CheckSendSoundEvent()
  6127. {
  6128. if (m_SoundEvent!= 0 && !m_SoundEventSent)
  6129. {
  6130. m_SoundEventSent = true;
  6131. }
  6132. }
  6133. override bool PlaySoundEventType(ESoundEventType soundType, int soundEventID, int param = 0)
  6134. {
  6135. if (m_ReplaceSoundEventHandler)
  6136. return m_ReplaceSoundEventHandler.PlayReplaceSound(soundEventID, soundType, param);
  6137. return false;
  6138. }
  6139. override bool PlaySoundEvent(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false)
  6140. {
  6141. return PlaySoundEventEx(id, from_anim_system, is_from_server);
  6142. }
  6143. override bool PlaySoundEventEx(EPlayerSoundEventID id, bool from_anim_system = false, bool is_from_server = false, int param = 0)
  6144. {
  6145. if (!m_PlayerSoundEventHandler)
  6146. return false;
  6147. return m_PlayerSoundEventHandler.PlayRequestEx(id, is_from_server, param);
  6148. }
  6149. PlayerSoundEventHandler GetPlayerSoundEventHandler()
  6150. {
  6151. return m_PlayerSoundEventHandler;
  6152. }
  6153. void OnBleedingBegin();
  6154. void OnBleedingEnd();
  6155. void OnBleedingSourceAdded()
  6156. {
  6157. m_BleedingSourceCount++;
  6158. if (IsControlledPlayer())
  6159. {
  6160. if (!GetGame().IsDedicatedServer())
  6161. {
  6162. DisplayElementBadge dis_elm = DisplayElementBadge.Cast(GetVirtualHud().GetElement(eDisplayElements.DELM_BADGE_BLEEDING));
  6163. if (dis_elm)
  6164. {
  6165. dis_elm.SetValue(GetBleedingSourceCount());
  6166. }
  6167. //Print("----------bleeding_SoundSet----------");
  6168. SEffectManager.PlaySoundOnObject("bleeding_SoundSet", this);
  6169. }
  6170. }
  6171. }
  6172. void OnBleedingSourceRemoved()
  6173. {
  6174. m_BleedingSourceCount--;
  6175. if (GetGame().IsServer())
  6176. {
  6177. ArrowManagerBase arrowManager = GetArrowManager();
  6178. if (GetBleedingSourceCount() > 0)
  6179. {
  6180. arrowManager.DropFirstArrow();
  6181. }
  6182. else
  6183. {
  6184. arrowManager.DropAllArrows();
  6185. }
  6186. }
  6187. if (IsControlledPlayer())
  6188. {
  6189. if (!GetGame().IsDedicatedServer())
  6190. {
  6191. //Print("GetBleedingSourceCount() "+GetBleedingSourceCount());
  6192. DisplayElementBadge dis_elm = DisplayElementBadge.Cast(GetVirtualHud().GetElement(eDisplayElements.DELM_BADGE_BLEEDING));
  6193. if (dis_elm)
  6194. {
  6195. dis_elm.SetValue(GetBleedingSourceCount());
  6196. }
  6197. }
  6198. }
  6199. }
  6200. void OnBleedingSourceRemovedEx(ItemBase item)
  6201. {
  6202. OnBleedingSourceRemoved();
  6203. }
  6204. int GetBleedingSourceCount()
  6205. {
  6206. return m_BleedingSourceCount;
  6207. }
  6208. // for debug purposes, should reset some systems like Modifiers, Stats, Damage etc.....
  6209. void ResetPlayer(bool set_max)
  6210. {
  6211. #ifdef DIAG_DEVELOPER
  6212. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  6213. {
  6214. GetStomach().ClearContents();
  6215. DamageSystem.ResetAllZones(this);
  6216. GetModifiersManager().ResetAll();
  6217. // bleeding sources
  6218. if (m_BleedingManagerServer)
  6219. m_BleedingManagerServer.RemoveAllSources();
  6220. // Stats
  6221. if (GetPlayerStats())
  6222. {
  6223. int bloodType = GetStatBloodType().Get();
  6224. GetPlayerStats().ResetAllStats();
  6225. GetStatBloodType().Set(bloodType);
  6226. }
  6227. // Agents
  6228. if (m_AgentPool)
  6229. m_AgentPool.RemoveAllAgents();
  6230. if (m_StaminaHandler)
  6231. m_StaminaHandler.SetStamina(GameConstants.STAMINA_MAX);
  6232. // uncon
  6233. if (IsUnconscious())
  6234. DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, false);
  6235. // set max
  6236. if (set_max)
  6237. {
  6238. GetStatWater().Set(GetStatWater().GetMax());
  6239. GetStatEnergy().Set(GetStatEnergy().GetMax());
  6240. }
  6241. // fix up inventory
  6242. FixAllInventoryItems();
  6243. //remove bloody hands
  6244. PluginLifespan moduleLifespan = PluginLifespan.Cast(GetPlugin(PluginLifespan));
  6245. moduleLifespan.UpdateBloodyHandsVisibilityEx(this, eBloodyHandsTypes.CLEAN);
  6246. ClearBloodyHandsPenaltyChancePerAgent(eAgents.SALMONELLA);
  6247. if (GetArrowManager())
  6248. GetArrowManager().ClearArrows();
  6249. }
  6250. // client + single + server
  6251. HumanCommandVehicle vehCmd = GetCommand_Vehicle();
  6252. if (vehCmd)
  6253. {
  6254. Transport transport = vehCmd.GetTransport();
  6255. if (transport)
  6256. transport.FixEntity();
  6257. }
  6258. #endif
  6259. }
  6260. void CheckSoundEvent()
  6261. {
  6262. if (m_SoundEvent != 0)
  6263. {
  6264. PlaySoundEventEx(m_SoundEvent, false, true,m_SoundEventParam);
  6265. m_SoundEvent = 0;
  6266. m_SoundEventParam = 0;
  6267. }
  6268. // cancelling marked interrupted sounds
  6269. if (m_PerformedAnimActionID == -1)
  6270. {
  6271. if (m_PerformedActionSounds.Count() == 0)
  6272. return;
  6273. foreach (AbstractWave sound : m_PerformedActionSounds)
  6274. {
  6275. if (sound)
  6276. sound.Stop();
  6277. }
  6278. m_PerformedActionSounds.Clear();
  6279. }
  6280. }
  6281. void TestSend()
  6282. {
  6283. if (GetGame().IsClient()) return;
  6284. RequestSoundEvent(1234);
  6285. //Math.RandomInt(1,4096)
  6286. }
  6287. void SetStaminaState(eStaminaState state)
  6288. {
  6289. if (state != m_StaminaState)
  6290. {
  6291. m_StaminaState = state;
  6292. //PrintString("m_StaminaState:"+m_StaminaState.ToString());
  6293. SetSynchDirty();
  6294. }
  6295. }
  6296. int GetStaminaState()
  6297. {
  6298. return m_StaminaState;
  6299. }
  6300. void UpdateQuickBarExtraSlots()
  6301. {
  6302. m_QuickBarBase.updateSlotsCount();
  6303. }
  6304. bool Save()
  6305. {
  6306. // saved player must be alive and not captive
  6307. if (GetPlayerState() == EPlayerStates.ALIVE && !IsRestrained())
  6308. {
  6309. GetHive().CharacterSave(this);
  6310. Debug.Log("Player "+this.ToString()+ " saved as alive");
  6311. return true;
  6312. }
  6313. return false;
  6314. }
  6315. // agent transfer
  6316. //! chance between [0..1] , distance in meters
  6317. void SpreadAgentsEx(float distance = 3,float chance = 0.25)
  6318. {
  6319. if (Math.RandomFloat01() > chance)
  6320. return;
  6321. GetGame().GetPlayers(m_ServerPlayers);
  6322. float dist_check = distance * distance;//make it sq
  6323. PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
  6324. foreach (Man target: m_ServerPlayers)
  6325. {
  6326. if (vector.DistanceSq(GetWorldPosition(), target.GetWorldPosition()) < dist_check && target != this)
  6327. {
  6328. plugin.TransmitAgents(this, target, AGT_AIRBOURNE_BIOLOGICAL, 1);
  6329. }
  6330. }
  6331. }
  6332. void SpreadAgents()//legacy method
  6333. {
  6334. SpreadAgentsEx(3,1);
  6335. }
  6336. //--------------------------------------------------------------------------------------------
  6337. override int GetAgents()
  6338. {
  6339. return m_AgentPool.GetAgents();
  6340. }
  6341. //--------------------------------------------------------------------------------------------
  6342. override void RemoveAgent(int agent_id) //removes a single agent type from the player agent pool
  6343. {
  6344. m_AgentPool.RemoveAgent(agent_id);
  6345. }
  6346. //--------------------------------------------------------------------------------------------
  6347. override void RemoveAllAgents()
  6348. {
  6349. m_AgentPool.RemoveAllAgents();
  6350. }
  6351. //--------------------------------------------------------------------------------------------
  6352. override void InsertAgent(int agent, float count = 1) //adds a single agent type to the player agent pool
  6353. {
  6354. m_AgentPool.AddAgent(agent,count);
  6355. }
  6356. //--------------------------------------------------------------------------------------------
  6357. int GetSingleAgentCount(int agent_id)
  6358. {
  6359. return m_AgentPool.GetSingleAgentCount(agent_id);
  6360. }
  6361. //--------------------------------------------------------------------------------------------
  6362. float GetSingleAgentCountNormalized(int agent_id)
  6363. {
  6364. int max_count = PluginTransmissionAgents.GetAgentMaxCount(agent_id);
  6365. return m_AgentPool.GetSingleAgentCount(agent_id) / max_count;
  6366. }
  6367. float GetTotalAgentCount()
  6368. {
  6369. return m_AgentPool.GetTotalAgentCount();
  6370. }
  6371. void PrintAgents()
  6372. {
  6373. m_AgentPool.PrintAgents();
  6374. }
  6375. void ImmuneSystemTick(float value, float deltaT)
  6376. {
  6377. m_AgentPool.ImmuneSystemTick(value, deltaT);
  6378. }
  6379. void AntibioticsAttack(float value)
  6380. {
  6381. m_AgentPool.DrugsAttack(EMedicalDrugsType.ANTIBIOTICS, value);
  6382. }
  6383. void SetTemporaryResistanceToAgent(int agent, float time)
  6384. {
  6385. m_AgentPool.SetTemporaryResistance(agent, time);
  6386. }
  6387. float GetTemporaryResistanceToAgent(int agent)
  6388. {
  6389. return m_AgentPool.GetTemporaryResistance(agent);
  6390. }
  6391. //Get aim (player crosshair) position
  6392. vector GetAimPosition()
  6393. {
  6394. float min_distance = 0.5; //min distance, default = 5m
  6395. vector from = GetGame().GetCurrentCameraPosition();
  6396. vector to = from + (GetGame().GetCurrentCameraDirection() * min_distance);
  6397. vector contactPos;
  6398. vector contactDir;
  6399. int contactComponent;
  6400. DayZPhysics.RaycastRV(from, to, contactPos, contactDir, contactComponent, NULL, NULL, NULL, false, true);
  6401. return contactPos;
  6402. }
  6403. bool CanEatAndDrink()
  6404. {
  6405. ItemBase mask = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
  6406. return (!mask || (mask && mask.AllowFoodConsumption()));
  6407. }
  6408. bool CanConsumeFood(ConsumeConditionData data = null)
  6409. {
  6410. return true;
  6411. }
  6412. //get modifier manager
  6413. ModifiersManager GetModifiersManager()
  6414. {
  6415. return m_ModifiersManager;
  6416. }
  6417. PlayerStat<float> GetStatWater()
  6418. {
  6419. if (!m_StatWater && GetPlayerStats())
  6420. {
  6421. m_StatWater = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.WATER));
  6422. }
  6423. return m_StatWater;
  6424. }
  6425. PlayerStat<float> GetStatToxicity()
  6426. {
  6427. if (!m_StatToxicity && GetPlayerStats())
  6428. {
  6429. m_StatToxicity = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.TOXICITY));
  6430. }
  6431. return m_StatToxicity;
  6432. }
  6433. PlayerStat<float> GetStatEnergy()
  6434. {
  6435. if (!m_StatEnergy && GetPlayerStats())
  6436. {
  6437. m_StatEnergy = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.ENERGY));
  6438. }
  6439. return m_StatEnergy;
  6440. }
  6441. PlayerStat<float> GetStatHeatComfort()
  6442. {
  6443. if (!m_StatHeatComfort && GetPlayerStats())
  6444. {
  6445. m_StatHeatComfort = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.HEATCOMFORT));
  6446. }
  6447. return m_StatHeatComfort;
  6448. }
  6449. PlayerStat<float> GetStatTremor()
  6450. {
  6451. if (!m_StatTremor && GetPlayerStats())
  6452. {
  6453. m_StatTremor = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.TREMOR));
  6454. }
  6455. return m_StatTremor;
  6456. }
  6457. PlayerStat<int> GetStatWet()
  6458. {
  6459. if (!m_StatWet && GetPlayerStats())
  6460. {
  6461. m_StatWet = PlayerStat<int>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.WET));
  6462. }
  6463. return m_StatWet;
  6464. }
  6465. PlayerStat<float> GetStatDiet()
  6466. {
  6467. if (!m_StatDiet && GetPlayerStats())
  6468. {
  6469. m_StatDiet = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.DIET));
  6470. }
  6471. return m_StatDiet;
  6472. }
  6473. PlayerStat<float> GetStatStamina()
  6474. {
  6475. if (!m_StatStamina && GetPlayerStats())
  6476. {
  6477. m_StatStamina = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.STAMINA));
  6478. }
  6479. return m_StatStamina;
  6480. }
  6481. PlayerStat<float> GetStatSpecialty()
  6482. {
  6483. if (!m_StatSpecialty && GetPlayerStats())
  6484. {
  6485. m_StatSpecialty = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.SPECIALTY));
  6486. }
  6487. return m_StatSpecialty;
  6488. }
  6489. PlayerStat<int> GetStatBloodType()
  6490. {
  6491. if (!m_StatBloodType && GetPlayerStats())
  6492. {
  6493. m_StatBloodType = PlayerStat<int>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.BLOODTYPE));
  6494. }
  6495. return m_StatBloodType;
  6496. }
  6497. PlayerStat<float> GetStatHeatBuffer()
  6498. {
  6499. if (!m_StatHeatBuffer && GetPlayerStats())
  6500. {
  6501. m_StatHeatBuffer = PlayerStat<float>.Cast(GetPlayerStats().GetStatObject(EPlayerStats_current.HEATBUFFER));
  6502. }
  6503. return m_StatHeatBuffer;
  6504. }
  6505. void SetHeatBufferDynamicMax(float value)
  6506. {
  6507. m_HeatBufferDynamicMax = value;
  6508. SetSynchDirty();
  6509. }
  6510. float GetHeatBufferDynamicMax()
  6511. {
  6512. return m_HeatBufferDynamicMax;
  6513. }
  6514. void ToggleHeatBufferVisibility(bool show)
  6515. {
  6516. m_HasHeatBuffer = show;
  6517. SetSynchDirty();
  6518. }
  6519. void ToggleHeatBufferVisibility(int heatbufferStage)
  6520. {
  6521. m_HeatBufferStage = heatbufferStage;
  6522. SetSynchDirty();
  6523. }
  6524. //! UA Last Message
  6525. string GetLastUAMessage()
  6526. {
  6527. return m_UALastMessage;
  6528. }
  6529. void SetLastUAMessage(string pMsg)
  6530. {
  6531. m_UALastMessage = pMsg;
  6532. if (m_UALastMessageTimer.IsRunning())
  6533. {
  6534. m_UALastMessageTimer.Stop();
  6535. }
  6536. m_UALastMessageTimer.Run(PlayerConstants.LAST_UA_MSG_LIFETIME, this, "ClearLastUAMessage", null);
  6537. }
  6538. protected void ClearLastUAMessage()
  6539. {
  6540. if (m_UALastMessageTimer.IsRunning())
  6541. {
  6542. m_UALastMessageTimer.Stop();
  6543. }
  6544. m_UALastMessage = "";
  6545. }
  6546. //! -------------------------------------------------------------------------
  6547. //! Injured stat
  6548. //! update injured state immediately
  6549. void ForceUpdateInjuredState()
  6550. {
  6551. m_InjuryHandler.CheckValue(true);
  6552. }
  6553. override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
  6554. {
  6555. #ifdef DIAG_DEVELOPER
  6556. if (m_Bot && action_id > EActions.PLAYER_BOT_INTERNAL_START && action_id < EActions.PLAYER_BOT_END)
  6557. {
  6558. m_Bot.StartAction(action_id);
  6559. return true;
  6560. }
  6561. #endif
  6562. return super.OnAction(action_id, player, ctx);
  6563. }
  6564. // -------------------------------------------------------------------------
  6565. override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
  6566. {
  6567. int i;
  6568. PluginTransmissionAgents pluginTransmissionAgents = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
  6569. if (pluginTransmissionAgents)
  6570. {
  6571. map<int, string> agentList = pluginTransmissionAgents.GetSimpleAgentList();
  6572. if (agentList)
  6573. {
  6574. foreach (int tid, string tname : agentList)
  6575. {
  6576. string injectName = "Inject " + tname;
  6577. string removeName = "Remove " + tname;
  6578. outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_AGENTS_RANGE_INJECT_START + tid, injectName, Colors.WHITE));
  6579. outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEBUG_AGENTS_RANGE_REMOVE_START + tid, removeName, Colors.WHITE));
  6580. }
  6581. }
  6582. }
  6583. #ifdef DIAG_DEVELOPER
  6584. if (m_Bot || GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE)
  6585. {
  6586. outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
  6587. typename e = EActions;
  6588. int cnt = e.GetVariableCount();
  6589. int val;
  6590. for (i = 0; i < cnt; i++)
  6591. {
  6592. if (!e.GetVariableValue(null, i, val))
  6593. continue;
  6594. if (val <= EActions.PLAYER_BOT_INTERNAL_START)
  6595. continue;
  6596. if (val == EActions.PLAYER_BOT_START)
  6597. {
  6598. outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
  6599. continue;
  6600. }
  6601. if (val >= EActions.PLAYER_BOT_END)
  6602. break;
  6603. string name = e.GetVariableName(i);
  6604. outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, val, name, FadeColors.LIGHT_GREY));
  6605. }
  6606. }
  6607. #endif
  6608. }
  6609. //-------------------------------------------------------------
  6610. //!
  6611. //! SyncJunctures
  6612. //!
  6613. override void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
  6614. {
  6615. super.OnSyncJuncture(pJunctureID, pCtx);
  6616. switch(pJunctureID)
  6617. {
  6618. case DayZPlayerSyncJunctures.SJ_INJURY:
  6619. eInjuryHandlerLevels level;
  6620. bool enable;
  6621. DayZPlayerSyncJunctures.ReadInjuryParams(pCtx, enable, level);
  6622. m_InjuryHandler.SetInjuryCommandParams(enable, level);
  6623. break;
  6624. case DayZPlayerSyncJunctures.SJ_PLAYER_STATES:
  6625. GetSymptomManager().SetAnimation(pCtx);
  6626. break;
  6627. case DayZPlayerSyncJunctures.SJ_QUICKBAR_SET_SHORTCUT:
  6628. OnQuickbarSetEntityRequest(pCtx);
  6629. break;
  6630. case DayZPlayerSyncJunctures.SJ_INVENTORY:
  6631. GetInventory().OnInventoryJunctureFromServer(pCtx);
  6632. break;
  6633. case DayZPlayerSyncJunctures.SJ_INVENTORY_REPAIR:
  6634. GetInventory().OnInventoryJunctureRepairFromServer(pCtx);
  6635. break;
  6636. case DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE:
  6637. GetInventory().OnInventoryJunctureFailureFromServer(pCtx);
  6638. break;
  6639. case DayZPlayerSyncJunctures.SJ_ACTION_INTERRUPT:
  6640. case DayZPlayerSyncJunctures.SJ_ACTION_ACK_ACCEPT:
  6641. case DayZPlayerSyncJunctures.SJ_ACTION_ACK_REJECT:
  6642. m_ActionManager.OnSyncJuncture(pJunctureID,pCtx);
  6643. break;
  6644. case DayZPlayerSyncJunctures.SJ_WEAPON_ACTION_ACK_ACCEPT:
  6645. case DayZPlayerSyncJunctures.SJ_WEAPON_ACTION_ACK_REJECT:
  6646. case DayZPlayerSyncJunctures.SJ_WEAPON_SET_JAMMING_CHANCE:
  6647. m_WeaponManager.OnSyncJuncture(pJunctureID,pCtx);
  6648. break;
  6649. case DayZPlayerSyncJunctures.SJ_UNCONSCIOUSNESS:
  6650. DayZPlayerSyncJunctures.ReadPlayerUnconsciousnessParams(pCtx, m_ShouldBeUnconscious);
  6651. break;
  6652. case DayZPlayerSyncJunctures.SJ_PLAYER_ADD_MODIFIER:
  6653. GetSymptomManager().SetAnimation(pCtx);
  6654. break;
  6655. case DayZPlayerSyncJunctures.SJ_KURU_REQUEST:
  6656. float amount;
  6657. if (DayZPlayerSyncJunctures.ReadKuruRequest(pCtx, amount))
  6658. {
  6659. if (GetAimingModel() && IsFireWeaponRaised())
  6660. {
  6661. GetAimingModel().RequestKuruShake(amount);
  6662. }
  6663. }
  6664. break;
  6665. case DayZPlayerSyncJunctures.SJ_GESTURE_REQUEST :
  6666. m_EmoteManager.OnSyncJuncture(pJunctureID, pCtx);
  6667. break;
  6668. case DayZPlayerSyncJunctures.SJ_WEAPON_LIFT: // Obsolete
  6669. SetLiftWeapon(pJunctureID, pCtx);
  6670. break;
  6671. case DayZPlayerSyncJunctures.SJ_ADS_RESET:
  6672. m_ResetADS = true;
  6673. break;
  6674. case DayZPlayerSyncJunctures.SJ_DELETE_ITEM:
  6675. SetToDelete(pCtx);
  6676. break;
  6677. case DayZPlayerSyncJunctures.SJ_BROKEN_LEGS:
  6678. m_BrokenLegsJunctureReceived = true;
  6679. DayZPlayerSyncJunctures.ReadBrokenLegsParamsEx(pCtx, m_BrokenLegState);
  6680. break;
  6681. case DayZPlayerSyncJunctures.SJ_SHOCK :
  6682. DayZPlayerSyncJunctures.ReadShockParams(pCtx, m_CurrentShock);
  6683. break;
  6684. case DayZPlayerSyncJunctures.SJ_STAMINA:
  6685. m_StaminaHandler.OnSyncJuncture(pJunctureID, pCtx);
  6686. break;
  6687. case DayZPlayerSyncJunctures.SJ_STAMINA_MISC:
  6688. m_StaminaHandler.OnSyncJuncture(pJunctureID, pCtx);
  6689. break;
  6690. #ifdef DEVELOPER
  6691. case DayZPlayerSyncJunctures.SJ_DEBUG_GET_IN_VEHICLE:
  6692. EntityAI vehicle;
  6693. DayZPlayerSyncJunctures.ReadGetInVehicleParams(pCtx, vehicle);
  6694. SetGetInVehicleDebug(vehicle);
  6695. break;
  6696. #endif
  6697. }
  6698. }
  6699. bool IsItemsToDelete()
  6700. {
  6701. return m_ItemsToDelete.Count() > 0;
  6702. }
  6703. void SetToDelete(ParamsReadContext pCtx)
  6704. {
  6705. EntityAI item;
  6706. pCtx.Read(item);
  6707. AddItemToDelete(item);
  6708. }
  6709. override void AddItemToDelete(EntityAI item)
  6710. {
  6711. if (item)
  6712. {
  6713. item.SetPrepareToDelete();
  6714. m_ItemsToDelete.Insert(item);
  6715. }
  6716. }
  6717. bool CanDeleteItems()
  6718. {
  6719. return !(GetThrowing().IsThrowingAnimationPlaying() || GetDayZPlayerInventory().IsProcessing() || (GetActionManager() && GetActionManager().GetRunningAction()));
  6720. }
  6721. override void JunctureDeleteItem(EntityAI item)
  6722. {
  6723. DayZPlayerSyncJunctures.SendDeleteItem(this, item);
  6724. }
  6725. void UpdateDelete()
  6726. {
  6727. int count = m_ItemsToDelete.Count();
  6728. if (count > 0)
  6729. {
  6730. if (CanDeleteItems())
  6731. {
  6732. EntityAI itemToDelete;
  6733. if (GetGame().IsClient() && GetGame().IsMultiplayer())
  6734. {
  6735. InventoryLocation il = new InventoryLocation();
  6736. for (int i = count - 1; i >= 0 ; i--)
  6737. {
  6738. itemToDelete = m_ItemsToDelete.Get(i);
  6739. if (itemToDelete != null)
  6740. {
  6741. itemToDelete.GetInventory().GetCurrentInventoryLocation(il);
  6742. }
  6743. if (itemToDelete == null || (GetItemInHands() == null && il.GetType() == InventoryLocationType.UNKNOWN))
  6744. {
  6745. m_ItemsToDelete.Remove(i);
  6746. }
  6747. }
  6748. }
  6749. else
  6750. {
  6751. for (int j = count - 1; j >= 0 ; j--)
  6752. {
  6753. itemToDelete = m_ItemsToDelete.Get(j);
  6754. if (itemToDelete == null)
  6755. {
  6756. m_ItemsToDelete.Remove(j);
  6757. }
  6758. else
  6759. {
  6760. itemToDelete.Delete();
  6761. m_ItemsToDelete.Remove(j);
  6762. }
  6763. }
  6764. }
  6765. }
  6766. }
  6767. }
  6768. override bool HeadingModel(float pDt, SDayZPlayerHeadingModel pModel)
  6769. {
  6770. if (GetActionManager()) // disable character turning while performing actions
  6771. {
  6772. ActionContinuousBase action = ActionContinuousBase.Cast(GetActionManager().GetRunningAction());
  6773. if (action && action.IsFullBody(this) && action.IsCameraLockOnPerform())
  6774. {
  6775. if (!m_IsHeadingRestricted)
  6776. {
  6777. m_IsHeadingRestricted = true;
  6778. m_HeadingRestrictData.InitData(pModel.m_fHeadingAngle, action.GetCameraLRAngle());
  6779. }
  6780. return DayZPlayerImplementHeading.RestrictHeading(pDt, pModel, m_fLastHeadingDiff, m_HeadingRestrictData);
  6781. }
  6782. else
  6783. m_IsHeadingRestricted = false;
  6784. }
  6785. //! during fullbody gestures - disables character turning
  6786. if (GetEmoteManager().IsControllsLocked())
  6787. {
  6788. HumanItemAccessor hia = GetItemAccessor();
  6789. HumanItemBehaviorCfg hibcfg = hia.GetItemInHandsBehaviourCfg();
  6790. if (hibcfg && hibcfg.m_StanceRotation[m_MovementState.m_iStanceIdx] == DayZPlayerConstants.ROTATION_DISABLE)
  6791. {
  6792. return DayZPlayerImplementHeading.NoHeading(pDt, pModel, m_fLastHeadingDiff);
  6793. }
  6794. else
  6795. {
  6796. m_fLastHeadingDiff = 0;
  6797. return DayZPlayerImplementHeading.ClampHeading(pDt, pModel, m_fLastHeadingDiff);
  6798. }
  6799. }
  6800. return super.HeadingModel(pDt, pModel);
  6801. }
  6802. override bool IsInventorySoftLocked()
  6803. {
  6804. return m_InventorySoftLockCount > 0;
  6805. }
  6806. //! 'soft lock' meaning inventory screen cannot be displayed, but mechanically, inventory operations are still possible
  6807. override void SetInventorySoftLock(bool status)
  6808. {
  6809. if (status)
  6810. m_InventorySoftLockCount++;
  6811. else
  6812. m_InventorySoftLockCount--;
  6813. if (m_InventorySoftLockCount < 0)
  6814. m_InventorySoftLockCount = 0;
  6815. m_InventorySoftLocked = IsInventorySoftLocked();
  6816. }
  6817. void SetLoadedQuickBarItemBind(EntityAI entity, int index)
  6818. {
  6819. if (m_aQuickBarLoad)
  6820. m_aQuickBarLoad.Insert(new Param2<EntityAI, int>(entity,index));
  6821. }
  6822. override bool IsLiftWeapon()
  6823. {
  6824. return m_LiftWeapon_player;
  6825. }
  6826. //Server
  6827. bool ReadLiftWeaponRequest(int userDataType, ParamsReadContext ctx)
  6828. {
  6829. bool state;
  6830. ctx.Read(state);
  6831. SetLiftWeapon(state);
  6832. return true;
  6833. }
  6834. void SetLiftWeapon(int pJunctureID, ParamsReadContext ctx) // Obsolete
  6835. {
  6836. bool state;
  6837. ctx.Read(state);
  6838. SetLiftWeapon(state);
  6839. //Print("SetLiftWeapon | STS: " + GetSimulationTimeStamp());
  6840. }
  6841. void SetLiftWeapon(bool state)
  6842. {
  6843. m_ProcessLiftWeaponState = state;
  6844. m_ProcessLiftWeapon = true;
  6845. }
  6846. //! Client-side only
  6847. void SendLiftWeaponSync(bool state)
  6848. {
  6849. HumanCommandWeapons hcw;
  6850. // Apply state immediately
  6851. m_LiftWeapon_player = state;
  6852. hcw = GetCommandModifier_Weapons();
  6853. if (hcw)
  6854. hcw.LiftWeapon(state);
  6855. GetWeaponManager().OnLiftWeapon();
  6856. // Notify server to apply same state
  6857. if (GetGame().IsMultiplayer() && GetGame().IsClient())
  6858. {
  6859. ScriptInputUserData ctx = new ScriptInputUserData;
  6860. if (!ctx.CanStoreInputUserData())
  6861. {
  6862. // ctx not available??
  6863. return;
  6864. }
  6865. ctx.Write(INPUT_UDT_WEAPON_LIFT_EVENT);
  6866. ctx.Write(state);
  6867. ctx.Send();
  6868. }
  6869. }
  6870. override void CheckLiftWeapon()
  6871. {
  6872. // lift weapon check
  6873. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  6874. {
  6875. Weapon_Base weap;
  6876. if (Weapon_Base.CastTo(weap, GetItemInHands()))
  6877. {
  6878. bool limited = weap.LiftWeaponCheck(this);
  6879. if (limited && !m_LiftWeapon_player)
  6880. SendLiftWeaponSync(true);
  6881. else if (!limited && m_LiftWeapon_player)
  6882. SendLiftWeaponSync(false);
  6883. }
  6884. else if (m_LiftWeapon_player)
  6885. {
  6886. SendLiftWeaponSync(false);
  6887. }
  6888. }
  6889. }
  6890. override void ProcessLiftWeapon()
  6891. {
  6892. if (m_ProcessLiftWeapon)
  6893. {
  6894. HumanCommandWeapons hcw = GetCommandModifier_Weapons();
  6895. if (hcw)
  6896. hcw.LiftWeapon(m_ProcessLiftWeaponState);
  6897. GetWeaponManager().OnLiftWeapon();
  6898. m_LiftWeapon_player = m_ProcessLiftWeaponState;
  6899. m_ProcessLiftWeapon = false;
  6900. //Debug.Log("SimulationStamp_server: " + this.GetSimulationTimeStamp());
  6901. }
  6902. }
  6903. //! state 'true' == hide
  6904. override void HideClothing(ItemOptics optic, bool state)
  6905. {
  6906. super.HideClothing(optic, state);
  6907. array<int> clothingArray = new array<int>;
  6908. Clothing clothes;
  6909. if (state && DayZPlayerCameraOptics.Cast(m_CurrentCamera))
  6910. {
  6911. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  6912. {
  6913. clothingArray.Insert(InventorySlots.BACK);
  6914. clothingArray.Insert(InventorySlots.SHOULDER);
  6915. clothingArray.Insert(InventorySlots.MELEE);
  6916. if (optic && optic.GetCurrentStepFOV() < GameConstants.DZPLAYER_CAMERA_FOV_IRONSIGHTS)
  6917. {
  6918. clothingArray.Insert(InventorySlots.BODY);
  6919. clothingArray.Insert(InventorySlots.VEST);
  6920. }
  6921. SetInvisibleRecursive(true,this,clothingArray);
  6922. }
  6923. }
  6924. //showing should be instant (called directly, not via CallLater)
  6925. else
  6926. {
  6927. if (GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  6928. {
  6929. clothingArray = {InventorySlots.BACK,InventorySlots.BODY,InventorySlots.VEST,InventorySlots.SHOULDER,InventorySlots.MELEE};
  6930. SetInvisibleRecursive(false,this,clothingArray);
  6931. }
  6932. }
  6933. }
  6934. void RequestUnconsciousness(bool enable)
  6935. {
  6936. DayZPlayerSyncJunctures.SendPlayerUnconsciousness(this, enable);
  6937. }
  6938. override void SetDeathDarknessLevel(float duration, float tick_time)
  6939. {
  6940. super.SetDeathDarknessLevel(duration, tick_time);
  6941. if (IsControlledPlayer())
  6942. {
  6943. float actual_tick = tick_time;
  6944. if (GetDamageDealtEffect())
  6945. m_DamageDealtEffect = null;
  6946. if (GetFlashbangEffect())
  6947. m_FlashbangEffect = null;
  6948. float progress;
  6949. if (duration > 0)
  6950. progress = 1 - ((duration - m_DeathDarkeningCurrentTime) / duration);
  6951. m_DeathDarkeningCurrentTime += actual_tick;
  6952. if (!IsAlive() && IsPlayerSelected())
  6953. {
  6954. m_DeathDarkeningParam.param1 = progress;
  6955. PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Start(m_DeathDarkeningParam);
  6956. }
  6957. if (m_DeathDarkeningCurrentTime >= duration)
  6958. {
  6959. StopDeathDarkeningEffect();
  6960. }
  6961. }
  6962. else
  6963. {
  6964. StopDeathDarkeningEffect();
  6965. }
  6966. }
  6967. override bool IsInFBEmoteState()
  6968. {
  6969. if (!IsEmotePlaying())
  6970. return false;
  6971. if ((m_EmoteManager.m_Callback && m_EmoteManager.m_Callback.m_IsFullbody) || m_EmoteManager.m_IsSurrendered)
  6972. {
  6973. return true;
  6974. }
  6975. return false;
  6976. }
  6977. //! ends surrender, originally intended for surrender->restrained transitioning
  6978. void EndSurrenderRequest(SurrenderData data = null)
  6979. {
  6980. if (m_EmoteManager)
  6981. m_EmoteManager.EndSurrenderRequest(data);
  6982. }
  6983. bool IsSurrendered()
  6984. {
  6985. if (m_EmoteManager)
  6986. return m_EmoteManager.m_IsSurrendered;
  6987. return false;
  6988. }
  6989. bool IsPlayerLoaded()
  6990. {
  6991. return m_PlayerLoaded;
  6992. }
  6993. //disconnected, caused problems. Awaiting refactor
  6994. override void CheckAnimationOverrides()
  6995. {
  6996. //FB gesture slideposeangle override
  6997. if (IsInFBEmoteState() && IsControlledPlayer() && IsPlayerSelected())
  6998. {
  6999. OverrideSlidePoseAngle(Math.PI2);
  7000. }
  7001. else if (!IsInFBEmoteState() && IsControlledPlayer() && IsPlayerSelected())
  7002. {
  7003. OverrideSlidePoseAngle(m_OriginalSlidePoseAngle);
  7004. }
  7005. //+add more, if needed
  7006. }
  7007. /*void OnSurrenderEnd()
  7008. {
  7009. }*/
  7010. bool CanRedirectToWeaponManager (notnull EntityAI item, out bool isActionPossible)
  7011. {
  7012. isActionPossible = false;
  7013. Magazine mag = Magazine.Cast(item);
  7014. Weapon_Base wpn = Weapon_Base.Cast(item.GetHierarchyParent());
  7015. if (mag && wpn)
  7016. {
  7017. if (GetWeaponManager().CanDetachMagazine(wpn, mag))
  7018. {
  7019. //Print("[inv] PlayerBase.CanRedirectToWeaponManager OK, can detach mag=" + mag + " from wpn=" + wpn);
  7020. isActionPossible = true;
  7021. }
  7022. else
  7023. {
  7024. //Print("[inv] PlayerBase.CanRedirectToWeaponManager cannot detach mag=" + mag + " from wpn=" + wpn);
  7025. }
  7026. return true;
  7027. }
  7028. return false;
  7029. }
  7030. // Inventory actions with redirection to weapon manager
  7031. override bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
  7032. {
  7033. bool can_detach;
  7034. if (CanRedirectToWeaponManager(item,can_detach))
  7035. {
  7036. InventoryLocation il = new InventoryLocation();
  7037. if (can_detach && target.GetInventory().FindFreeLocationFor(item, flags, il))
  7038. {
  7039. return GetWeaponManager().DetachMagazine(il);
  7040. }
  7041. return false;
  7042. }
  7043. return super.PredictiveTakeEntityToTargetInventory(target, flags, item);
  7044. }
  7045. override bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
  7046. {
  7047. bool can_detach;
  7048. if (CanRedirectToWeaponManager(item,can_detach))
  7049. {
  7050. InventoryLocation il = new InventoryLocation();
  7051. if (can_detach && GetInventory().FindFreeLocationFor(item, flags, il))
  7052. {
  7053. return GetWeaponManager().DetachMagazine(il);
  7054. }
  7055. return false;
  7056. }
  7057. return super.PredictiveTakeEntityToInventory(flags, item);
  7058. }
  7059. override bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
  7060. {
  7061. Weapon_Base parentWpn = Weapon_Base.Cast(target);
  7062. Magazine mag = Magazine.Cast(item);
  7063. if (parentWpn && mag)
  7064. {
  7065. if (GetWeaponManager().CanAttachMagazine(parentWpn, mag))
  7066. return GetWeaponManager().AttachMagazine(mag);
  7067. return false;
  7068. }
  7069. return super.PredictiveTakeEntityToTargetAttachment(target, item);
  7070. }
  7071. override bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
  7072. {
  7073. Weapon_Base parentWpn = Weapon_Base.Cast(target);
  7074. Magazine mag = Magazine.Cast(item);
  7075. if (parentWpn && mag)
  7076. {
  7077. if (target.CanReceiveAttachment(item,slot) && GetWeaponManager().CanAttachMagazine(parentWpn, mag))
  7078. return GetWeaponManager().AttachMagazine(mag);
  7079. return false;
  7080. }
  7081. return super.PredictiveTakeEntityToTargetAttachmentEx(target, item,slot);
  7082. }
  7083. override bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
  7084. {
  7085. bool can_detach;
  7086. if (CanRedirectToWeaponManager(item,can_detach))
  7087. {
  7088. InventoryLocation il = new InventoryLocation();
  7089. if (can_detach && target.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, il))
  7090. {
  7091. return GetWeaponManager().DetachMagazine(il);
  7092. }
  7093. return false;
  7094. }
  7095. return super.PredictiveTakeEntityToTargetCargo(target,item);
  7096. }
  7097. override bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
  7098. {
  7099. bool can_detach;
  7100. if (CanRedirectToWeaponManager(item, can_detach))
  7101. {
  7102. if (can_detach)
  7103. {
  7104. InventoryLocation dst = new InventoryLocation;
  7105. dst.SetCargoAuto(cargo, item, row, col, item.GetInventory().GetFlipCargo());
  7106. return GetWeaponManager().DetachMagazine(dst);
  7107. }
  7108. return false;
  7109. }
  7110. return super.PredictiveTakeEntityToTargetCargoEx (cargo, item, row, col);
  7111. }
  7112. override bool PredictiveDropEntity (notnull EntityAI item)
  7113. {
  7114. bool can_detach;
  7115. if (CanRedirectToWeaponManager(item,can_detach))
  7116. {
  7117. if (can_detach)
  7118. {
  7119. vector m4[4];
  7120. Math3D.MatrixIdentity4(m4);
  7121. //! 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
  7122. GameInventory.PrepareDropEntityPos(this, item, m4, false, GameConstants.INVENTORY_ENTITY_DROP_OVERLAP_DEPTH);
  7123. InventoryLocation il = new InventoryLocation;
  7124. il.SetGround(item, m4);
  7125. return GetWeaponManager().DetachMagazine(il);
  7126. }
  7127. return false;
  7128. }
  7129. return super.PredictiveDropEntity(item);
  7130. }
  7131. override bool PredictiveSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
  7132. {
  7133. //Print("PlayerBase | PredictiveSwapEntities");
  7134. Magazine swapmag1 = Magazine.Cast(item1);
  7135. Magazine swapmag2 = Magazine.Cast(item2);
  7136. if (swapmag1 && swapmag2)
  7137. {
  7138. Weapon_Base parentWpn;
  7139. if (Class.CastTo(parentWpn, swapmag1.GetHierarchyParent()))
  7140. {
  7141. if (GetWeaponManager().CanSwapMagazine(parentWpn, swapmag2))
  7142. {
  7143. Print("[inv] PlayerBase.PredictiveSwapEntities: swapping mag1=" + swapmag1 + " to parent wpn=" + parentWpn + " of mag1=" + swapmag1);
  7144. return GetWeaponManager().SwapMagazine(swapmag2);
  7145. }
  7146. else
  7147. {
  7148. Print("[inv] PlayerBase.PredictiveSwapEntities: can not swap magazines");
  7149. return false;
  7150. }
  7151. }
  7152. if (Class.CastTo(parentWpn, swapmag2.GetHierarchyParent()))
  7153. {
  7154. if (GetWeaponManager().CanSwapMagazine(parentWpn, swapmag1))
  7155. {
  7156. Print("[inv] PlayerBase.PredictiveSwapEntities: swapping mag1=" + swapmag1 + " to parent wpn=" + parentWpn + " of mag2=" + swapmag2);
  7157. return GetWeaponManager().SwapMagazine(swapmag1);
  7158. }
  7159. else
  7160. {
  7161. Print("[inv] PlayerBase.PredictiveSwapEntities: can not swap magazines");
  7162. return false;
  7163. }
  7164. }
  7165. }
  7166. EntityAI item_hands;
  7167. EntityAI item_ground;
  7168. if (IsSwapBetweenHandsAndGroundLargeItem(item1,item2,item_hands,item_ground) && !m_ActionManager.GetRunningAction())
  7169. {
  7170. ActionManagerClient mngr_client;
  7171. CastTo(mngr_client,m_ActionManager);
  7172. ActionTarget atrg = new ActionTarget(item_ground,null,-1,vector.Zero,-1.0);
  7173. if (mngr_client.GetAction(ActionSwapItemToHands).Can(this,atrg,ItemBase.Cast(item_hands)))
  7174. {
  7175. mngr_client.PerformActionStart(mngr_client.GetAction(ActionSwapItemToHands),atrg,ItemBase.Cast(item_hands));
  7176. return true;
  7177. }
  7178. return super.PredictiveSwapEntities(item1, item2);
  7179. }
  7180. else
  7181. return super.PredictiveSwapEntities(item1, item2);
  7182. }
  7183. override bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
  7184. {
  7185. InventoryLocation il = new InventoryLocation;
  7186. if (item1.IsHeavyBehaviour() && item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND && !m_ActionManager.GetRunningAction())
  7187. {
  7188. //Print("override bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)");
  7189. ActionManagerClient mngr_client;
  7190. CastTo(mngr_client,m_ActionManager);
  7191. ActionTarget atrg = new ActionTarget(item1,null,-1,vector.Zero,-1.0);
  7192. if (mngr_client.GetAction(ActionSwapItemToHands).Can(this,atrg,ItemBase.Cast(item2)))
  7193. {
  7194. mngr_client.PerformActionStart(mngr_client.GetAction(ActionSwapItemToHands),atrg,ItemBase.Cast(item2));
  7195. }
  7196. return true;
  7197. }
  7198. else
  7199. return super.PredictiveForceSwapEntities(item1, item2, item2_dst);
  7200. }
  7201. override void PredictiveTakeEntityToHands(EntityAI item)
  7202. {
  7203. if (item.IsHeavyBehaviour() && !m_ActionManager.GetRunningAction() && !item.GetHierarchyParent())
  7204. {
  7205. ActionManagerClient mngr_client;
  7206. if (CastTo(mngr_client,m_ActionManager))
  7207. {
  7208. ActionTarget atrg = new ActionTarget(item,null,-1,vector.Zero,-1.0);
  7209. if (mngr_client.GetAction(ActionTakeItemToHands).Can(this,atrg,null))
  7210. {
  7211. mngr_client.PerformActionStart(mngr_client.GetAction(ActionTakeItemToHands),atrg,null);
  7212. }
  7213. /*).Can(this,
  7214. mngr_client.ActionStart(mngr_client.GetAction(ActionTakeItemToHands),mngr_client.FindActionTarget(),null);
  7215. return;*/
  7216. }
  7217. }
  7218. else
  7219. super.PredictiveTakeEntityToHands(item);
  7220. }
  7221. override bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
  7222. {
  7223. EntityAI item = src.GetItem();
  7224. if (item)
  7225. {
  7226. bool can_detach;
  7227. if (CanRedirectToWeaponManager(item,can_detach))
  7228. {
  7229. if (can_detach)
  7230. {
  7231. return GetWeaponManager().DetachMagazine(dst);
  7232. }
  7233. return false;
  7234. }
  7235. return super.PredictiveTakeToDst(src,dst);
  7236. }
  7237. return false;
  7238. }
  7239. bool IsSwapBetweenHandsAndGroundLargeItem(notnull EntityAI item1, notnull EntityAI item2, out EntityAI item_hands, out EntityAI item_ground)
  7240. {
  7241. InventoryLocation il = new InventoryLocation;
  7242. if (item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.HANDS)
  7243. item_hands = item1;
  7244. if (item2.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.HANDS)
  7245. item_hands = item2;
  7246. if (item1.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND)
  7247. item_ground = item1;
  7248. if (item2.GetInventory().GetCurrentInventoryLocation(il) && il.GetType() == InventoryLocationType.GROUND)
  7249. item_ground = item2;
  7250. return item_hands && item_ground && item_ground.IsHeavyBehaviour();
  7251. }
  7252. //! Dynamic hair hiding
  7253. void SetHairLevelToHide(int level, bool state, bool was_debug = false)
  7254. {
  7255. if (was_debug && GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
  7256. return;
  7257. if (!m_CharactersHead)
  7258. {
  7259. ErrorEx("No valid head detected on character!");
  7260. return;
  7261. }
  7262. if (level == -1) //hide/show ALL
  7263. {
  7264. m_HideHairAnimated = !m_HideHairAnimated;
  7265. for (int i = 0; i < m_CharactersHead.m_HeadHairSelectionArray.Count(); ++i)
  7266. {
  7267. //m_CharactersHead.SetSimpleHiddenSelectionState(i,m_HideHairAnimated);
  7268. SelectionTranslation stt = SelectionTranslation.Cast(m_CharactersHead.m_HeadHairHidingStateMap.Get(i));
  7269. stt.SetSelectionState(m_HideHairAnimated);
  7270. m_CharactersHead.m_HeadHairHidingStateMap.Set(i, stt);
  7271. #ifdef DIAG_DEVELOPER
  7272. #ifndef SERVER
  7273. PluginDiagMenuClient diagmenu = PluginDiagMenuClient.Cast(GetPlugin(PluginDiagMenuClient));
  7274. diagmenu.m_HairHidingStateMap.Set(i, m_HideHairAnimated);
  7275. #endif
  7276. #endif
  7277. }
  7278. }
  7279. else //hide/show selected level only
  7280. {
  7281. bool switchState;
  7282. if (was_debug)
  7283. {
  7284. #ifdef DIAG_DEVELOPER
  7285. #ifndef SERVER
  7286. PluginDiagMenuClient diagmenuu = PluginDiagMenuClient.Cast(GetPlugin(PluginDiagMenuClient));
  7287. switchState = !diagmenuu.m_HairHidingStateMap.Get(level);
  7288. diagmenuu.m_HairHidingStateMap.Set(level, switchState);
  7289. #endif
  7290. #endif
  7291. }
  7292. else
  7293. {
  7294. switchState = !state;
  7295. }
  7296. //m_CharactersHead.SetSimpleHiddenSelectionState(level,switchState);
  7297. stt = SelectionTranslation.Cast(m_CharactersHead.m_HeadHairHidingStateMap.Get(level));
  7298. stt.SetSelectionState(switchState);
  7299. m_CharactersHead.m_HeadHairHidingStateMap.Set(level, stt); //nescessary?
  7300. }
  7301. }
  7302. void HideHairSelections(ItemBase item, bool state)
  7303. {
  7304. if (!item || !item.GetHeadHidingSelection() || !m_CharactersHead)
  7305. return;
  7306. int slot_id; //item currently attached (or detaching from) here
  7307. string slot_name; //item currently attached (or detaching from) here
  7308. string str
  7309. int idx = 0;
  7310. int i;
  7311. int count;
  7312. item.GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
  7313. if (item.HidesSelectionBySlot())
  7314. {
  7315. count = item.GetInventory().GetSlotIdCount();
  7316. for (i = 0; i < count; i++)
  7317. {
  7318. if (item.GetInventory().GetSlotId(i) == slot_id)
  7319. {
  7320. str = item.GetHeadHidingSelection().Get(i);
  7321. idx = m_CharactersHead.m_HeadHairSelectionArray.Find(str);
  7322. if (idx != -1)
  7323. SetHairLevelToHide(idx,state);
  7324. #ifdef DEVELOPER
  7325. else
  7326. Debug.Log("No valid selection '" + str + "' found on head of " + GetType() + ". Verify the p3d, model config, and the 'HAIR_HIDING_SELECTIONS' macro in basicDefines.");
  7327. #endif
  7328. }
  7329. }
  7330. }
  7331. else
  7332. {
  7333. count = item.GetHeadHidingSelection().Count();
  7334. for (i = 0; i < count; i++)
  7335. {
  7336. str = item.GetHeadHidingSelection().Get(i);
  7337. idx = m_CharactersHead.m_HeadHairSelectionArray.Find(str);
  7338. if (idx != -1)
  7339. SetHairLevelToHide(idx,state);
  7340. #ifdef DEVELOPER
  7341. else
  7342. Debug.Log("No valid selection '" + str + "' found on head of " + GetType() + ". Verify the p3d, model config, and the 'HAIR_HIDING_SELECTIONS' macro in basicDefines.");
  7343. #endif
  7344. }
  7345. }
  7346. UpdateHairSelectionVisibility();
  7347. }
  7348. void UpdateHairSelectionVisibility(bool was_debug = false)
  7349. {
  7350. if (!m_CharactersHead)
  7351. return;
  7352. bool shown;
  7353. bool exception_hidden = false;
  7354. int i;
  7355. int count = m_CharactersHead.m_HeadHairHidingStateMap.Count();
  7356. SelectionTranslation stt;
  7357. //hide/show beard
  7358. if (IsMale() && m_CharactersHead.GetBeardIndex() > -1 && !was_debug)
  7359. {
  7360. SetHairLevelToHide(m_CharactersHead.GetBeardIndex(),GetLifeSpanState() != LifeSpanState.BEARD_EXTRA);
  7361. }
  7362. //show all first
  7363. for (i = 0; i < count; i++)
  7364. {
  7365. m_CharactersHead.SetSimpleHiddenSelectionState(i,true);
  7366. }
  7367. //then carve it up
  7368. for (i = 0; i < count; i++)
  7369. {
  7370. stt = m_CharactersHead.m_HeadHairHidingStateMap.Get(i);
  7371. shown = stt.GetSelectionState();
  7372. if (!shown)
  7373. {
  7374. if (/*IsMale() && */!m_CharactersHead.IsHandlingException())
  7375. {
  7376. m_CharactersHead.SetSimpleHiddenSelectionState(i,shown);
  7377. UpdateTranslatedSelections(stt);
  7378. //Print("hidden idx: " + i);
  7379. }
  7380. else
  7381. {
  7382. exception_hidden = true;
  7383. }
  7384. }
  7385. }
  7386. //exceptions handled differently; hides hair
  7387. if (exception_hidden)
  7388. {
  7389. m_CharactersHead.SetSimpleHiddenSelectionState(m_CharactersHead.GetHairIndex(),false);
  7390. if (IsMale())
  7391. m_CharactersHead.SetSimpleHiddenSelectionState(m_CharactersHead.GetBeardIndex(),false);
  7392. }
  7393. }
  7394. void UpdateTranslatedSelections(SelectionTranslation stt)
  7395. {
  7396. int index;
  7397. array<int> translatedSelectinosArray = stt.GetTranslatedSelections();
  7398. for (int i = 0; i < translatedSelectinosArray.Count(); i++)
  7399. {
  7400. index = translatedSelectinosArray.Get(i);
  7401. //if (index > -1)
  7402. m_CharactersHead.SetSimpleHiddenSelectionState(index,false); //safe this way, only hiding/carving from shown parts
  7403. }
  7404. }
  7405. //! helper method for re-checking hairhiding on character load
  7406. void CheckHairClippingOnCharacterLoad()
  7407. {
  7408. ItemBase headgear = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.HEADGEAR));
  7409. ItemBase mask = ItemBase.Cast(GetInventory().FindAttachment(InventorySlots.MASK));
  7410. HideHairSelections(headgear,true);
  7411. HideHairSelections(mask,true);
  7412. }
  7413. bool IsNVGWorking()
  7414. {
  7415. return m_ActiveNVTypes && m_ActiveNVTypes.Count() > 0;
  7416. }
  7417. bool IsNVGLowered()
  7418. {
  7419. return m_LoweredNVGHeadset;
  7420. }
  7421. int GetNVType()
  7422. {
  7423. if (!m_ActiveNVTypes || m_ActiveNVTypes.Count() == 0)
  7424. {
  7425. return NVTypes.NONE;
  7426. }
  7427. else
  7428. {
  7429. return m_ActiveNVTypes[m_ActiveNVTypes.Count() - 1];
  7430. }
  7431. }
  7432. array<int> GetNVTypesArray()
  7433. {
  7434. return m_ActiveNVTypes;
  7435. }
  7436. //!Deprecated
  7437. void SetNVGWorking(bool state)
  7438. {
  7439. //Deprecated, below is for legacy's sake
  7440. AddActiveNV(NVTypes.NV_GOGGLES);
  7441. }
  7442. void SetNVGLowered(bool state)
  7443. {
  7444. m_LoweredNVGHeadset = state;
  7445. }
  7446. void AddActiveNV(int type)
  7447. {
  7448. if (!m_ActiveNVTypes || (GetGame().IsMultiplayer() && GetGame().IsServer()))
  7449. {
  7450. #ifdef DEVELOPER
  7451. Error("AddActiveNV | illegal server-side call!");
  7452. #endif
  7453. return;
  7454. }
  7455. if (m_ActiveNVTypes.Find(type) == -1)
  7456. m_ActiveNVTypes.Insert(type);
  7457. }
  7458. void RemoveActiveNV(int type)
  7459. {
  7460. if (!m_ActiveNVTypes || (GetGame().IsMultiplayer() && GetGame().IsServer()))
  7461. {
  7462. #ifdef DEVELOPER
  7463. Error("RemoveActiveNV | illegal server-side call!");
  7464. #endif
  7465. return;
  7466. }
  7467. if (m_ActiveNVTypes.Find(type) != -1)
  7468. m_ActiveNVTypes.RemoveItem(type);
  7469. }
  7470. void ResetActiveNV()
  7471. {
  7472. m_ActiveNVTypes.Clear();
  7473. }
  7474. #ifdef DEVELOPER
  7475. override string GetDebugText()
  7476. {
  7477. string text = super.GetDebugText();
  7478. /*
  7479. text += "GetMovementTimeToStrafeJog:" + CfgGameplayHandler.GetMovementTimeToStrafeJog() + "\n";
  7480. text += "GetMovementTimeToStrafeSprint:" + CfgGameplayHandler.GetMovementTimeToStrafeSprint()+ "\n";
  7481. SHumanCommandMoveSettings moveSettings = GetDayZPlayerType().CommandMoveSettingsW();
  7482. if (moveSettings)
  7483. {
  7484. text += "hmcs.m_fDirFilterTimeout:" + moveSettings.m_fDirFilterTimeout + "\n";
  7485. text += "hmcs.m_fDirFilterSprintTimeout:" + moveSettings.m_fDirFilterSprintTimeout+ "\n";
  7486. }*/
  7487. return text;
  7488. }
  7489. void DEBUGRotateNVG()
  7490. {
  7491. NVGoggles nvg;
  7492. if (FindAttachmentBySlotName("Eyewear"))
  7493. {
  7494. nvg = NVGoggles.Cast(FindAttachmentBySlotName("Eyewear").FindAttachmentBySlotName("NVG"));
  7495. }
  7496. else if (FindAttachmentBySlotName("Headgear"))
  7497. {
  7498. nvg = NVGoggles.Cast(FindAttachmentBySlotName("Headgear").FindAttachmentBySlotName("NVG"));
  7499. }
  7500. if (nvg)
  7501. {
  7502. nvg.RotateGoggles(nvg.m_IsLowered);
  7503. }
  7504. }
  7505. #endif
  7506. void AdjustBandana(EntityAI item, string slot_name)
  7507. {
  7508. if (Bandana_ColorBase.Cast(item))
  7509. {
  7510. if (slot_name == "Headgear")
  7511. {
  7512. item.SetSimpleHiddenSelectionState(0,1);
  7513. item.SetSimpleHiddenSelectionState(1,0);
  7514. }
  7515. else if (slot_name == "Mask")
  7516. {
  7517. item.SetSimpleHiddenSelectionState(0,0);
  7518. item.SetSimpleHiddenSelectionState(1,1);
  7519. }
  7520. }
  7521. }
  7522. void AdjustShemag(EntityAI item, string slot_name)
  7523. {
  7524. if (Shemag_ColorBase.Cast(item))
  7525. {
  7526. if (slot_name == "Headgear")
  7527. {
  7528. item.SetSimpleHiddenSelectionState(0,1);
  7529. item.SetSimpleHiddenSelectionState(1,0);
  7530. }
  7531. else if (slot_name == "Mask")
  7532. {
  7533. item.SetSimpleHiddenSelectionState(0,0);
  7534. item.SetSimpleHiddenSelectionState(1,1);
  7535. }
  7536. }
  7537. }
  7538. //client-side
  7539. void UpdateCorpseStateVisual()
  7540. {
  7541. //Print("---Prettying up corpses... | " + GetGame().GetTime() + " | " + this + " | " + GetType() + "---");
  7542. //Print("m_DecayedTexture = " + m_DecayedTexture);
  7543. 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
  7544. if (state == PlayerConstants.CORPSE_STATE_DECAYED)
  7545. {
  7546. EntityAI bodypart;
  7547. ItemBase item;
  7548. string path;
  7549. int idx;
  7550. int slot_id;
  7551. array<string> bodyparts = {"Gloves","Body","Legs","Feet"};
  7552. for (int i = 0; i < bodyparts.Count(); i++)
  7553. {
  7554. slot_id = InventorySlots.GetSlotIdFromString(bodyparts.Get(i));
  7555. bodypart = GetInventory().FindPlaceholderForSlot(slot_id);
  7556. item = ItemBase.Cast(GetInventory().FindAttachment(slot_id));
  7557. if (bodypart)
  7558. {
  7559. path = "cfgVehicles " + bodypart.GetType();
  7560. idx = bodypart.GetHiddenSelectionIndex("personality");
  7561. if (idx > -1)
  7562. {
  7563. bodypart.SetObjectTexture(idx,m_DecayedTexture);
  7564. }
  7565. }
  7566. if (item)
  7567. {
  7568. path = "cfgVehicles " + item.GetType();
  7569. idx = item.GetHiddenSelectionIndex("personality");
  7570. if (idx > -1)
  7571. {
  7572. item.SetObjectTexture(idx,m_DecayedTexture);
  7573. }
  7574. }
  7575. }
  7576. SetFaceTexture(m_DecayedTexture);
  7577. }
  7578. }
  7579. void SetDecayEffects(int effect = -1)
  7580. {
  7581. int boneIdx = GetBoneIndexByName("Spine2");
  7582. Particle p;
  7583. switch (effect)
  7584. {
  7585. case PlayerConstants.CORPSE_STATE_MEDIUM :
  7586. //play medium sound/flies particle
  7587. if (!m_FliesEff)
  7588. m_FliesEff = new EffSwarmingFlies();
  7589. if (m_FliesEff && !SEffectManager.IsEffectExist(m_FliesIndex))
  7590. {
  7591. m_FliesEff.SetDecalOwner(this);
  7592. m_FliesIndex = SEffectManager.PlayOnObject(m_FliesEff, this, "0 0.25 0");
  7593. p = m_FliesEff.GetParticle();
  7594. AddChild(p, boneIdx);
  7595. if (!m_SoundFliesEffect)
  7596. {
  7597. PlaySoundSetLoop(m_SoundFliesEffect, "Flies_SoundSet", 1.0, 1.0);
  7598. }
  7599. }
  7600. break;
  7601. case PlayerConstants.CORPSE_STATE_DECAYED :
  7602. //play serious sound/flies particle
  7603. if (!m_FliesEff)
  7604. m_FliesEff = new EffSwarmingFlies();
  7605. if (m_FliesEff && !SEffectManager.IsEffectExist(m_FliesIndex))
  7606. {
  7607. m_FliesEff.SetDecalOwner(this);
  7608. m_FliesIndex = SEffectManager.PlayOnObject(m_FliesEff, this, "0 0.25 0");
  7609. p = m_FliesEff.GetParticle();
  7610. AddChild(p, boneIdx);
  7611. if (!m_SoundFliesEffect)
  7612. {
  7613. PlaySoundSetLoop(m_SoundFliesEffect, "Flies_SoundSet", 1.0, 1.0);
  7614. }
  7615. }
  7616. break;
  7617. //remove
  7618. default:
  7619. SEffectManager.DestroyEffect(m_FliesEff);
  7620. StopSoundSet(m_SoundFliesEffect);
  7621. break;
  7622. }
  7623. }
  7624. void PreloadDecayTexture()
  7625. {
  7626. int idx = GetHiddenSelectionIndex("decay_preload");
  7627. if (idx > -1)
  7628. SetObjectTexture(idx, m_DecayedTexture);
  7629. }
  7630. void SetLastMapInfo(float scale, vector pos)
  7631. {
  7632. m_LastMapScale = scale;
  7633. m_LastMapPos = pos;
  7634. }
  7635. bool GetLastMapInfo(out float scale, out vector pos)
  7636. {
  7637. scale = m_LastMapScale;
  7638. pos = m_LastMapPos;
  7639. return m_LastMapScale != -1.0;
  7640. }
  7641. override bool PhysicalPredictiveDropItem(EntityAI entity, bool heavy_item_only = true)
  7642. {
  7643. vector dir;
  7644. ItemBase item = ItemBase.Cast(entity);
  7645. //! from hands
  7646. if (GetItemInHands() == item)
  7647. {
  7648. return PredictiveDropEntity(item);
  7649. }
  7650. else
  7651. {
  7652. ActionManagerClient actionManager = ActionManagerClient.Cast(m_ActionManager);
  7653. if (actionManager)
  7654. {
  7655. ActionTarget actionTarget = new ActionTarget(null, null, -1, vector.Zero, -1);
  7656. if (actionManager.GetAction(ActionDropItemSimple).Can(this, actionTarget, item))
  7657. {
  7658. actionManager.PerformActionStart(actionManager.GetAction(ActionDropItemSimple), actionTarget, item);
  7659. return true;
  7660. }
  7661. }
  7662. else
  7663. return true;
  7664. }
  7665. return false;
  7666. }
  7667. override void SetProcessUIWarning(bool state)
  7668. {
  7669. m_ProcessUIWarning = state;
  7670. }
  7671. void dmgDebugPrint(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
  7672. {
  7673. /*Print("ProjectileDebugging | Damage Health: " + damageResult.GetDamage(dmgZone,"Health") + " | Component: " + component + " | Zone: " + dmgZone + "| Timestamp: " + GetSimulationTimeStamp());
  7674. Print("ProjectileDebugging | speedCoef: " + speedCoef);
  7675. Print("ProjectileDebugging | GetWorldTime(): " + GetWorldTime());
  7676. Print("-----------------------------------------------");*/
  7677. }
  7678. //Use this method to process additionnal dmg to legs specifically (must use the dmg system to fire relevant events)
  7679. //Legzone is a dummy to inflict damage once and NOT transfer damage to other zones. All leg zones will drop to 0 anyway
  7680. void DamageAllLegs(float inputDmg)
  7681. {
  7682. array<string> legZones = new array<string>;
  7683. legZones.Insert("LeftLeg");
  7684. legZones.Insert("RightLeg");
  7685. legZones.Insert("RightFoot");
  7686. legZones.Insert("LeftFoot");
  7687. foreach (string legZone : legZones)
  7688. DecreaseHealth(legZone, "", inputDmg);
  7689. }
  7690. //! tries to hide item in player's hands, some exceptions for various movement states
  7691. void TryHideItemInHands(bool hide, bool force = false)
  7692. {
  7693. if (!hide && ((!IsSwimming() && !IsClimbingLadder() && !IsInVehicle() && !AnimCommandCheck(HumanMoveCommandID.CommandSwim | HumanMoveCommandID.CommandLadder | HumanMoveCommandID.CommandVehicle)) || force))
  7694. {
  7695. GetItemAccessor().HideItemInHands(false);
  7696. }
  7697. else
  7698. {
  7699. GetItemAccessor().HideItemInHands(true);
  7700. }
  7701. }
  7702. //!
  7703. bool CheckAndExecuteStackSplit(FindInventoryLocationType flags, notnull EntityAI item, notnull EntityAI target)
  7704. {
  7705. InventoryLocation il = new InventoryLocation;
  7706. if (target.GetInventory().FindFreeLocationFor(item, flags, il))
  7707. {
  7708. return CheckAndExecuteStackSplitToInventoryLocation(il,item);
  7709. }
  7710. return false;
  7711. }
  7712. bool CheckAndExecuteStackSplitToInventoryLocation(InventoryLocation il, notnull EntityAI item)
  7713. {
  7714. int slotID = il.GetSlot();
  7715. float stackableTarget = item.GetTargetQuantityMax(slotID);
  7716. if (stackableTarget > 0 && stackableTarget < item.GetQuantity())
  7717. {
  7718. ItemBase itemB;
  7719. if (CastTo(itemB, item))
  7720. {
  7721. itemB.SplitIntoStackMaxToInventoryLocationClient(il);
  7722. return true;
  7723. }
  7724. }
  7725. return false;
  7726. }
  7727. override protected bool TakeEntityToInventoryImpl(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
  7728. {
  7729. if (CheckAndExecuteStackSplit(flags, item, this))
  7730. {
  7731. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Inv(SPLIT) item=" + GetDebugName(item));
  7732. return true;
  7733. }
  7734. return super.TakeEntityToInventoryImpl(mode, flags, item);
  7735. }
  7736. override protected bool TakeEntityToCargoImpl(InventoryMode mode, notnull EntityAI item)
  7737. {
  7738. if (CheckAndExecuteStackSplit(FindInventoryLocationType.CARGO, item, this))
  7739. {
  7740. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Cgo(SPLIT) item=" +GetDebugName(item));
  7741. return true;
  7742. }
  7743. return super.TakeEntityToCargoImpl(mode, item);
  7744. }
  7745. override protected bool TakeEntityAsAttachmentImpl(InventoryMode mode, notnull EntityAI item)
  7746. {
  7747. if (CheckAndExecuteStackSplit(FindInventoryLocationType.ATTACHMENT, item, this))
  7748. {
  7749. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Att(SPLIT) item=" + GetDebugName(item));
  7750. return true;
  7751. }
  7752. return super.TakeEntityAsAttachmentImpl(mode, item);
  7753. }
  7754. override void TakeEntityToHandsImpl(InventoryMode mode, EntityAI item)
  7755. {
  7756. if (CheckAndExecuteStackSplit(FindInventoryLocationType.HANDS, item, this))
  7757. {
  7758. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Hands(SPLIT) item=" + GetDebugName(item));
  7759. return;
  7760. }
  7761. super.TakeEntityToHandsImpl(mode, item);
  7762. }
  7763. override protected bool TakeEntityToTargetInventoryImpl(InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
  7764. {
  7765. if (CheckAndExecuteStackSplit(flags, item, target))
  7766. {
  7767. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetInv(SPLIT) item=" + GetDebugName(item));
  7768. return true;
  7769. }
  7770. return super.TakeEntityToTargetInventoryImpl(mode, target, flags, item);
  7771. }
  7772. override protected bool TakeEntityToTargetCargoImpl(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
  7773. {
  7774. if (CheckAndExecuteStackSplit(FindInventoryLocationType.CARGO, item, target))
  7775. {
  7776. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetCgo(SPLIT) item=" + GetDebugName(item));
  7777. return true;
  7778. }
  7779. return super.TakeEntityToTargetCargoImpl(mode, target, item);
  7780. }
  7781. override protected bool TakeEntityToTargetAttachmentImpl(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
  7782. {
  7783. if (CheckAndExecuteStackSplit(FindInventoryLocationType.ATTACHMENT, item, target))
  7784. {
  7785. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2TargetAtt(SPLIT) item=" + GetDebugName(item));
  7786. return true;
  7787. }
  7788. return super.TakeEntityToTargetAttachmentImpl(mode, target, item);
  7789. }
  7790. override protected bool TakeToDstImpl(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
  7791. {
  7792. if (CheckAndExecuteStackSplitToInventoryLocation(dst, dst.GetItem()))
  7793. {
  7794. if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS=" + GetSimulationTimeStamp() + " Take2Dst(SPLIT) item=" + GetDebugName(dst.GetItem()));
  7795. return true;
  7796. }
  7797. return super.TakeToDstImpl(mode, src, dst);
  7798. }
  7799. override vector GetCenter()
  7800. {
  7801. return GetBonePositionWS(GetBoneIndexByName("spine3"));
  7802. }
  7803. // contaminated areas - temp stuff
  7804. void ContaminatedParticleAdjustment()
  7805. {
  7806. if (GetCommand_Move() && m_ContaminatedAroundPlayer && m_ContaminatedAroundPlayerTiny)
  7807. {
  7808. float playerSpeed = GetCommand_Move().GetCurrentMovementSpeed();
  7809. //Print(playerSpeed);
  7810. // 1 - prone, crouch
  7811. // 2 - jog
  7812. // 3 - sprint
  7813. float particleLifetime = 5.25;
  7814. float particleSpeed = 0.25;
  7815. if (playerSpeed >= 1)
  7816. {
  7817. particleLifetime = 3.5;
  7818. particleSpeed = 3.25;
  7819. }
  7820. if (playerSpeed >= 2)
  7821. {
  7822. particleLifetime = 2.5;
  7823. particleSpeed = 5.25;
  7824. }
  7825. if (playerSpeed >= 3)
  7826. {
  7827. particleLifetime = 1.5;
  7828. particleSpeed = 8.25;
  7829. }
  7830. m_ContaminatedAroundPlayer.SetParameter(0, EmitorParam.LIFETIME, particleLifetime);
  7831. m_ContaminatedAroundPlayer.SetParameter(1, EmitorParam.LIFETIME, particleLifetime);
  7832. m_ContaminatedAroundPlayer.SetParameter(2, EmitorParam.LIFETIME, particleLifetime);
  7833. m_ContaminatedAroundPlayer.SetParameter(3, EmitorParam.LIFETIME, particleLifetime);
  7834. m_ContaminatedAroundPlayerTiny.SetParameter(0, EmitorParam.VELOCITY, particleSpeed);
  7835. vector transform[4];
  7836. GetTransform(transform);
  7837. m_ContaminatedAroundPlayer.SetTransform(transform);
  7838. m_ContaminatedAroundPlayerTiny.SetTransform(transform);
  7839. }
  7840. }
  7841. void HandleGlassesEffect()
  7842. {
  7843. if (!IsControlledPlayer())
  7844. return;
  7845. int i;
  7846. if (m_ProcessRemoveGlassesEffects)
  7847. {
  7848. for (i = 0; i < m_ProcessRemoveGlassesEffects.Count(); i++)
  7849. {
  7850. PPERequesterBank.GetRequester(m_ProcessRemoveGlassesEffects[i]).Stop();
  7851. }
  7852. m_ProcessRemoveGlassesEffects.Clear();
  7853. }
  7854. if (m_ProcessAddGlassesEffects)
  7855. {
  7856. for (i = 0; i < m_ProcessAddGlassesEffects.Count(); i++)
  7857. {
  7858. PPERequesterBank.GetRequester(m_ProcessAddGlassesEffects[i]).Start();
  7859. }
  7860. m_ProcessAddGlassesEffects.Clear();
  7861. }
  7862. }
  7863. override void AddArrow(Object arrow, int componentIndex, vector closeBonePosWS, vector closeBoneRotWS)
  7864. {
  7865. CachedObjectsArrays.ARRAY_STRING.Clear();
  7866. GetActionComponentNameList(componentIndex, CachedObjectsArrays.ARRAY_STRING, LOD.NAME_FIRE);
  7867. int pivot = componentIndex;
  7868. int newPivot = -1;
  7869. string compName;
  7870. for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count() && newPivot == -1; i++)
  7871. {
  7872. compName = CachedObjectsArrays.ARRAY_STRING.Get(i);
  7873. newPivot = GetBoneIndexByName(compName);
  7874. }
  7875. if (newPivot != -1)
  7876. {
  7877. pivot = newPivot;
  7878. }
  7879. vector parentTransMat[4];
  7880. vector arrowTransMat[4];
  7881. arrow.GetTransform(arrowTransMat);
  7882. if (pivot == -1)
  7883. {
  7884. GetTransformWS(parentTransMat);
  7885. }
  7886. else
  7887. {
  7888. vector rotMatrix[3];
  7889. Math3D.YawPitchRollMatrix(closeBoneRotWS * Math.RAD2DEG,rotMatrix);
  7890. parentTransMat[0] = rotMatrix[0];
  7891. parentTransMat[1] = rotMatrix[1];
  7892. parentTransMat[2] = rotMatrix[2];
  7893. parentTransMat[3] = closeBonePosWS;
  7894. }
  7895. Math3D.MatrixInvMultiply4(parentTransMat, arrowTransMat, arrowTransMat);
  7896. Math3D.MatrixOrthogonalize4(arrowTransMat);
  7897. arrow.SetTransform(arrowTransMat);
  7898. AddChild(arrow, pivot);
  7899. #ifdef SERVER
  7900. // creating bleeding source
  7901. BleedingSourcesManagerServer bleedingManager = GetBleedingManagerServer();
  7902. if (bleedingManager)
  7903. {
  7904. if (!bleedingManager.AttemptAddBleedingSourceBySelection(compName))
  7905. 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
  7906. }
  7907. #endif
  7908. }
  7909. override bool IsManagingArrows()
  7910. {
  7911. return true;
  7912. }
  7913. string GetCachedName()
  7914. {
  7915. return m_CachedPlayerName;
  7916. }
  7917. string GetCachedID()
  7918. {
  7919. return m_CachedPlayerID;
  7920. }
  7921. override void OnFreezeStateChangeClient()
  7922. {
  7923. super.OnFreezeStateChangeClient();
  7924. UpdateCorpseState();
  7925. }
  7926. bool HasHeatBuffer()
  7927. {
  7928. return m_HasHeatBuffer;
  7929. }
  7930. int GetHeatBufferStage()
  7931. {
  7932. return m_HeatBufferStage;
  7933. }
  7934. //! ----------
  7935. //! DEPRECATED
  7936. //! ----------
  7937. static ref array<Object> SPREAD_AGENTS_OBJECTS = new array<Object>;
  7938. static ref array<CargoBase> SPREAD_AGENTS_PROXY_CARGOS = new array<CargoBase>;
  7939. private int m_FaceCoveredForShaveLayers = 0;
  7940. int m_AntibioticsActive;
  7941. void SwitchItemTypeAttach(EntityAI item, string slot)
  7942. {
  7943. if (!GetGame().IsServer())
  7944. return;
  7945. }
  7946. void SwitchItemTypeDetach(EntityAI item, string slot);
  7947. void AddToEnvironmentTemperature(float pTemperature);
  7948. void IncreaseAntibioticsCount()
  7949. {
  7950. AddMedicalDrugsInUse(EMedicalDrugsType.ANTIBIOTICS);
  7951. }
  7952. void DecreaseAntibioticsCount()
  7953. {
  7954. RemoveMedicalDrugsInUse(EMedicalDrugsType.ANTIBIOTICS);
  7955. }
  7956. bool Consume(ItemBase source, float amount, EConsumeType consume_type)
  7957. {
  7958. PlayerConsumeData consumeData = new PlayerConsumeData();
  7959. consumeData.m_Type = consume_type;
  7960. consumeData.m_Amount = amount;
  7961. consumeData.m_Source = source;
  7962. consumeData.m_Agents = 0;
  7963. return Consume(consumeData);
  7964. }
  7965. bool HasStaminaRemaining()
  7966. {
  7967. if (!GetStaminaHandler())
  7968. return false;
  7969. return GetStaminaHandler().GetStamina() > 0;
  7970. }
  7971. void SetBloodyHandsPenalty()
  7972. {
  7973. InsertAgent(eAgents.SALMONELLA, 1);
  7974. }
  7975. }
  7976. #ifdef DEVELOPER
  7977. PlayerBase _player;
  7978. #endif