GameScene.cs 504 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517
  1. using Client.MirControls;
  2. using Client.MirGraphics;
  3. using Client.MirNetwork;
  4. using Client.MirObjects;
  5. using Client.MirSounds;
  6. using SlimDX;
  7. using SlimDX.Direct3D9;
  8. using Font = System.Drawing.Font;
  9. using S = ServerPackets;
  10. using C = ClientPackets;
  11. using Effect = Client.MirObjects.Effect;
  12. using Client.MirScenes.Dialogs;
  13. using Client.Utils;
  14. using Client.MirGraphics.Particles;
  15. namespace Client.MirScenes
  16. {
  17. public sealed class GameScene : MirScene
  18. {
  19. public static GameScene Scene;
  20. public static bool Observing;
  21. public static bool AllowObserve;
  22. public static UserObject User
  23. {
  24. get { return MapObject.User; }
  25. set { MapObject.User = value; }
  26. }
  27. public static UserHeroObject Hero
  28. {
  29. get { return MapObject.Hero; }
  30. set { MapObject.Hero = value; }
  31. }
  32. public static HeroObject HeroObject
  33. {
  34. get { return MapObject.HeroObject; }
  35. set { MapObject.HeroObject = value; }
  36. }
  37. public static long MoveTime, AttackTime, NextRunTime, LogTime, LastRunTime, ChangePModeTime, ChangeAModeTime, HeroSpellTime, IntelligentCreaturePickupTime;
  38. public static bool CanMove, CanRun;
  39. private bool hasHero;
  40. public bool HasHero
  41. {
  42. get { return hasHero; }
  43. set
  44. {
  45. if (hasHero == value) return;
  46. hasHero = value;
  47. MainDialog.HeroSummonButton.Visible = value;
  48. }
  49. }
  50. public HeroSpawnState HeroSpawnState;
  51. public List<ParticleEngine> ParticleEngines = new List<ParticleEngine>();
  52. public MapControl MapControl;
  53. public MainDialog MainDialog;
  54. public ChatDialog ChatDialog;
  55. public ChatControlBar ChatControl;
  56. public InventoryDialog InventoryDialog;
  57. public CharacterDialog CharacterDialog;
  58. public CharacterDialog HeroDialog;
  59. public HeroInventoryDialog HeroInventoryDialog;
  60. public HeroManageDialog HeroManageDialog;
  61. public CraftDialog CraftDialog;
  62. public StorageDialog StorageDialog;
  63. public BeltDialog BeltDialog;
  64. public MiniMapDialog MiniMapDialog;
  65. public InspectDialog InspectDialog;
  66. public OptionDialog OptionDialog;
  67. public MenuDialog MenuDialog;
  68. public NPCDialog NPCDialog;
  69. public NPCGoodsDialog NPCGoodsDialog;
  70. public NPCGoodsDialog NPCSubGoodsDialog;
  71. public NPCGoodsDialog NPCCraftGoodsDialog;
  72. public NPCDropDialog NPCDropDialog;
  73. public NPCAwakeDialog NPCAwakeDialog;
  74. public HelpDialog HelpDialog;
  75. public MountDialog MountDialog;
  76. public FishingDialog FishingDialog;
  77. public FishingStatusDialog FishingStatusDialog;
  78. public RefineDialog RefineDialog;
  79. public GroupDialog GroupDialog;
  80. public GuildDialog GuildDialog;
  81. public GuildTerritoryDialog GuildTerritoryDialog;
  82. public NewCharacterDialog NewHeroDialog;
  83. public HeroBeltDialog HeroBeltDialog;
  84. public BigMapDialog BigMapDialog;
  85. public TrustMerchantDialog TrustMerchantDialog;
  86. public CharacterDuraPanel CharacterDuraPanel;
  87. public DuraStatusDialog DuraStatusPanel;
  88. public TradeDialog TradeDialog;
  89. public GuestTradeDialog GuestTradeDialog;
  90. public HeroMenuPanel HeroMenuPanel;
  91. public HeroBehaviourPanel HeroBehaviourPanel;
  92. public SocketDialog SocketDialog;
  93. public List<SkillBarDialog> SkillBarDialogs = new List<SkillBarDialog>();
  94. public ChatOptionDialog ChatOptionDialog;
  95. public ChatNoticeDialog ChatNoticeDialog;
  96. public QuestListDialog QuestListDialog;
  97. public QuestDetailDialog QuestDetailDialog;
  98. public QuestDiaryDialog QuestLogDialog;
  99. public QuestTrackingDialog QuestTrackingDialog;
  100. public RankingDialog RankingDialog;
  101. public MailListDialog MailListDialog;
  102. public MailComposeLetterDialog MailComposeLetterDialog;
  103. public MailComposeParcelDialog MailComposeParcelDialog;
  104. public MailReadLetterDialog MailReadLetterDialog;
  105. public MailReadParcelDialog MailReadParcelDialog;
  106. public IntelligentCreatureDialog IntelligentCreatureDialog;
  107. public IntelligentCreatureOptionsDialog IntelligentCreatureOptionsDialog;
  108. public IntelligentCreatureOptionsGradeDialog IntelligentCreatureOptionsGradeDialog;
  109. public FriendDialog FriendDialog;
  110. public MemoDialog MemoDialog;
  111. public RelationshipDialog RelationshipDialog;
  112. public MentorDialog MentorDialog;
  113. public GameShopDialog GameShopDialog;
  114. public ReportDialog ReportDialog;
  115. public ItemRentingDialog ItemRentingDialog;
  116. public ItemRentDialog ItemRentDialog;
  117. public GuestItemRentingDialog GuestItemRentingDialog;
  118. public GuestItemRentDialog GuestItemRentDialog;
  119. public ItemRentalDialog ItemRentalDialog;
  120. public BuffDialog BuffsDialog;
  121. public BuffDialog HeroBuffsDialog;
  122. public KeyboardLayoutDialog KeyboardLayoutDialog;
  123. public NoticeDialog NoticeDialog;
  124. public TimerDialog TimerControl;
  125. public CompassDialog CompassControl;
  126. public RollDialog RollControl;
  127. public static List<ItemInfo> ItemInfoList = new List<ItemInfo>();
  128. public static List<UserId> UserIdList = new List<UserId>();
  129. public static List<UserItem> ChatItemList = new List<UserItem>();
  130. public static List<ClientQuestInfo> QuestInfoList = new List<ClientQuestInfo>();
  131. public static List<GameShopItem> GameShopInfoList = new List<GameShopItem>();
  132. public static List<ClientRecipeInfo> RecipeInfoList = new List<ClientRecipeInfo>();
  133. public static Dictionary<int, BigMapRecord> MapInfoList = new Dictionary<int, BigMapRecord>();
  134. public static List<ClientHeroInformation> HeroInfoList = new List<ClientHeroInformation>();
  135. public static ClientHeroInformation[] HeroStorage = new ClientHeroInformation[8];
  136. public static Dictionary<long, RankCharacterInfo> RankingList = new Dictionary<long, RankCharacterInfo>();
  137. public static int TeleportToNPCCost;
  138. public static int MaximumHeroCount;
  139. public static List<ClientMonsterInfo> MonsterInfoList = new List<ClientMonsterInfo>();
  140. public static List<ClientNPCInfo> NPCInfoList = new List<ClientNPCInfo>();
  141. private static readonly HashSet<int> RequestedItemInfo = new HashSet<int>();
  142. private static readonly HashSet<int> RequestedMonsterInfo = new HashSet<int>();
  143. private static readonly HashSet<int> RequestedNPCInfo = new HashSet<int>();
  144. public static void RequestItemInfo(int index)
  145. {
  146. if (index <= 0 || HasItemInfo(index) || !RequestedItemInfo.Add(index)) return;
  147. if (!Network.Connected) return;
  148. Network.Enqueue(new C.RequestItemInfo { ItemIndex = index });
  149. }
  150. public static void RequestMonsterInfo(int index)
  151. {
  152. if (index <= 0 || HasMonsterInfo(index) || !RequestedMonsterInfo.Add(index)) return;
  153. if (!Network.Connected) return;
  154. Network.Enqueue(new C.RequestMonsterInfo { MonsterIndex = index });
  155. }
  156. public static void RequestNPCInfo(int index)
  157. {
  158. if (index <= 0 || HasNPCInfo(index) || !RequestedNPCInfo.Add(index)) return;
  159. if (!Network.Connected) return;
  160. Network.Enqueue(new C.RequestNPCInfo { NPCIndex = index });
  161. }
  162. public static void OnItemInfoReceived(int index)
  163. {
  164. RequestedItemInfo.Remove(index);
  165. }
  166. public static void OnMonsterInfoReceived(int index)
  167. {
  168. RequestedMonsterInfo.Remove(index);
  169. }
  170. public static void OnNPCInfoReceived(int index)
  171. {
  172. RequestedNPCInfo.Remove(index);
  173. }
  174. private static bool HasItemInfo(int index)
  175. {
  176. for (int i = 0; i < ItemInfoList.Count; i++)
  177. {
  178. if (ItemInfoList[i].Index == index)
  179. return true;
  180. }
  181. return false;
  182. }
  183. private static bool HasMonsterInfo(int index)
  184. {
  185. for (int i = 0; i < MonsterInfoList.Count; i++)
  186. {
  187. if (MonsterInfoList[i].Index == index)
  188. return true;
  189. }
  190. return false;
  191. }
  192. private static bool HasNPCInfo(int index)
  193. {
  194. for (int i = 0; i < NPCInfoList.Count; i++)
  195. {
  196. if (NPCInfoList[i].Index == index)
  197. return true;
  198. }
  199. return false;
  200. }
  201. public static UserItem[] Storage = new UserItem[80];
  202. public static UserItem[] GuildStorage = new UserItem[112];
  203. public static UserItem[] Refine = new UserItem[16];
  204. public static UserItem HoverItem, SelectedItem;
  205. public static MirItemCell SelectedCell;
  206. public static bool PickedUpGold;
  207. public MirControl ItemLabel, MailLabel, MemoLabel, GuildBuffLabel;
  208. public static long UseItemTime, PickUpTime, DropViewTime, TargetDeadTime;
  209. public static uint Gold, Credit;
  210. public static long InspectTime;
  211. public bool ShowReviveMessage;
  212. public bool NewMail;
  213. public int NewMailCounter = 0;
  214. public AttackMode AMode;
  215. public PetMode PMode;
  216. public LightSetting Lights;
  217. public static long NPCTime;
  218. public static uint NPCID;
  219. public static float NPCRate;
  220. public static PanelType NPCPanelType;
  221. public static uint DefaultNPCID;
  222. public static bool HideAddedStoreStats;
  223. public long ToggleTime;
  224. public static long SpellTime;
  225. public MirLabel[] OutputLines = new MirLabel[10];
  226. public List<OutPutMessage> OutputMessages = new List<OutPutMessage>();
  227. public long OutputDelay;
  228. public GameScene()
  229. {
  230. MapControl.AutoRun = false;
  231. MapControl.AutoHit = false;
  232. Scene = this;
  233. RequestedItemInfo.Clear();
  234. RequestedMonsterInfo.Clear();
  235. RequestedNPCInfo.Clear();
  236. BackColour = Color.Transparent;
  237. MoveTime = CMain.Time;
  238. KeyDown += GameScene_KeyDown;
  239. MainDialog = new MainDialog { Parent = this };
  240. ChatDialog = new ChatDialog { Parent = this };
  241. ChatControl = new ChatControlBar { Parent = this };
  242. InventoryDialog = new InventoryDialog { Parent = this };
  243. BeltDialog = new BeltDialog { Parent = this };
  244. StorageDialog = new StorageDialog { Parent = this, Visible = false };
  245. CraftDialog = new CraftDialog { Parent = this, Visible = false };
  246. MiniMapDialog = new MiniMapDialog { Parent = this };
  247. InspectDialog = new InspectDialog { Parent = this, Visible = false };
  248. OptionDialog = new OptionDialog { Parent = this, Visible = false };
  249. MenuDialog = new MenuDialog { Parent = this, Visible = false };
  250. NPCDialog = new NPCDialog { Parent = this, Visible = false };
  251. NPCGoodsDialog = new NPCGoodsDialog(PanelType.Buy) { Parent = this, Visible = false };
  252. NPCSubGoodsDialog = new NPCGoodsDialog(PanelType.BuySub) { Parent = this, Visible = false };
  253. NPCCraftGoodsDialog = new NPCGoodsDialog(PanelType.Craft) { Parent = this, Visible = false };
  254. NPCDropDialog = new NPCDropDialog { Parent = this, Visible = false };
  255. NPCAwakeDialog = new NPCAwakeDialog { Parent = this, Visible = false, Location = new Point(0, GameScene.Scene.NPCDialog.Size.Height) };
  256. HelpDialog = new HelpDialog { Parent = this, Visible = false };
  257. KeyboardLayoutDialog = new KeyboardLayoutDialog { Parent = this, Visible = false };
  258. NoticeDialog = new NoticeDialog { Parent = this, Visible = false };
  259. MountDialog = new MountDialog { Parent = this, Visible = false };
  260. FishingDialog = new FishingDialog { Parent = this, Visible = false };
  261. FishingStatusDialog = new FishingStatusDialog { Parent = this, Visible = false };
  262. GroupDialog = new GroupDialog { Parent = this, Visible = false };
  263. GuildDialog = new GuildDialog { Parent = this, Visible = false };
  264. GuildTerritoryDialog = new GuildTerritoryDialog { Parent = this, Visible = false };
  265. NewHeroDialog = new NewCharacterDialog { Parent = this, Visible = false };
  266. NewHeroDialog.TitleLabel.Index = 847;
  267. NewHeroDialog.TitleLabel.Location = new Point(246, 11);
  268. NewHeroDialog.OnCreateCharacter += (o, e) =>
  269. {
  270. Network.Enqueue(new C.NewHero
  271. {
  272. Name = NewHeroDialog.NameTextBox.Text,
  273. Class = NewHeroDialog.Class,
  274. Gender = NewHeroDialog.Gender
  275. });
  276. };
  277. HeroMenuPanel = new HeroMenuPanel(this) { Visible = false };
  278. HeroBehaviourPanel = new HeroBehaviourPanel { Parent = this, Visible = false };
  279. HeroManageDialog = new HeroManageDialog { Parent = this, Visible = false };
  280. BigMapDialog = new BigMapDialog { Parent = this, Visible = false };
  281. TrustMerchantDialog = new TrustMerchantDialog { Parent = this, Visible = false };
  282. CharacterDuraPanel = new CharacterDuraPanel { Parent = this, Visible = false };
  283. DuraStatusPanel = new DuraStatusDialog { Parent = this, Visible = true };
  284. TradeDialog = new TradeDialog { Parent = this, Visible = false };
  285. GuestTradeDialog = new GuestTradeDialog { Parent = this, Visible = false };
  286. SocketDialog = new SocketDialog { Parent = this, Visible = false };
  287. SkillBarDialog Bar1 = new SkillBarDialog { Parent = this, Visible = false, BarIndex = 0 };
  288. SkillBarDialogs.Add(Bar1);
  289. SkillBarDialog Bar2 = new SkillBarDialog { Parent = this, Visible = false, BarIndex = 1 };
  290. SkillBarDialogs.Add(Bar2);
  291. ChatOptionDialog = new ChatOptionDialog { Parent = this, Visible = false };
  292. ChatNoticeDialog = new ChatNoticeDialog { Parent = this, Visible = false };
  293. QuestListDialog = new QuestListDialog { Parent = this, Visible = false };
  294. QuestDetailDialog = new QuestDetailDialog { Parent = this, Visible = false };
  295. QuestTrackingDialog = new QuestTrackingDialog { Parent = this, Visible = false };
  296. QuestLogDialog = new QuestDiaryDialog { Parent = this, Visible = false };
  297. RankingDialog = new RankingDialog { Parent = this, Visible = false };
  298. MailListDialog = new MailListDialog { Parent = this, Visible = false };
  299. MailComposeLetterDialog = new MailComposeLetterDialog { Parent = this, Visible = false };
  300. MailComposeParcelDialog = new MailComposeParcelDialog { Parent = this, Visible = false };
  301. MailReadLetterDialog = new MailReadLetterDialog { Parent = this, Visible = false };
  302. MailReadParcelDialog = new MailReadParcelDialog { Parent = this, Visible = false };
  303. IntelligentCreatureDialog = new IntelligentCreatureDialog { Parent = this, Visible = false };
  304. IntelligentCreatureOptionsDialog = new IntelligentCreatureOptionsDialog { Parent = this, Visible = false };
  305. IntelligentCreatureOptionsGradeDialog = new IntelligentCreatureOptionsGradeDialog { Parent = this, Visible = false };
  306. RefineDialog = new RefineDialog { Parent = this, Visible = false };
  307. RelationshipDialog = new RelationshipDialog { Parent = this, Visible = false };
  308. FriendDialog = new FriendDialog { Parent = this, Visible = false };
  309. MemoDialog = new MemoDialog { Parent = this, Visible = false };
  310. MentorDialog = new MentorDialog { Parent = this, Visible = false };
  311. GameShopDialog = new GameShopDialog { Parent = this, Visible = false };
  312. ReportDialog = new ReportDialog { Parent = this, Visible = false };
  313. ItemRentingDialog = new ItemRentingDialog { Parent = this, Visible = false };
  314. ItemRentDialog = new ItemRentDialog { Parent = this, Visible = false };
  315. GuestItemRentingDialog = new GuestItemRentingDialog { Parent = this, Visible = false };
  316. GuestItemRentDialog = new GuestItemRentDialog { Parent = this, Visible = false };
  317. ItemRentalDialog = new ItemRentalDialog { Parent = this, Visible = false };
  318. BuffsDialog = new BuffDialog
  319. {
  320. Parent = this,
  321. Visible = true,
  322. GetExpandedParameter = () => { return Settings.ExpandedBuffWindow; },
  323. SetExpandedParameter = (value) => { Settings.ExpandedBuffWindow = value; }
  324. };
  325. KeyboardLayoutDialog = new KeyboardLayoutDialog { Parent = this, Visible = false };
  326. TimerControl = new TimerDialog { Parent = this, Visible = false };
  327. CompassControl = new CompassDialog { Parent = this, Visible = false };
  328. RollControl = new RollDialog { Parent = this, Visible = false };
  329. for (int i = 0; i < OutputLines.Length; i++)
  330. OutputLines[i] = new MirLabel
  331. {
  332. AutoSize = true,
  333. BackColour = Color.Transparent,
  334. Font = new Font(Settings.FontName, 10F),
  335. ForeColour = Color.LimeGreen,
  336. Location = new Point(20, 25 + i * 13),
  337. OutLine = true,
  338. };
  339. if (MapInfoList.Count > 0)
  340. RecreateBigMapButtons();
  341. }
  342. private void UpdateMouseCursor()
  343. {
  344. if (!Settings.UseMouseCursors) return;
  345. if (GameScene.HoverItem != null)
  346. {
  347. if (GameScene.SelectedCell != null && GameScene.SelectedCell.Item != null && GameScene.SelectedCell.Item.Info.Type == ItemType.Gem && CMain.Ctrl)
  348. {
  349. CMain.SetMouseCursor(MouseCursor.Upgrade);
  350. }
  351. else
  352. {
  353. CMain.SetMouseCursor(MouseCursor.Default);
  354. }
  355. }
  356. else if (MapObject.MouseObject != null)
  357. {
  358. switch (MapObject.MouseObject.Race)
  359. {
  360. case ObjectType.Monster:
  361. CMain.SetMouseCursor(MouseCursor.Attack);
  362. break;
  363. case ObjectType.Merchant:
  364. CMain.SetMouseCursor(MouseCursor.NPCTalk);
  365. break;
  366. case ObjectType.Player:
  367. if (CMain.Shift)
  368. {
  369. CMain.SetMouseCursor(MouseCursor.AttackRed);
  370. }
  371. else
  372. {
  373. CMain.SetMouseCursor(MouseCursor.Default);
  374. }
  375. break;
  376. default:
  377. CMain.SetMouseCursor(MouseCursor.Default);
  378. break;
  379. }
  380. }
  381. else
  382. {
  383. CMain.SetMouseCursor(MouseCursor.Default);
  384. }
  385. }
  386. public void OutputMessage(string message, OutputMessageType type = OutputMessageType.Normal)
  387. {
  388. OutputMessages.Add(new OutPutMessage { Message = message, ExpireTime = CMain.Time + 5000, Type = type });
  389. if (OutputMessages.Count > 10)
  390. OutputMessages.RemoveAt(0);
  391. }
  392. private void ProcessOuput()
  393. {
  394. for (int i = 0; i < OutputMessages.Count; i++)
  395. {
  396. if (CMain.Time >= OutputMessages[i].ExpireTime)
  397. OutputMessages.RemoveAt(i);
  398. }
  399. for (int i = 0; i < OutputLines.Length; i++)
  400. {
  401. if (OutputMessages.Count > i)
  402. {
  403. Color color;
  404. switch (OutputMessages[i].Type)
  405. {
  406. case OutputMessageType.Quest:
  407. color = Color.Gold;
  408. break;
  409. case OutputMessageType.Guild:
  410. color = Color.DeepPink;
  411. break;
  412. default:
  413. color = Color.LimeGreen;
  414. break;
  415. }
  416. OutputLines[i].Text = OutputMessages[i].Message;
  417. OutputLines[i].ForeColour = color;
  418. OutputLines[i].Visible = true;
  419. }
  420. else
  421. {
  422. OutputLines[i].Text = string.Empty;
  423. OutputLines[i].Visible = false;
  424. }
  425. }
  426. }
  427. private void GameScene_KeyDown(object sender, KeyEventArgs e)
  428. {
  429. if (GameScene.Scene.KeyboardLayoutDialog.WaitingForBind != null)
  430. {
  431. GameScene.Scene.KeyboardLayoutDialog.CheckNewInput(e);
  432. return;
  433. }
  434. foreach (KeyBind KeyCheck in CMain.InputKeys.Keylist)
  435. {
  436. if (KeyCheck.Key == Keys.None)
  437. continue;
  438. if (KeyCheck.Key != e.KeyCode)
  439. continue;
  440. if (KeyCheck.Key == Keys.Insert && e.KeyCode == Keys.Insert && e.Modifiers == Keys.Control)
  441. {
  442. //When Ctrl is held down, KeyData=Insert | Control, the system may mistakenly recognize it as Keys.Insert, requiring special judgment to be added.
  443. continue;
  444. }
  445. if ((KeyCheck.RequireAlt != 2) && (KeyCheck.RequireAlt != (CMain.Alt ? 1 : 0)))
  446. continue;
  447. if ((KeyCheck.RequireShift != 2) && (KeyCheck.RequireShift != (CMain.Shift ? 1 : 0)))
  448. continue;
  449. if ((KeyCheck.RequireCtrl != 2) && (KeyCheck.RequireCtrl != (CMain.Ctrl ? 1 : 0)))
  450. continue;
  451. if ((KeyCheck.RequireTilde != 2) && (KeyCheck.RequireTilde != (CMain.Tilde ? 1 : 0)))
  452. continue;
  453. //now run the real code
  454. switch (KeyCheck.function)
  455. {
  456. case KeybindOptions.Bar1Skill1: UseSpell(1); break;
  457. case KeybindOptions.Bar1Skill2: UseSpell(2); break;
  458. case KeybindOptions.Bar1Skill3: UseSpell(3); break;
  459. case KeybindOptions.Bar1Skill4: UseSpell(4); break;
  460. case KeybindOptions.Bar1Skill5: UseSpell(5); break;
  461. case KeybindOptions.Bar1Skill6: UseSpell(6); break;
  462. case KeybindOptions.Bar1Skill7: UseSpell(7); break;
  463. case KeybindOptions.Bar1Skill8: UseSpell(8); break;
  464. case KeybindOptions.Bar2Skill1: UseSpell(9); break;
  465. case KeybindOptions.Bar2Skill2: UseSpell(10); break;
  466. case KeybindOptions.Bar2Skill3: UseSpell(11); break;
  467. case KeybindOptions.Bar2Skill4: UseSpell(12); break;
  468. case KeybindOptions.Bar2Skill5: UseSpell(13); break;
  469. case KeybindOptions.Bar2Skill6: UseSpell(14); break;
  470. case KeybindOptions.Bar2Skill7: UseSpell(15); break;
  471. case KeybindOptions.Bar2Skill8: UseSpell(16); break;
  472. case KeybindOptions.HeroSkill1: UseSpell(17); break;
  473. case KeybindOptions.HeroSkill2: UseSpell(18); break;
  474. case KeybindOptions.HeroSkill3: UseSpell(19); break;
  475. case KeybindOptions.HeroSkill4: UseSpell(20); break;
  476. case KeybindOptions.HeroSkill5: UseSpell(21); break;
  477. case KeybindOptions.HeroSkill6: UseSpell(22); break;
  478. case KeybindOptions.HeroSkill7: UseSpell(23); break;
  479. case KeybindOptions.HeroSkill8: UseSpell(24); break;
  480. case KeybindOptions.Inventory:
  481. case KeybindOptions.Inventory2:
  482. if (!InventoryDialog.Visible) InventoryDialog.Show();
  483. else InventoryDialog.Hide();
  484. break;
  485. case KeybindOptions.Equipment:
  486. case KeybindOptions.Equipment2:
  487. if (!CharacterDialog.Visible || !CharacterDialog.CharacterPage.Visible)
  488. {
  489. CharacterDialog.Show();
  490. CharacterDialog.ShowCharacterPage();
  491. }
  492. else CharacterDialog.Hide();
  493. break;
  494. case KeybindOptions.Skills:
  495. case KeybindOptions.Skills2:
  496. if (!CharacterDialog.Visible || !CharacterDialog.SkillPage.Visible)
  497. {
  498. CharacterDialog.Show();
  499. CharacterDialog.ShowSkillPage();
  500. }
  501. else CharacterDialog.Hide();
  502. break;
  503. case KeybindOptions.HeroInventory:
  504. if (Hero == null)
  505. break;
  506. if (!HeroInventoryDialog.Visible) HeroInventoryDialog.Show();
  507. else HeroInventoryDialog.Hide();
  508. break;
  509. case KeybindOptions.HeroEquipment:
  510. if (Hero == null)
  511. break;
  512. if (!HeroDialog.Visible || !HeroDialog.CharacterPage.Visible)
  513. {
  514. HeroDialog.Show();
  515. HeroDialog.ShowCharacterPage();
  516. }
  517. else HeroDialog.Hide();
  518. break;
  519. case KeybindOptions.HeroSkills:
  520. if (Hero == null)
  521. break;
  522. if (!HeroDialog.Visible || !HeroDialog.SkillPage.Visible)
  523. {
  524. HeroDialog.Show();
  525. HeroDialog.ShowSkillPage();
  526. }
  527. else HeroDialog.Hide();
  528. break;
  529. case KeybindOptions.Creature:
  530. if (!IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Show();
  531. else IntelligentCreatureDialog.Hide();
  532. break;
  533. case KeybindOptions.MountWindow:
  534. if (!MountDialog.Visible) MountDialog.Show();
  535. else MountDialog.Hide();
  536. break;
  537. case KeybindOptions.GameShop:
  538. if (!GameShopDialog.Visible) GameShopDialog.Show();
  539. else GameShopDialog.Hide();
  540. break;
  541. case KeybindOptions.Fishing:
  542. if (!FishingDialog.Visible) FishingDialog.Show();
  543. else FishingDialog.Hide();
  544. break;
  545. case KeybindOptions.Skillbar:
  546. if (!Settings.SkillBar)
  547. foreach (SkillBarDialog Bar in SkillBarDialogs)
  548. Bar.Show();
  549. else
  550. foreach (SkillBarDialog Bar in SkillBarDialogs)
  551. Bar.Hide();
  552. break;
  553. case KeybindOptions.Mount:
  554. if (GameScene.Scene.MountDialog.CanRide())
  555. GameScene.Scene.MountDialog.Ride();
  556. break;
  557. case KeybindOptions.Mentor:
  558. if (!MentorDialog.Visible) MentorDialog.Show();
  559. else MentorDialog.Hide();
  560. break;
  561. case KeybindOptions.Relationship:
  562. if (!RelationshipDialog.Visible) RelationshipDialog.Show();
  563. else RelationshipDialog.Hide();
  564. break;
  565. case KeybindOptions.Friends:
  566. if (!FriendDialog.Visible) FriendDialog.Show();
  567. else FriendDialog.Hide();
  568. break;
  569. case KeybindOptions.Guilds:
  570. if (!GuildDialog.Visible) GuildDialog.Show();
  571. else
  572. {
  573. GuildDialog.Hide();
  574. }
  575. break;
  576. case KeybindOptions.Ranking:
  577. if (!RankingDialog.Visible) RankingDialog.Show();
  578. else RankingDialog.Hide();
  579. break;
  580. case KeybindOptions.Quests:
  581. if (!QuestLogDialog.Visible) QuestLogDialog.Show();
  582. else QuestLogDialog.Hide();
  583. break;
  584. case KeybindOptions.Exit:
  585. QuitGame();
  586. return;
  587. case KeybindOptions.Closeall:
  588. InventoryDialog.Hide();
  589. CharacterDialog.Hide();
  590. OptionDialog.Hide();
  591. MenuDialog.Hide();
  592. if (NPCDialog.Visible) NPCDialog.Hide();
  593. HelpDialog.Hide();
  594. KeyboardLayoutDialog.Hide();
  595. RankingDialog.Hide();
  596. IntelligentCreatureDialog.Hide();
  597. IntelligentCreatureOptionsDialog.Hide();
  598. IntelligentCreatureOptionsGradeDialog.Hide();
  599. MountDialog.Hide();
  600. FishingDialog.Hide();
  601. FriendDialog.Hide();
  602. RelationshipDialog.Hide();
  603. MentorDialog.Hide();
  604. GameShopDialog.Hide();
  605. GroupDialog.Hide();
  606. GuildDialog.Hide();
  607. InspectDialog.Hide();
  608. StorageDialog.Hide();
  609. TrustMerchantDialog.Hide();
  610. //CharacterDuraPanel.Hide();
  611. QuestListDialog.Hide();
  612. QuestDetailDialog.Hide();
  613. QuestLogDialog.Hide();
  614. NPCAwakeDialog.Hide();
  615. RefineDialog.Hide();
  616. BigMapDialog.Hide();
  617. if (FishingStatusDialog.bEscExit) FishingStatusDialog.Cancel();
  618. MailComposeLetterDialog.Hide();
  619. MailComposeParcelDialog.Hide();
  620. MailListDialog.Hide();
  621. MailReadLetterDialog.Hide();
  622. MailReadParcelDialog.Hide();
  623. ItemRentalDialog.Hide();
  624. NoticeDialog.Hide();
  625. HeroInventoryDialog?.Hide();
  626. HeroManageDialog?.Hide();
  627. HeroDialog?.Hide();
  628. GameScene.Scene.DisposeItemLabel();
  629. break;
  630. case KeybindOptions.Options:
  631. case KeybindOptions.Options2:
  632. if (!OptionDialog.Visible) OptionDialog.Show();
  633. else OptionDialog.Hide();
  634. break;
  635. case KeybindOptions.Group:
  636. if (!GroupDialog.Visible) GroupDialog.Show();
  637. else GroupDialog.Hide();
  638. break;
  639. case KeybindOptions.Belt:
  640. if (!BeltDialog.Visible) BeltDialog.Show();
  641. else BeltDialog.Hide();
  642. break;
  643. case KeybindOptions.BeltFlip:
  644. BeltDialog.Flip();
  645. break;
  646. case KeybindOptions.Pickup:
  647. if (CMain.Time > PickUpTime)
  648. {
  649. PickUpTime = CMain.Time + 200;
  650. Network.Enqueue(new C.PickUp());
  651. }
  652. break;
  653. case KeybindOptions.Belt1:
  654. case KeybindOptions.Belt1Alt:
  655. BeltDialog.Grid[0].UseItem();
  656. break;
  657. case KeybindOptions.Belt2:
  658. case KeybindOptions.Belt2Alt:
  659. BeltDialog.Grid[1].UseItem();
  660. break;
  661. case KeybindOptions.Belt3:
  662. case KeybindOptions.Belt3Alt:
  663. BeltDialog.Grid[2].UseItem();
  664. break;
  665. case KeybindOptions.Belt4:
  666. case KeybindOptions.Belt4Alt:
  667. BeltDialog.Grid[3].UseItem();
  668. break;
  669. case KeybindOptions.Belt5:
  670. case KeybindOptions.Belt5Alt:
  671. BeltDialog.Grid[4].UseItem();
  672. break;
  673. case KeybindOptions.Belt6:
  674. case KeybindOptions.Belt6Alt:
  675. BeltDialog.Grid[5].UseItem();
  676. break;
  677. case KeybindOptions.Belt7:
  678. case KeybindOptions.Belt7Alt:
  679. HeroBeltDialog?.Grid[0].UseItem();
  680. break;
  681. case KeybindOptions.Belt8:
  682. case KeybindOptions.Belt8Alt:
  683. HeroBeltDialog?.Grid[1].UseItem();
  684. break;
  685. case KeybindOptions.Logout:
  686. LogOut();
  687. break;
  688. case KeybindOptions.Minimap:
  689. MiniMapDialog.Toggle();
  690. break;
  691. case KeybindOptions.Bigmap:
  692. BigMapDialog.Toggle();
  693. break;
  694. case KeybindOptions.Trade:
  695. Network.Enqueue(new C.TradeRequest());
  696. break;
  697. case KeybindOptions.Rental:
  698. ItemRentalDialog.Toggle();
  699. break;
  700. case KeybindOptions.ChangePetmode:
  701. ChangePetMode();
  702. break;
  703. case KeybindOptions.PetmodeBoth:
  704. Network.Enqueue(new C.ChangePMode { Mode = PetMode.Both });
  705. return;
  706. case KeybindOptions.PetmodeMoveonly:
  707. Network.Enqueue(new C.ChangePMode { Mode = PetMode.MoveOnly });
  708. return;
  709. case KeybindOptions.PetmodeAttackonly:
  710. Network.Enqueue(new C.ChangePMode { Mode = PetMode.AttackOnly });
  711. return;
  712. case KeybindOptions.PetmodeNone:
  713. Network.Enqueue(new C.ChangePMode { Mode = PetMode.None });
  714. return;
  715. case KeybindOptions.PetmodeFocusMasterTarget:
  716. Network.Enqueue(new C.ChangePMode { Mode = PetMode.FocusMasterTarget });
  717. return;
  718. case KeybindOptions.CreatureAutoPickup://semiauto!
  719. if (CMain.Time > IntelligentCreaturePickupTime)
  720. {
  721. IntelligentCreaturePickupTime = CMain.Time + 200;
  722. Network.Enqueue(new C.IntelligentCreaturePickup { MouseMode = false, Location = MapControl.MapLocation });
  723. }
  724. break;
  725. case KeybindOptions.CreaturePickup:
  726. if (CMain.Time > IntelligentCreaturePickupTime)
  727. {
  728. IntelligentCreaturePickupTime = CMain.Time + 200;
  729. Network.Enqueue(new C.IntelligentCreaturePickup { MouseMode = true, Location = MapControl.MapLocation });
  730. }
  731. break;
  732. case KeybindOptions.ChangeAttackmode:
  733. ChangeAttackMode();
  734. break;
  735. case KeybindOptions.AttackmodePeace:
  736. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.Peace });
  737. return;
  738. case KeybindOptions.AttackmodeGroup:
  739. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.Group });
  740. return;
  741. case KeybindOptions.AttackmodeGuild:
  742. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.Guild });
  743. return;
  744. case KeybindOptions.AttackmodeEnemyguild:
  745. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.EnemyGuild });
  746. return;
  747. case KeybindOptions.AttackmodeRedbrown:
  748. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.RedBrown });
  749. return;
  750. case KeybindOptions.AttackmodeAll:
  751. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.All });
  752. return;
  753. case KeybindOptions.Help:
  754. if (!HelpDialog.Visible) HelpDialog.Show();
  755. else HelpDialog.Hide();
  756. break;
  757. case KeybindOptions.Keybind:
  758. if (!KeyboardLayoutDialog.Visible) KeyboardLayoutDialog.Show();
  759. else KeyboardLayoutDialog.Hide();
  760. break;
  761. case KeybindOptions.Autorun:
  762. MapControl.AutoRun = !MapControl.AutoRun;
  763. break;
  764. case KeybindOptions.Cameramode:
  765. if (!MainDialog.Visible)
  766. {
  767. MainDialog.Show();
  768. ChatDialog.Show();
  769. BeltDialog.Show();
  770. ChatControl.Show();
  771. MiniMapDialog.Show();
  772. CharacterDuraPanel.Show();
  773. DuraStatusPanel.Show();
  774. BuffsDialog.Show();
  775. }
  776. else
  777. {
  778. MainDialog.Hide();
  779. ChatDialog.Hide();
  780. BeltDialog.Hide();
  781. ChatControl.Hide();
  782. MiniMapDialog.Hide();
  783. CharacterDuraPanel.Hide();
  784. DuraStatusPanel.Hide();
  785. BuffsDialog.Hide();
  786. }
  787. break;
  788. case KeybindOptions.DropView:
  789. if (CMain.Time > DropViewTime)
  790. DropViewTime = CMain.Time + 5000;
  791. break;
  792. case KeybindOptions.TargetDead:
  793. if (CMain.Time > TargetDeadTime)
  794. TargetDeadTime = CMain.Time + 5000;
  795. break;
  796. case KeybindOptions.AddGroupMember:
  797. if (MapObject.MouseObject == null) break;
  798. if (MapObject.MouseObject.Race != ObjectType.Player) break;
  799. GameScene.Scene.GroupDialog.AddMember(MapObject.MouseObject.Name);
  800. break;
  801. }
  802. }
  803. }
  804. public void ChangeSkillMode(bool? ctrl)
  805. {
  806. if (Settings.SkillMode || ctrl == true)
  807. {
  808. Settings.SkillMode = false;
  809. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SkillModeCtrl), ChatType.Hint);
  810. GameScene.Scene.OptionDialog.ToggleSkillButtons(true);
  811. }
  812. else if (!Settings.SkillMode || ctrl == false)
  813. {
  814. Settings.SkillMode = true;
  815. GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SkillModeTilde), ChatType.Hint);
  816. GameScene.Scene.OptionDialog.ToggleSkillButtons(false);
  817. }
  818. }
  819. public void ChangePetMode()
  820. {
  821. if (CMain.Time > ChangePModeTime)
  822. {
  823. ChangePModeTime = CMain.Time + 500;
  824. switch (PMode)
  825. {
  826. case PetMode.Both:
  827. Network.Enqueue(new C.ChangePMode { Mode = PetMode.MoveOnly });
  828. return;
  829. case PetMode.MoveOnly:
  830. Network.Enqueue(new C.ChangePMode { Mode = PetMode.AttackOnly });
  831. return;
  832. case PetMode.AttackOnly:
  833. Network.Enqueue(new C.ChangePMode { Mode = PetMode.None });
  834. return;
  835. case PetMode.None:
  836. Network.Enqueue(new C.ChangePMode { Mode = PetMode.FocusMasterTarget });
  837. return;
  838. case PetMode.FocusMasterTarget:
  839. Network.Enqueue(new C.ChangePMode { Mode = PetMode.Both });
  840. return;
  841. }
  842. }
  843. }
  844. public void ChangeAttackMode()
  845. {
  846. if (CMain.Time > ChangeAModeTime)
  847. {
  848. ChangeAModeTime = CMain.Time + 300;
  849. switch (AMode)
  850. {
  851. case AttackMode.Peace:
  852. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.Group });
  853. return;
  854. case AttackMode.Group:
  855. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.Guild });
  856. return;
  857. case AttackMode.Guild:
  858. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.EnemyGuild });
  859. return;
  860. case AttackMode.EnemyGuild:
  861. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.RedBrown });
  862. return;
  863. case AttackMode.RedBrown:
  864. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.All });
  865. return;
  866. case AttackMode.All:
  867. Network.Enqueue(new C.ChangeAMode { Mode = AttackMode.Peace });
  868. return;
  869. }
  870. }
  871. }
  872. public void UseSpell(int key)
  873. {
  874. UserObject actor = User;
  875. if (key > 16)
  876. {
  877. if (HeroObject == null || CMain.Time < HeroSpellTime) return;
  878. actor = Hero;
  879. HeroSpellTime = CMain.Time + 200;
  880. }
  881. if (actor.Dead || actor.RidingMount || actor.Fishing) return;
  882. if (!actor.HasClassWeapon && actor.Weapon >= 0)
  883. {
  884. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MustWearSuitableWeapon), ChatType.System);
  885. return;
  886. }
  887. if (CMain.Time < actor.BlizzardStopTime || CMain.Time < actor.ReincarnationStopTime) return;
  888. ClientMagic magic = null;
  889. for (int i = 0; i < actor.Magics.Count; i++)
  890. {
  891. if (actor.Magics[i].Key != key) continue;
  892. magic = actor.Magics[i];
  893. break;
  894. }
  895. if (magic == null) return;
  896. switch (magic.Spell)
  897. {
  898. case Spell.CounterAttack:
  899. if ((CMain.Time < magic.CastTime + magic.Delay))
  900. {
  901. if (CMain.Time >= OutputDelay)
  902. {
  903. OutputDelay = CMain.Time + 1000;
  904. Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CannotCastForSeconds), magic.Name,
  905. ((magic.CastTime + magic.Delay) - CMain.Time - 1) / 1000 + 1));
  906. }
  907. return;
  908. }
  909. magic.CastTime = CMain.Time;
  910. break;
  911. }
  912. int cost;
  913. string prefix = actor == Hero ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Hero) : string.Empty;
  914. switch (magic.Spell)
  915. {
  916. case Spell.Fencing:
  917. case Spell.FatalSword:
  918. case Spell.MPEater:
  919. case Spell.Hemorrhage:
  920. case Spell.SpiritSword:
  921. case Spell.Slaying:
  922. case Spell.Focus:
  923. case Spell.Meditation:
  924. return;
  925. case Spell.Thrusting:
  926. if (CMain.Time < ToggleTime) return;
  927. actor.Thrusting = !actor.Thrusting;
  928. ChatDialog.ReceiveChat(
  929. prefix + (actor.Thrusting ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseThrusting) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseThrusting)),
  930. ChatType.Hint);
  931. ToggleTime = CMain.Time + 1000;
  932. SendSpellToggle(actor, magic.Spell, actor.Thrusting);
  933. break;
  934. case Spell.HalfMoon:
  935. if (CMain.Time < ToggleTime) return;
  936. actor.HalfMoon = !actor.HalfMoon;
  937. ChatDialog.ReceiveChat(
  938. prefix + (actor.HalfMoon ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseHalfMoon) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseHalfMoon)),
  939. ChatType.Hint);
  940. ToggleTime = CMain.Time + 1000;
  941. SendSpellToggle(actor, magic.Spell, actor.HalfMoon);
  942. break;
  943. case Spell.CrossHalfMoon:
  944. if (CMain.Time < ToggleTime) return;
  945. actor.CrossHalfMoon = !actor.CrossHalfMoon;
  946. ChatDialog.ReceiveChat(
  947. prefix + (actor.CrossHalfMoon ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseCrossHalfMoon) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseCrossHalfMoon)),
  948. ChatType.Hint);
  949. ToggleTime = CMain.Time + 1000;
  950. SendSpellToggle(actor, magic.Spell, actor.CrossHalfMoon);
  951. break;
  952. case Spell.DoubleSlash:
  953. if (CMain.Time < ToggleTime) return;
  954. actor.DoubleSlash = !actor.DoubleSlash;
  955. ChatDialog.ReceiveChat(
  956. prefix + (actor.DoubleSlash ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseDoubleSlash) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseDoubleSlash)),
  957. ChatType.Hint);
  958. ToggleTime = CMain.Time + 1000;
  959. SendSpellToggle(actor, magic.Spell, actor.DoubleSlash);
  960. break;
  961. case Spell.TwinDrakeBlade:
  962. if (CMain.Time < ToggleTime) return;
  963. ToggleTime = CMain.Time + 500;
  964. cost = magic.Level * magic.LevelCost + magic.BaseCost;
  965. if (cost > actor.MP)
  966. {
  967. Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LowMana));
  968. return;
  969. }
  970. actor.TwinDrakeBlade = true;
  971. SendSpellToggle(actor, magic.Spell, true);
  972. if (actor == Hero)
  973. HeroObject?.Effects.Add(new Effect(Libraries.Magic2, 210, 6, 500, HeroObject));
  974. else
  975. actor.Effects.Add(new Effect(Libraries.Magic2, 210, 6, 500, actor));
  976. break;
  977. case Spell.FlamingSword:
  978. if (CMain.Time < ToggleTime) return;
  979. ToggleTime = CMain.Time + 500;
  980. cost = magic.Level * magic.LevelCost + magic.BaseCost;
  981. if (cost > actor.MP)
  982. {
  983. Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LowMana));
  984. return;
  985. }
  986. SendSpellToggle(actor, magic.Spell, true);
  987. break;
  988. case Spell.CounterAttack:
  989. cost = magic.Level * magic.LevelCost + magic.BaseCost;
  990. if (cost > actor.MP)
  991. {
  992. Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LowMana));
  993. return;
  994. }
  995. SoundManager.PlaySound(20000 + (ushort)Spell.CounterAttack * 10);
  996. SendSpellToggle(actor, magic.Spell, true);
  997. break;
  998. case Spell.MentalState:
  999. if (CMain.Time < ToggleTime) return;
  1000. ToggleTime = CMain.Time + 500;
  1001. SendSpellToggle(actor, magic.Spell, true);
  1002. break;
  1003. default:
  1004. actor.NextMagic = magic;
  1005. actor.NextMagicLocation = MapControl.MapLocation;
  1006. actor.NextMagicObject = MapObject.MouseObject;
  1007. actor.NextMagicDirection = MapControl.MouseDirection();
  1008. if (actor == Hero)
  1009. MapControl.UseMagic(Hero.NextMagic, Hero);
  1010. break;
  1011. }
  1012. }
  1013. private void SendSpellToggle(UserObject Actor, Spell Spell, bool CanUse)
  1014. {
  1015. if (Actor == User)
  1016. Network.Enqueue(new C.SpellToggle { Spell = Spell, CanUse = CanUse });
  1017. else
  1018. Network.Enqueue(new C.SpellToggle { Spell = Spell });
  1019. }
  1020. public void QuitGame()
  1021. {
  1022. if (CMain.Time >= LogTime)
  1023. {
  1024. //If Last Combat < 10 CANCEL
  1025. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExitTip), MirMessageBoxButtons.YesNo);
  1026. messageBox.YesButton.Click += (o, e) => Program.Form.Close();
  1027. messageBox.Show();
  1028. }
  1029. else
  1030. {
  1031. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CannotLeaveGame), (LogTime - CMain.Time) / 1000), ChatType.System);
  1032. }
  1033. }
  1034. public void LogOut()
  1035. {
  1036. if (CMain.Time >= LogTime)
  1037. {
  1038. //If Last Combat < 10 CANCEL
  1039. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LogOutTip), MirMessageBoxButtons.YesNo);
  1040. messageBox.YesButton.Click += (o, e) =>
  1041. {
  1042. Network.Enqueue(new C.LogOut());
  1043. Enabled = false;
  1044. };
  1045. messageBox.Show();
  1046. }
  1047. else
  1048. {
  1049. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CannotLeaveGame), (LogTime - CMain.Time) / 1000), ChatType.System);
  1050. }
  1051. }
  1052. protected internal override void DrawControl()
  1053. {
  1054. if (MapControl != null && !MapControl.IsDisposed)
  1055. MapControl.DrawControl();
  1056. base.DrawControl();
  1057. if (PickedUpGold || (SelectedCell != null && SelectedCell.Item != null))
  1058. {
  1059. int image = PickedUpGold ? 116 : SelectedCell.Item.Image;
  1060. Size imgSize = Libraries.Items.GetTrueSize(image);
  1061. Point p = CMain.MPoint.Add(-imgSize.Width / 2, -imgSize.Height / 2);
  1062. if (p.X + imgSize.Width >= Settings.ScreenWidth)
  1063. p.X = Settings.ScreenWidth - imgSize.Width;
  1064. if (p.Y + imgSize.Height >= Settings.ScreenHeight)
  1065. p.Y = Settings.ScreenHeight - imgSize.Height;
  1066. Libraries.Items.Draw(image, p.X, p.Y);
  1067. }
  1068. for (int i = 0; i < OutputLines.Length; i++)
  1069. OutputLines[i].Draw();
  1070. }
  1071. public override void Process()
  1072. {
  1073. if (MapControl == null || User == null)
  1074. return;
  1075. if (CMain.Time >= MoveTime)
  1076. {
  1077. MoveTime = CMain.Time + 100; //Move Speed
  1078. CanMove = true;
  1079. MapControl.AnimationCount++;
  1080. MapControl.TextureValid = false;
  1081. }
  1082. else
  1083. CanMove = false;
  1084. if (CMain.Time >= CMain.NextPing)
  1085. {
  1086. CMain.NextPing = CMain.Time + 60000;
  1087. Network.Enqueue(new C.KeepAlive() { Time = CMain.Time });
  1088. }
  1089. TimerControl.Process();
  1090. CompassControl.Process();
  1091. RankingDialog.Process();
  1092. MirItemCell cell = MouseControl as MirItemCell;
  1093. if (cell != null && HoverItem != cell.Item && HoverItem != cell.ShadowItem)
  1094. {
  1095. DisposeItemLabel();
  1096. HoverItem = null;
  1097. CreateItemLabel(cell.Item);
  1098. }
  1099. if (ItemLabel != null && !ItemLabel.IsDisposed)
  1100. {
  1101. ItemLabel.BringToFront();
  1102. int x = CMain.MPoint.X + 28, y = CMain.MPoint.Y + 28;
  1103. if (x + ItemLabel.Size.Width > Settings.ScreenWidth)
  1104. x = Settings.ScreenWidth - ItemLabel.Size.Width;
  1105. if (y + ItemLabel.Size.Height > Settings.ScreenHeight)
  1106. y = Settings.ScreenHeight - ItemLabel.Size.Height;
  1107. ItemLabel.Location = new Point(x, y);
  1108. }
  1109. if (MailLabel != null && !MailLabel.IsDisposed)
  1110. {
  1111. MailLabel.BringToFront();
  1112. int x = CMain.MPoint.X + 15, y = CMain.MPoint.Y;
  1113. if (x + MailLabel.Size.Width > Settings.ScreenWidth)
  1114. x = Settings.ScreenWidth - MailLabel.Size.Width;
  1115. if (y + MailLabel.Size.Height > Settings.ScreenHeight)
  1116. y = Settings.ScreenHeight - MailLabel.Size.Height;
  1117. MailLabel.Location = new Point(x, y);
  1118. }
  1119. if (MemoLabel != null && !MemoLabel.IsDisposed)
  1120. {
  1121. MemoLabel.BringToFront();
  1122. int x = CMain.MPoint.X + 15, y = CMain.MPoint.Y;
  1123. if (x + MemoLabel.Size.Width > Settings.ScreenWidth)
  1124. x = Settings.ScreenWidth - MemoLabel.Size.Width;
  1125. if (y + MemoLabel.Size.Height > Settings.ScreenHeight)
  1126. y = Settings.ScreenHeight - MemoLabel.Size.Height;
  1127. MemoLabel.Location = new Point(x, y);
  1128. }
  1129. if (GuildBuffLabel != null && !GuildBuffLabel.IsDisposed)
  1130. {
  1131. GuildBuffLabel.BringToFront();
  1132. int x = CMain.MPoint.X + 15, y = CMain.MPoint.Y;
  1133. if (x + GuildBuffLabel.Size.Width > Settings.ScreenWidth)
  1134. x = Settings.ScreenWidth - GuildBuffLabel.Size.Width;
  1135. if (y + GuildBuffLabel.Size.Height > Settings.ScreenHeight)
  1136. y = Settings.ScreenHeight - GuildBuffLabel.Size.Height;
  1137. GuildBuffLabel.Location = new Point(x, y);
  1138. }
  1139. if (!User.Dead) ShowReviveMessage = false;
  1140. if (ShowReviveMessage && CMain.Time > User.DeadTime && User.CurrentAction == MirAction.Dead)
  1141. {
  1142. ShowReviveMessage = false;
  1143. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DiedTip), MirMessageBoxButtons.YesNo, false);
  1144. messageBox.YesButton.Click += (o, e) =>
  1145. {
  1146. if (User.Dead) Network.Enqueue(new C.TownRevive());
  1147. };
  1148. messageBox.AfterDraw += (o, e) =>
  1149. {
  1150. if (!User.Dead) messageBox.Dispose();
  1151. };
  1152. messageBox.Show();
  1153. }
  1154. BuffsDialog.Process();
  1155. HeroBuffsDialog?.Process();
  1156. MapControl.Process();
  1157. MainDialog.Process();
  1158. InventoryDialog.Process();
  1159. GameShopDialog.Process();
  1160. MiniMapDialog.Process();
  1161. foreach (SkillBarDialog Bar in Scene.SkillBarDialogs)
  1162. Bar.Process();
  1163. foreach (ParticleEngine pe in ParticleEngines)
  1164. pe.Process();
  1165. DialogProcess();
  1166. ProcessOuput();
  1167. UpdateMouseCursor();
  1168. SoundManager.ProcessDelayedSounds();
  1169. }
  1170. public void DialogProcess()
  1171. {
  1172. if (Settings.SkillBar)
  1173. {
  1174. foreach (SkillBarDialog Bar in Scene.SkillBarDialogs)
  1175. Bar.Show();
  1176. }
  1177. else
  1178. {
  1179. foreach (SkillBarDialog Bar in Scene.SkillBarDialogs)
  1180. Bar.Hide();
  1181. }
  1182. for (int i = 0; i < Scene.SkillBarDialogs.Count; i++)
  1183. {
  1184. if (i * 2 > Settings.SkillbarLocation.Length) break;
  1185. if ((Settings.SkillbarLocation[i, 0] > Settings.Resolution - 100) || (Settings.SkillbarLocation[i, 1] > 700))
  1186. continue; //in theory you'd want the y coord to be validated based on resolution, but since client only allows for wider screens and not higher :(
  1187. Scene.SkillBarDialogs[i].Location = new Point(Settings.SkillbarLocation[i, 0], Settings.SkillbarLocation[i, 1]);
  1188. }
  1189. if (Settings.DuraView)
  1190. CharacterDuraPanel.Show();
  1191. else
  1192. CharacterDuraPanel.Hide();
  1193. }
  1194. public override void ProcessPacket(Packet p)
  1195. {
  1196. switch (p.Index)
  1197. {
  1198. case (short)ServerPacketIds.KeepAlive:
  1199. KeepAlive((S.KeepAlive)p);
  1200. break;
  1201. case (short)ServerPacketIds.MapInformation: //MapInfo
  1202. MapInformation((S.MapInformation)p);
  1203. break;
  1204. case (short)ServerPacketIds.NewMapInfo:
  1205. NewMapInfo((S.NewMapInfo)p);
  1206. break;
  1207. case (short)ServerPacketIds.WorldMapSetup:
  1208. WorldMapSetup((S.WorldMapSetupInfo)p);
  1209. break;
  1210. case (short)ServerPacketIds.SearchMapResult:
  1211. SearchMapResult((S.SearchMapResult)p);
  1212. break;
  1213. case (short)ServerPacketIds.UserInformation:
  1214. UserInformation((S.UserInformation)p);
  1215. break;
  1216. case (short)ServerPacketIds.UserSlotsRefresh:
  1217. UserSlotsRefresh((S.UserSlotsRefresh)p);
  1218. break;
  1219. case (short)ServerPacketIds.UserLocation:
  1220. UserLocation((S.UserLocation)p);
  1221. break;
  1222. case (short)ServerPacketIds.ObjectPlayer:
  1223. ObjectPlayer((S.ObjectPlayer)p);
  1224. break;
  1225. case (short)ServerPacketIds.ObjectHero:
  1226. ObjectHero((S.ObjectHero)p);
  1227. break;
  1228. case (short)ServerPacketIds.ObjectRemove:
  1229. ObjectRemove((S.ObjectRemove)p);
  1230. break;
  1231. case (short)ServerPacketIds.ObjectTurn:
  1232. ObjectTurn((S.ObjectTurn)p);
  1233. break;
  1234. case (short)ServerPacketIds.ObjectWalk:
  1235. ObjectWalk((S.ObjectWalk)p);
  1236. break;
  1237. case (short)ServerPacketIds.ObjectRun:
  1238. ObjectRun((S.ObjectRun)p);
  1239. break;
  1240. case (short)ServerPacketIds.Chat:
  1241. ReceiveChat((S.Chat)p);
  1242. break;
  1243. case (short)ServerPacketIds.ObjectChat:
  1244. ObjectChat((S.ObjectChat)p);
  1245. break;
  1246. case (short)ServerPacketIds.MoveItem:
  1247. MoveItem((S.MoveItem)p);
  1248. break;
  1249. case (short)ServerPacketIds.EquipItem:
  1250. EquipItem((S.EquipItem)p);
  1251. break;
  1252. case (short)ServerPacketIds.MergeItem:
  1253. MergeItem((S.MergeItem)p);
  1254. break;
  1255. case (short)ServerPacketIds.RemoveItem:
  1256. RemoveItem((S.RemoveItem)p);
  1257. break;
  1258. case (short)ServerPacketIds.RemoveSlotItem:
  1259. RemoveSlotItem((S.RemoveSlotItem)p);
  1260. break;
  1261. case (short)ServerPacketIds.TakeBackItem:
  1262. TakeBackItem((S.TakeBackItem)p);
  1263. break;
  1264. case (short)ServerPacketIds.StoreItem:
  1265. StoreItem((S.StoreItem)p);
  1266. break;
  1267. case (short)ServerPacketIds.DepositRefineItem:
  1268. DepositRefineItem((S.DepositRefineItem)p);
  1269. break;
  1270. case (short)ServerPacketIds.RetrieveRefineItem:
  1271. RetrieveRefineItem((S.RetrieveRefineItem)p);
  1272. break;
  1273. case (short)ServerPacketIds.RefineCancel:
  1274. RefineCancel((S.RefineCancel)p);
  1275. break;
  1276. case (short)ServerPacketIds.RefineItem:
  1277. RefineItem((S.RefineItem)p);
  1278. break;
  1279. case (short)ServerPacketIds.DepositTradeItem:
  1280. DepositTradeItem((S.DepositTradeItem)p);
  1281. break;
  1282. case (short)ServerPacketIds.RetrieveTradeItem:
  1283. RetrieveTradeItem((S.RetrieveTradeItem)p);
  1284. break;
  1285. case (short)ServerPacketIds.SplitItem:
  1286. SplitItem((S.SplitItem)p);
  1287. break;
  1288. case (short)ServerPacketIds.SplitItem1:
  1289. SplitItem1((S.SplitItem1)p);
  1290. break;
  1291. case (short)ServerPacketIds.UseItem:
  1292. UseItem((S.UseItem)p);
  1293. break;
  1294. case (short)ServerPacketIds.DropItem:
  1295. DropItem((S.DropItem)p);
  1296. break;
  1297. case (short)ServerPacketIds.TakeBackHeroItem:
  1298. TakeBackHeroItem((S.TakeBackHeroItem)p);
  1299. break;
  1300. case (short)ServerPacketIds.TransferHeroItem:
  1301. TransferHeroItem((S.TransferHeroItem)p);
  1302. break;
  1303. case (short)ServerPacketIds.PlayerUpdate:
  1304. PlayerUpdate((S.PlayerUpdate)p);
  1305. break;
  1306. case (short)ServerPacketIds.PlayerInspect:
  1307. PlayerInspect((S.PlayerInspect)p);
  1308. break;
  1309. case (short)ServerPacketIds.LogOutSuccess:
  1310. LogOutSuccess((S.LogOutSuccess)p);
  1311. break;
  1312. case (short)ServerPacketIds.LogOutFailed:
  1313. LogOutFailed((S.LogOutFailed)p);
  1314. break;
  1315. case (short)ServerPacketIds.ReturnToLogin:
  1316. ReturnToLogin((S.ReturnToLogin)p);
  1317. break;
  1318. case (short)ServerPacketIds.TimeOfDay:
  1319. TimeOfDay((S.TimeOfDay)p);
  1320. break;
  1321. case (short)ServerPacketIds.ChangeAMode:
  1322. ChangeAMode((S.ChangeAMode)p);
  1323. break;
  1324. case (short)ServerPacketIds.ChangePMode:
  1325. ChangePMode((S.ChangePMode)p);
  1326. break;
  1327. case (short)ServerPacketIds.ObjectItem:
  1328. ObjectItem((S.ObjectItem)p);
  1329. break;
  1330. case (short)ServerPacketIds.ObjectGold:
  1331. ObjectGold((S.ObjectGold)p);
  1332. break;
  1333. case (short)ServerPacketIds.GainedItem:
  1334. GainedItem((S.GainedItem)p);
  1335. break;
  1336. case (short)ServerPacketIds.GainedGold:
  1337. GainedGold((S.GainedGold)p);
  1338. break;
  1339. case (short)ServerPacketIds.LoseGold:
  1340. LoseGold((S.LoseGold)p);
  1341. break;
  1342. case (short)ServerPacketIds.GainedCredit:
  1343. GainedCredit((S.GainedCredit)p);
  1344. break;
  1345. case (short)ServerPacketIds.LoseCredit:
  1346. LoseCredit((S.LoseCredit)p);
  1347. break;
  1348. case (short)ServerPacketIds.ObjectMonster:
  1349. ObjectMonster((S.ObjectMonster)p);
  1350. break;
  1351. case (short)ServerPacketIds.ObjectAttack:
  1352. ObjectAttack((S.ObjectAttack)p);
  1353. break;
  1354. case (short)ServerPacketIds.Struck:
  1355. Struck((S.Struck)p);
  1356. break;
  1357. case (short)ServerPacketIds.DamageIndicator:
  1358. DamageIndicator((S.DamageIndicator)p);
  1359. break;
  1360. case (short)ServerPacketIds.ObjectStruck:
  1361. ObjectStruck((S.ObjectStruck)p);
  1362. break;
  1363. case (short)ServerPacketIds.DuraChanged:
  1364. DuraChanged((S.DuraChanged)p);
  1365. break;
  1366. case (short)ServerPacketIds.HealthChanged:
  1367. HealthChanged((S.HealthChanged)p);
  1368. break;
  1369. case (short)ServerPacketIds.HeroHealthChanged:
  1370. HeroHealthChanged((S.HeroHealthChanged)p);
  1371. break;
  1372. case (short)ServerPacketIds.DeleteItem:
  1373. DeleteItem((S.DeleteItem)p);
  1374. break;
  1375. case (short)ServerPacketIds.Death:
  1376. Death((S.Death)p);
  1377. break;
  1378. case (short)ServerPacketIds.ObjectDied:
  1379. ObjectDied((S.ObjectDied)p);
  1380. break;
  1381. case (short)ServerPacketIds.ColourChanged:
  1382. ColourChanged((S.ColourChanged)p);
  1383. break;
  1384. case (short)ServerPacketIds.ObjectColourChanged:
  1385. ObjectColourChanged((S.ObjectColourChanged)p);
  1386. break;
  1387. case (short)ServerPacketIds.ObjectGuildNameChanged:
  1388. ObjectGuildNameChanged((S.ObjectGuildNameChanged)p);
  1389. break;
  1390. case (short)ServerPacketIds.GainExperience:
  1391. GainExperience((S.GainExperience)p);
  1392. break;
  1393. case (short)ServerPacketIds.GainHeroExperience:
  1394. GainHeroExperience((S.GainHeroExperience)p);
  1395. break;
  1396. case (short)ServerPacketIds.LevelChanged:
  1397. LevelChanged((S.LevelChanged)p);
  1398. break;
  1399. case (short)ServerPacketIds.HeroLevelChanged:
  1400. HeroLevelChanged((S.HeroLevelChanged)p);
  1401. break;
  1402. case (short)ServerPacketIds.ObjectLeveled:
  1403. ObjectLeveled((S.ObjectLeveled)p);
  1404. break;
  1405. case (short)ServerPacketIds.ObjectHarvest:
  1406. ObjectHarvest((S.ObjectHarvest)p);
  1407. break;
  1408. case (short)ServerPacketIds.ObjectHarvested:
  1409. ObjectHarvested((S.ObjectHarvested)p);
  1410. break;
  1411. case (short)ServerPacketIds.ObjectNpc:
  1412. ObjectNPC((S.ObjectNPC)p);
  1413. break;
  1414. case (short)ServerPacketIds.NPCResponse:
  1415. NPCResponse((S.NPCResponse)p);
  1416. break;
  1417. case (short)ServerPacketIds.ObjectHide:
  1418. ObjectHide((S.ObjectHide)p);
  1419. break;
  1420. case (short)ServerPacketIds.ObjectShow:
  1421. ObjectShow((S.ObjectShow)p);
  1422. break;
  1423. case (short)ServerPacketIds.Poisoned:
  1424. Poisoned((S.Poisoned)p);
  1425. break;
  1426. case (short)ServerPacketIds.ObjectPoisoned:
  1427. ObjectPoisoned((S.ObjectPoisoned)p);
  1428. break;
  1429. case (short)ServerPacketIds.MapChanged:
  1430. MapChanged((S.MapChanged)p);
  1431. break;
  1432. case (short)ServerPacketIds.ObjectTeleportOut:
  1433. ObjectTeleportOut((S.ObjectTeleportOut)p);
  1434. break;
  1435. case (short)ServerPacketIds.ObjectTeleportIn:
  1436. ObjectTeleportIn((S.ObjectTeleportIn)p);
  1437. break;
  1438. case (short)ServerPacketIds.TeleportIn:
  1439. TeleportIn();
  1440. break;
  1441. case (short)ServerPacketIds.NPCGoods:
  1442. NPCGoods((S.NPCGoods)p);
  1443. break;
  1444. case (short)ServerPacketIds.NPCSell:
  1445. NPCSell();
  1446. break;
  1447. case (short)ServerPacketIds.NPCRepair:
  1448. NPCRepair((S.NPCRepair)p);
  1449. break;
  1450. case (short)ServerPacketIds.NPCSRepair:
  1451. NPCSRepair((S.NPCSRepair)p);
  1452. break;
  1453. case (short)ServerPacketIds.NPCRefine:
  1454. NPCRefine((S.NPCRefine)p);
  1455. break;
  1456. case (short)ServerPacketIds.NPCCheckRefine:
  1457. NPCCheckRefine((S.NPCCheckRefine)p);
  1458. break;
  1459. case (short)ServerPacketIds.NPCCollectRefine:
  1460. NPCCollectRefine((S.NPCCollectRefine)p);
  1461. break;
  1462. case (short)ServerPacketIds.NPCReplaceWedRing:
  1463. NPCReplaceWedRing((S.NPCReplaceWedRing)p);
  1464. break;
  1465. case (short)ServerPacketIds.NPCStorage:
  1466. NPCStorage();
  1467. break;
  1468. case (short)ServerPacketIds.StorageUnlockResult:
  1469. StorageUnlockResult((S.StorageUnlockResult)p);
  1470. break;
  1471. case (short)ServerPacketIds.StoragePasswordResult:
  1472. StoragePasswordResult((S.StoragePasswordResult)p);
  1473. break;
  1474. case (short)ServerPacketIds.NPCRequestInput:
  1475. NPCRequestInput((S.NPCRequestInput)p);
  1476. break;
  1477. case (short)ServerPacketIds.SellItem:
  1478. SellItem((S.SellItem)p);
  1479. break;
  1480. case (short)ServerPacketIds.CraftItem:
  1481. CraftItem((S.CraftItem)p);
  1482. break;
  1483. case (short)ServerPacketIds.RepairItem:
  1484. RepairItem((S.RepairItem)p);
  1485. break;
  1486. case (short)ServerPacketIds.ItemRepaired:
  1487. ItemRepaired((S.ItemRepaired)p);
  1488. break;
  1489. case (short)ServerPacketIds.ItemSlotSizeChanged:
  1490. ItemSlotSizeChanged((S.ItemSlotSizeChanged)p);
  1491. break;
  1492. case (short)ServerPacketIds.ItemSealChanged:
  1493. ItemSealChanged((S.ItemSealChanged)p);
  1494. break;
  1495. case (short)ServerPacketIds.NewMagic:
  1496. NewMagic((S.NewMagic)p);
  1497. break;
  1498. case (short)ServerPacketIds.MagicLeveled:
  1499. MagicLeveled((S.MagicLeveled)p);
  1500. break;
  1501. case (short)ServerPacketIds.Magic:
  1502. Magic((S.Magic)p);
  1503. break;
  1504. case (short)ServerPacketIds.MagicDelay:
  1505. MagicDelay((S.MagicDelay)p);
  1506. break;
  1507. case (short)ServerPacketIds.MagicCast:
  1508. MagicCast((S.MagicCast)p);
  1509. break;
  1510. case (short)ServerPacketIds.ObjectMagic:
  1511. ObjectMagic((S.ObjectMagic)p);
  1512. break;
  1513. case (short)ServerPacketIds.ObjectProjectile:
  1514. ObjectProjectile((S.ObjectProjectile)p);
  1515. break;
  1516. case (short)ServerPacketIds.ObjectEffect:
  1517. ObjectEffect((S.ObjectEffect)p);
  1518. break;
  1519. case (short)ServerPacketIds.RangeAttack:
  1520. RangeAttack((S.RangeAttack)p);
  1521. break;
  1522. case (short)ServerPacketIds.Pushed:
  1523. Pushed((S.Pushed)p);
  1524. break;
  1525. case (short)ServerPacketIds.ObjectPushed:
  1526. ObjectPushed((S.ObjectPushed)p);
  1527. break;
  1528. case (short)ServerPacketIds.ObjectName:
  1529. ObjectName((S.ObjectName)p);
  1530. break;
  1531. case (short)ServerPacketIds.UserStorage:
  1532. UserStorage((S.UserStorage)p);
  1533. break;
  1534. case (short)ServerPacketIds.SwitchGroup:
  1535. SwitchGroup((S.SwitchGroup)p);
  1536. break;
  1537. case (short)ServerPacketIds.DeleteGroup:
  1538. DeleteGroup();
  1539. break;
  1540. case (short)ServerPacketIds.DeleteMember:
  1541. DeleteMember((S.DeleteMember)p);
  1542. break;
  1543. case (short)ServerPacketIds.GroupInvite:
  1544. GroupInvite((S.GroupInvite)p);
  1545. break;
  1546. case (short)ServerPacketIds.AddMember:
  1547. AddMember((S.AddMember)p);
  1548. break;
  1549. case (short)ServerPacketIds.GroupMembersMap:
  1550. GroupMembersMap((S.GroupMembersMap)p);
  1551. break;
  1552. case (short)ServerPacketIds.SendMemberLocation:
  1553. SendMemberLocation((S.SendMemberLocation)p);
  1554. break;
  1555. case (short)ServerPacketIds.Revived:
  1556. Revived();
  1557. break;
  1558. case (short)ServerPacketIds.ObjectRevived:
  1559. ObjectRevived((S.ObjectRevived)p);
  1560. break;
  1561. case (short)ServerPacketIds.SpellToggle:
  1562. SpellToggle((S.SpellToggle)p);
  1563. break;
  1564. case (short)ServerPacketIds.ObjectHealth:
  1565. ObjectHealth((S.ObjectHealth)p);
  1566. break;
  1567. case (short)ServerPacketIds.ObjectMana:
  1568. ObjectMana((S.ObjectMana)p);
  1569. break;
  1570. case (short)ServerPacketIds.MapEffect:
  1571. MapEffect((S.MapEffect)p);
  1572. break;
  1573. case (short)ServerPacketIds.AllowObserve:
  1574. AllowObserve = ((S.AllowObserve)p).Allow;
  1575. break;
  1576. case (short)ServerPacketIds.ObjectRangeAttack:
  1577. ObjectRangeAttack((S.ObjectRangeAttack)p);
  1578. break;
  1579. case (short)ServerPacketIds.AddBuff:
  1580. AddBuff((S.AddBuff)p);
  1581. break;
  1582. case (short)ServerPacketIds.RemoveBuff:
  1583. RemoveBuff((S.RemoveBuff)p);
  1584. break;
  1585. case (short)ServerPacketIds.PauseBuff:
  1586. PauseBuff((S.PauseBuff)p);
  1587. break;
  1588. case (short)ServerPacketIds.ObjectHidden:
  1589. ObjectHidden((S.ObjectHidden)p);
  1590. break;
  1591. case (short)ServerPacketIds.RefreshItem:
  1592. RefreshItem((S.RefreshItem)p);
  1593. break;
  1594. case (short)ServerPacketIds.ObjectSpell:
  1595. ObjectSpell((S.ObjectSpell)p);
  1596. break;
  1597. case (short)ServerPacketIds.UserDash:
  1598. UserDash((S.UserDash)p);
  1599. break;
  1600. case (short)ServerPacketIds.ObjectDash:
  1601. ObjectDash((S.ObjectDash)p);
  1602. break;
  1603. case (short)ServerPacketIds.UserDashFail:
  1604. UserDashFail((S.UserDashFail)p);
  1605. break;
  1606. case (short)ServerPacketIds.ObjectDashFail:
  1607. ObjectDashFail((S.ObjectDashFail)p);
  1608. break;
  1609. case (short)ServerPacketIds.NPCConsign:
  1610. NPCConsign();
  1611. break;
  1612. case (short)ServerPacketIds.NPCMarket:
  1613. NPCMarket((S.NPCMarket)p);
  1614. break;
  1615. case (short)ServerPacketIds.NPCMarketPage:
  1616. NPCMarketPage((S.NPCMarketPage)p);
  1617. break;
  1618. case (short)ServerPacketIds.ConsignItem:
  1619. ConsignItem((S.ConsignItem)p);
  1620. break;
  1621. case (short)ServerPacketIds.MarketFail:
  1622. MarketFail((S.MarketFail)p);
  1623. break;
  1624. case (short)ServerPacketIds.MarketSuccess:
  1625. MarketSuccess((S.MarketSuccess)p);
  1626. break;
  1627. case (short)ServerPacketIds.ObjectSitDown:
  1628. ObjectSitDown((S.ObjectSitDown)p);
  1629. break;
  1630. case (short)ServerPacketIds.InTrapRock:
  1631. S.InTrapRock packetdata = (S.InTrapRock)p;
  1632. User.InTrapRock = packetdata.Trapped;
  1633. break;
  1634. case (short)ServerPacketIds.RemoveMagic:
  1635. RemoveMagic((S.RemoveMagic)p);
  1636. break;
  1637. case (short)ServerPacketIds.BaseStatsInfo:
  1638. BaseStatsInfo((S.BaseStatsInfo)p);
  1639. break;
  1640. case (short)ServerPacketIds.HeroBaseStatsInfo:
  1641. HeroBaseStatsInfo((S.HeroBaseStatsInfo)p);
  1642. break;
  1643. case (short)ServerPacketIds.UserName:
  1644. UserName((S.UserName)p);
  1645. break;
  1646. case (short)ServerPacketIds.ChatItemStats:
  1647. ChatItemStats((S.ChatItemStats)p);
  1648. break;
  1649. case (short)ServerPacketIds.GuildInvite:
  1650. GuildInvite((S.GuildInvite)p);
  1651. break;
  1652. case (short)ServerPacketIds.GuildMemberChange:
  1653. GuildMemberChange((S.GuildMemberChange)p);
  1654. break;
  1655. case (short)ServerPacketIds.GuildNoticeChange:
  1656. GuildNoticeChange((S.GuildNoticeChange)p);
  1657. break;
  1658. case (short)ServerPacketIds.GuildStatus:
  1659. GuildStatus((S.GuildStatus)p);
  1660. break;
  1661. case (short)ServerPacketIds.GuildExpGain:
  1662. GuildExpGain((S.GuildExpGain)p);
  1663. break;
  1664. case (short)ServerPacketIds.GuildNameRequest:
  1665. GuildNameRequest((S.GuildNameRequest)p);
  1666. break;
  1667. case (short)ServerPacketIds.GuildStorageGoldChange:
  1668. GuildStorageGoldChange((S.GuildStorageGoldChange)p);
  1669. break;
  1670. case (short)ServerPacketIds.GuildStorageItemChange:
  1671. GuildStorageItemChange((S.GuildStorageItemChange)p);
  1672. break;
  1673. case (short)ServerPacketIds.GuildStorageList:
  1674. GuildStorageList((S.GuildStorageList)p);
  1675. break;
  1676. case (short)ServerPacketIds.GuildRequestWar:
  1677. GuildRequestWar((S.GuildRequestWar)p);
  1678. break;
  1679. case (short)ServerPacketIds.HeroCreateRequest:
  1680. HeroCreateRequest((S.HeroCreateRequest)p);
  1681. break;
  1682. case (short)ServerPacketIds.NewHero:
  1683. NewHero((S.NewHero)p);
  1684. break;
  1685. case (short)ServerPacketIds.HeroInformation:
  1686. HeroInformation((S.HeroInformation)p);
  1687. break;
  1688. case (short)ServerPacketIds.UpdateHeroSpawnState:
  1689. UpdateHeroSpawnState((S.UpdateHeroSpawnState)p);
  1690. break;
  1691. case (short)ServerPacketIds.UnlockHeroAutoPot:
  1692. UnlockHeroAutoPot(true);
  1693. break;
  1694. case (short)ServerPacketIds.SetAutoPotValue:
  1695. SetAutoPotValue((S.SetAutoPotValue)p);
  1696. break;
  1697. case (short)ServerPacketIds.SetHeroBehaviour:
  1698. SetHeroBehaviour((S.SetHeroBehaviour)p);
  1699. break;
  1700. case (short)ServerPacketIds.SetAutoPotItem:
  1701. SetAutoPotItem((S.SetAutoPotItem)p);
  1702. break;
  1703. case (short)ServerPacketIds.ManageHeroes:
  1704. ManageHeroes((S.ManageHeroes)p);
  1705. break;
  1706. case (short)ServerPacketIds.ChangeHero:
  1707. ChangeHero((S.ChangeHero)p);
  1708. break;
  1709. case (short)ServerPacketIds.DefaultNPC:
  1710. DefaultNPC((S.DefaultNPC)p);
  1711. break;
  1712. case (short)ServerPacketIds.NPCUpdate:
  1713. NPCUpdate((S.NPCUpdate)p);
  1714. break;
  1715. case (short)ServerPacketIds.NPCImageUpdate:
  1716. NPCImageUpdate((S.NPCImageUpdate)p);
  1717. break;
  1718. case (short)ServerPacketIds.MarriageRequest:
  1719. MarriageRequest((S.MarriageRequest)p);
  1720. break;
  1721. case (short)ServerPacketIds.DivorceRequest:
  1722. DivorceRequest((S.DivorceRequest)p);
  1723. break;
  1724. case (short)ServerPacketIds.MentorRequest:
  1725. MentorRequest((S.MentorRequest)p);
  1726. break;
  1727. case (short)ServerPacketIds.TradeRequest:
  1728. TradeRequest((S.TradeRequest)p);
  1729. break;
  1730. case (short)ServerPacketIds.TradeAccept:
  1731. TradeAccept((S.TradeAccept)p);
  1732. break;
  1733. case (short)ServerPacketIds.TradeGold:
  1734. TradeGold((S.TradeGold)p);
  1735. break;
  1736. case (short)ServerPacketIds.TradeItem:
  1737. TradeItem((S.TradeItem)p);
  1738. break;
  1739. case (short)ServerPacketIds.TradeConfirm:
  1740. TradeConfirm();
  1741. break;
  1742. case (short)ServerPacketIds.TradeCancel:
  1743. TradeCancel((S.TradeCancel)p);
  1744. break;
  1745. case (short)ServerPacketIds.MountUpdate:
  1746. MountUpdate((S.MountUpdate)p);
  1747. break;
  1748. case (short)ServerPacketIds.TransformUpdate:
  1749. TransformUpdate((S.TransformUpdate)p);
  1750. break;
  1751. case (short)ServerPacketIds.EquipSlotItem:
  1752. EquipSlotItem((S.EquipSlotItem)p);
  1753. break;
  1754. case (short)ServerPacketIds.FishingUpdate:
  1755. FishingUpdate((S.FishingUpdate)p);
  1756. break;
  1757. case (short)ServerPacketIds.ChangeQuest:
  1758. ChangeQuest((S.ChangeQuest)p);
  1759. break;
  1760. case (short)ServerPacketIds.CompleteQuest:
  1761. CompleteQuest((S.CompleteQuest)p);
  1762. break;
  1763. case (short)ServerPacketIds.ShareQuest:
  1764. ShareQuest((S.ShareQuest)p);
  1765. break;
  1766. case (short)ServerPacketIds.GainedQuestItem:
  1767. GainedQuestItem((S.GainedQuestItem)p);
  1768. break;
  1769. case (short)ServerPacketIds.DeleteQuestItem:
  1770. DeleteQuestItem((S.DeleteQuestItem)p);
  1771. break;
  1772. case (short)ServerPacketIds.CancelReincarnation:
  1773. User.ReincarnationStopTime = 0;
  1774. break;
  1775. case (short)ServerPacketIds.RequestReincarnation:
  1776. if (!User.Dead) return;
  1777. RequestReincarnation();
  1778. break;
  1779. case (short)ServerPacketIds.UserBackStep:
  1780. UserBackStep((S.UserBackStep)p);
  1781. break;
  1782. case (short)ServerPacketIds.ObjectBackStep:
  1783. ObjectBackStep((S.ObjectBackStep)p);
  1784. break;
  1785. case (short)ServerPacketIds.UserDashAttack:
  1786. UserDashAttack((S.UserDashAttack)p);
  1787. break;
  1788. case (short)ServerPacketIds.ObjectDashAttack:
  1789. ObjectDashAttack((S.ObjectDashAttack)p);
  1790. break;
  1791. case (short)ServerPacketIds.UserAttackMove://Warrior Skill - SlashingBurst
  1792. UserAttackMove((S.UserAttackMove)p);
  1793. break;
  1794. case (short)ServerPacketIds.CombineItem:
  1795. CombineItem((S.CombineItem)p);
  1796. break;
  1797. case (short)ServerPacketIds.ItemUpgraded:
  1798. ItemUpgraded((S.ItemUpgraded)p);
  1799. break;
  1800. case (short)ServerPacketIds.SetConcentration:
  1801. SetConcentration((S.SetConcentration)p);
  1802. break;
  1803. case (short)ServerPacketIds.SetElemental:
  1804. SetElemental((S.SetElemental)p);
  1805. break;
  1806. case (short)ServerPacketIds.RemoveDelayedExplosion:
  1807. RemoveDelayedExplosion((S.RemoveDelayedExplosion)p);
  1808. break;
  1809. case (short)ServerPacketIds.ObjectDeco:
  1810. ObjectDeco((S.ObjectDeco)p);
  1811. break;
  1812. case (short)ServerPacketIds.ObjectSneaking:
  1813. ObjectSneaking((S.ObjectSneaking)p);
  1814. break;
  1815. case (short)ServerPacketIds.ObjectLevelEffects:
  1816. ObjectLevelEffects((S.ObjectLevelEffects)p);
  1817. break;
  1818. case (short)ServerPacketIds.SetBindingShot:
  1819. SetBindingShot((S.SetBindingShot)p);
  1820. break;
  1821. case (short)ServerPacketIds.SendOutputMessage:
  1822. SendOutputMessage((S.SendOutputMessage)p);
  1823. break;
  1824. case (short)ServerPacketIds.NPCAwakening:
  1825. NPCAwakening();
  1826. break;
  1827. case (short)ServerPacketIds.NPCDisassemble:
  1828. NPCDisassemble();
  1829. break;
  1830. case (short)ServerPacketIds.NPCDowngrade:
  1831. NPCDowngrade();
  1832. break;
  1833. case (short)ServerPacketIds.NPCReset:
  1834. NPCReset();
  1835. break;
  1836. case (short)ServerPacketIds.AwakeningNeedMaterials:
  1837. AwakeningNeedMaterials((S.AwakeningNeedMaterials)p);
  1838. break;
  1839. case (short)ServerPacketIds.AwakeningLockedItem:
  1840. AwakeningLockedItem((S.AwakeningLockedItem)p);
  1841. break;
  1842. case (short)ServerPacketIds.Awakening:
  1843. Awakening((S.Awakening)p);
  1844. break;
  1845. case (short)ServerPacketIds.ReceiveMail:
  1846. ReceiveMail((S.ReceiveMail)p);
  1847. break;
  1848. case (short)ServerPacketIds.MailLockedItem:
  1849. MailLockedItem((S.MailLockedItem)p);
  1850. break;
  1851. case (short)ServerPacketIds.MailSent:
  1852. MailSent((S.MailSent)p);
  1853. break;
  1854. case (short)ServerPacketIds.MailSendRequest:
  1855. MailSendRequest((S.MailSendRequest)p);
  1856. break;
  1857. case (short)ServerPacketIds.ParcelCollected:
  1858. ParcelCollected((S.ParcelCollected)p);
  1859. break;
  1860. case (short)ServerPacketIds.MailCost:
  1861. MailCost((S.MailCost)p);
  1862. break;
  1863. case (short)ServerPacketIds.ResizeInventory:
  1864. ResizeInventory((S.ResizeInventory)p);
  1865. break;
  1866. case (short)ServerPacketIds.ResizeStorage:
  1867. ResizeStorage((S.ResizeStorage)p);
  1868. break;
  1869. case (short)ServerPacketIds.NewIntelligentCreature:
  1870. NewIntelligentCreature((S.NewIntelligentCreature)p);
  1871. break;
  1872. case (short)ServerPacketIds.UpdateIntelligentCreatureList:
  1873. UpdateIntelligentCreatureList((S.UpdateIntelligentCreatureList)p);
  1874. break;
  1875. case (short)ServerPacketIds.IntelligentCreatureEnableRename:
  1876. IntelligentCreatureEnableRename((S.IntelligentCreatureEnableRename)p);
  1877. break;
  1878. case (short)ServerPacketIds.IntelligentCreaturePickup:
  1879. IntelligentCreaturePickup((S.IntelligentCreaturePickup)p);
  1880. break;
  1881. case (short)ServerPacketIds.NPCPearlGoods:
  1882. NPCPearlGoods((S.NPCPearlGoods)p);
  1883. break;
  1884. case (short)ServerPacketIds.FriendUpdate:
  1885. FriendUpdate((S.FriendUpdate)p);
  1886. break;
  1887. case (short)ServerPacketIds.LoverUpdate:
  1888. LoverUpdate((S.LoverUpdate)p);
  1889. break;
  1890. case (short)ServerPacketIds.MentorUpdate:
  1891. MentorUpdate((S.MentorUpdate)p);
  1892. break;
  1893. case (short)ServerPacketIds.GuildBuffList:
  1894. GuildBuffList((S.GuildBuffList)p);
  1895. break;
  1896. case (short)ServerPacketIds.GameShopInfo:
  1897. GameShopUpdate((S.GameShopInfo)p);
  1898. break;
  1899. case (short)ServerPacketIds.GameShopStock:
  1900. GameShopStock((S.GameShopStock)p);
  1901. break;
  1902. case (short)ServerPacketIds.Rankings:
  1903. Rankings((S.Rankings)p);
  1904. break;
  1905. case (short)ServerPacketIds.Opendoor:
  1906. Opendoor((S.Opendoor)p);
  1907. break;
  1908. case (short)ServerPacketIds.GetRentedItems:
  1909. RentedItems((S.GetRentedItems)p);
  1910. break;
  1911. case (short)ServerPacketIds.ItemRentalRequest:
  1912. ItemRentalRequest((S.ItemRentalRequest)p);
  1913. break;
  1914. case (short)ServerPacketIds.ItemRentalFee:
  1915. ItemRentalFee((S.ItemRentalFee)p);
  1916. break;
  1917. case (short)ServerPacketIds.ItemRentalPeriod:
  1918. ItemRentalPeriod((S.ItemRentalPeriod)p);
  1919. break;
  1920. case (short)ServerPacketIds.DepositRentalItem:
  1921. DepositRentalItem((S.DepositRentalItem)p);
  1922. break;
  1923. case (short)ServerPacketIds.RetrieveRentalItem:
  1924. RetrieveRentalItem((S.RetrieveRentalItem)p);
  1925. break;
  1926. case (short)ServerPacketIds.UpdateRentalItem:
  1927. UpdateRentalItem((S.UpdateRentalItem)p);
  1928. break;
  1929. case (short)ServerPacketIds.CancelItemRental:
  1930. CancelItemRental((S.CancelItemRental)p);
  1931. break;
  1932. case (short)ServerPacketIds.ItemRentalLock:
  1933. ItemRentalLock((S.ItemRentalLock)p);
  1934. break;
  1935. case (short)ServerPacketIds.ItemRentalPartnerLock:
  1936. ItemRentalPartnerLock((S.ItemRentalPartnerLock)p);
  1937. break;
  1938. case (short)ServerPacketIds.CanConfirmItemRental:
  1939. CanConfirmItemRental((S.CanConfirmItemRental)p);
  1940. break;
  1941. case (short)ServerPacketIds.ConfirmItemRental:
  1942. ConfirmItemRental((S.ConfirmItemRental)p);
  1943. break;
  1944. case (short)ServerPacketIds.OpenBrowser:
  1945. OpenBrowser((S.OpenBrowser)p);
  1946. break;
  1947. case (short)ServerPacketIds.PlaySound:
  1948. PlaySound((S.PlaySound)p);
  1949. break;
  1950. case (short)ServerPacketIds.SetTimer:
  1951. SetTimer((S.SetTimer)p);
  1952. break;
  1953. case (short)ServerPacketIds.ExpireTimer:
  1954. ExpireTimer((S.ExpireTimer)p);
  1955. break;
  1956. case (short)ServerPacketIds.UpdateNotice:
  1957. ShowNotice((S.UpdateNotice)p);
  1958. break;
  1959. case (short)ServerPacketIds.Roll:
  1960. Roll((S.Roll)p);
  1961. break;
  1962. case (short)ServerPacketIds.SetCompass:
  1963. SetCompass((S.SetCompass)p);
  1964. break;
  1965. case (short)ServerPacketIds.GuildTerritoryPage:
  1966. GuildTerritoryPage((S.GuildTerritoryPage)p);
  1967. break;
  1968. case (short)ServerPacketIds.NewMonsterInfo:
  1969. NewMonsterInfo((S.NewMonsterInfo)p);
  1970. break;
  1971. case (short)ServerPacketIds.NewNPCInfo:
  1972. NewNPCInfo((S.NewNPCInfo)p);
  1973. break;
  1974. default:
  1975. base.ProcessPacket(p);
  1976. break;
  1977. }
  1978. }
  1979. private void KeepAlive(S.KeepAlive p)
  1980. {
  1981. if (p.Time == 0) return;
  1982. CMain.PingTime = (CMain.Time - p.Time);
  1983. }
  1984. private void MapInformation(S.MapInformation p)
  1985. {
  1986. if (MapControl != null && !MapControl.IsDisposed)
  1987. MapControl.Dispose();
  1988. MapControl = new MapControl
  1989. {
  1990. Index = p.MapIndex,
  1991. FileName = Path.Combine(Settings.MapPath, p.FileName + ".map"),
  1992. Title = p.Title,
  1993. MiniMap = p.MiniMap,
  1994. BigMap = p.BigMap,
  1995. Lights = p.Lights,
  1996. Lightning = p.Lightning,
  1997. Fire = p.Fire,
  1998. MapDarkLight = p.MapDarkLight,
  1999. Music = p.Music
  2000. };
  2001. MapControl.Weather = p.WeatherParticles;
  2002. MapControl.LoadMap();
  2003. InsertControl(0, MapControl);
  2004. }
  2005. private void WorldMapSetup(S.WorldMapSetupInfo info)
  2006. {
  2007. BigMapDialog.WorldMapSetup(info.Setup);
  2008. TeleportToNPCCost = info.TeleportToNPCCost;
  2009. }
  2010. private void NewMapInfo(S.NewMapInfo info)
  2011. {
  2012. BigMapRecord newRecord = new BigMapRecord() { Index = info.MapIndex, MapInfo = info.Info };
  2013. CreateBigMapButtons(newRecord);
  2014. MapInfoList.Add(info.MapIndex, newRecord);
  2015. }
  2016. private void CreateBigMapButtons(BigMapRecord record)
  2017. {
  2018. record.MovementButtons.Clear();
  2019. record.NPCButtons.Clear();
  2020. foreach (ClientMovementInfo mInfo in record.MapInfo.Movements)
  2021. {
  2022. MirButton button = new MirButton()
  2023. {
  2024. Library = Libraries.MapLinkIcon,
  2025. Index = mInfo.Icon,
  2026. PressedIndex = mInfo.Icon,
  2027. Sound = SoundList.ButtonA,
  2028. Parent = BigMapDialog.ViewPort,
  2029. Location = new Point(20, 38),
  2030. Hint = mInfo.Title,
  2031. Visible = false
  2032. };
  2033. button.MouseEnter += (o, e) =>
  2034. {
  2035. BigMapDialog.MouseLocation = mInfo.Location;
  2036. };
  2037. button.Click += (o, e) =>
  2038. {
  2039. BigMapDialog.SetTargetMap(mInfo.Destination);
  2040. };
  2041. record.MovementButtons.Add(mInfo, button);
  2042. }
  2043. foreach (ClientNPCInfo npcInfo in record.MapInfo.NPCs)
  2044. {
  2045. BigMapNPCRow row = new BigMapNPCRow(npcInfo) { Parent = BigMapDialog };
  2046. record.NPCButtons.Add(row);
  2047. }
  2048. }
  2049. private void RecreateBigMapButtons()
  2050. {
  2051. foreach (var record in MapInfoList.Values)
  2052. CreateBigMapButtons(record);
  2053. }
  2054. private void SearchMapResult(S.SearchMapResult info)
  2055. {
  2056. if (info.MapIndex == -1 && info.NPCIndex == 0)
  2057. {
  2058. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NothingFound), MirMessageBoxButtons.OK);
  2059. messageBox.OKButton.Click += (o, a) => { BigMapDialog.SearchTextBox.SetFocus(); };
  2060. messageBox.Show();
  2061. return;
  2062. }
  2063. BigMapDialog.SetTargetMap(info.MapIndex);
  2064. BigMapDialog.SetTargetNPC(info.NPCIndex);
  2065. }
  2066. private void UserInformation(S.UserInformation p)
  2067. {
  2068. User = new UserObject(p.ObjectID);
  2069. User.Load(p);
  2070. MainDialog.PModeLabel.Visible = User.Class == MirClass.Wizard || User.Class == MirClass.Taoist;
  2071. HasHero = p.HasHero;
  2072. HeroBehaviourPanel.UpdateBehaviour(p.HeroBehaviour);
  2073. Gold = p.Gold;
  2074. Credit = p.Credit;
  2075. CharacterDialog = new CharacterDialog(MirGridType.Equipment, User) { Parent = this, Visible = false };
  2076. InventoryDialog.RefreshInventory();
  2077. foreach (SkillBarDialog Bar in SkillBarDialogs)
  2078. Bar.Update();
  2079. AllowObserve = p.AllowObserve;
  2080. Observing = p.Observer;
  2081. }
  2082. private void UserSlotsRefresh(S.UserSlotsRefresh p)
  2083. {
  2084. User.SetSlots(p);
  2085. }
  2086. private void UserLocation(S.UserLocation p)
  2087. {
  2088. MapControl.NextAction = 0;
  2089. if (User.CurrentLocation == p.Location && User.Direction == p.Direction) return;
  2090. MapControl.RemoveObject(User);
  2091. User.CurrentLocation = p.Location;
  2092. User.MapLocation = p.Location;
  2093. MapControl.AddObject(User);
  2094. MapControl.FloorValid = false;
  2095. MapControl.InputDelay = CMain.Time + 400;
  2096. if (User.Dead) return;
  2097. User.ClearMagic();
  2098. User.QueuedAction = null;
  2099. for (int i = User.ActionFeed.Count - 1; i >= 0; i--)
  2100. {
  2101. if (User.ActionFeed[i].Action == MirAction.Pushed) continue;
  2102. User.ActionFeed.RemoveAt(i);
  2103. }
  2104. User.SetAction();
  2105. }
  2106. private void ReceiveChat(S.Chat p)
  2107. {
  2108. ChatDialog.ReceiveChat(p.Message, p.Type);
  2109. }
  2110. private void ObjectPlayer(S.ObjectPlayer p)
  2111. {
  2112. PlayerObject player = new PlayerObject(p.ObjectID);
  2113. player.Load(p);
  2114. }
  2115. private void ObjectHero(S.ObjectHero p)
  2116. {
  2117. HeroObject hero = new HeroObject(p.ObjectID);
  2118. hero.Load(p);
  2119. if (p.ObjectID == Hero?.ObjectID)
  2120. HeroObject = hero;
  2121. }
  2122. private void ObjectRemove(S.ObjectRemove p)
  2123. {
  2124. if (p.ObjectID == User.ObjectID) return;
  2125. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2126. ob.Remove();
  2127. }
  2128. private void ObjectTurn(S.ObjectTurn p)
  2129. {
  2130. if (p.ObjectID == User.ObjectID && !Observing) return;
  2131. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2132. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Standing, Direction = p.Direction, Location = p.Location });
  2133. }
  2134. private void ObjectWalk(S.ObjectWalk p)
  2135. {
  2136. if (p.ObjectID == User.ObjectID && !Observing) return;
  2137. if (p.ObjectID == Hero?.ObjectID)
  2138. Hero.CurrentLocation = p.Location;
  2139. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2140. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Walking, Direction = p.Direction, Location = p.Location });
  2141. }
  2142. private void ObjectRun(S.ObjectRun p)
  2143. {
  2144. if (p.ObjectID == User.ObjectID && !Observing) return;
  2145. if (p.ObjectID == Hero?.ObjectID)
  2146. Hero.CurrentLocation = p.Location;
  2147. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2148. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Running, Direction = p.Direction, Location = p.Location });
  2149. }
  2150. private void ObjectChat(S.ObjectChat p)
  2151. {
  2152. ChatDialog.ReceiveChat(p.Text, p.Type);
  2153. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2154. ob.Chat(RegexFunctions.CleanChatString(p.Text));
  2155. }
  2156. private void NewMonsterInfo(S.NewMonsterInfo info)
  2157. {
  2158. GameScene.MonsterInfoList.RemoveAll(x => x.Index == info.Info.Index);
  2159. GameScene.MonsterInfoList.Add(info.Info);
  2160. GameScene.OnMonsterInfoReceived(info.Info.Index);
  2161. }
  2162. private void NewNPCInfo(S.NewNPCInfo info)
  2163. {
  2164. GameScene.NPCInfoList.RemoveAll(x => x.Index == info.Info.Index);
  2165. GameScene.NPCInfoList.Add(info.Info);
  2166. GameScene.OnNPCInfoReceived(info.Info.Index);
  2167. }
  2168. private void MoveItem(S.MoveItem p)
  2169. {
  2170. MirItemCell toCell, fromCell;
  2171. switch (p.Grid)
  2172. {
  2173. case MirGridType.Inventory:
  2174. fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  2175. break;
  2176. case MirGridType.Storage:
  2177. fromCell = StorageDialog.Grid[p.From];
  2178. break;
  2179. case MirGridType.Trade:
  2180. fromCell = TradeDialog.Grid[p.From];
  2181. break;
  2182. case MirGridType.Refine:
  2183. fromCell = RefineDialog.Grid[p.From];
  2184. break;
  2185. case MirGridType.HeroInventory:
  2186. fromCell = p.From < User.HeroBeltIdx ? HeroBeltDialog.Grid[p.From] : HeroInventoryDialog.Grid[p.From - User.HeroBeltIdx];
  2187. break;
  2188. default:
  2189. return;
  2190. }
  2191. switch (p.Grid)
  2192. {
  2193. case MirGridType.Inventory:
  2194. toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2195. break;
  2196. case MirGridType.Storage:
  2197. toCell = StorageDialog.Grid[p.To];
  2198. break;
  2199. case MirGridType.Trade:
  2200. toCell = TradeDialog.Grid[p.To];
  2201. break;
  2202. case MirGridType.Refine:
  2203. toCell = RefineDialog.Grid[p.To];
  2204. break;
  2205. case MirGridType.HeroInventory:
  2206. toCell = p.To < User.HeroBeltIdx ? HeroBeltDialog.Grid[p.To] : HeroInventoryDialog.Grid[p.To - User.HeroBeltIdx];
  2207. break;
  2208. default:
  2209. return;
  2210. }
  2211. if (toCell == null || fromCell == null) return;
  2212. toCell.Locked = false;
  2213. fromCell.Locked = false;
  2214. if (p.Grid == MirGridType.Trade)
  2215. TradeDialog.ChangeLockState(false);
  2216. if (!p.Success) return;
  2217. UserItem i = fromCell.Item;
  2218. fromCell.Item = toCell.Item;
  2219. toCell.Item = i;
  2220. User.RefreshStats();
  2221. CharacterDuraPanel.GetCharacterDura();
  2222. }
  2223. private void EquipItem(S.EquipItem p)
  2224. {
  2225. MirItemCell fromCell, toCell;
  2226. switch (p.Grid)
  2227. {
  2228. case MirGridType.HeroInventory:
  2229. toCell = HeroDialog.Grid[p.To];
  2230. break;
  2231. default:
  2232. toCell = CharacterDialog.Grid[p.To];
  2233. break;
  2234. }
  2235. switch (p.Grid)
  2236. {
  2237. case MirGridType.Inventory:
  2238. fromCell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2239. break;
  2240. case MirGridType.Storage:
  2241. fromCell = StorageDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2242. break;
  2243. case MirGridType.HeroInventory:
  2244. fromCell = HeroInventoryDialog.GetCell(p.UniqueID) ?? HeroBeltDialog.GetCell(p.UniqueID);
  2245. break;
  2246. default:
  2247. return;
  2248. }
  2249. if (toCell == null || fromCell == null) return;
  2250. toCell.Locked = false;
  2251. fromCell.Locked = false;
  2252. if (!p.Success) return;
  2253. UserItem i = fromCell.Item;
  2254. fromCell.Item = toCell.Item;
  2255. toCell.Item = i;
  2256. CharacterDuraPanel.UpdateCharacterDura(i);
  2257. if (p.Grid == MirGridType.HeroInventory)
  2258. Hero.RefreshStats();
  2259. else
  2260. User.RefreshStats();
  2261. }
  2262. private void EquipSlotItem(S.EquipSlotItem p)
  2263. {
  2264. MirItemCell fromCell;
  2265. MirItemCell toCell;
  2266. switch (p.GridTo)
  2267. {
  2268. case MirGridType.Socket:
  2269. toCell = SocketDialog.Grid[p.To];
  2270. break;
  2271. case MirGridType.Mount:
  2272. toCell = MountDialog.Grid[p.To];
  2273. break;
  2274. case MirGridType.Fishing:
  2275. toCell = FishingDialog.Grid[p.To];
  2276. break;
  2277. default:
  2278. return;
  2279. }
  2280. switch (p.Grid)
  2281. {
  2282. case MirGridType.Inventory:
  2283. fromCell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2284. break;
  2285. case MirGridType.Storage:
  2286. fromCell = StorageDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2287. break;
  2288. default:
  2289. return;
  2290. }
  2291. //if (toCell == null || fromCell == null) return;
  2292. toCell.Locked = false;
  2293. fromCell.Locked = false;
  2294. if (!p.Success) return;
  2295. UserItem i = fromCell.Item;
  2296. fromCell.Item = null;
  2297. toCell.Item = i;
  2298. User.RefreshStats();
  2299. }
  2300. private void CombineItem(S.CombineItem p)
  2301. {
  2302. MirItemCell fromCell = null;
  2303. MirItemCell toCell = null;
  2304. switch (p.Grid)
  2305. {
  2306. case MirGridType.Inventory:
  2307. fromCell = InventoryDialog.GetCell(p.IDFrom) ?? BeltDialog.GetCell(p.IDFrom);
  2308. toCell = InventoryDialog.GetCell(p.IDTo) ?? BeltDialog.GetCell(p.IDTo);
  2309. break;
  2310. case MirGridType.HeroInventory:
  2311. fromCell = HeroInventoryDialog.GetCell(p.IDFrom) ?? HeroBeltDialog.GetCell(p.IDFrom);
  2312. toCell = HeroInventoryDialog.GetCell(p.IDTo) ?? HeroBeltDialog.GetCell(p.IDTo);
  2313. break;
  2314. }
  2315. if (toCell == null || fromCell == null) return;
  2316. toCell.Locked = false;
  2317. fromCell.Locked = false;
  2318. if (p.Destroy) toCell.Item = null;
  2319. if (!p.Success) return;
  2320. if (fromCell.Item.Count > 1)
  2321. fromCell.Item.Count--;
  2322. else
  2323. fromCell.Item = null;
  2324. switch (p.Grid)
  2325. {
  2326. case MirGridType.Inventory:
  2327. User.RefreshStats();
  2328. break;
  2329. case MirGridType.HeroInventory:
  2330. Hero.RefreshStats();
  2331. break;
  2332. }
  2333. }
  2334. private void MergeItem(S.MergeItem p)
  2335. {
  2336. MirItemCell toCell, fromCell;
  2337. switch (p.GridFrom)
  2338. {
  2339. case MirGridType.Inventory:
  2340. fromCell = InventoryDialog.GetCell(p.IDFrom) ?? BeltDialog.GetCell(p.IDFrom);
  2341. break;
  2342. case MirGridType.Storage:
  2343. fromCell = StorageDialog.GetCell(p.IDFrom);
  2344. break;
  2345. case MirGridType.Equipment:
  2346. fromCell = CharacterDialog.GetCell(p.IDFrom);
  2347. break;
  2348. case MirGridType.Trade:
  2349. fromCell = TradeDialog.GetCell(p.IDFrom);
  2350. break;
  2351. case MirGridType.Fishing:
  2352. fromCell = FishingDialog.GetCell(p.IDFrom);
  2353. break;
  2354. case MirGridType.HeroEquipment:
  2355. fromCell = HeroDialog.GetCell(p.IDFrom);
  2356. break;
  2357. case MirGridType.HeroInventory:
  2358. fromCell = HeroInventoryDialog.GetCell(p.IDFrom) ?? HeroBeltDialog.GetCell(p.IDFrom);
  2359. break;
  2360. default:
  2361. return;
  2362. }
  2363. switch (p.GridTo)
  2364. {
  2365. case MirGridType.Inventory:
  2366. toCell = InventoryDialog.GetCell(p.IDTo) ?? BeltDialog.GetCell(p.IDTo);
  2367. break;
  2368. case MirGridType.Storage:
  2369. toCell = StorageDialog.GetCell(p.IDTo);
  2370. break;
  2371. case MirGridType.Equipment:
  2372. toCell = CharacterDialog.GetCell(p.IDTo);
  2373. break;
  2374. case MirGridType.Trade:
  2375. toCell = TradeDialog.GetCell(p.IDTo);
  2376. break;
  2377. case MirGridType.Fishing:
  2378. toCell = FishingDialog.GetCell(p.IDTo);
  2379. break;
  2380. case MirGridType.HeroEquipment:
  2381. toCell = HeroDialog.GetCell(p.IDTo);
  2382. break;
  2383. case MirGridType.HeroInventory:
  2384. toCell = HeroInventoryDialog.GetCell(p.IDTo) ?? HeroBeltDialog.GetCell(p.IDTo);
  2385. break;
  2386. default:
  2387. return;
  2388. }
  2389. if (toCell == null || fromCell == null) return;
  2390. toCell.Locked = false;
  2391. fromCell.Locked = false;
  2392. if (p.GridFrom == MirGridType.Trade || p.GridTo == MirGridType.Trade)
  2393. TradeDialog.ChangeLockState(false);
  2394. if (!p.Success) return;
  2395. if (fromCell.Item.Count <= toCell.Item.Info.StackSize - toCell.Item.Count)
  2396. {
  2397. toCell.Item.Count += fromCell.Item.Count;
  2398. fromCell.Item = null;
  2399. }
  2400. else
  2401. {
  2402. fromCell.Item.Count -= (ushort)(toCell.Item.Info.StackSize - toCell.Item.Count);
  2403. toCell.Item.Count = toCell.Item.Info.StackSize;
  2404. }
  2405. User.RefreshStats();
  2406. }
  2407. private void RemoveItem(S.RemoveItem p)
  2408. {
  2409. MirItemCell toCell;
  2410. int index = -1;
  2411. MirItemCell fromCell = null;
  2412. for (int i = 0; i < MapObject.User.Equipment.Length; i++)
  2413. {
  2414. if (MapObject.User.Equipment[i] == null || MapObject.User.Equipment[i].UniqueID != p.UniqueID) continue;
  2415. index = i;
  2416. fromCell = CharacterDialog.Grid[index];
  2417. break;
  2418. }
  2419. if (index == -1 && Hero != null)
  2420. {
  2421. for (int i = 0; i < MapObject.Hero.Equipment.Length; i++)
  2422. {
  2423. if (MapObject.Hero.Equipment[i] == null || MapObject.Hero.Equipment[i].UniqueID != p.UniqueID) continue;
  2424. index = i;
  2425. fromCell = HeroDialog.Grid[index];
  2426. break;
  2427. }
  2428. }
  2429. switch (p.Grid)
  2430. {
  2431. case MirGridType.Inventory:
  2432. toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2433. break;
  2434. case MirGridType.Storage:
  2435. toCell = StorageDialog.Grid[p.To];
  2436. break;
  2437. case MirGridType.HeroInventory:
  2438. toCell = p.To < User.HeroBeltIdx ? HeroBeltDialog.Grid[p.To] : HeroInventoryDialog.Grid[p.To - User.HeroBeltIdx];
  2439. break;
  2440. default:
  2441. return;
  2442. }
  2443. if (toCell == null || fromCell == null) return;
  2444. toCell.Locked = false;
  2445. fromCell.Locked = false;
  2446. if (!p.Success) return;
  2447. toCell.Item = fromCell.Item;
  2448. fromCell.Item = null;
  2449. CharacterDuraPanel.GetCharacterDura();
  2450. if (p.Grid == MirGridType.HeroInventory)
  2451. Hero.RefreshStats();
  2452. else
  2453. User.RefreshStats();
  2454. }
  2455. private void RemoveSlotItem(S.RemoveSlotItem p)
  2456. {
  2457. MirItemCell fromCell;
  2458. MirItemCell toCell;
  2459. switch (p.Grid)
  2460. {
  2461. case MirGridType.Socket:
  2462. fromCell = SocketDialog.GetCell(p.UniqueID);
  2463. break;
  2464. case MirGridType.Mount:
  2465. fromCell = MountDialog.GetCell(p.UniqueID);
  2466. break;
  2467. case MirGridType.Fishing:
  2468. fromCell = FishingDialog.GetCell(p.UniqueID);
  2469. break;
  2470. default:
  2471. return;
  2472. }
  2473. switch (p.GridTo)
  2474. {
  2475. case MirGridType.Inventory:
  2476. toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2477. break;
  2478. case MirGridType.Storage:
  2479. toCell = StorageDialog.Grid[p.To];
  2480. break;
  2481. default:
  2482. return;
  2483. }
  2484. if (toCell == null || fromCell == null) return;
  2485. toCell.Locked = false;
  2486. fromCell.Locked = false;
  2487. if (!p.Success) return;
  2488. toCell.Item = fromCell.Item;
  2489. fromCell.Item = null;
  2490. CharacterDuraPanel.GetCharacterDura();
  2491. User.RefreshStats();
  2492. }
  2493. private void TakeBackItem(S.TakeBackItem p)
  2494. {
  2495. MirItemCell fromCell = StorageDialog.Grid[p.From];
  2496. MirItemCell toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2497. if (toCell == null || fromCell == null) return;
  2498. toCell.Locked = false;
  2499. fromCell.Locked = false;
  2500. if (!p.Success) return;
  2501. toCell.Item = fromCell.Item;
  2502. fromCell.Item = null;
  2503. User.RefreshStats();
  2504. CharacterDuraPanel.GetCharacterDura();
  2505. }
  2506. private void StoreItem(S.StoreItem p)
  2507. {
  2508. MirItemCell fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  2509. MirItemCell toCell = StorageDialog.Grid[p.To];
  2510. if (toCell == null || fromCell == null) return;
  2511. toCell.Locked = false;
  2512. fromCell.Locked = false;
  2513. if (!p.Success) return;
  2514. toCell.Item = fromCell.Item;
  2515. fromCell.Item = null;
  2516. User.RefreshStats();
  2517. }
  2518. private void DepositRefineItem(S.DepositRefineItem p)
  2519. {
  2520. MirItemCell fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  2521. MirItemCell toCell = RefineDialog.Grid[p.To];
  2522. if (toCell == null || fromCell == null) return;
  2523. toCell.Locked = false;
  2524. fromCell.Locked = false;
  2525. if (!p.Success) return;
  2526. toCell.Item = fromCell.Item;
  2527. fromCell.Item = null;
  2528. User.RefreshStats();
  2529. }
  2530. private void RetrieveRefineItem(S.RetrieveRefineItem p)
  2531. {
  2532. MirItemCell fromCell = RefineDialog.Grid[p.From];
  2533. MirItemCell toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2534. if (toCell == null || fromCell == null) return;
  2535. toCell.Locked = false;
  2536. fromCell.Locked = false;
  2537. if (!p.Success) return;
  2538. toCell.Item = fromCell.Item;
  2539. fromCell.Item = null;
  2540. User.RefreshStats();
  2541. }
  2542. private void RefineCancel(S.RefineCancel p)
  2543. {
  2544. RefineDialog.RefineReset();
  2545. }
  2546. private void RefineItem(S.RefineItem p)
  2547. {
  2548. RefineDialog.RefineReset();
  2549. for (int i = 0; i < User.Inventory.Length; i++)
  2550. {
  2551. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.UniqueID)
  2552. {
  2553. User.Inventory[i] = null;
  2554. break;
  2555. }
  2556. }
  2557. NPCDialog.Hide();
  2558. }
  2559. private void DepositTradeItem(S.DepositTradeItem p)
  2560. {
  2561. MirItemCell fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  2562. MirItemCell toCell = TradeDialog.Grid[p.To];
  2563. if (toCell == null || fromCell == null) return;
  2564. toCell.Locked = false;
  2565. fromCell.Locked = false;
  2566. TradeDialog.ChangeLockState(false);
  2567. if (!p.Success) return;
  2568. toCell.Item = fromCell.Item;
  2569. fromCell.Item = null;
  2570. User.RefreshStats();
  2571. }
  2572. private void RetrieveTradeItem(S.RetrieveTradeItem p)
  2573. {
  2574. MirItemCell fromCell = TradeDialog.Grid[p.From];
  2575. MirItemCell toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2576. if (toCell == null || fromCell == null) return;
  2577. toCell.Locked = false;
  2578. fromCell.Locked = false;
  2579. TradeDialog.ChangeLockState(false);
  2580. if (!p.Success) return;
  2581. toCell.Item = fromCell.Item;
  2582. fromCell.Item = null;
  2583. User.RefreshStats();
  2584. }
  2585. private void SplitItem(S.SplitItem p)
  2586. {
  2587. Bind(p.Item);
  2588. UserItem[] array;
  2589. switch (p.Grid)
  2590. {
  2591. case MirGridType.Inventory:
  2592. array = MapObject.User.Inventory;
  2593. break;
  2594. case MirGridType.Storage:
  2595. array = Storage;
  2596. break;
  2597. default:
  2598. return;
  2599. }
  2600. if (p.Grid == MirGridType.Inventory && (p.Item.Info.Type == ItemType.Potion || p.Item.Info.Type == ItemType.Scroll || p.Item.Info.Type == ItemType.Amulet || (p.Item.Info.Type == ItemType.Script && p.Item.Info.Effect == 1)))
  2601. {
  2602. if (p.Item.Info.Type == ItemType.Potion || p.Item.Info.Type == ItemType.Scroll || (p.Item.Info.Type == ItemType.Script && p.Item.Info.Effect == 1))
  2603. {
  2604. for (int i = 0; i < 4; i++)
  2605. {
  2606. if (array[i] != null) continue;
  2607. array[i] = p.Item;
  2608. User.RefreshStats();
  2609. return;
  2610. }
  2611. }
  2612. else if (p.Item.Info.Type == ItemType.Amulet)
  2613. {
  2614. for (int i = 4; i < GameScene.User.BeltIdx; i++)
  2615. {
  2616. if (array[i] != null) continue;
  2617. array[i] = p.Item;
  2618. User.RefreshStats();
  2619. return;
  2620. }
  2621. }
  2622. }
  2623. for (int i = GameScene.User.BeltIdx; i < array.Length; i++)
  2624. {
  2625. if (array[i] != null) continue;
  2626. array[i] = p.Item;
  2627. User.RefreshStats();
  2628. return;
  2629. }
  2630. for (int i = 0; i < GameScene.User.BeltIdx; i++)
  2631. {
  2632. if (array[i] != null) continue;
  2633. array[i] = p.Item;
  2634. User.RefreshStats();
  2635. return;
  2636. }
  2637. }
  2638. private void SplitItem1(S.SplitItem1 p)
  2639. {
  2640. MirItemCell cell;
  2641. switch (p.Grid)
  2642. {
  2643. case MirGridType.Inventory:
  2644. cell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2645. break;
  2646. case MirGridType.Storage:
  2647. cell = StorageDialog.GetCell(p.UniqueID);
  2648. break;
  2649. default:
  2650. return;
  2651. }
  2652. if (cell == null) return;
  2653. cell.Locked = false;
  2654. if (!p.Success) return;
  2655. cell.Item.Count -= p.Count;
  2656. User.RefreshStats();
  2657. }
  2658. private void UseItem(S.UseItem p)
  2659. {
  2660. MirItemCell cell = null;
  2661. bool hero = false;
  2662. switch (p.Grid)
  2663. {
  2664. case MirGridType.Inventory:
  2665. cell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2666. break;
  2667. case MirGridType.HeroInventory:
  2668. cell = HeroInventoryDialog.GetCell(p.UniqueID) ?? HeroBeltDialog.GetCell(p.UniqueID);
  2669. hero = true;
  2670. break;
  2671. }
  2672. if (cell == null) return;
  2673. cell.Locked = false;
  2674. if (!p.Success) return;
  2675. if (cell.Item.Count > 1) cell.Item.Count--;
  2676. else cell.Item = null;
  2677. if (hero)
  2678. Hero.RefreshStats();
  2679. else
  2680. User.RefreshStats();
  2681. }
  2682. private void DropItem(S.DropItem p)
  2683. {
  2684. MirItemCell cell;
  2685. if (p.HeroItem)
  2686. {
  2687. cell = HeroInventoryDialog.GetCell(p.UniqueID) ?? HeroBeltDialog.GetCell(p.UniqueID);
  2688. }
  2689. else
  2690. {
  2691. cell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  2692. }
  2693. if (cell == null) return;
  2694. cell.Locked = false;
  2695. if (!p.Success) return;
  2696. if (p.Count == cell.Item.Count)
  2697. cell.Item = null;
  2698. else
  2699. cell.Item.Count -= p.Count;
  2700. if (p.HeroItem)
  2701. {
  2702. Hero.RefreshStats();
  2703. }
  2704. else
  2705. {
  2706. User.RefreshStats();
  2707. }
  2708. }
  2709. private void TakeBackHeroItem(S.TakeBackHeroItem p)
  2710. {
  2711. MirItemCell fromCell = p.From < User.HeroBeltIdx ? HeroBeltDialog.Grid[p.From] : HeroInventoryDialog.Grid[p.From - User.HeroBeltIdx];
  2712. MirItemCell toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  2713. if (toCell == null || fromCell == null) return;
  2714. toCell.Locked = false;
  2715. fromCell.Locked = false;
  2716. if (!p.Success) return;
  2717. toCell.Item = fromCell.Item;
  2718. fromCell.Item = null;
  2719. User.RefreshStats();
  2720. Hero.RefreshStats();
  2721. CharacterDuraPanel.GetCharacterDura();
  2722. }
  2723. private void TransferHeroItem(S.TransferHeroItem p)
  2724. {
  2725. MirItemCell fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  2726. MirItemCell toCell = p.To < User.HeroBeltIdx ? HeroBeltDialog.Grid[p.To] : HeroInventoryDialog.Grid[p.To - User.HeroBeltIdx];
  2727. if (toCell == null || fromCell == null) return;
  2728. toCell.Locked = false;
  2729. fromCell.Locked = false;
  2730. if (!p.Success) return;
  2731. toCell.Item = fromCell.Item;
  2732. fromCell.Item = null;
  2733. User.RefreshStats();
  2734. Hero.RefreshStats();
  2735. CharacterDuraPanel.GetCharacterDura();
  2736. }
  2737. private void MountUpdate(S.MountUpdate p)
  2738. {
  2739. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2740. {
  2741. if (ob is PlayerObject player)
  2742. player.MountUpdate(p);
  2743. }
  2744. if (p.ObjectID != User.ObjectID) return;
  2745. CanRun = false;
  2746. User.RefreshStats();
  2747. MountDialog.RefreshDialog();
  2748. Redraw();
  2749. }
  2750. private void TransformUpdate(S.TransformUpdate p)
  2751. {
  2752. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob))
  2753. if (ob is PlayerObject player)
  2754. player.TransformType = p.TransformType;
  2755. }
  2756. private void FishingUpdate(S.FishingUpdate p)
  2757. {
  2758. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && ob is PlayerObject player)
  2759. player.FishingUpdate(p);
  2760. if (p.ObjectID != User.ObjectID) return;
  2761. FishingStatusDialog.ProgressPercent = p.ProgressPercent;
  2762. FishingStatusDialog.ChancePercent = p.ChancePercent;
  2763. FishingStatusDialog.ChanceLabel.Text = string.Format("{0}%", FishingStatusDialog.ChancePercent);
  2764. if (p.Fishing)
  2765. FishingStatusDialog.Show();
  2766. else
  2767. FishingStatusDialog.Hide();
  2768. Redraw();
  2769. }
  2770. private void CompleteQuest(S.CompleteQuest p)
  2771. {
  2772. User.CompletedQuests = p.CompletedQuests;
  2773. }
  2774. private void ShareQuest(S.ShareQuest p)
  2775. {
  2776. ClientQuestInfo quest = GameScene.QuestInfoList.FirstOrDefault(e => e.Index == p.QuestIndex);
  2777. if (quest == null) return;
  2778. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerShareQuestRequest), p.SharerName), MirMessageBoxButtons.YesNo);
  2779. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.AcceptQuest { NPCIndex = 0, QuestIndex = quest.Index });
  2780. messageBox.Show();
  2781. }
  2782. private void ChangeQuest(S.ChangeQuest p)
  2783. {
  2784. switch (p.QuestState)
  2785. {
  2786. case QuestState.Add:
  2787. User.CurrentQuests.Add(p.Quest);
  2788. foreach (ClientQuestProgress quest in User.CurrentQuests)
  2789. BindQuest(quest);
  2790. if (Settings.TrackedQuests.Contains(p.Quest.Id))
  2791. {
  2792. GameScene.Scene.QuestTrackingDialog.AddQuest(p.Quest, true);
  2793. }
  2794. if (p.TrackQuest)
  2795. {
  2796. GameScene.Scene.QuestTrackingDialog.AddQuest(p.Quest);
  2797. }
  2798. break;
  2799. case QuestState.Update:
  2800. for (int i = 0; i < User.CurrentQuests.Count; i++)
  2801. {
  2802. if (User.CurrentQuests[i].Id != p.Quest.Id) continue;
  2803. User.CurrentQuests[i] = p.Quest;
  2804. }
  2805. foreach (ClientQuestProgress quest in User.CurrentQuests)
  2806. BindQuest(quest);
  2807. break;
  2808. case QuestState.Remove:
  2809. for (int i = User.CurrentQuests.Count - 1; i >= 0; i--)
  2810. {
  2811. if (User.CurrentQuests[i].Id != p.Quest.Id) continue;
  2812. User.CurrentQuests.RemoveAt(i);
  2813. }
  2814. GameScene.Scene.QuestTrackingDialog.RemoveQuest(p.Quest);
  2815. break;
  2816. }
  2817. GameScene.Scene.QuestTrackingDialog.DisplayQuests();
  2818. if (Scene.QuestListDialog.Visible)
  2819. {
  2820. Scene.QuestListDialog.DisplayInfo();
  2821. }
  2822. if (Scene.QuestLogDialog.Visible)
  2823. {
  2824. Scene.QuestLogDialog.DisplayQuests();
  2825. }
  2826. }
  2827. private void PlayerUpdate(S.PlayerUpdate p)
  2828. {
  2829. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && ob is PlayerObject player)
  2830. player.Update(p);
  2831. }
  2832. private void PlayerInspect(S.PlayerInspect p)
  2833. {
  2834. InspectDialog.Items = p.Equipment;
  2835. InspectDialog.Name = p.Name;
  2836. InspectDialog.GuildName = p.GuildName;
  2837. InspectDialog.GuildRank = p.GuildRank;
  2838. InspectDialog.Class = p.Class;
  2839. InspectDialog.Gender = p.Gender;
  2840. InspectDialog.Hair = p.Hair;
  2841. InspectDialog.Level = p.Level;
  2842. InspectDialog.LoverName = p.LoverName;
  2843. InspectDialog.AllowObserve = p.AllowObserve;
  2844. InspectDialog.RefreshInferface(p.IsHero);
  2845. InspectDialog.Show();
  2846. }
  2847. private void LogOutSuccess(S.LogOutSuccess p)
  2848. {
  2849. for (int i = 0; i <= 3; i++)//Fix for orbs sound
  2850. SoundManager.StopSound(20000 + 126 * 10 + 5 + i);
  2851. User = null;
  2852. if (Settings.Resolution != 1024)
  2853. {
  2854. CMain.SetResolution(1024, 768);
  2855. }
  2856. ActiveScene = new SelectScene(p.Characters);
  2857. Dispose();
  2858. }
  2859. private void LogOutFailed(S.LogOutFailed p)
  2860. {
  2861. Enabled = true;
  2862. }
  2863. private void ReturnToLogin(S.ReturnToLogin p)
  2864. {
  2865. User = null;
  2866. if (Settings.Resolution != 1024)
  2867. CMain.SetResolution(1024, 768);
  2868. ActiveScene = new LoginScene();
  2869. Dispose();
  2870. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ObservedPlayerLoggedOff));
  2871. }
  2872. private void TimeOfDay(S.TimeOfDay p)
  2873. {
  2874. Lights = p.Lights;
  2875. switch (Lights)
  2876. {
  2877. case LightSetting.Day:
  2878. case LightSetting.Normal:
  2879. MiniMapDialog.LightSetting.Index = 2093;
  2880. break;
  2881. case LightSetting.Dawn:
  2882. MiniMapDialog.LightSetting.Index = 2095;
  2883. break;
  2884. case LightSetting.Evening:
  2885. MiniMapDialog.LightSetting.Index = 2094;
  2886. break;
  2887. case LightSetting.Night:
  2888. MiniMapDialog.LightSetting.Index = 2092;
  2889. break;
  2890. }
  2891. }
  2892. private void ChangeAMode(S.ChangeAMode p)
  2893. {
  2894. AMode = p.Mode;
  2895. switch (p.Mode)
  2896. {
  2897. case AttackMode.Peace:
  2898. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AttackMode_Peace), ChatType.Hint);
  2899. break;
  2900. case AttackMode.Group:
  2901. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AttackMode_Group), ChatType.Hint);
  2902. break;
  2903. case AttackMode.Guild:
  2904. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AttackMode_Guild), ChatType.Hint);
  2905. break;
  2906. case AttackMode.EnemyGuild:
  2907. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AttackMode_EnemyGuild), ChatType.Hint);
  2908. break;
  2909. case AttackMode.RedBrown:
  2910. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AttackMode_RedBrown), ChatType.Hint);
  2911. break;
  2912. case AttackMode.All:
  2913. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AttackMode_All), ChatType.Hint);
  2914. break;
  2915. }
  2916. }
  2917. private void ChangePMode(S.ChangePMode p)
  2918. {
  2919. PMode = p.Mode;
  2920. switch (p.Mode)
  2921. {
  2922. case PetMode.Both:
  2923. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PetMode_Both), ChatType.Hint);
  2924. break;
  2925. case PetMode.MoveOnly:
  2926. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PetMode_MoveOnly), ChatType.Hint);
  2927. break;
  2928. case PetMode.AttackOnly:
  2929. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PetMode_AttackOnly), ChatType.Hint);
  2930. break;
  2931. case PetMode.None:
  2932. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PetMode_None), ChatType.Hint);
  2933. break;
  2934. case PetMode.FocusMasterTarget:
  2935. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PetMode_FocusMasterTarget), ChatType.Hint);
  2936. break;
  2937. }
  2938. }
  2939. private void ObjectItem(S.ObjectItem p)
  2940. {
  2941. ItemObject ob = new ItemObject(p.ObjectID);
  2942. ob.Load(p);
  2943. /*
  2944. string[] Warnings = new string[] {"HeroNecklace","AdamantineNecklace","8TrigramWheel","HangMaWheel","BaekTaGlove","SpiritReformer","BokMaWheel","BoundlessRing","ThunderRing","TaeGukRing","OmaSpiritRing","NobleRing"};
  2945. if (Warnings.Contains(p.Name))
  2946. {
  2947. ChatDialog.ReceiveChat(string.Format("{0} at {1}", p.Name, p.Location), ChatType.Hint);
  2948. }
  2949. */
  2950. }
  2951. private void ObjectGold(S.ObjectGold p)
  2952. {
  2953. ItemObject ob = new ItemObject(p.ObjectID);
  2954. ob.Load(p);
  2955. }
  2956. private void GainedItem(S.GainedItem p)
  2957. {
  2958. Bind(p.Item);
  2959. AddItem(p.Item);
  2960. User.RefreshStats();
  2961. OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.YouGainedItem), p.Item.FriendlyName));
  2962. }
  2963. private void GainedQuestItem(S.GainedQuestItem p)
  2964. {
  2965. Bind(p.Item);
  2966. AddQuestItem(p.Item);
  2967. }
  2968. private void GainedGold(S.GainedGold p)
  2969. {
  2970. if (p.Gold == 0) return;
  2971. Gold += p.Gold;
  2972. SoundManager.PlaySound(SoundList.Gold);
  2973. OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.YouGainedGold), p.Gold, GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Gold)));
  2974. }
  2975. private void LoseGold(S.LoseGold p)
  2976. {
  2977. Gold -= p.Gold;
  2978. SoundManager.PlaySound(SoundList.Gold);
  2979. }
  2980. private void GainedCredit(S.GainedCredit p)
  2981. {
  2982. if (p.Credit == 0) return;
  2983. Credit += p.Credit;
  2984. SoundManager.PlaySound(SoundList.Gold);
  2985. OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.YouGainedGold), p.Credit, GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Credit)));
  2986. }
  2987. private void LoseCredit(S.LoseCredit p)
  2988. {
  2989. Credit -= p.Credit;
  2990. SoundManager.PlaySound(SoundList.Gold);
  2991. }
  2992. private void ObjectMonster(S.ObjectMonster p)
  2993. {
  2994. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && ob is MonsterObject mob)
  2995. {
  2996. mob.Load(p, true);
  2997. return;
  2998. }
  2999. mob = new MonsterObject(p.ObjectID);
  3000. mob.Load(p, false);
  3001. }
  3002. private void ObjectAttack(S.ObjectAttack p)
  3003. {
  3004. if (p.ObjectID == User.ObjectID && !Observing) return;
  3005. QueuedAction action = null;
  3006. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3007. {
  3008. if (ob.Race == ObjectType.Player)
  3009. {
  3010. action = new QueuedAction { Action = MirAction.Attack1, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  3011. }
  3012. else
  3013. {
  3014. switch (p.Type)
  3015. {
  3016. default:
  3017. {
  3018. action = new QueuedAction { Action = MirAction.Attack1, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  3019. break;
  3020. }
  3021. case 1:
  3022. {
  3023. action = new QueuedAction { Action = MirAction.Attack2, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  3024. break;
  3025. }
  3026. case 2:
  3027. {
  3028. action = new QueuedAction { Action = MirAction.Attack3, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  3029. break;
  3030. }
  3031. case 3:
  3032. {
  3033. action = new QueuedAction { Action = MirAction.Attack4, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  3034. break;
  3035. }
  3036. case 4:
  3037. {
  3038. action = new QueuedAction { Action = MirAction.Attack5, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  3039. break;
  3040. }
  3041. }
  3042. }
  3043. action.Params.Add(p.Spell);
  3044. action.Params.Add(p.Level);
  3045. ob.ActionFeed.Add(action);
  3046. }
  3047. }
  3048. private void Struck(S.Struck p)
  3049. {
  3050. LogTime = CMain.Time + Globals.LogDelay;
  3051. NextRunTime = CMain.Time + 2500;
  3052. User.BlizzardStopTime = 0;
  3053. User.ClearMagic();
  3054. if (User.ReincarnationStopTime > CMain.Time)
  3055. Network.Enqueue(new C.CancelReincarnation { });
  3056. MirDirection dir = User.Direction;
  3057. Point location = User.CurrentLocation;
  3058. for (int i = 0; i < User.ActionFeed.Count; i++)
  3059. if (User.ActionFeed[i].Action == MirAction.Struck) return;
  3060. if (User.ActionFeed.Count > 0)
  3061. {
  3062. dir = User.ActionFeed[User.ActionFeed.Count - 1].Direction;
  3063. location = User.ActionFeed[User.ActionFeed.Count - 1].Location;
  3064. }
  3065. if (User.Buffs.Any(a => a == BuffType.EnergyShield))
  3066. {
  3067. for (int j = 0; j < User.Effects.Count; j++)
  3068. {
  3069. BuffEffect effect = null;
  3070. effect = User.Effects[j] as BuffEffect;
  3071. if (effect != null && effect.BuffType == BuffType.EnergyShield)
  3072. {
  3073. effect.Clear();
  3074. effect.Remove();
  3075. User.Effects.Add(effect = new BuffEffect(Libraries.Magic2, 1890, 6, 600, User, true, BuffType.EnergyShield) { Repeat = false });
  3076. SoundManager.PlaySound(20000 + (ushort)Spell.EnergyShield * 10 + 1);
  3077. effect.Complete += (o, e) =>
  3078. {
  3079. User.Effects.Add(new BuffEffect(Libraries.Magic2, 1900, 2, 800, User, true, BuffType.EnergyShield) { Repeat = true });
  3080. };
  3081. break;
  3082. }
  3083. }
  3084. }
  3085. QueuedAction action = new QueuedAction
  3086. {
  3087. Action = MirAction.Struck,
  3088. Direction = dir,
  3089. Location = location,
  3090. Params = new List<object>()
  3091. };
  3092. action.Params.Add(p.AttackerID);
  3093. int weapon = -2;
  3094. if (MapControl.Objects.TryGetValue(p.AttackerID, out MapObject attacker) &&
  3095. attacker.Race == ObjectType.Player)
  3096. {
  3097. PlayerObject player = (PlayerObject)attacker;
  3098. weapon = player.Weapon;
  3099. if (player.Class == MirClass.Assassin && weapon > -1)
  3100. weapon = 1;
  3101. }
  3102. action.Params.Add(weapon);
  3103. User.ActionFeed.Add(action);
  3104. }
  3105. private void ObjectStruck(S.ObjectStruck p)
  3106. {
  3107. if (p.ObjectID == User.ObjectID) return;
  3108. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3109. {
  3110. if (ob.SkipFrames) return;
  3111. if (ob.ActionFeed.Count > 0 && ob.ActionFeed[ob.ActionFeed.Count - 1].Action == MirAction.Struck) return;
  3112. if (ob.Race == ObjectType.Player)
  3113. ((PlayerObject)ob).BlizzardStopTime = 0;
  3114. QueuedAction action = new QueuedAction
  3115. {
  3116. Action = MirAction.Struck,
  3117. Direction = p.Direction,
  3118. Location = p.Location,
  3119. Params = new List<object>()
  3120. };
  3121. action.Params.Add(p.AttackerID);
  3122. int weapon = -2;
  3123. if (MapControl.Objects.TryGetValue(p.AttackerID, out MapObject attacker) &&
  3124. attacker.Race == ObjectType.Player)
  3125. {
  3126. PlayerObject player = (PlayerObject)attacker;
  3127. weapon = player.Weapon;
  3128. if (player.Class == MirClass.Assassin && weapon > -1)
  3129. weapon = 1;
  3130. }
  3131. action.Params.Add(weapon);
  3132. ob.ActionFeed.Add(action);
  3133. if (ob.Buffs.Any(a => a == BuffType.EnergyShield))
  3134. {
  3135. for (int j = 0; j < ob.Effects.Count; j++)
  3136. {
  3137. BuffEffect effect = null;
  3138. effect = ob.Effects[j] as BuffEffect;
  3139. if (effect != null && effect.BuffType == BuffType.EnergyShield)
  3140. {
  3141. effect.Clear();
  3142. effect.Remove();
  3143. ob.Effects.Add(effect = new BuffEffect(Libraries.Magic2, 1890, 6, 600, ob, true, BuffType.EnergyShield) { Repeat = false });
  3144. SoundManager.PlaySound(20000 + (ushort)Spell.EnergyShield * 10 + 1);
  3145. effect.Complete += (o, e) =>
  3146. {
  3147. ob.Effects.Add(new BuffEffect(Libraries.Magic2, 1900, 2, 800, ob, true, BuffType.EnergyShield) { Repeat = true });
  3148. };
  3149. break;
  3150. }
  3151. }
  3152. }
  3153. }
  3154. }
  3155. private void DamageIndicator(S.DamageIndicator p)
  3156. {
  3157. if (Settings.DisplayDamage)
  3158. {
  3159. if (MapControl.Objects.TryGetValue(p.ObjectID, out var obj))
  3160. {
  3161. if (obj.Damages.Count >= 10) return;
  3162. switch (p.Type)
  3163. {
  3164. case DamageType.Hit: //add damage level colours
  3165. obj.Damages.Add(new Damage(p.Damage.ToString("#,##0"), 1000, obj.Race == ObjectType.Player ? Color.Red : Color.White, 50));
  3166. break;
  3167. case DamageType.Miss:
  3168. obj.Damages.Add(new Damage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Miss), 1200, obj.Race == ObjectType.Player ? Color.LightCoral : Color.LightGray, 50));
  3169. break;
  3170. case DamageType.Critical:
  3171. obj.Damages.Add(
  3172. new Damage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Crit), 1000, obj.Race == ObjectType.Player ? Color.DarkRed : Color.DarkRed, 50) { Offset = 15 });
  3173. break;
  3174. }
  3175. }
  3176. }
  3177. }
  3178. private void DuraChanged(S.DuraChanged p)
  3179. {
  3180. UserItem item = null;
  3181. for (int i = 0; i < User.Inventory.Length; i++)
  3182. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.UniqueID)
  3183. {
  3184. item = User.Inventory[i];
  3185. break;
  3186. }
  3187. if (item == null)
  3188. for (int i = 0; i < User.Equipment.Length; i++)
  3189. {
  3190. if (User.Equipment[i] != null && User.Equipment[i].UniqueID == p.UniqueID)
  3191. {
  3192. item = User.Equipment[i];
  3193. break;
  3194. }
  3195. if (User.Equipment[i] != null && User.Equipment[i].Slots != null)
  3196. {
  3197. for (int j = 0; j < User.Equipment[i].Slots.Length; j++)
  3198. {
  3199. if (User.Equipment[i].Slots[j] != null && User.Equipment[i].Slots[j].UniqueID == p.UniqueID)
  3200. {
  3201. item = User.Equipment[i].Slots[j];
  3202. break;
  3203. }
  3204. }
  3205. if (item != null) break;
  3206. }
  3207. }
  3208. if (item == null) return;
  3209. item.CurrentDura = p.CurrentDura;
  3210. if (item.CurrentDura == 0)
  3211. {
  3212. User.RefreshStats();
  3213. switch (item.Info.Type)
  3214. {
  3215. case ItemType.Mount:
  3216. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.FriendlyNoLongerLoyal), item.Info.FriendlyName), ChatType.System);
  3217. break;
  3218. default:
  3219. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.FriendlyDuraDroppedToZero), item.Info.FriendlyName), ChatType.System);
  3220. break;
  3221. }
  3222. }
  3223. if (HoverItem == item)
  3224. {
  3225. DisposeItemLabel();
  3226. CreateItemLabel(item);
  3227. }
  3228. CharacterDuraPanel.UpdateCharacterDura(item);
  3229. }
  3230. private void HealthChanged(S.HealthChanged p)
  3231. {
  3232. User.HP = p.HP;
  3233. User.MP = p.MP;
  3234. User.PercentHealth = (byte)(User.HP / (float)User.Stats[Stat.HP] * 100);
  3235. }
  3236. private void HeroHealthChanged(S.HeroHealthChanged p)
  3237. {
  3238. Hero.HP = p.HP;
  3239. Hero.MP = p.MP;
  3240. Hero.PercentHealth = (byte)(Hero.HP / (float)Hero.Stats[Stat.HP] * 100);
  3241. Hero.PercentMana = (byte)(Hero.MP / (float)Hero.Stats[Stat.MP] * 100);
  3242. }
  3243. private void DeleteQuestItem(S.DeleteQuestItem p)
  3244. {
  3245. for (int i = 0; i < User.QuestInventory.Length; i++)
  3246. {
  3247. UserItem item = User.QuestInventory[i];
  3248. if (item == null || item.UniqueID != p.UniqueID) continue;
  3249. if (item.Count == p.Count)
  3250. User.QuestInventory[i] = null;
  3251. else
  3252. item.Count -= p.Count;
  3253. break;
  3254. }
  3255. }
  3256. private void DeleteItem(S.DeleteItem p)
  3257. {
  3258. UserObject actor = null;
  3259. for (int i = 0; i < User.Inventory.Length; i++)
  3260. {
  3261. if (actor != null) break;
  3262. UserItem item = User.Inventory[i];
  3263. if (item != null && item.Slots.Length > 0)
  3264. {
  3265. for (int j = 0; j < item.Slots.Length; j++)
  3266. {
  3267. UserItem slotItem = item.Slots[j];
  3268. if (slotItem == null || slotItem.UniqueID != p.UniqueID) continue;
  3269. if (slotItem.Count == p.Count)
  3270. item.Slots[j] = null;
  3271. else
  3272. slotItem.Count -= p.Count;
  3273. actor = User;
  3274. break;
  3275. }
  3276. }
  3277. if (item == null || item.UniqueID != p.UniqueID) continue;
  3278. if (item.Count == p.Count)
  3279. User.Inventory[i] = null;
  3280. else
  3281. item.Count -= p.Count;
  3282. actor = User;
  3283. }
  3284. if (actor == null)
  3285. {
  3286. for (int i = 0; i < User.Equipment.Length; i++)
  3287. {
  3288. if (actor != null) break;
  3289. UserItem item = User.Equipment[i];
  3290. if (item != null && item.Slots.Length > 0)
  3291. {
  3292. for (int j = 0; j < item.Slots.Length; j++)
  3293. {
  3294. UserItem slotItem = item.Slots[j];
  3295. if (slotItem == null || slotItem.UniqueID != p.UniqueID) continue;
  3296. if (slotItem.Count == p.Count)
  3297. item.Slots[j] = null;
  3298. else
  3299. slotItem.Count -= p.Count;
  3300. actor = User;
  3301. break;
  3302. }
  3303. }
  3304. if (item == null || item.UniqueID != p.UniqueID) continue;
  3305. if (item.Count == p.Count)
  3306. User.Equipment[i] = null;
  3307. else
  3308. item.Count -= p.Count;
  3309. actor = User;
  3310. }
  3311. }
  3312. if (Hero != null && actor == null)
  3313. {
  3314. for (int i = 0; i < Hero.Inventory.Length; i++)
  3315. {
  3316. if (actor != null) break;
  3317. UserItem item = Hero.Inventory[i];
  3318. if (item != null && item.Slots.Length > 0)
  3319. {
  3320. for (int j = 0; j < item.Slots.Length; j++)
  3321. {
  3322. UserItem slotItem = item.Slots[j];
  3323. if (slotItem == null || slotItem.UniqueID != p.UniqueID) continue;
  3324. if (slotItem.Count == p.Count)
  3325. item.Slots[j] = null;
  3326. else
  3327. slotItem.Count -= p.Count;
  3328. actor = Hero;
  3329. break;
  3330. }
  3331. }
  3332. if (item == null || item.UniqueID != p.UniqueID) continue;
  3333. if (item.Count == p.Count)
  3334. User.Inventory[i] = null;
  3335. else
  3336. item.Count -= p.Count;
  3337. actor = Hero;
  3338. }
  3339. if (actor == null)
  3340. {
  3341. for (int i = 0; i < Hero.Equipment.Length; i++)
  3342. {
  3343. if (actor != null) break;
  3344. UserItem item = Hero.Equipment[i];
  3345. if (item != null && item.Slots.Length > 0)
  3346. {
  3347. for (int j = 0; j < item.Slots.Length; j++)
  3348. {
  3349. UserItem slotItem = item.Slots[j];
  3350. if (slotItem == null || slotItem.UniqueID != p.UniqueID) continue;
  3351. if (slotItem.Count == p.Count)
  3352. item.Slots[j] = null;
  3353. else
  3354. slotItem.Count -= p.Count;
  3355. actor = Hero;
  3356. break;
  3357. }
  3358. }
  3359. if (item == null || item.UniqueID != p.UniqueID) continue;
  3360. if (item.Count == p.Count)
  3361. User.Equipment[i] = null;
  3362. else
  3363. item.Count -= p.Count;
  3364. actor = Hero;
  3365. }
  3366. }
  3367. }
  3368. if (actor == null)
  3369. {
  3370. for (int i = 0; i < Storage.Length; i++)
  3371. {
  3372. var item = Storage[i];
  3373. if (item == null || item.UniqueID != p.UniqueID) continue;
  3374. if (item.Count == p.Count)
  3375. Storage[i] = null;
  3376. else
  3377. item.Count -= p.Count;
  3378. break;
  3379. }
  3380. }
  3381. actor?.RefreshStats();
  3382. }
  3383. private void Death(S.Death p)
  3384. {
  3385. User.Dead = true;
  3386. User.ActionFeed.Add(new QueuedAction { Action = MirAction.Die, Direction = p.Direction, Location = p.Location });
  3387. ShowReviveMessage = true;
  3388. LogTime = 0;
  3389. }
  3390. private void ObjectDied(S.ObjectDied p)
  3391. {
  3392. if (p.ObjectID == User.ObjectID) return;
  3393. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3394. {
  3395. switch (p.Type)
  3396. {
  3397. default:
  3398. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Die, Direction = p.Direction, Location = p.Location });
  3399. ob.Dead = true;
  3400. break;
  3401. case 1:
  3402. MapControl.Effects.Add(new Effect(Libraries.Magic2, 690, 10, 1000, ob.CurrentLocation));
  3403. ob.Remove();
  3404. break;
  3405. case 2:
  3406. SoundManager.PlaySound(20000 + (ushort)Spell.DarkBody * 10 + 1);
  3407. MapControl.Effects.Add(new Effect(Libraries.Magic2, 2600, 10, 1200, ob.CurrentLocation));
  3408. ob.Remove();
  3409. break;
  3410. }
  3411. }
  3412. }
  3413. private void ColourChanged(S.ColourChanged p)
  3414. {
  3415. User.NameColour = p.NameColour;
  3416. }
  3417. private void ObjectColourChanged(S.ObjectColourChanged p)
  3418. {
  3419. if (p.ObjectID == User.ObjectID) return;
  3420. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3421. ob.NameColour = p.NameColour;
  3422. }
  3423. private void ObjectGuildNameChanged(S.ObjectGuildNameChanged p)
  3424. {
  3425. if (p.ObjectID == User.ObjectID) return;
  3426. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && ob is PlayerObject obPlayer)
  3427. obPlayer.GuildName = p.GuildName;
  3428. }
  3429. private void GainExperience(S.GainExperience p)
  3430. {
  3431. OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ExperienceGained), p.Amount));
  3432. MapObject.User.Experience += p.Amount;
  3433. }
  3434. private void GainHeroExperience(S.GainHeroExperience p)
  3435. {
  3436. OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.HeroExperienceGained), p.Amount));
  3437. MapObject.Hero.Experience += p.Amount;
  3438. }
  3439. private void LevelChanged(S.LevelChanged p)
  3440. {
  3441. User.Level = p.Level;
  3442. User.Experience = p.Experience;
  3443. User.MaxExperience = p.MaxExperience;
  3444. User.RefreshStats();
  3445. OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LevelUp));
  3446. User.Effects.Add(new Effect(Libraries.Magic2, 1200, 20, 2000, User));
  3447. SoundManager.PlaySound(SoundList.LevelUp);
  3448. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LevelUp), ChatType.LevelUp);
  3449. }
  3450. private void HeroLevelChanged(S.HeroLevelChanged p)
  3451. {
  3452. Hero.Level = p.Level;
  3453. Hero.Experience = p.Experience;
  3454. Hero.MaxExperience = p.MaxExperience;
  3455. Hero.RefreshStats();
  3456. Hero.Effects.Add(new Effect(Libraries.Magic2, 1200, 20, 2000, User));
  3457. SoundManager.PlaySound(SoundList.LevelUp);
  3458. MainDialog.HeroInfoPanel.Update();
  3459. }
  3460. private void ObjectLeveled(S.ObjectLeveled p)
  3461. {
  3462. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3463. {
  3464. ob.Effects.Add(new Effect(Libraries.Magic2, 1180, 16, 2500, ob));
  3465. SoundManager.PlaySound(SoundList.LevelUp);
  3466. }
  3467. }
  3468. private void ObjectHarvest(S.ObjectHarvest p)
  3469. {
  3470. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3471. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Harvest, Direction = ob.Direction, Location = ob.CurrentLocation });
  3472. }
  3473. private void ObjectHarvested(S.ObjectHarvested p)
  3474. {
  3475. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3476. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Skeleton, Direction = ob.Direction, Location = ob.CurrentLocation });
  3477. }
  3478. private void ObjectNPC(S.ObjectNPC p)
  3479. {
  3480. NPCObject ob = new NPCObject(p.ObjectID);
  3481. ob.Load(p);
  3482. }
  3483. private void NPCResponse(S.NPCResponse p)
  3484. {
  3485. NPCTime = 0;
  3486. NPCDialog.BigButtons.Clear();
  3487. NPCDialog.BigButtonDialog.Hide();
  3488. NPCDialog.NewText(p.Page);
  3489. if (p.Page.Count > 0 || NPCDialog.BigButtons.Count > 0)
  3490. NPCDialog.Show();
  3491. else
  3492. NPCDialog.Hide();
  3493. NPCGoodsDialog.Hide();
  3494. NPCSubGoodsDialog.Hide();
  3495. NPCCraftGoodsDialog.Hide();
  3496. NPCDropDialog.Hide();
  3497. StorageDialog.Hide();
  3498. NPCAwakeDialog.Hide();
  3499. RefineDialog.Hide();
  3500. StorageDialog.Hide();
  3501. TrustMerchantDialog.Hide();
  3502. QuestListDialog.Hide();
  3503. }
  3504. private void NPCUpdate(S.NPCUpdate p)
  3505. {
  3506. GameScene.NPCID = p.NPCID; //Updates the client with the correct NPC ID if it's manually called from the client
  3507. }
  3508. private void NPCImageUpdate(S.NPCImageUpdate p)
  3509. {
  3510. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && ob is NPCObject npc && ob.Race == ObjectType.Merchant)
  3511. {
  3512. npc.Image = p.Image;
  3513. npc.Colour = p.Colour;
  3514. npc.LoadLibrary();
  3515. }
  3516. }
  3517. private void DefaultNPC(S.DefaultNPC p)
  3518. {
  3519. GameScene.DefaultNPCID = p.ObjectID; //Updates the client with the correct Default NPC ID
  3520. }
  3521. private void ObjectHide(S.ObjectHide p)
  3522. {
  3523. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3524. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Hide, Direction = ob.Direction, Location = ob.CurrentLocation });
  3525. }
  3526. private void ObjectShow(S.ObjectShow p)
  3527. {
  3528. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3529. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Show, Direction = ob.Direction, Location = ob.CurrentLocation });
  3530. }
  3531. private void Poisoned(S.Poisoned p)
  3532. {
  3533. var previousPoisons = User.Poison;
  3534. User.Poison = p.Poison;
  3535. if (p.Poison.HasFlag(PoisonType.Stun) || p.Poison.HasFlag(PoisonType.Dazed) || p.Poison.HasFlag(PoisonType.Frozen) || p.Poison.HasFlag(PoisonType.Paralysis) || p.Poison.HasFlag(PoisonType.LRParalysis))
  3536. {
  3537. User.ClearMagic();
  3538. }
  3539. if (previousPoisons.HasFlag(PoisonType.Blindness) && !User.Poison.HasFlag(PoisonType.Blindness))
  3540. {
  3541. User.BlindCount = 0;
  3542. }
  3543. }
  3544. private void ObjectPoisoned(S.ObjectPoisoned p)
  3545. {
  3546. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3547. ob.Poison = p.Poison;
  3548. }
  3549. private void MapChanged(S.MapChanged p)
  3550. {
  3551. var isCurrentMap = (MapControl.Index == p.MapIndex);
  3552. if (isCurrentMap)
  3553. MapControl.ResetMap();
  3554. else
  3555. {
  3556. MapControl.Index = p.MapIndex;
  3557. MapControl.FileName = Path.Combine(Settings.MapPath, p.FileName + ".map");
  3558. MapControl.Title = p.Title;
  3559. MapControl.MiniMap = p.MiniMap;
  3560. MapControl.BigMap = p.BigMap;
  3561. MapControl.Lights = p.Lights;
  3562. MapControl.MapDarkLight = p.MapDarkLight;
  3563. MapControl.Music = p.Music;
  3564. MapControl.Weather = p.Weather;
  3565. MapControl.LoadMap();
  3566. }
  3567. MapControl.NextAction = 0;
  3568. Scene.MapControl.AutoPath = false;
  3569. User.CurrentLocation = p.Location;
  3570. User.MapLocation = p.Location;
  3571. MapControl.AddObject(User);
  3572. User.Direction = p.Direction;
  3573. User.QueuedAction = null;
  3574. User.ActionFeed.Clear();
  3575. User.ClearMagic();
  3576. User.SetAction();
  3577. GameScene.CanRun = false;
  3578. MapControl.FloorValid = false;
  3579. MapControl.InputDelay = CMain.Time + 400;
  3580. MapControl.UpdateWeather();
  3581. }
  3582. private void ObjectTeleportOut(S.ObjectTeleportOut p)
  3583. {
  3584. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3585. {
  3586. Effect effect = null;
  3587. bool playDefaultSound = true;
  3588. switch (p.Type)
  3589. {
  3590. case 1: //Yimoogi
  3591. {
  3592. effect = new Effect(Libraries.Magic2, 1300, 10, 500, ob.CurrentLocation);
  3593. break;
  3594. }
  3595. case 2: //RedFoxman
  3596. {
  3597. effect = new Effect(Libraries.Monsters[(ushort)Monster.RedFoxman], 243, 10, 500, ob.CurrentLocation);
  3598. break;
  3599. }
  3600. case 4: //MutatedManWorm
  3601. {
  3602. effect = new Effect(Libraries.Monsters[(ushort)Monster.MutatedManworm], 272, 6, 500, ob.CurrentLocation);
  3603. SoundManager.PlaySound(((ushort)Monster.MutatedManworm) * 10 + 7);
  3604. playDefaultSound = false;
  3605. break;
  3606. }
  3607. case 5: //WitchDoctor
  3608. {
  3609. effect = new Effect(Libraries.Monsters[(ushort)Monster.WitchDoctor], 328, 20, 1000, ob.CurrentLocation);
  3610. SoundManager.PlaySound(((ushort)Monster.WitchDoctor) * 10 + 7);
  3611. playDefaultSound = false;
  3612. break;
  3613. }
  3614. case 6: //TurtleKing
  3615. {
  3616. effect = new Effect(Libraries.Monsters[(ushort)Monster.TurtleKing], 946, 10, 500, ob.CurrentLocation);
  3617. break;
  3618. }
  3619. case 7: //Mandrill
  3620. {
  3621. effect = new Effect(Libraries.Monsters[(ushort)Monster.Mandrill], 280, 10, 1000, ob.CurrentLocation);
  3622. SoundManager.PlaySound(((ushort)Monster.Mandrill) * 10 + 6);
  3623. playDefaultSound = false;
  3624. break;
  3625. }
  3626. case 8: //DarkCaptain
  3627. {
  3628. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.DarkCaptain], 1224, 10, 1000, ob.CurrentLocation));
  3629. SoundManager.PlaySound(((ushort)Monster.DarkCaptain) * 10 + 8);
  3630. playDefaultSound = false;
  3631. break;
  3632. }
  3633. case 9: //Doe
  3634. {
  3635. effect = new Effect(Libraries.Monsters[(ushort)Monster.Doe], 208, 10, 1000, ob.CurrentLocation);
  3636. SoundManager.PlaySound(((ushort)Monster.Doe) * 10 + 7);
  3637. playDefaultSound = false;
  3638. break;
  3639. }
  3640. case 10: //HornedCommander
  3641. {
  3642. MapControl.Effects.Add(effect = new Effect(Libraries.Monsters[(ushort)Monster.HornedCommander], 928, 10, 1000, ob.CurrentLocation));
  3643. SoundManager.PlaySound(8455);
  3644. playDefaultSound = false;
  3645. break;
  3646. }
  3647. case 11: //SnowWolfKing
  3648. {
  3649. MapControl.Effects.Add(effect = new Effect(Libraries.Monsters[(ushort)Monster.SnowWolfKing], 561, 10, 1000, ob.CurrentLocation));
  3650. SoundManager.PlaySound(8455);
  3651. playDefaultSound = false;
  3652. break;
  3653. }
  3654. default:
  3655. {
  3656. effect = new Effect(Libraries.Magic, 250, 10, 500, ob.CurrentLocation);
  3657. break;
  3658. }
  3659. }
  3660. MapControl.Effects.Add(effect);
  3661. if (playDefaultSound)
  3662. SoundManager.PlaySound(SoundList.Teleport);
  3663. }
  3664. }
  3665. private void ObjectTeleportIn(S.ObjectTeleportIn p)
  3666. {
  3667. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  3668. {
  3669. bool playDefaultSound = true;
  3670. switch (p.Type)
  3671. {
  3672. case 1: //Yimoogi
  3673. {
  3674. ob.Effects.Add(new Effect(Libraries.Magic2, 1310, 10, 500, ob));
  3675. break;
  3676. }
  3677. case 2: //RedFoxman
  3678. {
  3679. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.RedFoxman], 253, 10, 500, ob));
  3680. break;
  3681. }
  3682. case 4: //MutatedManWorm
  3683. {
  3684. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.MutatedManworm], 278, 7, 500, ob));
  3685. SoundManager.PlaySound(((ushort)Monster.MutatedManworm) * 10 + 7);
  3686. playDefaultSound = false;
  3687. break;
  3688. }
  3689. case 5: //WitchDoctor
  3690. {
  3691. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.WitchDoctor], 348, 20, 1000, ob));
  3692. SoundManager.PlaySound(((ushort)Monster.WitchDoctor) * 10 + 7);
  3693. playDefaultSound = false;
  3694. break;
  3695. }
  3696. case 6: //TurtleKing
  3697. {
  3698. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.TurtleKing], 956, 10, 500, ob));
  3699. break;
  3700. }
  3701. case 7: //Mandrill
  3702. {
  3703. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.Mandrill], 290, 10, 1000, ob));
  3704. SoundManager.PlaySound(((ushort)Monster.Mandrill) * 10 + 6);
  3705. playDefaultSound = false;
  3706. break;
  3707. }
  3708. case 8: //DarkCaptain
  3709. {
  3710. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.DarkCaptain], 1224, 10, 1000, ob));
  3711. SoundManager.PlaySound(((ushort)Monster.DarkCaptain) * 10 + 9);
  3712. playDefaultSound = false;
  3713. break;
  3714. }
  3715. case 9: //Doe
  3716. {
  3717. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.Doe], 208, 10, 1000, ob));
  3718. SoundManager.PlaySound(((ushort)Monster.Doe) * 10 + 7);
  3719. playDefaultSound = false;
  3720. break;
  3721. }
  3722. case 10: //HornedCommander
  3723. {
  3724. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.HornedCommander], 928, 10, 1000, ob));
  3725. SoundManager.PlaySound(8455);
  3726. playDefaultSound = false;
  3727. break;
  3728. }
  3729. case 11: //SnowWolfKing
  3730. {
  3731. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.SnowWolfKing], 571, 10, 1000, ob));
  3732. SoundManager.PlaySound(8455);
  3733. playDefaultSound = false;
  3734. break;
  3735. }
  3736. default:
  3737. {
  3738. ob.Effects.Add(new Effect(Libraries.Magic, 260, 10, 500, ob));
  3739. break;
  3740. }
  3741. }
  3742. if (p.ObjectID == User.ObjectID)
  3743. User.TargetID = User.LastTargetObjectId;
  3744. if (playDefaultSound)
  3745. SoundManager.PlaySound(SoundList.Teleport);
  3746. }
  3747. }
  3748. private void TeleportIn()
  3749. {
  3750. User.Effects.Add(new Effect(Libraries.Magic, 260, 10, 500, User));
  3751. SoundManager.PlaySound(SoundList.Teleport);
  3752. }
  3753. private void NPCGoods(S.NPCGoods p)
  3754. {
  3755. for (int i = 0; i < p.List.Count; i++)
  3756. {
  3757. p.List[i].Info = GetItemInfo(p.List[i].ItemIndex);
  3758. }
  3759. NPCRate = p.Rate;
  3760. NPCPanelType = p.Type;
  3761. HideAddedStoreStats = p.HideAddedStats;
  3762. if (!NPCDialog.Visible) return;
  3763. switch (NPCPanelType)
  3764. {
  3765. case PanelType.Buy:
  3766. NPCGoodsDialog.UsePearls = false;
  3767. NPCGoodsDialog.NewGoods(p.List);
  3768. NPCGoodsDialog.Show();
  3769. break;
  3770. case PanelType.BuySub:
  3771. NPCSubGoodsDialog.UsePearls = false;
  3772. NPCSubGoodsDialog.NewGoods(p.List);
  3773. NPCSubGoodsDialog.Show();
  3774. break;
  3775. case PanelType.Craft:
  3776. NPCCraftGoodsDialog.UsePearls = false;
  3777. NPCCraftGoodsDialog.NewGoods(p.List);
  3778. NPCCraftGoodsDialog.Show();
  3779. CraftDialog.Show();
  3780. break;
  3781. }
  3782. }
  3783. private void NPCPearlGoods(S.NPCPearlGoods p)
  3784. {
  3785. for (int i = 0; i < p.List.Count; i++)
  3786. {
  3787. p.List[i].Info = GetItemInfo(p.List[i].ItemIndex);
  3788. }
  3789. NPCRate = p.Rate;
  3790. NPCPanelType = p.Type;
  3791. if (!NPCDialog.Visible) return;
  3792. NPCGoodsDialog.UsePearls = true;
  3793. NPCGoodsDialog.NewGoods(p.List);
  3794. NPCGoodsDialog.Show();
  3795. }
  3796. private void NPCSell()
  3797. {
  3798. if (!NPCDialog.Visible) return;
  3799. NPCDropDialog.PType = PanelType.Sell;
  3800. NPCDropDialog.Show();
  3801. }
  3802. private void NPCRepair(S.NPCRepair p)
  3803. {
  3804. NPCRate = p.Rate;
  3805. if (!NPCDialog.Visible) return;
  3806. NPCDropDialog.PType = PanelType.Repair;
  3807. NPCDropDialog.Show();
  3808. }
  3809. private void NPCStorage()
  3810. {
  3811. if (NPCDialog.Visible)
  3812. StorageDialog.Show();
  3813. }
  3814. private void StorageUnlockResult(S.StorageUnlockResult p)
  3815. {
  3816. StorageDialog?.HandleStorageUnlockResult(p);
  3817. }
  3818. private void StoragePasswordResult(S.StoragePasswordResult p)
  3819. {
  3820. StorageDialog?.HandleStoragePasswordResult(p);
  3821. }
  3822. private void NPCRequestInput(S.NPCRequestInput p)
  3823. {
  3824. MirInputBox inputBox = new MirInputBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PleaseEnterRequiredInformation));
  3825. inputBox.OKButton.Click += (o1, e1) =>
  3826. {
  3827. Network.Enqueue(new C.NPCConfirmInput { Value = inputBox.InputTextBox.Text, NPCID = p.NPCID, PageName = p.PageName });
  3828. inputBox.Dispose();
  3829. };
  3830. inputBox.Show();
  3831. }
  3832. private void NPCSRepair(S.NPCSRepair p)
  3833. {
  3834. NPCRate = p.Rate;
  3835. if (!NPCDialog.Visible) return;
  3836. NPCDropDialog.PType = PanelType.SpecialRepair;
  3837. NPCDropDialog.Show();
  3838. }
  3839. private void NPCRefine(S.NPCRefine p)
  3840. {
  3841. NPCRate = p.Rate;
  3842. if (!NPCDialog.Visible) return;
  3843. NPCDropDialog.PType = PanelType.Refine;
  3844. if (p.Refining)
  3845. {
  3846. NPCDropDialog.Hide();
  3847. NPCDialog.Hide();
  3848. }
  3849. else
  3850. NPCDropDialog.Show();
  3851. }
  3852. private void NPCCheckRefine(S.NPCCheckRefine p)
  3853. {
  3854. if (!NPCDialog.Visible) return;
  3855. NPCDropDialog.PType = PanelType.CheckRefine;
  3856. NPCDropDialog.Show();
  3857. }
  3858. private void NPCCollectRefine(S.NPCCollectRefine p)
  3859. {
  3860. if (!NPCDialog.Visible) return;
  3861. NPCDialog.Hide();
  3862. }
  3863. private void NPCReplaceWedRing(S.NPCReplaceWedRing p)
  3864. {
  3865. if (!NPCDialog.Visible) return;
  3866. NPCRate = p.Rate;
  3867. NPCDropDialog.PType = PanelType.ReplaceWedRing;
  3868. NPCDropDialog.Show();
  3869. }
  3870. private void SellItem(S.SellItem p)
  3871. {
  3872. MirItemCell cell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  3873. if (cell == null) return;
  3874. cell.Locked = false;
  3875. if (!p.Success) return;
  3876. if (p.Count == cell.Item.Count)
  3877. cell.Item = null;
  3878. else
  3879. cell.Item.Count -= p.Count;
  3880. User.RefreshStats();
  3881. }
  3882. private void RepairItem(S.RepairItem p)
  3883. {
  3884. MirItemCell cell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  3885. if (cell == null) return;
  3886. cell.Locked = false;
  3887. }
  3888. private void CraftItem(S.CraftItem p)
  3889. {
  3890. if (!p.Success) return;
  3891. CraftDialog.UpdateCraftCells();
  3892. User.RefreshStats();
  3893. }
  3894. private void ItemRepaired(S.ItemRepaired p)
  3895. {
  3896. UserItem item = null;
  3897. for (int i = 0; i < User.Inventory.Length; i++)
  3898. {
  3899. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.UniqueID)
  3900. {
  3901. item = User.Inventory[i];
  3902. break;
  3903. }
  3904. }
  3905. if (item == null)
  3906. {
  3907. for (int i = 0; i < User.Equipment.Length; i++)
  3908. {
  3909. if (User.Equipment[i] != null && User.Equipment[i].UniqueID == p.UniqueID)
  3910. {
  3911. item = User.Equipment[i];
  3912. break;
  3913. }
  3914. }
  3915. }
  3916. if (Hero != null)
  3917. {
  3918. if (item == null)
  3919. {
  3920. for (int i = 0; i < Hero.Inventory.Length; i++)
  3921. {
  3922. if (Hero.Inventory[i] != null && Hero.Inventory[i].UniqueID == p.UniqueID)
  3923. {
  3924. item = Hero.Inventory[i];
  3925. break;
  3926. }
  3927. }
  3928. }
  3929. if (item == null)
  3930. {
  3931. for (int i = 0; i < Hero.Equipment.Length; i++)
  3932. {
  3933. if (Hero.Equipment[i] != null && Hero.Equipment[i].UniqueID == p.UniqueID)
  3934. {
  3935. item = Hero.Equipment[i];
  3936. break;
  3937. }
  3938. }
  3939. }
  3940. }
  3941. if (item == null) return;
  3942. item.MaxDura = p.MaxDura;
  3943. item.CurrentDura = p.CurrentDura;
  3944. if (HoverItem == item)
  3945. {
  3946. DisposeItemLabel();
  3947. CreateItemLabel(item);
  3948. }
  3949. }
  3950. private void ItemSlotSizeChanged(S.ItemSlotSizeChanged p)
  3951. {
  3952. UserItem item = null;
  3953. for (int i = 0; i < User.Inventory.Length; i++)
  3954. {
  3955. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.UniqueID)
  3956. {
  3957. item = User.Inventory[i];
  3958. break;
  3959. }
  3960. }
  3961. if (item == null)
  3962. {
  3963. for (int i = 0; i < User.Equipment.Length; i++)
  3964. {
  3965. if (User.Equipment[i] != null && User.Equipment[i].UniqueID == p.UniqueID)
  3966. {
  3967. item = User.Equipment[i];
  3968. break;
  3969. }
  3970. }
  3971. }
  3972. if (Hero != null)
  3973. {
  3974. if (item == null)
  3975. {
  3976. for (int i = 0; i < Hero.Inventory.Length; i++)
  3977. {
  3978. if (Hero.Inventory[i] != null && Hero.Inventory[i].UniqueID == p.UniqueID)
  3979. {
  3980. item = Hero.Inventory[i];
  3981. break;
  3982. }
  3983. }
  3984. }
  3985. if (item == null)
  3986. {
  3987. for (int i = 0; i < Hero.Equipment.Length; i++)
  3988. {
  3989. if (Hero.Equipment[i] != null && Hero.Equipment[i].UniqueID == p.UniqueID)
  3990. {
  3991. item = Hero.Equipment[i];
  3992. break;
  3993. }
  3994. }
  3995. }
  3996. }
  3997. if (item == null) return;
  3998. item.SetSlotSize(p.SlotSize);
  3999. }
  4000. private void ItemSealChanged(S.ItemSealChanged p)
  4001. {
  4002. UserItem item = null;
  4003. for (int i = 0; i < User.Inventory.Length; i++)
  4004. {
  4005. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.UniqueID)
  4006. {
  4007. item = User.Inventory[i];
  4008. break;
  4009. }
  4010. }
  4011. if (item == null)
  4012. {
  4013. for (int i = 0; i < User.Equipment.Length; i++)
  4014. {
  4015. if (User.Equipment[i] != null && User.Equipment[i].UniqueID == p.UniqueID)
  4016. {
  4017. item = User.Equipment[i];
  4018. break;
  4019. }
  4020. }
  4021. }
  4022. if (Hero != null)
  4023. {
  4024. if (item == null)
  4025. {
  4026. for (int i = 0; i < Hero.Inventory.Length; i++)
  4027. {
  4028. if (Hero.Inventory[i] != null && Hero.Inventory[i].UniqueID == p.UniqueID)
  4029. {
  4030. item = Hero.Inventory[i];
  4031. break;
  4032. }
  4033. }
  4034. }
  4035. if (item == null)
  4036. {
  4037. for (int i = 0; i < Hero.Equipment.Length; i++)
  4038. {
  4039. if (Hero.Equipment[i] != null && Hero.Equipment[i].UniqueID == p.UniqueID)
  4040. {
  4041. item = Hero.Equipment[i];
  4042. break;
  4043. }
  4044. }
  4045. }
  4046. }
  4047. if (item == null) return;
  4048. item.SealedInfo = new SealedInfo { ExpiryDate = p.ExpiryDate };
  4049. if (HoverItem == item)
  4050. {
  4051. DisposeItemLabel();
  4052. CreateItemLabel(item);
  4053. }
  4054. }
  4055. private void ItemUpgraded(S.ItemUpgraded p)
  4056. {
  4057. UserItem item = null;
  4058. MirGridType grid = MirGridType.Inventory;
  4059. for (int i = 0; i < User.Inventory.Length; i++)
  4060. {
  4061. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.Item.UniqueID)
  4062. {
  4063. item = User.Inventory[i];
  4064. break;
  4065. }
  4066. }
  4067. if (item == null && Hero != null)
  4068. {
  4069. for (int i = 0; i < Hero.Inventory.Length; i++)
  4070. {
  4071. if (Hero.Inventory[i] != null && Hero.Inventory[i].UniqueID == p.Item.UniqueID)
  4072. {
  4073. item = Hero.Inventory[i];
  4074. grid = MirGridType.HeroInventory;
  4075. break;
  4076. }
  4077. }
  4078. }
  4079. if (item == null) return;
  4080. item.AddedStats.Clear();
  4081. item.AddedStats.Add(p.Item.AddedStats);
  4082. item.MaxDura = p.Item.MaxDura;
  4083. item.RefineAdded = p.Item.RefineAdded;
  4084. switch (grid)
  4085. {
  4086. case MirGridType.Inventory:
  4087. InventoryDialog.DisplayItemGridEffect(item.UniqueID, 0);
  4088. break;
  4089. case MirGridType.HeroInventory:
  4090. HeroInventoryDialog.DisplayItemGridEffect(item.UniqueID, 0);
  4091. break;
  4092. }
  4093. if (HoverItem == item)
  4094. {
  4095. DisposeItemLabel();
  4096. CreateItemLabel(item);
  4097. }
  4098. }
  4099. private void NewMagic(S.NewMagic p)
  4100. {
  4101. ClientMagic magic = p.Magic;
  4102. UserObject actor = User;
  4103. if (p.Hero)
  4104. actor = Hero;
  4105. actor.Magics.Add(magic);
  4106. actor.RefreshStats();
  4107. foreach (SkillBarDialog Bar in SkillBarDialogs)
  4108. {
  4109. Bar.Update();
  4110. }
  4111. }
  4112. private void RemoveMagic(S.RemoveMagic p)
  4113. {
  4114. User.Magics.RemoveAt(p.PlaceId);
  4115. User.RefreshStats();
  4116. foreach (SkillBarDialog Bar in SkillBarDialogs)
  4117. {
  4118. Bar.Update();
  4119. }
  4120. }
  4121. private void MagicLeveled(S.MagicLeveled p)
  4122. {
  4123. UserObject actor = p.ObjectID == Hero?.ObjectID ? Hero : User;
  4124. for (int i = 0; i < actor.Magics.Count; i++)
  4125. {
  4126. ClientMagic magic = actor.Magics[i];
  4127. if (magic.Spell != p.Spell) continue;
  4128. if (magic.Level != p.Level)
  4129. {
  4130. magic.Level = p.Level;
  4131. actor.RefreshStats();
  4132. }
  4133. magic.Experience = p.Experience;
  4134. break;
  4135. }
  4136. }
  4137. private void Magic(S.Magic p)
  4138. {
  4139. User.Spell = p.Spell;
  4140. User.Cast = p.Cast;
  4141. User.TargetID = p.TargetID;
  4142. User.TargetPoint = p.Target;
  4143. User.SpellLevel = p.Level;
  4144. User.SecondaryTargetIDs = p.SecondaryTargetIDs;
  4145. if (!p.Cast) return;
  4146. ClientMagic magic = User.GetMagic(p.Spell);
  4147. magic.CastTime = CMain.Time;
  4148. }
  4149. private void MagicDelay(S.MagicDelay p)
  4150. {
  4151. ClientMagic magic;
  4152. if (p.ObjectID == Hero?.ObjectID)
  4153. magic = Hero.GetMagic(p.Spell);
  4154. else
  4155. magic = User.GetMagic(p.Spell);
  4156. magic.Delay = p.Delay;
  4157. }
  4158. private void MagicCast(S.MagicCast p)
  4159. {
  4160. ClientMagic magic = User.GetMagic(p.Spell);
  4161. magic.CastTime = CMain.Time;
  4162. }
  4163. private void ObjectMagic(S.ObjectMagic p)
  4164. {
  4165. if (p.SelfBroadcast == false && p.ObjectID == User.ObjectID && !Observing) return;
  4166. if (p.ObjectID == Hero?.ObjectID && p.Cast)
  4167. {
  4168. ClientMagic magic = Hero.GetMagic(p.Spell);
  4169. magic.CastTime = CMain.Time;
  4170. }
  4171. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4172. {
  4173. QueuedAction action = new QueuedAction { Action = MirAction.Spell, Direction = p.Direction, Location = p.Location, Params = new List<object>() };
  4174. action.Params.Add(p.Spell);
  4175. action.Params.Add(p.TargetID);
  4176. action.Params.Add(p.Target);
  4177. action.Params.Add(p.Cast);
  4178. action.Params.Add(p.Level);
  4179. action.Params.Add(p.SecondaryTargetIDs);
  4180. ob.ActionFeed.Add(action);
  4181. }
  4182. }
  4183. private void ObjectProjectile(S.ObjectProjectile p)
  4184. {
  4185. MapObject source = MapControl.GetObject(p.Source);
  4186. if (source == null) return;
  4187. switch (p.Spell)
  4188. {
  4189. case Spell.FireBounce:
  4190. {
  4191. SoundManager.PlaySound(20000 + (ushort)Spell.GreatFireBall * 10 + 1);
  4192. Missile missile = source.CreateProjectile(410, Libraries.Magic, true, 6, 30, 4, targetID: p.Destination);
  4193. if (missile.Target != null)
  4194. {
  4195. missile.Complete += (o, e) =>
  4196. {
  4197. var sender = (Missile)o;
  4198. if (sender.Target.CurrentAction == MirAction.Dead) return;
  4199. sender.Target.Effects.Add(new Effect(Libraries.Magic, 570, 10, 600, sender.Target));
  4200. SoundManager.PlaySound(20000 + (ushort)Spell.GreatFireBall * 10 + 2);
  4201. };
  4202. }
  4203. }
  4204. break;
  4205. }
  4206. }
  4207. private void ObjectEffect(S.ObjectEffect p)
  4208. {
  4209. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4210. {
  4211. PlayerObject player;
  4212. switch (p.Effect)
  4213. {
  4214. case SpellEffect.FurbolgWarriorCritical:
  4215. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.FurbolgWarrior], 400, 6, 600, ob));
  4216. SoundManager.PlaySound(20000 + (ushort)Spell.FatalSword * 10);
  4217. break;
  4218. case SpellEffect.FatalSword:
  4219. ob.Effects.Add(new Effect(Libraries.Magic2, 1940, 4, 400, ob));
  4220. SoundManager.PlaySound(20000 + (ushort)Spell.FatalSword * 10);
  4221. break;
  4222. case SpellEffect.StormEscape:
  4223. ob.Effects.Add(new Effect(Libraries.Magic3, 610, 10, 600, ob));
  4224. SoundManager.PlaySound(SoundList.Teleport);
  4225. break;
  4226. case SpellEffect.Teleport:
  4227. ob.Effects.Add(new Effect(Libraries.Magic, 1600, 10, 600, ob));
  4228. SoundManager.PlaySound(SoundList.Teleport);
  4229. break;
  4230. case SpellEffect.Healing:
  4231. SoundManager.PlaySound(20000 + (ushort)Spell.Healing * 10 + 1);
  4232. ob.Effects.Add(new Effect(Libraries.Magic, 370, 10, 800, ob));
  4233. break;
  4234. case SpellEffect.RedMoonEvil:
  4235. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.RedMoonEvil], 32, 6, 400, ob) { Blend = false });
  4236. break;
  4237. case SpellEffect.TwinDrakeBlade:
  4238. ob.Effects.Add(new Effect(Libraries.Magic2, 380, 6, 800, ob));
  4239. break;
  4240. case SpellEffect.MPEater:
  4241. if (MapControl.Objects.TryGetValue(p.EffectType, out var ob2))
  4242. ob2.Effects.Add(new Effect(Libraries.Magic2, 2411, 19, 1900, ob2));
  4243. ob.Effects.Add(new Effect(Libraries.Magic2, 2400, 9, 900, ob));
  4244. SoundManager.PlaySound(20000 + (ushort)Spell.FatalSword * 10);
  4245. break;
  4246. case SpellEffect.Bleeding:
  4247. ob.Effects.Add(new Effect(Libraries.Magic3, 60, 3, 400, ob));
  4248. break;
  4249. case SpellEffect.Hemorrhage:
  4250. SoundManager.PlaySound(20000 + (ushort)Spell.Hemorrhage * 10);
  4251. ob.Effects.Add(new Effect(Libraries.Magic3, 0, 4, 400, ob));
  4252. ob.Effects.Add(new Effect(Libraries.Magic3, 28, 6, 600, ob));
  4253. ob.Effects.Add(new Effect(Libraries.Magic3, 46, 8, 800, ob));
  4254. break;
  4255. case SpellEffect.MagicShieldUp:
  4256. if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Hero) return;
  4257. player = (PlayerObject)ob;
  4258. if (player.ShieldEffect != null)
  4259. {
  4260. player.ShieldEffect.Clear();
  4261. player.ShieldEffect.Remove();
  4262. }
  4263. player.MagicShield = true;
  4264. player.Effects.Add(player.ShieldEffect = new Effect(Libraries.Magic, 3890, 3, 600, ob) { Repeat = true });
  4265. break;
  4266. case SpellEffect.MagicShieldDown:
  4267. if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Hero) return;
  4268. player = (PlayerObject)ob;
  4269. if (player.ShieldEffect != null)
  4270. {
  4271. player.ShieldEffect.Clear();
  4272. player.ShieldEffect.Remove();
  4273. }
  4274. player.ShieldEffect = null;
  4275. player.MagicShield = false;
  4276. break;
  4277. case SpellEffect.GreatFoxSpirit:
  4278. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.GreatFoxSpirit], 375 + (CMain.Random.Next(3) * 20), 20, 1400, ob));
  4279. SoundManager.PlaySound(((ushort)Monster.GreatFoxSpirit * 10) + 5);
  4280. break;
  4281. case SpellEffect.Entrapment:
  4282. ob.Effects.Add(new Effect(Libraries.Magic2, 1010, 10, 1500, ob));
  4283. ob.Effects.Add(new Effect(Libraries.Magic2, 1020, 8, 1200, ob));
  4284. break;
  4285. case SpellEffect.Critical:
  4286. //ob.Effects.Add(new Effect(Libraries.CustomEffects, 0, 12, 60, ob));
  4287. break;
  4288. case SpellEffect.Reflect:
  4289. ob.Effects.Add(new Effect(Libraries.Effect, 580, 10, 70, ob));
  4290. break;
  4291. case SpellEffect.ElementalBarrierUp:
  4292. if (ob.Race != ObjectType.Player) return;
  4293. player = (PlayerObject)ob;
  4294. if (player.ElementalBarrierEffect != null)
  4295. {
  4296. player.ElementalBarrierEffect.Clear();
  4297. player.ElementalBarrierEffect.Remove();
  4298. }
  4299. player.ElementalBarrier = true;
  4300. player.Effects.Add(player.ElementalBarrierEffect = new Effect(Libraries.Magic3, 1890, 10, 2000, ob) { Repeat = true });
  4301. break;
  4302. case SpellEffect.ElementalBarrierDown:
  4303. if (ob.Race != ObjectType.Player) return;
  4304. player = (PlayerObject)ob;
  4305. if (player.ElementalBarrierEffect != null)
  4306. {
  4307. player.ElementalBarrierEffect.Clear();
  4308. player.ElementalBarrierEffect.Remove();
  4309. }
  4310. player.ElementalBarrierEffect = null;
  4311. player.ElementalBarrier = false;
  4312. player.Effects.Add(player.ElementalBarrierEffect = new Effect(Libraries.Magic3, 1910, 7, 1400, ob));
  4313. SoundManager.PlaySound(20000 + 131 * 10 + 5);
  4314. break;
  4315. case SpellEffect.DelayedExplosion:
  4316. int effectid = DelayedExplosionEffect.GetOwnerEffectID(ob.ObjectID);
  4317. if (effectid < 0)
  4318. {
  4319. ob.Effects.Add(new DelayedExplosionEffect(Libraries.Magic3, 1590, 8, 1200, ob, true, 0, 0));
  4320. }
  4321. else if (effectid >= 0)
  4322. {
  4323. if (DelayedExplosionEffect.effectlist[effectid].stage < p.EffectType)
  4324. {
  4325. DelayedExplosionEffect.effectlist[effectid].Remove();
  4326. ob.Effects.Add(new DelayedExplosionEffect(Libraries.Magic3, 1590 + ((int)p.EffectType * 10), 8, 1200, ob, true, (int)p.EffectType, 0));
  4327. }
  4328. }
  4329. break;
  4330. case SpellEffect.AwakeningSuccess:
  4331. {
  4332. Effect ef = new Effect(Libraries.Magic3, 900, 16, 1600, ob, CMain.Time + p.DelayTime);
  4333. ef.Played += (o, e) => SoundManager.PlaySound(50002);
  4334. ef.Complete += (o, e) => MapControl.AwakeningAction = false;
  4335. ob.Effects.Add(ef);
  4336. ob.Effects.Add(new Effect(Libraries.Magic3, 840, 16, 1600, ob, CMain.Time + p.DelayTime) { Blend = false });
  4337. }
  4338. break;
  4339. case SpellEffect.AwakeningFail:
  4340. {
  4341. Effect ef = new Effect(Libraries.Magic3, 920, 9, 900, ob, CMain.Time + p.DelayTime);
  4342. ef.Played += (o, e) => SoundManager.PlaySound(50003);
  4343. ef.Complete += (o, e) => MapControl.AwakeningAction = false;
  4344. ob.Effects.Add(ef);
  4345. ob.Effects.Add(new Effect(Libraries.Magic3, 860, 9, 900, ob, CMain.Time + p.DelayTime) { Blend = false });
  4346. }
  4347. break;
  4348. case SpellEffect.AwakeningHit:
  4349. {
  4350. Effect ef = new Effect(Libraries.Magic3, 880, 5, 500, ob, CMain.Time + p.DelayTime);
  4351. ef.Played += (o, e) => SoundManager.PlaySound(50001);
  4352. ob.Effects.Add(ef);
  4353. ob.Effects.Add(new Effect(Libraries.Magic3, 820, 5, 500, ob, CMain.Time + p.DelayTime) { Blend = false });
  4354. }
  4355. break;
  4356. case SpellEffect.AwakeningMiss:
  4357. {
  4358. Effect ef = new Effect(Libraries.Magic3, 890, 5, 500, ob, CMain.Time + p.DelayTime);
  4359. ef.Played += (o, e) => SoundManager.PlaySound(50000);
  4360. ob.Effects.Add(ef);
  4361. ob.Effects.Add(new Effect(Libraries.Magic3, 830, 5, 500, ob, CMain.Time + p.DelayTime) { Blend = false });
  4362. }
  4363. break;
  4364. case SpellEffect.TurtleKing:
  4365. {
  4366. Effect ef = new Effect(Libraries.Monsters[(ushort)Monster.TurtleKing], CMain.Random.Next(2) == 0 ? 922 : 934, 12, 1200, ob);
  4367. ef.Played += (o, e) => SoundManager.PlaySound(20000 + (ushort)Spell.HellFire * 10 + 1);
  4368. ob.Effects.Add(ef);
  4369. }
  4370. break;
  4371. case SpellEffect.Behemoth:
  4372. {
  4373. MapControl.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.Behemoth], 788, 10, 1500, ob.CurrentLocation));
  4374. MapControl.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.Behemoth], 778, 10, 1500, ob.CurrentLocation, 0, true) { Blend = false });
  4375. }
  4376. break;
  4377. case SpellEffect.Stunned:
  4378. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.StoningStatue], 632, 10, 1000, ob)
  4379. {
  4380. Repeat = p.Time > 0,
  4381. RepeatUntil = p.Time > 0 ? CMain.Time + p.Time : 0
  4382. });
  4383. break;
  4384. case SpellEffect.IcePillar:
  4385. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.IcePillar], 18, 8, 800, ob));
  4386. break;
  4387. case SpellEffect.KingGuard:
  4388. if (p.EffectType == 0)
  4389. {
  4390. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.KingGuard], 753, 10, 1000, ob) { Blend = false });
  4391. }
  4392. else
  4393. {
  4394. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.KingGuard], 763, 10, 1000, ob) { Blend = false });
  4395. }
  4396. break;
  4397. case SpellEffect.FlamingMutantWeb:
  4398. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.FlamingMutant], 330, 10, 1000, ob)
  4399. {
  4400. Repeat = p.Time > 0,
  4401. RepeatUntil = p.Time > 0 ? CMain.Time + p.Time : 0
  4402. });
  4403. break;
  4404. case SpellEffect.DeathCrawlerBreath:
  4405. ob.Effects.Add(new Effect(Libraries.Monsters[(ushort)Monster.DeathCrawler], 272 + ((int)ob.Direction * 4), 4, 400, ob) { Blend = true });
  4406. break;
  4407. case SpellEffect.MoonMist:
  4408. ob.Effects.Add(new Effect(Libraries.Magic3, 705, 10, 800, ob));
  4409. break;
  4410. }
  4411. }
  4412. }
  4413. private void RangeAttack(S.RangeAttack p)
  4414. {
  4415. User.TargetID = p.TargetID;
  4416. User.TargetPoint = p.Target;
  4417. User.Spell = p.Spell;
  4418. }
  4419. private void Pushed(S.Pushed p)
  4420. {
  4421. User.ActionFeed.Add(new QueuedAction { Action = MirAction.Pushed, Direction = p.Direction, Location = p.Location });
  4422. }
  4423. private void ObjectPushed(S.ObjectPushed p)
  4424. {
  4425. if (p.ObjectID == User.ObjectID) return;
  4426. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4427. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Pushed, Direction = p.Direction, Location = p.Location });
  4428. }
  4429. private void ObjectName(S.ObjectName p)
  4430. {
  4431. if (p.ObjectID == User.ObjectID) return;
  4432. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4433. ob.Name = p.Name;
  4434. }
  4435. private void UserStorage(S.UserStorage p)
  4436. {
  4437. if (Storage.Length != p.Storage.Length)
  4438. {
  4439. Array.Resize(ref Storage, p.Storage.Length);
  4440. }
  4441. Storage = p.Storage;
  4442. for (int i = 0; i < Storage.Length; i++)
  4443. {
  4444. if (Storage[i] == null) continue;
  4445. Bind(Storage[i]);
  4446. }
  4447. }
  4448. private void SwitchGroup(S.SwitchGroup p)
  4449. {
  4450. GroupDialog.AllowGroup = p.AllowGroup;
  4451. if (!p.AllowGroup && GroupDialog.GroupList.Count > 0)
  4452. DeleteGroup();
  4453. }
  4454. private void DeleteGroup()
  4455. {
  4456. GroupDialog.GroupList.Clear();
  4457. GroupDialog.GroupMembersMap.Clear();
  4458. BigMapViewPort.PlayerLocations.Clear();
  4459. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouHaveLeftGroup), ChatType.Group);
  4460. }
  4461. private void DeleteMember(S.DeleteMember p)
  4462. {
  4463. GroupDialog.GroupList.Remove(p.Name);
  4464. GroupDialog.GroupMembersMap.Remove(p.Name);
  4465. BigMapViewPort.PlayerLocations.Remove(p.Name);
  4466. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerHasLeftGroup), p.Name), ChatType.Group);
  4467. }
  4468. private void GroupInvite(S.GroupInvite p)
  4469. {
  4470. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DoYouWantGroupWithPlayer), p.Name), MirMessageBoxButtons.YesNo);
  4471. messageBox.YesButton.Click += (o, e) =>
  4472. {
  4473. Network.Enqueue(new C.GroupInvite { AcceptInvite = true });
  4474. GroupDialog.Show();
  4475. };
  4476. messageBox.NoButton.Click += (o, e) => Network.Enqueue(new C.GroupInvite { AcceptInvite = false });
  4477. messageBox.Show();
  4478. }
  4479. private void AddMember(S.AddMember p)
  4480. {
  4481. GroupDialog.GroupList.Add(p.Name);
  4482. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerHasJoinedGroup), p.Name), ChatType.Group);
  4483. }
  4484. private void GroupMembersMap(S.GroupMembersMap p)
  4485. {
  4486. if (!GroupDialog.GroupMembersMap.ContainsKey(p.PlayerName))
  4487. GroupDialog.GroupMembersMap.Add(p.PlayerName, p.PlayerMap);
  4488. else
  4489. {
  4490. GroupDialog.GroupMembersMap.Remove(p.PlayerName);
  4491. GroupDialog.GroupMembersMap.Add(p.PlayerName, p.PlayerMap);
  4492. }
  4493. }
  4494. private void SendMemberLocation(S.SendMemberLocation p)
  4495. {
  4496. if (!BigMapViewPort.PlayerLocations.ContainsKey(p.MemberName))
  4497. BigMapViewPort.PlayerLocations.Add(p.MemberName, p.MemberLocation);
  4498. else
  4499. {
  4500. BigMapViewPort.PlayerLocations.Remove(p.MemberName);
  4501. BigMapViewPort.PlayerLocations.Add(p.MemberName, p.MemberLocation);
  4502. }
  4503. }
  4504. private void Revived()
  4505. {
  4506. User.SetAction();
  4507. User.Dead = false;
  4508. User.Effects.Add(new Effect(Libraries.Magic2, 1220, 20, 2000, User));
  4509. SoundManager.PlaySound(SoundList.Revive);
  4510. }
  4511. private void ObjectRevived(S.ObjectRevived p)
  4512. {
  4513. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4514. {
  4515. if (p.Effect)
  4516. {
  4517. ob.Effects.Add(new Effect(Libraries.Magic2, 1220, 20, 2000, ob));
  4518. SoundManager.PlaySound(SoundList.Revive);
  4519. }
  4520. ob.Dead = false;
  4521. ob.ActionFeed.Clear();
  4522. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Revive, Direction = ob.Direction, Location = ob.CurrentLocation });
  4523. }
  4524. }
  4525. private void SpellToggle(S.SpellToggle p)
  4526. {
  4527. UserObject actor = User;
  4528. string prefix = string.Empty;
  4529. if (p.ObjectID == Hero?.ObjectID)
  4530. {
  4531. actor = Hero;
  4532. prefix = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Hero);
  4533. }
  4534. switch (p.Spell)
  4535. {
  4536. //Warrior
  4537. case Spell.Slaying:
  4538. actor.Slaying = p.CanUse;
  4539. break;
  4540. case Spell.Thrusting:
  4541. actor.Thrusting = p.CanUse;
  4542. ChatDialog.ReceiveChat(
  4543. prefix + (actor.Thrusting ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseThrusting) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseThrusting)),
  4544. ChatType.Hint);
  4545. break;
  4546. case Spell.HalfMoon:
  4547. actor.HalfMoon = p.CanUse;
  4548. ChatDialog.ReceiveChat(
  4549. prefix + (actor.HalfMoon ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseHalfMoon) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseHalfMoon)),
  4550. ChatType.Hint);
  4551. break;
  4552. case Spell.CrossHalfMoon:
  4553. actor.CrossHalfMoon = p.CanUse;
  4554. ChatDialog.ReceiveChat(
  4555. prefix + (actor.CrossHalfMoon ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseCrossHalfMoon) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseCrossHalfMoon)),
  4556. ChatType.Hint);
  4557. break;
  4558. case Spell.DoubleSlash:
  4559. actor.DoubleSlash = p.CanUse;
  4560. ChatDialog.ReceiveChat(
  4561. prefix + (actor.DoubleSlash ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UseDoubleSlash) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DoNotUseDoubleSlash)),
  4562. ChatType.Hint);
  4563. break;
  4564. case Spell.FlamingSword:
  4565. actor.FlamingSword = p.CanUse;
  4566. if (actor.FlamingSword)
  4567. ChatDialog.ReceiveChat(prefix + GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.WeaponSpiritFire), ChatType.Hint);
  4568. else
  4569. ChatDialog.ReceiveChat(prefix + GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SpiritsFireDisappeared), ChatType.System);
  4570. break;
  4571. }
  4572. }
  4573. private void ObjectHealth(S.ObjectHealth p)
  4574. {
  4575. if (p.ObjectID == Hero?.ObjectID)
  4576. Hero.PercentHealth = p.Percent;
  4577. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4578. {
  4579. ob.PercentHealth = p.Percent;
  4580. ob.HealthTime = CMain.Time + p.Expire * 1000;
  4581. }
  4582. }
  4583. private void ObjectMana(S.ObjectMana p)
  4584. {
  4585. if (p.ObjectID == Hero?.ObjectID)
  4586. Hero.PercentMana = p.Percent;
  4587. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4588. ob.PercentMana = p.Percent;
  4589. }
  4590. private void MapEffect(S.MapEffect p)
  4591. {
  4592. switch (p.Effect)
  4593. {
  4594. case SpellEffect.Mine:
  4595. SoundManager.PlaySound(10091);
  4596. Effect HitWall = new Effect(Libraries.Effect, 8 * p.Value, 3, 240, p.Location) { Light = 0 };
  4597. MapControl.Effects.Add(HitWall);
  4598. break;
  4599. case SpellEffect.Tester:
  4600. Effect eff = new Effect(Libraries.Effect, 328, 10, 500, p.Location) { Light = 0 };
  4601. MapControl.Effects.Add(eff);
  4602. break;
  4603. }
  4604. }
  4605. private void ObjectRangeAttack(S.ObjectRangeAttack p)
  4606. {
  4607. if (p.ObjectID == User.ObjectID && !Observing) return;
  4608. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4609. {
  4610. QueuedAction action = null;
  4611. if (ob.Race == ObjectType.Player)
  4612. {
  4613. action = p.Type switch
  4614. {
  4615. _ => new QueuedAction { Action = MirAction.AttackRange1, Direction = p.Direction, Location = p.Location, Params = new List<object>() }
  4616. };
  4617. }
  4618. else
  4619. {
  4620. action = p.Type switch
  4621. {
  4622. 1 => new QueuedAction { Action = MirAction.AttackRange2, Direction = p.Direction, Location = p.Location, Params = new List<object>() },
  4623. 2 => new QueuedAction { Action = MirAction.AttackRange3, Direction = p.Direction, Location = p.Location, Params = new List<object>() },
  4624. _ => new QueuedAction { Action = MirAction.AttackRange1, Direction = p.Direction, Location = p.Location, Params = new List<object>() }
  4625. };
  4626. }
  4627. action.Params.Add(p.TargetID);
  4628. action.Params.Add(p.Target);
  4629. action.Params.Add(p.Spell);
  4630. action.Params.Add(new List<uint>());
  4631. action.Params.Add(p.Level);
  4632. ob.ActionFeed.Add(action);
  4633. }
  4634. }
  4635. private void AddBuff(S.AddBuff p)
  4636. {
  4637. ClientBuff buff = p.Buff;
  4638. if (!buff.Paused)
  4639. {
  4640. buff.ExpireTime += CMain.Time;
  4641. }
  4642. if (buff.ObjectID == User.ObjectID)
  4643. {
  4644. for (int i = 0; i < BuffsDialog.Buffs.Count; i++)
  4645. {
  4646. if (BuffsDialog.Buffs[i].Type != buff.Type) continue;
  4647. BuffsDialog.Buffs[i] = buff;
  4648. User.RefreshStats();
  4649. return;
  4650. }
  4651. BuffsDialog.Buffs.Add(buff);
  4652. BuffsDialog.CreateBuff(buff);
  4653. User.RefreshStats();
  4654. }
  4655. if (Hero != null && buff.ObjectID == Hero.ObjectID)
  4656. {
  4657. for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++)
  4658. {
  4659. if (HeroBuffsDialog.Buffs[i].Type != buff.Type) continue;
  4660. HeroBuffsDialog.Buffs[i] = buff;
  4661. Hero.RefreshStats();
  4662. return;
  4663. }
  4664. HeroBuffsDialog.Buffs.Add(buff);
  4665. HeroBuffsDialog.CreateBuff(buff);
  4666. Hero.RefreshStats();
  4667. }
  4668. if (!buff.Visible || buff.ObjectID <= 0) return;
  4669. if (MapControl.Objects.TryGetValue(buff.ObjectID, out var ob) && (ob is PlayerObject || ob is MonsterObject))
  4670. {
  4671. if (!ob.Buffs.Contains(buff.Type))
  4672. ob.Buffs.Add(buff.Type);
  4673. ob.AddBuffEffect(buff.Type);
  4674. }
  4675. }
  4676. private void RemoveBuff(S.RemoveBuff p)
  4677. {
  4678. if (User.ObjectID == p.ObjectID)
  4679. {
  4680. for (int i = 0; i < BuffsDialog.Buffs.Count; i++)
  4681. {
  4682. if (BuffsDialog.Buffs[i].Type != p.Type) continue;
  4683. switch (BuffsDialog.Buffs[i].Type)
  4684. {
  4685. case BuffType.SwiftFeet:
  4686. User.Sprint = false;
  4687. break;
  4688. case BuffType.Transform:
  4689. User.TransformType = -1;
  4690. break;
  4691. }
  4692. BuffsDialog.RemoveBuff(i);
  4693. BuffsDialog.Buffs.RemoveAt(i);
  4694. }
  4695. User.RefreshStats();
  4696. }
  4697. if (Hero != null && Hero.ObjectID == p.ObjectID)
  4698. {
  4699. for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++)
  4700. {
  4701. if (HeroBuffsDialog.Buffs[i].Type != p.Type) continue;
  4702. switch (HeroBuffsDialog.Buffs[i].Type)
  4703. {
  4704. case BuffType.SwiftFeet:
  4705. Hero.Sprint = false;
  4706. break;
  4707. case BuffType.Transform:
  4708. Hero.TransformType = -1;
  4709. break;
  4710. }
  4711. HeroBuffsDialog.RemoveBuff(i);
  4712. HeroBuffsDialog.Buffs.RemoveAt(i);
  4713. }
  4714. Hero.RefreshStats();
  4715. }
  4716. if (p.ObjectID <= 0) return;
  4717. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4718. {
  4719. ob.Buffs.Remove(p.Type);
  4720. ob.RemoveBuffEffect(p.Type);
  4721. }
  4722. }
  4723. private void PauseBuff(S.PauseBuff p)
  4724. {
  4725. if (User.ObjectID == p.ObjectID)
  4726. {
  4727. for (int i = 0; i < BuffsDialog.Buffs.Count; i++)
  4728. {
  4729. if (BuffsDialog.Buffs[i].Type != p.Type) continue;
  4730. User.RefreshStats();
  4731. if (BuffsDialog.Buffs[i].Paused == p.Paused) return;
  4732. BuffsDialog.Buffs[i].Paused = p.Paused;
  4733. if (p.Paused)
  4734. {
  4735. BuffsDialog.Buffs[i].ExpireTime -= CMain.Time;
  4736. }
  4737. else
  4738. {
  4739. BuffsDialog.Buffs[i].ExpireTime += CMain.Time;
  4740. }
  4741. }
  4742. }
  4743. if (Hero != null && Hero.ObjectID == p.ObjectID)
  4744. {
  4745. for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++)
  4746. {
  4747. if (HeroBuffsDialog.Buffs[i].Type != p.Type) continue;
  4748. Hero.RefreshStats();
  4749. if (HeroBuffsDialog.Buffs[i].Paused == p.Paused) return;
  4750. HeroBuffsDialog.Buffs[i].Paused = p.Paused;
  4751. if (p.Paused)
  4752. {
  4753. HeroBuffsDialog.Buffs[i].ExpireTime -= CMain.Time;
  4754. }
  4755. else
  4756. {
  4757. HeroBuffsDialog.Buffs[i].ExpireTime += CMain.Time;
  4758. }
  4759. }
  4760. }
  4761. }
  4762. private void ObjectHidden(S.ObjectHidden p)
  4763. {
  4764. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4765. ob.Hidden = p.Hidden;
  4766. }
  4767. private void ObjectSneaking(S.ObjectSneaking p)
  4768. {
  4769. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4770. {
  4771. // ob.SneakingActive = p.SneakingActive;
  4772. }
  4773. }
  4774. private void ObjectLevelEffects(S.ObjectLevelEffects p)
  4775. {
  4776. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && ob is PlayerObject player)
  4777. {
  4778. player.LevelEffects = p.LevelEffects;
  4779. player.SetEffects();
  4780. }
  4781. }
  4782. private void RefreshItem(S.RefreshItem p)
  4783. {
  4784. Bind(p.Item);
  4785. if (SelectedCell != null && SelectedCell.Item.UniqueID == p.Item.UniqueID)
  4786. SelectedCell = null;
  4787. if (HoverItem != null && HoverItem.UniqueID == p.Item.UniqueID)
  4788. {
  4789. DisposeItemLabel();
  4790. CreateItemLabel(p.Item);
  4791. }
  4792. for (int i = 0; i < User.Inventory.Length; i++)
  4793. {
  4794. if (User.Inventory[i] != null && User.Inventory[i].UniqueID == p.Item.UniqueID)
  4795. {
  4796. User.Inventory[i] = p.Item;
  4797. User.RefreshStats();
  4798. return;
  4799. }
  4800. }
  4801. for (int i = 0; i < User.Equipment.Length; i++)
  4802. {
  4803. if (User.Equipment[i] != null && User.Equipment[i].UniqueID == p.Item.UniqueID)
  4804. {
  4805. User.Equipment[i] = p.Item;
  4806. User.RefreshStats();
  4807. return;
  4808. }
  4809. }
  4810. if (Hero != null)
  4811. {
  4812. for (int i = 0; i < Hero.Inventory.Length; i++)
  4813. {
  4814. if (Hero.Inventory[i] != null && Hero.Inventory[i].UniqueID == p.Item.UniqueID)
  4815. {
  4816. Hero.Inventory[i] = p.Item;
  4817. Hero.RefreshStats();
  4818. return;
  4819. }
  4820. }
  4821. for (int i = 0; i < Hero.Equipment.Length; i++)
  4822. {
  4823. if (Hero.Equipment[i] != null && Hero.Equipment[i].UniqueID == p.Item.UniqueID)
  4824. {
  4825. Hero.Equipment[i] = p.Item;
  4826. Hero.RefreshStats();
  4827. return;
  4828. }
  4829. }
  4830. }
  4831. }
  4832. private void ObjectSpell(S.ObjectSpell p)
  4833. {
  4834. SpellObject ob = new SpellObject(p.ObjectID);
  4835. ob.Load(p);
  4836. }
  4837. private void ObjectDeco(S.ObjectDeco p)
  4838. {
  4839. DecoObject ob = new DecoObject(p.ObjectID);
  4840. ob.Load(p);
  4841. }
  4842. private void UserDash(S.UserDash p)
  4843. {
  4844. if (User.Direction == p.Direction && User.CurrentLocation == p.Location)
  4845. {
  4846. MapControl.NextAction = 0;
  4847. return;
  4848. }
  4849. MirAction action = User.CurrentAction == MirAction.DashL ? MirAction.DashR : MirAction.DashL;
  4850. for (int i = User.ActionFeed.Count - 1; i >= 0; i--)
  4851. {
  4852. if (User.ActionFeed[i].Action == MirAction.DashR)
  4853. {
  4854. action = MirAction.DashL;
  4855. break;
  4856. }
  4857. if (User.ActionFeed[i].Action == MirAction.DashL)
  4858. {
  4859. action = MirAction.DashR;
  4860. break;
  4861. }
  4862. }
  4863. User.ActionFeed.Add(new QueuedAction { Action = action, Direction = p.Direction, Location = p.Location });
  4864. }
  4865. private void UserDashFail(S.UserDashFail p)
  4866. {
  4867. MapControl.NextAction = 0;
  4868. User.ActionFeed.Add(new QueuedAction { Action = MirAction.DashFail, Direction = p.Direction, Location = p.Location });
  4869. }
  4870. private void ObjectDash(S.ObjectDash p)
  4871. {
  4872. if (p.ObjectID == User.ObjectID) return;
  4873. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4874. {
  4875. var action = ob.ActionFeed.Count > 0 && ob.ActionFeed[^1].Action == MirAction.DashL ? MirAction.DashR : MirAction.DashL;
  4876. ob.ActionFeed.Add(new QueuedAction { Action = action, Direction = p.Direction, Location = p.Location });
  4877. }
  4878. }
  4879. private void ObjectDashFail(S.ObjectDashFail p)
  4880. {
  4881. if (p.ObjectID == User.ObjectID) return;
  4882. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4883. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.DashFail, Direction = p.Direction, Location = p.Location });
  4884. }
  4885. private void UserBackStep(S.UserBackStep p)
  4886. {
  4887. if (User.Direction == p.Direction && User.CurrentLocation == p.Location)
  4888. {
  4889. MapControl.NextAction = 0;
  4890. return;
  4891. }
  4892. User.ActionFeed.Add(new QueuedAction { Action = MirAction.Jump, Direction = p.Direction, Location = p.Location });
  4893. }
  4894. private void ObjectBackStep(S.ObjectBackStep p)
  4895. {
  4896. if (p.ObjectID == User.ObjectID) return;
  4897. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4898. {
  4899. ob.JumpDistance = p.Distance;
  4900. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.Jump, Direction = p.Direction, Location = p.Location });
  4901. }
  4902. }
  4903. private void UserDashAttack(S.UserDashAttack p)
  4904. {
  4905. if (User.Direction == p.Direction && User.CurrentLocation == p.Location)
  4906. {
  4907. MapControl.NextAction = 0;
  4908. return;
  4909. }
  4910. //User.JumpDistance = p.Distance;
  4911. User.ActionFeed.Add(new QueuedAction { Action = MirAction.DashAttack, Direction = p.Direction, Location = p.Location });
  4912. }
  4913. private void ObjectDashAttack(S.ObjectDashAttack p)
  4914. {
  4915. if (p.ObjectID == User.ObjectID) return;
  4916. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob))
  4917. {
  4918. ob.JumpDistance = p.Distance;
  4919. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.DashAttack, Direction = p.Direction, Location = p.Location });
  4920. }
  4921. }
  4922. private void UserAttackMove(S.UserAttackMove p)//Warrior Skill - SlashingBurst
  4923. {
  4924. MapControl.NextAction = 0;
  4925. if (User.CurrentLocation == p.Location && User.Direction == p.Direction) return;
  4926. MapControl.RemoveObject(User);
  4927. User.CurrentLocation = p.Location;
  4928. User.MapLocation = p.Location;
  4929. MapControl.AddObject(User);
  4930. MapControl.FloorValid = false;
  4931. MapControl.InputDelay = CMain.Time + 400;
  4932. if (User.Dead) return;
  4933. User.ClearMagic();
  4934. User.QueuedAction = null;
  4935. for (int i = User.ActionFeed.Count - 1; i >= 0; i--)
  4936. {
  4937. if (User.ActionFeed[i].Action == MirAction.Pushed) continue;
  4938. User.ActionFeed.RemoveAt(i);
  4939. }
  4940. User.SetAction();
  4941. User.ActionFeed.Add(new QueuedAction { Action = MirAction.Standing, Direction = p.Direction, Location = p.Location });
  4942. }
  4943. private void SetConcentration(S.SetConcentration p)
  4944. {
  4945. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && (ob.Race == ObjectType.Player || ob.Race == ObjectType.Hero))
  4946. {
  4947. var player = (PlayerObject)ob;
  4948. player.Concentrating = p.Enabled;
  4949. player.ConcentrateInterrupted = p.Interrupted;
  4950. if (p.Enabled && !p.Interrupted && InterruptionEffect.GetOwnerEffectID(player.ObjectID) < 0)
  4951. {
  4952. player.Effects.Add(new InterruptionEffect(Libraries.Magic3, 1860, 8, 8 * 100, player, true));
  4953. SoundManager.PlaySound(20000 + 129 * 10);
  4954. }
  4955. }
  4956. }
  4957. private void SetElemental(S.SetElemental p)
  4958. {
  4959. if (MapControl.Objects.TryGetValue(p.ObjectID, out var ob) && (ob.Race == ObjectType.Player || ob.Race == ObjectType.Hero))
  4960. {
  4961. var player = (PlayerObject)ob;
  4962. player.HasElements = p.Enabled;
  4963. player.ElementCasted = p.Casted && User.ObjectID != p.ObjectID;
  4964. player.ElementsLevel = (int)p.Value;
  4965. if (p.Enabled && p.ElementType > 0)
  4966. {
  4967. int elementType = (int)p.ElementType;
  4968. int maxExp = (int)p.ExpLast;
  4969. player.Effects.Add(new ElementsEffect(Libraries.Magic3, 1630 + ((elementType - 1) * 10), 10, 10 * 100, player, true, 1 + (elementType - 1), maxExp, User.ObjectID == p.ObjectID && (elementType == 4 || elementType == 3)));
  4970. }
  4971. }
  4972. }
  4973. private void RemoveDelayedExplosion(S.RemoveDelayedExplosion p)
  4974. {
  4975. //if (p.ObjectID == User.ObjectID) return;
  4976. int effectid = DelayedExplosionEffect.GetOwnerEffectID(p.ObjectID);
  4977. if (effectid >= 0)
  4978. DelayedExplosionEffect.effectlist[effectid].Remove();
  4979. }
  4980. private void SetBindingShot(S.SetBindingShot p)
  4981. {
  4982. if (p.ObjectID == User.ObjectID) return;
  4983. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob) && ob.Race == ObjectType.Monster)
  4984. {
  4985. var NetCast = new TrackableEffect(new Effect(Libraries.MagicC, 0, 8, 700, ob)) { EffectName = "BindingShotDrop" };
  4986. var NetDropped = new TrackableEffect(new Effect(Libraries.MagicC, 7, 1, 1000, ob) { Repeat = true, RepeatUntil = CMain.Time + (p.Value - 1500) }) { EffectName = "BindingShotDown" };
  4987. var NetFall = new TrackableEffect(new Effect(Libraries.MagicC, 8, 8, 700, ob)) { EffectName = "BindingShotFall" };
  4988. NetDropped.Complete += (o1, e1) =>
  4989. {
  4990. SoundManager.PlaySound(20000 + 130 * 10 + 6); // sound M130-6
  4991. ob.Effects.Add(NetFall);
  4992. };
  4993. NetCast.Complete += (o, e) =>
  4994. {
  4995. SoundManager.PlaySound(20000 + 130 * 10 + 5); // sound M130-5
  4996. ob.Effects.Add(NetDropped);
  4997. };
  4998. ob.Effects.Add(NetCast);
  4999. }
  5000. }
  5001. private void SendOutputMessage(S.SendOutputMessage p)
  5002. {
  5003. OutputMessage(p.Message, p.Type);
  5004. }
  5005. private void NPCConsign()
  5006. {
  5007. if (!NPCDialog.Visible) return;
  5008. NPCDropDialog.PType = PanelType.Consign;
  5009. NPCDropDialog.Show();
  5010. }
  5011. private void NPCMarket(S.NPCMarket p)
  5012. {
  5013. for (int i = 0; i < p.Listings.Count; i++)
  5014. Bind(p.Listings[i].Item);
  5015. TrustMerchantDialog.Show();
  5016. TrustMerchantDialog.UserMode = p.UserMode;
  5017. TrustMerchantDialog.Listings = p.Listings;
  5018. TrustMerchantDialog.Page = 0;
  5019. TrustMerchantDialog.PageCount = p.Pages;
  5020. TrustMerchantDialog.UpdateInterface();
  5021. }
  5022. private void NPCMarketPage(S.NPCMarketPage p)
  5023. {
  5024. if (!TrustMerchantDialog.Visible) return;
  5025. for (int i = 0; i < p.Listings.Count; i++)
  5026. Bind(p.Listings[i].Item);
  5027. TrustMerchantDialog.Listings.AddRange(p.Listings);
  5028. TrustMerchantDialog.Page = (TrustMerchantDialog.Listings.Count - 1) / 10;
  5029. TrustMerchantDialog.UpdateInterface();
  5030. }
  5031. private void ConsignItem(S.ConsignItem p)
  5032. {
  5033. MirItemCell cell = InventoryDialog.GetCell(p.UniqueID) ?? BeltDialog.GetCell(p.UniqueID);
  5034. if (cell == null) return;
  5035. cell.Locked = false;
  5036. if (!p.Success) return;
  5037. cell.Item = null;
  5038. User.RefreshStats();
  5039. }
  5040. private void MarketFail(S.MarketFail p)
  5041. {
  5042. TrustMerchantDialog.MarketTime = 0;
  5043. switch (p.Reason)
  5044. {
  5045. case 0:
  5046. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouCannotUseTrustMerchantWhenDead));
  5047. break;
  5048. case 1:
  5049. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouCannotBuyFromTrustMerchantWithoutUsing));
  5050. break;
  5051. case 2:
  5052. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemHasBeenSold));
  5053. break;
  5054. case 3:
  5055. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemExpiredCannotBeBought));
  5056. break;
  5057. case 4:
  5058. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LowGold));
  5059. break;
  5060. case 5:
  5061. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NotEnoughWeightOrSpaceToBuyItem));
  5062. break;
  5063. case 6:
  5064. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotBuyOwnItems));
  5065. break;
  5066. case 7:
  5067. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TooFarFromTrustMerchant));
  5068. break;
  5069. case 8:
  5070. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotHoldGoldForSale));
  5071. break;
  5072. case 9:
  5073. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemNotMetMinimumBid));
  5074. break;
  5075. case 10:
  5076. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AuctionAlreadyEndedForItem));
  5077. break;
  5078. }
  5079. }
  5080. private void MarketSuccess(S.MarketSuccess p)
  5081. {
  5082. TrustMerchantDialog.MarketTime = 0;
  5083. MirMessageBox.Show(p.Message);
  5084. }
  5085. private void ObjectSitDown(S.ObjectSitDown p)
  5086. {
  5087. if (p.ObjectID == User.ObjectID) return;
  5088. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob) && ob.Race == ObjectType.Monster)
  5089. {
  5090. ob.SitDown = p.Sitting;
  5091. ob.ActionFeed.Add(new QueuedAction { Action = MirAction.SitDown, Direction = p.Direction, Location = p.Location });
  5092. }
  5093. }
  5094. private void BaseStatsInfo(S.BaseStatsInfo p)
  5095. {
  5096. User.CoreStats = p.Stats;
  5097. User.RefreshStats();
  5098. }
  5099. private void HeroBaseStatsInfo(S.HeroBaseStatsInfo p)
  5100. {
  5101. if (Hero == null) return;
  5102. Hero.CoreStats = p.Stats;
  5103. Hero.RefreshStats();
  5104. }
  5105. private void UserName(S.UserName p)
  5106. {
  5107. for (int i = 0; i < UserIdList.Count; i++)
  5108. if (UserIdList[i].Id == p.Id)
  5109. {
  5110. UserIdList[i].UserName = p.Name;
  5111. break;
  5112. }
  5113. DisposeItemLabel();
  5114. HoverItem = null;
  5115. }
  5116. private void ChatItemStats(S.ChatItemStats p)
  5117. {
  5118. //for (int i = 0; i < ChatItemList.Count; i++)
  5119. // if (ChatItemList[i].ID == p.ChatItemId)
  5120. // {
  5121. // ChatItemList[i].ItemStats = p.Stats;
  5122. // ChatItemList[i].RecievedTick = CMain.Time;
  5123. // }
  5124. }
  5125. private void GuildInvite(S.GuildInvite p)
  5126. {
  5127. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.JoinGuildPrompt), p.Name), MirMessageBoxButtons.YesNo);
  5128. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.GuildInvite { AcceptInvite = true });
  5129. messageBox.NoButton.Click += (o, e) => Network.Enqueue(new C.GuildInvite { AcceptInvite = false });
  5130. messageBox.Show();
  5131. }
  5132. private void GuildNameRequest(S.GuildNameRequest p)
  5133. {
  5134. MirInputBox inputBox = new MirInputBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.EnterGuildNameLengthLimit));
  5135. inputBox.InputTextBox.TextBox.KeyPress += (o, e) =>
  5136. {
  5137. string Allowed = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  5138. if (!Allowed.Contains(e.KeyChar) && e.KeyChar != (char)Keys.Back)
  5139. e.Handled = true;
  5140. };
  5141. inputBox.OKButton.Click += (o, e) =>
  5142. {
  5143. if (inputBox.InputTextBox.Text.Contains('\\'))
  5144. {
  5145. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotUseBackslashInGuildName), ChatType.System);
  5146. inputBox.InputTextBox.Text = "";
  5147. }
  5148. Network.Enqueue(new C.GuildNameReturn { Name = inputBox.InputTextBox.Text });
  5149. inputBox.Dispose();
  5150. };
  5151. inputBox.Show();
  5152. }
  5153. private void GuildRequestWar(S.GuildRequestWar p)
  5154. {
  5155. MirInputBox inputBox = new MirInputBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.EnterGuildToWarWith));
  5156. inputBox.OKButton.Click += (o, e) =>
  5157. {
  5158. Network.Enqueue(new C.GuildWarReturn { Name = inputBox.InputTextBox.Text });
  5159. inputBox.Dispose();
  5160. };
  5161. inputBox.Show();
  5162. }
  5163. private void GuildNoticeChange(S.GuildNoticeChange p)
  5164. {
  5165. if (p.update == -1)
  5166. GuildDialog.NoticeChanged = true;
  5167. else
  5168. GuildDialog.NoticeChange(p.notice);
  5169. }
  5170. private void GuildMemberChange(S.GuildMemberChange p)
  5171. {
  5172. switch (p.Status)
  5173. {
  5174. case 0: // logged of
  5175. GuildDialog.MemberStatusChange(p.Name, false);
  5176. break;
  5177. case 1: // logged on
  5178. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerLoggedOn), p.Name), ChatType.Guild);
  5179. GuildDialog.MemberStatusChange(p.Name, true);
  5180. break;
  5181. case 2: //new member
  5182. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerJoinedGuild), p.Name), ChatType.Guild);
  5183. GuildDialog.MemberCount++;
  5184. GuildDialog.MembersChanged = true;
  5185. break;
  5186. case 3: //kicked member
  5187. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerRemovedFromGuild), p.Name), ChatType.Guild);
  5188. GuildDialog.MemberCount = Math.Max(0, GuildDialog.MemberCount - 1);
  5189. GuildDialog.MembersChanged = true;
  5190. break;
  5191. case 4: //member left
  5192. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerLeftGuild), p.Name), ChatType.Guild);
  5193. GuildDialog.MemberCount = Math.Max(0, GuildDialog.MemberCount - 1);
  5194. GuildDialog.MembersChanged = true;
  5195. break;
  5196. case 5://rank change (name or different rank)
  5197. GuildDialog.MembersChanged = true;
  5198. break;
  5199. case 6: //new rank
  5200. if (p.Ranks.Count > 0)
  5201. GuildDialog.NewRankRecieved(p.Ranks[0]);
  5202. break;
  5203. case 7: //rank option changed
  5204. if (p.Ranks.Count > 0)
  5205. GuildDialog.RankChangeRecieved(p.Ranks[0]);
  5206. break;
  5207. case 8: //my rank changed
  5208. if (p.Ranks.Count > 0)
  5209. GuildDialog.MyRankChanged(p.Ranks[0]);
  5210. break;
  5211. case 255:
  5212. GuildDialog.NewMembersList(p.Ranks);
  5213. break;
  5214. }
  5215. }
  5216. private void GuildStatus(S.GuildStatus p)
  5217. {
  5218. if ((User.GuildName == "") && (p.GuildName != ""))
  5219. {
  5220. GuildDialog.NoticeChanged = true;
  5221. GuildDialog.MembersChanged = true;
  5222. }
  5223. if (p.GuildName == "")
  5224. {
  5225. GuildDialog.Hide();
  5226. }
  5227. if ((User.GuildName == p.GuildName) && (GuildDialog.Level < p.Level))
  5228. {
  5229. //guild leveled
  5230. }
  5231. bool GuildChange = User.GuildName != p.GuildName;
  5232. User.GuildName = p.GuildName;
  5233. User.GuildRankName = p.GuildRankName;
  5234. GuildDialog.Level = p.Level;
  5235. GuildDialog.Experience = p.Experience;
  5236. GuildDialog.MaxExperience = p.MaxExperience;
  5237. GuildDialog.Gold = p.Gold;
  5238. GuildDialog.SparePoints = p.SparePoints;
  5239. GuildDialog.MemberCount = p.MemberCount;
  5240. GuildDialog.MaxMembers = p.MaxMembers;
  5241. GuildDialog.Voting = p.Voting;
  5242. GuildDialog.ItemCount = p.ItemCount;
  5243. GuildDialog.BuffCount = p.BuffCount;
  5244. GuildDialog.StatusChanged(p.MyOptions);
  5245. GuildDialog.MyRankId = p.MyRankId;
  5246. GuildDialog.UpdateMembers();
  5247. //reset guildbuffs
  5248. if (GuildChange)
  5249. {
  5250. GuildDialog.EnabledBuffs.Clear();
  5251. GuildDialog.UpdateActiveStats();
  5252. RemoveBuff(new S.RemoveBuff { ObjectID = User.ObjectID, Type = BuffType.Guild });
  5253. User.RefreshStats();
  5254. }
  5255. }
  5256. private void GuildExpGain(S.GuildExpGain p)
  5257. {
  5258. //OutputMessage(string.Format("Guild Experience Gained {0}.", p.Amount));
  5259. GuildDialog.Experience += p.Amount;
  5260. }
  5261. private void GuildStorageGoldChange(S.GuildStorageGoldChange p)
  5262. {
  5263. switch (p.Type)
  5264. {
  5265. case 0:
  5266. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerDonatedGoldToGuildFunds), p.Name, p.Amount), ChatType.Guild);
  5267. GuildDialog.Gold += p.Amount;
  5268. break;
  5269. case 1:
  5270. ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerRetrievedGoldFromGuildFunds), p.Name, p.Amount), ChatType.Guild);
  5271. if (GuildDialog.Gold > p.Amount)
  5272. GuildDialog.Gold -= p.Amount;
  5273. else
  5274. GuildDialog.Gold = 0;
  5275. break;
  5276. case 2:
  5277. if (GuildDialog.Gold > p.Amount)
  5278. GuildDialog.Gold -= p.Amount;
  5279. else
  5280. GuildDialog.Gold = 0;
  5281. break;
  5282. case 3:
  5283. GuildDialog.Gold += p.Amount;
  5284. break;
  5285. }
  5286. }
  5287. private void GuildStorageItemChange(S.GuildStorageItemChange p)
  5288. {
  5289. MirItemCell fromCell = null;
  5290. MirItemCell toCell = null;
  5291. switch (p.Type)
  5292. {
  5293. case 0://store
  5294. toCell = GuildDialog.StorageGrid[p.To];
  5295. if (toCell == null) return;
  5296. toCell.Locked = false;
  5297. toCell.Item = p.Item.Item;
  5298. Bind(toCell.Item);
  5299. if (p.User != User.Id) return;
  5300. fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  5301. fromCell.Locked = false;
  5302. if (fromCell != null)
  5303. fromCell.Item = null;
  5304. User.RefreshStats();
  5305. break;
  5306. case 1://retrieve
  5307. fromCell = GuildDialog.StorageGrid[p.From];
  5308. if (fromCell == null) return;
  5309. fromCell.Locked = false;
  5310. if (p.User != User.Id)
  5311. {
  5312. fromCell.Item = null;
  5313. return;
  5314. }
  5315. toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  5316. if (toCell == null) return;
  5317. toCell.Locked = false;
  5318. toCell.Item = fromCell.Item;
  5319. fromCell.Item = null;
  5320. break;
  5321. case 2:
  5322. toCell = GuildDialog.StorageGrid[p.To];
  5323. fromCell = GuildDialog.StorageGrid[p.From];
  5324. if (toCell == null || fromCell == null) return;
  5325. toCell.Locked = false;
  5326. fromCell.Locked = false;
  5327. fromCell.Item = toCell.Item;
  5328. toCell.Item = p.Item.Item;
  5329. Bind(toCell.Item);
  5330. if (fromCell.Item != null)
  5331. Bind(fromCell.Item);
  5332. break;
  5333. case 3://failstore
  5334. fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  5335. toCell = GuildDialog.StorageGrid[p.To];
  5336. if (toCell == null || fromCell == null) return;
  5337. toCell.Locked = false;
  5338. fromCell.Locked = false;
  5339. break;
  5340. case 4://failretrieve
  5341. toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  5342. fromCell = GuildDialog.StorageGrid[p.From];
  5343. if (toCell == null || fromCell == null) return;
  5344. toCell.Locked = false;
  5345. fromCell.Locked = false;
  5346. break;
  5347. case 5://failmove
  5348. fromCell = GuildDialog.StorageGrid[p.To];
  5349. toCell = GuildDialog.StorageGrid[p.From];
  5350. if (toCell == null || fromCell == null) return;
  5351. GuildDialog.StorageGrid[p.From].Locked = false;
  5352. GuildDialog.StorageGrid[p.To].Locked = false;
  5353. break;
  5354. }
  5355. }
  5356. private void GuildStorageList(S.GuildStorageList p)
  5357. {
  5358. for (int i = 0; i < p.Items.Length; i++)
  5359. {
  5360. if (i >= GuildDialog.StorageGrid.Length) break;
  5361. if (p.Items[i] == null)
  5362. {
  5363. GuildDialog.StorageGrid[i].Item = null;
  5364. continue;
  5365. }
  5366. GuildDialog.StorageGrid[i].Item = p.Items[i].Item;
  5367. Bind(GuildDialog.StorageGrid[i].Item);
  5368. }
  5369. }
  5370. private void GuildTerritoryPage(S.GuildTerritoryPage p)
  5371. {
  5372. if (!GuildTerritoryDialog.Visible)
  5373. {
  5374. GuildTerritoryDialog.Show();
  5375. }
  5376. GuildTerritoryDialog.GTMapList = p.Listings;
  5377. GuildTerritoryDialog.Lenght = p.length;
  5378. GuildTerritoryDialog.UpdateInterface();
  5379. }
  5380. private void HeroCreateRequest(S.HeroCreateRequest p)
  5381. {
  5382. NewHeroDialog.WarriorButton.Visible = p.CanCreateClass[(int)MirClass.Warrior];
  5383. NewHeroDialog.WizardButton.Visible = p.CanCreateClass[(int)MirClass.Wizard];
  5384. NewHeroDialog.TaoistButton.Visible = p.CanCreateClass[(int)MirClass.Taoist];
  5385. NewHeroDialog.AssassinButton.Visible = p.CanCreateClass[(int)MirClass.Assassin];
  5386. NewHeroDialog.ArcherButton.Visible = p.CanCreateClass[(int)MirClass.Archer];
  5387. NewHeroDialog.Show();
  5388. }
  5389. private void ManageHeroes(S.ManageHeroes p)
  5390. {
  5391. if (p.Heroes != null)
  5392. {
  5393. for (int i = 0; i < p.Heroes.Length; i++)
  5394. AddHeroInformation(p.Heroes[i], i);
  5395. }
  5396. MaximumHeroCount = p.MaximumCount;
  5397. HeroManageDialog.SetCurrentHero(p.CurrentHero);
  5398. HeroManageDialog.Show();
  5399. }
  5400. private void ChangeHero(S.ChangeHero p)
  5401. {
  5402. ClientHeroInformation temp = HeroStorage[p.FromIndex];
  5403. HeroStorage[p.FromIndex] = HeroManageDialog.CurrentAvatar.Info;
  5404. HeroManageDialog.SetCurrentHero(temp);
  5405. HeroManageDialog.RefreshInterface();
  5406. }
  5407. public int HeroAvatar(MirClass job, MirGender gender) => 1400 + (byte)job + 10 * (byte)gender;
  5408. private void UnlockHeroAutoPot(bool value)
  5409. {
  5410. if (Hero == null) return;
  5411. Hero.AutoPot = value;
  5412. HeroInventoryDialog.RefreshInterface();
  5413. }
  5414. private void SetAutoPotValue(S.SetAutoPotValue p)
  5415. {
  5416. if (Hero == null) return;
  5417. if (p.Stat == Stat.HP)
  5418. Hero.AutoHPPercent = p.Value;
  5419. else
  5420. Hero.AutoMPPercent = p.Value;
  5421. HeroInventoryDialog.RefreshInterface();
  5422. }
  5423. private void SetAutoPotItem(S.SetAutoPotItem p)
  5424. {
  5425. if (Hero == null) return;
  5426. if (p.Grid == MirGridType.HeroHPItem)
  5427. Hero.HPItem[0] = p.ItemIndex > 0 ? new UserItem(GetItemInfo(p.ItemIndex)) : null;
  5428. else
  5429. Hero.MPItem[0] = p.ItemIndex > 0 ? new UserItem(GetItemInfo(p.ItemIndex)) : null;
  5430. }
  5431. private void SetHeroBehaviour(S.SetHeroBehaviour p)
  5432. {
  5433. if (Hero == null) return;
  5434. HeroBehaviourPanel.UpdateBehaviour(p.Behaviour);
  5435. }
  5436. private void NewHero(S.NewHero p)
  5437. {
  5438. NewHeroDialog.OKButton.Enabled = true;
  5439. switch (p.Result)
  5440. {
  5441. case 0:
  5442. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CreatingNewHeroesDisabled));
  5443. NewHeroDialog.Hide();
  5444. break;
  5445. case 1:
  5446. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YourHeroNameNotAcceptable));
  5447. NewHeroDialog.NameTextBox.SetFocus();
  5448. break;
  5449. case 2:
  5450. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SelectedGenderNotExist));
  5451. break;
  5452. case 3:
  5453. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SelectedClassNotExist));
  5454. break;
  5455. case 4:
  5456. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotMakeMoreHeroes));
  5457. NewHeroDialog.Hide();
  5458. break;
  5459. case 5:
  5460. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CharacterNameAlreadyExists));
  5461. NewHeroDialog.NameTextBox.SetFocus();
  5462. break;
  5463. case 6:
  5464. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NoBagSpace));
  5465. NewHeroDialog.Hide();
  5466. break;
  5467. case 10:
  5468. MirMessageBox.Show(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HeroCreatedSuccessfully));
  5469. NewHeroDialog.Hide();
  5470. break;
  5471. }
  5472. }
  5473. private void HeroInformation(S.HeroInformation p)
  5474. {
  5475. Hero = new UserHeroObject(p.ObjectID);
  5476. Hero.Load(p);
  5477. Hero.AutoPot = p.AutoPot;
  5478. Hero.AutoHPPercent = p.AutoHPPercent;
  5479. Hero.AutoMPPercent = p.AutoMPPercent;
  5480. if (p.HPItemIndex > 0)
  5481. Hero.HPItem[0] = new UserItem(GetItemInfo(p.HPItemIndex));
  5482. if (p.MPItemIndex > 0)
  5483. Hero.MPItem[0] = new UserItem(GetItemInfo(p.MPItemIndex));
  5484. HeroDialog = new CharacterDialog(MirGridType.HeroEquipment, Hero) { Parent = this, Visible = false };
  5485. HeroInventoryDialog = new HeroInventoryDialog { Parent = this };
  5486. HeroBeltDialog = new HeroBeltDialog { Parent = this };
  5487. HeroBuffsDialog = new BuffDialog
  5488. {
  5489. Parent = this,
  5490. Visible = true,
  5491. Location = new Point(Settings.ScreenWidth - 170, 80),
  5492. GetExpandedParameter = () => { return Settings.ExpandedHeroBuffWindow; },
  5493. SetExpandedParameter = (value) => { Settings.ExpandedHeroBuffWindow = value; }
  5494. };
  5495. MainDialog.HeroInfoPanel.Update();
  5496. Hero.RefreshStats();
  5497. }
  5498. private void UpdateHeroSpawnState(S.UpdateHeroSpawnState p)
  5499. {
  5500. HeroSpawnState = p.State;
  5501. HasHero = p.State > HeroSpawnState.None;
  5502. MainDialog.HeroInfoPanel.Visible = p.State > HeroSpawnState.Unsummoned;
  5503. MainDialog.HeroMenuButton.Visible = p.State > HeroSpawnState.Unsummoned;
  5504. HeroBehaviourPanel.Visible = p.State > HeroSpawnState.Unsummoned;
  5505. HeroMenuPanel.Visible = HeroMenuPanel.Visible && MainDialog.HeroMenuButton.Visible;
  5506. if (p.State < HeroSpawnState.Summoned)
  5507. {
  5508. HeroInventoryDialog.Dispose();
  5509. HeroDialog.Dispose();
  5510. HeroBeltDialog.Dispose();
  5511. HeroBuffsDialog.Dispose();
  5512. }
  5513. }
  5514. private void MarriageRequest(S.MarriageRequest p)
  5515. {
  5516. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerAskedForMarriage), p.Name), MirMessageBoxButtons.YesNo);
  5517. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.MarriageReply { AcceptInvite = true });
  5518. messageBox.NoButton.Click += (o, e) => { Network.Enqueue(new C.MarriageReply { AcceptInvite = false }); messageBox.Dispose(); };
  5519. messageBox.Show();
  5520. }
  5521. private void DivorceRequest(S.DivorceRequest p)
  5522. {
  5523. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerRequestedDivorce), p.Name), MirMessageBoxButtons.YesNo);
  5524. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.DivorceReply { AcceptInvite = true });
  5525. messageBox.NoButton.Click += (o, e) => { Network.Enqueue(new C.DivorceReply { AcceptInvite = false }); messageBox.Dispose(); };
  5526. messageBox.Show();
  5527. }
  5528. private void MentorRequest(S.MentorRequest p)
  5529. {
  5530. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerRequestedTeachClass), p.Name, p.Level, GameScene.User.Class.ToString()),
  5531. MirMessageBoxButtons.YesNo);
  5532. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.MentorReply { AcceptInvite = true });
  5533. messageBox.NoButton.Click += (o, e) => { Network.Enqueue(new C.MentorReply { AcceptInvite = false }); messageBox.Dispose(); };
  5534. messageBox.Show();
  5535. }
  5536. private bool UpdateGuildBuff(GuildBuff buff, bool Remove = false)
  5537. {
  5538. for (int i = 0; i < GuildDialog.EnabledBuffs.Count; i++)
  5539. {
  5540. if (GuildDialog.EnabledBuffs[i].Id == buff.Id)
  5541. {
  5542. if (Remove)
  5543. {
  5544. GuildDialog.EnabledBuffs.RemoveAt(i);
  5545. }
  5546. else
  5547. GuildDialog.EnabledBuffs[i] = buff;
  5548. return true;
  5549. }
  5550. }
  5551. return false;
  5552. }
  5553. private void GuildBuffList(S.GuildBuffList p)
  5554. {
  5555. //getting the list of all guildbuffs on server?
  5556. if (p.GuildBuffs.Count > 0)
  5557. GuildDialog.GuildBuffInfos.Clear();
  5558. for (int i = 0; i < p.GuildBuffs.Count; i++)
  5559. {
  5560. GuildDialog.GuildBuffInfos.Add(p.GuildBuffs[i]);
  5561. }
  5562. //getting the list of all active/removedbuffs?
  5563. for (int i = 0; i < p.ActiveBuffs.Count; i++)
  5564. {
  5565. //if (p.ActiveBuffs[i].ActiveTimeRemaining > 0)
  5566. // p.ActiveBuffs[i].ActiveTimeRemaining = Convert.ToInt32(CMain.Time / 1000) + (p.ActiveBuffs[i].ActiveTimeRemaining * 60);
  5567. if (UpdateGuildBuff(p.ActiveBuffs[i], p.Remove == 1)) continue;
  5568. if (!(p.Remove == 1))
  5569. {
  5570. GuildDialog.EnabledBuffs.Add(p.ActiveBuffs[i]);
  5571. //CreateGuildBuff(p.ActiveBuffs[i]);
  5572. }
  5573. }
  5574. for (int i = 0; i < GuildDialog.EnabledBuffs.Count; i++)
  5575. {
  5576. if (GuildDialog.EnabledBuffs[i].Info == null)
  5577. {
  5578. GuildDialog.EnabledBuffs[i].Info = GuildDialog.FindGuildBuffInfo(GuildDialog.EnabledBuffs[i].Id);
  5579. }
  5580. }
  5581. ClientBuff buff = BuffsDialog.Buffs.FirstOrDefault(e => e.Type == BuffType.Guild);
  5582. if (GuildDialog.EnabledBuffs.Any(e => e.Active))
  5583. {
  5584. if (buff == null)
  5585. {
  5586. buff = new ClientBuff { Type = BuffType.Guild, ObjectID = User.ObjectID, Caster = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Guild), Infinite = true, Values = new int[0] };
  5587. BuffsDialog.Buffs.Add(buff);
  5588. BuffsDialog.CreateBuff(buff);
  5589. }
  5590. GuildDialog.UpdateActiveStats();
  5591. }
  5592. else
  5593. {
  5594. RemoveBuff(new S.RemoveBuff { ObjectID = User.ObjectID, Type = BuffType.Guild });
  5595. }
  5596. User.RefreshStats();
  5597. }
  5598. private void TradeRequest(S.TradeRequest p)
  5599. {
  5600. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PlayerRequestedTrade), p.Name), MirMessageBoxButtons.YesNo);
  5601. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.TradeReply { AcceptInvite = true });
  5602. messageBox.NoButton.Click += (o, e) => { Network.Enqueue(new C.TradeReply { AcceptInvite = false }); messageBox.Dispose(); };
  5603. messageBox.Show();
  5604. }
  5605. private void TradeAccept(S.TradeAccept p)
  5606. {
  5607. GuestTradeDialog.GuestName = p.Name;
  5608. TradeDialog.TradeAccept();
  5609. }
  5610. private void TradeGold(S.TradeGold p)
  5611. {
  5612. GuestTradeDialog.GuestGold = p.Amount;
  5613. TradeDialog.ChangeLockState(false);
  5614. TradeDialog.RefreshInterface();
  5615. }
  5616. private void TradeItem(S.TradeItem p)
  5617. {
  5618. GuestTradeDialog.GuestItems = p.TradeItems;
  5619. TradeDialog.ChangeLockState(false);
  5620. TradeDialog.RefreshInterface();
  5621. }
  5622. private void TradeConfirm()
  5623. {
  5624. TradeDialog.TradeReset();
  5625. }
  5626. private void TradeCancel(S.TradeCancel p)
  5627. {
  5628. if (p.Unlock)
  5629. {
  5630. TradeDialog.ChangeLockState(false);
  5631. }
  5632. else
  5633. {
  5634. TradeDialog.TradeReset();
  5635. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DealCancelledMustFace), MirMessageBoxButtons.OK);
  5636. messageBox.Show();
  5637. }
  5638. }
  5639. private void NPCAwakening()
  5640. {
  5641. if (NPCAwakeDialog.Visible != true)
  5642. NPCAwakeDialog.Show();
  5643. }
  5644. private void NPCDisassemble()
  5645. {
  5646. if (!NPCDialog.Visible) return;
  5647. NPCDropDialog.PType = PanelType.Disassemble;
  5648. NPCDropDialog.Show();
  5649. }
  5650. private void NPCDowngrade()
  5651. {
  5652. if (!NPCDialog.Visible) return;
  5653. NPCDropDialog.PType = PanelType.Downgrade;
  5654. NPCDropDialog.Show();
  5655. }
  5656. private void NPCReset()
  5657. {
  5658. if (!NPCDialog.Visible) return;
  5659. NPCDropDialog.PType = PanelType.Reset;
  5660. NPCDropDialog.Show();
  5661. }
  5662. private void AwakeningNeedMaterials(S.AwakeningNeedMaterials p)
  5663. {
  5664. NPCAwakeDialog.setNeedItems(p.Materials, p.MaterialsCount);
  5665. }
  5666. private void AwakeningLockedItem(S.AwakeningLockedItem p)
  5667. {
  5668. MirItemCell cell = InventoryDialog.GetCell(p.UniqueID);
  5669. if (cell != null)
  5670. cell.Locked = p.Locked;
  5671. }
  5672. private void Awakening(S.Awakening p)
  5673. {
  5674. if (NPCAwakeDialog.Visible)
  5675. NPCAwakeDialog.Hide();
  5676. if (InventoryDialog.Visible)
  5677. InventoryDialog.Hide();
  5678. InventoryDialog.Location = new Point(0, 0);
  5679. MirItemCell cell = InventoryDialog.GetCell((ulong)p.removeID);
  5680. if (cell != null)
  5681. {
  5682. cell.Locked = false;
  5683. cell.Item = null;
  5684. }
  5685. for (int i = 0; i < InventoryDialog.Grid.Length; i++)
  5686. {
  5687. if (InventoryDialog.Grid[i].Locked == true)
  5688. {
  5689. InventoryDialog.Grid[i].Locked = false;
  5690. //if (InventoryDialog.Grid[i].Item.UniqueID == (ulong)p.removeID)
  5691. //{
  5692. // InventoryDialog.Grid[i].Item = null;
  5693. //}
  5694. }
  5695. }
  5696. for (int i = 0; i < NPCAwakeDialog.ItemsIdx.Length; i++)
  5697. {
  5698. NPCAwakeDialog.ItemsIdx[i] = 0;
  5699. }
  5700. MirMessageBox messageBox = null;
  5701. switch (p.result)
  5702. {
  5703. case -4:
  5704. messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NotEnoughMaterials), MirMessageBoxButtons.OK);
  5705. MapControl.AwakeningAction = false;
  5706. break;
  5707. case -3:
  5708. messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LowGold), MirMessageBoxButtons.OK);
  5709. MapControl.AwakeningAction = false;
  5710. break;
  5711. case -2:
  5712. messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AwakeningMaxLevel), MirMessageBoxButtons.OK);
  5713. MapControl.AwakeningAction = false;
  5714. break;
  5715. case -1:
  5716. messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotAwakenItem), MirMessageBoxButtons.OK);
  5717. MapControl.AwakeningAction = false;
  5718. break;
  5719. case 0:
  5720. //messageBox = new MirMessageBox("Upgrade Failed.", MirMessageBoxButtons.OK);
  5721. break;
  5722. case 1:
  5723. //messageBox = new MirMessageBox("Upgrade Success.", MirMessageBoxButtons.OK);
  5724. break;
  5725. }
  5726. if (messageBox != null) messageBox.Show();
  5727. }
  5728. private void ReceiveMail(S.ReceiveMail p)
  5729. {
  5730. NewMail = false;
  5731. NewMailCounter = 0;
  5732. User.Mail.Clear();
  5733. User.Mail = p.Mail.OrderByDescending(e => !e.Locked).ThenByDescending(e => e.DateSent).ToList();
  5734. foreach (ClientMail mail in User.Mail)
  5735. {
  5736. foreach (UserItem itm in mail.Items)
  5737. {
  5738. Bind(itm);
  5739. }
  5740. }
  5741. //display new mail received
  5742. if (User.Mail.Any(e => e.Opened == false))
  5743. {
  5744. NewMail = true;
  5745. }
  5746. GameScene.Scene.MailListDialog.UpdateInterface();
  5747. }
  5748. private void MailLockedItem(S.MailLockedItem p)
  5749. {
  5750. MirItemCell cell = InventoryDialog.GetCell(p.UniqueID);
  5751. if (cell != null)
  5752. cell.Locked = p.Locked;
  5753. }
  5754. private void MailSendRequest(S.MailSendRequest p)
  5755. {
  5756. MirInputBox inputBox = new MirInputBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.EnterMailRecipientName));
  5757. inputBox.OKButton.Click += (o1, e1) =>
  5758. {
  5759. GameScene.Scene.MailComposeParcelDialog.ComposeMail(inputBox.InputTextBox.Text);
  5760. GameScene.Scene.InventoryDialog.Show();
  5761. //open letter dialog, pass in name
  5762. inputBox.Dispose();
  5763. };
  5764. inputBox.Show();
  5765. }
  5766. private void MailSent(S.MailSent p)
  5767. {
  5768. for (int i = 0; i < InventoryDialog.Grid.Length; i++)
  5769. {
  5770. if (InventoryDialog.Grid[i].Locked == true)
  5771. {
  5772. InventoryDialog.Grid[i].Locked = false;
  5773. }
  5774. }
  5775. for (int i = 0; i < BeltDialog.Grid.Length; i++)
  5776. {
  5777. if (BeltDialog.Grid[i].Locked == true)
  5778. {
  5779. BeltDialog.Grid[i].Locked = false;
  5780. }
  5781. }
  5782. GameScene.Scene.MailComposeParcelDialog.Hide();
  5783. }
  5784. private void ParcelCollected(S.ParcelCollected p)
  5785. {
  5786. switch (p.Result)
  5787. {
  5788. case -1:
  5789. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NoParcelsToCollect), MirMessageBoxButtons.OK);
  5790. messageBox.Show();
  5791. break;
  5792. case 0:
  5793. messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AllParcelsCollected), MirMessageBoxButtons.OK);
  5794. messageBox.Show();
  5795. break;
  5796. case 1:
  5797. GameScene.Scene.MailReadParcelDialog.Hide();
  5798. break;
  5799. }
  5800. }
  5801. private void ResizeInventory(S.ResizeInventory p)
  5802. {
  5803. Array.Resize(ref User.Inventory, p.Size);
  5804. InventoryDialog.RefreshInventory2();
  5805. }
  5806. private void ResizeStorage(S.ResizeStorage p)
  5807. {
  5808. Array.Resize(ref Storage, p.Size);
  5809. User.HasExpandedStorage = p.HasExpandedStorage;
  5810. User.ExpandedStorageExpiryTime = p.ExpiryTime;
  5811. StorageDialog.RefreshStorage2();
  5812. }
  5813. private void MailCost(S.MailCost p)
  5814. {
  5815. if (GameScene.Scene.MailComposeParcelDialog.Visible)
  5816. {
  5817. if (p.Cost > 0)
  5818. SoundManager.PlaySound(SoundList.Gold);
  5819. GameScene.Scene.MailComposeParcelDialog.ParcelCostLabel.Text = p.Cost.ToString();
  5820. }
  5821. }
  5822. public void AddQuestItem(UserItem item)
  5823. {
  5824. Redraw();
  5825. if (item.Info.StackSize > 1) //Stackable
  5826. {
  5827. for (int i = 0; i < User.QuestInventory.Length; i++)
  5828. {
  5829. UserItem temp = User.QuestInventory[i];
  5830. if (temp == null || item.Info != temp.Info || temp.Count >= temp.Info.StackSize) continue;
  5831. if (item.Count + temp.Count <= temp.Info.StackSize)
  5832. {
  5833. temp.Count += item.Count;
  5834. return;
  5835. }
  5836. item.Count -= (ushort)(temp.Info.StackSize - temp.Count);
  5837. temp.Count = temp.Info.StackSize;
  5838. }
  5839. }
  5840. for (int i = 0; i < User.QuestInventory.Length; i++)
  5841. {
  5842. if (User.QuestInventory[i] != null) continue;
  5843. User.QuestInventory[i] = item;
  5844. return;
  5845. }
  5846. }
  5847. private void RequestReincarnation()
  5848. {
  5849. if (CMain.Time > User.DeadTime && User.CurrentAction == MirAction.Dead)
  5850. {
  5851. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.WouldYouLikeToBeRevived), MirMessageBoxButtons.YesNo);
  5852. messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.AcceptReincarnation());
  5853. messageBox.Show();
  5854. }
  5855. }
  5856. private void NewIntelligentCreature(S.NewIntelligentCreature p)
  5857. {
  5858. User.IntelligentCreatures.Add(p.Creature);
  5859. MirInputBox inputBox = new MirInputBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PleaseGiveYourCreatureName));
  5860. inputBox.InputTextBox.Text = GameScene.User.IntelligentCreatures[User.IntelligentCreatures.Count - 1].CustomName;
  5861. inputBox.OKButton.Click += (o1, e1) =>
  5862. {
  5863. if (IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Update();//refresh changes
  5864. GameScene.User.IntelligentCreatures[User.IntelligentCreatures.Count - 1].CustomName = inputBox.InputTextBox.Text;
  5865. Network.Enqueue(new C.UpdateIntelligentCreature { Creature = GameScene.User.IntelligentCreatures[User.IntelligentCreatures.Count - 1] });
  5866. inputBox.Dispose();
  5867. };
  5868. inputBox.Show();
  5869. }
  5870. private void UpdateIntelligentCreatureList(S.UpdateIntelligentCreatureList p)
  5871. {
  5872. User.CreatureSummoned = p.CreatureSummoned;
  5873. User.SummonedCreatureType = p.SummonedCreatureType;
  5874. User.PearlCount = p.PearlCount;
  5875. if (p.CreatureList.Count != User.IntelligentCreatures.Count)
  5876. {
  5877. User.IntelligentCreatures.Clear();
  5878. for (int i = 0; i < p.CreatureList.Count; i++)
  5879. User.IntelligentCreatures.Add(p.CreatureList[i]);
  5880. for (int i = 0; i < IntelligentCreatureDialog.CreatureButtons.Length; i++)
  5881. IntelligentCreatureDialog.CreatureButtons[i].Clear();
  5882. IntelligentCreatureDialog.Hide();
  5883. }
  5884. else
  5885. {
  5886. for (int i = 0; i < p.CreatureList.Count; i++)
  5887. User.IntelligentCreatures[i] = p.CreatureList[i];
  5888. if (IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Update();
  5889. }
  5890. }
  5891. private void IntelligentCreatureEnableRename(S.IntelligentCreatureEnableRename p)
  5892. {
  5893. IntelligentCreatureDialog.CreatureRenameButton.Visible = true;
  5894. if (IntelligentCreatureDialog.Visible) IntelligentCreatureDialog.Update();
  5895. }
  5896. private void IntelligentCreaturePickup(S.IntelligentCreaturePickup p)
  5897. {
  5898. if (MapControl.Objects.TryGetValue(p.ObjectID, out MapObject ob) && ob is MonsterObject monOb)
  5899. monOb.PlayPickupSound();
  5900. }
  5901. private void FriendUpdate(S.FriendUpdate p)
  5902. {
  5903. FriendDialog.Friends = p.Friends;
  5904. if (FriendDialog.Visible)
  5905. FriendDialog.Update(false);
  5906. }
  5907. private void LoverUpdate(S.LoverUpdate p)
  5908. {
  5909. RelationshipDialog.LoverName = p.Name;
  5910. RelationshipDialog.Date = p.Date;
  5911. RelationshipDialog.MapName = p.MapName;
  5912. RelationshipDialog.MarriedDays = p.MarriedDays;
  5913. RelationshipDialog.UpdateInterface();
  5914. }
  5915. private void MentorUpdate(S.MentorUpdate p)
  5916. {
  5917. MentorDialog.MentorName = p.Name;
  5918. MentorDialog.MentorLevel = p.Level;
  5919. MentorDialog.MentorOnline = p.Online;
  5920. MentorDialog.MenteeEXP = p.MenteeEXP;
  5921. MentorDialog.UpdateInterface();
  5922. }
  5923. private void GameShopUpdate(S.GameShopInfo p)
  5924. {
  5925. p.Item.Stock = p.StockLevel;
  5926. GameShopInfoList.Add(p.Item);
  5927. if (p.Item.Date > CMain.Now.AddDays(-7)) GameShopDialog.New.Visible = true;
  5928. }
  5929. private void GameShopStock(S.GameShopStock p)
  5930. {
  5931. for (int i = 0; i < GameShopInfoList.Count; i++)
  5932. {
  5933. if (GameShopInfoList[i].GIndex == p.GIndex)
  5934. {
  5935. if (p.StockLevel == 0) GameShopInfoList.Remove(GameShopInfoList[i]);
  5936. else GameShopInfoList[i].Stock = p.StockLevel;
  5937. if (GameShopDialog.Visible) GameShopDialog.UpdateShop();
  5938. }
  5939. }
  5940. }
  5941. public void AddItem(UserItem item)
  5942. {
  5943. Redraw();
  5944. if (item.Info.StackSize > 1) //Stackable
  5945. {
  5946. for (int i = 0; i < User.Inventory.Length; i++)
  5947. {
  5948. UserItem temp = User.Inventory[i];
  5949. if (temp == null || item.Info != temp.Info || temp.Count >= temp.Info.StackSize) continue;
  5950. if (item.Count + temp.Count <= temp.Info.StackSize)
  5951. {
  5952. temp.Count += item.Count;
  5953. return;
  5954. }
  5955. item.Count -= (ushort)(temp.Info.StackSize - temp.Count);
  5956. temp.Count = temp.Info.StackSize;
  5957. }
  5958. }
  5959. if (item.Info.Type == ItemType.Potion || item.Info.Type == ItemType.Scroll || (item.Info.Type == ItemType.Script && item.Info.Effect == 1))
  5960. {
  5961. for (int i = 0; i < User.BeltIdx - 2; i++)
  5962. {
  5963. if (User.Inventory[i] != null) continue;
  5964. User.Inventory[i] = item;
  5965. return;
  5966. }
  5967. }
  5968. else if (item.Info.Type == ItemType.Amulet)
  5969. {
  5970. for (int i = 4; i < User.BeltIdx; i++)
  5971. {
  5972. if (User.Inventory[i] != null) continue;
  5973. User.Inventory[i] = item;
  5974. return;
  5975. }
  5976. }
  5977. else
  5978. {
  5979. for (int i = User.BeltIdx; i < User.Inventory.Length; i++)
  5980. {
  5981. if (User.Inventory[i] != null) continue;
  5982. User.Inventory[i] = item;
  5983. return;
  5984. }
  5985. }
  5986. for (int i = 0; i < User.Inventory.Length; i++)
  5987. {
  5988. if (User.Inventory[i] != null) continue;
  5989. User.Inventory[i] = item;
  5990. return;
  5991. }
  5992. }
  5993. public static void Bind(UserItem item)
  5994. {
  5995. for (int i = 0; i < ItemInfoList.Count; i++)
  5996. {
  5997. if (ItemInfoList[i].Index != item.ItemIndex) continue;
  5998. item.Info = ItemInfoList[i];
  5999. for (int s = 0; s < item.Slots.Length; s++)
  6000. {
  6001. if (item.Slots[s] == null) continue;
  6002. Bind(item.Slots[s]);
  6003. }
  6004. return;
  6005. }
  6006. }
  6007. public ItemInfo GetItemInfo(int index)
  6008. {
  6009. return ItemInfoList.Find(x => x.Index == index);
  6010. }
  6011. public static void BindQuest(ClientQuestProgress quest)
  6012. {
  6013. for (int i = 0; i < QuestInfoList.Count; i++)
  6014. {
  6015. if (QuestInfoList[i].Index != quest.Id) continue;
  6016. quest.QuestInfo = QuestInfoList[i];
  6017. return;
  6018. }
  6019. }
  6020. public Color GradeNameColor(ItemGrade grade)
  6021. {
  6022. switch (grade)
  6023. {
  6024. case ItemGrade.Common:
  6025. return Color.Yellow;
  6026. case ItemGrade.Rare:
  6027. return Color.DeepSkyBlue;
  6028. case ItemGrade.Legendary:
  6029. return Color.DarkOrange;
  6030. case ItemGrade.Mythical:
  6031. return Color.Plum;
  6032. case ItemGrade.Heroic:
  6033. return Color.Red;
  6034. default:
  6035. return Color.Yellow;
  6036. }
  6037. }
  6038. public void DisposeItemLabel()
  6039. {
  6040. if (ItemLabel != null && !ItemLabel.IsDisposed)
  6041. ItemLabel.Dispose();
  6042. ItemLabel = null;
  6043. }
  6044. public void DisposeMailLabel()
  6045. {
  6046. if (MailLabel != null && !MailLabel.IsDisposed)
  6047. MailLabel.Dispose();
  6048. MailLabel = null;
  6049. }
  6050. public void DisposeMemoLabel()
  6051. {
  6052. if (MemoLabel != null && !MemoLabel.IsDisposed)
  6053. MemoLabel.Dispose();
  6054. MemoLabel = null;
  6055. }
  6056. public void DisposeGuildBuffLabel()
  6057. {
  6058. if (GuildBuffLabel != null && !GuildBuffLabel.IsDisposed)
  6059. GuildBuffLabel.Dispose();
  6060. GuildBuffLabel = null;
  6061. }
  6062. public MirControl NameInfoLabel(UserItem item, bool inspect = false, bool hideDura = false)
  6063. {
  6064. ushort level = inspect ? InspectDialog.Level : MapObject.User.Level;
  6065. MirClass job = inspect ? InspectDialog.Class : MapObject.User.Class;
  6066. HoverItem = item;
  6067. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  6068. string GradeString = "";
  6069. switch (HoverItem.Info.Grade)
  6070. {
  6071. case ItemGrade.None:
  6072. break;
  6073. case ItemGrade.Common:
  6074. GradeString = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemGradeCommon);
  6075. break;
  6076. case ItemGrade.Rare:
  6077. GradeString = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemGradeRare);
  6078. break;
  6079. case ItemGrade.Legendary:
  6080. GradeString = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemGradeLegendary);
  6081. break;
  6082. case ItemGrade.Mythical:
  6083. GradeString = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemGradeMythical);
  6084. break;
  6085. case ItemGrade.Heroic:
  6086. GradeString = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemGradeHeroic);
  6087. break;
  6088. }
  6089. MirLabel nameLabel = new MirLabel
  6090. {
  6091. AutoSize = true,
  6092. ForeColour = GradeNameColor(HoverItem.Info.Grade),
  6093. Location = new Point(4, 4),
  6094. OutLine = true,
  6095. Parent = ItemLabel,
  6096. Text = HoverItem.Info.Grade != ItemGrade.None ? string.Format("{0}{1}{2}", HoverItem.Info.FriendlyName, "\n", GradeString) : HoverItem.Info.FriendlyName,
  6097. };
  6098. if (HoverItem.RefineAdded > 0)
  6099. nameLabel.Text = "(*)" + nameLabel.Text;
  6100. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, nameLabel.DisplayRectangle.Right + 4),
  6101. Math.Max(ItemLabel.Size.Height, nameLabel.DisplayRectangle.Bottom));
  6102. string text = "";
  6103. if (HoverItem.Info.Durability > 0 && !hideDura)
  6104. {
  6105. switch (HoverItem.Info.Type)
  6106. {
  6107. case ItemType.Amulet:
  6108. if (HoverItem.CurrentDura > 0 || HoverItem.MaxDura > 0)
  6109. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UsageCurrentMax, HoverItem.CurrentDura, HoverItem.MaxDura);
  6110. break;
  6111. case ItemType.Ore:
  6112. if (HoverItem.CurrentDura > 0)
  6113. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PurityValue, Math.Floor(HoverItem.CurrentDura / 1000M));
  6114. break;
  6115. case ItemType.Meat:
  6116. if (HoverItem.CurrentDura > 0)
  6117. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.QualityValue, Math.Floor(HoverItem.CurrentDura / 1000M));
  6118. break;
  6119. case ItemType.Mount:
  6120. if (HoverItem.CurrentDura > 0 || HoverItem.MaxDura > 0)
  6121. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LoyaltyValues, HoverItem.CurrentDura, HoverItem.MaxDura);
  6122. break;
  6123. case ItemType.Food:
  6124. if (HoverItem.CurrentDura > 0)
  6125. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.NutritionValue, HoverItem.CurrentDura);
  6126. break;
  6127. case ItemType.Gem:
  6128. case ItemType.Potion:
  6129. case ItemType.Transform:
  6130. case ItemType.SealedHero:
  6131. break;
  6132. case ItemType.Pets:
  6133. if ((HoverItem.Info.Shape == 26 || HoverItem.Info.Shape == 28) && HoverItem.CurrentDura > 0)//WonderDrug, Knapsack
  6134. {
  6135. string strTime = Functions.PrintTimeSpanFromSeconds((HoverItem.CurrentDura * 3600), false);
  6136. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DurationValue, strTime);
  6137. }
  6138. break;
  6139. default:
  6140. int current = (int)Math.Floor(HoverItem.CurrentDura / 1000M);
  6141. int maximum = (int)Math.Floor(HoverItem.MaxDura / 1000M);
  6142. if (current > 0 || maximum > 0)
  6143. text = string.Format("{0} {1}/{2}", GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Durability), current, maximum);
  6144. break;
  6145. }
  6146. }
  6147. string baseText = string.Empty;
  6148. switch (HoverItem.Info.Type)
  6149. {
  6150. case ItemType.Nothing:
  6151. break;
  6152. case ItemType.Weapon:
  6153. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeWeapon);
  6154. break;
  6155. case ItemType.Armour:
  6156. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeArmour);
  6157. break;
  6158. case ItemType.Helmet:
  6159. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeHelmet);
  6160. break;
  6161. case ItemType.Necklace:
  6162. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeNecklace);
  6163. break;
  6164. case ItemType.Bracelet:
  6165. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeBracelet);
  6166. break;
  6167. case ItemType.Ring:
  6168. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeRing);
  6169. break;
  6170. case ItemType.Amulet:
  6171. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeAmulet);
  6172. break;
  6173. case ItemType.Belt:
  6174. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeBelt);
  6175. break;
  6176. case ItemType.Boots:
  6177. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeBoots);
  6178. break;
  6179. case ItemType.Stone:
  6180. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeStone);
  6181. break;
  6182. case ItemType.Torch:
  6183. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeTorch);
  6184. break;
  6185. case ItemType.Potion:
  6186. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypePotion);
  6187. break;
  6188. case ItemType.Ore:
  6189. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeOre);
  6190. break;
  6191. case ItemType.Meat:
  6192. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeMeat);
  6193. break;
  6194. case ItemType.CraftingMaterial:
  6195. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeCraftingMaterial);
  6196. break;
  6197. case ItemType.Scroll:
  6198. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeScroll);
  6199. break;
  6200. case ItemType.Gem:
  6201. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeGem);
  6202. break;
  6203. case ItemType.Mount:
  6204. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeMount);
  6205. break;
  6206. case ItemType.Book:
  6207. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeBook);
  6208. break;
  6209. case ItemType.Script:
  6210. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeScript);
  6211. break;
  6212. case ItemType.Reins:
  6213. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeReins);
  6214. break;
  6215. case ItemType.Bells:
  6216. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeBells);
  6217. break;
  6218. case ItemType.Saddle:
  6219. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeSaddle);
  6220. break;
  6221. case ItemType.Ribbon:
  6222. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeRibbon);
  6223. break;
  6224. case ItemType.Mask:
  6225. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeMask);
  6226. break;
  6227. case ItemType.Food:
  6228. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeFood);
  6229. break;
  6230. case ItemType.Hook:
  6231. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeHook);
  6232. break;
  6233. case ItemType.Float:
  6234. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeFloat);
  6235. break;
  6236. case ItemType.Bait:
  6237. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeBait);
  6238. break;
  6239. case ItemType.Finder:
  6240. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeFinder);
  6241. break;
  6242. case ItemType.Reel:
  6243. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeReel);
  6244. break;
  6245. case ItemType.Fish:
  6246. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeFish);
  6247. break;
  6248. case ItemType.Quest:
  6249. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeQuest);
  6250. break;
  6251. case ItemType.Awakening:
  6252. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeAwakening);
  6253. break;
  6254. case ItemType.Pets:
  6255. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypePets);
  6256. break;
  6257. case ItemType.Transform:
  6258. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeTransform);
  6259. break;
  6260. case ItemType.Deco:
  6261. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeDeco);
  6262. break;
  6263. case ItemType.MonsterSpawn:
  6264. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeMonsterSpawn);
  6265. break;
  6266. case ItemType.SealedHero:
  6267. baseText = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemTypeSealedHero);
  6268. break;
  6269. }
  6270. if (HoverItem.WeddingRing != -1)
  6271. {
  6272. baseText += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.WeddingRing);
  6273. }
  6274. List<string> tailParts = new List<string>();
  6275. if (HoverItem.Weight > 0)
  6276. tailParts.Add(string.Format("{0} {1}", GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Weight), HoverItem.Weight));
  6277. if (!string.IsNullOrEmpty(text))
  6278. tailParts.Add(text);
  6279. if (tailParts.Count > 0)
  6280. {
  6281. string tailText = string.Join(" ", tailParts.ToArray());
  6282. baseText = string.IsNullOrEmpty(baseText)
  6283. ? tailText
  6284. : string.Format("{0}\n{1}", baseText, tailText);
  6285. }
  6286. MirLabel etcLabel = new MirLabel
  6287. {
  6288. AutoSize = true,
  6289. ForeColour = Color.White,
  6290. Location = new Point(4, nameLabel.DisplayRectangle.Bottom),
  6291. OutLine = true,
  6292. Parent = ItemLabel,
  6293. Text = baseText
  6294. };
  6295. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, etcLabel.DisplayRectangle.Right + 4),
  6296. Math.Max(ItemLabel.Size.Height, etcLabel.DisplayRectangle.Bottom + 4));
  6297. #region OUTLINE
  6298. MirControl outLine = new MirControl
  6299. {
  6300. BackColour = Color.FromArgb(255, 50, 50, 50),
  6301. Border = true,
  6302. BorderColour = Color.Gray,
  6303. NotControl = true,
  6304. Parent = ItemLabel,
  6305. Opacity = 0.4F,
  6306. Location = new Point(0, 0)
  6307. };
  6308. outLine.Size = ItemLabel.Size;
  6309. #endregion
  6310. return outLine;
  6311. }
  6312. private Stats GetTotalAddedStats(UserItem item, ushort level, MirClass job)
  6313. {
  6314. Stats total = new Stats();
  6315. if (item == null) return total;
  6316. total.Add(item.AddedStats);
  6317. if (item.Slots == null || item.Slots.Length == 0) return total;
  6318. for (int i = 0; i < item.Slots.Length; i++)
  6319. {
  6320. UserItem socketItem = item.Slots[i];
  6321. if (socketItem == null) continue;
  6322. ItemInfo socketInfo = Functions.GetRealItem(socketItem.Info, level, job, ItemInfoList);
  6323. if (socketItem.CurrentDura == 0 && socketInfo.Durability > 0) continue;
  6324. total.Add(socketInfo.Stats);
  6325. total.Add(socketItem.AddedStats);
  6326. }
  6327. return total;
  6328. }
  6329. public MirControl AttackInfoLabel(UserItem item, bool Inspect = false, bool hideAdded = false)
  6330. {
  6331. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  6332. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  6333. HoverItem = item;
  6334. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  6335. Stats addedStats = GetTotalAddedStats(item, level, job);
  6336. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  6337. bool fishingItem = false;
  6338. switch (HoverItem.Info.Type)
  6339. {
  6340. case ItemType.Hook:
  6341. case ItemType.Float:
  6342. case ItemType.Bait:
  6343. case ItemType.Finder:
  6344. case ItemType.Reel:
  6345. fishingItem = true;
  6346. break;
  6347. case ItemType.Weapon:
  6348. if (Globals.FishingRodShapes.Contains(HoverItem.Info.Shape))
  6349. fishingItem = true;
  6350. break;
  6351. default:
  6352. fishingItem = false;
  6353. break;
  6354. }
  6355. int count = 0;
  6356. int minValue = 0;
  6357. int maxValue = 0;
  6358. int addValue = 0;
  6359. string text = "";
  6360. #region Dura gem
  6361. minValue = realItem.Durability;
  6362. if (minValue > 0 && realItem.Type == ItemType.Gem)
  6363. {
  6364. switch (realItem.Shape)
  6365. {
  6366. default:
  6367. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AddsDurability, minValue / 1000);
  6368. break;
  6369. case 8:
  6370. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SealsFor, Functions.PrintTimeSpanFromSeconds(minValue * 60));
  6371. break;
  6372. }
  6373. count++;
  6374. MirLabel DuraLabel = new MirLabel
  6375. {
  6376. AutoSize = true,
  6377. ForeColour = Color.White,
  6378. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6379. OutLine = true,
  6380. Parent = ItemLabel,
  6381. Text = text
  6382. };
  6383. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DuraLabel.DisplayRectangle.Right + 4),
  6384. Math.Max(ItemLabel.Size.Height, DuraLabel.DisplayRectangle.Bottom));
  6385. }
  6386. #endregion
  6387. #region DC
  6388. minValue = realItem.Stats[Stat.MinDC];
  6389. maxValue = realItem.Stats[Stat.MaxDC];
  6390. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MaxDC] : 0;
  6391. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6392. {
  6393. count++;
  6394. if (HoverItem.Info.Type != ItemType.Gem)
  6395. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DC, minValue, maxValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6396. else
  6397. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AddsDC, minValue + maxValue + addValue);
  6398. MirLabel DCLabel = new MirLabel
  6399. {
  6400. AutoSize = true,
  6401. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6402. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6403. OutLine = true,
  6404. Parent = ItemLabel,
  6405. Text = text
  6406. };
  6407. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DCLabel.DisplayRectangle.Right + 4),
  6408. Math.Max(ItemLabel.Size.Height, DCLabel.DisplayRectangle.Bottom));
  6409. }
  6410. #endregion
  6411. #region MC
  6412. minValue = realItem.Stats[Stat.MinMC];
  6413. maxValue = realItem.Stats[Stat.MaxMC];
  6414. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MaxMC] : 0;
  6415. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6416. {
  6417. count++;
  6418. if (HoverItem.Info.Type != ItemType.Gem)
  6419. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MC, minValue, maxValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6420. else
  6421. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AddsMC, minValue + maxValue + addValue);
  6422. MirLabel MCLabel = new MirLabel
  6423. {
  6424. AutoSize = true,
  6425. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6426. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6427. OutLine = true,
  6428. Parent = ItemLabel,
  6429. Text = text
  6430. };
  6431. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MCLabel.DisplayRectangle.Right + 4),
  6432. Math.Max(ItemLabel.Size.Height, MCLabel.DisplayRectangle.Bottom));
  6433. }
  6434. #endregion
  6435. #region SC
  6436. minValue = realItem.Stats[Stat.MinSC];
  6437. maxValue = realItem.Stats[Stat.MaxSC];
  6438. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MaxSC] : 0;
  6439. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6440. {
  6441. count++;
  6442. if (HoverItem.Info.Type != ItemType.Gem)
  6443. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SC, minValue, maxValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6444. else
  6445. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AddsSC, minValue + maxValue + addValue);
  6446. MirLabel SCLabel = new MirLabel
  6447. {
  6448. AutoSize = true,
  6449. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6450. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6451. OutLine = true,
  6452. Parent = ItemLabel,
  6453. //Text = string.Format("SC + {0}~{1}", minValue, maxValue + addValue)
  6454. Text = text
  6455. };
  6456. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, SCLabel.DisplayRectangle.Right + 4),
  6457. Math.Max(ItemLabel.Size.Height, SCLabel.DisplayRectangle.Bottom));
  6458. }
  6459. #endregion
  6460. #region LUCK / SUCCESS
  6461. minValue = realItem.Stats[Stat.Luck];
  6462. maxValue = 0;
  6463. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.Luck] : 0;
  6464. if (minValue != 0 || addValue != 0)
  6465. {
  6466. count++;
  6467. if (realItem.Type == ItemType.Pets && realItem.Shape == 28)
  6468. {
  6469. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.BagWeightPercent, minValue + addValue);
  6470. }
  6471. else if (realItem.Type == ItemType.Potion && realItem.Shape == 4)
  6472. {
  6473. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExpPercent, minValue + addValue);
  6474. }
  6475. else if (realItem.Type == ItemType.Potion && realItem.Shape == 5)
  6476. {
  6477. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DropPercent, minValue + addValue);
  6478. }
  6479. else
  6480. {
  6481. text = string.Format(minValue + addValue > 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Luck) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CursePlusValue),
  6482. Math.Abs(minValue + addValue));
  6483. }
  6484. MirLabel LUCKLabel = new MirLabel
  6485. {
  6486. AutoSize = true,
  6487. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6488. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6489. OutLine = true,
  6490. Parent = ItemLabel,
  6491. Text = text
  6492. };
  6493. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, LUCKLabel.DisplayRectangle.Right + 4),
  6494. Math.Max(ItemLabel.Size.Height, LUCKLabel.DisplayRectangle.Bottom));
  6495. }
  6496. #endregion
  6497. #region ACC
  6498. minValue = realItem.Stats[Stat.Accuracy];
  6499. maxValue = 0;
  6500. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.Accuracy] : 0;
  6501. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6502. {
  6503. count++;
  6504. if (HoverItem.Info.Type != ItemType.Gem)
  6505. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Accuracy, minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6506. else
  6507. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AddsAccuracyValue, minValue + maxValue + addValue);
  6508. MirLabel ACCLabel = new MirLabel
  6509. {
  6510. AutoSize = true,
  6511. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6512. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6513. OutLine = true,
  6514. Parent = ItemLabel,
  6515. //Text = string.Format("Accuracy + {0}", minValue + addValue)
  6516. Text = text
  6517. };
  6518. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, ACCLabel.DisplayRectangle.Right + 4),
  6519. Math.Max(ItemLabel.Size.Height, ACCLabel.DisplayRectangle.Bottom));
  6520. }
  6521. #endregion
  6522. #region HOLY
  6523. minValue = realItem.Stats[Stat.Holy];
  6524. maxValue = 0;
  6525. addValue = 0;
  6526. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6527. {
  6528. count++;
  6529. MirLabel HOLYLabel = new MirLabel
  6530. {
  6531. AutoSize = true,
  6532. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6533. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6534. OutLine = true,
  6535. Parent = ItemLabel,
  6536. //Text = string.Format("Holy + {0}", minValue + addValue)
  6537. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Holy, minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty)
  6538. };
  6539. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, HOLYLabel.DisplayRectangle.Right + 4),
  6540. Math.Max(ItemLabel.Size.Height, HOLYLabel.DisplayRectangle.Bottom));
  6541. }
  6542. #endregion
  6543. #region ASPEED
  6544. minValue = realItem.Stats[Stat.AttackSpeed];
  6545. maxValue = 0;
  6546. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.AttackSpeed] : 0;
  6547. if (minValue != 0 || maxValue != 0 || addValue != 0)
  6548. {
  6549. string plus = (addValue + minValue < 0) ? String.Empty : "+";
  6550. count++;
  6551. if (HoverItem.Info.Type != ItemType.Gem)
  6552. {
  6553. string negative = "+";
  6554. if (addValue < 0) negative = String.Empty;
  6555. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AttackSpeedValue), plus, minValue + addValue) + (addValue != 0 ? $" ({negative}{addValue})" : string.Empty);
  6556. //text = string.Format(addValue != 0 ? "A.Speed: " + plus + "{0} ({2}{1})" : "A.Speed: " + plus + "{0}", minValue + addValue, addValue, negative);
  6557. //text = string.Format(addValue > 0 ? "A.Speed: + {0} (+{1})" : "A.Speed: + {0}", minValue + addValue, addValue);
  6558. }
  6559. else
  6560. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddAttackSpeed), minValue + maxValue + addValue);
  6561. MirLabel ASPEEDLabel = new MirLabel
  6562. {
  6563. AutoSize = true,
  6564. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6565. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6566. OutLine = true,
  6567. Parent = ItemLabel,
  6568. //Text = string.Format("A.Speed + {0}", minValue + addValue)
  6569. Text = text
  6570. };
  6571. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, ASPEEDLabel.DisplayRectangle.Right + 4),
  6572. Math.Max(ItemLabel.Size.Height, ASPEEDLabel.DisplayRectangle.Bottom));
  6573. }
  6574. #endregion
  6575. #region FREEZING
  6576. minValue = realItem.Stats[Stat.Freezing];
  6577. maxValue = 0;
  6578. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.Freezing] : 0;
  6579. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6580. {
  6581. count++;
  6582. if (HoverItem.Info.Type != ItemType.Gem)
  6583. {
  6584. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.FreezingPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6585. }
  6586. else text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddsFreezingPlus), minValue + maxValue + addValue);
  6587. MirLabel FREEZINGLabel = new MirLabel
  6588. {
  6589. AutoSize = true,
  6590. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6591. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6592. OutLine = true,
  6593. Parent = ItemLabel,
  6594. //Text = string.Format("Freezing + {0}", minValue + addValue)
  6595. Text = text
  6596. };
  6597. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, FREEZINGLabel.DisplayRectangle.Right + 4),
  6598. Math.Max(ItemLabel.Size.Height, FREEZINGLabel.DisplayRectangle.Bottom));
  6599. }
  6600. #endregion
  6601. #region POISON
  6602. minValue = realItem.Stats[Stat.PoisonAttack];
  6603. maxValue = 0;
  6604. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.PoisonAttack] : 0;
  6605. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6606. {
  6607. count++;
  6608. if (HoverItem.Info.Type != ItemType.Gem)
  6609. {
  6610. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PoisonPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6611. }
  6612. else
  6613. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddsPoisonPlus), minValue + maxValue + addValue);
  6614. MirLabel POISONLabel = new MirLabel
  6615. {
  6616. AutoSize = true,
  6617. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6618. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6619. OutLine = true,
  6620. Parent = ItemLabel,
  6621. //Text = string.Format("Poison + {0}", minValue + addValue)
  6622. Text = text
  6623. };
  6624. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, POISONLabel.DisplayRectangle.Right + 4),
  6625. Math.Max(ItemLabel.Size.Height, POISONLabel.DisplayRectangle.Bottom));
  6626. }
  6627. #endregion
  6628. #region CRITICALRATE / FLEXIBILITY
  6629. minValue = realItem.Stats[Stat.CriticalRate];
  6630. maxValue = 0;
  6631. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.CriticalRate] : 0;
  6632. if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem.Type != ItemType.Gem))
  6633. {
  6634. count++;
  6635. MirLabel CRITICALRATELabel = new MirLabel
  6636. {
  6637. AutoSize = true,
  6638. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6639. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6640. OutLine = true,
  6641. Parent = ItemLabel,
  6642. //Text = string.Format("Critical Chance + {0}", minValue + addValue)
  6643. //Text = string.Format(addValue > 0 ? "Critical Chance: + {0} (+{1})" : "Critical Chance: + {0}", minValue + addValue, addValue)
  6644. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CriticalChancePlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty)
  6645. };
  6646. if (fishingItem)
  6647. {
  6648. CRITICALRATELabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.FlexibilityPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6649. }
  6650. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, CRITICALRATELabel.DisplayRectangle.Right + 4),
  6651. Math.Max(ItemLabel.Size.Height, CRITICALRATELabel.DisplayRectangle.Bottom));
  6652. }
  6653. #endregion
  6654. #region CRITICALDAMAGE
  6655. minValue = realItem.Stats[Stat.CriticalDamage];
  6656. maxValue = 0;
  6657. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.CriticalDamage] : 0;
  6658. if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem.Type != ItemType.Gem))
  6659. {
  6660. count++;
  6661. MirLabel CRITICALDAMAGELabel = new MirLabel
  6662. {
  6663. AutoSize = true,
  6664. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6665. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6666. OutLine = true,
  6667. Parent = ItemLabel,
  6668. //Text = string.Format("Critical Damage + {0}", minValue + addValue)
  6669. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CriticalDamagePlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty)
  6670. };
  6671. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, CRITICALDAMAGELabel.DisplayRectangle.Right + 4),
  6672. Math.Max(ItemLabel.Size.Height, CRITICALDAMAGELabel.DisplayRectangle.Bottom));
  6673. }
  6674. #endregion
  6675. #region Reflect
  6676. minValue = realItem.Stats[Stat.Reflect];
  6677. maxValue = 0;
  6678. addValue = 0;
  6679. if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem.Type != ItemType.Gem))
  6680. {
  6681. count++;
  6682. MirLabel ReflectLabel = new MirLabel
  6683. {
  6684. AutoSize = true,
  6685. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6686. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6687. OutLine = true,
  6688. Parent = ItemLabel,
  6689. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ReflectChance), minValue)
  6690. };
  6691. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, ReflectLabel.DisplayRectangle.Right + 4),
  6692. Math.Max(ItemLabel.Size.Height, ReflectLabel.DisplayRectangle.Bottom));
  6693. }
  6694. #endregion
  6695. #region Hpdrain
  6696. minValue = realItem.Stats[Stat.HPDrainRatePercent];
  6697. maxValue = 0;
  6698. addValue = 0;
  6699. if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem.Type != ItemType.Gem))
  6700. {
  6701. count++;
  6702. MirLabel HPdrainLabel = new MirLabel
  6703. {
  6704. AutoSize = true,
  6705. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6706. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6707. OutLine = true,
  6708. Parent = ItemLabel,
  6709. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.HPDrainRate), minValue)
  6710. };
  6711. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, HPdrainLabel.DisplayRectangle.Right + 4),
  6712. Math.Max(ItemLabel.Size.Height, HPdrainLabel.DisplayRectangle.Bottom));
  6713. }
  6714. #endregion
  6715. #region Exp Rate
  6716. minValue = realItem.Stats[Stat.ExpRatePercent];
  6717. maxValue = 0;
  6718. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.ExpRatePercent] : 0;
  6719. if (minValue != 0 || maxValue != 0 || addValue != 0)
  6720. {
  6721. string plus = (addValue + minValue < 0) ? string.Empty : "+";
  6722. count++;
  6723. string negative = "+";
  6724. if (addValue < 0) negative = String.Empty;
  6725. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ExpRate), plus, minValue + addValue) + (addValue != 0 ? $" ({negative}{addValue}%)" : String.Empty);
  6726. MirLabel expRateLabel = new MirLabel
  6727. {
  6728. AutoSize = true,
  6729. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6730. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6731. OutLine = true,
  6732. Parent = ItemLabel,
  6733. Text = text
  6734. };
  6735. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, expRateLabel.DisplayRectangle.Right + 4),
  6736. Math.Max(ItemLabel.Size.Height, expRateLabel.DisplayRectangle.Bottom));
  6737. }
  6738. #endregion
  6739. #region Drop Rate
  6740. minValue = realItem.Stats[Stat.ItemDropRatePercent];
  6741. maxValue = 0;
  6742. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.ItemDropRatePercent] : 0;
  6743. if (minValue != 0 || maxValue != 0 || addValue != 0)
  6744. {
  6745. string plus = (addValue + minValue < 0) ? String.Empty : "+";
  6746. count++;
  6747. string negative = "+";
  6748. if (addValue < 0) negative = String.Empty;
  6749. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DropRate), plus, minValue + addValue) + (addValue != 0 ? $" ({negative}{addValue}%)" : string.Empty);
  6750. MirLabel dropRateLabel = new MirLabel
  6751. {
  6752. AutoSize = true,
  6753. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6754. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6755. OutLine = true,
  6756. Parent = ItemLabel,
  6757. Text = text
  6758. };
  6759. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, dropRateLabel.DisplayRectangle.Right + 4),
  6760. Math.Max(ItemLabel.Size.Height, dropRateLabel.DisplayRectangle.Bottom));
  6761. }
  6762. #endregion
  6763. #region Gold Rate
  6764. minValue = realItem.Stats[Stat.GoldDropRatePercent];
  6765. maxValue = 0;
  6766. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.GoldDropRatePercent] : 0;
  6767. if (minValue != 0 || maxValue != 0 || addValue != 0)
  6768. {
  6769. string plus = (addValue + minValue < 0) ? String.Empty : "+";
  6770. count++;
  6771. string negative = "+";
  6772. if (addValue < 0) negative = "";
  6773. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.GoldRate), plus, minValue + addValue) + (addValue != 0 ? $" ({negative}{addValue}%)" : String.Empty);
  6774. MirLabel goldRateLabel = new MirLabel
  6775. {
  6776. AutoSize = true,
  6777. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6778. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6779. OutLine = true,
  6780. Parent = ItemLabel,
  6781. Text = text
  6782. };
  6783. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, goldRateLabel.DisplayRectangle.Right + 4),
  6784. Math.Max(ItemLabel.Size.Height, goldRateLabel.DisplayRectangle.Bottom));
  6785. }
  6786. #endregion
  6787. #region Hero
  6788. if (addedStats[Stat.Hero] > 0)
  6789. {
  6790. ClientHeroInformation heroInfo = HeroInfoList.FirstOrDefault(x => x.Index == addedStats[Stat.Hero]);
  6791. if (heroInfo != null)
  6792. {
  6793. count++;
  6794. text = heroInfo.ToString();
  6795. MirLabel heroLabel = new MirLabel
  6796. {
  6797. AutoSize = true,
  6798. ForeColour = Color.White,
  6799. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6800. OutLine = true,
  6801. Parent = ItemLabel,
  6802. Text = text
  6803. };
  6804. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, heroLabel.DisplayRectangle.Right + 4),
  6805. Math.Max(ItemLabel.Size.Height, heroLabel.DisplayRectangle.Bottom));
  6806. }
  6807. }
  6808. #endregion
  6809. if (count > 0)
  6810. {
  6811. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  6812. #region OUTLINE
  6813. MirControl outLine = new MirControl
  6814. {
  6815. BackColour = Color.FromArgb(255, 50, 50, 50),
  6816. Border = true,
  6817. BorderColour = Color.Gray,
  6818. NotControl = true,
  6819. Parent = ItemLabel,
  6820. Opacity = 0.4F,
  6821. Location = new Point(0, 0)
  6822. };
  6823. outLine.Size = ItemLabel.Size;
  6824. #endregion
  6825. return outLine;
  6826. }
  6827. else
  6828. {
  6829. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  6830. }
  6831. return null;
  6832. }
  6833. public MirControl DefenceInfoLabel(UserItem item, bool Inspect = false, bool hideAdded = false)
  6834. {
  6835. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  6836. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  6837. HoverItem = item;
  6838. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  6839. Stats addedStats = GetTotalAddedStats(item, level, job);
  6840. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  6841. bool fishingItem = false;
  6842. switch (HoverItem.Info.Type)
  6843. {
  6844. case ItemType.Hook:
  6845. case ItemType.Float:
  6846. case ItemType.Bait:
  6847. case ItemType.Finder:
  6848. case ItemType.Reel:
  6849. fishingItem = true;
  6850. break;
  6851. case ItemType.Weapon:
  6852. if (HoverItem.Info.Shape == 49 || HoverItem.Info.Shape == 50)
  6853. fishingItem = true;
  6854. break;
  6855. default:
  6856. fishingItem = false;
  6857. break;
  6858. }
  6859. int count = 0;
  6860. int minValue = 0;
  6861. int maxValue = 0;
  6862. int addValue = 0;
  6863. string text = "";
  6864. #region AC
  6865. minValue = realItem.Stats[Stat.MinAC];
  6866. maxValue = realItem.Stats[Stat.MaxAC];
  6867. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MaxAC] : 0;
  6868. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6869. {
  6870. count++;
  6871. if (HoverItem.Info.Type != ItemType.Gem)
  6872. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AC), minValue, maxValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6873. else
  6874. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddsAC), minValue + maxValue + addValue);
  6875. MirLabel ACLabel = new MirLabel
  6876. {
  6877. AutoSize = true,
  6878. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6879. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6880. OutLine = true,
  6881. Parent = ItemLabel,
  6882. //Text = string.Format("AC + {0}~{1}", minValue, maxValue + addValue)
  6883. Text = text
  6884. };
  6885. if (fishingItem)
  6886. {
  6887. if (HoverItem.Info.Type == ItemType.Float)
  6888. {
  6889. ACLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.NibbleChance), minValue, maxValue + addValue) +
  6890. (addValue > 0 ? $" (+{addValue})" : String.Empty);
  6891. }
  6892. else if (HoverItem.Info.Type == ItemType.Finder)
  6893. {
  6894. ACLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.FinderIncrease), minValue, maxValue + addValue) +
  6895. (addValue > 0 ? $" (+{addValue})" : String.Empty);
  6896. }
  6897. else
  6898. {
  6899. ACLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.SuccessChance), maxValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty);
  6900. }
  6901. }
  6902. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, ACLabel.DisplayRectangle.Right + 4),
  6903. Math.Max(ItemLabel.Size.Height, ACLabel.DisplayRectangle.Bottom));
  6904. }
  6905. #endregion
  6906. #region MAC
  6907. minValue = realItem.Stats[Stat.MinMAC];
  6908. maxValue = realItem.Stats[Stat.MaxMAC];
  6909. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MaxMAC] : 0;
  6910. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6911. {
  6912. count++;
  6913. if (HoverItem.Info.Type != ItemType.Gem)
  6914. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MAC), minValue, maxValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  6915. else
  6916. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddsMAC), minValue + maxValue + addValue);
  6917. MirLabel MACLabel = new MirLabel
  6918. {
  6919. AutoSize = true,
  6920. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6921. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6922. OutLine = true,
  6923. Parent = ItemLabel,
  6924. //Text = string.Format("MAC + {0}~{1}", minValue, maxValue + addValue)
  6925. Text = text
  6926. };
  6927. if (fishingItem)
  6928. {
  6929. MACLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AutoReelChance), maxValue + addValue);
  6930. }
  6931. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MACLabel.DisplayRectangle.Right + 4),
  6932. Math.Max(ItemLabel.Size.Height, MACLabel.DisplayRectangle.Bottom));
  6933. }
  6934. #endregion
  6935. #region MAXHP
  6936. if (HoverItem.Info.Type != ItemType.MonsterSpawn)
  6937. {
  6938. minValue = realItem.Stats[Stat.HP];
  6939. maxValue = 0;
  6940. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.HP] : 0;
  6941. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6942. {
  6943. count++;
  6944. MirLabel MAXHPLabel = new MirLabel
  6945. {
  6946. AutoSize = true,
  6947. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6948. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6949. OutLine = true,
  6950. Parent = ItemLabel,
  6951. //Text = string.Format(realItem.Type == ItemType.Potion ? "HP + {0} Recovery" : "MAXHP + {0}", minValue + addValue)
  6952. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxHpPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  6953. };
  6954. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXHPLabel.DisplayRectangle.Right + 4),
  6955. Math.Max(ItemLabel.Size.Height, MAXHPLabel.DisplayRectangle.Bottom));
  6956. }
  6957. }
  6958. #endregion
  6959. #region MAXMP
  6960. minValue = realItem.Stats[Stat.MP];
  6961. maxValue = 0;
  6962. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MP] : 0;
  6963. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6964. {
  6965. count++;
  6966. MirLabel MAXMPLabel = new MirLabel
  6967. {
  6968. AutoSize = true,
  6969. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6970. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6971. OutLine = true,
  6972. Parent = ItemLabel,
  6973. //Text = string.Format(realItem.Type == ItemType.Potion ? "MP + {0} Recovery" : "MAXMP + {0}", minValue + addValue)
  6974. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxMpPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  6975. };
  6976. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXMPLabel.DisplayRectangle.Right + 4),
  6977. Math.Max(ItemLabel.Size.Height, MAXMPLabel.DisplayRectangle.Bottom));
  6978. }
  6979. #endregion
  6980. #region MAXHPRATE
  6981. minValue = realItem.Stats[Stat.HPRatePercent];
  6982. maxValue = 0;
  6983. addValue = 0;
  6984. if (minValue > 0 || maxValue > 0 || addValue > 0)
  6985. {
  6986. count++;
  6987. MirLabel MAXHPRATELabel = new MirLabel
  6988. {
  6989. AutoSize = true,
  6990. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  6991. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  6992. OutLine = true,
  6993. Parent = ItemLabel,
  6994. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxHpPlusPercent), minValue + addValue)
  6995. };
  6996. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXHPRATELabel.DisplayRectangle.Right + 4),
  6997. Math.Max(ItemLabel.Size.Height, MAXHPRATELabel.DisplayRectangle.Bottom));
  6998. }
  6999. #endregion
  7000. #region MAXMPRATE
  7001. minValue = realItem.Stats[Stat.MPRatePercent];
  7002. maxValue = 0;
  7003. addValue = 0;
  7004. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7005. {
  7006. count++;
  7007. MirLabel MAXMPRATELabel = new MirLabel
  7008. {
  7009. AutoSize = true,
  7010. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7011. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7012. OutLine = true,
  7013. Parent = ItemLabel,
  7014. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxMpPlusPercent), minValue + addValue)
  7015. };
  7016. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXMPRATELabel.DisplayRectangle.Right + 4),
  7017. Math.Max(ItemLabel.Size.Height, MAXMPRATELabel.DisplayRectangle.Bottom));
  7018. }
  7019. #endregion
  7020. #region MAXACRATE
  7021. minValue = realItem.Stats[Stat.MaxACRatePercent];
  7022. maxValue = 0;
  7023. addValue = 0;
  7024. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7025. {
  7026. count++;
  7027. MirLabel MAXACRATE = new MirLabel
  7028. {
  7029. AutoSize = true,
  7030. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7031. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7032. OutLine = true,
  7033. Parent = ItemLabel,
  7034. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxAcPlusPercent), minValue + addValue)
  7035. };
  7036. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXACRATE.DisplayRectangle.Right + 4),
  7037. Math.Max(ItemLabel.Size.Height, MAXACRATE.DisplayRectangle.Bottom));
  7038. }
  7039. #endregion
  7040. #region MAXMACRATE
  7041. minValue = realItem.Stats[Stat.MaxMACRatePercent];
  7042. maxValue = 0;
  7043. addValue = 0;
  7044. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7045. {
  7046. count++;
  7047. MirLabel MAXMACRATELabel = new MirLabel
  7048. {
  7049. AutoSize = true,
  7050. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7051. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7052. OutLine = true,
  7053. Parent = ItemLabel,
  7054. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxMacPlusPercent), minValue + addValue)
  7055. };
  7056. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXMACRATELabel.DisplayRectangle.Right + 4),
  7057. Math.Max(ItemLabel.Size.Height, MAXMACRATELabel.DisplayRectangle.Bottom));
  7058. }
  7059. #endregion
  7060. #region HEALTH_RECOVERY
  7061. minValue = realItem.Stats[Stat.HealthRecovery];
  7062. maxValue = 0;
  7063. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.HealthRecovery] : 0;
  7064. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7065. {
  7066. count++;
  7067. MirLabel HEALTH_RECOVERYLabel = new MirLabel
  7068. {
  7069. AutoSize = true,
  7070. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7071. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7072. OutLine = true,
  7073. Parent = ItemLabel,
  7074. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.HealthRecoveryPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7075. };
  7076. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, HEALTH_RECOVERYLabel.DisplayRectangle.Right + 4),
  7077. Math.Max(ItemLabel.Size.Height, HEALTH_RECOVERYLabel.DisplayRectangle.Bottom));
  7078. }
  7079. #endregion
  7080. #region MANA_RECOVERY
  7081. minValue = realItem.Stats[Stat.SpellRecovery];
  7082. maxValue = 0;
  7083. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.SpellRecovery] : 0;
  7084. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7085. {
  7086. count++;
  7087. MirLabel MANA_RECOVERYLabel = new MirLabel
  7088. {
  7089. AutoSize = true,
  7090. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7091. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7092. OutLine = true,
  7093. Parent = ItemLabel,
  7094. //Text = string.Format("ManaRecovery + {0}", minValue + addValue)
  7095. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ManaRecoveryPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7096. };
  7097. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MANA_RECOVERYLabel.DisplayRectangle.Right + 4),
  7098. Math.Max(ItemLabel.Size.Height, MANA_RECOVERYLabel.DisplayRectangle.Bottom));
  7099. }
  7100. #endregion
  7101. #region POISON_RECOVERY
  7102. minValue = realItem.Stats[Stat.PoisonRecovery];
  7103. maxValue = 0;
  7104. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.PoisonRecovery] : 0;
  7105. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7106. {
  7107. count++;
  7108. MirLabel POISON_RECOVERYabel = new MirLabel
  7109. {
  7110. AutoSize = true,
  7111. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7112. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7113. OutLine = true,
  7114. Parent = ItemLabel,
  7115. //Text = string.Format("Poison Recovery + {0}", minValue + addValue)
  7116. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PoisonRecoveryPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7117. };
  7118. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, POISON_RECOVERYabel.DisplayRectangle.Right + 4),
  7119. Math.Max(ItemLabel.Size.Height, POISON_RECOVERYabel.DisplayRectangle.Bottom));
  7120. }
  7121. #endregion
  7122. #region AGILITY
  7123. minValue = realItem.Stats[Stat.Agility];
  7124. maxValue = 0;
  7125. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.Agility] : 0;
  7126. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7127. {
  7128. count++;
  7129. if (HoverItem.Info.Type != ItemType.Gem)
  7130. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.Agility), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : string.Empty);
  7131. else
  7132. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddsAgilityPlus), minValue + maxValue + addValue);
  7133. MirLabel AGILITYLabel = new MirLabel
  7134. {
  7135. AutoSize = true,
  7136. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7137. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7138. OutLine = true,
  7139. Parent = ItemLabel,
  7140. Text = text
  7141. };
  7142. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, AGILITYLabel.DisplayRectangle.Right + 4),
  7143. Math.Max(ItemLabel.Size.Height, AGILITYLabel.DisplayRectangle.Bottom));
  7144. }
  7145. #endregion
  7146. #region STRONG
  7147. minValue = realItem.Stats[Stat.Strong];
  7148. maxValue = 0;
  7149. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.Strong] : 0;
  7150. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7151. {
  7152. count++;
  7153. MirLabel STRONGLabel = new MirLabel
  7154. {
  7155. AutoSize = true,
  7156. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7157. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7158. OutLine = true,
  7159. Parent = ItemLabel,
  7160. //Text = string.Format("Strong + {0}", minValue + addValue)
  7161. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.StrongPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7162. };
  7163. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, STRONGLabel.DisplayRectangle.Right + 4),
  7164. Math.Max(ItemLabel.Size.Height, STRONGLabel.DisplayRectangle.Bottom));
  7165. }
  7166. #endregion
  7167. #region POISON_RESIST
  7168. minValue = realItem.Stats[Stat.PoisonResist];
  7169. maxValue = 0;
  7170. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.PoisonResist] : 0;
  7171. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7172. {
  7173. count++;
  7174. if (HoverItem.Info.Type != ItemType.Gem)
  7175. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.PoisonResistPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty);
  7176. else
  7177. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddPoisonResistPlus), minValue + maxValue + addValue);
  7178. MirLabel POISON_RESISTLabel = new MirLabel
  7179. {
  7180. AutoSize = true,
  7181. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7182. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7183. OutLine = true,
  7184. Parent = ItemLabel,
  7185. Text = text
  7186. };
  7187. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, POISON_RESISTLabel.DisplayRectangle.Right + 4),
  7188. Math.Max(ItemLabel.Size.Height, POISON_RESISTLabel.DisplayRectangle.Bottom));
  7189. }
  7190. #endregion
  7191. #region MAGIC_RESIST
  7192. minValue = realItem.Stats[Stat.MagicResist];
  7193. maxValue = 0;
  7194. addValue = (!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) ? addedStats[Stat.MagicResist] : 0;
  7195. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7196. {
  7197. count++;
  7198. if (HoverItem.Info.Type != ItemType.Gem)
  7199. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MagicResistPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty);
  7200. else
  7201. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddMagicResistPlus), minValue + maxValue + addValue);
  7202. MirLabel MAGIC_RESISTLabel = new MirLabel
  7203. {
  7204. AutoSize = true,
  7205. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7206. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7207. OutLine = true,
  7208. Parent = ItemLabel,
  7209. //Text = string.Format("Magic Resist + {0}", minValue + addValue)
  7210. Text = text
  7211. };
  7212. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAGIC_RESISTLabel.DisplayRectangle.Right + 4),
  7213. Math.Max(ItemLabel.Size.Height, MAGIC_RESISTLabel.DisplayRectangle.Bottom));
  7214. }
  7215. #endregion
  7216. #region MAX_DC_RATE
  7217. minValue = realItem.Stats[Stat.MaxDCRatePercent];
  7218. maxValue = 0;
  7219. addValue = 0;
  7220. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7221. {
  7222. count++;
  7223. MirLabel MAXDCRATE = new MirLabel
  7224. {
  7225. AutoSize = true,
  7226. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7227. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7228. OutLine = true,
  7229. Parent = ItemLabel,
  7230. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxDcPlusPercent), minValue + addValue)
  7231. };
  7232. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXDCRATE.DisplayRectangle.Right + 4),
  7233. Math.Max(ItemLabel.Size.Height, MAXDCRATE.DisplayRectangle.Bottom));
  7234. }
  7235. #endregion
  7236. #region MAX_MC_RATE
  7237. minValue = realItem.Stats[Stat.MaxMCRatePercent];
  7238. maxValue = 0;
  7239. addValue = 0;
  7240. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7241. {
  7242. count++;
  7243. MirLabel MAXMCRATE = new MirLabel
  7244. {
  7245. AutoSize = true,
  7246. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7247. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7248. OutLine = true,
  7249. Parent = ItemLabel,
  7250. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxMcPlusPercent), minValue + addValue)
  7251. };
  7252. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXMCRATE.DisplayRectangle.Right + 4),
  7253. Math.Max(ItemLabel.Size.Height, MAXMCRATE.DisplayRectangle.Bottom));
  7254. }
  7255. #endregion
  7256. #region MAX_SC_RATE
  7257. minValue = realItem.Stats[Stat.MaxSCRatePercent];
  7258. maxValue = 0;
  7259. addValue = 0;
  7260. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7261. {
  7262. count++;
  7263. MirLabel MAXSCRATE = new MirLabel
  7264. {
  7265. AutoSize = true,
  7266. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7267. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7268. OutLine = true,
  7269. Parent = ItemLabel,
  7270. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxScPlusPercent), minValue + addValue)
  7271. };
  7272. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, MAXSCRATE.DisplayRectangle.Right + 4),
  7273. Math.Max(ItemLabel.Size.Height, MAXSCRATE.DisplayRectangle.Bottom));
  7274. }
  7275. #endregion
  7276. #region DAMAGE_REDUCTION
  7277. minValue = realItem.Stats[Stat.DamageReductionPercent];
  7278. maxValue = 0;
  7279. addValue = 0;
  7280. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7281. {
  7282. count++;
  7283. MirLabel DAMAGEREDUC = new MirLabel
  7284. {
  7285. AutoSize = true,
  7286. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7287. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7288. OutLine = true,
  7289. Parent = ItemLabel,
  7290. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AllDamageReductionPlusPercent), minValue + addValue)
  7291. };
  7292. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DAMAGEREDUC.DisplayRectangle.Right + 4),
  7293. Math.Max(ItemLabel.Size.Height, DAMAGEREDUC.DisplayRectangle.Bottom));
  7294. }
  7295. #endregion
  7296. if (count > 0)
  7297. {
  7298. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7299. #region OUTLINE
  7300. MirControl outLine = new MirControl
  7301. {
  7302. BackColour = Color.FromArgb(255, 50, 50, 50),
  7303. Border = true,
  7304. BorderColour = Color.Gray,
  7305. NotControl = true,
  7306. Parent = ItemLabel,
  7307. Opacity = 0.4F,
  7308. Location = new Point(0, 0)
  7309. };
  7310. outLine.Size = ItemLabel.Size;
  7311. #endregion
  7312. return outLine;
  7313. }
  7314. else
  7315. {
  7316. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  7317. }
  7318. return null;
  7319. }
  7320. public MirControl WeightInfoLabel(UserItem item, bool Inspect = false)
  7321. {
  7322. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  7323. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  7324. HoverItem = item;
  7325. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  7326. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7327. int count = 0;
  7328. int minValue = 0;
  7329. int maxValue = 0;
  7330. int addValue = 0;
  7331. #region HANDWEIGHT
  7332. minValue = realItem.Stats[Stat.HandWeight];
  7333. maxValue = 0;
  7334. addValue = 0;
  7335. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7336. {
  7337. count++;
  7338. MirLabel HANDWEIGHTLabel = new MirLabel
  7339. {
  7340. AutoSize = true,
  7341. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7342. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7343. OutLine = true,
  7344. Parent = ItemLabel,
  7345. //Text = string.Format("Hand Weight + {0}", minValue + addValue)
  7346. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.HandWeightPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7347. };
  7348. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, HANDWEIGHTLabel.DisplayRectangle.Right + 4),
  7349. Math.Max(ItemLabel.Size.Height, HANDWEIGHTLabel.DisplayRectangle.Bottom));
  7350. }
  7351. #endregion
  7352. #region WEARWEIGHT
  7353. minValue = realItem.Stats[Stat.WearWeight];
  7354. maxValue = 0;
  7355. addValue = 0;
  7356. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7357. {
  7358. count++;
  7359. MirLabel WEARWEIGHTLabel = new MirLabel
  7360. {
  7361. AutoSize = true,
  7362. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7363. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7364. OutLine = true,
  7365. Parent = ItemLabel,
  7366. //Text = string.Format("Wear Weight + {0}", minValue + addValue)
  7367. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.WearWeightPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7368. };
  7369. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, WEARWEIGHTLabel.DisplayRectangle.Right + 4),
  7370. Math.Max(ItemLabel.Size.Height, WEARWEIGHTLabel.DisplayRectangle.Bottom));
  7371. }
  7372. #endregion
  7373. #region BAGWEIGHT
  7374. minValue = realItem.Stats[Stat.BagWeight];
  7375. maxValue = 0;
  7376. addValue = 0;
  7377. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7378. {
  7379. count++;
  7380. MirLabel BAGWEIGHTLabel = new MirLabel
  7381. {
  7382. AutoSize = true,
  7383. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7384. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7385. OutLine = true,
  7386. Parent = ItemLabel,
  7387. //Text = string.Format("Bag Weight + {0}", minValue + addValue)
  7388. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.BagWeightPlus), minValue + addValue) + (addValue > 0 ? $" (+{addValue})" : String.Empty)
  7389. };
  7390. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, BAGWEIGHTLabel.DisplayRectangle.Right + 4),
  7391. Math.Max(ItemLabel.Size.Height, BAGWEIGHTLabel.DisplayRectangle.Bottom));
  7392. }
  7393. #endregion
  7394. #region FASTRUN
  7395. minValue = realItem.CanFastRun == true ? 1 : 0;
  7396. maxValue = 0;
  7397. addValue = 0;
  7398. if (minValue > 0 || maxValue > 0 || addValue > 0)
  7399. {
  7400. count++;
  7401. MirLabel BAGWEIGHTLabel = new MirLabel
  7402. {
  7403. AutoSize = true,
  7404. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7405. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7406. OutLine = true,
  7407. Parent = ItemLabel,
  7408. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InstantRun)
  7409. };
  7410. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, BAGWEIGHTLabel.DisplayRectangle.Right + 4),
  7411. Math.Max(ItemLabel.Size.Height, BAGWEIGHTLabel.DisplayRectangle.Bottom));
  7412. }
  7413. #endregion
  7414. #region TIME & RANGE
  7415. minValue = 0;
  7416. maxValue = 0;
  7417. addValue = 0;
  7418. if (HoverItem.Info.Type == ItemType.Potion && HoverItem.Info.Durability > 0)
  7419. {
  7420. count++;
  7421. MirLabel TNRLabel = new MirLabel
  7422. {
  7423. AutoSize = true,
  7424. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7425. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7426. OutLine = true,
  7427. Parent = ItemLabel,
  7428. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.TimeValue), Functions.PrintTimeSpanFromSeconds(HoverItem.Info.Durability * 60))
  7429. };
  7430. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, TNRLabel.DisplayRectangle.Right + 4),
  7431. Math.Max(ItemLabel.Size.Height, TNRLabel.DisplayRectangle.Bottom));
  7432. }
  7433. if (HoverItem.Info.Type == ItemType.Transform && HoverItem.Info.Durability > 0)
  7434. {
  7435. count++;
  7436. MirLabel TNRLabel = new MirLabel
  7437. {
  7438. AutoSize = true,
  7439. ForeColour = addValue > 0 ? Color.Cyan : Color.White,
  7440. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7441. OutLine = true,
  7442. Parent = ItemLabel,
  7443. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.TimeValue), Functions.PrintTimeSpanFromSeconds(HoverItem.Info.Durability, false))
  7444. };
  7445. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, TNRLabel.DisplayRectangle.Right + 4),
  7446. Math.Max(ItemLabel.Size.Height, TNRLabel.DisplayRectangle.Bottom));
  7447. }
  7448. #endregion
  7449. if (count > 0)
  7450. {
  7451. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7452. #region OUTLINE
  7453. MirControl outLine = new MirControl
  7454. {
  7455. BackColour = Color.FromArgb(255, 50, 50, 50),
  7456. Border = true,
  7457. BorderColour = Color.Gray,
  7458. NotControl = true,
  7459. Parent = ItemLabel,
  7460. Opacity = 0.4F,
  7461. Location = new Point(0, 0)
  7462. };
  7463. outLine.Size = ItemLabel.Size;
  7464. #endregion
  7465. return outLine;
  7466. }
  7467. else
  7468. {
  7469. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  7470. }
  7471. return null;
  7472. }
  7473. public MirControl AwakeInfoLabel(UserItem item, bool Inspect = false)
  7474. {
  7475. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  7476. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  7477. HoverItem = item;
  7478. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  7479. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7480. int count = 0;
  7481. #region AWAKENAME
  7482. if (HoverItem.Awake.GetAwakeLevel() > 0)
  7483. {
  7484. count++;
  7485. MirLabel AWAKENAMELabel = new MirLabel
  7486. {
  7487. AutoSize = true,
  7488. ForeColour = GradeNameColor(HoverItem.Info.Grade),
  7489. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7490. OutLine = true,
  7491. Parent = ItemLabel,
  7492. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AwakeningWithValue), HoverItem.Awake.Type.ToLocalizedString(), HoverItem.Awake.GetAwakeLevel())
  7493. };
  7494. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, AWAKENAMELabel.DisplayRectangle.Right + 4),
  7495. Math.Max(ItemLabel.Size.Height, AWAKENAMELabel.DisplayRectangle.Bottom));
  7496. }
  7497. #endregion
  7498. #region AWAKE_TOTAL_VALUE
  7499. if (HoverItem.Awake.GetAwakeValue() > 0)
  7500. {
  7501. count++;
  7502. MirLabel AWAKE_TOTAL_VALUELabel = new MirLabel
  7503. {
  7504. AutoSize = true,
  7505. ForeColour = Color.White,
  7506. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7507. OutLine = true,
  7508. Parent = ItemLabel,
  7509. Text = string.Format(realItem.Type != ItemType.Armour ? "{0} + {1}~{2}" : "MAX {0} + {1}", HoverItem.Awake.Type.ToLocalizedString(), HoverItem.Awake.GetAwakeValue(), HoverItem.Awake.GetAwakeValue())
  7510. };
  7511. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, AWAKE_TOTAL_VALUELabel.DisplayRectangle.Right + 4),
  7512. Math.Max(ItemLabel.Size.Height, AWAKE_TOTAL_VALUELabel.DisplayRectangle.Bottom));
  7513. }
  7514. #endregion
  7515. #region AWAKE_LEVEL_VALUE
  7516. if (HoverItem.Awake.GetAwakeLevel() > 0)
  7517. {
  7518. count++;
  7519. for (int i = 0; i < HoverItem.Awake.GetAwakeLevel(); i++)
  7520. {
  7521. MirLabel AWAKE_LEVEL_VALUELabel = new MirLabel
  7522. {
  7523. AutoSize = true,
  7524. ForeColour = Color.White,
  7525. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7526. OutLine = true,
  7527. Parent = ItemLabel,
  7528. Text = string.Format(realItem.Type != ItemType.Armour ? "Level {0} : {1} + {2}~{3}" : "Level {0} : MAX {1} + {2}~{3}", i + 1, HoverItem.Awake.Type.ToLocalizedString(), HoverItem.Awake.GetAwakeLevelValue(i), HoverItem.Awake.GetAwakeLevelValue(i))
  7529. };
  7530. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, AWAKE_LEVEL_VALUELabel.DisplayRectangle.Right + 4),
  7531. Math.Max(ItemLabel.Size.Height, AWAKE_LEVEL_VALUELabel.DisplayRectangle.Bottom));
  7532. }
  7533. }
  7534. #endregion
  7535. if (count > 0)
  7536. {
  7537. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7538. #region OUTLINE
  7539. MirControl outLine = new MirControl
  7540. {
  7541. BackColour = Color.FromArgb(255, 50, 50, 50),
  7542. Border = true,
  7543. BorderColour = Color.Gray,
  7544. NotControl = true,
  7545. Parent = ItemLabel,
  7546. Opacity = 0.4F,
  7547. Location = new Point(0, 0)
  7548. };
  7549. outLine.Size = ItemLabel.Size;
  7550. #endregion
  7551. return outLine;
  7552. }
  7553. else
  7554. {
  7555. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  7556. }
  7557. return null;
  7558. }
  7559. public MirControl SocketInfoLabel(UserItem item, bool Inspect = false)
  7560. {
  7561. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  7562. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  7563. HoverItem = item;
  7564. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  7565. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7566. int count = 0;
  7567. #region SOCKET
  7568. for (int i = 0; i < item.Slots.Length; i++)
  7569. {
  7570. count++;
  7571. MirLabel SOCKETLabel = new MirLabel
  7572. {
  7573. AutoSize = true,
  7574. ForeColour = (count > realItem.Slots && !realItem.IsFishingRod && realItem.Type != ItemType.Mount) ? Color.Cyan : Color.White,
  7575. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7576. OutLine = true,
  7577. Parent = ItemLabel,
  7578. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.SocketWithValue),
  7579. item.Slots[i] == null ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Empty) : item.Slots[i].FriendlyName)
  7580. };
  7581. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, SOCKETLabel.DisplayRectangle.Right + 4),
  7582. Math.Max(ItemLabel.Size.Height, SOCKETLabel.DisplayRectangle.Bottom));
  7583. }
  7584. #endregion
  7585. if (count > 0)
  7586. {
  7587. #region SOCKET
  7588. count++;
  7589. MirLabel SOCKETLabel = new MirLabel
  7590. {
  7591. AutoSize = true,
  7592. ForeColour = Color.White,
  7593. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7594. OutLine = true,
  7595. Parent = ItemLabel,
  7596. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.OpenSocketsTips)
  7597. };
  7598. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, SOCKETLabel.DisplayRectangle.Right + 4),
  7599. Math.Max(ItemLabel.Size.Height, SOCKETLabel.DisplayRectangle.Bottom));
  7600. #endregion
  7601. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7602. #region OUTLINE
  7603. MirControl outLine = new MirControl
  7604. {
  7605. BackColour = Color.FromArgb(255, 50, 50, 50),
  7606. Border = true,
  7607. BorderColour = Color.Gray,
  7608. NotControl = true,
  7609. Parent = ItemLabel,
  7610. Opacity = 0.4F,
  7611. Location = new Point(0, 0)
  7612. };
  7613. outLine.Size = ItemLabel.Size;
  7614. #endregion
  7615. return outLine;
  7616. }
  7617. else
  7618. {
  7619. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  7620. }
  7621. return null;
  7622. }
  7623. public MirControl NeedInfoLabel(UserItem item, bool Inspect = false)
  7624. {
  7625. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  7626. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  7627. HoverItem = item;
  7628. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  7629. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7630. int count = 0;
  7631. #region LEVEL
  7632. if (realItem.RequiredAmount > 0)
  7633. {
  7634. count++;
  7635. string text;
  7636. Color colour = Color.White;
  7637. switch (realItem.RequiredType)
  7638. {
  7639. case RequiredType.Level:
  7640. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredLevel), realItem.RequiredAmount);
  7641. if (MapObject.User.Level < realItem.RequiredAmount)
  7642. colour = Color.Red;
  7643. break;
  7644. case RequiredType.MaxAC:
  7645. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredAC), realItem.RequiredAmount);
  7646. if (MapObject.User.Stats[Stat.MaxAC] < realItem.RequiredAmount)
  7647. colour = Color.Red;
  7648. break;
  7649. case RequiredType.MaxMAC:
  7650. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredMAC), realItem.RequiredAmount);
  7651. if (MapObject.User.Stats[Stat.MaxMAC] < realItem.RequiredAmount)
  7652. colour = Color.Red;
  7653. break;
  7654. case RequiredType.MaxDC:
  7655. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredDC), realItem.RequiredAmount);
  7656. if (MapObject.User.Stats[Stat.MaxDC] < realItem.RequiredAmount)
  7657. colour = Color.Red;
  7658. break;
  7659. case RequiredType.MaxMC:
  7660. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredMC), realItem.RequiredAmount);
  7661. if (MapObject.User.Stats[Stat.MaxMC] < realItem.RequiredAmount)
  7662. colour = Color.Red;
  7663. break;
  7664. case RequiredType.MaxSC:
  7665. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredSC), realItem.RequiredAmount);
  7666. if (MapObject.User.Stats[Stat.MaxSC] < realItem.RequiredAmount)
  7667. colour = Color.Red;
  7668. break;
  7669. case RequiredType.MaxLevel:
  7670. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaximumLevel), realItem.RequiredAmount);
  7671. if (MapObject.User.Level > realItem.RequiredAmount)
  7672. colour = Color.Red;
  7673. break;
  7674. case RequiredType.MinAC:
  7675. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredBaseAC), realItem.RequiredAmount);
  7676. if (MapObject.User.Stats[Stat.MinAC] < realItem.RequiredAmount)
  7677. colour = Color.Red;
  7678. break;
  7679. case RequiredType.MinMAC:
  7680. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredBaseMAC), realItem.RequiredAmount);
  7681. if (MapObject.User.Stats[Stat.MinMAC] < realItem.RequiredAmount)
  7682. colour = Color.Red;
  7683. break;
  7684. case RequiredType.MinDC:
  7685. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredBaseDC), realItem.RequiredAmount);
  7686. if (MapObject.User.Stats[Stat.MinDC] < realItem.RequiredAmount)
  7687. colour = Color.Red;
  7688. break;
  7689. case RequiredType.MinMC:
  7690. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredBaseMC), realItem.RequiredAmount);
  7691. if (MapObject.User.Stats[Stat.MinMC] < realItem.RequiredAmount)
  7692. colour = Color.Red;
  7693. break;
  7694. case RequiredType.MinSC:
  7695. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RequiredBaseSC), realItem.RequiredAmount);
  7696. if (MapObject.User.Stats[Stat.MinSC] < realItem.RequiredAmount)
  7697. colour = Color.Red;
  7698. break;
  7699. default:
  7700. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UnknownTypeRequired);
  7701. break;
  7702. }
  7703. MirLabel LEVELLabel = new MirLabel
  7704. {
  7705. AutoSize = true,
  7706. ForeColour = colour,
  7707. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7708. OutLine = true,
  7709. Parent = ItemLabel,
  7710. Text = text
  7711. };
  7712. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, LEVELLabel.DisplayRectangle.Right + 4),
  7713. Math.Max(ItemLabel.Size.Height, LEVELLabel.DisplayRectangle.Bottom));
  7714. }
  7715. #endregion
  7716. #region CLASS
  7717. if (realItem.RequiredClass != RequiredClass.None)
  7718. {
  7719. count++;
  7720. Color colour = Color.White;
  7721. switch (MapObject.User.Class)
  7722. {
  7723. case MirClass.Warrior:
  7724. if (!realItem.RequiredClass.HasFlag(RequiredClass.Warrior))
  7725. colour = Color.Red;
  7726. break;
  7727. case MirClass.Wizard:
  7728. if (!realItem.RequiredClass.HasFlag(RequiredClass.Wizard))
  7729. colour = Color.Red;
  7730. break;
  7731. case MirClass.Taoist:
  7732. if (!realItem.RequiredClass.HasFlag(RequiredClass.Taoist))
  7733. colour = Color.Red;
  7734. break;
  7735. case MirClass.Assassin:
  7736. if (!realItem.RequiredClass.HasFlag(RequiredClass.Assassin))
  7737. colour = Color.Red;
  7738. break;
  7739. case MirClass.Archer:
  7740. if (!realItem.RequiredClass.HasFlag(RequiredClass.Archer))
  7741. colour = Color.Red;
  7742. break;
  7743. }
  7744. MirLabel CLASSLabel = new MirLabel
  7745. {
  7746. AutoSize = true,
  7747. ForeColour = colour,
  7748. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7749. OutLine = true,
  7750. Parent = ItemLabel,
  7751. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ClassRequired), realItem.RequiredClass.ToLocalizedString())
  7752. };
  7753. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, CLASSLabel.DisplayRectangle.Right + 4),
  7754. Math.Max(ItemLabel.Size.Height, CLASSLabel.DisplayRectangle.Bottom));
  7755. }
  7756. #endregion
  7757. #region BUYING - SELLING PRICE
  7758. if (item.Price() > 0)
  7759. {
  7760. count++;
  7761. string text;
  7762. var colour = Color.White;
  7763. text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.SellingPriceGold), ((long)(item.Price() / 2)).ToString("###,###,##0"));
  7764. var costLabel = new MirLabel
  7765. {
  7766. AutoSize = true,
  7767. ForeColour = colour,
  7768. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7769. OutLine = true,
  7770. Parent = ItemLabel,
  7771. Text = text
  7772. };
  7773. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, costLabel.DisplayRectangle.Right + 4),
  7774. Math.Max(ItemLabel.Size.Height, costLabel.DisplayRectangle.Bottom));
  7775. }
  7776. #endregion
  7777. if (count > 0)
  7778. {
  7779. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7780. #region OUTLINE
  7781. MirControl outLine = new MirControl
  7782. {
  7783. BackColour = Color.FromArgb(255, 50, 50, 50),
  7784. Border = true,
  7785. BorderColour = Color.Gray,
  7786. NotControl = true,
  7787. Parent = ItemLabel,
  7788. Opacity = 0.4F,
  7789. Location = new Point(0, 0)
  7790. };
  7791. outLine.Size = ItemLabel.Size;
  7792. #endregion
  7793. return outLine;
  7794. }
  7795. else
  7796. {
  7797. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  7798. }
  7799. return null;
  7800. }
  7801. public MirControl BindInfoLabel(UserItem item, bool Inspect = false, bool hideAdded = false)
  7802. {
  7803. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  7804. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  7805. HoverItem = item;
  7806. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  7807. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  7808. int count = 0;
  7809. #region DONT_DEATH_DROP
  7810. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontDeathdrop))
  7811. {
  7812. count++;
  7813. MirLabel DONT_DEATH_DROPLabel = new MirLabel
  7814. {
  7815. AutoSize = true,
  7816. ForeColour = Color.Yellow,
  7817. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7818. OutLine = true,
  7819. Parent = ItemLabel,
  7820. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantDropOnDeath)
  7821. };
  7822. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_DEATH_DROPLabel.DisplayRectangle.Right + 4),
  7823. Math.Max(ItemLabel.Size.Height, DONT_DEATH_DROPLabel.DisplayRectangle.Bottom));
  7824. }
  7825. #endregion
  7826. #region DONT_DROP
  7827. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontDrop))
  7828. {
  7829. count++;
  7830. MirLabel DONT_DROPLabel = new MirLabel
  7831. {
  7832. AutoSize = true,
  7833. ForeColour = Color.Yellow,
  7834. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7835. OutLine = true,
  7836. Parent = ItemLabel,
  7837. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantDrop)
  7838. };
  7839. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_DROPLabel.DisplayRectangle.Right + 4),
  7840. Math.Max(ItemLabel.Size.Height, DONT_DROPLabel.DisplayRectangle.Bottom));
  7841. }
  7842. #endregion
  7843. #region DONT_UPGRADE
  7844. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontUpgrade))
  7845. {
  7846. count++;
  7847. MirLabel DONT_UPGRADELabel = new MirLabel
  7848. {
  7849. AutoSize = true,
  7850. ForeColour = Color.Yellow,
  7851. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7852. OutLine = true,
  7853. Parent = ItemLabel,
  7854. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantUpgrade)
  7855. };
  7856. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_UPGRADELabel.DisplayRectangle.Right + 4),
  7857. Math.Max(ItemLabel.Size.Height, DONT_UPGRADELabel.DisplayRectangle.Bottom));
  7858. }
  7859. #endregion
  7860. #region DONT_SELL
  7861. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontSell))
  7862. {
  7863. count++;
  7864. MirLabel DONT_SELLLabel = new MirLabel
  7865. {
  7866. AutoSize = true,
  7867. ForeColour = Color.Yellow,
  7868. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7869. OutLine = true,
  7870. Parent = ItemLabel,
  7871. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantSell)
  7872. };
  7873. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_SELLLabel.DisplayRectangle.Right + 4),
  7874. Math.Max(ItemLabel.Size.Height, DONT_SELLLabel.DisplayRectangle.Bottom));
  7875. }
  7876. #endregion
  7877. #region DONT_TRADE
  7878. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontTrade))
  7879. {
  7880. count++;
  7881. MirLabel DONT_TRADELabel = new MirLabel
  7882. {
  7883. AutoSize = true,
  7884. ForeColour = Color.Yellow,
  7885. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7886. OutLine = true,
  7887. Parent = ItemLabel,
  7888. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantTrade)
  7889. };
  7890. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_TRADELabel.DisplayRectangle.Right + 4),
  7891. Math.Max(ItemLabel.Size.Height, DONT_TRADELabel.DisplayRectangle.Bottom));
  7892. }
  7893. #endregion
  7894. #region DONT_STORE
  7895. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontStore))
  7896. {
  7897. count++;
  7898. MirLabel DONT_STORELabel = new MirLabel
  7899. {
  7900. AutoSize = true,
  7901. ForeColour = Color.Yellow,
  7902. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7903. OutLine = true,
  7904. Parent = ItemLabel,
  7905. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantStore)
  7906. };
  7907. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_STORELabel.DisplayRectangle.Right + 4),
  7908. Math.Max(ItemLabel.Size.Height, DONT_STORELabel.DisplayRectangle.Bottom));
  7909. }
  7910. #endregion
  7911. #region DONT_REPAIR
  7912. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DontRepair))
  7913. {
  7914. count++;
  7915. MirLabel DONT_REPAIRLabel = new MirLabel
  7916. {
  7917. AutoSize = true,
  7918. ForeColour = Color.Yellow,
  7919. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7920. OutLine = true,
  7921. Parent = ItemLabel,
  7922. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantRepair)
  7923. };
  7924. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_REPAIRLabel.DisplayRectangle.Right + 4),
  7925. Math.Max(ItemLabel.Size.Height, DONT_REPAIRLabel.DisplayRectangle.Bottom));
  7926. }
  7927. #endregion
  7928. #region DONT_SPECIALREPAIR
  7929. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.NoSRepair))
  7930. {
  7931. count++;
  7932. MirLabel DONT_REPAIRLabel = new MirLabel
  7933. {
  7934. AutoSize = true,
  7935. ForeColour = Color.Yellow,
  7936. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7937. OutLine = true,
  7938. Parent = ItemLabel,
  7939. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CantSpecialRepair)
  7940. };
  7941. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_REPAIRLabel.DisplayRectangle.Right + 4),
  7942. Math.Max(ItemLabel.Size.Height, DONT_REPAIRLabel.DisplayRectangle.Bottom));
  7943. }
  7944. #endregion
  7945. #region BREAK_ON_DEATH
  7946. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.BreakOnDeath))
  7947. {
  7948. count++;
  7949. MirLabel DONT_REPAIRLabel = new MirLabel
  7950. {
  7951. AutoSize = true,
  7952. ForeColour = Color.Yellow,
  7953. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7954. OutLine = true,
  7955. Parent = ItemLabel,
  7956. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.BreaksOnDeath)
  7957. };
  7958. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_REPAIRLabel.DisplayRectangle.Right + 4),
  7959. Math.Max(ItemLabel.Size.Height, DONT_REPAIRLabel.DisplayRectangle.Bottom));
  7960. }
  7961. #endregion
  7962. #region DONT_DESTROY_ON_DROP
  7963. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.DestroyOnDrop))
  7964. {
  7965. count++;
  7966. MirLabel DONT_DODLabel = new MirLabel
  7967. {
  7968. AutoSize = true,
  7969. ForeColour = Color.Yellow,
  7970. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7971. OutLine = true,
  7972. Parent = ItemLabel,
  7973. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DestroyedWhenDropped)
  7974. };
  7975. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, DONT_DODLabel.DisplayRectangle.Right + 4),
  7976. Math.Max(ItemLabel.Size.Height, DONT_DODLabel.DisplayRectangle.Bottom));
  7977. }
  7978. #endregion
  7979. #region NoWeddingRing
  7980. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.NoWeddingRing))
  7981. {
  7982. count++;
  7983. MirLabel No_WedLabel = new MirLabel
  7984. {
  7985. AutoSize = true,
  7986. ForeColour = Color.Yellow,
  7987. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  7988. OutLine = true,
  7989. Parent = ItemLabel,
  7990. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotBeWeddingRing)
  7991. };
  7992. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, No_WedLabel.DisplayRectangle.Right + 4),
  7993. Math.Max(ItemLabel.Size.Height, No_WedLabel.DisplayRectangle.Bottom));
  7994. }
  7995. #endregion
  7996. #region NoHero
  7997. if (HoverItem.Info.Bind != BindMode.None && HoverItem.Info.Bind.HasFlag(BindMode.NoHero))
  7998. {
  7999. count++;
  8000. MirLabel No_HeroLabel = new MirLabel
  8001. {
  8002. AutoSize = true,
  8003. ForeColour = Color.Yellow,
  8004. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8005. OutLine = true,
  8006. Parent = ItemLabel,
  8007. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotBeUsedByHero)
  8008. };
  8009. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, No_HeroLabel.DisplayRectangle.Right + 4),
  8010. Math.Max(ItemLabel.Size.Height, No_HeroLabel.DisplayRectangle.Bottom));
  8011. }
  8012. #endregion
  8013. #region BIND_ON_EQUIP
  8014. if ((HoverItem.Info.Bind.HasFlag(BindMode.BindOnEquip)) & HoverItem.SoulBoundId == -1)
  8015. {
  8016. count++;
  8017. MirLabel BOELabel = new MirLabel
  8018. {
  8019. AutoSize = true,
  8020. ForeColour = Color.Yellow,
  8021. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8022. OutLine = true,
  8023. Parent = ItemLabel,
  8024. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SoulBindsOnEquip)
  8025. };
  8026. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, BOELabel.DisplayRectangle.Right + 4),
  8027. Math.Max(ItemLabel.Size.Height, BOELabel.DisplayRectangle.Bottom));
  8028. }
  8029. else if (HoverItem.SoulBoundId != -1)
  8030. {
  8031. count++;
  8032. MirLabel BOELabel = new MirLabel
  8033. {
  8034. AutoSize = true,
  8035. ForeColour = Color.Yellow,
  8036. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8037. OutLine = true,
  8038. Parent = ItemLabel,
  8039. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SoulboundTo) + GetUserName((uint)HoverItem.SoulBoundId)
  8040. };
  8041. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, BOELabel.DisplayRectangle.Right + 4),
  8042. Math.Max(ItemLabel.Size.Height, BOELabel.DisplayRectangle.Bottom));
  8043. }
  8044. #endregion
  8045. #region CURSED
  8046. if ((!hideAdded && (!HoverItem.Info.NeedIdentify || HoverItem.Identified)) && HoverItem.Cursed)
  8047. {
  8048. count++;
  8049. MirLabel CURSEDLabel = new MirLabel
  8050. {
  8051. AutoSize = true,
  8052. ForeColour = Color.Yellow,
  8053. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8054. OutLine = true,
  8055. Parent = ItemLabel,
  8056. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Cursed)
  8057. };
  8058. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, CURSEDLabel.DisplayRectangle.Right + 4),
  8059. Math.Max(ItemLabel.Size.Height, CURSEDLabel.DisplayRectangle.Bottom));
  8060. }
  8061. #endregion
  8062. #region Gems
  8063. if (HoverItem.Info.Type == ItemType.Gem)
  8064. {
  8065. #region UseOn text
  8066. count++;
  8067. string Text = "";
  8068. if (HoverItem.Info.Unique == SpecialItemMode.None)
  8069. {
  8070. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CannotBeUsedOnAnyItem);
  8071. }
  8072. else
  8073. {
  8074. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CanBeUsedOn);
  8075. }
  8076. MirLabel GemUseOn = new MirLabel
  8077. {
  8078. AutoSize = true,
  8079. ForeColour = Color.Yellow,
  8080. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8081. OutLine = true,
  8082. Parent = ItemLabel,
  8083. Text = Text
  8084. };
  8085. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GemUseOn.DisplayRectangle.Right + 4),
  8086. Math.Max(ItemLabel.Size.Height, GemUseOn.DisplayRectangle.Bottom));
  8087. #endregion
  8088. #region Weapon text
  8089. count++;
  8090. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Paralize))
  8091. {
  8092. MirLabel GemWeapon = new MirLabel
  8093. {
  8094. AutoSize = true,
  8095. ForeColour = Color.White,
  8096. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8097. OutLine = true,
  8098. Parent = ItemLabel,
  8099. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterWeapon)
  8100. };
  8101. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GemWeapon.DisplayRectangle.Right + 4),
  8102. Math.Max(ItemLabel.Size.Height, GemWeapon.DisplayRectangle.Bottom));
  8103. }
  8104. #endregion
  8105. #region Armour text
  8106. count++;
  8107. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Teleport))
  8108. {
  8109. MirLabel GemArmour = new MirLabel
  8110. {
  8111. AutoSize = true,
  8112. ForeColour = Color.White,
  8113. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8114. OutLine = true,
  8115. Parent = ItemLabel,
  8116. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterArmour)
  8117. };
  8118. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GemArmour.DisplayRectangle.Right + 4),
  8119. Math.Max(ItemLabel.Size.Height, GemArmour.DisplayRectangle.Bottom));
  8120. }
  8121. #endregion
  8122. #region Helmet text
  8123. count++;
  8124. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.ClearRing))
  8125. {
  8126. MirLabel Gemhelmet = new MirLabel
  8127. {
  8128. AutoSize = true,
  8129. ForeColour = Color.White,
  8130. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8131. OutLine = true,
  8132. Parent = ItemLabel,
  8133. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterHelmet)
  8134. };
  8135. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gemhelmet.DisplayRectangle.Right + 4),
  8136. Math.Max(ItemLabel.Size.Height, Gemhelmet.DisplayRectangle.Bottom));
  8137. }
  8138. #endregion
  8139. #region Necklace text
  8140. count++;
  8141. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Protection))
  8142. {
  8143. MirLabel Gemnecklace = new MirLabel
  8144. {
  8145. AutoSize = true,
  8146. ForeColour = Color.White,
  8147. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8148. OutLine = true,
  8149. Parent = ItemLabel,
  8150. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterNecklace)
  8151. };
  8152. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gemnecklace.DisplayRectangle.Right + 4),
  8153. Math.Max(ItemLabel.Size.Height, Gemnecklace.DisplayRectangle.Bottom));
  8154. }
  8155. #endregion
  8156. #region Bracelet text
  8157. count++;
  8158. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Revival))
  8159. {
  8160. MirLabel GemBracelet = new MirLabel
  8161. {
  8162. AutoSize = true,
  8163. ForeColour = Color.White,
  8164. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8165. OutLine = true,
  8166. Parent = ItemLabel,
  8167. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterBracelet)
  8168. };
  8169. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GemBracelet.DisplayRectangle.Right + 4),
  8170. Math.Max(ItemLabel.Size.Height, GemBracelet.DisplayRectangle.Bottom));
  8171. }
  8172. #endregion
  8173. #region Ring text
  8174. count++;
  8175. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Muscle))
  8176. {
  8177. MirLabel GemRing = new MirLabel
  8178. {
  8179. AutoSize = true,
  8180. ForeColour = Color.White,
  8181. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8182. OutLine = true,
  8183. Parent = ItemLabel,
  8184. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterRing)
  8185. };
  8186. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GemRing.DisplayRectangle.Right + 4),
  8187. Math.Max(ItemLabel.Size.Height, GemRing.DisplayRectangle.Bottom));
  8188. }
  8189. #endregion
  8190. #region Amulet text
  8191. count++;
  8192. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Flame))
  8193. {
  8194. MirLabel Gemamulet = new MirLabel
  8195. {
  8196. AutoSize = true,
  8197. ForeColour = Color.White,
  8198. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8199. OutLine = true,
  8200. Parent = ItemLabel,
  8201. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterAmulet)
  8202. };
  8203. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gemamulet.DisplayRectangle.Right + 4),
  8204. Math.Max(ItemLabel.Size.Height, Gemamulet.DisplayRectangle.Bottom));
  8205. }
  8206. #endregion
  8207. #region Belt text
  8208. count++;
  8209. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Healing))
  8210. {
  8211. MirLabel Gembelt = new MirLabel
  8212. {
  8213. AutoSize = true,
  8214. ForeColour = Color.White,
  8215. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8216. OutLine = true,
  8217. Parent = ItemLabel,
  8218. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterBelt)
  8219. };
  8220. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gembelt.DisplayRectangle.Right + 4),
  8221. Math.Max(ItemLabel.Size.Height, Gembelt.DisplayRectangle.Bottom));
  8222. }
  8223. #endregion
  8224. #region Boots text
  8225. count++;
  8226. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Probe))
  8227. {
  8228. MirLabel Gemboots = new MirLabel
  8229. {
  8230. AutoSize = true,
  8231. ForeColour = Color.White,
  8232. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8233. OutLine = true,
  8234. Parent = ItemLabel,
  8235. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterBoots)
  8236. };
  8237. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gemboots.DisplayRectangle.Right + 4),
  8238. Math.Max(ItemLabel.Size.Height, Gemboots.DisplayRectangle.Bottom));
  8239. }
  8240. #endregion
  8241. #region Stone text
  8242. count++;
  8243. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.Skill))
  8244. {
  8245. MirLabel Gemstone = new MirLabel
  8246. {
  8247. AutoSize = true,
  8248. ForeColour = Color.White,
  8249. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8250. OutLine = true,
  8251. Parent = ItemLabel,
  8252. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Stone)
  8253. };
  8254. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gemstone.DisplayRectangle.Right + 4),
  8255. Math.Max(ItemLabel.Size.Height, Gemstone.DisplayRectangle.Bottom));
  8256. }
  8257. #endregion
  8258. #region Torch text
  8259. count++;
  8260. if (HoverItem.Info.Unique.HasFlag(SpecialItemMode.NoDuraLoss))
  8261. {
  8262. MirLabel Gemtorch = new MirLabel
  8263. {
  8264. AutoSize = true,
  8265. ForeColour = Color.White,
  8266. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8267. OutLine = true,
  8268. Parent = ItemLabel,
  8269. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AfterCandle)
  8270. };
  8271. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, Gemtorch.DisplayRectangle.Right + 4),
  8272. Math.Max(ItemLabel.Size.Height, Gemtorch.DisplayRectangle.Bottom));
  8273. }
  8274. #endregion
  8275. }
  8276. #endregion
  8277. #region CANTAWAKEN
  8278. //if ((HoverItem.Info.CanAwakening != true) && (HoverItem.Info.Type != ItemType.Gem))
  8279. //{
  8280. // count++;
  8281. // MirLabel CANTAWAKENINGLabel = new MirLabel
  8282. // {
  8283. // AutoSize = true,
  8284. // ForeColour = Color.Yellow,
  8285. // Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8286. // OutLine = true,
  8287. // Parent = ItemLabel,
  8288. // Text = string.Format("Can't awaken")
  8289. // };
  8290. // ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, CANTAWAKENINGLabel.DisplayRectangle.Right + 4),
  8291. // Math.Max(ItemLabel.Size.Height, CANTAWAKENINGLabel.DisplayRectangle.Bottom));
  8292. //}
  8293. #endregion
  8294. #region EXPIRE
  8295. if (HoverItem.ExpireInfo != null)
  8296. {
  8297. double remainingSeconds = (HoverItem.ExpireInfo.ExpiryDate - CMain.Now).TotalSeconds;
  8298. count++;
  8299. MirLabel EXPIRELabel = new MirLabel
  8300. {
  8301. AutoSize = true,
  8302. ForeColour = Color.Yellow,
  8303. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8304. OutLine = true,
  8305. Parent = ItemLabel,
  8306. Text = remainingSeconds > 0 ? GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ExpiresIn), Functions.PrintTimeSpanFromSeconds(remainingSeconds)) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Expired)
  8307. };
  8308. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, EXPIRELabel.DisplayRectangle.Right + 4),
  8309. Math.Max(ItemLabel.Size.Height, EXPIRELabel.DisplayRectangle.Bottom));
  8310. }
  8311. #endregion
  8312. #region SEALED
  8313. if (HoverItem.SealedInfo != null)
  8314. {
  8315. double remainingSeconds = (HoverItem.SealedInfo.ExpiryDate - CMain.Now).TotalSeconds;
  8316. if (remainingSeconds > 0)
  8317. {
  8318. count++;
  8319. MirLabel SEALEDLabel = new MirLabel
  8320. {
  8321. AutoSize = true,
  8322. ForeColour = Color.Red,
  8323. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8324. OutLine = true,
  8325. Parent = ItemLabel,
  8326. Text = remainingSeconds > 0 ? GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.SealedFor), Functions.PrintTimeSpanFromSeconds(remainingSeconds)) : string.Empty
  8327. };
  8328. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, SEALEDLabel.DisplayRectangle.Right + 4),
  8329. Math.Max(ItemLabel.Size.Height, SEALEDLabel.DisplayRectangle.Bottom));
  8330. }
  8331. }
  8332. #endregion
  8333. if (HoverItem.RentalInformation?.RentalLocked == false)
  8334. {
  8335. count++;
  8336. MirLabel OWNERLabel = new MirLabel
  8337. {
  8338. AutoSize = true,
  8339. ForeColour = Color.DarkKhaki,
  8340. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8341. OutLine = true,
  8342. Parent = ItemLabel,
  8343. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemRentedFrom) + HoverItem.RentalInformation.OwnerName
  8344. };
  8345. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, OWNERLabel.DisplayRectangle.Right + 4),
  8346. Math.Max(ItemLabel.Size.Height, OWNERLabel.DisplayRectangle.Bottom));
  8347. double remainingTime = (HoverItem.RentalInformation.ExpiryDate - CMain.Now).TotalSeconds;
  8348. count++;
  8349. MirLabel RENTALLabel = new MirLabel
  8350. {
  8351. AutoSize = true,
  8352. ForeColour = Color.Khaki,
  8353. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8354. OutLine = true,
  8355. Parent = ItemLabel,
  8356. Text = remainingTime > 0 ? GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RentalExpiresIn), Functions.PrintTimeSpanFromSeconds(remainingTime)) : "Rental expired"
  8357. };
  8358. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, RENTALLabel.DisplayRectangle.Right + 4),
  8359. Math.Max(ItemLabel.Size.Height, RENTALLabel.DisplayRectangle.Bottom));
  8360. }
  8361. else if (HoverItem.RentalInformation?.RentalLocked == true && HoverItem.RentalInformation.ExpiryDate > CMain.Now)
  8362. {
  8363. count++;
  8364. var remainingTime = (HoverItem.RentalInformation.ExpiryDate - CMain.Now).TotalSeconds;
  8365. var RentalLockLabel = new MirLabel
  8366. {
  8367. AutoSize = true,
  8368. ForeColour = Color.DarkKhaki,
  8369. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8370. OutLine = true,
  8371. Parent = ItemLabel,
  8372. Text = remainingTime > 0
  8373. ? GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RentalLockExpiresIn), Functions.PrintTimeSpanFromSeconds(remainingTime))
  8374. : "Rental lock expired"
  8375. };
  8376. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, RentalLockLabel.DisplayRectangle.Right + 4),
  8377. Math.Max(ItemLabel.Size.Height, RentalLockLabel.DisplayRectangle.Bottom));
  8378. }
  8379. if (count > 0)
  8380. {
  8381. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  8382. #region OUTLINE
  8383. MirControl outLine = new MirControl
  8384. {
  8385. BackColour = Color.FromArgb(255, 50, 50, 50),
  8386. Border = true,
  8387. BorderColour = Color.Gray,
  8388. NotControl = true,
  8389. Parent = ItemLabel,
  8390. Opacity = 0.4F,
  8391. Location = new Point(0, 0)
  8392. };
  8393. outLine.Size = ItemLabel.Size;
  8394. #endregion
  8395. return outLine;
  8396. }
  8397. else
  8398. {
  8399. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  8400. }
  8401. return null;
  8402. }
  8403. public MirControl OverlapInfoLabel(UserItem item, bool Inspect = false)
  8404. {
  8405. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  8406. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  8407. HoverItem = item;
  8408. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  8409. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  8410. int count = 0;
  8411. #region GEM
  8412. if (realItem.Type == ItemType.Gem)
  8413. {
  8414. string text = "";
  8415. switch (realItem.Shape)
  8416. {
  8417. case 1:
  8418. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlPartialRepairWeaponsAccessories);
  8419. break;
  8420. case 2:
  8421. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlPartialRepairArmourDrapery);
  8422. break;
  8423. case 3:
  8424. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlCombineDestroyChance);
  8425. break;
  8426. case 4:
  8427. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlCombineNoDestroy);
  8428. break;
  8429. case 5:
  8430. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlFullRepairWeaponsAccessories);
  8431. break;
  8432. case 6:
  8433. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlFullRepairArmourDrapery);
  8434. break;
  8435. case 8:
  8436. text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HoldCtrlSealItem);
  8437. break;
  8438. }
  8439. count++;
  8440. MirLabel GEMLabel = new MirLabel
  8441. {
  8442. AutoSize = true,
  8443. ForeColour = Color.White,
  8444. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8445. OutLine = true,
  8446. Parent = ItemLabel,
  8447. Text = text
  8448. };
  8449. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GEMLabel.DisplayRectangle.Right + 4),
  8450. Math.Max(ItemLabel.Size.Height, GEMLabel.DisplayRectangle.Bottom));
  8451. }
  8452. #endregion
  8453. #region SPLITUP
  8454. if (realItem.StackSize > 1 && realItem.Type != ItemType.Gem)
  8455. {
  8456. count++;
  8457. MirLabel SPLITUPLabel = new MirLabel
  8458. {
  8459. AutoSize = true,
  8460. ForeColour = Color.White,
  8461. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8462. OutLine = true,
  8463. Parent = ItemLabel,
  8464. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.MaxCombine), realItem.StackSize, "\n")
  8465. };
  8466. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, SPLITUPLabel.DisplayRectangle.Right + 4),
  8467. Math.Max(ItemLabel.Size.Height, SPLITUPLabel.DisplayRectangle.Bottom));
  8468. }
  8469. #endregion
  8470. if (count > 0)
  8471. {
  8472. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  8473. #region OUTLINE
  8474. MirControl outLine = new MirControl
  8475. {
  8476. BackColour = Color.FromArgb(255, 50, 50, 50),
  8477. Border = true,
  8478. BorderColour = Color.Gray,
  8479. NotControl = true,
  8480. Parent = ItemLabel,
  8481. Opacity = 0.4F,
  8482. Location = new Point(0, 0)
  8483. };
  8484. outLine.Size = ItemLabel.Size;
  8485. #endregion
  8486. return outLine;
  8487. }
  8488. else
  8489. {
  8490. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  8491. }
  8492. return null;
  8493. }
  8494. public MirControl StoryInfoLabel(UserItem item, bool Inspect = false)
  8495. {
  8496. ushort level = Inspect ? InspectDialog.Level : MapObject.User.Level;
  8497. MirClass job = Inspect ? InspectDialog.Class : MapObject.User.Class;
  8498. HoverItem = item;
  8499. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  8500. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  8501. int count = 0;
  8502. #region TOOLTIP
  8503. if (realItem.Type == ItemType.Scroll && realItem.Shape == 7)//Credit Scroll
  8504. {
  8505. HoverItem.Info.ToolTip = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.AddsCreditsToAccount), HoverItem.Info.Price);
  8506. }
  8507. if (!string.IsNullOrEmpty(HoverItem.Info.ToolTip))
  8508. {
  8509. count++;
  8510. MirLabel IDLabel = new MirLabel
  8511. {
  8512. AutoSize = true,
  8513. ForeColour = Color.DarkKhaki,
  8514. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8515. OutLine = true,
  8516. Parent = ItemLabel,
  8517. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemDescription)
  8518. };
  8519. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, IDLabel.DisplayRectangle.Right + 4),
  8520. Math.Max(ItemLabel.Size.Height, IDLabel.DisplayRectangle.Bottom));
  8521. MirLabel TOOLTIPLabel = new MirLabel
  8522. {
  8523. AutoSize = true,
  8524. ForeColour = Color.Khaki,
  8525. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8526. OutLine = true,
  8527. Parent = ItemLabel,
  8528. Text = HoverItem.Info.ToolTip
  8529. };
  8530. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, TOOLTIPLabel.DisplayRectangle.Right + 4),
  8531. Math.Max(ItemLabel.Size.Height, TOOLTIPLabel.DisplayRectangle.Bottom));
  8532. }
  8533. #endregion
  8534. if (count > 0)
  8535. {
  8536. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  8537. #region OUTLINE
  8538. MirControl outLine = new MirControl
  8539. {
  8540. BackColour = Color.FromArgb(255, 50, 50, 50),
  8541. Border = true,
  8542. BorderColour = Color.Gray,
  8543. NotControl = true,
  8544. Parent = ItemLabel,
  8545. Opacity = 0.4F,
  8546. Location = new Point(0, 0)
  8547. };
  8548. outLine.Size = ItemLabel.Size;
  8549. #endregion
  8550. return outLine;
  8551. }
  8552. else
  8553. {
  8554. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height - 4);
  8555. }
  8556. return null;
  8557. }
  8558. public MirControl GMMadeLabel(UserItem item)
  8559. {
  8560. if (item.GMMade)
  8561. {
  8562. ItemLabel.Size = new Size(ItemLabel.Size.Width, ItemLabel.Size.Height + 4);
  8563. MirLabel GMLabel = new MirLabel
  8564. {
  8565. AutoSize = true,
  8566. ForeColour = Color.Orchid,
  8567. Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
  8568. OutLine = true,
  8569. Parent = ItemLabel,
  8570. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CreatedByGameMaster)
  8571. };
  8572. ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, GMLabel.DisplayRectangle.Right + 4),
  8573. Math.Max(ItemLabel.Size.Height + 4, GMLabel.DisplayRectangle.Bottom + 4));
  8574. MirControl outLine = new MirControl
  8575. {
  8576. BackColour = Color.FromArgb(255, 50, 50, 50),
  8577. Border = true,
  8578. BorderColour = Color.Gray,
  8579. NotControl = true,
  8580. Parent = ItemLabel,
  8581. Opacity = 0.4F,
  8582. Location = new Point(0, 0)
  8583. };
  8584. outLine.Size = ItemLabel.Size;
  8585. return outLine;
  8586. }
  8587. else
  8588. {
  8589. return null;
  8590. }
  8591. }
  8592. public void CreateItemLabel(UserItem item, bool inspect = false, bool hideDura = false, bool hideAdded = false)
  8593. {
  8594. CMain.DebugText = CMain.Random.Next(1, 100).ToString();
  8595. if (item == null || HoverItem != item)
  8596. {
  8597. DisposeItemLabel();
  8598. if (item == null)
  8599. {
  8600. HoverItem = null;
  8601. return;
  8602. }
  8603. }
  8604. if (item == HoverItem && ItemLabel != null && !ItemLabel.IsDisposed) return;
  8605. ushort level = inspect ? InspectDialog.Level : MapObject.User.Level;
  8606. MirClass job = inspect ? InspectDialog.Class : MapObject.User.Class;
  8607. HoverItem = item;
  8608. ItemInfo realItem = Functions.GetRealItem(item.Info, level, job, ItemInfoList);
  8609. ItemLabel = new MirControl
  8610. {
  8611. BackColour = Color.FromArgb(255, 0, 0, 0),
  8612. Border = true,
  8613. BorderColour = ((HoverItem.CurrentDura == 0 && HoverItem.MaxDura != 0) ? Color.Red : Color.FromArgb(255, 148, 146, 148)),
  8614. DrawControlTexture = true,
  8615. NotControl = true,
  8616. Parent = this,
  8617. Opacity = 0.8F
  8618. };
  8619. //Name Info Label
  8620. MirControl[] outlines = new MirControl[11];
  8621. outlines[0] = NameInfoLabel(item, inspect, hideDura);
  8622. //Attribute Info1 Label - Attack Info
  8623. outlines[1] = AttackInfoLabel(item, inspect, hideAdded);
  8624. //Attribute Info2 Label - Defence Info
  8625. outlines[2] = DefenceInfoLabel(item, inspect, hideAdded);
  8626. //Attribute Info3 Label - Weight Info
  8627. outlines[3] = WeightInfoLabel(item, inspect);
  8628. //Awake Info Label
  8629. outlines[4] = AwakeInfoLabel(item, inspect);
  8630. //Socket Info Label
  8631. outlines[5] = SocketInfoLabel(item, inspect);
  8632. //need Info Label
  8633. outlines[6] = NeedInfoLabel(item, inspect);
  8634. //Bind Info Label
  8635. outlines[7] = BindInfoLabel(item, inspect, hideAdded);
  8636. //Overlap Info Label
  8637. outlines[8] = OverlapInfoLabel(item, inspect);
  8638. //Story Label
  8639. outlines[9] = StoryInfoLabel(item, inspect);
  8640. //GM Made
  8641. outlines[10] = GMMadeLabel(item);
  8642. foreach (var outline in outlines)
  8643. {
  8644. if (outline != null)
  8645. {
  8646. outline.Size = new Size(ItemLabel.Size.Width, outline.Size.Height);
  8647. }
  8648. }
  8649. //ItemLabel.Visible = true;
  8650. }
  8651. public void CreateMailLabel(ClientMail mail)
  8652. {
  8653. if (mail == null)
  8654. {
  8655. DisposeMailLabel();
  8656. return;
  8657. }
  8658. if (MailLabel != null && !MailLabel.IsDisposed) return;
  8659. MailLabel = new MirControl
  8660. {
  8661. BackColour = Color.FromArgb(255, 50, 50, 50),
  8662. Border = true,
  8663. BorderColour = Color.Gray,
  8664. DrawControlTexture = true,
  8665. NotControl = true,
  8666. Parent = this,
  8667. Opacity = 0.7F
  8668. };
  8669. MirLabel nameLabel = new MirLabel
  8670. {
  8671. AutoSize = true,
  8672. ForeColour = Color.Yellow,
  8673. Location = new Point(4, 4),
  8674. OutLine = true,
  8675. Parent = MailLabel,
  8676. Text = mail.SenderName
  8677. };
  8678. MailLabel.Size = new Size(Math.Max(MailLabel.Size.Width, nameLabel.DisplayRectangle.Right + 4),
  8679. Math.Max(MailLabel.Size.Height, nameLabel.DisplayRectangle.Bottom));
  8680. MirLabel dateLabel = new MirLabel
  8681. {
  8682. AutoSize = true,
  8683. ForeColour = Color.White,
  8684. Location = new Point(4, MailLabel.DisplayRectangle.Bottom),
  8685. OutLine = true,
  8686. Parent = MailLabel,
  8687. Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DateSent), mail.DateSent.ToString("dd/MM/yy H:mm:ss"))
  8688. };
  8689. MailLabel.Size = new Size(Math.Max(MailLabel.Size.Width, dateLabel.DisplayRectangle.Right + 4),
  8690. Math.Max(MailLabel.Size.Height, dateLabel.DisplayRectangle.Bottom));
  8691. if (mail.Gold > 0)
  8692. {
  8693. MirLabel goldLabel = new MirLabel
  8694. {
  8695. AutoSize = true,
  8696. ForeColour = Color.White,
  8697. Location = new Point(4, MailLabel.DisplayRectangle.Bottom),
  8698. OutLine = true,
  8699. Parent = MailLabel,
  8700. Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MailGoldLabel) + mail.Gold
  8701. };
  8702. MailLabel.Size = new Size(Math.Max(MailLabel.Size.Width, goldLabel.DisplayRectangle.Right + 4),
  8703. Math.Max(MailLabel.Size.Height, goldLabel.DisplayRectangle.Bottom));
  8704. }
  8705. MirLabel openedLabel = new MirLabel
  8706. {
  8707. AutoSize = true,
  8708. ForeColour = Color.Red,
  8709. Location = new Point(4, MailLabel.DisplayRectangle.Bottom),
  8710. OutLine = true,
  8711. Parent = MailLabel,
  8712. Text = mail.Opened ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MailHeaderOld) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MailHeaderNew)
  8713. };
  8714. MailLabel.Size = new Size(Math.Max(MailLabel.Size.Width, openedLabel.DisplayRectangle.Right + 4),
  8715. Math.Max(MailLabel.Size.Height, openedLabel.DisplayRectangle.Bottom));
  8716. }
  8717. public void CreateMemoLabel(ClientFriend friend)
  8718. {
  8719. if (friend == null)
  8720. {
  8721. DisposeMemoLabel();
  8722. return;
  8723. }
  8724. if (MemoLabel != null && !MemoLabel.IsDisposed) return;
  8725. MemoLabel = new MirControl
  8726. {
  8727. BackColour = Color.FromArgb(255, 50, 50, 50),
  8728. Border = true,
  8729. BorderColour = Color.Gray,
  8730. DrawControlTexture = true,
  8731. NotControl = true,
  8732. Parent = this,
  8733. Opacity = 0.7F
  8734. };
  8735. MirLabel memoLabel = new MirLabel
  8736. {
  8737. AutoSize = true,
  8738. ForeColour = Color.White,
  8739. Location = new Point(4, 4),
  8740. OutLine = true,
  8741. Parent = MemoLabel,
  8742. Text = Functions.StringOverLines(friend.Memo, 5, 20)
  8743. };
  8744. MemoLabel.Size = new Size(Math.Max(MemoLabel.Size.Width, memoLabel.DisplayRectangle.Right + 4),
  8745. Math.Max(MemoLabel.Size.Height, memoLabel.DisplayRectangle.Bottom + 4));
  8746. }
  8747. public string GetUserName(uint id)
  8748. {
  8749. for (int i = 0; i < UserIdList.Count; i++)
  8750. {
  8751. UserId who = UserIdList[i];
  8752. if (id == who.Id)
  8753. return who.UserName;
  8754. }
  8755. Network.Enqueue(new C.RequestUserName { UserID = id });
  8756. UserIdList.Add(new UserId() { Id = id, UserName = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.UserNameUnknown) });
  8757. return String.Empty;
  8758. }
  8759. public class UserId
  8760. {
  8761. public long Id = 0;
  8762. public string UserName = String.Empty;
  8763. }
  8764. public class OutPutMessage
  8765. {
  8766. public string Message;
  8767. public long ExpireTime;
  8768. public OutputMessageType Type;
  8769. }
  8770. public void Rankings(S.Rankings p)
  8771. {
  8772. foreach (RankCharacterInfo info in p.ListingDetails)
  8773. {
  8774. if (RankingList.ContainsKey(info.PlayerId))
  8775. RankingList[info.PlayerId] = info;
  8776. else
  8777. RankingList.Add(info.PlayerId, info);
  8778. }
  8779. List<RankCharacterInfo> listings = new List<RankCharacterInfo>();
  8780. foreach (long id in p.Listings)
  8781. listings.Add(RankingList[id]);
  8782. RankingDialog.RecieveRanks(listings, p.RankType, p.MyRank, p.Count);
  8783. }
  8784. public void Opendoor(S.Opendoor p)
  8785. {
  8786. MapControl.OpenDoor(p.DoorIndex, p.Close);
  8787. }
  8788. private void RentedItems(S.GetRentedItems p)
  8789. {
  8790. ItemRentalDialog.ReceiveRentedItems(p.RentedItems);
  8791. }
  8792. private void ItemRentalRequest(S.ItemRentalRequest p)
  8793. {
  8794. if (!p.Renting)
  8795. {
  8796. GuestItemRentDialog.SetGuestName(p.Name);
  8797. ItemRentingDialog.OpenItemRentalDialog();
  8798. }
  8799. else
  8800. {
  8801. GuestItemRentingDialog.SetGuestName(p.Name);
  8802. ItemRentDialog.OpenItemRentDialog();
  8803. }
  8804. ItemRentalDialog.Visible = false;
  8805. }
  8806. private void ItemRentalFee(S.ItemRentalFee p)
  8807. {
  8808. GuestItemRentDialog.SetGuestFee(p.Amount);
  8809. ItemRentDialog.RefreshInterface();
  8810. }
  8811. private void ItemRentalPeriod(S.ItemRentalPeriod p)
  8812. {
  8813. GuestItemRentingDialog.GuestRentalPeriod = p.Days;
  8814. ItemRentingDialog.RefreshInterface();
  8815. }
  8816. private void DepositRentalItem(S.DepositRentalItem p)
  8817. {
  8818. var fromCell = p.From < User.BeltIdx ? BeltDialog.Grid[p.From] : InventoryDialog.Grid[p.From - User.BeltIdx];
  8819. var toCell = ItemRentingDialog.ItemCell;
  8820. if (toCell == null || fromCell == null)
  8821. return;
  8822. toCell.Locked = false;
  8823. fromCell.Locked = false;
  8824. if (!p.Success)
  8825. return;
  8826. toCell.Item = fromCell.Item;
  8827. fromCell.Item = null;
  8828. User.RefreshStats();
  8829. if (ItemRentingDialog.RentalPeriod == 0)
  8830. ItemRentingDialog.InputRentalPeroid();
  8831. }
  8832. private void RetrieveRentalItem(S.RetrieveRentalItem p)
  8833. {
  8834. var fromCell = ItemRentingDialog.ItemCell;
  8835. var toCell = p.To < User.BeltIdx ? BeltDialog.Grid[p.To] : InventoryDialog.Grid[p.To - User.BeltIdx];
  8836. if (toCell == null || fromCell == null)
  8837. return;
  8838. toCell.Locked = false;
  8839. fromCell.Locked = false;
  8840. if (!p.Success)
  8841. return;
  8842. toCell.Item = fromCell.Item;
  8843. fromCell.Item = null;
  8844. User.RefreshStats();
  8845. }
  8846. private void UpdateRentalItem(S.UpdateRentalItem p)
  8847. {
  8848. GuestItemRentingDialog.GuestLoanItem = p.LoanItem;
  8849. ItemRentDialog.RefreshInterface();
  8850. }
  8851. private void CancelItemRental(S.CancelItemRental p)
  8852. {
  8853. User.RentalGoldLocked = false;
  8854. User.RentalItemLocked = false;
  8855. ItemRentingDialog.Reset();
  8856. ItemRentDialog.Reset();
  8857. var messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ItemRentalCancelledFaceOtherParty));
  8858. messageBox.Show();
  8859. }
  8860. private void ItemRentalLock(S.ItemRentalLock p)
  8861. {
  8862. if (!p.Success)
  8863. return;
  8864. User.RentalGoldLocked = p.GoldLocked;
  8865. User.RentalItemLocked = p.ItemLocked;
  8866. if (User.RentalGoldLocked)
  8867. ItemRentDialog.Lock();
  8868. else if (User.RentalItemLocked)
  8869. ItemRentingDialog.Lock();
  8870. }
  8871. private void ItemRentalPartnerLock(S.ItemRentalPartnerLock p)
  8872. {
  8873. if (p.GoldLocked)
  8874. GuestItemRentDialog.Lock();
  8875. else if (p.ItemLocked)
  8876. GuestItemRentingDialog.Lock();
  8877. }
  8878. private void CanConfirmItemRental(S.CanConfirmItemRental p)
  8879. {
  8880. ItemRentingDialog.EnableConfirmButton();
  8881. }
  8882. private void ConfirmItemRental(S.ConfirmItemRental p)
  8883. {
  8884. User.RentalGoldLocked = false;
  8885. User.RentalItemLocked = false;
  8886. ItemRentingDialog.Reset();
  8887. ItemRentDialog.Reset();
  8888. }
  8889. private void OpenBrowser(S.OpenBrowser p)
  8890. {
  8891. BrowserHelper.OpenDefaultBrowser(p.Url);
  8892. }
  8893. public void PlaySound(S.PlaySound p)
  8894. {
  8895. SoundManager.PlaySound(p.Sound, false);
  8896. }
  8897. private void SetTimer(S.SetTimer p)
  8898. {
  8899. GameScene.Scene.TimerControl.AddTimer(p);
  8900. }
  8901. private void ExpireTimer(S.ExpireTimer p)
  8902. {
  8903. GameScene.Scene.TimerControl.ExpireTimer(p.Key);
  8904. }
  8905. private void SetCompass(S.SetCompass p)
  8906. {
  8907. GameScene.Scene.CompassControl.SetPoint(p.Location);
  8908. }
  8909. private void Roll(S.Roll p)
  8910. {
  8911. GameScene.Scene.RollControl.Setup(p.Type, p.Page, p.Result, p.AutoRoll);
  8912. }
  8913. public void ShowNotice(S.UpdateNotice p)
  8914. {
  8915. NoticeDialog.Update(p.Notice);
  8916. }
  8917. #region Disposable
  8918. protected override void Dispose(bool disposing)
  8919. {
  8920. if (disposing)
  8921. {
  8922. Scene = null;
  8923. User = null;
  8924. MoveTime = 0;
  8925. AttackTime = 0;
  8926. NextRunTime = 0;
  8927. LastRunTime = 0;
  8928. CanMove = false;
  8929. CanRun = false;
  8930. MapControl = null;
  8931. MainDialog = null;
  8932. ChatDialog = null;
  8933. ChatControl = null;
  8934. InventoryDialog = null;
  8935. CharacterDialog = null;
  8936. StorageDialog = null;
  8937. BeltDialog = null;
  8938. MiniMapDialog = null;
  8939. InspectDialog = null;
  8940. OptionDialog = null;
  8941. MenuDialog = null;
  8942. NPCDialog = null;
  8943. QuestDetailDialog = null;
  8944. QuestListDialog = null;
  8945. QuestLogDialog = null;
  8946. QuestTrackingDialog = null;
  8947. GameShopDialog = null;
  8948. MentorDialog = null;
  8949. NewHeroDialog = null;
  8950. HeroInventoryDialog = null;
  8951. HeroDialog = null;
  8952. HeroBeltDialog = null;
  8953. RelationshipDialog = null;
  8954. CharacterDuraPanel = null;
  8955. DuraStatusPanel = null;
  8956. HoverItem = null;
  8957. SelectedCell = null;
  8958. PickedUpGold = false;
  8959. UseItemTime = 0;
  8960. PickUpTime = 0;
  8961. InspectTime = 0;
  8962. DisposeItemLabel();
  8963. AMode = 0;
  8964. PMode = 0;
  8965. Lights = 0;
  8966. NPCTime = 0;
  8967. NPCID = 0;
  8968. DefaultNPCID = 0;
  8969. for (int i = 0; i < OutputLines.Length; i++)
  8970. if (OutputLines[i] != null && OutputLines[i].IsDisposed)
  8971. OutputLines[i].Dispose();
  8972. OutputMessages.Clear();
  8973. OutputMessages = null;
  8974. }
  8975. base.Dispose(disposing);
  8976. }
  8977. #endregion
  8978. }
  8979. public sealed class MapControl : MirControl
  8980. {
  8981. public static UserObject User
  8982. {
  8983. get { return MapObject.User; }
  8984. set { MapObject.User = value; }
  8985. }
  8986. public static UserHeroObject Hero
  8987. {
  8988. get { return MapObject.Hero; }
  8989. set { MapObject.Hero = value; }
  8990. }
  8991. public static Dictionary<uint, MapObject> Objects = new Dictionary<uint, MapObject>();
  8992. public static List<MapObject> ObjectsList = new List<MapObject>();
  8993. public const int CellWidth = 48;
  8994. public const int CellHeight = 32;
  8995. public static int OffSetX;
  8996. public static int OffSetY;
  8997. public static int ViewRangeX;
  8998. public static int ViewRangeY;
  8999. private bool _autoPath;
  9000. public bool AutoPath
  9001. {
  9002. get
  9003. {
  9004. return _autoPath;
  9005. }
  9006. set
  9007. {
  9008. if (_autoPath == value) return;
  9009. _autoPath = value;
  9010. if (!_autoPath)
  9011. CurrentPath = null;
  9012. }
  9013. }
  9014. public PathFinder PathFinder;
  9015. public List<Node> CurrentPath = null;
  9016. public static Point MapLocation
  9017. {
  9018. get { return GameScene.User == null ? Point.Empty : new Point(MouseLocation.X / CellWidth - OffSetX, MouseLocation.Y / CellHeight - OffSetY).Add(GameScene.User.CurrentLocation); }
  9019. }
  9020. public static Point ToMouseLocation(Point p)
  9021. {
  9022. return new Point((p.X - MapObject.User.Movement.X + OffSetX) * CellWidth, (p.Y - MapObject.User.Movement.Y + OffSetY) * CellHeight).Add(MapObject.User.OffSetMove);
  9023. }
  9024. public static MouseButtons MapButtons;
  9025. public static Point MouseLocation;
  9026. public static long InputDelay;
  9027. private static long nextAction;
  9028. public static long NextAction
  9029. {
  9030. get { return nextAction; }
  9031. set
  9032. {
  9033. if (GameScene.Observing) return;
  9034. nextAction = value;
  9035. }
  9036. }
  9037. public CellInfo[,] M2CellInfo;
  9038. public List<Door> Doors = new List<Door>();
  9039. public int Width, Height;
  9040. public int Index;
  9041. public string FileName = String.Empty;
  9042. public string Title = String.Empty;
  9043. public ushort MiniMap, BigMap, Music, SetMusic;
  9044. public LightSetting Lights;
  9045. public bool Lightning, Fire;
  9046. public byte MapDarkLight;
  9047. public long LightningTime, FireTime;
  9048. public WeatherSetting Weather = WeatherSetting.None;
  9049. public bool FloorValid, LightsValid;
  9050. public long OutputDelay;
  9051. private static bool _awakeningAction;
  9052. public static bool AwakeningAction
  9053. {
  9054. get { return _awakeningAction; }
  9055. set
  9056. {
  9057. if (_awakeningAction == value) return;
  9058. _awakeningAction = value;
  9059. }
  9060. }
  9061. private static bool _autoRun;
  9062. public static bool AutoRun
  9063. {
  9064. get { return _autoRun; }
  9065. set
  9066. {
  9067. if (_autoRun == value) return;
  9068. _autoRun = value;
  9069. if (GameScene.Scene != null)
  9070. GameScene.Scene.ChatDialog.ReceiveChat(value ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AutoRunOn) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AutoRunOff),
  9071. ChatType.Hint);
  9072. }
  9073. }
  9074. public static bool AutoHit;
  9075. public int AnimationCount;
  9076. public static List<Effect> Effects = new List<Effect>();
  9077. public MapControl()
  9078. {
  9079. MapButtons = MouseButtons.None;
  9080. OffSetX = Settings.ScreenWidth / 2 / CellWidth;
  9081. OffSetY = Settings.ScreenHeight / 2 / CellHeight - 1;
  9082. ViewRangeX = OffSetX + 6;
  9083. ViewRangeY = OffSetY + 6;
  9084. Size = new Size(Settings.ScreenWidth, Settings.ScreenHeight);
  9085. DrawControlTexture = true;
  9086. BackColour = Color.Black;
  9087. MouseDown += OnMouseDown;
  9088. MouseMove += (o, e) => MouseLocation = e.Location;
  9089. Click += OnMouseClick;
  9090. }
  9091. public void ResetMap()
  9092. {
  9093. GameScene.Scene.NPCDialog.Hide();
  9094. MapObject.MouseObjectID = 0;
  9095. MapObject.TargetObjectID = 0;
  9096. MapObject.MagicObjectID = 0;
  9097. if (M2CellInfo != null)
  9098. for (var i = ObjectsList.Count - 1; i >= 0; i--)
  9099. ObjectsList[i]?.Remove();
  9100. Objects.Clear();
  9101. ObjectsList.Clear();
  9102. Effects.Clear();
  9103. Doors.Clear();
  9104. if (User != null)
  9105. {
  9106. Objects[User.ObjectID] = User;
  9107. ObjectsList.Add(User);
  9108. }
  9109. }
  9110. public void LoadMap()
  9111. {
  9112. ResetMap();
  9113. MapObject.MouseObjectID = 0;
  9114. MapObject.TargetObjectID = 0;
  9115. MapObject.MagicObjectID = 0;
  9116. MapReader Map = new MapReader(FileName);
  9117. M2CellInfo = Map.MapCells;
  9118. Width = Map.Width;
  9119. Height = Map.Height;
  9120. PathFinder = new PathFinder(this);
  9121. try
  9122. {
  9123. if (SetMusic != Music)
  9124. {
  9125. SoundManager.Music?.Dispose();
  9126. SoundManager.PlayMusic(Music, true);
  9127. }
  9128. }
  9129. catch (Exception)
  9130. {
  9131. // Do nothing. index was not valid.
  9132. }
  9133. SetMusic = Music;
  9134. SoundList.Music = Music;
  9135. UpdateWeather();
  9136. }
  9137. public void Process()
  9138. {
  9139. Processdoors();
  9140. User.Process();
  9141. for (int i = ObjectsList.Count - 1; i >= 0; i--)
  9142. {
  9143. if (ObjectsList[i] == User) continue;
  9144. ObjectsList[i].Process();
  9145. }
  9146. for (int i = Effects.Count - 1; i >= 0; i--)
  9147. Effects[i].Process();
  9148. if (MapObject.TargetObject != null && MapObject.TargetObject is MonsterObject && MapObject.TargetObject.AI == 64)
  9149. MapObject.TargetObjectID = 0;
  9150. if (MapObject.MagicObject != null && MapObject.MagicObject is MonsterObject && MapObject.MagicObject.AI == 64)
  9151. MapObject.MagicObjectID = 0;
  9152. CheckInput();
  9153. MapObject bestmouseobject = null;
  9154. for (int y = MapLocation.Y + 2; y >= MapLocation.Y - 2; y--)
  9155. {
  9156. if (y >= Height) continue;
  9157. if (y < 0) break;
  9158. for (int x = MapLocation.X + 2; x >= MapLocation.X - 2; x--)
  9159. {
  9160. if (x >= Width) continue;
  9161. if (x < 0) break;
  9162. CellInfo cell = M2CellInfo[x, y];
  9163. if (cell.CellObjects == null) continue;
  9164. for (int i = cell.CellObjects.Count - 1; i >= 0; i--)
  9165. {
  9166. MapObject ob = cell.CellObjects[i];
  9167. if (ob == MapObject.User || !ob.MouseOver(CMain.MPoint)) continue;
  9168. if (MapObject.MouseObject != ob)
  9169. {
  9170. if (ob.Dead)
  9171. {
  9172. if (!Settings.TargetDead && GameScene.TargetDeadTime <= CMain.Time) continue;
  9173. bestmouseobject = ob;
  9174. //continue;
  9175. }
  9176. MapObject.MouseObjectID = ob.ObjectID;
  9177. Redraw();
  9178. }
  9179. if (bestmouseobject != null && MapObject.MouseObject == null)
  9180. {
  9181. MapObject.MouseObjectID = bestmouseobject.ObjectID;
  9182. Redraw();
  9183. }
  9184. return;
  9185. }
  9186. }
  9187. }
  9188. if (MapObject.MouseObject != null)
  9189. {
  9190. MapObject.MouseObjectID = 0;
  9191. Redraw();
  9192. }
  9193. }
  9194. public static MapObject GetObject(uint targetID)
  9195. {
  9196. Objects.TryGetValue(targetID, out var ob);
  9197. return ob;
  9198. }
  9199. public override void Draw()
  9200. {
  9201. //Do nothing.
  9202. }
  9203. protected override void CreateTexture()
  9204. {
  9205. if (User == null) return;
  9206. if (!FloorValid)
  9207. DrawFloor();
  9208. if (Size != TextureSize)
  9209. DisposeTexture();
  9210. if (ControlTexture == null || ControlTexture.Disposed)
  9211. {
  9212. DXManager.ControlList.Add(this);
  9213. ControlTexture = new Texture(DXManager.Device, Size.Width, Size.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
  9214. TextureSize = Size;
  9215. }
  9216. Surface oldSurface = DXManager.CurrentSurface;
  9217. Surface surface = ControlTexture.GetSurfaceLevel(0);
  9218. DXManager.SetSurface(surface);
  9219. DXManager.Device.Clear(ClearFlags.Target, BackColour, 0, 0);
  9220. DrawBackground();
  9221. if (FloorValid)
  9222. {
  9223. DXManager.Draw(DXManager.FloorTexture, new Rectangle(0, 0, Settings.ScreenWidth, Settings.ScreenHeight), Vector3.Zero, Color.White);
  9224. }
  9225. DrawObjects();
  9226. //render weather
  9227. foreach (ParticleEngine engine in GameScene.Scene.ParticleEngines)
  9228. {
  9229. engine.Draw();
  9230. }
  9231. //Render Death,
  9232. LightSetting setting = Lights == LightSetting.Normal ? GameScene.Scene.Lights : Lights;
  9233. if (setting != LightSetting.Day || GameScene.User.Poison.HasFlag(PoisonType.Blindness))
  9234. {
  9235. DrawLights(setting);
  9236. }
  9237. if (Settings.DropView || GameScene.DropViewTime > CMain.Time)
  9238. {
  9239. foreach (var ob in Objects.Values.OfType<ItemObject>())
  9240. {
  9241. if (!ob.MouseOver(MouseLocation))
  9242. ob.DrawName();
  9243. }
  9244. }
  9245. if (MapObject.MouseObject != null && !(MapObject.MouseObject is ItemObject))
  9246. MapObject.MouseObject.DrawName();
  9247. int offSet = 0;
  9248. if (Settings.DisplayBodyName)
  9249. {
  9250. foreach (var ob in Objects.Values.OfType<MonsterObject>())
  9251. {
  9252. if (ob.MouseOver(MouseLocation))
  9253. ob.DrawName();
  9254. }
  9255. }
  9256. foreach (var ob in Objects.Values.OfType<ItemObject>())
  9257. {
  9258. if (ob.MouseOver(MouseLocation))
  9259. {
  9260. ob.DrawName(offSet);
  9261. offSet -= ob.NameLabel.Size.Height + (ob.NameLabel.Border ? 1 : 0);
  9262. }
  9263. }
  9264. if (MapObject.User.MouseOver(MouseLocation))
  9265. MapObject.User.DrawName();
  9266. DXManager.SetSurface(oldSurface);
  9267. surface.Dispose();
  9268. TextureValid = true;
  9269. }
  9270. protected internal override void DrawControl()
  9271. {
  9272. if (!DrawControlTexture)
  9273. return;
  9274. if (!TextureValid)
  9275. CreateTexture();
  9276. if (ControlTexture == null || ControlTexture.Disposed)
  9277. return;
  9278. float oldOpacity = DXManager.Opacity;
  9279. if (MapObject.User.Dead) DXManager.SetGrayscale(true);
  9280. DXManager.DrawOpaque(ControlTexture, new Rectangle(0, 0, Settings.ScreenWidth, Settings.ScreenHeight), Vector3.Zero, Color.White, Opacity);
  9281. if (MapObject.User.Dead) DXManager.SetGrayscale(false);
  9282. CleanTime = CMain.Time + Settings.CleanDelay;
  9283. }
  9284. private void DrawFloor()
  9285. {
  9286. if (DXManager.FloorTexture == null || DXManager.FloorTexture.Disposed)
  9287. {
  9288. DXManager.FloorTexture = new Texture(DXManager.Device, Settings.ScreenWidth, Settings.ScreenHeight, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
  9289. DXManager.FloorSurface = DXManager.FloorTexture.GetSurfaceLevel(0);
  9290. }
  9291. Surface oldSurface = DXManager.CurrentSurface;
  9292. DXManager.SetSurface(DXManager.FloorSurface);
  9293. DXManager.Device.Clear(ClearFlags.Target, Color.Empty, 0, 0);
  9294. int startX = User.Movement.X - ViewRangeX;
  9295. int endX = User.Movement.X + ViewRangeX;
  9296. int startY = User.Movement.Y - ViewRangeY;
  9297. int endY = User.Movement.Y + ViewRangeY;
  9298. int endYExtended = endY + 5;
  9299. int[] drawXCache = new int[endX - startX + 1];
  9300. for (int xi = startX; xi <= endX; xi++)
  9301. drawXCache[xi - startX] = (xi - User.Movement.X + OffSetX) * CellWidth - OffSetX + User.OffSetMove.X;
  9302. int[] drawYCache = new int[endYExtended - startY + 1];
  9303. for (int yi = startY; yi <= endYExtended; yi++)
  9304. drawYCache[yi - startY] = (yi - User.Movement.Y + OffSetY) * CellHeight + User.OffSetMove.Y;
  9305. for (int y = startY; y <= endYExtended; y++)
  9306. {
  9307. if (y <= 0) continue;
  9308. if (y >= Height) break;
  9309. int drawY = drawYCache[y - startY];
  9310. for (int x = startX; x <= endX; x++)
  9311. {
  9312. if (x < 0) continue;
  9313. if (x >= Width) break;
  9314. int drawX = drawXCache[x - startX];
  9315. var cell = M2CellInfo[x, y];
  9316. // Back
  9317. if (y % 2 == 0 && x % 2 == 0 && y <= endY)
  9318. {
  9319. if (cell.BackImage != 0 && cell.BackIndex != -1)
  9320. {
  9321. int index = (cell.BackImage & 0x1FFFFFFF) - 1;
  9322. var lib = Libraries.MapLibs[cell.BackIndex];
  9323. lib.Draw(index, drawX, drawY);
  9324. }
  9325. }
  9326. // Middle
  9327. int midIndex = cell.MiddleImage - 1;
  9328. if (midIndex >= 0 && cell.MiddleIndex != -1)
  9329. {
  9330. var lib = Libraries.MapLibs[cell.MiddleIndex];
  9331. Size s = lib.GetSize(midIndex);
  9332. if ((s.Width == CellWidth && s.Height == CellHeight) ||
  9333. (s.Width == CellWidth * 2 && s.Height == CellHeight * 2))
  9334. {
  9335. lib.Draw(midIndex, drawX, drawY);
  9336. }
  9337. }
  9338. // Front
  9339. int frontIndex = (cell.FrontImage & 0x7FFF) - 1;
  9340. if (frontIndex != -1)
  9341. {
  9342. int fileIndex = cell.FrontIndex;
  9343. if (fileIndex != -1 && fileIndex != 200)
  9344. {
  9345. var lib = Libraries.MapLibs[fileIndex];
  9346. Size s = lib.GetSize(frontIndex);
  9347. // door
  9348. if (cell.DoorIndex > 0)
  9349. {
  9350. Door doorInfo = GetDoor(cell.DoorIndex);
  9351. if (doorInfo == null)
  9352. {
  9353. doorInfo = new Door() { index = cell.DoorIndex, DoorState = 0, ImageIndex = 0, LastTick = CMain.Time };
  9354. Doors.Add(doorInfo);
  9355. }
  9356. else if (doorInfo.DoorState != 0)
  9357. {
  9358. frontIndex += (doorInfo.ImageIndex + 1) * cell.DoorOffset;
  9359. }
  9360. }
  9361. if (frontIndex >= 0 &&
  9362. ((s.Width == CellWidth && s.Height == CellHeight) ||
  9363. (s.Width == CellWidth * 2 && s.Height == CellHeight * 2)))
  9364. {
  9365. lib.Draw(frontIndex, drawX, drawY);
  9366. }
  9367. }
  9368. }
  9369. }
  9370. }
  9371. DXManager.SetSurface(oldSurface);
  9372. FloorValid = true;
  9373. }
  9374. private void DrawBackground()
  9375. {
  9376. string cleanFilename = FileName.Replace(Settings.MapPath, "");
  9377. if (cleanFilename.StartsWith("ID1") || cleanFilename.StartsWith("ID2"))
  9378. {
  9379. Libraries.Background.Draw(10, 0, 0); //mountains
  9380. }
  9381. else if (cleanFilename.StartsWith("ID3_013"))
  9382. {
  9383. Libraries.Background.Draw(22, 0, 0); //desert
  9384. }
  9385. else if (cleanFilename.StartsWith("ID3_015"))
  9386. {
  9387. Libraries.Background.Draw(23, 0, 0); //greatwall
  9388. }
  9389. else if (cleanFilename.StartsWith("ID3_023") || cleanFilename.StartsWith("ID3_025"))
  9390. {
  9391. Libraries.Background.Draw(21, 0, 0); //village entrance
  9392. }
  9393. }
  9394. private void DrawObjects()
  9395. {
  9396. if (Settings.Effect)
  9397. {
  9398. for (int i = Effects.Count - 1; i >= 0; i--)
  9399. {
  9400. if (!Effects[i].DrawBehind) continue;
  9401. Effects[i].Draw();
  9402. }
  9403. }
  9404. for (int y = User.Movement.Y - ViewRangeY; y <= User.Movement.Y + ViewRangeY + 25; y++)
  9405. {
  9406. if (y <= 0) continue;
  9407. if (y >= Height) break;
  9408. for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
  9409. {
  9410. if (x < 0) continue;
  9411. if (x >= Width) break;
  9412. M2CellInfo[x, y].DrawDeadObjects();
  9413. }
  9414. }
  9415. for (int y = User.Movement.Y - ViewRangeY; y <= User.Movement.Y + ViewRangeY + 25; y++)
  9416. {
  9417. if (y <= 0) continue;
  9418. if (y >= Height) break;
  9419. int drawY = (y - User.Movement.Y + OffSetY + 1) * CellHeight + User.OffSetMove.Y;
  9420. for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
  9421. {
  9422. if (x < 0) continue;
  9423. if (x >= Width) break;
  9424. int drawX = (x - User.Movement.X + OffSetX) * CellWidth - OffSetX + User.OffSetMove.X;
  9425. int index;
  9426. byte animation;
  9427. bool blend;
  9428. Size s;
  9429. #region Draw shanda's tile animation layer
  9430. index = M2CellInfo[x, y].TileAnimationImage;
  9431. animation = M2CellInfo[x, y].TileAnimationFrames;
  9432. if ((index > 0) & (animation > 0))
  9433. {
  9434. index--;
  9435. int animationoffset = M2CellInfo[x, y].TileAnimationOffset ^ 0x2000;
  9436. index += animationoffset * (AnimationCount % animation);
  9437. Libraries.MapLibs[190].DrawUp(index, drawX, drawY);
  9438. }
  9439. #endregion
  9440. #region Draw mir3 middle layer
  9441. if ((M2CellInfo[x, y].MiddleIndex >= 0) && (M2CellInfo[x, y].MiddleIndex != -1)) //M2P '> 199' changed to '>= 0' to include mir2 libraries. Fixes middle layer tile strips draw. Also changed in 'DrawFloor' above.
  9442. {
  9443. index = M2CellInfo[x, y].MiddleImage - 1;
  9444. if (index > 0)
  9445. {
  9446. animation = M2CellInfo[x, y].MiddleAnimationFrame;
  9447. blend = false;
  9448. if ((animation > 0) && (animation < 255))
  9449. {
  9450. if ((animation & 0x0f) > 0)
  9451. {
  9452. blend = true;
  9453. animation &= 0x0f;
  9454. }
  9455. if (animation > 0)
  9456. {
  9457. byte animationTick = M2CellInfo[x, y].MiddleAnimationTick;
  9458. index += (AnimationCount % (animation + (animation * animationTick))) / (1 + animationTick);
  9459. if (blend && (animation == 10 || animation == 8)) //diamond mines, abyss blends
  9460. {
  9461. Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].DrawUpBlend(index, new Point(drawX, drawY));
  9462. }
  9463. else
  9464. {
  9465. Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].DrawUp(index, drawX, drawY);
  9466. }
  9467. }
  9468. }
  9469. s = Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].GetSize(index);
  9470. if ((s.Width != CellWidth || s.Height != CellHeight) && (s.Width != (CellWidth * 2) || s.Height != (CellHeight * 2)) && !blend)
  9471. {
  9472. Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].DrawUp(index, drawX, drawY);
  9473. }
  9474. }
  9475. }
  9476. #endregion
  9477. #region Draw front layer
  9478. index = (M2CellInfo[x, y].FrontImage & 0x7FFF) - 1;
  9479. if (index < 0) continue;
  9480. int fileIndex = M2CellInfo[x, y].FrontIndex;
  9481. if (fileIndex == -1) continue;
  9482. animation = M2CellInfo[x, y].FrontAnimationFrame;
  9483. if ((animation & 0x80) > 0)
  9484. {
  9485. blend = true;
  9486. animation &= 0x7F;
  9487. }
  9488. else
  9489. blend = false;
  9490. if (animation > 0)
  9491. {
  9492. byte animationTick = M2CellInfo[x, y].FrontAnimationTick;
  9493. index += (AnimationCount % (animation + (animation * animationTick))) / (1 + animationTick);
  9494. }
  9495. if (M2CellInfo[x, y].DoorIndex > 0)
  9496. {
  9497. Door DoorInfo = GetDoor(M2CellInfo[x, y].DoorIndex);
  9498. if (DoorInfo == null)
  9499. {
  9500. DoorInfo = new Door() { index = M2CellInfo[x, y].DoorIndex, DoorState = 0, ImageIndex = 0, LastTick = CMain.Time };
  9501. Doors.Add(DoorInfo);
  9502. }
  9503. else
  9504. {
  9505. if (DoorInfo.DoorState != 0)
  9506. {
  9507. index += (DoorInfo.ImageIndex + 1) * M2CellInfo[x, y].DoorOffset;//'bad' code if you want to use animation but it's gonna depend on the animation > has to be custom designed for the animtion
  9508. }
  9509. }
  9510. }
  9511. s = Libraries.MapLibs[fileIndex].GetSize(index);
  9512. if (s.Width == CellWidth && s.Height == CellHeight && animation == 0) continue;
  9513. if ((s.Width == CellWidth * 2) && (s.Height == CellHeight * 2) && (animation == 0)) continue;
  9514. if (blend)
  9515. {
  9516. if (fileIndex == 14 || fileIndex == 27 || (fileIndex > 99 & fileIndex < 199))
  9517. Libraries.MapLibs[fileIndex].DrawBlend(index, new Point(drawX, drawY - (3 * CellHeight)), Color.White, true);
  9518. else
  9519. Libraries.MapLibs[fileIndex].DrawBlend(index, new Point(drawX, drawY - s.Height), Color.White, (index >= 2723 && index <= 2732));
  9520. }
  9521. else
  9522. {
  9523. if (fileIndex == 28 && Libraries.MapLibs[fileIndex].GetOffSet(index) != Point.Empty)
  9524. Libraries.MapLibs[fileIndex].Draw(index, new Point(drawX, drawY - CellHeight), Color.White, true);
  9525. else
  9526. Libraries.MapLibs[fileIndex].Draw(index, drawX, drawY - s.Height);
  9527. }
  9528. #endregion
  9529. }
  9530. for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
  9531. {
  9532. if (x < 0) continue;
  9533. if (x >= Width) break;
  9534. M2CellInfo[x, y].DrawObjects();
  9535. }
  9536. }
  9537. DXManager.Sprite.Flush();
  9538. float oldOpacity = DXManager.Opacity;
  9539. DXManager.SetOpacity(0.4F);
  9540. //MapObject.User.DrawMount();
  9541. MapObject.User.DrawBody();
  9542. if ((MapObject.User.Direction == MirDirection.Up) ||
  9543. (MapObject.User.Direction == MirDirection.UpLeft) ||
  9544. (MapObject.User.Direction == MirDirection.UpRight) ||
  9545. (MapObject.User.Direction == MirDirection.Right) ||
  9546. (MapObject.User.Direction == MirDirection.Left))
  9547. {
  9548. MapObject.User.DrawHead();
  9549. MapObject.User.DrawWings();
  9550. }
  9551. else
  9552. {
  9553. MapObject.User.DrawWings();
  9554. MapObject.User.DrawHead();
  9555. }
  9556. DXManager.SetOpacity(oldOpacity);
  9557. if (Settings.HighlightTarget)
  9558. {
  9559. if (MapObject.MouseObject != null && !MapObject.MouseObject.Dead && MapObject.MouseObject != MapObject.TargetObject && MapObject.MouseObject.Blend)
  9560. MapObject.MouseObject.DrawBlend();
  9561. if (MapObject.TargetObject != null)
  9562. MapObject.TargetObject.DrawBlend();
  9563. }
  9564. if (Settings.Effect)
  9565. {
  9566. for (int i = Effects.Count - 1; i >= 0; i--)
  9567. {
  9568. if (Effects[i].DrawBehind) continue;
  9569. Effects[i].Draw();
  9570. }
  9571. }
  9572. foreach (var ob in Objects.Values)
  9573. {
  9574. ob.DrawEffects(Settings.Effect);
  9575. if (Settings.NameView && !(ob is ItemObject) && !ob.Dead)
  9576. ob.DrawName();
  9577. ob.DrawChat();
  9578. //ob.DrawHealth();
  9579. ob.DrawPoison();
  9580. ob.DrawDamages();
  9581. }
  9582. foreach (var ob in Objects.Values)
  9583. {
  9584. ob.DrawHealth();
  9585. }
  9586. }
  9587. private Color GetBlindLight(Color light)
  9588. {
  9589. if (MapObject.User.BlindTime <= CMain.Time && MapObject.User.BlindCount < 25)
  9590. {
  9591. MapObject.User.BlindTime = CMain.Time + 100;
  9592. MapObject.User.BlindCount++;
  9593. }
  9594. int count = MapObject.User.BlindCount;
  9595. light = Color.FromArgb(255, Math.Max(20, light.R - (count * 10)), Math.Max(20, light.G - (count * 10)), Math.Max(20, light.B - (count * 10)));
  9596. return light;
  9597. }
  9598. private void DrawLights(LightSetting setting)
  9599. {
  9600. if (DXManager.Lights == null || DXManager.Lights.Count == 0) return;
  9601. if (DXManager.LightTexture == null || DXManager.LightTexture.Disposed)
  9602. {
  9603. DXManager.LightTexture = new Texture(DXManager.Device, Settings.ScreenWidth, Settings.ScreenHeight, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
  9604. DXManager.LightSurface = DXManager.LightTexture.GetSurfaceLevel(0);
  9605. }
  9606. Surface oldSurface = DXManager.CurrentSurface;
  9607. DXManager.SetSurface(DXManager.LightSurface);
  9608. #region Night Lights
  9609. Color darkness;
  9610. switch (setting)
  9611. {
  9612. case LightSetting.Night:
  9613. {
  9614. switch (MapDarkLight)
  9615. {
  9616. case 1:
  9617. darkness = Color.FromArgb(255, 20, 20, 20);
  9618. break;
  9619. case 2:
  9620. darkness = Color.LightSlateGray;
  9621. break;
  9622. case 3:
  9623. darkness = Color.SkyBlue;
  9624. break;
  9625. case 4:
  9626. darkness = Color.Goldenrod;
  9627. break;
  9628. default:
  9629. darkness = Color.Black;
  9630. break;
  9631. }
  9632. }
  9633. break;
  9634. case LightSetting.Evening:
  9635. case LightSetting.Dawn:
  9636. darkness = Color.FromArgb(255, 50, 50, 50);
  9637. break;
  9638. default:
  9639. case LightSetting.Day:
  9640. darkness = Color.FromArgb(255, 255, 255, 255);
  9641. break;
  9642. }
  9643. if (MapObject.User.Poison.HasFlag(PoisonType.Blindness))
  9644. {
  9645. darkness = GetBlindLight(darkness);
  9646. }
  9647. DXManager.Device.Clear(ClearFlags.Target, darkness, 0, 0);
  9648. #endregion
  9649. int light;
  9650. Point p;
  9651. DXManager.SetBlend(true);
  9652. DXManager.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
  9653. DXManager.Device.SetRenderState(RenderState.DestinationBlend, Blend.One);
  9654. #region Object Lights (Player/Mob/NPC)
  9655. foreach (var ob in Objects.Values)
  9656. {
  9657. if (ob.Light > 0 && (!ob.Dead || ob == MapObject.User || ob.Race == ObjectType.Spell))
  9658. {
  9659. light = ob.Light;
  9660. int lightRange = light % 15;
  9661. if (lightRange >= DXManager.Lights.Count)
  9662. lightRange = DXManager.Lights.Count - 1;
  9663. p = ob.DrawLocation;
  9664. Color lightColour = ob.LightColour;
  9665. if (ob.Race == ObjectType.Player)
  9666. {
  9667. switch (light / 15)
  9668. {
  9669. case 0://no light source
  9670. lightColour = Color.FromArgb(255, 60, 60, 60);
  9671. break;
  9672. case 1:
  9673. lightColour = Color.FromArgb(255, 120, 120, 120);
  9674. break;
  9675. case 2://Candle
  9676. lightColour = Color.FromArgb(255, 180, 180, 180);
  9677. break;
  9678. case 3://Torch
  9679. lightColour = Color.FromArgb(255, 240, 240, 240);
  9680. break;
  9681. default://Peddler Torch
  9682. lightColour = Color.FromArgb(255, 255, 255, 255);
  9683. break;
  9684. }
  9685. }
  9686. else if (ob.Race == ObjectType.Merchant)
  9687. {
  9688. lightColour = Color.FromArgb(255, 120, 120, 120);
  9689. }
  9690. if (MapObject.User.Poison.HasFlag(PoisonType.Blindness))
  9691. {
  9692. lightColour = GetBlindLight(lightColour);
  9693. }
  9694. if (DXManager.Lights[lightRange] != null && !DXManager.Lights[lightRange].Disposed)
  9695. {
  9696. p.Offset(-(DXManager.LightSizes[lightRange].X / 2) - (CellWidth / 2), -(DXManager.LightSizes[lightRange].Y / 2) - (CellHeight / 2) - 5);
  9697. DXManager.Draw(DXManager.Lights[lightRange], null, new Vector3((float)p.X, (float)p.Y, 0.0F), lightColour);
  9698. }
  9699. }
  9700. #region Object Effect Lights
  9701. if (!Settings.Effect) continue;
  9702. for (int e = 0; e < ob.Effects.Count; e++)
  9703. {
  9704. Effect effect = ob.Effects[e];
  9705. if (!effect.Blend || CMain.Time < effect.Start || (!(effect is Missile) && effect.Light < ob.Light)) continue;
  9706. light = effect.Light;
  9707. p = effect.DrawLocation;
  9708. var lightColour = effect.LightColour;
  9709. if (MapObject.User.Poison.HasFlag(PoisonType.Blindness))
  9710. {
  9711. lightColour = GetBlindLight(lightColour);
  9712. }
  9713. if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
  9714. {
  9715. p.Offset(-(DXManager.LightSizes[light].X / 2) - (CellWidth / 2), -(DXManager.LightSizes[light].Y / 2) - (CellHeight / 2) - 5);
  9716. DXManager.Draw(DXManager.Lights[light], null, new Vector3((float)p.X, (float)p.Y, 0.0F), lightColour);
  9717. }
  9718. }
  9719. #endregion
  9720. }
  9721. #endregion
  9722. #region Map Effect Lights
  9723. if (Settings.Effect)
  9724. {
  9725. for (int e = 0; e < Effects.Count; e++)
  9726. {
  9727. Effect effect = Effects[e];
  9728. if (!effect.Blend || CMain.Time < effect.Start) continue;
  9729. light = effect.Light;
  9730. if (light == 0) continue;
  9731. p = effect.DrawLocation;
  9732. var lightColour = Color.White;
  9733. if (MapObject.User.Poison.HasFlag(PoisonType.Blindness))
  9734. {
  9735. lightColour = GetBlindLight(lightColour);
  9736. }
  9737. if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
  9738. {
  9739. p.Offset(-(DXManager.LightSizes[light].X / 2) - (CellWidth / 2), -(DXManager.LightSizes[light].Y / 2) - (CellHeight / 2) - 5);
  9740. DXManager.Draw(DXManager.Lights[light], null, new Vector3((float)p.X, (float)p.Y, 0.0F), lightColour);
  9741. }
  9742. }
  9743. }
  9744. #endregion
  9745. #region Map Lights
  9746. for (int y = MapObject.User.Movement.Y - ViewRangeY - 24; y <= MapObject.User.Movement.Y + ViewRangeY + 24; y++)
  9747. {
  9748. if (y < 0) continue;
  9749. if (y >= Height) break;
  9750. for (int x = MapObject.User.Movement.X - ViewRangeX - 24; x < MapObject.User.Movement.X + ViewRangeX + 24; x++)
  9751. {
  9752. if (x < 0) continue;
  9753. if (x >= Width) break;
  9754. int imageIndex = (M2CellInfo[x, y].FrontImage & 0x7FFF) - 1;
  9755. if (imageIndex == -1) continue;
  9756. int fileIndex = M2CellInfo[x, y].FrontIndex;
  9757. if (fileIndex == -1) continue;
  9758. if (M2CellInfo[x, y].Light <= 0 || M2CellInfo[x, y].Light >= 10) continue;
  9759. if (M2CellInfo[x, y].Light == 0) continue;
  9760. Color lightIntensity;
  9761. light = (M2CellInfo[x, y].Light % 10) * 3;
  9762. switch (M2CellInfo[x, y].Light / 10)
  9763. {
  9764. case 1:
  9765. lightIntensity = Color.FromArgb(255, 255, 255, 255);
  9766. break;
  9767. case 2:
  9768. lightIntensity = Color.FromArgb(255, 120, 180, 255);
  9769. break;
  9770. case 3:
  9771. lightIntensity = Color.FromArgb(255, 255, 180, 120);
  9772. break;
  9773. case 4:
  9774. lightIntensity = Color.FromArgb(255, 22, 160, 5);
  9775. break;
  9776. default:
  9777. lightIntensity = Color.FromArgb(255, 255, 255, 255);
  9778. break;
  9779. }
  9780. if (MapObject.User.Poison.HasFlag(PoisonType.Blindness))
  9781. {
  9782. lightIntensity = GetBlindLight(lightIntensity);
  9783. }
  9784. p = new Point(
  9785. (x + OffSetX - MapObject.User.Movement.X) * CellWidth + MapObject.User.OffSetMove.X,
  9786. (y + OffSetY - MapObject.User.Movement.Y) * CellHeight + MapObject.User.OffSetMove.Y + 32);
  9787. if (M2CellInfo[x, y].FrontAnimationFrame > 0)
  9788. p.Offset(Libraries.MapLibs[fileIndex].GetOffSet(imageIndex));
  9789. if (light >= DXManager.Lights.Count)
  9790. light = DXManager.Lights.Count - 1;
  9791. if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
  9792. {
  9793. p.Offset(-(DXManager.LightSizes[light].X / 2) - (CellWidth / 2) + 10, -(DXManager.LightSizes[light].Y / 2) - (CellHeight / 2) - 5);
  9794. DXManager.Draw(DXManager.Lights[light], null, new Vector3((float)p.X, (float)p.Y, 0.0F), lightIntensity);
  9795. }
  9796. }
  9797. }
  9798. #endregion
  9799. DXManager.SetBlend(false);
  9800. DXManager.SetSurface(oldSurface);
  9801. DXManager.Device.SetRenderState(RenderState.SourceBlend, Blend.Zero);
  9802. DXManager.Device.SetRenderState(RenderState.DestinationBlend, Blend.SourceColor);
  9803. DXManager.Draw(DXManager.LightTexture, new Rectangle(0, 0, Settings.ScreenWidth, Settings.ScreenHeight), Vector3.Zero, Color.White);
  9804. DXManager.Sprite.End();
  9805. DXManager.Sprite.Begin(SpriteFlags.AlphaBlend);
  9806. }
  9807. private static void OnMouseClick(object sender, EventArgs e)
  9808. {
  9809. if (!(e is MouseEventArgs me)) return;
  9810. if (AwakeningAction == true) return;
  9811. switch (me.Button)
  9812. {
  9813. case MouseButtons.Left:
  9814. {
  9815. AutoRun = false;
  9816. GameScene.Scene.MapControl.AutoPath = false;
  9817. if (MapObject.MouseObject == null) return;
  9818. NPCObject npc = MapObject.MouseObject as NPCObject;
  9819. if (npc != null)
  9820. {
  9821. if (npc.ObjectID == GameScene.NPCID &&
  9822. (CMain.Time <= GameScene.NPCTime || GameScene.Scene.NPCDialog.Visible))
  9823. {
  9824. return;
  9825. }
  9826. //GameScene.Scene.NPCDialog.Hide();
  9827. GameScene.NPCTime = CMain.Time + 5000;
  9828. GameScene.NPCID = npc.ObjectID;
  9829. Network.Enqueue(new C.CallNPC { ObjectID = npc.ObjectID, Key = "[@Main]" });
  9830. }
  9831. }
  9832. break;
  9833. case MouseButtons.Right:
  9834. {
  9835. AutoRun = false;
  9836. if (MapObject.MouseObject == null)
  9837. {
  9838. if (Settings.NewMove && MapLocation != MapObject.User.CurrentLocation && GameScene.Scene.MapControl.EmptyCell(MapLocation))
  9839. {
  9840. var path = GameScene.Scene.MapControl.PathFinder.FindPath(MapObject.User.CurrentLocation, MapLocation, 20);
  9841. if (path != null && path.Count > 0)
  9842. {
  9843. GameScene.Scene.MapControl.CurrentPath = path;
  9844. GameScene.Scene.MapControl.AutoPath = true;
  9845. var offset = MouseLocation.Subtract(ToMouseLocation(MapLocation));
  9846. Effects.Add(new Effect(Libraries.Magic3, 500, 10, 600, MapLocation) { DrawOffset = offset.Subtract(8, 15) });
  9847. }
  9848. }
  9849. return;
  9850. }
  9851. if (CMain.Ctrl)
  9852. {
  9853. HeroObject hero = MapObject.MouseObject as HeroObject;
  9854. if (hero != null &&
  9855. hero.ObjectID != (Hero is null ? 0 : Hero.ObjectID) &&
  9856. CMain.Time >= GameScene.InspectTime)
  9857. {
  9858. GameScene.InspectTime = CMain.Time + 500;
  9859. InspectDialog.InspectID = hero.ObjectID;
  9860. Network.Enqueue(new C.Inspect { ObjectID = hero.ObjectID, Hero = true });
  9861. return;
  9862. }
  9863. PlayerObject player = MapObject.MouseObject as PlayerObject;
  9864. if (player != null &&
  9865. player != User &&
  9866. CMain.Time >= GameScene.InspectTime)
  9867. {
  9868. GameScene.InspectTime = CMain.Time + 500;
  9869. InspectDialog.InspectID = player.ObjectID;
  9870. Network.Enqueue(new C.Inspect { ObjectID = player.ObjectID });
  9871. return;
  9872. }
  9873. }
  9874. }
  9875. break;
  9876. case MouseButtons.Middle:
  9877. AutoRun = !AutoRun;
  9878. break;
  9879. }
  9880. }
  9881. private static void OnMouseDown(object sender, MouseEventArgs e)
  9882. {
  9883. MapButtons |= e.Button;
  9884. if (e.Button != MouseButtons.Right || !Settings.NewMove)
  9885. GameScene.CanRun = false;
  9886. if (AwakeningAction == true) return;
  9887. if (e.Button != MouseButtons.Left) return;
  9888. if (GameScene.SelectedCell != null)
  9889. {
  9890. if (GameScene.SelectedCell.GridType != MirGridType.Inventory && GameScene.SelectedCell.GridType != MirGridType.HeroInventory)
  9891. {
  9892. GameScene.SelectedCell = null;
  9893. return;
  9894. }
  9895. MirItemCell cell = GameScene.SelectedCell;
  9896. if (cell.Item.Info.Bind.HasFlag(BindMode.DontDrop))
  9897. {
  9898. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.YouCannotDrop), cell.Item.FriendlyName), MirMessageBoxButtons.OK);
  9899. messageBox.Show();
  9900. GameScene.SelectedCell = null;
  9901. return;
  9902. }
  9903. if (cell.Item.Count == 1)
  9904. {
  9905. MirMessageBox messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DropTip), cell.Item.FriendlyName), MirMessageBoxButtons.YesNo);
  9906. messageBox.YesButton.Click += (o, a) =>
  9907. {
  9908. Network.Enqueue(new C.DropItem
  9909. {
  9910. UniqueID = cell.Item.UniqueID,
  9911. Count = 1,
  9912. HeroInventory = cell.GridType == MirGridType.HeroInventory
  9913. });
  9914. cell.Locked = true;
  9915. };
  9916. messageBox.Show();
  9917. }
  9918. else
  9919. {
  9920. MirAmountBox amountBox = new MirAmountBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DropAmount), cell.Item.Info.Image, cell.Item.Count);
  9921. amountBox.OKButton.Click += (o, a) =>
  9922. {
  9923. if (amountBox.Amount <= 0) return;
  9924. Network.Enqueue(new C.DropItem
  9925. {
  9926. UniqueID = cell.Item.UniqueID,
  9927. Count = (ushort)amountBox.Amount,
  9928. HeroInventory = cell.GridType == MirGridType.HeroInventory
  9929. });
  9930. cell.Locked = true;
  9931. };
  9932. amountBox.Show();
  9933. }
  9934. GameScene.SelectedCell = null;
  9935. return;
  9936. }
  9937. if (GameScene.PickedUpGold)
  9938. {
  9939. MirAmountBox amountBox = new MirAmountBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DropAmount), 116, GameScene.Gold);
  9940. amountBox.OKButton.Click += (o, a) =>
  9941. {
  9942. if (amountBox.Amount > 0)
  9943. {
  9944. Network.Enqueue(new C.DropGold { Amount = amountBox.Amount });
  9945. }
  9946. };
  9947. amountBox.Show();
  9948. GameScene.PickedUpGold = false;
  9949. }
  9950. if (MapObject.MouseObject != null && !MapObject.MouseObject.Dead && !(MapObject.MouseObject is ItemObject) &&
  9951. !(MapObject.MouseObject is NPCObject) && !(MapObject.MouseObject is MonsterObject && MapObject.MouseObject.AI == 64)
  9952. && !(MapObject.MouseObject is MonsterObject && MapObject.MouseObject.AI == 70))
  9953. {
  9954. MapObject.TargetObjectID = MapObject.MouseObject.ObjectID;
  9955. if (MapObject.MouseObject is MonsterObject && MapObject.MouseObject.AI != 6)
  9956. MapObject.MagicObjectID = MapObject.TargetObject.ObjectID;
  9957. }
  9958. else
  9959. MapObject.TargetObjectID = 0;
  9960. }
  9961. private void CheckInput()
  9962. {
  9963. if (AwakeningAction == true) return;
  9964. if ((MouseControl == this) && (MapButtons != MouseButtons.None)) AutoHit = false;//mouse actions stop mining even when frozen!
  9965. if (!CanRideAttack()) AutoHit = false;
  9966. if (CMain.Time < InputDelay || User.Poison.HasFlag(PoisonType.Paralysis) || User.Poison.HasFlag(PoisonType.LRParalysis) || User.Poison.HasFlag(PoisonType.Frozen) || User.Fishing) return;
  9967. if (User.NextMagic != null && !User.RidingMount)
  9968. {
  9969. UseMagic(User.NextMagic, User);
  9970. return;
  9971. }
  9972. if (CMain.Time < User.BlizzardStopTime || CMain.Time < User.ReincarnationStopTime) return;
  9973. if (MapObject.TargetObject != null && !MapObject.TargetObject.Dead)
  9974. {
  9975. if (((MapObject.TargetObject.Name.EndsWith(")") || MapObject.TargetObject is PlayerObject) && CMain.Shift) ||
  9976. (!MapObject.TargetObject.Name.EndsWith(")") && MapObject.TargetObject is MonsterObject))
  9977. {
  9978. GameScene.LogTime = CMain.Time + Globals.LogDelay;
  9979. if (User.Class == MirClass.Archer && User.HasClassWeapon && !User.RidingMount && !User.Fishing)//ArcherTest - non aggressive targets (player / pets)
  9980. {
  9981. if (Functions.InRange(MapObject.TargetObject.CurrentLocation, User.CurrentLocation, Globals.MaxAttackRange))
  9982. {
  9983. if (CMain.Time > GameScene.AttackTime)
  9984. {
  9985. User.QueuedAction = new QueuedAction { Action = MirAction.AttackRange1, Direction = Functions.DirectionFromPoint(User.CurrentLocation, MapObject.TargetObject.CurrentLocation), Location = User.CurrentLocation, Params = new List<object>() };
  9986. User.QueuedAction.Params.Add(MapObject.TargetObject != null ? MapObject.TargetObject.ObjectID : (uint)0);
  9987. User.QueuedAction.Params.Add(MapObject.TargetObject.CurrentLocation);
  9988. // MapObject.TargetObject = null; //stop constant attack when close up
  9989. }
  9990. }
  9991. else
  9992. {
  9993. if (CMain.Time >= OutputDelay)
  9994. {
  9995. OutputDelay = CMain.Time + 1000;
  9996. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TargetTooFar));
  9997. }
  9998. }
  9999. // return;
  10000. }
  10001. else if (Functions.InRange(MapObject.TargetObject.CurrentLocation, User.CurrentLocation, 1))
  10002. {
  10003. if (CMain.Time > GameScene.AttackTime && CanRideAttack() && !User.Poison.HasFlag(PoisonType.Dazed))
  10004. {
  10005. User.QueuedAction = new QueuedAction { Action = MirAction.Attack1, Direction = Functions.DirectionFromPoint(User.CurrentLocation, MapObject.TargetObject.CurrentLocation), Location = User.CurrentLocation };
  10006. return;
  10007. }
  10008. }
  10009. }
  10010. }
  10011. if (AutoHit && !User.RidingMount)
  10012. {
  10013. if (CMain.Time > GameScene.AttackTime)
  10014. {
  10015. User.QueuedAction = new QueuedAction { Action = MirAction.Mine, Direction = User.Direction, Location = User.CurrentLocation };
  10016. return;
  10017. }
  10018. }
  10019. MirDirection direction;
  10020. if (MouseControl == this)
  10021. {
  10022. direction = MouseDirection();
  10023. if (AutoRun)
  10024. {
  10025. if (GameScene.CanRun && CanRun(direction) && CMain.Time > GameScene.NextRunTime && User.HP >= 10 && (!User.Sneaking || (User.Sneaking && User.Sprint))) //slow remove
  10026. {
  10027. int distance = User.RidingMount || User.Sprint && !User.Sneaking ? 3 : 2;
  10028. bool fail = false;
  10029. for (int i = 1; i <= distance; i++)
  10030. {
  10031. if (!CheckDoorOpen(Functions.PointMove(User.CurrentLocation, direction, i)))
  10032. fail = true;
  10033. }
  10034. if (!fail)
  10035. {
  10036. User.QueuedAction = new QueuedAction { Action = MirAction.Running, Direction = direction, Location = Functions.PointMove(User.CurrentLocation, direction, distance) };
  10037. return;
  10038. }
  10039. }
  10040. if ((CanWalk(direction, out direction)) && (CheckDoorOpen(Functions.PointMove(User.CurrentLocation, direction, 1))))
  10041. {
  10042. User.QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = direction, Location = Functions.PointMove(User.CurrentLocation, direction, 1) };
  10043. return;
  10044. }
  10045. if (direction != User.Direction)
  10046. {
  10047. User.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = direction, Location = User.CurrentLocation };
  10048. return;
  10049. }
  10050. return;
  10051. }
  10052. switch (MapButtons)
  10053. {
  10054. case MouseButtons.Left:
  10055. if (MapObject.MouseObject is NPCObject || (MapObject.MouseObject is PlayerObject && MapObject.MouseObject != User)) break;
  10056. if (MapObject.MouseObject is MonsterObject && MapObject.MouseObject.AI == 70) break;
  10057. if (CMain.Alt && !User.RidingMount)
  10058. {
  10059. User.QueuedAction = new QueuedAction { Action = MirAction.Harvest, Direction = direction, Location = User.CurrentLocation };
  10060. return;
  10061. }
  10062. if (CMain.Shift)
  10063. {
  10064. if (CMain.Time > GameScene.AttackTime && CanRideAttack()) //ArcherTest - shift click
  10065. {
  10066. MapObject target = null;
  10067. if (MapObject.MouseObject is MonsterObject || MapObject.MouseObject is PlayerObject) target = MapObject.MouseObject;
  10068. if (User.Class == MirClass.Archer && User.HasClassWeapon && !User.RidingMount && !User.Poison.HasFlag(PoisonType.Dazed))
  10069. {
  10070. if (target != null)
  10071. {
  10072. if (!Functions.InRange(MapObject.MouseObject.CurrentLocation, User.CurrentLocation, Globals.MaxAttackRange))
  10073. {
  10074. if (CMain.Time >= OutputDelay)
  10075. {
  10076. OutputDelay = CMain.Time + 1000;
  10077. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TargetTooFar));
  10078. }
  10079. return;
  10080. }
  10081. }
  10082. User.QueuedAction = new QueuedAction { Action = MirAction.AttackRange1, Direction = MouseDirection(), Location = User.CurrentLocation, Params = new List<object>() };
  10083. User.QueuedAction.Params.Add(target != null ? target.ObjectID : (uint)0);
  10084. User.QueuedAction.Params.Add(Functions.PointMove(User.CurrentLocation, MouseDirection(), 9));
  10085. return;
  10086. }
  10087. //stops double slash from being used without empty hand or assassin weapon (otherwise bugs on second swing)
  10088. if (GameScene.User.DoubleSlash && (!User.HasClassWeapon && User.Weapon > -1)) return;
  10089. if (User.Poison.HasFlag(PoisonType.Dazed)) return;
  10090. User.QueuedAction = new QueuedAction { Action = MirAction.Attack1, Direction = direction, Location = User.CurrentLocation };
  10091. }
  10092. return;
  10093. }
  10094. if (MapObject.MouseObject is MonsterObject && User.Class == MirClass.Archer && MapObject.TargetObject != null && !MapObject.TargetObject.Dead && User.HasClassWeapon && !User.RidingMount) //ArcherTest - range attack
  10095. {
  10096. if (Functions.InRange(MapObject.MouseObject.CurrentLocation, User.CurrentLocation, Globals.MaxAttackRange))
  10097. {
  10098. if (CMain.Time > GameScene.AttackTime)
  10099. {
  10100. User.QueuedAction = new QueuedAction { Action = MirAction.AttackRange1, Direction = direction, Location = User.CurrentLocation, Params = new List<object>() };
  10101. User.QueuedAction.Params.Add(MapObject.TargetObject.ObjectID);
  10102. User.QueuedAction.Params.Add(MapObject.TargetObject.CurrentLocation);
  10103. }
  10104. }
  10105. else
  10106. {
  10107. if (CMain.Time >= OutputDelay)
  10108. {
  10109. OutputDelay = CMain.Time + 1000;
  10110. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TargetTooFar));
  10111. }
  10112. }
  10113. return;
  10114. }
  10115. if (MapLocation == User.CurrentLocation)
  10116. {
  10117. if (CMain.Time > GameScene.PickUpTime)
  10118. {
  10119. GameScene.PickUpTime = CMain.Time + 200;
  10120. Network.Enqueue(new C.PickUp());
  10121. }
  10122. return;
  10123. }
  10124. //mine
  10125. if (!ValidPoint(Functions.PointMove(User.CurrentLocation, direction, 1)))
  10126. {
  10127. if ((MapObject.User.Equipment[(int)EquipmentSlot.Weapon] != null) && (MapObject.User.Equipment[(int)EquipmentSlot.Weapon].Info.CanMine))
  10128. {
  10129. if (direction != User.Direction)
  10130. {
  10131. User.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = direction, Location = User.CurrentLocation };
  10132. return;
  10133. }
  10134. AutoHit = true;
  10135. return;
  10136. }
  10137. }
  10138. if ((CanWalk(direction, out direction)) && (CheckDoorOpen(Functions.PointMove(User.CurrentLocation, direction, 1))))
  10139. {
  10140. User.QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = direction, Location = Functions.PointMove(User.CurrentLocation, direction, 1) };
  10141. return;
  10142. }
  10143. if (direction != User.Direction)
  10144. {
  10145. User.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = direction, Location = User.CurrentLocation };
  10146. return;
  10147. }
  10148. if (CanFish(direction))
  10149. {
  10150. User.FishingTime = CMain.Time;
  10151. Network.Enqueue(new C.FishingCast { CastOut = true });
  10152. return;
  10153. }
  10154. break;
  10155. case MouseButtons.Right:
  10156. if (MapObject.MouseObject is PlayerObject && MapObject.MouseObject != User && CMain.Ctrl) break;
  10157. if (Settings.NewMove) break;
  10158. if (Functions.InRange(MapLocation, User.CurrentLocation, 2))
  10159. {
  10160. if (direction != User.Direction)
  10161. {
  10162. User.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = direction, Location = User.CurrentLocation };
  10163. }
  10164. return;
  10165. }
  10166. GameScene.CanRun = User.FastRun ? true : GameScene.CanRun;
  10167. if (GameScene.CanRun && CanRun(direction) && CMain.Time > GameScene.NextRunTime && User.HP >= 10 && (!User.Sneaking || (User.Sneaking && User.Sprint))) //slow removed
  10168. {
  10169. int distance = User.RidingMount || User.Sprint && !User.Sneaking ? 3 : 2;
  10170. bool fail = false;
  10171. for (int i = 0; i <= distance; i++)
  10172. {
  10173. if (!CheckDoorOpen(Functions.PointMove(User.CurrentLocation, direction, i)))
  10174. fail = true;
  10175. }
  10176. if (!fail)
  10177. {
  10178. User.QueuedAction = new QueuedAction { Action = MirAction.Running, Direction = direction, Location = Functions.PointMove(User.CurrentLocation, direction, User.RidingMount || (User.Sprint && !User.Sneaking) ? 3 : 2) };
  10179. return;
  10180. }
  10181. }
  10182. if ((CanWalk(direction, out direction)) && (CheckDoorOpen(Functions.PointMove(User.CurrentLocation, direction, 1))))
  10183. {
  10184. User.QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = direction, Location = Functions.PointMove(User.CurrentLocation, direction, 1) };
  10185. return;
  10186. }
  10187. if (direction != User.Direction)
  10188. {
  10189. User.QueuedAction = new QueuedAction { Action = MirAction.Standing, Direction = direction, Location = User.CurrentLocation };
  10190. return;
  10191. }
  10192. break;
  10193. }
  10194. }
  10195. if (AutoPath)
  10196. {
  10197. if (CurrentPath == null || CurrentPath.Count == 0)
  10198. {
  10199. AutoPath = false;
  10200. return;
  10201. }
  10202. var path = GameScene.Scene.MapControl.PathFinder.FindPath(MapObject.User.CurrentLocation, CurrentPath.Last().Location);
  10203. if (path != null && path.Count > 0)
  10204. GameScene.Scene.MapControl.CurrentPath = path;
  10205. else
  10206. {
  10207. AutoPath = false;
  10208. return;
  10209. }
  10210. Node currentNode = CurrentPath.SingleOrDefault(x => User.CurrentLocation == x.Location);
  10211. if (currentNode != null)
  10212. {
  10213. while (true)
  10214. {
  10215. Node first = CurrentPath.First();
  10216. CurrentPath.Remove(first);
  10217. if (first == currentNode)
  10218. break;
  10219. }
  10220. }
  10221. if (CurrentPath.Count > 0)
  10222. {
  10223. MirDirection dir = Functions.DirectionFromPoint(User.CurrentLocation, CurrentPath.First().Location);
  10224. if (GameScene.CanRun && CanRun(dir) && CMain.Time > GameScene.NextRunTime && User.HP >= 10 && CurrentPath.Count > (User.RidingMount ? 2 : 1))
  10225. {
  10226. User.QueuedAction = new QueuedAction { Action = MirAction.Running, Direction = dir, Location = Functions.PointMove(User.CurrentLocation, dir, User.RidingMount ? 3 : 2) };
  10227. return;
  10228. }
  10229. if (CanWalk(dir))
  10230. {
  10231. User.QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = dir, Location = Functions.PointMove(User.CurrentLocation, dir, 1) };
  10232. return;
  10233. }
  10234. }
  10235. }
  10236. if (MapObject.TargetObject == null || MapObject.TargetObject.Dead) return;
  10237. if (((!MapObject.TargetObject.Name.EndsWith(")") && !(MapObject.TargetObject is PlayerObject)) || !CMain.Shift) &&
  10238. (MapObject.TargetObject.Name.EndsWith(")") || !(MapObject.TargetObject is MonsterObject))) return;
  10239. if (Functions.InRange(MapObject.TargetObject.CurrentLocation, User.CurrentLocation, 1)) return;
  10240. if (User.Class == MirClass.Archer && User.HasClassWeapon && (MapObject.TargetObject is MonsterObject || MapObject.TargetObject is PlayerObject)) return; //ArcherTest - stop walking
  10241. direction = Functions.DirectionFromPoint(User.CurrentLocation, MapObject.TargetObject.CurrentLocation);
  10242. if (!CanWalk(direction, out direction)) return;
  10243. User.QueuedAction = new QueuedAction { Action = MirAction.Walking, Direction = direction, Location = Functions.PointMove(User.CurrentLocation, direction, 1) };
  10244. }
  10245. public void UseMagic(ClientMagic magic, UserObject actor)
  10246. {
  10247. if (CMain.Time < GameScene.SpellTime || actor.Poison.HasFlag(PoisonType.Stun))
  10248. {
  10249. actor.ClearMagic();
  10250. return;
  10251. }
  10252. if ((CMain.Time <= magic.CastTime + magic.Delay))
  10253. {
  10254. if (CMain.Time >= OutputDelay)
  10255. {
  10256. OutputDelay = CMain.Time + 1000;
  10257. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CannotCastSpellSeconds), magic.Name,
  10258. ((magic.CastTime + magic.Delay) - CMain.Time - 1) / 1000 + 1));
  10259. }
  10260. actor.ClearMagic();
  10261. return;
  10262. }
  10263. int cost = magic.Level * magic.LevelCost + magic.BaseCost;
  10264. if (magic.Spell == Spell.Teleport || magic.Spell == Spell.Blink || magic.Spell == Spell.StormEscape)
  10265. {
  10266. if (actor.Stats[Stat.TeleportManaPenaltyPercent] > 0)
  10267. {
  10268. cost += (cost * actor.Stats[Stat.TeleportManaPenaltyPercent]) / 100;
  10269. }
  10270. }
  10271. if (actor.Stats[Stat.ManaPenaltyPercent] > 0)
  10272. {
  10273. cost += (cost * actor.Stats[Stat.ManaPenaltyPercent]) / 100;
  10274. }
  10275. if (cost > actor.MP)
  10276. {
  10277. if (CMain.Time >= OutputDelay)
  10278. {
  10279. OutputDelay = CMain.Time + 1000;
  10280. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LowMana));
  10281. }
  10282. actor.ClearMagic();
  10283. return;
  10284. }
  10285. //bool isTargetSpell = true;
  10286. MapObject target = null;
  10287. //Targeting
  10288. switch (magic.Spell)
  10289. {
  10290. case Spell.FireBall:
  10291. case Spell.GreatFireBall:
  10292. case Spell.ElectricShock:
  10293. case Spell.Poisoning:
  10294. case Spell.ThunderBolt:
  10295. case Spell.FlameDisruptor:
  10296. case Spell.SoulFireBall:
  10297. case Spell.TurnUndead:
  10298. case Spell.FrostCrunch:
  10299. case Spell.Vampirism:
  10300. case Spell.Revelation:
  10301. case Spell.Entrapment:
  10302. case Spell.Hallucination:
  10303. case Spell.DarkBody:
  10304. case Spell.FireBounce:
  10305. case Spell.MeteorShower:
  10306. if (actor.NextMagicObject != null)
  10307. {
  10308. if (!actor.NextMagicObject.Dead && actor.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant)
  10309. target = actor.NextMagicObject;
  10310. }
  10311. if (target == null) target = MapObject.MagicObject;
  10312. if (target != null && target.Race == ObjectType.Monster) MapObject.MagicObjectID = target.ObjectID;
  10313. break;
  10314. case Spell.StraightShot:
  10315. case Spell.DoubleShot:
  10316. case Spell.ElementalShot:
  10317. case Spell.DelayedExplosion:
  10318. case Spell.BindingShot:
  10319. case Spell.VampireShot:
  10320. case Spell.PoisonShot:
  10321. case Spell.CrippleShot:
  10322. case Spell.NapalmShot:
  10323. case Spell.SummonVampire:
  10324. case Spell.SummonToad:
  10325. case Spell.SummonSnakes:
  10326. if (!actor.HasClassWeapon)
  10327. {
  10328. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MustWearBowForSkill));
  10329. actor.ClearMagic();
  10330. return;
  10331. }
  10332. if (actor.NextMagicObject != null)
  10333. {
  10334. if (!actor.NextMagicObject.Dead && actor.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant)
  10335. target = actor.NextMagicObject;
  10336. }
  10337. if (target == null) target = MapObject.MagicObject;
  10338. if (target != null && target.Race == ObjectType.Monster) MapObject.MagicObjectID = target.ObjectID;
  10339. break;
  10340. case Spell.Stonetrap:
  10341. if (!User.HasClassWeapon)
  10342. {
  10343. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MustWearBowForSkill));
  10344. User.ClearMagic();
  10345. return;
  10346. }
  10347. if (User.NextMagicObject != null)
  10348. {
  10349. if (!User.NextMagicObject.Dead && User.NextMagicObject.Race != ObjectType.Item && User.NextMagicObject.Race != ObjectType.Merchant)
  10350. target = User.NextMagicObject;
  10351. }
  10352. //if(magic.Spell == Spell.ElementalShot)
  10353. //{
  10354. // isTargetSpell = User.HasElements;
  10355. //}
  10356. //switch(magic.Spell)
  10357. //{
  10358. // case Spell.SummonVampire:
  10359. // case Spell.SummonToad:
  10360. // case Spell.SummonSnakes:
  10361. // isTargetSpell = false;
  10362. // break;
  10363. //}
  10364. break;
  10365. case Spell.Purification:
  10366. case Spell.Healing:
  10367. case Spell.UltimateEnhancer:
  10368. case Spell.EnergyShield:
  10369. case Spell.PetEnhancer:
  10370. if (actor.NextMagicObject != null)
  10371. {
  10372. if (!actor.NextMagicObject.Dead && actor.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant && !(actor.NextMagicObject is MonsterObject monster && monster.MasterObjectId == 0))
  10373. target = actor.NextMagicObject;
  10374. }
  10375. if (target == null) target = User;
  10376. break;
  10377. case Spell.FireBang:
  10378. case Spell.MassHiding:
  10379. case Spell.FireWall:
  10380. case Spell.TrapHexagon:
  10381. case Spell.HealingCircle:
  10382. case Spell.CatTongue:
  10383. if (actor.NextMagicObject != null)
  10384. {
  10385. if (!actor.NextMagicObject.Dead && actor.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant)
  10386. target = actor.NextMagicObject;
  10387. }
  10388. break;
  10389. case Spell.PoisonCloud:
  10390. if (actor.NextMagicObject != null)
  10391. {
  10392. if (!actor.NextMagicObject.Dead && actor.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant)
  10393. target = actor.NextMagicObject;
  10394. }
  10395. break;
  10396. case Spell.Blizzard:
  10397. case Spell.MeteorStrike:
  10398. if (actor.NextMagicObject != null)
  10399. {
  10400. if (!actor.NextMagicObject.Dead && actor.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant)
  10401. target = actor.NextMagicObject;
  10402. }
  10403. break;
  10404. case Spell.Reincarnation:
  10405. if (actor == Hero && actor.NextMagicObject == null)
  10406. actor.NextMagicObject = User;
  10407. if (actor.NextMagicObject != null)
  10408. {
  10409. if (actor.NextMagicObject.Dead && actor.NextMagicObject.Race == ObjectType.Player)
  10410. target = actor.NextMagicObject;
  10411. }
  10412. break;
  10413. case Spell.Trap:
  10414. if (actor.NextMagicObject != null)
  10415. {
  10416. if (!actor.NextMagicObject.Dead && User.NextMagicObject.Race != ObjectType.Item && actor.NextMagicObject.Race != ObjectType.Merchant)
  10417. target = actor.NextMagicObject;
  10418. }
  10419. break;
  10420. case Spell.FlashDash:
  10421. if (actor.GetMagic(Spell.FlashDash).Level <= 1 && actor.IsDashAttack() == false)
  10422. {
  10423. actor.ClearMagic();
  10424. return;
  10425. }
  10426. //isTargetSpell = false;
  10427. break;
  10428. default:
  10429. //isTargetSpell = false;
  10430. break;
  10431. }
  10432. MirDirection dir = (target == null || target == User) ? actor.NextMagicDirection : Functions.DirectionFromPoint(actor.CurrentLocation, target.CurrentLocation);
  10433. Point location = target != null ? target.CurrentLocation : actor.NextMagicLocation;
  10434. uint targetID = target != null ? target.ObjectID : 0;
  10435. if (magic.Spell == Spell.FlashDash)
  10436. dir = actor.Direction;
  10437. if ((magic.Range != 0) && (!Functions.InRange(actor.CurrentLocation, location, magic.Range)))
  10438. {
  10439. if (CMain.Time >= OutputDelay)
  10440. {
  10441. OutputDelay = CMain.Time + 1000;
  10442. GameScene.Scene.OutputMessage(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TargetTooFar));
  10443. }
  10444. actor.ClearMagic();
  10445. return;
  10446. }
  10447. GameScene.LogTime = CMain.Time + Globals.LogDelay;
  10448. if (actor == User)
  10449. {
  10450. User.QueuedAction = new QueuedAction { Action = MirAction.Spell, Direction = dir, Location = User.CurrentLocation, Params = new List<object>() };
  10451. User.QueuedAction.Params.Add(magic.Spell);
  10452. User.QueuedAction.Params.Add(targetID);
  10453. User.QueuedAction.Params.Add(location);
  10454. User.QueuedAction.Params.Add(magic.Level);
  10455. }
  10456. else
  10457. {
  10458. Network.Enqueue(new C.Magic { ObjectID = actor.ObjectID, Spell = magic.Spell, Direction = dir, TargetID = targetID, Location = location, SpellTargetLock = CMain.SpellTargetLock });
  10459. }
  10460. }
  10461. public static MirDirection MouseDirection(float ratio = 45F) //22.5 = 16
  10462. {
  10463. Point p = new Point(MouseLocation.X / CellWidth, MouseLocation.Y / CellHeight);
  10464. if (Functions.InRange(new Point(OffSetX, OffSetY), p, 2))
  10465. return Functions.DirectionFromPoint(new Point(OffSetX, OffSetY), p);
  10466. PointF c = new PointF(OffSetX * CellWidth + CellWidth / 2F, OffSetY * CellHeight + CellHeight / 2F);
  10467. PointF a = new PointF(c.X, 0);
  10468. PointF b = MouseLocation;
  10469. float bc = (float)Distance(c, b);
  10470. float ac = bc;
  10471. b.Y -= c.Y;
  10472. c.Y += bc;
  10473. b.Y += bc;
  10474. float ab = (float)Distance(b, a);
  10475. double x = (ac * ac + bc * bc - ab * ab) / (2 * ac * bc);
  10476. double angle = Math.Acos(x);
  10477. angle *= 180 / Math.PI;
  10478. if (MouseLocation.X < c.X) angle = 360 - angle;
  10479. angle += ratio / 2;
  10480. if (angle > 360) angle -= 360;
  10481. return (MirDirection)(angle / ratio);
  10482. }
  10483. public static int Direction16(Point source, Point destination)
  10484. {
  10485. PointF c = new PointF(source.X, source.Y);
  10486. PointF a = new PointF(c.X, 0);
  10487. PointF b = new PointF(destination.X, destination.Y);
  10488. float bc = (float)Distance(c, b);
  10489. float ac = bc;
  10490. b.Y -= c.Y;
  10491. c.Y += bc;
  10492. b.Y += bc;
  10493. float ab = (float)Distance(b, a);
  10494. double x = (ac * ac + bc * bc - ab * ab) / (2 * ac * bc);
  10495. double angle = Math.Acos(x);
  10496. angle *= 180 / Math.PI;
  10497. if (destination.X < c.X) angle = 360 - angle;
  10498. angle += 11.25F;
  10499. if (angle > 360) angle -= 360;
  10500. return (int)(angle / 22.5F);
  10501. }
  10502. public static double Distance(PointF p1, PointF p2)
  10503. {
  10504. double x = p2.X - p1.X;
  10505. double y = p2.Y - p1.Y;
  10506. return Math.Sqrt(x * x + y * y);
  10507. }
  10508. public bool EmptyCell(Point p)
  10509. {
  10510. if ((M2CellInfo[p.X, p.Y].BackImage & 0x20000000) != 0 || (M2CellInfo[p.X, p.Y].FrontImage & 0x8000) != 0)
  10511. return false;
  10512. foreach (var ob in Objects.Values)
  10513. if (ob.CurrentLocation == p && ob.Blocking)
  10514. return false;
  10515. return true;
  10516. }
  10517. private bool CanWalk(MirDirection dir)
  10518. {
  10519. return EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 1)) && !User.InTrapRock;
  10520. }
  10521. private bool CanWalk(MirDirection dir, out MirDirection outDir)
  10522. {
  10523. outDir = dir;
  10524. if (User.InTrapRock) return false;
  10525. if (EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 1)))
  10526. return true;
  10527. dir = Functions.NextDir(outDir);
  10528. if (EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 1)))
  10529. {
  10530. outDir = dir;
  10531. return true;
  10532. }
  10533. dir = Functions.PreviousDir(outDir);
  10534. if (EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 1)))
  10535. {
  10536. outDir = dir;
  10537. return true;
  10538. }
  10539. return false;
  10540. }
  10541. private bool CheckDoorOpen(Point p)
  10542. {
  10543. if (M2CellInfo[p.X, p.Y].DoorIndex == 0) return true;
  10544. Door DoorInfo = GetDoor(M2CellInfo[p.X, p.Y].DoorIndex);
  10545. if (DoorInfo == null) return false;//if the door doesnt exist then it isnt even being shown on screen (and cant be open lol)
  10546. if ((DoorInfo.DoorState == DoorState.Closed) || (DoorInfo.DoorState == DoorState.Closing))
  10547. {
  10548. if (CMain.Time > _doorTime)
  10549. {
  10550. _doorTime = CMain.Time + 4000;
  10551. Network.Enqueue(new C.Opendoor() { DoorIndex = DoorInfo.index });
  10552. }
  10553. return false;
  10554. }
  10555. if ((DoorInfo.DoorState == DoorState.Open) && (DoorInfo.LastTick + 4000 > CMain.Time))
  10556. {
  10557. if (CMain.Time > _doorTime)
  10558. {
  10559. _doorTime = CMain.Time + 4000;
  10560. Network.Enqueue(new C.Opendoor() { DoorIndex = DoorInfo.index });
  10561. }
  10562. }
  10563. return true;
  10564. }
  10565. private long _doorTime = 0;
  10566. private bool CanRun(MirDirection dir)
  10567. {
  10568. if (User.InTrapRock) return false;
  10569. if (User.CurrentBagWeight > User.Stats[Stat.BagWeight]) return false;
  10570. if (User.CurrentWearWeight > User.Stats[Stat.BagWeight]) return false;
  10571. if (CanWalk(dir) && EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 2)))
  10572. {
  10573. if (User.RidingMount || User.Sprint && !User.Sneaking)
  10574. {
  10575. return EmptyCell(Functions.PointMove(User.CurrentLocation, dir, 3));
  10576. }
  10577. return true;
  10578. }
  10579. return false;
  10580. }
  10581. private bool CanRideAttack()
  10582. {
  10583. if (GameScene.User.RidingMount)
  10584. {
  10585. UserItem item = GameScene.User.Equipment[(int)EquipmentSlot.Mount];
  10586. if (item == null || item.Slots.Length < 4 || item.Slots[(int)MountSlot.Bells] == null) return false;
  10587. }
  10588. return true;
  10589. }
  10590. public bool CanFish(MirDirection dir)
  10591. {
  10592. if (!GameScene.User.HasFishingRod || GameScene.User.FishingTime + 1000 > CMain.Time) return false;
  10593. if (GameScene.User.CurrentAction != MirAction.Standing) return false;
  10594. if (GameScene.User.Direction != dir) return false;
  10595. if (GameScene.User.TransformType >= 6 && GameScene.User.TransformType <= 9) return false;
  10596. Point point = Functions.PointMove(User.CurrentLocation, dir, 3);
  10597. if (!M2CellInfo[point.X, point.Y].FishingCell) return false;
  10598. return true;
  10599. }
  10600. public bool CanFly(Point target)
  10601. {
  10602. Point location = User.CurrentLocation;
  10603. while (location != target)
  10604. {
  10605. MirDirection dir = Functions.DirectionFromPoint(location, target);
  10606. location = Functions.PointMove(location, dir, 1);
  10607. if (location.X < 0 || location.Y < 0 || location.X >= GameScene.Scene.MapControl.Width || location.Y >= GameScene.Scene.MapControl.Height) return false;
  10608. if (!GameScene.Scene.MapControl.ValidPoint(location)) return false;
  10609. }
  10610. return true;
  10611. }
  10612. public bool ValidPoint(Point p)
  10613. {
  10614. //GameScene.Scene.ChatDialog.ReceiveChat(string.Format("cell: {0}", (M2CellInfo[p.X, p.Y].BackImage & 0x20000000)), ChatType.Hint);
  10615. return (M2CellInfo[p.X, p.Y].BackImage & 0x20000000) == 0;
  10616. }
  10617. public bool HasTarget(Point p)
  10618. {
  10619. foreach (var ob in Objects.Values)
  10620. if (ob.CurrentLocation == p && ob.Blocking)
  10621. return true;
  10622. return false;
  10623. }
  10624. public bool CanHalfMoon(Point p, MirDirection d)
  10625. {
  10626. d = Functions.PreviousDir(d);
  10627. for (int i = 0; i < 4; i++)
  10628. {
  10629. if (HasTarget(Functions.PointMove(p, d, 1))) return true;
  10630. d = Functions.NextDir(d);
  10631. }
  10632. return false;
  10633. }
  10634. public bool CanCrossHalfMoon(Point p)
  10635. {
  10636. MirDirection dir = MirDirection.Up;
  10637. for (int i = 0; i < 8; i++)
  10638. {
  10639. if (HasTarget(Functions.PointMove(p, dir, 1))) return true;
  10640. dir = Functions.NextDir(dir);
  10641. }
  10642. return false;
  10643. }
  10644. #region Disposable
  10645. protected override void Dispose(bool disposing)
  10646. {
  10647. if (disposing)
  10648. {
  10649. Objects.Clear();
  10650. MapButtons = 0;
  10651. MouseLocation = Point.Empty;
  10652. InputDelay = 0;
  10653. NextAction = 0;
  10654. M2CellInfo = null;
  10655. Width = 0;
  10656. Height = 0;
  10657. Index = 0;
  10658. FileName = String.Empty;
  10659. Title = String.Empty;
  10660. MiniMap = 0;
  10661. BigMap = 0;
  10662. Lights = 0;
  10663. FloorValid = false;
  10664. LightsValid = false;
  10665. MapDarkLight = 0;
  10666. Music = 0;
  10667. AnimationCount = 0;
  10668. Effects.Clear();
  10669. }
  10670. base.Dispose(disposing);
  10671. }
  10672. #endregion
  10673. public void UpdateWeather()
  10674. {
  10675. for (int i = GameScene.Scene.ParticleEngines.Count - 1; i > 0; i--)
  10676. GameScene.Scene.ParticleEngines[i].Dispose();
  10677. GameScene.Scene.ParticleEngines.Clear();
  10678. List<ParticleImageInfo> textures = new List<ParticleImageInfo>();
  10679. foreach (WeatherSetting itemWeather in Enum.GetValues(typeof(WeatherSetting)).Cast<object>().ToArray())
  10680. {
  10681. //if not enabled skip
  10682. if ((Weather & itemWeather) != itemWeather)
  10683. continue;
  10684. //foreach (WeatherSetting itemWeather in Weather)
  10685. //{
  10686. switch (itemWeather)
  10687. {
  10688. case WeatherSetting.Leaves:
  10689. textures = new List<ParticleImageInfo>();
  10690. textures.Add(new ParticleImageInfo(Libraries.Weather, 359, 170, 50));
  10691. textures.Add(new ParticleImageInfo(Libraries.Weather, 531, 55, 50));
  10692. textures.Add(new ParticleImageInfo(Libraries.Weather, 587, 200, 50));
  10693. ParticleEngine LeavesEngine2 = new ParticleEngine(textures, new Vector2(2f, 0), ParticleType.Leaves);
  10694. Vector2 lVelocity = new Vector2(0F, 0F);
  10695. for (int y = 512 * -1; y < Settings.ScreenHeight + 512; y += 512)
  10696. for (int x = 512 * -1; x < Settings.ScreenWidth + 512; x += 512)
  10697. {
  10698. Particle part = LeavesEngine2.GenerateNewParticle(ParticleType.Leaves);
  10699. part.Position = new Vector2(x, y);
  10700. part.Velocity = lVelocity;
  10701. }
  10702. LeavesEngine2.GenerateParticles = false;
  10703. GameScene.Scene.ParticleEngines.Add(LeavesEngine2);
  10704. break;
  10705. case WeatherSetting.FireyLeaves:
  10706. textures = new List<ParticleImageInfo>();
  10707. textures.Add(new ParticleImageInfo(Libraries.Weather, 359, 170, 50));
  10708. textures.Add(new ParticleImageInfo(Libraries.Weather, 531, 55, 50));
  10709. textures.Add(new ParticleImageInfo(Libraries.Weather, 587, 200, 50));
  10710. ParticleEngine FLeavesEngine2 = new ParticleEngine(textures, new Vector2(2f, 0), ParticleType.FireyLeaves);
  10711. Vector2 FlVelocity = new Vector2(0F, 0F);
  10712. for (int y = 512 * -1; y < Settings.ScreenHeight + 512; y += 512)
  10713. for (int x = 512 * -1; x < Settings.ScreenWidth + 512; x += 512)
  10714. {
  10715. Particle part = FLeavesEngine2.GenerateNewParticle(ParticleType.FireyLeaves);
  10716. part.Position = new Vector2(x, y);
  10717. part.Velocity = FlVelocity;
  10718. }
  10719. FLeavesEngine2.GenerateParticles = false;
  10720. GameScene.Scene.ParticleEngines.Add(FLeavesEngine2);
  10721. break;
  10722. case WeatherSetting.Rain:
  10723. textures = new List<ParticleImageInfo>();
  10724. //Rain
  10725. textures.Add(new ParticleImageInfo(Libraries.Weather, 164, 150, 50));
  10726. ParticleEngine RainEngine2 = new ParticleEngine(textures, new Vector2(2f, 0), ParticleType.Rain);
  10727. Vector2 rsevelocity = new Vector2(0F, 0F);
  10728. var xVar = 512;
  10729. var yVar = 512;
  10730. for (int y = yVar * -1; y < Settings.ScreenHeight + yVar; y += yVar)
  10731. for (int x = xVar * -1; x < Settings.ScreenWidth + xVar; x += xVar)
  10732. {
  10733. Particle part = RainEngine2.GenerateNewParticle(ParticleType.Rain);
  10734. part.Position = new Vector2(x, y);
  10735. part.Velocity = rsevelocity;
  10736. }
  10737. RainEngine2.GenerateParticles = false;
  10738. GameScene.Scene.ParticleEngines.Add(RainEngine2);
  10739. break;
  10740. case WeatherSetting.Snow:
  10741. textures = new List<ParticleImageInfo>();
  10742. textures.Add(new ParticleImageInfo(Libraries.Weather, 43, 20, 50));
  10743. ParticleEngine RainEngine = new ParticleEngine(textures, new Vector2(0, 0), ParticleType.Snow);
  10744. Vector2 rsvelocity = new Vector2(1F, -1F);
  10745. for (int y = -400; y < Settings.ScreenHeight + 400; y += 400)
  10746. for (int x = -400; x < Settings.ScreenWidth + 400; x += 400)
  10747. {
  10748. Particle part = RainEngine.GenerateNewParticle(ParticleType.Snow);
  10749. part.Position = new Vector2(x, y);
  10750. part.Velocity = rsvelocity;
  10751. }
  10752. RainEngine.GenerateParticles = false;
  10753. GameScene.Scene.ParticleEngines.Add(RainEngine);
  10754. break;
  10755. case WeatherSetting.Fog:
  10756. List<ParticleImageInfo> ftextures = new List<ParticleImageInfo>();
  10757. ftextures.Add(new ParticleImageInfo(Libraries.Weather, 0));
  10758. ParticleEngine fengine = new ParticleEngine(ftextures, new Vector2(0, 0), ParticleType.Fog);
  10759. fengine.UpdateDelay = TimeSpan.FromMilliseconds(20);
  10760. Vector2 fvelocity = new Vector2(2F, -2F);
  10761. for (int y = -512; y < Settings.ScreenHeight + 512; y += 512)
  10762. for (int x = -512; x < Settings.ScreenWidth + 512; x += 512)
  10763. {
  10764. Particle part = fengine.GenerateNewParticle(ParticleType.Fog);
  10765. part.Position = new Vector2(x, y);
  10766. part.Velocity = fvelocity;
  10767. }
  10768. fengine.GenerateParticles = false;
  10769. GameScene.Scene.ParticleEngines.Add(fengine);
  10770. break;
  10771. case WeatherSetting.RedEmber:
  10772. var rtextures = new List<ParticleImageInfo>();
  10773. rtextures.Add(new ParticleImageInfo(Libraries.Weather, 1, 9, 150));
  10774. var rengine = new ParticleEngine(rtextures, new Vector2(0, 0), ParticleType.RedFogEmber);
  10775. GameScene.Scene.ParticleEngines.Add(rengine);
  10776. break;
  10777. case WeatherSetting.WhiteEmber:
  10778. textures = new List<ParticleImageInfo>();
  10779. textures.Add(new ParticleImageInfo(Libraries.Weather, 1, 9, 150));
  10780. var whiteEmberEngine = new ParticleEngine(textures, new Vector2(0, 0), ParticleType.WhiteEmber);
  10781. GameScene.Scene.ParticleEngines.Add(whiteEmberEngine);
  10782. break;
  10783. case WeatherSetting.PurpleLeaves:
  10784. textures = new List<ParticleImageInfo>();
  10785. textures.Add(new ParticleImageInfo(Libraries.Weather, 359, 170, 50));
  10786. textures.Add(new ParticleImageInfo(Libraries.Weather, 531, 55, 50));
  10787. textures.Add(new ParticleImageInfo(Libraries.Weather, 587, 200, 50));
  10788. //textures.Add(new ParticleImageInfo(Libraries.Weather, 10, 20, 50));
  10789. var pEmberEngine = new ParticleEngine(textures, new Vector2(0, 0), ParticleType.PurpleLeaves);
  10790. for (int y = 512 * -1; y < Settings.ScreenHeight + 512; y += 512)
  10791. for (int x = 512 * -1; x < Settings.ScreenWidth + 512; x += 512)
  10792. {
  10793. Particle part = pEmberEngine.GenerateNewParticle(ParticleType.PurpleLeaves);
  10794. part.Position = new Vector2(x, y);
  10795. part.Velocity = new Vector2(0, 0);
  10796. }
  10797. pEmberEngine.GenerateParticles = false;
  10798. GameScene.Scene.ParticleEngines.Add(pEmberEngine);
  10799. break;
  10800. case WeatherSetting.YellowEmber:
  10801. textures = new List<ParticleImageInfo>();
  10802. textures.Add(new ParticleImageInfo(Libraries.Weather, 1, 9, 100));
  10803. var yellowEmberEngine = new ParticleEngine(textures, new Vector2(0, 0), ParticleType.YellowEmber);
  10804. GameScene.Scene.ParticleEngines.Add(yellowEmberEngine);
  10805. break;
  10806. case WeatherSetting.FireParticle:
  10807. textures = new List<ParticleImageInfo>();
  10808. //textures.Add(new ParticleImageInfo(Libraries.StateEffect, 640)); << TODO - Win
  10809. // textures.Add(new ParticleImageInfo(Libraries.Prguse4, 642));
  10810. var fEmberEngine = new ParticleEngine(textures, new Vector2(0, 0), ParticleType.Bird);
  10811. GameScene.Scene.ParticleEngines.Add(fEmberEngine);
  10812. break;
  10813. }
  10814. }
  10815. }
  10816. public void RemoveObject(MapObject ob)
  10817. {
  10818. M2CellInfo[ob.MapLocation.X, ob.MapLocation.Y].RemoveObject(ob);
  10819. }
  10820. public void AddObject(MapObject ob)
  10821. {
  10822. M2CellInfo[ob.MapLocation.X, ob.MapLocation.Y].AddObject(ob);
  10823. }
  10824. public MapObject FindObject(uint ObjectID, int x, int y)
  10825. {
  10826. return M2CellInfo[x, y].FindObject(ObjectID);
  10827. }
  10828. public void SortObject(MapObject ob)
  10829. {
  10830. M2CellInfo[ob.MapLocation.X, ob.MapLocation.Y].Sort();
  10831. }
  10832. public Door GetDoor(byte Index)
  10833. {
  10834. for (int i = 0; i < Doors.Count; i++)
  10835. {
  10836. if (Doors[i].index == Index)
  10837. return Doors[i];
  10838. }
  10839. return null;
  10840. }
  10841. public void Processdoors()
  10842. {
  10843. for (int i = 0; i < Doors.Count; i++)
  10844. {
  10845. if ((Doors[i].DoorState == DoorState.Opening) || (Doors[i].DoorState == DoorState.Closing))
  10846. {
  10847. if (Doors[i].LastTick + 50 < CMain.Time)
  10848. {
  10849. Doors[i].LastTick = CMain.Time;
  10850. Doors[i].ImageIndex++;
  10851. if (Doors[i].ImageIndex == 1)//change the 1 if you want to animate doors opening/closing
  10852. {
  10853. Doors[i].ImageIndex = 0;
  10854. Doors[i].DoorState = (DoorState)Enum.ToObject(typeof(DoorState), ((byte)++Doors[i].DoorState % 4));
  10855. }
  10856. FloorValid = false;
  10857. }
  10858. }
  10859. if (Doors[i].DoorState == DoorState.Open)
  10860. {
  10861. if (Doors[i].LastTick + 5000 < CMain.Time)
  10862. {
  10863. Doors[i].LastTick = CMain.Time;
  10864. Doors[i].DoorState = DoorState.Closing;
  10865. FloorValid = false;
  10866. }
  10867. }
  10868. }
  10869. }
  10870. public void OpenDoor(byte Index, bool closed)
  10871. {
  10872. Door Info = GetDoor(Index);
  10873. if (Info == null) return;
  10874. Info.DoorState = (closed ? DoorState.Closing : Info.DoorState == DoorState.Open ? DoorState.Open : DoorState.Opening);
  10875. Info.ImageIndex = 0;
  10876. Info.LastTick = CMain.Time;
  10877. }
  10878. }
  10879. }